diff --git a/reactos/Makefile b/reactos/Makefile
index 3a1f685749c..f31ae65724a 100644
--- a/reactos/Makefile
+++ b/reactos/Makefile
@@ -26,23 +26,21 @@ $(ROS_INTERMEDIATE):
${nmkdir} $(ROS_INTERMEDIATE)
endif
-Makefile.auto: rmkdir buildno wmc rbuild
- tools$(SEP)rbuild$(SEP)rbuild$(EXEPOSTFIX) mingw
-# $(MAKE) $(MAKECMDGOALS)
+include tools/Makefile
+-include Makefile.auto
-init:: \
+Makefile.auto: $(RMKDIR_TARGET) $(BUILDNO_TARGET) $(NCI_SERVICE_FILES) $(WMC_TARGET) $(RBUILD_TARGET)
+ tools$(SEP)rbuild$(SEP)rbuild$(EXEPOSTFIX) mingw
+ $(MAKE) $(MAKECMDGOALS)
+
+init: \
include$(SEP)reactos$(SEP)bugcodes.h \
ntoskrnl$(SEP)bugcodes.rc \
include$(SEP)reactos$(SEP)errcodes.h \
lib$(SEP)kernel32$(SEP)errcodes.rc
-include$(SEP)reactos$(SEP)bugcodes.h ntoskrnl$(SEP)bugcodes.rc: ntoskrnl$(SEP)ntoskrnl.mc
- $(WMC_TARGET) -H include$(SEP)reactos$(SEP)bugcodes.h -o ntoskrnl$(SEP)bugcodes.rc bugcodes$(SEP)ntoskrnl.mc
+include$(SEP)reactos$(SEP)bugcodes.h ntoskrnl$(SEP)bugcodes.rc: $(WMC_TARGET) ntoskrnl$(SEP)ntoskrnl.mc
+ $(WMC_TARGET) -H include$(SEP)reactos$(SEP)bugcodes.h -o ntoskrnl$(SEP)bugcodes.rc ntoskrnl$(SEP)ntoskrnl.mc
-include$(SEP)reactos$(SEP)errcodes.h lib$(SEP)kernel32$(SEP)errcodes.rc: lib$(SEP)kernel32$(SEP)kernel32.mc
+include$(SEP)reactos$(SEP)errcodes.h lib$(SEP)kernel32$(SEP)errcodes.rc: $(WMC_TARGET) lib$(SEP)kernel32$(SEP)kernel32.mc
$(WMC_TARGET) -H include$(SEP)reactos$(SEP)errcodes.h -o lib$(SEP)kernel32$(SEP)errcodes.rc lib$(SEP)kernel32$(SEP)kernel32.mc
-
-include tools/Makefile
-include tools/rbuild/makefile
-
-#-include Makefile.auto
diff --git a/reactos/ReactOS.xml b/reactos/ReactOS.xml
index 019f3a9771c..954593c4e11 100644
--- a/reactos/ReactOS.xml
+++ b/reactos/ReactOS.xml
@@ -36,14 +36,6 @@
-
-
-
-
-
-
-
-
diff --git a/reactos/apps/utils/Makefile b/reactos/apps/utils/Makefile
index 43d5be5c94b..92a1d5157f1 100644
--- a/reactos/apps/utils/Makefile
+++ b/reactos/apps/utils/Makefile
@@ -11,7 +11,7 @@ include $(PATH_TO_TOP)/rules.mak
# cabman cat net objdir partinfo pice ps sc stats
UTIL_APPS = cat objdir partinfo pnpdump sc shutdown stats tickcount consw rundll32 ps
-UTIL_NET_APPS = arp finger ipconfig netstat ping route telnet whois
+UTIL_NET_APPS = arp finger ftp ipconfig netstat ping route telnet whois
all: $(UTIL_APPS) $(UTIL_NET_APPS)
diff --git a/reactos/apps/utils/net/directory.xml b/reactos/apps/utils/net/directory.xml
index 57b9d6a1365..a0b63207a20 100644
--- a/reactos/apps/utils/net/directory.xml
+++ b/reactos/apps/utils/net/directory.xml
@@ -4,6 +4,9 @@
+
+
+
@@ -13,6 +16,9 @@
+
+
+
diff --git a/reactos/apps/utils/net/ftp/cmds.c b/reactos/apps/utils/net/ftp/cmds.c
new file mode 100644
index 00000000000..c88e3a0f7f8
--- /dev/null
+++ b/reactos/apps/utils/net/ftp/cmds.c
@@ -0,0 +1,2376 @@
+/*
+ * Copyright (c) 1985, 1989 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the University of California, Berkeley. The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)cmds.c 5.18 (Berkeley) 4/20/89";
+#endif /* not lint */
+
+/*
+ * FTP User Program -- Command Routines.
+ */
+//#include
+//#include
+#include
+#if !defined(WIN32)
+#include
+#include
+#include
+#include
+#else
+#include
+#endif
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "ftp_var.h"
+#include "pathnames.h"
+#include "prototypes.h"
+
+extern char *globerr;
+extern char **glob();
+extern char home[];
+extern char *remglob();
+extern char *getenv();
+extern int allbinary;
+extern off_t restart_point;
+extern char reply_string[];
+
+char *mname;
+jmp_buf jabort;
+char *dotrans(), *domap();
+
+extern short portnum;
+extern char *hostname;
+extern int autologin;
+/*
+ * Connect to peer server and
+ * auto-login, if possible.
+ */
+void setpeer(int argc, char *argv[])
+{
+ char *host, *hookup();
+
+ if (connected) {
+ printf("Already connected to %s, use close first.\n",
+ hostname);
+ (void) fflush(stdout);
+ code = -1;
+ return;
+ }
+ if (argc < 2) {
+ (void) strcat(line, " ");
+ printf("(to) ");
+ (void) fflush(stdout);
+ (void) gets(&line[strlen(line)]);
+ makeargv();
+ argc = margc;
+ argv = margv;
+ }
+ if (argc > 3) {
+ printf("usage: %s host-name [port]\n", argv[0]);
+ (void) fflush(stdout);
+ code = -1;
+ return;
+ }
+ if (argc > 2) {
+ portnum = atoi(argv[2]);
+ if (portnum <= 0) {
+ printf("%s: bad port number-- %s\n", argv[1], argv[2]);
+ printf ("usage: %s host-name [port]\n", argv[0]);
+ (void) fflush(stdout);
+ code = -1;
+ return;
+ }
+ portnum = htons(portnum);
+ }
+ host = hookup(argv[1], portnum);
+ if (host) {
+#if defined(unix) && NBBY == 8
+ int overbose;
+#endif
+ connected = 1;
+ if (autologin)
+ (void) login(argv[1]);
+
+#if defined(unix) && NBBY == 8
+/*
+ * this ifdef is to keep someone form "porting" this to an incompatible
+ * system and not checking this out. This way they have to think about it.
+ */
+ overbose = verbose;
+ if (debug == 0)
+ verbose = -1;
+ allbinary = 0;
+ if (command("SYST") == COMPLETE && overbose) {
+ register char *cp, c;
+ cp = index(reply_string+4, ' ');
+ if (cp == NULL)
+ cp = index(reply_string+4, '\r');
+ if (cp) {
+ if (cp[-1] == '.')
+ cp--;
+ c = *cp;
+ *cp = '\0';
+ }
+
+ printf("Remote system type is %s.\n",
+ reply_string+4);
+ if (cp)
+ *cp = c;
+ }
+ if (!strncmp(reply_string, "215 UNIX Type: L8", 17)) {
+ setbinary();
+ /* allbinary = 1; this violates the RFC */
+ if (overbose)
+ printf("Using %s mode to transfer files.\n",
+ typename);
+ } else if (overbose &&
+ !strncmp(reply_string, "215 TOPS20", 10)) {
+ printf(
+"Remember to set tenex mode when transfering binary files from this machine.\n");
+ }
+ verbose = overbose;
+#endif /* unix */
+ }
+ (void) fflush(stdout);
+}
+
+struct types {
+ char *t_name;
+ char *t_mode;
+ int t_type;
+ char *t_arg;
+} types[] = {
+ { "ascii", "A", TYPE_A, 0 },
+ { "binary", "I", TYPE_I, 0 },
+ { "image", "I", TYPE_I, 0 },
+ { "ebcdic", "E", TYPE_E, 0 },
+ { "tenex", "L", TYPE_L, bytename },
+ 0
+};
+
+/*
+ * Set transfer type.
+ */
+void settype(argc, argv)
+ char *argv[];
+{
+ register struct types *p;
+ int comret;
+
+ if (argc > 2) {
+ char *sep;
+
+ printf("usage: %s [", argv[0]);
+ sep = " ";
+ for (p = types; p->t_name; p++) {
+ printf("%s%s", sep, p->t_name);
+ if (*sep == ' ')
+ sep = " | ";
+ }
+ printf(" ]\n");
+ (void) fflush(stdout);
+ code = -1;
+ return;
+ }
+ if (argc < 2) {
+ printf("Using %s mode to transfer files.\n", typename);
+ (void) fflush(stdout);
+ code = 0;
+ return;
+ }
+ for (p = types; p->t_name; p++)
+ if (strcmp(argv[1], p->t_name) == 0)
+ break;
+ if (p->t_name == 0) {
+ printf("%s: unknown mode\n", argv[1]);
+ (void) fflush(stdout);
+ code = -1;
+ return;
+ }
+ if ((p->t_arg != NULL) && (*(p->t_arg) != '\0'))
+ comret = command ("TYPE %s %s", p->t_mode, p->t_arg);
+ else
+ comret = command("TYPE %s", p->t_mode);
+ if (comret == COMPLETE) {
+ (void) strcpy(typename, p->t_name);
+ type = p->t_type;
+ }
+}
+
+char *stype[] = {
+ "type",
+ "",
+ 0
+};
+
+/*
+ * Set binary transfer type.
+ */
+/*VARARGS*/
+void setbinary()
+{
+ stype[1] = "binary";
+ settype(2, stype);
+}
+
+/*
+ * Set ascii transfer type.
+ */
+/*VARARGS*/
+void setascii()
+{
+ stype[1] = "ascii";
+ settype(2, stype);
+}
+
+/*
+ * Set tenex transfer type.
+ */
+/*VARARGS*/
+void settenex()
+{
+ stype[1] = "tenex";
+ settype(2, stype);
+}
+
+/*
+ * Set ebcdic transfer type.
+ */
+/*VARARGS*/
+void setebcdic()
+{
+ stype[1] = "ebcdic";
+ settype(2, stype);
+}
+
+/*
+ * Set file transfer mode.
+ */
+#if 0
+/*ARGSUSED*/
+void setmode(argc, argv)
+ char *argv[];
+{
+
+ printf("We only support %s mode, sorry.\n", modename);
+ (void) fflush(stdout);
+ code = -1;
+}
+#endif
+
+/*
+ * Set file transfer format.
+ */
+/*ARGSUSED*/
+void setform(argc, argv)
+ char *argv[];
+{
+
+ printf("We only support %s format, sorry.\n", formname);
+ (void) fflush(stdout);
+ code = -1;
+}
+
+/*
+ * Set file transfer structure.
+ */
+/*ARGSUSED*/
+void setstruct(argc, argv)
+ char *argv[];
+{
+
+ printf("We only support %s structure, sorry.\n", structname);
+ (void) fflush(stdout);
+ code = -1;
+}
+
+/*
+ * Send a single file.
+ */
+void put(argc, argv)
+ int argc;
+ char *argv[];
+{
+ char *cmd;
+ int loc = 0;
+ char *oldargv1, *oldargv2;
+
+ if (argc == 2) {
+ argc++;
+ argv[2] = argv[1];
+ loc++;
+ }
+ if (argc < 2) {
+ (void) strcat(line, " ");
+ printf("(local-file) ");
+ (void) fflush(stdout);
+ (void) gets(&line[strlen(line)]);
+ makeargv();
+ argc = margc;
+ argv = margv;
+ }
+ if (argc < 2) {
+usage:
+ printf("usage:%s local-file remote-file\n", argv[0]);
+ (void) fflush(stdout);
+ code = -1;
+ return;
+ }
+ if (argc < 3) {
+ (void) strcat(line, " ");
+ printf("(remote-file) ");
+ (void) fflush(stdout);
+ (void) gets(&line[strlen(line)]);
+ makeargv();
+ argc = margc;
+ argv = margv;
+ }
+ if (argc < 3)
+ goto usage;
+ oldargv1 = argv[1];
+ oldargv2 = argv[2];
+ if (!globulize(&argv[1])) {
+ code = -1;
+ return;
+ }
+ /*
+ * If "globulize" modifies argv[1], and argv[2] is a copy of
+ * the old argv[1], make it a copy of the new argv[1].
+ */
+ if (argv[1] != oldargv1 && argv[2] == oldargv1) {
+ argv[2] = argv[1];
+ }
+ cmd = (argv[0][0] == 'a') ? "APPE" : ((sunique) ? "STOU" : "STOR");
+ if (loc && ntflag) {
+ argv[2] = dotrans(argv[2]);
+ }
+ if (loc && mapflag) {
+ argv[2] = domap(argv[2]);
+ }
+ sendrequest(cmd, argv[1], argv[2],
+ argv[1] != oldargv1 || argv[2] != oldargv2);
+}
+
+/*
+ * Send multiple files.
+ */
+void mput(argc, argv)
+ char *argv[];
+{
+ register int i;
+ int ointer;
+ void mabort();
+ extern jmp_buf jabort;
+ char *tp;
+
+ if (argc < 2) {
+ (void) strcat(line, " ");
+ printf("(local-files) ");
+ (void) fflush(stdout);
+ (void) gets(&line[strlen(line)]);
+ makeargv();
+ argc = margc;
+ argv = margv;
+ }
+ if (argc < 2) {
+ printf("usage:%s local-files\n", argv[0]);
+ (void) fflush(stdout);
+ code = -1;
+ return;
+ }
+ mname = argv[0];
+ mflag = 1;
+// oldintr = signal(SIGINT, mabort);
+ (void) setjmp(jabort);
+ if (proxy) {
+ char *cp, *tp2, tmpbuf[MAXPATHLEN];
+
+ while ((cp = remglob(argv,0)) != NULL) {
+ if (*cp == 0) {
+ mflag = 0;
+ continue;
+ }
+ if (mflag && confirm(argv[0], cp)) {
+ tp = cp;
+ if (mcase) {
+ while (*tp && !islower(*tp)) {
+ tp++;
+ }
+ if (!*tp) {
+ tp = cp;
+ tp2 = tmpbuf;
+ while ((*tp2 = *tp) != (int) NULL) {
+ if (isupper(*tp2)) {
+ *tp2 = 'a' + *tp2 - 'A';
+ }
+ tp++;
+ tp2++;
+ }
+ }
+ tp = tmpbuf;
+ }
+ if (ntflag) {
+ tp = dotrans(tp);
+ }
+ if (mapflag) {
+ tp = domap(tp);
+ }
+ sendrequest((sunique) ? "STOU" : "STOR",
+ cp, tp, cp != tp || !interactive);
+ if (!mflag && fromatty) {
+ ointer = interactive;
+ interactive = 1;
+ if (confirm("Continue with","mput")) {
+ mflag++;
+ }
+ interactive = ointer;
+ }
+ }
+ }
+// (void) signal(SIGINT, oldintr);
+ mflag = 0;
+ return;
+ }
+ for (i = 1; i < argc; i++) {
+ register char **cpp, **gargs;
+
+ if (!doglob) {
+ if (mflag && confirm(argv[0], argv[i])) {
+ tp = (ntflag) ? dotrans(argv[i]) : argv[i];
+ tp = (mapflag) ? domap(tp) : tp;
+ sendrequest((sunique) ? "STOU" : "STOR",
+ argv[i], tp, tp != argv[i] || !interactive);
+ if (!mflag && fromatty) {
+ ointer = interactive;
+ interactive = 1;
+ if (confirm("Continue with","mput")) {
+ mflag++;
+ }
+ interactive = ointer;
+ }
+ }
+ continue;
+ }
+ gargs = glob(argv[i]);
+ if (globerr != NULL) {
+ printf("%s\n", globerr);
+ (void) fflush(stdout);
+ if (gargs) {
+ blkfree(gargs);
+ free((char *)gargs);
+ }
+ continue;
+ }
+ for (cpp = gargs; cpp && *cpp != NULL; cpp++) {
+ if (mflag && confirm(argv[0], *cpp)) {
+ tp = (ntflag) ? dotrans(*cpp) : *cpp;
+ tp = (mapflag) ? domap(tp) : tp;
+ sendrequest((sunique) ? "STOU" : "STOR",
+ *cpp, tp, *cpp != tp || !interactive);
+ if (!mflag && fromatty) {
+ ointer = interactive;
+ interactive = 1;
+ if (confirm("Continue with","mput")) {
+ mflag++;
+ }
+ interactive = ointer;
+ }
+ }
+ }
+ if (gargs != NULL) {
+ blkfree(gargs);
+ free((char *)gargs);
+ }
+ }
+// (void) signal(SIGINT, oldintr);
+ mflag = 0;
+}
+
+void reget(argc, argv)
+ char *argv[];
+{
+ (void) getit(argc, argv, 1, "r+w");
+}
+
+void get(argc, argv)
+ char *argv[];
+{
+ (void) getit(argc, argv, 0, restart_point ? "r+w" : "w" );
+}
+
+/*
+ * Receive one file.
+ */
+int getit(argc, argv, restartit, mode)
+ char *argv[];
+ char *mode;
+{
+ int loc = 0;
+ char *oldargv1, *oldargv2;
+
+ if (argc == 2) {
+ argc++;
+ argv[2] = argv[1];
+ loc++;
+ }
+ if (argc < 2) {
+ (void) strcat(line, " ");
+ printf("(remote-file) ");
+ (void) fflush(stdout);
+ (void) gets(&line[strlen(line)]);
+ makeargv();
+ argc = margc;
+ argv = margv;
+ }
+ if (argc < 2) {
+usage:
+ printf("usage: %s remote-file [ local-file ]\n", argv[0]);
+ (void) fflush(stdout);
+ code = -1;
+ return (0);
+ }
+ if (argc < 3) {
+ (void) strcat(line, " ");
+ printf("(local-file) ");
+ (void) fflush(stdout);
+ (void) gets(&line[strlen(line)]);
+ makeargv();
+ argc = margc;
+ argv = margv;
+ }
+ if (argc < 3)
+ goto usage;
+ oldargv1 = argv[1];
+ oldargv2 = argv[2];
+ if (!globulize(&argv[2])) {
+ code = -1;
+ return (0);
+ }
+ if (loc && mcase) {
+ char *tp = argv[1], *tp2, tmpbuf[MAXPATHLEN];
+
+ while (*tp && !islower(*tp)) {
+ tp++;
+ }
+ if (!*tp) {
+ tp = argv[2];
+ tp2 = tmpbuf;
+ while ((*tp2 = *tp) != (int) NULL) {
+ if (isupper(*tp2)) {
+ *tp2 = 'a' + *tp2 - 'A';
+ }
+ tp++;
+ tp2++;
+ }
+ argv[2] = tmpbuf;
+ }
+ }
+ if (loc && ntflag)
+ argv[2] = dotrans(argv[2]);
+ if (loc && mapflag)
+ argv[2] = domap(argv[2]);
+ if (restartit) {
+ struct stat stbuf;
+ int ret;
+
+ ret = stat(argv[2], &stbuf);
+ if (restartit == 1) {
+ if (ret < 0) {
+ perror(argv[2]);
+ return (0);
+ }
+ restart_point = stbuf.st_size;
+ } else {
+ if (ret == 0) {
+ int overbose;
+
+ overbose = verbose;
+ if (debug == 0)
+ verbose = -1;
+ if (command("MDTM %s", argv[1]) == COMPLETE) {
+ int yy, mo, day, hour, min, sec;
+ struct tm *tm;
+ verbose = overbose;
+ sscanf(reply_string,
+ "%*s %04d%02d%02d%02d%02d%02d",
+ &yy, &mo, &day, &hour, &min, &sec);
+ tm = gmtime(&stbuf.st_mtime);
+ tm->tm_mon++;
+ if (tm->tm_year > yy%100)
+ return (1);
+ else if (tm->tm_year == yy%100) {
+ if (tm->tm_mon > mo)
+ return (1);
+ } else if (tm->tm_mon == mo) {
+ if (tm->tm_mday > day)
+ return (1);
+ } else if (tm->tm_mday == day) {
+ if (tm->tm_hour > hour)
+ return (1);
+ } else if (tm->tm_hour == hour) {
+ if (tm->tm_min > min)
+ return (1);
+ } else if (tm->tm_min == min) {
+ if (tm->tm_sec > sec)
+ return (1);
+ }
+ } else {
+ printf("%s\n", reply_string);
+ (void) fflush(stdout);
+ verbose = overbose;
+ return (0);
+ }
+ }
+ }
+ }
+
+ recvrequest("RETR", argv[2], argv[1], mode,
+ argv[1] != oldargv1 || argv[2] != oldargv2);
+ restart_point = 0;
+ return (0);
+}
+
+void
+mabort()
+{
+ int ointer;
+ extern jmp_buf jabort;
+
+ printf("\n");
+ (void) fflush(stdout);
+ if (mflag && fromatty) {
+ ointer = interactive;
+ interactive = 1;
+ if (confirm("Continue with", mname)) {
+ interactive = ointer;
+ longjmp(jabort,0);
+ }
+ interactive = ointer;
+ }
+ mflag = 0;
+ longjmp(jabort,0);
+}
+
+/*
+ * Get multiple files.
+ */
+void mget(argc, argv)
+ char *argv[];
+{
+ char *cp, *tp, *tp2, tmpbuf[MAXPATHLEN];
+ int ointer;
+ void mabort();
+ extern jmp_buf jabort;
+
+ if (argc < 2) {
+ (void) strcat(line, " ");
+ printf("(remote-files) ");
+ (void) fflush(stdout);
+ (void) gets(&line[strlen(line)]);
+ makeargv();
+ argc = margc;
+ argv = margv;
+ }
+ if (argc < 2) {
+ printf("usage:%s remote-files\n", argv[0]);
+ (void) fflush(stdout);
+ code = -1;
+ return;
+ }
+ mname = argv[0];
+ mflag = 1;
+// oldintr = signal(SIGINT,mabort);
+ (void) setjmp(jabort);
+ while ((cp = remglob(argv,proxy)) != NULL) {
+ if (*cp == '\0') {
+ mflag = 0;
+ continue;
+ }
+ if (mflag && confirm(argv[0], cp)) {
+ tp = cp;
+ if (mcase) {
+ while (*tp && !islower(*tp)) {
+ tp++;
+ }
+ if (!*tp) {
+ tp = cp;
+ tp2 = tmpbuf;
+ while ((*tp2 = *tp) != (int) NULL) {
+ if (isupper(*tp2)) {
+ *tp2 = 'a' + *tp2 - 'A';
+ }
+ tp++;
+ tp2++;
+ }
+ }
+ tp = tmpbuf;
+ }
+ if (ntflag) {
+ tp = dotrans(tp);
+ }
+ if (mapflag) {
+ tp = domap(tp);
+ }
+ recvrequest("RETR", tp, cp, "w",
+ tp != cp || !interactive);
+ if (!mflag && fromatty) {
+ ointer = interactive;
+ interactive = 1;
+ if (confirm("Continue with","mget")) {
+ mflag++;
+ }
+ interactive = ointer;
+ }
+ }
+ }
+// (void) signal(SIGINT,oldintr);
+ mflag = 0;
+}
+
+char *
+remglob(argv,doswitch)
+ char *argv[];
+ int doswitch;
+{
+ char temp[16];
+ static char buf[MAXPATHLEN];
+ static FILE *ftemp = NULL;
+ static char **args;
+ int oldverbose, oldhash;
+ char *cp, *mode;
+
+ if (!mflag) {
+ if (!doglob) {
+ args = NULL;
+ }
+ else {
+ if (ftemp) {
+ (void) fclose(ftemp);
+ ftemp = NULL;
+ }
+ }
+ return(NULL);
+ }
+ if (!doglob) {
+ if (args == NULL)
+ args = argv;
+ if ((cp = *++args) == NULL)
+ args = NULL;
+ return (cp);
+ }
+ if (ftemp == NULL) {
+ (void) strcpy(temp, _PATH_TMP);
+ (void) mktemp(temp);
+ oldverbose = verbose, verbose = 0;
+ oldhash = hash, hash = 0;
+ if (doswitch) {
+ pswitch(!proxy);
+ }
+ for (mode = "w"; *++argv != NULL; mode = "a")
+ recvrequest ("NLST", temp, *argv, mode, 0);
+ if (doswitch) {
+ pswitch(!proxy);
+ }
+ verbose = oldverbose; hash = oldhash;
+ ftemp = fopen(temp, "r");
+ (void) unlink(temp);
+ if (ftemp == NULL) {
+ printf("can't find list of remote files, oops\n");
+ (void) fflush(stdout);
+ return (NULL);
+ }
+ }
+ if (fgets(buf, sizeof (buf), ftemp) == NULL) {
+ (void) fclose(ftemp), ftemp = NULL;
+ return (NULL);
+ }
+ if ((cp = index(buf, '\n')) != NULL)
+ *cp = '\0';
+ return (buf);
+}
+
+char *
+onoff(bool)
+ int bool;
+{
+
+ return (bool ? "on" : "off");
+}
+
+/*
+ * Show status.
+ */
+/*ARGSUSED*/
+void status(argc, argv)
+ char *argv[];
+{
+ int i;
+
+ if (connected)
+ printf("Connected to %s.\n", hostname);
+ else
+ printf("Not connected.\n");
+ if (!proxy) {
+ pswitch(1);
+ if (connected) {
+ printf("Connected for proxy commands to %s.\n", hostname);
+ }
+ else {
+ printf("No proxy connection.\n");
+ }
+ pswitch(0);
+ }
+ printf("Mode: %s; Type: %s; Form: %s; Structure: %s\n",
+ modename, typename, formname, structname);
+ printf("Verbose: %s; Bell: %s; Prompting: %s; Globbing: %s\n",
+ onoff(verbose), onoff(bell), onoff(interactive),
+ onoff(doglob));
+ printf("Store unique: %s; Receive unique: %s\n", onoff(sunique),
+ onoff(runique));
+ printf("Case: %s; CR stripping: %s\n",onoff(mcase),onoff(crflag));
+ if (ntflag) {
+ printf("Ntrans: (in) %s (out) %s\n", ntin,ntout);
+ }
+ else {
+ printf("Ntrans: off\n");
+ }
+ if (mapflag) {
+ printf("Nmap: (in) %s (out) %s\n", mapin, mapout);
+ }
+ else {
+ printf("Nmap: off\n");
+ }
+ printf("Hash mark printing: %s; Use of PORT cmds: %s\n",
+ onoff(hash), onoff(sendport));
+ if (macnum > 0) {
+ printf("Macros:\n");
+ for (i=0; i 1) {
+ val = atoi(argv[1]);
+ if (val < 0) {
+ printf("%s: bad debugging value.\n", argv[1]);
+ (void) fflush(stdout);
+ code = -1;
+ return;
+ }
+ } else
+ val = !debug;
+ debug = val;
+ if (debug)
+ options |= SO_DEBUG;
+ else
+ options &= ~SO_DEBUG;
+ printf("Debugging %s (debug=%d).\n", onoff(debug), debug);
+ (void) fflush(stdout);
+ code = debug > 0;
+}
+
+/*
+ * Set current working directory
+ * on remote machine.
+ */
+void cd(argc, argv)
+ char *argv[];
+{
+
+ if (argc < 2) {
+ (void) strcat(line, " ");
+ printf("(remote-directory) ");
+ (void) fflush(stdout);
+ (void) gets(&line[strlen(line)]);
+ makeargv();
+ argc = margc;
+ argv = margv;
+ }
+ if (argc < 2) {
+ printf("usage:%s remote-directory\n", argv[0]);
+ (void) fflush(stdout);
+ code = -1;
+ return;
+ }
+ if (command("CWD %s", argv[1]) == ERROR && code == 500) {
+ if (verbose) {
+ printf("CWD command not recognized, trying XCWD\n");
+ (void) fflush(stdout);
+ }
+ (void) command("XCWD %s", argv[1]);
+ }
+}
+
+/*
+ * Set current working directory
+ * on local machine.
+ */
+void lcd(argc, argv)
+ char *argv[];
+{
+ char buf[MAXPATHLEN];
+
+ if (argc < 2)
+ argc++, argv[1] = home;
+ if (argc != 2) {
+ printf("usage:%s local-directory\n", argv[0]);
+ (void) fflush(stdout);
+ code = -1;
+ return;
+ }
+ if (!globulize(&argv[1])) {
+ code = -1;
+ return;
+ }
+ if (chdir(argv[1]) < 0) {
+ perror(argv[1]);
+ code = -1;
+ return;
+ }
+ printf("Local directory now %s\n", getcwd(buf,sizeof(buf)));
+ (void) fflush(stdout);
+ code = 0;
+}
+
+/*
+ * Delete a single file.
+ */
+void delete(argc, argv)
+ char *argv[];
+{
+
+ if (argc < 2) {
+ (void) strcat(line, " ");
+ printf("(remote-file) ");
+ (void) fflush(stdout);
+ (void) gets(&line[strlen(line)]);
+ makeargv();
+ argc = margc;
+ argv = margv;
+ }
+ if (argc < 2) {
+ printf("usage:%s remote-file\n", argv[0]);
+ (void) fflush(stdout);
+ code = -1;
+ return;
+ }
+ (void) command("DELE %s", argv[1]);
+}
+
+/*
+ * Delete multiple files.
+ */
+void mdelete(argc, argv)
+ char *argv[];
+{
+ char *cp;
+ int ointer;
+ void mabort();
+ extern jmp_buf jabort;
+
+ if (argc < 2) {
+ (void) strcat(line, " ");
+ printf("(remote-files) ");
+ (void) fflush(stdout);
+ (void) gets(&line[strlen(line)]);
+ makeargv();
+ argc = margc;
+ argv = margv;
+ }
+ if (argc < 2) {
+ printf("usage:%s remote-files\n", argv[0]);
+ (void) fflush(stdout);
+ code = -1;
+ return;
+ }
+ mname = argv[0];
+ mflag = 1;
+// oldintr = signal(SIGINT, mabort);
+ (void) setjmp(jabort);
+ while ((cp = remglob(argv,0)) != NULL) {
+ if (*cp == '\0') {
+ mflag = 0;
+ continue;
+ }
+ if (mflag && confirm(argv[0], cp)) {
+ (void) command("DELE %s", cp);
+ if (!mflag && fromatty) {
+ ointer = interactive;
+ interactive = 1;
+ if (confirm("Continue with", "mdelete")) {
+ mflag++;
+ }
+ interactive = ointer;
+ }
+ }
+ }
+// (void) signal(SIGINT, oldintr);
+ mflag = 0;
+}
+
+/*
+ * Rename a remote file.
+ */
+void renamefile(argc, argv)
+ char *argv[];
+{
+
+ if (argc < 2) {
+ (void) strcat(line, " ");
+ printf("(from-name) ");
+ (void) fflush(stdout);
+ (void) gets(&line[strlen(line)]);
+ makeargv();
+ argc = margc;
+ argv = margv;
+ }
+ if (argc < 2) {
+usage:
+ printf("%s from-name to-name\n", argv[0]);
+ (void) fflush(stdout);
+ code = -1;
+ return;
+ }
+ if (argc < 3) {
+ (void) strcat(line, " ");
+ printf("(to-name) ");
+ (void) fflush(stdout);
+ (void) gets(&line[strlen(line)]);
+ makeargv();
+ argc = margc;
+ argv = margv;
+ }
+ if (argc < 3)
+ goto usage;
+ if (command("RNFR %s", argv[1]) == CONTINUE)
+ (void) command("RNTO %s", argv[2]);
+}
+
+/*
+ * Get a directory listing
+ * of remote files.
+ */
+void ls(argc, argv)
+ char *argv[];
+{
+ char *cmd;
+
+ if (argc < 2)
+ argc++, argv[1] = NULL;
+ if (argc < 3)
+ argc++, argv[2] = "-";
+ if (argc > 3) {
+ printf("usage: %s remote-directory local-file\n", argv[0]);
+ (void) fflush(stdout);
+ code = -1;
+ return;
+ }
+ cmd = argv[0][0] == 'n' ? "NLST" : "LIST";
+// cmd = argv[0][0] == 'n' ? "NLST -CF" : "NLST -CF";
+ if (strcmp(argv[2], "-") && !globulize(&argv[2])) {
+ code = -1;
+ return;
+ }
+ if (strcmp(argv[2], "-") && *argv[2] != '|')
+ if (!globulize(&argv[2]) || !confirm("output to local-file:", argv[2])) {
+ code = -1;
+ return;
+ }
+ recvrequest(cmd, argv[2], argv[1], "w", 0);
+}
+
+/*
+ * Get a directory listing
+ * of multiple remote files.
+ */
+void mls(argc, argv)
+ char *argv[];
+{
+ char *cmd, mode[1], *dest;
+ int ointer, i;
+ void mabort();
+ extern jmp_buf jabort;
+
+ if (argc < 2) {
+ (void) strcat(line, " ");
+ printf("(remote-files) ");
+ (void) fflush(stdout);
+ (void) gets(&line[strlen(line)]);
+ makeargv();
+ argc = margc;
+ argv = margv;
+ }
+ if (argc < 3) {
+ (void) strcat(line, " ");
+ printf("(local-file) ");
+ (void) fflush(stdout);
+ (void) gets(&line[strlen(line)]);
+ makeargv();
+ argc = margc;
+ argv = margv;
+ }
+ if (argc < 3) {
+ printf("usage:%s remote-files local-file\n", argv[0]);
+ (void) fflush(stdout);
+ code = -1;
+ return;
+ }
+ dest = argv[argc - 1];
+ argv[argc - 1] = NULL;
+ if (strcmp(dest, "-") && *dest != '|')
+ if (!globulize(&dest) || !confirm("output to local-file:", dest)) {
+ code = -1;
+ return;
+ }
+ cmd = argv[0][1] == 'l' ? "NLST" : "LIST";
+ mname = argv[0];
+ mflag = 1;
+// oldintr = signal(SIGINT, mabort);
+ (void) setjmp(jabort);
+ for (i = 1; mflag && i < argc-1; ++i) {
+ *mode = (i == 1) ? 'w' : 'a';
+ recvrequest(cmd, dest, argv[i], mode, 0);
+ if (!mflag && fromatty) {
+ ointer = interactive;
+ interactive = 1;
+ if (confirm("Continue with", argv[0])) {
+ mflag ++;
+ }
+ interactive = ointer;
+ }
+ }
+// (void) signal(SIGINT, oldintr);
+ mflag = 0;
+}
+
+/*
+ * Do a shell escape
+ */
+/*ARGSUSED*/
+shell(argc, argv)
+ char *argv[];
+{
+#if 0
+ int pid;
+ sig_t (*old1)(), (*old2)();
+ char shellnam[40], *shell, *namep;
+ union wait status;
+
+ old1 = signal (SIGINT, SIG_IGN);
+ old2 = signal (SIGQUIT, SIG_IGN);
+ if ((pid = fork()) == 0) {
+ for (pid = 3; pid < 20; pid++)
+ (void) close(pid);
+ (void) signal(SIGINT, SIG_DFL);
+ (void) signal(SIGQUIT, SIG_DFL);
+ shell = getenv("SHELL");
+ if (shell == NULL)
+ shell = _PATH_BSHELL;
+ namep = rindex(shell,'/');
+ if (namep == NULL)
+ namep = shell;
+ (void) strcpy(shellnam,"-");
+ (void) strcat(shellnam, ++namep);
+ if (strcmp(namep, "sh") != 0)
+ shellnam[0] = '+';
+ if (debug) {
+ printf ("%s\n", shell);
+ (void) fflush (stdout);
+ }
+ if (argc > 1) {
+ execl(shell,shellnam,"-c",altarg,(char *)0);
+ }
+ else {
+ execl(shell,shellnam,(char *)0);
+ }
+ perror(shell);
+ code = -1;
+ exit(1);
+ }
+ if (pid > 0)
+ while (wait(&status) != pid)
+ ;
+ (void) signal(SIGINT, old1);
+ (void) signal(SIGQUIT, old2);
+ if (pid == -1) {
+ perror("Try again later");
+ code = -1;
+ }
+ else {
+ code = 0;
+ }
+#endif
+
+ char * AppName;
+ char ShellCmd[MAX_PATH];
+ char CmdLine[MAX_PATH];
+ int i;
+ PROCESS_INFORMATION ProcessInformation;
+ BOOL Result;
+ STARTUPINFO StartupInfo;
+ char ShellName[] = "COMSPEC";
+ int NumBytes;
+
+ NumBytes = GetEnvironmentVariable( ShellName, ShellCmd, MAX_PATH);
+
+ if (NumBytes == 0)
+ {
+ return(-1);
+ }
+
+ AppName = ShellCmd;
+ strcpy( CmdLine, ShellCmd );
+
+ if (argc > 1)
+ {
+ strncat(CmdLine, " /C", MAX_PATH);
+ }
+
+ for (i=1; i 4) {
+ printf("usage: %s username [password] [account]\n", argv[0]);
+ (void) fflush(stdout);
+ code = -1;
+ return (0);
+ }
+ n = command("USER %s", argv[1]);
+ if (n == CONTINUE) {
+ if (argc < 3 )
+ argv[2] = getpass("Password: "), argc++;
+ n = command("PASS %s", argv[2]);
+ }
+ if (n == CONTINUE) {
+ if (argc < 4) {
+ printf("Account: "); (void) fflush(stdout);
+ (void) fflush(stdout);
+ (void) fgets(acct, sizeof(acct) - 1, stdin);
+ acct[strlen(acct) - 1] = '\0';
+ argv[3] = acct; argc++;
+ }
+ n = command("ACCT %s", argv[3]);
+ aflag++;
+ }
+ if (n != COMPLETE) {
+ fprintf(stdout, "Login failed.\n");
+ (void) fflush(stdout);
+ return (0);
+ }
+ if (!aflag && argc == 4) {
+ (void) command("ACCT %s", argv[3]);
+ }
+ return (1);
+}
+
+/*
+ * Print working directory.
+ */
+/*VARARGS*/
+void pwd()
+{
+ int oldverbose = verbose;
+
+ /*
+ * If we aren't verbose, this doesn't do anything!
+ */
+ verbose = 1;
+ if (command("PWD") == ERROR && code == 500) {
+ printf("PWD command not recognized, trying XPWD\n");
+ (void) fflush(stdout);
+ (void) command("XPWD");
+ }
+ verbose = oldverbose;
+}
+
+/*
+ * Make a directory.
+ */
+void makedir(argc, argv)
+ char *argv[];
+{
+
+ if (argc < 2) {
+ (void) strcat(line, " ");
+ printf("(directory-name) ");
+ (void) fflush(stdout);
+ (void) gets(&line[strlen(line)]);
+ makeargv();
+ argc = margc;
+ argv = margv;
+ }
+ if (argc < 2) {
+ printf("usage: %s directory-name\n", argv[0]);
+ (void) fflush(stdout);
+ code = -1;
+ return;
+ }
+ if (command("MKD %s", argv[1]) == ERROR && code == 500) {
+ if (verbose) {
+ printf("MKD command not recognized, trying XMKD\n");
+ (void) fflush(stdout);
+ }
+ (void) command("XMKD %s", argv[1]);
+ }
+}
+
+/*
+ * Remove a directory.
+ */
+void removedir(argc, argv)
+ char *argv[];
+{
+
+ if (argc < 2) {
+ (void) strcat(line, " ");
+ printf("(directory-name) ");
+ (void) fflush(stdout);
+ (void) gets(&line[strlen(line)]);
+ makeargv();
+ argc = margc;
+ argv = margv;
+ }
+ if (argc < 2) {
+ printf("usage: %s directory-name\n", argv[0]);
+ (void) fflush(stdout);
+ code = -1;
+ return;
+ }
+ if (command("RMD %s", argv[1]) == ERROR && code == 500) {
+ if (verbose) {
+ printf("RMD command not recognized, trying XRMD\n");
+ (void) fflush(stdout);
+ }
+ (void) command("XRMD %s", argv[1]);
+ }
+}
+
+/*
+ * Send a line, verbatim, to the remote machine.
+ */
+void quote(argc, argv)
+ char *argv[];
+{
+ int i;
+ char buf[BUFSIZ];
+
+ if (argc < 2) {
+ (void) strcat(line, " ");
+ printf("(command line to send) ");
+ (void) fflush(stdout);
+ (void) gets(&line[strlen(line)]);
+ makeargv();
+ argc = margc;
+ argv = margv;
+ }
+ if (argc < 2) {
+ printf("usage: %s line-to-send\n", argv[0]);
+ (void) fflush(stdout);
+ code = -1;
+ return;
+ }
+ (void) strcpy(buf, argv[1]);
+ for (i = 2; i < argc; i++) {
+ (void) strcat(buf, " ");
+ (void) strcat(buf, argv[i]);
+ }
+ if (command(buf) == PRELIM) {
+ while (getreply(0) == PRELIM);
+ }
+}
+
+/*
+ * Send a SITE command to the remote machine. The line
+ * is sent almost verbatim to the remote machine, the
+ * first argument is changed to SITE.
+ */
+
+void site(argc, argv)
+ char *argv[];
+{
+ int i;
+ char buf[BUFSIZ];
+
+ if (argc < 2) {
+ (void) strcat(line, " ");
+ printf("(arguments to SITE command) ");
+ (void) fflush(stdout);
+ (void) gets(&line[strlen(line)]);
+ makeargv();
+ argc = margc;
+ argv = margv;
+ }
+ if (argc < 2) {
+ printf("usage: %s line-to-send\n", argv[0]);
+ (void) fflush(stdout);
+ code = -1;
+ return;
+ }
+ (void) strcpy(buf, "SITE ");
+ (void) strcat(buf, argv[1]);
+ for (i = 2; i < argc; i++) {
+ (void) strcat(buf, " ");
+ (void) strcat(buf, argv[i]);
+ }
+ if (command(buf) == PRELIM) {
+ while (getreply(0) == PRELIM);
+ }
+}
+
+void do_chmod(argc, argv)
+ char *argv[];
+{
+ if (argc == 2) {
+ printf("usage: %s mode file-name\n", argv[0]);
+ (void) fflush(stdout);
+ code = -1;
+ return;
+ }
+ if (argc < 3) {
+ (void) strcat(line, " ");
+ printf("(mode and file-name) ");
+ (void) fflush(stdout);
+ (void) gets(&line[strlen(line)]);
+ makeargv();
+ argc = margc;
+ argv = margv;
+ }
+ if (argc != 3) {
+ printf("usage: %s mode file-name\n", argv[0]);
+ (void) fflush(stdout);
+ code = -1;
+ return;
+ }
+ (void)command("SITE CHMOD %s %s", argv[1], argv[2]);
+}
+
+void do_umask(argc, argv)
+ char *argv[];
+{
+ int oldverbose = verbose;
+
+ verbose = 1;
+ (void) command(argc == 1 ? "SITE UMASK" : "SITE UMASK %s", argv[1]);
+ verbose = oldverbose;
+}
+
+void idle(argc, argv)
+ char *argv[];
+{
+ int oldverbose = verbose;
+
+ verbose = 1;
+ (void) command(argc == 1 ? "SITE IDLE" : "SITE IDLE %s", argv[1]);
+ verbose = oldverbose;
+}
+
+/*
+ * Ask the other side for help.
+ */
+void rmthelp(argc, argv)
+ char *argv[];
+{
+ int oldverbose = verbose;
+
+ verbose = 1;
+ (void) command(argc == 1 ? "HELP" : "HELP %s", argv[1]);
+ verbose = oldverbose;
+}
+
+/*
+ * Terminate session and exit.
+ */
+/*VARARGS*/
+void quit()
+{
+
+ if (connected)
+ disconnect();
+ pswitch(1);
+ if (connected) {
+ disconnect();
+ }
+ exit(0);
+}
+
+/*
+ * Terminate session, but don't exit.
+ */
+void disconnect()
+{
+ extern int cout;
+ extern int data;
+
+ if (!connected)
+ return;
+ (void) command("QUIT");
+ cout = (int) NULL;
+ connected = 0;
+ data = -1;
+ if (!proxy) {
+ macnum = 0;
+ }
+}
+
+confirm(cmd, file)
+ char *cmd, *file;
+{
+ char line[BUFSIZ];
+
+ if (!interactive)
+ return (1);
+ printf("%s %s? ", cmd, file);
+ (void) fflush(stdout);
+ (void) gets(line);
+ return (*line != 'n' && *line != 'N');
+}
+
+void fatal(msg)
+ char *msg;
+{
+
+ fprintf(stderr, "ftp: %s\n", msg);
+ exit(1);
+}
+
+/*
+ * Glob a local file name specification with
+ * the expectation of a single return value.
+ * Can't control multiple values being expanded
+ * from the expression, we return only the first.
+ */
+globulize(cpp)
+ char **cpp;
+{
+ char **globbed;
+
+ if (!doglob)
+ return (1);
+ globbed = glob(*cpp);
+ if (globerr != NULL) {
+ printf("%s: %s\n", *cpp, globerr);
+ (void) fflush(stdout);
+ if (globbed) {
+ blkfree(globbed);
+ free((char *)globbed);
+ }
+ return (0);
+ }
+ if (globbed) {
+ *cpp = *globbed++;
+ /* don't waste too much memory */
+ if (*globbed) {
+ blkfree(globbed);
+ free((char *)globbed);
+ }
+ }
+ return (1);
+}
+
+void account(argc,argv)
+ int argc;
+ char **argv;
+{
+ char acct[50], *getpass(), *ap;
+
+ if (argc > 1) {
+ ++argv;
+ --argc;
+ (void) strncpy(acct,*argv,49);
+ acct[49] = '\0';
+ while (argc > 1) {
+ --argc;
+ ++argv;
+ (void) strncat(acct,*argv, 49-strlen(acct));
+ }
+ ap = acct;
+ }
+ else {
+ ap = getpass("Account:");
+ }
+ (void) command("ACCT %s", ap);
+}
+
+jmp_buf abortprox;
+
+void
+proxabort()
+{
+ extern int proxy;
+
+ if (!proxy) {
+ pswitch(1);
+ }
+ if (connected) {
+ proxflag = 1;
+ }
+ else {
+ proxflag = 0;
+ }
+ pswitch(0);
+ longjmp(abortprox,1);
+}
+
+void doproxy(argc,argv)
+ int argc;
+ char *argv[];
+{
+ void proxabort();
+ register struct cmd *c;
+ struct cmd *getcmd();
+ extern struct cmd cmdtab[];
+ extern jmp_buf abortprox;
+
+ if (argc < 2) {
+ (void) strcat(line, " ");
+ printf("(command) ");
+ (void) fflush(stdout);
+ (void) gets(&line[strlen(line)]);
+ makeargv();
+ argc = margc;
+ argv = margv;
+ }
+ if (argc < 2) {
+ printf("usage:%s command\n", argv[0]);
+ (void) fflush(stdout);
+ code = -1;
+ return;
+ }
+ c = getcmd(argv[1]);
+ if (c == (struct cmd *) -1) {
+ printf("?Ambiguous command\n");
+ (void) fflush(stdout);
+ code = -1;
+ return;
+ }
+ if (c == 0) {
+ printf("?Invalid command\n");
+ (void) fflush(stdout);
+ code = -1;
+ return;
+ }
+ if (!c->c_proxy) {
+ printf("?Invalid proxy command\n");
+ (void) fflush(stdout);
+ code = -1;
+ return;
+ }
+ if (setjmp(abortprox)) {
+ code = -1;
+ return;
+ }
+// oldintr = signal(SIGINT, proxabort);
+ pswitch(1);
+ if (c->c_conn && !connected) {
+ printf("Not connected\n");
+ (void) fflush(stdout);
+ pswitch(0);
+// (void) signal(SIGINT, oldintr);
+ code = -1;
+ return;
+ }
+ (*c->c_handler)(argc-1, argv+1);
+ if (connected) {
+ proxflag = 1;
+ }
+ else {
+ proxflag = 0;
+ }
+ pswitch(0);
+// (void) signal(SIGINT, oldintr);
+}
+
+void setcase()
+{
+ mcase = !mcase;
+ printf("Case mapping %s.\n", onoff(mcase));
+ (void) fflush(stdout);
+ code = mcase;
+}
+
+void setcr()
+{
+ crflag = !crflag;
+ printf("Carriage Return stripping %s.\n", onoff(crflag));
+ (void) fflush(stdout);
+ code = crflag;
+}
+
+void setntrans(argc,argv)
+ int argc;
+ char *argv[];
+{
+ if (argc == 1) {
+ ntflag = 0;
+ printf("Ntrans off.\n");
+ (void) fflush(stdout);
+ code = ntflag;
+ return;
+ }
+ ntflag++;
+ code = ntflag;
+ (void) strncpy(ntin, argv[1], 16);
+ ntin[16] = '\0';
+ if (argc == 2) {
+ ntout[0] = '\0';
+ return;
+ }
+ (void) strncpy(ntout, argv[2], 16);
+ ntout[16] = '\0';
+}
+
+char *
+dotrans(name)
+ char *name;
+{
+ static char new[MAXPATHLEN];
+ char *cp1, *cp2 = new;
+ register int i, ostop, found;
+
+ for (ostop = 0; *(ntout + ostop) && ostop < 16; ostop++);
+ for (cp1 = name; *cp1; cp1++) {
+ found = 0;
+ for (i = 0; *(ntin + i) && i < 16; i++) {
+ if (*cp1 == *(ntin + i)) {
+ found++;
+ if (i < ostop) {
+ *cp2++ = *(ntout + i);
+ }
+ break;
+ }
+ }
+ if (!found) {
+ *cp2++ = *cp1;
+ }
+ }
+ *cp2 = '\0';
+ return(new);
+}
+
+
+void
+setpassive(argc, argv)
+ int argc;
+ char *argv[];
+{
+ passivemode = !passivemode;
+ printf("Passive mode %s.\n", onoff(passivemode));
+ (void) fflush(stdout);
+ code = passivemode;
+}
+
+void setnmap(argc, argv)
+ int argc;
+ char *argv[];
+{
+ char *cp;
+
+ if (argc == 1) {
+ mapflag = 0;
+ printf("Nmap off.\n");
+ (void) fflush(stdout);
+ code = mapflag;
+ return;
+ }
+ if (argc < 3) {
+ (void) strcat(line, " ");
+ printf("(mapout) ");
+ (void) fflush(stdout);
+ (void) gets(&line[strlen(line)]);
+ makeargv();
+ argc = margc;
+ argv = margv;
+ }
+ if (argc < 3) {
+ printf("Usage: %s [mapin mapout]\n",argv[0]);
+ (void) fflush(stdout);
+ code = -1;
+ return;
+ }
+ mapflag = 1;
+ code = 1;
+ cp = index(altarg, ' ');
+ if (proxy) {
+ while(*++cp == ' ');
+ altarg = cp;
+ cp = index(altarg, ' ');
+ }
+ *cp = '\0';
+ (void) strncpy(mapin, altarg, MAXPATHLEN - 1);
+ while (*++cp == ' ');
+ (void) strncpy(mapout, cp, MAXPATHLEN - 1);
+}
+
+char *
+domap(name)
+ char *name;
+{
+ static char new[MAXPATHLEN];
+ register char *cp1 = name, *cp2 = mapin;
+ char *tp[9], *te[9];
+ int i, toks[9], toknum = 0, match = 1;
+
+ for (i=0; i < 9; ++i) {
+ toks[i] = 0;
+ }
+ while (match && *cp1 && *cp2) {
+ switch (*cp2) {
+ case '\\':
+ if (*++cp2 != *cp1) {
+ match = 0;
+ }
+ break;
+ case '$':
+ if (*(cp2+1) >= '1' && (*cp2+1) <= '9') {
+ if (*cp1 != *(++cp2+1)) {
+ toks[toknum = *cp2 - '1']++;
+ tp[toknum] = cp1;
+ while (*++cp1 && *(cp2+1)
+ != *cp1);
+ te[toknum] = cp1;
+ }
+ cp2++;
+ break;
+ }
+ /* FALLTHROUGH */
+ default:
+ if (*cp2 != *cp1) {
+ match = 0;
+ }
+ break;
+ }
+ if (match && *cp1) {
+ cp1++;
+ }
+ if (match && *cp2) {
+ cp2++;
+ }
+ }
+ if (!match && *cp1) /* last token mismatch */
+ {
+ toks[toknum] = 0;
+ }
+ cp1 = new;
+ *cp1 = '\0';
+ cp2 = mapout;
+ while (*cp2) {
+ match = 0;
+ switch (*cp2) {
+ case '\\':
+ if (*(cp2 + 1)) {
+ *cp1++ = *++cp2;
+ }
+ break;
+ case '[':
+LOOP:
+ if (*++cp2 == '$' && isdigit(*(cp2+1))) {
+ if (*++cp2 == '0') {
+ char *cp3 = name;
+
+ while (*cp3) {
+ *cp1++ = *cp3++;
+ }
+ match = 1;
+ }
+ else if (toks[toknum = *cp2 - '1']) {
+ char *cp3 = tp[toknum];
+
+ while (cp3 != te[toknum]) {
+ *cp1++ = *cp3++;
+ }
+ match = 1;
+ }
+ }
+ else {
+ while (*cp2 && *cp2 != ',' &&
+ *cp2 != ']') {
+ if (*cp2 == '\\') {
+ cp2++;
+ }
+ else if (*cp2 == '$' &&
+ isdigit(*(cp2+1))) {
+ if (*++cp2 == '0') {
+ char *cp3 = name;
+
+ while (*cp3) {
+ *cp1++ = *cp3++;
+ }
+ }
+ else if (toks[toknum =
+ *cp2 - '1']) {
+ char *cp3=tp[toknum];
+
+ while (cp3 !=
+ te[toknum]) {
+ *cp1++ = *cp3++;
+ }
+ }
+ }
+ else if (*cp2) {
+ *cp1++ = *cp2++;
+ }
+ }
+ if (!*cp2) {
+ printf("nmap: unbalanced brackets\n");
+ (void) fflush(stdout);
+ return(name);
+ }
+ match = 1;
+ cp2--;
+ }
+ if (match) {
+ while (*++cp2 && *cp2 != ']') {
+ if (*cp2 == '\\' && *(cp2 + 1)) {
+ cp2++;
+ }
+ }
+ if (!*cp2) {
+ printf("nmap: unbalanced brackets\n");
+ (void) fflush(stdout);
+ return(name);
+ }
+ break;
+ }
+ switch (*++cp2) {
+ case ',':
+ goto LOOP;
+ case ']':
+ break;
+ default:
+ cp2--;
+ goto LOOP;
+ }
+ break;
+ case '$':
+ if (isdigit(*(cp2 + 1))) {
+ if (*++cp2 == '0') {
+ char *cp3 = name;
+
+ while (*cp3) {
+ *cp1++ = *cp3++;
+ }
+ }
+ else if (toks[toknum = *cp2 - '1']) {
+ char *cp3 = tp[toknum];
+
+ while (cp3 != te[toknum]) {
+ *cp1++ = *cp3++;
+ }
+ }
+ break;
+ }
+ /* intentional drop through */
+ default:
+ *cp1++ = *cp2;
+ break;
+ }
+ cp2++;
+ }
+ *cp1 = '\0';
+ if (!*new) {
+ return(name);
+ }
+ return(new);
+}
+
+void setsunique()
+{
+ sunique = !sunique;
+ printf("Store unique %s.\n", onoff(sunique));
+ (void) fflush(stdout);
+ code = sunique;
+}
+
+void setrunique()
+{
+ runique = !runique;
+ printf("Receive unique %s.\n", onoff(runique));
+ (void) fflush(stdout);
+ code = runique;
+}
+
+/* change directory to perent directory */
+void cdup()
+{
+ if (command("CDUP") == ERROR && code == 500) {
+ if (verbose) {
+ printf("CDUP command not recognized, trying XCUP\n");
+ (void) fflush(stdout);
+ }
+ (void) command("XCUP");
+ }
+}
+
+/* restart transfer at specific point */
+void restart(argc, argv)
+ int argc;
+ char *argv[];
+{
+ extern long atol();
+ if (argc != 2)
+ printf("restart: offset not specified\n");
+ else {
+ restart_point = atol(argv[1]);
+ printf("restarting at %ld. %s\n", restart_point,
+ "execute get, put or append to initiate transfer");
+ }
+ (void) fflush(stdout);
+}
+
+/* show remote system type */
+void syst()
+{
+ (void) command("SYST");
+}
+
+void macdef(argc, argv)
+ int argc;
+ char *argv[];
+{
+ char *tmp;
+ int c;
+
+ if (macnum == 16) {
+ printf("Limit of 16 macros have already been defined\n");
+ (void) fflush(stdout);
+ code = -1;
+ return;
+ }
+ if (argc < 2) {
+ (void) strcat(line, " ");
+ printf("(macro name) ");
+ (void) fflush(stdout);
+ (void) gets(&line[strlen(line)]);
+ makeargv();
+ argc = margc;
+ argv = margv;
+ }
+ if (argc != 2) {
+ printf("Usage: %s macro_name\n",argv[0]);
+ (void) fflush(stdout);
+ code = -1;
+ return;
+ }
+ if (interactive) {
+ printf("Enter macro line by line, terminating it with a null line\n");
+ (void) fflush(stdout);
+ }
+ (void) strncpy(macros[macnum].mac_name, argv[1], 8);
+ if (macnum == 0) {
+ macros[macnum].mac_start = macbuf;
+ }
+ else {
+ macros[macnum].mac_start = macros[macnum - 1].mac_end + 1;
+ }
+ tmp = macros[macnum].mac_start;
+ while (tmp != macbuf+4096) {
+ if ((c = getchar()) == EOF) {
+ printf("macdef:end of file encountered\n");
+ (void) fflush(stdout);
+ code = -1;
+ return;
+ }
+ if ((*tmp = c) == '\n') {
+ if (tmp == macros[macnum].mac_start) {
+ macros[macnum++].mac_end = tmp;
+ code = 0;
+ return;
+ }
+ if (*(tmp-1) == '\0') {
+ macros[macnum++].mac_end = tmp - 1;
+ code = 0;
+ return;
+ }
+ *tmp = '\0';
+ }
+ tmp++;
+ }
+ while (1) {
+ while ((c = getchar()) != '\n' && c != EOF)
+ /* LOOP */;
+ if (c == EOF || getchar() == '\n') {
+ printf("Macro not defined - 4k buffer exceeded\n");
+ (void) fflush(stdout);
+ code = -1;
+ return;
+ }
+ }
+}
+
+/*
+ * get size of file on remote machine
+ */
+void sizecmd(argc, argv)
+ char *argv[];
+{
+
+ if (argc < 2) {
+ (void) strcat(line, " ");
+ printf("(filename) ");
+ (void) fflush(stdout);
+ (void) gets(&line[strlen(line)]);
+ makeargv();
+ argc = margc;
+ argv = margv;
+ }
+ if (argc < 2) {
+ printf("usage:%s filename\n", argv[0]);
+ (void) fflush(stdout);
+ code = -1;
+ return;
+ }
+ (void) command("SIZE %s", argv[1]);
+}
+
+/*
+ * get last modification time of file on remote machine
+ */
+void modtime(argc, argv)
+ char *argv[];
+{
+ int overbose;
+
+ if (argc < 2) {
+ (void) strcat(line, " ");
+ printf("(filename) ");
+ (void) fflush(stdout);
+ (void) gets(&line[strlen(line)]);
+ makeargv();
+ argc = margc;
+ argv = margv;
+ }
+ if (argc < 2) {
+ printf("usage:%s filename\n", argv[0]);
+ (void) fflush(stdout);
+ code = -1;
+ return;
+ }
+ overbose = verbose;
+ if (debug == 0)
+ verbose = -1;
+ if (command("MDTM %s", argv[1]) == COMPLETE) {
+ int yy, mo, day, hour, min, sec;
+ sscanf(reply_string, "%*s %04d%02d%02d%02d%02d%02d", &yy, &mo,
+ &day, &hour, &min, &sec);
+ /* might want to print this in local time */
+ printf("%s\t%02d/%02d/%04d %02d:%02d:%02d GMT\n", argv[1],
+ mo, day, yy, hour, min, sec);
+ } else
+ printf("%s\n", reply_string);
+ verbose = overbose;
+ (void) fflush(stdout);
+}
+
+/*
+ * show status on reomte machine
+ */
+void rmtstatus(argc, argv)
+ char *argv[];
+{
+ (void) command(argc > 1 ? "STAT %s" : "STAT" , argv[1]);
+}
+
+/*
+ * get file if modtime is more recent than current file
+ */
+void newer(argc, argv)
+ char *argv[];
+{
+ if (getit(argc, argv, -1, "w")) {
+ printf("Local file \"%s\" is newer than remote file \"%s\"\n",
+ argv[1], argv[2]);
+ (void) fflush(stdout);
+ }
+}
diff --git a/reactos/apps/utils/net/ftp/cmdtab.c b/reactos/apps/utils/net/ftp/cmdtab.c
new file mode 100644
index 00000000000..5dd04ff340f
--- /dev/null
+++ b/reactos/apps/utils/net/ftp/cmdtab.c
@@ -0,0 +1,185 @@
+/*
+ * Copyright (c) 1985, 1989 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the University of California, Berkeley. The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)cmdtab.c 5.9 (Berkeley) 3/21/89";
+#endif /* not lint */
+
+#include "ftp_var.h"
+
+/*
+ * User FTP -- Command Tables.
+ */
+int setascii(), setbell(), setbinary(), setdebug(), setform();
+int setglob(), sethash(), setmode(), setpeer(), setpassive(), setport();
+int setprompt(), setstruct();
+int settenex(), settrace(), settype(), setverbose();
+int disconnect(), restart(), reget(), syst();
+int cd(), lcd(), delete(), mdelete(), user();
+int ls(), mls(), get(), mget(), help(), append(), put(), mput();
+int quit(), renamefile(), status();
+int quote(), rmthelp(), shell(), site();
+int pwd(), makedir(), removedir(), setcr();
+int account(), doproxy(), reset(), setcase(), setntrans(), setnmap();
+int setsunique(), setrunique(), cdup(), macdef(), domacro();
+int sizecmd(), modtime(), newer(), rmtstatus();
+int do_chmod(), do_umask(), idle();
+
+char accounthelp[] = "send account command to remote server";
+char appendhelp[] = "append to a file";
+char asciihelp[] = "set ascii transfer type";
+char beephelp[] = "beep when command completed";
+char binaryhelp[] = "set binary transfer type";
+char casehelp[] = "toggle mget upper/lower case id mapping";
+char cdhelp[] = "change remote working directory";
+char cduphelp[] = "change remote working directory to parent directory";
+char chmodhelp[] = "change file permissions of remote file";
+char connecthelp[] = "connect to remote tftp";
+char crhelp[] = "toggle carriage return stripping on ascii gets";
+char deletehelp[] = "delete remote file";
+char debughelp[] = "toggle/set debugging mode";
+char dirhelp[] = "list contents of remote directory";
+char disconhelp[] = "terminate ftp session";
+char domachelp[] = "execute macro";
+char formhelp[] = "set file transfer format";
+char globhelp[] = "toggle metacharacter expansion of local file names";
+char hashhelp[] = "toggle printing `#' for each buffer transferred";
+char helphelp[] = "print local help information";
+char idlehelp[] = "get (set) idle timer on remote side";
+char lcdhelp[] = "change local working directory";
+char lshelp[] = "list contents of remote directory";
+char macdefhelp[] = "define a macro";
+char mdeletehelp[] = "delete multiple files";
+char mdirhelp[] = "list contents of multiple remote directories";
+char mgethelp[] = "get multiple files";
+char mkdirhelp[] = "make directory on the remote machine";
+char mlshelp[] = "list contents of multiple remote directories";
+char modtimehelp[] = "show last modification time of remote file";
+char modehelp[] = "set file transfer mode";
+char mputhelp[] = "send multiple files";
+char newerhelp[] = "get file if remote file is newer than local file ";
+char nlisthelp[] = "nlist contents of remote directory";
+char nmaphelp[] = "set templates for default file name mapping";
+char ntranshelp[] = "set translation table for default file name mapping";
+char porthelp[] = "toggle use of PORT cmd for each data connection";
+char prompthelp[] = "force interactive prompting on multiple commands";
+char proxyhelp[] = "issue command on alternate connection";
+char pwdhelp[] = "print working directory on remote machine";
+char quithelp[] = "terminate ftp session and exit";
+char quotehelp[] = "send arbitrary ftp command";
+char receivehelp[] = "receive file";
+char regethelp[] = "get file restarting at end of local file";
+char remotehelp[] = "get help from remote server";
+char renamehelp[] = "rename file";
+char restarthelp[]= "restart file transfer at bytecount";
+char rmdirhelp[] = "remove directory on the remote machine";
+char rmtstatushelp[]="show status of remote machine";
+char runiquehelp[] = "toggle store unique for local files";
+char resethelp[] = "clear queued command replies";
+char sendhelp[] = "send one file";
+char passivehelp[] = "enter passive transfer mode";
+char sitehelp[] = "send site specific command to remote server\n\t\tTry \"rhelp site\" or \"site help\" for more information";
+char shellhelp[] = "escape to the shell";
+char sizecmdhelp[] = "show size of remote file";
+char statushelp[] = "show current status";
+char structhelp[] = "set file transfer structure";
+char suniquehelp[] = "toggle store unique on remote machine";
+char systemhelp[] = "show remote system type";
+char tenexhelp[] = "set tenex file transfer type";
+char tracehelp[] = "toggle packet tracing";
+char typehelp[] = "set file transfer type";
+char umaskhelp[] = "get (set) umask on remote side";
+char userhelp[] = "send new user information";
+char verbosehelp[] = "toggle verbose mode";
+
+struct cmd cmdtab[] = {
+ { "!", shellhelp, 0, 0, 0, shell },
+ { "$", domachelp, 1, 0, 0, domacro },
+ { "account", accounthelp, 0, 1, 1, account},
+ { "append", appendhelp, 1, 1, 1, put },
+ { "ascii", asciihelp, 0, 1, 1, setascii },
+ { "bell", beephelp, 0, 0, 0, setbell },
+ { "binary", binaryhelp, 0, 1, 1, setbinary },
+ { "bye", quithelp, 0, 0, 0, quit },
+ { "case", casehelp, 0, 0, 1, setcase },
+ { "cd", cdhelp, 0, 1, 1, cd },
+ { "cdup", cduphelp, 0, 1, 1, cdup },
+ { "chmod", chmodhelp, 0, 1, 1, do_chmod },
+ { "close", disconhelp, 0, 1, 1, disconnect },
+ { "cr", crhelp, 0, 0, 0, setcr },
+ { "delete", deletehelp, 0, 1, 1, delete },
+ { "debug", debughelp, 0, 0, 0, setdebug },
+ { "dir", dirhelp, 1, 1, 1, ls },
+ { "disconnect", disconhelp, 0, 1, 1, disconnect },
+ { "form", formhelp, 0, 1, 1, setform },
+ { "get", receivehelp, 1, 1, 1, get },
+ { "glob", globhelp, 0, 0, 0, setglob },
+ { "hash", hashhelp, 0, 0, 0, sethash },
+ { "help", helphelp, 0, 0, 1, help },
+ { "idle", idlehelp, 0, 1, 1, idle },
+ { "image", binaryhelp, 0, 1, 1, setbinary },
+ { "lcd", lcdhelp, 0, 0, 0, lcd },
+ { "ls", lshelp, 1, 1, 1, ls },
+ { "macdef", macdefhelp, 0, 0, 0, macdef },
+ { "mdelete", mdeletehelp, 1, 1, 1, mdelete },
+ { "mdir", mdirhelp, 1, 1, 1, mls },
+ { "mget", mgethelp, 1, 1, 1, mget },
+ { "mkdir", mkdirhelp, 0, 1, 1, makedir },
+ { "mls", mlshelp, 1, 1, 1, mls },
+ { "mode", modehelp, 0, 1, 1, setmode },
+ { "modtime", modtimehelp, 0, 1, 1, modtime },
+ { "mput", mputhelp, 1, 1, 1, mput },
+ { "newer", newerhelp, 1, 1, 1, newer },
+ { "nmap", nmaphelp, 0, 0, 1, setnmap },
+ { "nlist", nlisthelp, 1, 1, 1, ls },
+ { "ntrans", ntranshelp, 0, 0, 1, setntrans },
+ { "open", connecthelp, 0, 0, 1, setpeer },
+ { "passive",passivehelp,0, 0, 0, setpassive },
+ { "prompt", prompthelp, 0, 0, 0, setprompt },
+ { "proxy", proxyhelp, 0, 0, 1, doproxy },
+ { "sendport", porthelp, 0, 0, 0, setport },
+ { "put", sendhelp, 1, 1, 1, put },
+ { "pwd", pwdhelp, 0, 1, 1, pwd },
+ { "quit", quithelp, 0, 0, 0, quit },
+ { "quote", quotehelp, 1, 1, 1, quote },
+ { "recv", receivehelp, 1, 1, 1, get },
+ { "reget", regethelp, 1, 1, 1, reget },
+ { "rstatus", rmtstatushelp, 0, 1, 1, rmtstatus },
+ { "rhelp", remotehelp, 0, 1, 1, rmthelp },
+ { "rename", renamehelp, 0, 1, 1, renamefile },
+ { "reset", resethelp, 0, 1, 1, reset },
+ { "restart", restarthelp, 1, 1, 1, restart },
+ { "rmdir", rmdirhelp, 0, 1, 1, removedir },
+ { "runique", runiquehelp, 0, 0, 1, setrunique },
+ { "send", sendhelp, 1, 1, 1, put },
+ { "site", sitehelp, 0, 1, 1, site },
+ { "size", sizecmdhelp, 1, 1, 1, sizecmd },
+ { "status", statushelp, 0, 0, 1, status },
+ { "struct", structhelp, 0, 1, 1, setstruct },
+ { "system", systemhelp, 0, 1, 1, syst },
+ { "sunique", suniquehelp, 0, 0, 1, setsunique },
+ { "tenex", tenexhelp, 0, 1, 1, settenex },
+ { "trace", tracehelp, 0, 0, 0, settrace },
+ { "type", typehelp, 0, 1, 1, settype },
+ { "user", userhelp, 0, 1, 1, user },
+ { "umask", umaskhelp, 0, 1, 1, do_umask },
+ { "verbose", verbosehelp, 0, 0, 0, setverbose },
+ { "?", helphelp, 0, 0, 1, help },
+ { 0 },
+};
+
+int NCMDS = (sizeof (cmdtab) / sizeof (cmdtab[0])) - 1;
diff --git a/reactos/apps/utils/net/ftp/domacro.c b/reactos/apps/utils/net/ftp/domacro.c
new file mode 100644
index 00000000000..a4eeed1914a
--- /dev/null
+++ b/reactos/apps/utils/net/ftp/domacro.c
@@ -0,0 +1,149 @@
+/*
+ * Copyright (c) 1985 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the University of California, Berkeley. The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)domacro.c 1.6 (Berkeley) 2/28/89";
+#endif /* not lint */
+
+#include "ftp_var.h"
+#include "prototypes.h"
+
+#include
+#include
+//#include
+#include
+//#include
+
+void domacro(argc, argv)
+ int argc;
+ char *argv[];
+{
+ register int i, j;
+ register char *cp1, *cp2;
+ int count = 2, loopflg = 0;
+ char line2[200];
+ extern char **glob(), *globerr;
+ struct cmd *getcmd(), *c;
+ extern struct cmd cmdtab[];
+
+ if (argc < 2) {
+ (void) strcat(line, " ");
+ printf("(macro name) ");
+ (void) fflush(stdout);
+ (void) gets(&line[strlen(line)]);
+ makeargv();
+ argc = margc;
+ argv = margv;
+ }
+ if (argc < 2) {
+ printf("Usage: %s macro_name.\n", argv[0]);
+ (void) fflush(stdout);
+ code = -1;
+ return;
+ }
+ for (i = 0; i < macnum; ++i) {
+ if (!strncmp(argv[1], macros[i].mac_name, 9)) {
+ break;
+ }
+ }
+ if (i == macnum) {
+ printf("'%s' macro not found.\n", argv[1]);
+ (void) fflush(stdout);
+ code = -1;
+ return;
+ }
+ (void) strcpy(line2, line);
+TOP:
+ cp1 = macros[i].mac_start;
+ while (cp1 != macros[i].mac_end) {
+ while (isspace(*cp1)) {
+ cp1++;
+ }
+ cp2 = line;
+ while (*cp1 != '\0') {
+ switch(*cp1) {
+ case '\\':
+ *cp2++ = *++cp1;
+ break;
+ case '$':
+ if (isdigit(*(cp1+1))) {
+ j = 0;
+ while (isdigit(*++cp1)) {
+ j = 10*j + *cp1 - '0';
+ }
+ cp1--;
+ if (argc - 2 >= j) {
+ (void) strcpy(cp2, argv[j+1]);
+ cp2 += strlen(argv[j+1]);
+ }
+ break;
+ }
+ if (*(cp1+1) == 'i') {
+ loopflg = 1;
+ cp1++;
+ if (count < argc) {
+ (void) strcpy(cp2, argv[count]);
+ cp2 += strlen(argv[count]);
+ }
+ break;
+ }
+ /* intentional drop through */
+ default:
+ *cp2++ = *cp1;
+ break;
+ }
+ if (*cp1 != '\0') {
+ cp1++;
+ }
+ }
+ *cp2 = '\0';
+ makeargv();
+ c = getcmd(margv[0]);
+ if (c == (struct cmd *)-1) {
+ printf("?Ambiguous command\n");
+ code = -1;
+ }
+ else if (c == 0) {
+ printf("?Invalid command\n");
+ code = -1;
+ }
+ else if (c->c_conn && !connected) {
+ printf("Not connected.\n");
+ code = -1;
+ }
+ else {
+ if (verbose) {
+ printf("%s\n",line);
+ }
+ (*c->c_handler)(margc, margv);
+ if (bell && c->c_bell) {
+ (void) putchar('\007');
+ }
+ (void) strcpy(line, line2);
+ makeargv();
+ argc = margc;
+ argv = margv;
+ }
+ if (cp1 != macros[i].mac_end) {
+ cp1++;
+ }
+ (void) fflush(stdout);
+ }
+ if (loopflg && ++count < argc) {
+ goto TOP;
+ }
+}
diff --git a/reactos/apps/utils/net/ftp/fake.c b/reactos/apps/utils/net/ftp/fake.c
new file mode 100644
index 00000000000..24f549f25a3
--- /dev/null
+++ b/reactos/apps/utils/net/ftp/fake.c
@@ -0,0 +1,344 @@
+#include
+#include
+#include
+#include "prototypes.h"
+
+#define MAX_ASCII 100
+
+int checkRecv(SOCKET s);
+
+int checkRecv(SOCKET s)
+{
+ int testVal;
+ fd_set sSet;
+ struct timeval timeout;
+ timeout.tv_sec = 60;
+
+ FD_ZERO(&sSet);
+
+ FD_SET(s, &sSet);
+
+ testVal = select(0, &sSet, NULL, NULL, &timeout);
+
+ if (testVal == SOCKET_ERROR)
+ fprintf(stderr, "Socket Error");
+
+ return testVal;
+}
+
+void blkfree(char **av0)
+{
+ register char **av = av0;
+
+ while (*av)
+ free(*av++);
+}
+
+char *glob(register char *v)
+{
+ return NULL;
+}
+
+
+int sleep(int time)
+{
+ return time;
+}
+
+int herror(char *string)
+{
+ return 0;
+}
+#if 0
+
+int gettimeofday(struct timeval *timenow,
+ struct timezone *zone)
+{
+ time_t t;
+
+ t = clock();
+
+ timenow->tv_usec = t;
+ timenow->tv_sec = t / CLK_TCK;
+
+ return 0;
+}
+
+int fgetcSocket(int s)
+{
+ int c;
+ char buffer[10];
+
+// checkRecv(s);
+
+ c = recv(s, buffer, 1, 0);
+
+#ifdef DEBUG_IN
+ printf("%c", buffer[0]);
+#endif
+
+ if (c == INVALID_SOCKET)
+ return c;
+
+ if (c == 0)
+ return EOF;
+
+ return buffer[0];
+}
+
+#else
+
+int fgetcSocket(int s)
+{
+ static int index = 0;
+ static int total = 0;
+ static unsigned char buffer[4096];
+
+ if (index == total)
+ {
+ index = 0;
+ total = recv(s, buffer, sizeof(buffer), 0);
+
+ if (total == INVALID_SOCKET)
+ {
+ total = 0;
+ return ERROR;
+ }
+
+ if (total == 0)
+ return EOF;
+ }
+ return buffer[index++];
+}
+
+#endif
+
+char *fprintfSocket(int s, char *format, ...)
+{
+ va_list argptr;
+ char buffer[10009];
+
+ va_start(argptr, format);
+ vsprintf(buffer, format, argptr);
+ va_end(argptr);
+
+ send(s, buffer, strlen(buffer), 0);
+
+ return NULL;
+}
+
+char *fputsSocket(char *format, int s)
+{
+ send(s, format, strlen(format), 0);
+
+ return NULL;
+}
+
+int fputcSocket(int s, char putChar)
+{
+ char buffer[2];
+
+ buffer[0] = putChar;
+ buffer[1] = '\0';
+
+ if(SOCKET_ERROR==send(s, buffer, 1, 0)) {
+ int iret=WSAGetLastError ();
+ fprintf(stdout,"fputcSocket: %d\n",iret);
+ return 0;
+ }
+ else {
+ return putChar;
+ }
+}
+int fputSocket(int s, char *buffer, int len)
+{
+ int iret;
+ while(len) {
+ if(SOCKET_ERROR==(iret=send(s, buffer, len, 0)))
+ {
+ iret=WSAGetLastError ();
+ fprintf(stdout,"fputcSocket: %d\n",iret);
+ return 0;
+ }
+ else {
+ return len-=iret;
+ }
+ }
+ return 0;
+}
+
+char *fgetsSocket(int s, char *string)
+{
+ char buffer[2] = {0};
+ int i, count;
+
+ for (i = 0, count = 1; count != 0 && buffer[0] != '\n'; i++)
+ {
+ checkRecv(s);
+
+ count = recv(s, buffer, 1, 0);
+
+ if (count == SOCKET_ERROR)
+ {
+ printf("Error in fgetssocket");
+ return NULL;
+ }
+
+ if (count == 1)
+ {
+ string[i] = buffer[0];
+
+ if (i == MAX_ASCII - 3)
+ {
+ count = 0;
+ string[++i] = '\n';
+ string[++i] = '\0';
+ }
+ }
+ else
+ {
+ if (i == 0)
+ return NULL;
+ else
+ {
+ string[i] = '\n';
+ string[i + 1] = '\0'; // This is risky
+ return string;
+ }
+
+ }
+
+ }
+ string[i] = '\0';
+
+#ifdef DEBUG_IN
+ printf("%s", string);
+#endif
+ return string;
+}
+
+
+#if 0
+char *getpass(const char *prompt)
+{
+ static char string[64];
+
+ printf("%s", prompt);
+
+ gets(string);
+
+ return string;
+}
+#endif
+char *getpass (const char * prompt)
+{
+ static char input[256];
+ HANDLE in;
+ HANDLE err;
+ int count;
+
+ in = GetStdHandle (STD_INPUT_HANDLE);
+ err = GetStdHandle (STD_ERROR_HANDLE);
+
+ if (in == INVALID_HANDLE_VALUE || err == INVALID_HANDLE_VALUE)
+ return NULL;
+
+ if (WriteFile (err, prompt, strlen (prompt), &count, NULL))
+ {
+ int istty = (GetFileType (in) == FILE_TYPE_CHAR);
+ DWORD old_flags;
+ int rc;
+
+ if (istty)
+ {
+ if (GetConsoleMode (in, &old_flags))
+ SetConsoleMode (in, ENABLE_LINE_INPUT | ENABLE_PROCESSED_INPUT);
+ else
+ istty = 0;
+ }
+ /* Need to read line one byte at time to avoid blocking, if not a
+ tty, so always do it this way. */
+ count = 0;
+ while (1)
+ {
+ DWORD dummy;
+ char one_char;
+
+ rc = ReadFile (in, &one_char, 1, &dummy, NULL);
+ if (rc == 0)
+ break;
+ if (one_char == '\r')
+ {
+ /* CR is always followed by LF if reading from tty. */
+ if (istty)
+ continue;
+ else
+ break;
+ }
+ if (one_char == '\n')
+ break;
+ /* Silently truncate password string if overly long. */
+ if (count < sizeof (input) - 1)
+ input[count++] = one_char;
+ }
+ input[count] = '\0';
+
+ WriteFile (err, "\r\n", 2, &count, NULL);
+ if (istty)
+ SetConsoleMode (in, old_flags);
+ if (rc)
+ return input;
+ }
+
+ return NULL;
+}
+
+// Stubbed out here. Should be changed in Source code...
+int access(const char *filename, int accessmethod)
+{
+ return 0;
+}
+
+#ifndef __GNUC__
+#define EPOCHFILETIME (116444736000000000i64)
+#else
+#define EPOCHFILETIME (116444736000000000LL)
+#endif
+
+struct timezone {
+ int tz_minuteswest; /* minutes W of Greenwich */
+ int tz_dsttime; /* type of dst correction */
+};
+
+__inline int gettimeofday(struct timeval *tv, struct timezone *tz)
+{
+ FILETIME ft;
+ LARGE_INTEGER li;
+ __int64 t;
+ static int tzflag;
+
+ if (tv)
+ {
+ GetSystemTimeAsFileTime(&ft);
+ //li.LowPart = ft.dwLowDateTime;
+ //li.HighPart = ft.dwHighDateTime;
+ t = li.QuadPart; /* In 100-nanosecond intervals */
+ t -= EPOCHFILETIME; /* Offset to the Epoch time */
+ t /= 10; /* In microseconds */
+ tv->tv_sec = (long)(t / 1000000);
+ tv->tv_usec = (long)(t % 1000000);
+ }
+
+ if (tz)
+ {
+ if (!tzflag)
+ {
+ _tzset();
+ tzflag++;
+ }
+ tz->tz_minuteswest = _timezone / 60;
+ tz->tz_dsttime = _daylight;
+ }
+
+ return 0;
+}
diff --git a/reactos/apps/utils/net/ftp/fake.h b/reactos/apps/utils/net/ftp/fake.h
new file mode 100644
index 00000000000..816c7818064
--- /dev/null
+++ b/reactos/apps/utils/net/ftp/fake.h
@@ -0,0 +1,10 @@
+#define bcopy(s,d,l) memcpy((d),(s),(l))
+#define bzero(cp,l) memset((cp),0,(l))
+
+#define rindex strrchr
+#define index strchr
+
+#define getwd getcwd
+
+#define strcasecmp strcmp
+#define strncasecmp strnicmp
diff --git a/reactos/apps/utils/net/ftp/ftp.c b/reactos/apps/utils/net/ftp/ftp.c
new file mode 100644
index 00000000000..34d443be6a5
--- /dev/null
+++ b/reactos/apps/utils/net/ftp/ftp.c
@@ -0,0 +1,1805 @@
+#define L_SET SEEK_SET
+#define L_INCR SEEK_CUR
+#define caddr_t void *
+/*
+ * Copyright (c) 1985, 1989 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the University of California, Berkeley. The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)ftp.c 5.28 (Berkeley) 4/20/89";
+#endif /* not lint */
+#include
+
+#include
+
+#if !defined(WIN32)
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#else
+#include
+#endif
+
+#include
+#include
+#include
+#include
+
+#include "ftp_var.h"
+#include "prototypes.h"
+#ifndef MAXHOSTNAMELEN
+#define MAXHOSTNAMELEN 64
+#endif
+
+#ifdef NOVFPRINTF
+#define vfprintf(a,b,c) _doprnt(b,c,a)
+#endif
+
+#ifdef sun
+/* FD_SET wasn't defined until 4.0. its a cheap test for uid_t presence */
+#ifndef FD_SET
+#define NBBY 8 /* number of bits in a byte */
+/*
+ * Select uses bit masks of file descriptors in longs.
+ * These macros manipulate such bit fields (the filesystem macros use chars).
+ * FD_SETSIZE may be defined by the user, but the default here
+ * should be >= NOFILE (param.h).
+ */
+#ifndef FD_SETSIZE
+#define FD_SETSIZE 256
+#endif
+
+typedef long fd_mask;
+#define NFDBITS (sizeof(fd_mask) * NBBY) /* bits per mask */
+#ifndef howmany
+#define howmany(x, y) (((x)+((y)-1))/(y))
+#endif
+
+#define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
+#define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
+#define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
+#define FD_ZERO(p) bzero((char *)(p), sizeof(*(p)))
+
+typedef int uid_t;
+typedef int gid_t;
+#endif
+#endif
+
+struct sockaddr_in hisctladdr;
+struct sockaddr_in data_addr;
+int data = -1;
+int abrtflag = 0;
+int ptflag = 0;
+int allbinary;
+struct sockaddr_in myctladdr;
+uid_t getuid();
+sig_t lostpeer();
+off_t restart_point = 0;
+
+int cin, cout;
+int dataconn(char *mode);
+
+int command(char *fmt, ...);
+
+char *hostname;
+
+typedef void (*Sig_t)(int);
+
+// Signal Handlers
+
+void psabort(int sig);
+
+char *hookup(char *host, int port)
+{
+ register struct hostent *hp = 0;
+ int s,len;
+ static char hostnamebuf[80];
+
+ bzero((char *)&hisctladdr, sizeof (hisctladdr));
+ hisctladdr.sin_addr.s_addr = inet_addr(host);
+ if (hisctladdr.sin_addr.s_addr != -1) {
+ hisctladdr.sin_family = AF_INET;
+ (void) strncpy(hostnamebuf, host, sizeof(hostnamebuf));
+ } else {
+ hp = gethostbyname(host);
+ if (hp == NULL) {
+ fprintf(stderr, "ftp: %s: ", host);
+ herror((char *)NULL);
+ code = -1;
+ return((char *) 0);
+ }
+ hisctladdr.sin_family = hp->h_addrtype;
+ bcopy(hp->h_addr_list[0],
+ (caddr_t)&hisctladdr.sin_addr, hp->h_length);
+ (void) strncpy(hostnamebuf, hp->h_name, sizeof(hostnamebuf));
+ }
+ hostname = hostnamebuf;
+ s = socket(hisctladdr.sin_family, SOCK_STREAM, 0);
+ if (s < 0) {
+ perror("ftp: socket");
+ code = -1;
+ return (0);
+ }
+ hisctladdr.sin_port = port;
+ while (connect(s, (struct sockaddr *)&hisctladdr, sizeof (hisctladdr)) < 0) {
+ if (hp && hp->h_addr_list[1]) {
+ int oerrno = errno;
+
+ fprintf(stderr, "ftp: connect to address %s: ",
+ inet_ntoa(hisctladdr.sin_addr));
+ errno = oerrno;
+ perror((char *) 0);
+ hp->h_addr_list++;
+ bcopy(hp->h_addr_list[0],
+ (caddr_t)&hisctladdr.sin_addr, hp->h_length);
+ fprintf(stdout, "Trying %s...\n",
+ inet_ntoa(hisctladdr.sin_addr));
+ (void) fflush(stdout);
+ (void) close(s);
+ s = socket(hisctladdr.sin_family, SOCK_STREAM, 0);
+ if (s < 0) {
+ perror("ftp: socket");
+ code = -1;
+ return (0);
+ }
+ continue;
+ }
+ perror("ftp: connect");
+ code = -1;
+ goto bad;
+ }
+ len = sizeof (myctladdr);
+ if (getsockname(s, (struct sockaddr *)&myctladdr, &len) < 0) {
+ perror("ftp: getsockname");
+ code = -1;
+ goto bad;
+ }
+ cin = cout = s;
+ if (verbose) {
+ printf("Connected to %s.\n", hostname);
+ (void) fflush(stdout);
+ }
+ if (getreply(0) > 2) { /* read startup message from server */
+ closesocket(cin);
+ code = -1;
+ goto bad;
+ }
+#ifdef SO_OOBINLINE
+ {
+ int on = 1;
+
+ if (setsockopt(s, SOL_SOCKET, SO_OOBINLINE, (const char *) &on, sizeof(on))
+ < 0 && debug) {
+ perror("ftp: setsockopt");
+ }
+ }
+#endif //SO_OOBINLINE
+
+ return (hostname);
+bad:
+ (void) close(s);
+ return ((char *)0);
+}
+
+int login(char *host)
+{
+ char tmp[80];
+ char *user, *pass, *acct;
+ int n, aflag = 0;
+
+ user = pass = acct = 0;
+ if (ruserpass(host, &user, &pass, &acct) < 0) {
+ code = -1;
+ return(0);
+ }
+ while (user == NULL) {
+ char *myname = "none"; // This needs to become the usename env
+
+ if (myname)
+ printf("Name (%s:%s): ", host, myname);
+ else
+ printf("Name (%s): ", host);
+ (void) fflush(stdout);
+ (void) fgets(tmp, sizeof(tmp) - 1, stdin);
+ tmp[strlen(tmp) - 1] = '\0';
+ if (*tmp == '\0')
+ user = myname;
+ else
+ user = tmp;
+ }
+ n = command("USER %s", user);
+ if (n == CONTINUE) {
+ if (pass == NULL)
+ pass = getpass("Password:");
+ n = command("PASS %s", pass);
+ fflush(stdin);
+ }
+ if (n == CONTINUE) {
+ aflag++;
+ acct = getpass("Account:");
+ n = command("ACCT %s", acct);
+ }
+ if (n != COMPLETE) {
+ fprintf(stderr, "Login failed.\n");
+ return (0);
+ }
+ if (!aflag && acct != NULL)
+ (void) command("ACCT %s", acct);
+ if (proxy)
+ return(1);
+ for (n = 0; n < macnum; ++n) {
+ if (!strcmp("init", macros[n].mac_name)) {
+ (void) strcpy(line, "$init");
+ makeargv();
+ domacro(margc, margv);
+ break;
+ }
+ }
+ return (1);
+}
+
+void
+cmdabort(int sig)
+{
+ extern jmp_buf ptabort;
+
+ printf("\n");
+ (void) fflush(stdout);
+ abrtflag++;
+ if (ptflag)
+ longjmp(ptabort,1);
+}
+
+/*VARARGS1*/
+int command(char *fmt, ...)
+{
+ va_list ap;
+ int r;
+ void (*oldintr)(int), cmdabort(int);
+
+ abrtflag = 0;
+ if (debug) {
+ printf("---> ");
+ va_start(ap, fmt);
+ vfprintf(stdout, fmt, ap);
+ va_end(ap);
+ printf("\n");
+ (void) fflush(stdout);
+ }
+ if (cout == (int) NULL) {
+ perror ("No control connection for command");
+ code = -1;
+ return (0);
+ }
+ oldintr = signal(SIGINT,cmdabort);
+ {
+ char buffer[1024];
+
+ va_start(ap, fmt);
+ vsprintf(buffer, fmt, ap);
+ va_end(ap);
+//DLJ: to work through firewalls - send the command as a single message
+ strcat(buffer,"\r\n");
+ fprintfSocket(cout, buffer);
+ }
+//DLJ: the following two lines are replaced by the strcat above - seems to
+// make it work through firewalls.
+// fprintfSocket(cout, "\r\n");
+// (void) fflush(cout);
+ cpend = 1;
+ r = getreply(!strcmp(fmt, "QUIT"));
+ if (abrtflag && oldintr != SIG_IGN)
+ (*oldintr)(SIGINT);
+// (void) signal(SIGINT, oldintr);
+ return(r);
+}
+
+char reply_string[BUFSIZ]; /* last line of previous reply */
+
+#include
+
+getreply(expecteof)
+ int expecteof;
+{
+ register int c, n;
+ register int dig;
+ register char *cp;
+ int originalcode = 0, continuation = 0;
+ void (*oldintr)(int), cmdabort(int);
+ int pflag = 0;
+ char *pt = pasv;
+
+ oldintr = signal(SIGINT,cmdabort);
+ for (;;) {
+ dig = n = code = 0;
+ cp = reply_string;
+ while ((c = fgetcSocket(cin)) != '\n') {
+ if (c == IAC) { /* handle telnet commands */
+ switch (c = fgetcSocket(cin)) {
+ case WILL:
+ case WONT:
+ c = fgetcSocket(cin);
+ fprintfSocket(cout, "%c%c%c",IAC,DONT,c);
+ break;
+ case DO:
+ case DONT:
+ c = fgetcSocket(cin);
+ fprintfSocket(cout, "%c%c%c",IAC,WONT,c);
+ break;
+ default:
+ break;
+ }
+ continue;
+ }
+ dig++;
+ if (c == EOF) {
+ if (expecteof) {
+// (void) signal(SIGINT,oldintr);
+ code = 221;
+ return (0);
+ }
+ lostpeer();
+ if (verbose) {
+ printf("421 Service not available, remote server has closed connection\n");
+ (void) fflush(stdout);
+ }
+ code = 421;
+ return(4);
+ }
+ if (c != '\r' && (verbose > 0 ||
+ (verbose > -1 && n == '5' && dig > 4))) {
+ if (proxflag &&
+ (dig == 1 || dig == 5 && verbose == 0))
+ printf("%s:",hostname);
+ (void) putchar(c);
+ (void) fflush(stdout);
+ }
+ if (dig < 4 && isdigit(c))
+ code = code * 10 + (c - '0');
+ if (!pflag && code == 227)
+ pflag = 1;
+ if (dig > 4 && pflag == 1 && isdigit(c))
+ pflag = 2;
+ if (pflag == 2) {
+ if (c != '\r' && c != ')')
+ *pt++ = c;
+ else {
+ *pt = '\0';
+ pflag = 3;
+ }
+ }
+ if (dig == 4 && c == '-') {
+ if (continuation)
+ code = 0;
+ continuation++;
+ }
+ if (n == 0)
+ n = c;
+ if (cp < &reply_string[sizeof(reply_string) - 1])
+ *cp++ = c;
+ }
+ if (verbose > 0 || verbose > -1 && n == '5') {
+ (void) putchar(c);
+ (void) fflush (stdout);
+ }
+ if (continuation && code != originalcode) {
+ if (originalcode == 0)
+ originalcode = code;
+ continue;
+ }
+ *cp = '\0';
+ if (n != '1')
+ cpend = 0;
+ (void) signal(SIGINT,oldintr);
+ if (code == 421 || originalcode == 421)
+ lostpeer();
+ if (abrtflag && oldintr != cmdabort && oldintr != SIG_IGN)
+ (*oldintr)(SIGINT);
+ return (n - '0');
+ }
+}
+
+empty(mask, sec)
+ struct fd_set *mask;
+ int sec;
+{
+ struct timeval t;
+
+ t.tv_sec = (long) sec;
+ t.tv_usec = 0;
+ return(select(32, mask, (struct fd_set *) 0, (struct fd_set *) 0, &t));
+}
+
+jmp_buf sendabort;
+
+void abortsend()
+{
+
+ mflag = 0;
+ abrtflag = 0;
+ printf("\nsend aborted\n");
+ (void) fflush(stdout);
+ longjmp(sendabort, 1);
+}
+
+#define HASHBYTES 1024
+
+void sendrequest(char *cmd, char *local, char *remote, int printnames)
+{
+ FILE *fin;
+ int dout = 0;
+ int (*closefunc)(), _pclose(), fclose();
+ sig_t (*oldintr)(), (*oldintp)();
+ void abortsend();
+ char buf[BUFSIZ], *bufp;
+ long bytes = 0, hashbytes = HASHBYTES;
+ register int c, d;
+ struct stat st;
+ struct timeval start, stop;
+ char *mode;
+
+ if (verbose && printnames) {
+ if (local && *local != '-')
+ printf("local: %s ", local);
+ if (remote)
+ printf("remote: %s\n", remote);
+ (void) fflush(stdout);
+ }
+ if (proxy) {
+ proxtrans(cmd, local, remote);
+ return;
+ }
+ closefunc = NULL;
+ oldintr = NULL;
+ oldintp = NULL;
+ mode = "w";
+ if (setjmp(sendabort)) {
+ while (cpend) {
+ (void) getreply(0);
+ }
+ if (data >= 0) {
+ (void) close(data);
+ data = -1;
+ }
+ if (oldintr)
+null();// (void) signal(SIGINT,oldintr);
+ if (oldintp)
+null();// (void) signal(SIGPIPE,oldintp);
+ code = -1;
+ return;
+ }
+null();// oldintr = signal(SIGINT, abortsend);
+ if (strcmp(local, "-") == 0)
+ fin = stdin;
+ else if (*local == '|') {
+null();// oldintp = signal(SIGPIPE,SIG_IGN);
+ fin = _popen(local + 1, "r");
+ if (fin == NULL) {
+ perror(local + 1);
+null();// (void) signal(SIGINT, oldintr);
+null();// (void) signal(SIGPIPE, oldintp);
+ code = -1;
+ return;
+ }
+ closefunc = _pclose;
+ } else {
+ fin = fopen(local, "r");
+ if (fin == NULL) {
+ perror(local);
+null();// (void) signal(SIGINT, oldintr);
+ code = -1;
+ return;
+ }
+ closefunc = fclose;
+ if (fstat(fileno(fin), &st) < 0 ||
+ (st.st_mode&S_IFMT) != S_IFREG) {
+ fprintf(stdout, "%s: not a plain file.\n", local);
+ (void) fflush(stdout);
+null();// (void) signal(SIGINT, oldintr);
+ fclose(fin);
+ code = -1;
+ return;
+ }
+ }
+ if (initconn()) {
+null();// (void) signal(SIGINT, oldintr);
+ if (oldintp)
+null();// (void) signal(SIGPIPE, oldintp);
+ code = -1;
+ if (closefunc != NULL)
+ (*closefunc)(fin);
+ return;
+ }
+ if (setjmp(sendabort))
+ goto abort;
+
+ if (restart_point &&
+ (strcmp(cmd, "STOR") == 0 || strcmp(cmd, "APPE") == 0)) {
+ if (fseek(fin, (long) restart_point, 0) < 0) {
+ perror(local);
+ restart_point = 0;
+ if (closefunc != NULL)
+ (*closefunc)(fin);
+ return;
+ }
+ if (command("REST %ld", (long) restart_point)
+ != CONTINUE) {
+ restart_point = 0;
+ if (closefunc != NULL)
+ (*closefunc)(fin);
+ return;
+ }
+ restart_point = 0;
+ mode = "r+w";
+ }
+ if (remote) {
+ if (command("%s %s", cmd, remote) != PRELIM) {
+null();// (void) signal(SIGINT, oldintr);
+ if (oldintp)
+null();// (void) signal(SIGPIPE, oldintp);
+ if (closefunc != NULL)
+ (*closefunc)(fin);
+ return;
+ }
+ } else
+ if (command("%s", cmd) != PRELIM) {
+null();// (void) signal(SIGINT, oldintr);
+ if (oldintp)
+null();// (void) signal(SIGPIPE, oldintp);
+ if (closefunc != NULL)
+ (*closefunc)(fin);
+ return;
+ }
+ dout = dataconn(mode);
+ if (dout == (int)NULL)
+ goto abort;
+ (void) gettimeofday(&start, (struct timezone *)0);
+null();// oldintp = signal(SIGPIPE, SIG_IGN);
+ switch (type) {
+
+ case TYPE_I:
+ case TYPE_L:
+ errno = d = 0;
+ while ((c = read(fileno(fin), buf, sizeof (buf))) > 0) {
+ bytes += c;
+ for (bufp = buf; c > 0; c -= d, bufp += d)
+ if ((d = send(dout, bufp, c, 0)) <= 0)
+ break;
+ if (hash) {
+ while (bytes >= hashbytes) {
+ (void) putchar('#');
+ hashbytes += HASHBYTES;
+ }
+ (void) fflush(stdout);
+ }
+ }
+ if (hash && bytes > 0) {
+ if (bytes < HASHBYTES)
+ (void) putchar('#');
+ (void) putchar('\n');
+ (void) fflush(stdout);
+ }
+ if (c < 0)
+ perror(local);
+ if (d <= 0) {
+ if (d == 0)
+ fprintf(stderr, "netout: write returned 0?\n");
+ else if (errno != EPIPE)
+ perror("netout");
+ bytes = -1;
+ }
+ break;
+
+ case TYPE_A:
+ {
+ char buf[1024];
+ static int bufsize = 1024;
+ int ipos=0;
+
+ while ((c = getc(fin)) != EOF) {
+ if (c == '\n') {
+ while (hash && (bytes >= hashbytes)) {
+ (void) putchar('#');
+ (void) fflush(stdout);
+ hashbytes += HASHBYTES;
+ }
+// Szurgot: The following code is unncessary on Win32.
+// (void) fputcSocket(dout, '\r');
+// bytes++;
+ }
+
+ if (ipos >= bufsize) {
+ fputSocket(dout,buf,ipos);
+ if(!hash) (void) putchar('.');
+ ipos=0;
+ }
+ buf[ipos]=c; ++ipos;
+ bytes++;
+ }
+ if (ipos) {
+ fputSocket(dout,buf,ipos);
+ ipos=0;
+ }
+ if (hash) {
+ if (bytes < hashbytes)
+ (void) putchar('#');
+ (void) putchar('\n');
+ (void) fflush(stdout);
+ }
+ else {
+ (void) putchar('.');
+ (void) putchar('\n');
+ (void) fflush(stdout);
+ }
+ if (ferror(fin))
+ perror(local);
+// if (ferror(dout)) {
+// if (errno != EPIPE)
+// perror("netout");
+// bytes = -1;
+// }
+ break;
+ }
+ }
+ (void) gettimeofday(&stop, (struct timezone *)0);
+ if (closefunc != NULL)
+ (*closefunc)(fin);
+ if(closesocket(dout)) {
+ int iret=WSAGetLastError ();
+ fprintf(stdout,"Error closing socket(%d)\n",iret);
+ (void) fflush(stdout);
+ }
+ (void) getreply(0);
+null();// (void) signal(SIGINT, oldintr);
+ if (oldintp)
+null();// (void) signal(SIGPIPE, oldintp);
+ if (bytes > 0)
+ ptransfer("sent", bytes, &start, &stop);
+ return;
+abort:
+ (void) gettimeofday(&stop, (struct timezone *)0);
+null();// (void) signal(SIGINT, oldintr);
+ if (oldintp)
+null();// (void) signal(SIGPIPE, oldintp);
+ if (!cpend) {
+ code = -1;
+ return;
+ }
+ if (data >= 0) {
+ (void) close(data);
+ data = -1;
+ }
+ if (dout)
+ if(closesocket(dout)) {
+ int iret=WSAGetLastError ();
+ fprintf(stdout,"Error closing socket(%d)\n",iret);
+ (void) fflush(stdout);
+ }
+
+ (void) getreply(0);
+ code = -1;
+ if (closefunc != NULL && fin != NULL)
+ (*closefunc)(fin);
+ if (bytes > 0)
+ ptransfer("sent", bytes, &start, &stop);
+}
+
+jmp_buf recvabort;
+
+
+void abortrecv()
+{
+
+ mflag = 0;
+ abrtflag = 0;
+ printf("\n");
+ (void) fflush(stdout);
+ longjmp(recvabort, 1);
+}
+
+void recvrequest(char *cmd, char *local, char *remote, char *mode,
+ int printnames)
+{
+ FILE *fout;
+ int din = 0;
+ int (*closefunc)(), _pclose(), fclose();
+ void (*oldintr)(int), (*oldintp)(int);
+ void abortrecv();
+ int oldverbose, oldtype = 0, is_retr, tcrflag, nfnd, bare_lfs = 0;
+ char *gunique(), msg;
+// static char *buf; // Szurgot: Shouldn't this go SOMEWHERE?
+ char buf[1024];
+ static int bufsize = 1024;
+ long bytes = 0, hashbytes = HASHBYTES;
+// struct
+ fd_set mask;
+ register int c, d;
+ struct timeval start, stop;
+// struct stat st;
+ extern void *malloc();
+
+ is_retr = strcmp(cmd, "RETR") == 0;
+ if (is_retr && verbose && printnames) {
+ if (local && *local != '-')
+ printf("local: %s ", local);
+ if (remote)
+ printf("remote: %s\n", remote);
+ (void) fflush(stdout);
+ }
+ if (proxy && is_retr) {
+ proxtrans(cmd, local, remote);
+ return;
+ }
+ closefunc = NULL;
+ oldintr = NULL;
+ oldintp = NULL;
+ tcrflag = !crflag && is_retr;
+ if (setjmp(recvabort)) {
+ while (cpend) {
+ (void) getreply(0);
+ }
+ if (data >= 0) {
+ (void) close(data);
+ data = -1;
+ }
+ if (oldintr)
+null();// (void) signal(SIGINT, oldintr);
+ code = -1;
+ return;
+ }
+null();// oldintr = signal(SIGINT, abortrecv);
+ if (strcmp(local, "-") && *local != '|') {
+#ifndef __WIN32__
+// This whole thing is a problem... access Won't work on non-existent files
+ if (access(local, 2) < 0) {
+ char *dir = rindex(local, '/');
+
+ if (errno != ENOENT && errno != EACCES) {
+ perror(local);
+ (void) signal(SIGINT, oldintr);
+ code = -1;
+ return;
+ }
+ if (dir != NULL)
+ *dir = 0;
+ d = access(dir ? local : ".", 2);
+ if (dir != NULL)
+ *dir = '/';
+ if (d < 0) {
+ perror(local);
+ (void) signal(SIGINT, oldintr);
+ code = -1;
+ return;
+ }
+ if (!runique && errno == EACCES &&
+ chmod(local, 0600) < 0) {
+ perror(local);
+ (void) signal(SIGINT, oldintr);
+ code = -1;
+ return;
+ }
+ if (runique && errno == EACCES &&
+ (local = gunique(local)) == NULL) {
+ (void) signal(SIGINT, oldintr);
+ code = -1;
+ return;
+ }
+ }
+ else if (runique && (local = gunique(local)) == NULL) {
+ (void) signal(SIGINT, oldintr);
+ code = -1;
+ return;
+ }
+#endif
+ }
+ if (initconn()) {
+null();// (void) signal(SIGINT, oldintr);
+ code = -1;
+ return;
+ }
+ if (setjmp(recvabort))
+ goto abort;
+ if (!is_retr) {
+ if (type != TYPE_A && (allbinary == 0 || type != TYPE_I)) {
+ oldtype = type;
+ oldverbose = verbose;
+ if (!debug)
+ verbose = 0;
+ setascii();
+ verbose = oldverbose;
+ }
+ } else if (restart_point) {
+ if (command("REST %ld", (long) restart_point) != CONTINUE)
+ return;
+ }
+ if (remote) {
+ if (command("%s %s", cmd, remote) != PRELIM) {
+null();// (void) signal(SIGINT, oldintr);
+ if (oldtype) {
+ if (!debug)
+ verbose = 0;
+ switch (oldtype) {
+ case TYPE_I:
+ setbinary();
+ break;
+ case TYPE_E:
+ setebcdic();
+ break;
+ case TYPE_L:
+ settenex();
+ break;
+ }
+ verbose = oldverbose;
+ }
+ return;
+ }
+ } else {
+ if (command("%s", cmd) != PRELIM) {
+null();// (void) signal(SIGINT, oldintr);
+ if (oldtype) {
+ if (!debug)
+ verbose = 0;
+ switch (oldtype) {
+ case TYPE_I:
+ setbinary();
+ break;
+ case TYPE_E:
+ setebcdic();
+ break;
+ case TYPE_L:
+ settenex();
+ break;
+ }
+ verbose = oldverbose;
+ }
+ return;
+ }
+ }
+ din = dataconn("r");
+ if (din == (int)NULL)
+ goto abort;
+ if (strcmp(local, "-") == 0)
+ fout = stdout;
+ else if (*local == '|') {
+null();// oldintp = signal(SIGPIPE, SIG_IGN);
+ fout = _popen(local + 1, "w");
+ if (fout == NULL) {
+ perror(local+1);
+ goto abort;
+ }
+ closefunc = _pclose;
+ } else {
+ fout = fopen(local, mode);
+ if (fout == NULL) {
+ perror(local);
+ goto abort;
+ }
+ closefunc = fclose;
+ }
+ (void) gettimeofday(&start, (struct timezone *)0);
+ switch (type) {
+
+ case TYPE_I:
+ case TYPE_L:
+ if (restart_point &&
+ lseek(fileno(fout), (long) restart_point, L_SET) < 0) {
+ perror(local);
+ if (closefunc != NULL)
+ (*closefunc)(fout);
+ return;
+ }
+ errno = d = 0;
+// while ((c = recv(din, buf, bufsize, 1)) > 0) {
+// if ((d = write(fileno(fout), buf, c)) != c)
+// if ((d = write(fileno(fout), buf, c)) != c)
+// break;
+ while ((c = recv(din, buf, bufsize, 0)) > 0) {
+ write(fileno(fout), buf, c);
+ bytes += c;
+ if (hash) {
+ while (bytes >= hashbytes) {
+ (void) putchar('#');
+ hashbytes += HASHBYTES;
+ }
+ (void) fflush(stdout);
+ }
+ }
+ if (hash && bytes > 0) {
+ if (bytes < HASHBYTES)
+ (void) putchar('#');
+ (void) putchar('\n');
+ (void) fflush(stdout);
+ }
+// if (c < 0) {
+// if (errno != EPIPE)
+// perror("netin");
+// bytes = -1;
+// }
+// if (d < c) {
+// if (d < 0)
+// perror(local);
+// else
+// fprintf(stderr, "%s: short write\n", local);
+// }
+ break;
+
+ case TYPE_A:
+ if (restart_point) {
+ register int i, n, c;
+
+ if (fseek(fout, 0L, L_SET) < 0)
+ goto done;
+ n = restart_point;
+ i = 0;
+ while (i++ < n) {
+ if ((c=getc(fout)) == EOF)
+ goto done;
+ if (c == '\n')
+ i++;
+ }
+ if (fseek(fout, 0L, L_INCR) < 0) {
+done:
+ perror(local);
+ if (closefunc != NULL)
+ (*closefunc)(fout);
+ return;
+ }
+ }
+ while ((c = fgetcSocket(din)) != EOF) {
+ if (c == '\n')
+ bare_lfs++;
+ while (c == '\r') {
+ while (hash && (bytes >= hashbytes)) {
+ (void) putchar('#');
+ (void) fflush(stdout);
+ hashbytes += HASHBYTES;
+ }
+ bytes++;
+ if ((c = fgetcSocket(din)) != '\n' || tcrflag) {
+ if (ferror(fout))
+ goto break2;
+ (void) putc('\r', fout);
+ if (c == '\0') {
+ bytes++;
+ goto contin2;
+ }
+ if (c == EOF)
+ goto contin2;
+ }
+ }
+ (void) putc(c, fout);
+ bytes++;
+ contin2: ;
+ }
+break2:
+ if (bare_lfs) {
+ printf("WARNING! %d bare linefeeds received in ASCII mode\n");
+ printf("File may not have transferred correctly.\n");
+ (void) fflush(stdout);
+ }
+ if (hash) {
+ if (bytes < hashbytes)
+ (void) putchar('#');
+ (void) putchar('\n');
+ (void) fflush(stdout);
+ }
+// if (ferror(din)) {
+// if (errno != EPIPE)
+// perror("netin");
+// bytes = -1;
+// }
+ if (ferror(fout))
+ perror(local);
+ break;
+ }
+ if (closefunc != NULL)
+ (*closefunc)(fout);
+null();// (void) signal(SIGINT, oldintr);
+ if (oldintp)
+null();// (void) signal(SIGPIPE, oldintp);
+ (void) gettimeofday(&stop, (struct timezone *)0);
+ if(closesocket(din)) {
+ int iret=WSAGetLastError ();
+ fprintf(stdout,"Error closing socket(%d)\n",iret);
+ (void) fflush(stdout);
+ }
+
+ (void) getreply(0);
+ if (bytes > 0 && is_retr)
+ ptransfer("received", bytes, &start, &stop);
+ if (oldtype) {
+ if (!debug)
+ verbose = 0;
+ switch (oldtype) {
+ case TYPE_I:
+ setbinary();
+ break;
+ case TYPE_E:
+ setebcdic();
+ break;
+ case TYPE_L:
+ settenex();
+ break;
+ }
+ verbose = oldverbose;
+ }
+ return;
+abort:
+
+/* abort using RFC959 recommended IP,SYNC sequence */
+
+ (void) gettimeofday(&stop, (struct timezone *)0);
+ if (oldintp)
+null();// (void) signal(SIGPIPE, oldintr);
+null();// (void) signal(SIGINT,SIG_IGN);
+ if (oldtype) {
+ if (!debug)
+ verbose = 0;
+ switch (oldtype) {
+ case TYPE_I:
+ setbinary();
+ break;
+ case TYPE_E:
+ setebcdic();
+ break;
+ case TYPE_L:
+ settenex();
+ break;
+ }
+ verbose = oldverbose;
+ }
+ if (!cpend) {
+ code = -1;
+null();// (void) signal(SIGINT,oldintr);
+ return;
+ }
+
+ fprintfSocket(cout,"%c%c",IAC,IP);
+ msg = (char)IAC;
+/* send IAC in urgent mode instead of DM because UNIX places oob mark */
+/* after urgent byte rather than before as now is protocol */
+ if (send(cout,&msg,1,MSG_OOB) != 1) {
+ perror("abort");
+ }
+ fprintfSocket(cout,"%cABOR\r\n",DM);
+ FD_ZERO(&mask);
+ FD_SET(cin, &mask); // Need to correct this
+ if (din) {
+ FD_SET(din, &mask); // Need to correct this
+ }
+ if ((nfnd = empty(&mask,10)) <= 0) {
+ if (nfnd < 0) {
+ perror("abort");
+ }
+ code = -1;
+ lostpeer();
+ }
+ if (din && FD_ISSET(din, &mask)) {
+ while ((c = recv(din, buf, bufsize, 0)) > 0)
+ ;
+ }
+ if ((c = getreply(0)) == ERROR && code == 552) { /* needed for nic style abort */
+ if (data >= 0) {
+ (void) close(data);
+ data = -1;
+ }
+ (void) getreply(0);
+ }
+ (void) getreply(0);
+ code = -1;
+ if (data >= 0) {
+ (void) close(data);
+ data = -1;
+ }
+ if (closefunc != NULL && fout != NULL)
+ (*closefunc)(fout);
+ if (din)
+ if(closesocket(din)) {
+ int iret=WSAGetLastError ();
+ fprintf(stdout,"Error closing socket(%d)\n",iret);
+ (void) fflush(stdout);
+ }
+
+ if (bytes > 0)
+ ptransfer("received", bytes, &start, &stop);
+null();// (void) signal(SIGINT,oldintr);
+}
+
+/*
+ * Need to start a listen on the data channel
+ * before we send the command, otherwise the
+ * server's connect may fail.
+ */
+int sendport = -1;
+
+initconn()
+{
+ register char *p, *a;
+ int result, len, tmpno = 0;
+ int on = 1;
+ int a0, a1, a2, a3, p0, p1;
+
+
+ if (passivemode) {
+ data = socket(AF_INET, SOCK_STREAM, 0);
+ if (data < 0) {
+ perror("ftp: socket");
+ return(1);
+ }
+ if ((options & SO_DEBUG) &&
+ setsockopt(data, SOL_SOCKET, SO_DEBUG, (char *)&on,
+ sizeof (on)) < 0)
+ perror("ftp: setsockopt (ignored)");
+ if (command("PASV") != COMPLETE) {
+ printf("Passive mode refused.\n");
+ goto bad;
+ }
+
+ /*
+ * What we've got at this point is a string of comma
+ * separated one-byte unsigned integer values.
+ * The first four are the an IP address. The fifth is
+ * the MSB of the port number, the sixth is the LSB.
+ * From that we'll prepare a sockaddr_in.
+ */
+
+ if (sscanf(pasv,"%d,%d,%d,%d,%d,%d",
+ &a0, &a1, &a2, &a3, &p0, &p1) != 6) {
+ printf("Passive mode address scan failure. Shouldn't happen!\n");
+ goto bad;
+ }
+
+ bzero(&data_addr, sizeof(data_addr));
+ data_addr.sin_family = AF_INET;
+ a = (char *)&data_addr.sin_addr.s_addr;
+ a[0] = a0 & 0xff;
+ a[1] = a1 & 0xff;
+ a[2] = a2 & 0xff;
+ a[3] = a3 & 0xff;
+ p = (char *)&data_addr.sin_port;
+ p[0] = p0 & 0xff;
+ p[1] = p1 & 0xff;
+
+ if (connect(data, (struct sockaddr *)&data_addr,
+ sizeof(data_addr)) < 0) {
+ perror("ftp: connect");
+ goto bad;
+ }
+ return(0);
+ }
+
+
+noport:
+ data_addr = myctladdr;
+ if (sendport)
+ data_addr.sin_port = 0; /* let system pick one */
+ if (data != -1)
+ (void) close (data);
+ data = socket(AF_INET, SOCK_STREAM, 0);
+ if (data < 0) {
+ perror("ftp: socket");
+ if (tmpno)
+ sendport = 1;
+ return (1);
+ }
+ if (!sendport)
+ if (setsockopt(data, SOL_SOCKET, SO_REUSEADDR, (char *)&on, sizeof (on)) < 0) {
+ perror("ftp: setsockopt (reuse address)");
+ goto bad;
+ }
+ if (bind(data, (struct sockaddr *)&data_addr, sizeof (data_addr)) < 0) {
+ perror("ftp: bind");
+ goto bad;
+ }
+ if (options & SO_DEBUG &&
+ setsockopt(data, SOL_SOCKET, SO_DEBUG, (char *)&on, sizeof (on)) < 0)
+ perror("ftp: setsockopt (ignored)");
+ len = sizeof (data_addr);
+ if (getsockname(data, (struct sockaddr *)&data_addr, &len) < 0) {
+ perror("ftp: getsockname");
+ goto bad;
+ }
+ if (listen(data, 1) < 0)
+ perror("ftp: listen");
+ if (sendport) {
+ a = (char *)&data_addr.sin_addr;
+ p = (char *)&data_addr.sin_port;
+#define UC(b) (((int)b)&0xff)
+ result =
+ command("PORT %d,%d,%d,%d,%d,%d",
+ UC(a[0]), UC(a[1]), UC(a[2]), UC(a[3]),
+ UC(p[0]), UC(p[1]));
+ if (result == ERROR && sendport == -1) {
+ sendport = 0;
+ tmpno = 1;
+ goto noport;
+ }
+ return (result != COMPLETE);
+ }
+ if (tmpno)
+ sendport = 1;
+ return (0);
+bad:
+ (void) fflush(stdout);
+ (void) close(data), data = -1;
+ if (tmpno)
+ sendport = 1;
+ return (1);
+}
+
+int dataconn(char *mode)
+{
+ struct sockaddr_in from;
+ int s, fromlen = sizeof (from);
+
+ if (passivemode)
+ return (data);
+
+ s = accept(data, (struct sockaddr *) &from, &fromlen);
+ if (s < 0) {
+ perror("ftp: accept");
+ (void) closesocket(data), data = -1;
+ return (int) (NULL);
+ }
+ if(closesocket(data)) {
+ int iret=WSAGetLastError ();
+ fprintf(stdout,"Error closing socket(%d)\n",iret);
+ (void) fflush(stdout);
+ }
+
+ data = s;
+ return (data);
+}
+
+void ptransfer(direction, bytes, t0, t1)
+ char *direction;
+ long bytes;
+ struct timeval *t0, *t1;
+{
+ struct timeval td;
+ double s, bs;
+
+ if (verbose) {
+ tvsub(&td, t1, t0);
+ s = td.tv_sec + (td.tv_usec / 1000000.);
+#define nz(x) ((x) == 0 ? 1 : (x))
+ bs = bytes / nz(s);
+ printf("%ld bytes %s in %.2g seconds (%.2g Kbytes/s)\n",
+ bytes, direction, s, bs / 1024.);
+ (void) fflush(stdout);
+ }
+}
+
+/*tvadd(tsum, t0)
+ struct timeval *tsum, *t0;
+{
+
+ tsum->tv_sec += t0->tv_sec;
+ tsum->tv_usec += t0->tv_usec;
+ if (tsum->tv_usec > 1000000)
+ tsum->tv_sec++, tsum->tv_usec -= 1000000;
+} */
+
+void tvsub(tdiff, t1, t0)
+ struct timeval *tdiff, *t1, *t0;
+{
+
+ tdiff->tv_sec = t1->tv_sec - t0->tv_sec;
+ tdiff->tv_usec = t1->tv_usec - t0->tv_usec;
+ if (tdiff->tv_usec < 0)
+ tdiff->tv_sec--, tdiff->tv_usec += 1000000;
+}
+
+void psabort(int flag)
+{
+ extern int abrtflag;
+
+ abrtflag++;
+}
+
+void pswitch(int flag)
+{
+ extern int proxy, abrtflag;
+ Sig_t oldintr;
+ static struct comvars {
+ int connect;
+ char name[MAXHOSTNAMELEN];
+ struct sockaddr_in mctl;
+ struct sockaddr_in hctl;
+ FILE *in;
+ FILE *out;
+ int tpe;
+ int cpnd;
+ int sunqe;
+ int runqe;
+ int mcse;
+ int ntflg;
+ char nti[17];
+ char nto[17];
+ int mapflg;
+ char mi[MAXPATHLEN];
+ char mo[MAXPATHLEN];
+ } proxstruct, tmpstruct;
+ struct comvars *ip, *op;
+
+ abrtflag = 0;
+ oldintr = signal(SIGINT, psabort);
+ if (flag) {
+ if (proxy)
+ return;
+ ip = &tmpstruct;
+ op = &proxstruct;
+ proxy++;
+ }
+ else {
+ if (!proxy)
+ return;
+ ip = &proxstruct;
+ op = &tmpstruct;
+ proxy = 0;
+ }
+ ip->connect = connected;
+ connected = op->connect;
+ if (hostname) {
+ (void) strncpy(ip->name, hostname, sizeof(ip->name) - 1);
+ ip->name[strlen(ip->name)] = '\0';
+ } else
+ ip->name[0] = 0;
+ hostname = op->name;
+ ip->hctl = hisctladdr;
+ hisctladdr = op->hctl;
+ ip->mctl = myctladdr;
+ myctladdr = op->mctl;
+ (int) ip->in = cin; // What the hell am I looking at...?
+ cin = (int) op->in;
+ (int) ip->out = cout; // Same again...
+ cout = (int) op->out;
+ ip->tpe = type;
+ type = op->tpe;
+ if (!type)
+ type = 1;
+ ip->cpnd = cpend;
+ cpend = op->cpnd;
+ ip->sunqe = sunique;
+ sunique = op->sunqe;
+ ip->runqe = runique;
+ runique = op->runqe;
+ ip->mcse = mcase;
+ mcase = op->mcse;
+ ip->ntflg = ntflag;
+ ntflag = op->ntflg;
+ (void) strncpy(ip->nti, ntin, 16);
+ (ip->nti)[strlen(ip->nti)] = '\0';
+ (void) strcpy(ntin, op->nti);
+ (void) strncpy(ip->nto, ntout, 16);
+ (ip->nto)[strlen(ip->nto)] = '\0';
+ (void) strcpy(ntout, op->nto);
+ ip->mapflg = mapflag;
+ mapflag = op->mapflg;
+ (void) strncpy(ip->mi, mapin, MAXPATHLEN - 1);
+ (ip->mi)[strlen(ip->mi)] = '\0';
+ (void) strcpy(mapin, op->mi);
+ (void) strncpy(ip->mo, mapout, MAXPATHLEN - 1);
+ (ip->mo)[strlen(ip->mo)] = '\0';
+ (void) strcpy(mapout, op->mo);
+// (void) signal(SIGINT, oldintr);
+ if (abrtflag) {
+ abrtflag = 0;
+ (*oldintr)(1);
+ }
+}
+
+jmp_buf ptabort;
+int ptabflg;
+
+void
+abortpt()
+{
+ printf("\n");
+ (void) fflush(stdout);
+ ptabflg++;
+ mflag = 0;
+ abrtflag = 0;
+ longjmp(ptabort, 1);
+}
+
+void proxtrans(cmd, local, remote)
+ char *cmd, *local, *remote;
+{
+// void (*oldintr)(int);
+ //void abortpt(int);
+ int tmptype, oldtype = 0, secndflag = 0, nfnd;
+ extern jmp_buf ptabort;
+ char *cmd2;
+// struct
+ fd_set mask;
+
+ if (strcmp(cmd, "RETR"))
+ cmd2 = "RETR";
+ else
+ cmd2 = runique ? "STOU" : "STOR";
+ if (command("PASV") != COMPLETE) {
+ printf("proxy server does not support third part transfers.\n");
+ (void) fflush(stdout);
+ return;
+ }
+ tmptype = type;
+ pswitch(0);
+ if (!connected) {
+ printf("No primary connection\n");
+ (void) fflush(stdout);
+ pswitch(1);
+ code = -1;
+ return;
+ }
+ if (type != tmptype) {
+ oldtype = type;
+ switch (tmptype) {
+ case TYPE_A:
+ setascii();
+ break;
+ case TYPE_I:
+ setbinary();
+ break;
+ case TYPE_E:
+ setebcdic();
+ break;
+ case TYPE_L:
+ settenex();
+ break;
+ }
+ }
+ if (command("PORT %s", pasv) != COMPLETE) {
+ switch (oldtype) {
+ case 0:
+ break;
+ case TYPE_A:
+ setascii();
+ break;
+ case TYPE_I:
+ setbinary();
+ break;
+ case TYPE_E:
+ setebcdic();
+ break;
+ case TYPE_L:
+ settenex();
+ break;
+ }
+ pswitch(1);
+ return;
+ }
+ if (setjmp(ptabort))
+ goto abort;
+null();// oldintr = signal(SIGINT, abortpt);
+ if (command("%s %s", cmd, remote) != PRELIM) {
+null();// (void) signal(SIGINT, oldintr);
+ switch (oldtype) {
+ case 0:
+ break;
+ case TYPE_A:
+ setascii();
+ break;
+ case TYPE_I:
+ setbinary();
+ break;
+ case TYPE_E:
+ setebcdic();
+ break;
+ case TYPE_L:
+ settenex();
+ break;
+ }
+ pswitch(1);
+ return;
+ }
+ sleep(2);
+ pswitch(1);
+ secndflag++;
+ if (command("%s %s", cmd2, local) != PRELIM)
+ goto abort;
+ ptflag++;
+ (void) getreply(0);
+ pswitch(0);
+ (void) getreply(0);
+null();// (void) signal(SIGINT, oldintr);
+ switch (oldtype) {
+ case 0:
+ break;
+ case TYPE_A:
+ setascii();
+ break;
+ case TYPE_I:
+ setbinary();
+ break;
+ case TYPE_E:
+ setebcdic();
+ break;
+ case TYPE_L:
+ settenex();
+ break;
+ }
+ pswitch(1);
+ ptflag = 0;
+ printf("local: %s remote: %s\n", local, remote);
+ (void) fflush(stdout);
+ return;
+abort:
+null();// (void) signal(SIGINT, SIG_IGN);
+ ptflag = 0;
+ if (strcmp(cmd, "RETR") && !proxy)
+ pswitch(1);
+ else if (!strcmp(cmd, "RETR") && proxy)
+ pswitch(0);
+ if (!cpend && !secndflag) { /* only here if cmd = "STOR" (proxy=1) */
+ if (command("%s %s", cmd2, local) != PRELIM) {
+ pswitch(0);
+ switch (oldtype) {
+ case 0:
+ break;
+ case TYPE_A:
+ setascii();
+ break;
+ case TYPE_I:
+ setbinary();
+ break;
+ case TYPE_E:
+ setebcdic();
+ break;
+ case TYPE_L:
+ settenex();
+ break;
+ }
+ if (cpend) {
+ char msg[2];
+
+ fprintfSocket(cout,"%c%c",IAC,IP);
+ *msg = (char) IAC;
+ *(msg+1) = (char) DM;
+ if (send(cout,msg,2,MSG_OOB) != 2)
+ perror("abort");
+ fprintfSocket(cout,"ABOR\r\n");
+ FD_ZERO(&mask);
+// FD_SET(fileno(cin), &mask); // Chris: Need to correct this
+ if ((nfnd = empty(&mask,10)) <= 0) {
+ if (nfnd < 0) {
+ perror("abort");
+ }
+ if (ptabflg)
+ code = -1;
+ lostpeer();
+ }
+ (void) getreply(0);
+ (void) getreply(0);
+ }
+ }
+ pswitch(1);
+ if (ptabflg)
+ code = -1;
+null();// (void) signal(SIGINT, oldintr);
+ return;
+ }
+ if (cpend) {
+ char msg[2];
+
+ fprintfSocket(cout,"%c%c",IAC,IP);
+ *msg = (char)IAC;
+ *(msg+1) = (char)DM;
+ if (send(cout,msg,2,MSG_OOB) != 2)
+ perror("abort");
+ fprintfSocket(cout,"ABOR\r\n");
+ FD_ZERO(&mask);
+// FD_SET(fileno(cin), &mask); // Chris: Need to correct this...
+ if ((nfnd = empty(&mask,10)) <= 0) {
+ if (nfnd < 0) {
+ perror("abort");
+ }
+ if (ptabflg)
+ code = -1;
+ lostpeer();
+ }
+ (void) getreply(0);
+ (void) getreply(0);
+ }
+ pswitch(!proxy);
+ if (!cpend && !secndflag) { /* only if cmd = "RETR" (proxy=1) */
+ if (command("%s %s", cmd2, local) != PRELIM) {
+ pswitch(0);
+ switch (oldtype) {
+ case 0:
+ break;
+ case TYPE_A:
+ setascii();
+ break;
+ case TYPE_I:
+ setbinary();
+ break;
+ case TYPE_E:
+ setebcdic();
+ break;
+ case TYPE_L:
+ settenex();
+ break;
+ }
+ if (cpend) {
+ char msg[2];
+
+ fprintfSocket(cout,"%c%c",IAC,IP);
+ *msg = (char)IAC;
+ *(msg+1) = (char)DM;
+ if (send(cout,msg,2,MSG_OOB) != 2)
+ perror("abort");
+ fprintfSocket(cout,"ABOR\r\n");
+ FD_ZERO(&mask);
+// FD_SET(fileno(cin), &mask); // Chris:
+ if ((nfnd = empty(&mask,10)) <= 0) {
+ if (nfnd < 0) {
+ perror("abort");
+ }
+ if (ptabflg)
+ code = -1;
+ lostpeer();
+ }
+ (void) getreply(0);
+ (void) getreply(0);
+ }
+ pswitch(1);
+ if (ptabflg)
+ code = -1;
+null();// (void) signal(SIGINT, oldintr);
+ return;
+ }
+ }
+ if (cpend) {
+ char msg[2];
+
+ fprintfSocket(cout,"%c%c",IAC,IP);
+ *msg = (char)IAC;
+ *(msg+1) = (char)DM;
+ if (send(cout,msg,2,MSG_OOB) != 2)
+ perror("abort");
+ fprintfSocket(cout,"ABOR\r\n");
+ FD_ZERO(&mask);
+// FD_SET(fileno(cin), &mask); // Chris:
+ if ((nfnd = empty(&mask,10)) <= 0) {
+ if (nfnd < 0) {
+ perror("abort");
+ }
+ if (ptabflg)
+ code = -1;
+ lostpeer();
+ }
+ (void) getreply(0);
+ (void) getreply(0);
+ }
+ pswitch(!proxy);
+ if (cpend) {
+ FD_ZERO(&mask);
+// FD_SET(fileno(cin), &mask); // Chris:
+ if ((nfnd = empty(&mask,10)) <= 0) {
+ if (nfnd < 0) {
+ perror("abort");
+ }
+ if (ptabflg)
+ code = -1;
+ lostpeer();
+ }
+ (void) getreply(0);
+ (void) getreply(0);
+ }
+ if (proxy)
+ pswitch(0);
+ switch (oldtype) {
+ case 0:
+ break;
+ case TYPE_A:
+ setascii();
+ break;
+ case TYPE_I:
+ setbinary();
+ break;
+ case TYPE_E:
+ setebcdic();
+ break;
+ case TYPE_L:
+ settenex();
+ break;
+ }
+ pswitch(1);
+ if (ptabflg)
+ code = -1;
+null();// (void) signal(SIGINT, oldintr);
+}
+
+void reset()
+{
+// struct
+ fd_set mask;
+ int nfnd = 1;
+
+ FD_ZERO(&mask);
+ while (nfnd > 0) {
+// FD_SET(fileno(cin), &mask); // Chris
+ if ((nfnd = empty(&mask,0)) < 0) {
+ perror("reset");
+ code = -1;
+ lostpeer();
+ }
+ else if (nfnd) {
+ (void) getreply(0);
+ }
+ }
+}
+
+char *
+gunique(local)
+ char *local;
+{
+ static char new[MAXPATHLEN];
+ char *cp = rindex(local, '/');
+ int d, count=0;
+ char ext = '1';
+
+ if (cp)
+ *cp = '\0';
+ d = access(cp ? local : ".", 2);
+ if (cp)
+ *cp = '/';
+ if (d < 0) {
+ perror(local);
+ return((char *) 0);
+ }
+ (void) strcpy(new, local);
+ cp = new + strlen(new);
+ *cp++ = '.';
+ while (!d) {
+ if (++count == 100) {
+ printf("runique: can't find unique file name.\n");
+ (void) fflush(stdout);
+ return((char *) 0);
+ }
+ *cp++ = ext;
+ *cp = '\0';
+ if (ext == '9')
+ ext = '0';
+ else
+ ext++;
+ if ((d = access(new, 0)) < 0)
+ break;
+ if (ext != '0')
+ cp--;
+ else if (*(cp - 2) == '.')
+ *(cp - 1) = '1';
+ else {
+ *(cp - 2) = *(cp - 2) + 1;
+ cp--;
+ }
+ }
+ return(new);
+}
+
+int null(void)
+{
+ return 0;
+}
diff --git a/reactos/apps/utils/net/ftp/ftp.mak b/reactos/apps/utils/net/ftp/ftp.mak
new file mode 100644
index 00000000000..084404f1927
--- /dev/null
+++ b/reactos/apps/utils/net/ftp/ftp.mak
@@ -0,0 +1,372 @@
+# Microsoft Developer Studio Generated NMAKE File, Based on ftp.dsp
+!IF "$(CFG)" == ""
+CFG=ftp - Win32 Debug
+!MESSAGE No configuration specified. Defaulting to ftp - Win32 Debug.
+!ENDIF
+
+!IF "$(CFG)" != "ftp - Win32 Release" && "$(CFG)" != "ftp - Win32 Debug"
+!MESSAGE Invalid configuration "$(CFG)" specified.
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "ftp.mak" CFG="ftp - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "ftp - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "ftp - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE
+!ERROR An invalid configuration is specified.
+!ENDIF
+
+!IF "$(OS)" == "Windows_NT"
+NULL=
+!ELSE
+NULL=nul
+!ENDIF
+
+!IF "$(CFG)" == "ftp - Win32 Release"
+
+OUTDIR=.\Release
+INTDIR=.\Release
+# Begin Custom Macros
+OutDir=.\Release
+# End Custom Macros
+
+!IF "$(RECURSE)" == "0"
+
+ALL : "$(OUTDIR)\ftp.exe"
+
+!ELSE
+
+ALL : "$(OUTDIR)\ftp.exe"
+
+!ENDIF
+
+CLEAN :
+ -@erase "$(INTDIR)\cmds.obj"
+ -@erase "$(INTDIR)\cmdtab.obj"
+ -@erase "$(INTDIR)\domacro.obj"
+ -@erase "$(INTDIR)\fake.obj"
+ -@erase "$(INTDIR)\ftp.obj"
+ -@erase "$(INTDIR)\main.obj"
+ -@erase "$(INTDIR)\ruserpass.obj"
+ -@erase "$(INTDIR)\vc*.idb"
+ -@erase "$(OUTDIR)\ftp.exe"
+ -@erase "$(OUTDIR)\ftp.pch"
+
+"$(OUTDIR)" :
+ if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
+
+CPP=cl.exe
+CPP_PROJ=/nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" \
+ /D "HAVE_TIMEVAL" /Fp"$(INTDIR)\ftp.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD\
+ /c
+CPP_OBJS=.\Release/
+CPP_SBRS=.
+
+.c{$(CPP_OBJS)}.obj::
+ $(CPP) @<<
+ $(CPP_PROJ) $<
+<<
+
+.cpp{$(CPP_OBJS)}.obj::
+ $(CPP) @<<
+ $(CPP_PROJ) $<
+<<
+
+.cxx{$(CPP_OBJS)}.obj::
+ $(CPP) @<<
+ $(CPP_PROJ) $<
+<<
+
+.c{$(CPP_SBRS)}.sbr::
+ $(CPP) @<<
+ $(CPP_PROJ) $<
+<<
+
+.cpp{$(CPP_SBRS)}.sbr::
+ $(CPP) @<<
+ $(CPP_PROJ) $<
+<<
+
+.cxx{$(CPP_SBRS)}.sbr::
+ $(CPP) @<<
+ $(CPP_PROJ) $<
+<<
+
+RSC=rc.exe
+BSC32=bscmake.exe
+BSC32_FLAGS=/nologo /o"$(OUTDIR)\ftp.bsc"
+BSC32_SBRS= \
+
+LINK32=link.exe
+LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\
+ advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib\
+ odbccp32.lib wsock32.lib /nologo /subsystem:console /incremental:no\
+ /pdb:"$(OUTDIR)\ftp.pdb" /machine:I386 /out:"$(OUTDIR)\ftp.exe"
+LINK32_OBJS= \
+ "$(INTDIR)\cmds.obj" \
+ "$(INTDIR)\cmdtab.obj" \
+ "$(INTDIR)\domacro.obj" \
+ "$(INTDIR)\fake.obj" \
+ "$(INTDIR)\ftp.obj" \
+ "$(INTDIR)\main.obj" \
+ "$(INTDIR)\ruserpass.obj"
+
+"$(OUTDIR)\ftp.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
+ $(LINK32) @<<
+ $(LINK32_FLAGS) $(LINK32_OBJS)
+<<
+
+TargetPath=.\Release\ftp.exe
+InputPath=.\Release\ftp.exe
+SOURCE=$(InputPath)
+
+!ELSEIF "$(CFG)" == "ftp - Win32 Debug"
+
+OUTDIR=.\Debug
+INTDIR=.\Debug
+# Begin Custom Macros
+OutDir=.\Debug
+# End Custom Macros
+
+!IF "$(RECURSE)" == "0"
+
+ALL : "$(OUTDIR)\ftp.exe"
+
+!ELSE
+
+ALL : "$(OUTDIR)\ftp.exe"
+
+!ENDIF
+
+CLEAN :
+ -@erase "$(INTDIR)\cmds.obj"
+ -@erase "$(INTDIR)\cmdtab.obj"
+ -@erase "$(INTDIR)\domacro.obj"
+ -@erase "$(INTDIR)\fake.obj"
+ -@erase "$(INTDIR)\ftp.obj"
+ -@erase "$(INTDIR)\main.obj"
+ -@erase "$(INTDIR)\ruserpass.obj"
+ -@erase "$(INTDIR)\vc*.idb"
+ -@erase "$(INTDIR)\vc*.pdb"
+ -@erase "$(OUTDIR)\ftp.exe"
+ -@erase "$(OUTDIR)\ftp.ilk"
+ -@erase "$(OUTDIR)\ftp.pdb"
+ -@erase "$(OUTDIR)\ftp.pch"
+
+"$(OUTDIR)" :
+ if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
+
+CPP=cl.exe
+CPP_PROJ=/nologo /MLd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS"\
+ /Fp"$(INTDIR)\ftp.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
+CPP_OBJS=.\Debug/
+CPP_SBRS=.
+
+.c{$(CPP_OBJS)}.obj::
+ $(CPP) @<<
+ $(CPP_PROJ) $<
+<<
+
+.cpp{$(CPP_OBJS)}.obj::
+ $(CPP) @<<
+ $(CPP_PROJ) $<
+<<
+
+.cxx{$(CPP_OBJS)}.obj::
+ $(CPP) @<<
+ $(CPP_PROJ) $<
+<<
+
+.c{$(CPP_SBRS)}.sbr::
+ $(CPP) @<<
+ $(CPP_PROJ) $<
+<<
+
+.cpp{$(CPP_SBRS)}.sbr::
+ $(CPP) @<<
+ $(CPP_PROJ) $<
+<<
+
+.cxx{$(CPP_SBRS)}.sbr::
+ $(CPP) @<<
+ $(CPP_PROJ) $<
+<<
+
+RSC=rc.exe
+BSC32=bscmake.exe
+BSC32_FLAGS=/nologo /o"$(OUTDIR)\ftp.bsc"
+BSC32_SBRS= \
+
+LINK32=link.exe
+LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\
+ advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib\
+ odbccp32.lib wsock32.lib /nologo /subsystem:console /incremental:yes\
+ /pdb:"$(OUTDIR)\ftp.pdb" /debug /machine:I386 /out:"$(OUTDIR)\ftp.exe"\
+ /pdbtype:sept
+LINK32_OBJS= \
+ "$(INTDIR)\cmds.obj" \
+ "$(INTDIR)\cmdtab.obj" \
+ "$(INTDIR)\domacro.obj" \
+ "$(INTDIR)\fake.obj" \
+ "$(INTDIR)\ftp.obj" \
+ "$(INTDIR)\main.obj" \
+ "$(INTDIR)\ruserpass.obj"
+
+"$(OUTDIR)\ftp.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
+ $(LINK32) @<<
+ $(LINK32_FLAGS) $(LINK32_OBJS)
+<<
+
+TargetPath=.\Debug\ftp.exe
+InputPath=.\Debug\ftp.exe
+SOURCE=$(InputPath)
+
+!ENDIF
+
+
+!IF "$(CFG)" == "ftp - Win32 Release" || "$(CFG)" == "ftp - Win32 Debug"
+SOURCE=.\cmds.c
+
+!IF "$(CFG)" == "ftp - Win32 Release"
+
+DEP_CPP_CMDS_=\
+ ".\fake.h"\
+ ".\ftp_var.h"\
+ ".\pathnames.h"\
+ ".\prototypes.h"\
+
+
+"$(INTDIR)\cmds.obj" : $(SOURCE) $(DEP_CPP_CMDS_) "$(INTDIR)"
+
+
+!ELSEIF "$(CFG)" == "ftp - Win32 Debug"
+
+DEP_CPP_CMDS_=\
+ ".\fake.h"\
+ ".\ftp_var.h"\
+ ".\pathnames.h"\
+ ".\prototypes.h"\
+ {$(INCLUDE)}"sys\stat.h"\
+ {$(INCLUDE)}"sys\types.h"\
+
+
+"$(INTDIR)\cmds.obj" : $(SOURCE) $(DEP_CPP_CMDS_) "$(INTDIR)"
+
+
+!ENDIF
+
+SOURCE=.\cmdtab.c
+DEP_CPP_CMDTA=\
+ ".\fake.h"\
+ ".\ftp_var.h"\
+
+
+"$(INTDIR)\cmdtab.obj" : $(SOURCE) $(DEP_CPP_CMDTA) "$(INTDIR)"
+
+
+SOURCE=.\domacro.c
+DEP_CPP_DOMAC=\
+ ".\fake.h"\
+ ".\ftp_var.h"\
+ ".\prototypes.h"\
+
+
+"$(INTDIR)\domacro.obj" : $(SOURCE) $(DEP_CPP_DOMAC) "$(INTDIR)"
+
+
+SOURCE=.\fake.c
+DEP_CPP_FAKE_=\
+ ".\prototypes.h"\
+
+
+"$(INTDIR)\fake.obj" : $(SOURCE) $(DEP_CPP_FAKE_) "$(INTDIR)"
+
+
+SOURCE=.\ftp.c
+
+!IF "$(CFG)" == "ftp - Win32 Release"
+
+DEP_CPP_FTP_C=\
+ ".\fake.h"\
+ ".\ftp_var.h"\
+ ".\prototypes.h"\
+
+
+"$(INTDIR)\ftp.obj" : $(SOURCE) $(DEP_CPP_FTP_C) "$(INTDIR)"
+
+
+!ELSEIF "$(CFG)" == "ftp - Win32 Debug"
+
+DEP_CPP_FTP_C=\
+ ".\fake.h"\
+ ".\ftp_var.h"\
+ ".\prototypes.h"\
+ {$(INCLUDE)}"sys\stat.h"\
+ {$(INCLUDE)}"sys\types.h"\
+
+
+"$(INTDIR)\ftp.obj" : $(SOURCE) $(DEP_CPP_FTP_C) "$(INTDIR)"
+
+
+!ENDIF
+
+SOURCE=.\main.c
+
+!IF "$(CFG)" == "ftp - Win32 Release"
+
+DEP_CPP_MAIN_=\
+ ".\fake.h"\
+ ".\ftp_var.h"\
+ ".\prototypes.h"\
+
+
+"$(INTDIR)\main.obj" : $(SOURCE) $(DEP_CPP_MAIN_) "$(INTDIR)"
+
+
+!ELSEIF "$(CFG)" == "ftp - Win32 Debug"
+
+DEP_CPP_MAIN_=\
+ ".\fake.h"\
+ ".\ftp_var.h"\
+ ".\prototypes.h"\
+ {$(INCLUDE)}"sys\types.h"\
+
+
+"$(INTDIR)\main.obj" : $(SOURCE) $(DEP_CPP_MAIN_) "$(INTDIR)"
+
+
+!ENDIF
+
+SOURCE=.\ruserpass.c
+
+!IF "$(CFG)" == "ftp - Win32 Release"
+
+DEP_CPP_RUSER=\
+ ".\fake.h"\
+ ".\ftp_var.h"\
+ ".\prototypes.h"\
+
+
+"$(INTDIR)\ruserpass.obj" : $(SOURCE) $(DEP_CPP_RUSER) "$(INTDIR)"
+
+
+!ELSEIF "$(CFG)" == "ftp - Win32 Debug"
+
+DEP_CPP_RUSER=\
+ ".\fake.h"\
+ ".\ftp_var.h"\
+ ".\prototypes.h"\
+ {$(INCLUDE)}"sys\stat.h"\
+ {$(INCLUDE)}"sys\types.h"\
+
+
+"$(INTDIR)\ruserpass.obj" : $(SOURCE) $(DEP_CPP_RUSER) "$(INTDIR)"
+
+
+!ENDIF
+
+
+!ENDIF
diff --git a/reactos/apps/utils/net/ftp/ftp.mak.orig b/reactos/apps/utils/net/ftp/ftp.mak.orig
new file mode 100644
index 00000000000..b482649d551
--- /dev/null
+++ b/reactos/apps/utils/net/ftp/ftp.mak.orig
@@ -0,0 +1,400 @@
+# Microsoft Developer Studio Generated NMAKE File, Based on ftp.dsp
+!IF "$(CFG)" == ""
+CFG=ftp - Win32 Debug
+!MESSAGE No configuration specified. Defaulting to ftp - Win32 Debug.
+!ENDIF
+
+!IF "$(CFG)" != "ftp - Win32 Release" && "$(CFG)" != "ftp - Win32 Debug"
+!MESSAGE Invalid configuration "$(CFG)" specified.
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "ftp.mak" CFG="ftp - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "ftp - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "ftp - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE
+!ERROR An invalid configuration is specified.
+!ENDIF
+
+!IF "$(OS)" == "Windows_NT"
+NULL=
+!ELSE
+NULL=nul
+!ENDIF
+
+!IF "$(CFG)" == "ftp - Win32 Release"
+
+OUTDIR=.\Release
+INTDIR=.\Release
+# Begin Custom Macros
+OutDir=.\Release
+# End Custom Macros
+
+!IF "$(RECURSE)" == "0"
+
+ALL : "$(OUTDIR)\ftp.exe" "\emacs-19.34\bin\ftp.exe"
+
+!ELSE
+
+ALL : "$(OUTDIR)\ftp.exe" "\emacs-19.34\bin\ftp.exe"
+
+!ENDIF
+
+CLEAN :
+ -@erase "$(INTDIR)\cmds.obj"
+ -@erase "$(INTDIR)\cmdtab.obj"
+ -@erase "$(INTDIR)\domacro.obj"
+ -@erase "$(INTDIR)\fake.obj"
+ -@erase "$(INTDIR)\ftp.obj"
+ -@erase "$(INTDIR)\main.obj"
+ -@erase "$(INTDIR)\ruserpass.obj"
+ -@erase "$(INTDIR)\vc50.idb"
+ -@erase "$(OUTDIR)\ftp.exe"
+ -@erase "\emacs-19.34\bin\ftp.exe"
+
+"$(OUTDIR)" :
+ if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
+
+CPP=cl.exe
+CPP_PROJ=/nologo /ML /W3 /GX /O2 /I "C:\emacs-19.34\nt\inc" /I\
+ "C:\emacs-19.34\src" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D\
+ "HAVE_TIMEVAL" /Fp"$(INTDIR)\ftp.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD\
+ /c
+CPP_OBJS=.\Release/
+CPP_SBRS=.
+
+.c{$(CPP_OBJS)}.obj::
+ $(CPP) @<<
+ $(CPP_PROJ) $<
+<<
+
+.cpp{$(CPP_OBJS)}.obj::
+ $(CPP) @<<
+ $(CPP_PROJ) $<
+<<
+
+.cxx{$(CPP_OBJS)}.obj::
+ $(CPP) @<<
+ $(CPP_PROJ) $<
+<<
+
+.c{$(CPP_SBRS)}.sbr::
+ $(CPP) @<<
+ $(CPP_PROJ) $<
+<<
+
+.cpp{$(CPP_SBRS)}.sbr::
+ $(CPP) @<<
+ $(CPP_PROJ) $<
+<<
+
+.cxx{$(CPP_SBRS)}.sbr::
+ $(CPP) @<<
+ $(CPP_PROJ) $<
+<<
+
+RSC=rc.exe
+BSC32=bscmake.exe
+BSC32_FLAGS=/nologo /o"$(OUTDIR)\ftp.bsc"
+BSC32_SBRS= \
+
+LINK32=link.exe
+LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\
+ advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib\
+ odbccp32.lib /nologo /subsystem:console /incremental:no\
+ /pdb:"$(OUTDIR)\ftp.pdb" /machine:I386 /out:"$(OUTDIR)\ftp.exe"
+LINK32_OBJS= \
+ "$(INTDIR)\cmds.obj" \
+ "$(INTDIR)\cmdtab.obj" \
+ "$(INTDIR)\domacro.obj" \
+ "$(INTDIR)\fake.obj" \
+ "$(INTDIR)\ftp.obj" \
+ "$(INTDIR)\main.obj" \
+ "$(INTDIR)\ruserpass.obj" \
+ "d:\Program Files\DevStudio\VC\lib\WSOCK32.LIB"
+
+"$(OUTDIR)\ftp.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
+ $(LINK32) @<<
+ $(LINK32_FLAGS) $(LINK32_OBJS)
+<<
+
+TargetPath=.\Release\ftp.exe
+InputPath=.\Release\ftp.exe
+SOURCE=$(InputPath)
+
+"\emacs-19.34\bin\ftp.exe" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+# copy $(TargetPath) \emacs-19.34\bin
+
+!ELSEIF "$(CFG)" == "ftp - Win32 Debug"
+
+OUTDIR=.\Debug
+INTDIR=.\Debug
+# Begin Custom Macros
+OutDir=.\Debug
+# End Custom Macros
+
+!IF "$(RECURSE)" == "0"
+
+ALL : "$(OUTDIR)\ftp.exe" "\emacs-19.34\bin\ftp.exe"
+
+!ELSE
+
+ALL : "$(OUTDIR)\ftp.exe" "\emacs-19.34\bin\ftp.exe"
+
+!ENDIF
+
+CLEAN :
+ -@erase "$(INTDIR)\cmds.obj"
+ -@erase "$(INTDIR)\cmdtab.obj"
+ -@erase "$(INTDIR)\domacro.obj"
+ -@erase "$(INTDIR)\fake.obj"
+ -@erase "$(INTDIR)\ftp.obj"
+ -@erase "$(INTDIR)\main.obj"
+ -@erase "$(INTDIR)\ruserpass.obj"
+ -@erase "$(INTDIR)\vc50.idb"
+ -@erase "$(INTDIR)\vc50.pdb"
+ -@erase "$(OUTDIR)\ftp.exe"
+ -@erase "$(OUTDIR)\ftp.ilk"
+ -@erase "$(OUTDIR)\ftp.pdb"
+ -@erase "\emacs-19.34\bin\ftp.exe"
+
+"$(OUTDIR)" :
+ if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
+
+CPP=cl.exe
+CPP_PROJ=/nologo /MLd /W3 /Gm /GX /Zi /Od /I "C:\emacs-19.34\nt\inc" /I\
+ "C:\emacs-19.34\src" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS"\
+ /Fp"$(INTDIR)\ftp.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
+CPP_OBJS=.\Debug/
+CPP_SBRS=.
+
+.c{$(CPP_OBJS)}.obj::
+ $(CPP) @<<
+ $(CPP_PROJ) $<
+<<
+
+.cpp{$(CPP_OBJS)}.obj::
+ $(CPP) @<<
+ $(CPP_PROJ) $<
+<<
+
+.cxx{$(CPP_OBJS)}.obj::
+ $(CPP) @<<
+ $(CPP_PROJ) $<
+<<
+
+.c{$(CPP_SBRS)}.sbr::
+ $(CPP) @<<
+ $(CPP_PROJ) $<
+<<
+
+.cpp{$(CPP_SBRS)}.sbr::
+ $(CPP) @<<
+ $(CPP_PROJ) $<
+<<
+
+.cxx{$(CPP_SBRS)}.sbr::
+ $(CPP) @<<
+ $(CPP_PROJ) $<
+<<
+
+RSC=rc.exe
+BSC32=bscmake.exe
+BSC32_FLAGS=/nologo /o"$(OUTDIR)\ftp.bsc"
+BSC32_SBRS= \
+
+LINK32=link.exe
+LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\
+ advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib\
+ odbccp32.lib /nologo /subsystem:console /incremental:yes\
+ /pdb:"$(OUTDIR)\ftp.pdb" /debug /machine:I386 /out:"$(OUTDIR)\ftp.exe"\
+ /pdbtype:sept
+LINK32_OBJS= \
+ "$(INTDIR)\cmds.obj" \
+ "$(INTDIR)\cmdtab.obj" \
+ "$(INTDIR)\domacro.obj" \
+ "$(INTDIR)\fake.obj" \
+ "$(INTDIR)\ftp.obj" \
+ "$(INTDIR)\main.obj" \
+ "$(INTDIR)\ruserpass.obj" \
+ "d:\Program Files\DevStudio\VC\lib\WSOCK32.LIB"
+
+"$(OUTDIR)\ftp.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
+ $(LINK32) @<<
+ $(LINK32_FLAGS) $(LINK32_OBJS)
+<<
+
+TargetPath=.\Debug\ftp.exe
+InputPath=.\Debug\ftp.exe
+SOURCE=$(InputPath)
+
+"\emacs-19.34\bin\ftp.exe" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+# copy $(TargetPath) \emacs-19.34\bin
+
+!ENDIF
+
+
+!IF "$(CFG)" == "ftp - Win32 Release" || "$(CFG)" == "ftp - Win32 Debug"
+SOURCE=.\cmds.c
+
+!IF "$(CFG)" == "ftp - Win32 Release"
+
+DEP_CPP_CMDS_=\
+ ".\fake.h"\
+ ".\ftp_var.h"\
+ ".\pathnames.h"\
+ ".\prototypes.h"\
+
+
+"$(INTDIR)\cmds.obj" : $(SOURCE) $(DEP_CPP_CMDS_) "$(INTDIR)"
+
+
+!ELSEIF "$(CFG)" == "ftp - Win32 Debug"
+
+DEP_CPP_CMDS_=\
+ "..\..\..\emacs-19.34\nt\inc\netdb.h"\
+ "..\..\..\emacs-19.34\nt\inc\netinet\in.h"\
+ "..\..\..\emacs-19.34\nt\inc\sys\socket.h"\
+ "..\..\..\emacs-19.34\src\nt.h"\
+ ".\fake.h"\
+ ".\ftp_var.h"\
+ ".\pathnames.h"\
+ ".\prototypes.h"\
+ {$(INCLUDE)}"sys\stat.h"\
+ {$(INCLUDE)}"sys\types.h"\
+
+
+"$(INTDIR)\cmds.obj" : $(SOURCE) $(DEP_CPP_CMDS_) "$(INTDIR)"
+
+
+!ENDIF
+
+SOURCE=.\cmdtab.c
+DEP_CPP_CMDTA=\
+ ".\fake.h"\
+ ".\ftp_var.h"\
+
+
+"$(INTDIR)\cmdtab.obj" : $(SOURCE) $(DEP_CPP_CMDTA) "$(INTDIR)"
+
+
+SOURCE=.\domacro.c
+DEP_CPP_DOMAC=\
+ ".\fake.h"\
+ ".\ftp_var.h"\
+ ".\prototypes.h"\
+
+
+"$(INTDIR)\domacro.obj" : $(SOURCE) $(DEP_CPP_DOMAC) "$(INTDIR)"
+
+
+SOURCE=.\fake.c
+DEP_CPP_FAKE_=\
+ ".\prototypes.h"\
+
+
+"$(INTDIR)\fake.obj" : $(SOURCE) $(DEP_CPP_FAKE_) "$(INTDIR)"
+
+
+SOURCE=.\ftp.c
+
+!IF "$(CFG)" == "ftp - Win32 Release"
+
+DEP_CPP_FTP_C=\
+ ".\fake.h"\
+ ".\ftp_var.h"\
+ ".\prototypes.h"\
+
+
+"$(INTDIR)\ftp.obj" : $(SOURCE) $(DEP_CPP_FTP_C) "$(INTDIR)"
+
+
+!ELSEIF "$(CFG)" == "ftp - Win32 Debug"
+
+DEP_CPP_FTP_C=\
+ "..\..\..\emacs-19.34\nt\inc\netdb.h"\
+ "..\..\..\emacs-19.34\nt\inc\netinet\in.h"\
+ "..\..\..\emacs-19.34\nt\inc\pwd.h"\
+ "..\..\..\emacs-19.34\nt\inc\sys\file.h"\
+ "..\..\..\emacs-19.34\nt\inc\sys\ioctl.h"\
+ "..\..\..\emacs-19.34\nt\inc\sys\param.h"\
+ "..\..\..\emacs-19.34\nt\inc\sys\socket.h"\
+ "..\..\..\emacs-19.34\nt\inc\sys\time.h"\
+ "..\..\..\emacs-19.34\src\nt.h"\
+ ".\fake.h"\
+ ".\ftp_var.h"\
+ ".\prototypes.h"\
+ {$(INCLUDE)}"sys\stat.h"\
+ {$(INCLUDE)}"sys\types.h"\
+
+
+"$(INTDIR)\ftp.obj" : $(SOURCE) $(DEP_CPP_FTP_C) "$(INTDIR)"
+
+
+!ENDIF
+
+SOURCE=.\main.c
+
+!IF "$(CFG)" == "ftp - Win32 Release"
+
+DEP_CPP_MAIN_=\
+ ".\fake.h"\
+ ".\ftp_var.h"\
+ ".\prototypes.h"\
+
+
+"$(INTDIR)\main.obj" : $(SOURCE) $(DEP_CPP_MAIN_) "$(INTDIR)"
+
+
+!ELSEIF "$(CFG)" == "ftp - Win32 Debug"
+
+DEP_CPP_MAIN_=\
+ "..\..\..\emacs-19.34\nt\inc\netdb.h"\
+ "..\..\..\emacs-19.34\nt\inc\pwd.h"\
+ "..\..\..\emacs-19.34\nt\inc\sys\ioctl.h"\
+ "..\..\..\emacs-19.34\nt\inc\sys\socket.h"\
+ "..\..\..\emacs-19.34\src\nt.h"\
+ ".\fake.h"\
+ ".\ftp_var.h"\
+ ".\prototypes.h"\
+ {$(INCLUDE)}"sys\types.h"\
+
+
+"$(INTDIR)\main.obj" : $(SOURCE) $(DEP_CPP_MAIN_) "$(INTDIR)"
+
+
+!ENDIF
+
+SOURCE=.\ruserpass.c
+
+!IF "$(CFG)" == "ftp - Win32 Release"
+
+DEP_CPP_RUSER=\
+ ".\fake.h"\
+ ".\ftp_var.h"\
+ ".\prototypes.h"\
+
+
+"$(INTDIR)\ruserpass.obj" : $(SOURCE) $(DEP_CPP_RUSER) "$(INTDIR)"
+
+
+!ELSEIF "$(CFG)" == "ftp - Win32 Debug"
+
+DEP_CPP_RUSER=\
+ ".\fake.h"\
+ ".\ftp_var.h"\
+ ".\prototypes.h"\
+ {$(INCLUDE)}"sys\stat.h"\
+ {$(INCLUDE)}"sys\types.h"\
+
+
+"$(INTDIR)\ruserpass.obj" : $(SOURCE) $(DEP_CPP_RUSER) "$(INTDIR)"
+
+
+!ENDIF
+
+
+!ENDIF
diff --git a/reactos/apps/utils/net/ftp/ftp.rc b/reactos/apps/utils/net/ftp/ftp.rc
new file mode 100644
index 00000000000..505a9fe9d25
--- /dev/null
+++ b/reactos/apps/utils/net/ftp/ftp.rc
@@ -0,0 +1,6 @@
+/* $Id: route.rc 11816 2004-11-26 06:51:47Z arty $ */
+
+#define REACTOS_STR_FILE_DESCRIPTION "ReactOS TCP/IPv4 FTP Client\0"
+#define REACTOS_STR_INTERNAL_NAME "ftp\0"
+#define REACTOS_STR_ORIGINAL_FILENAME "ftp.exe\0"
+#include
diff --git a/reactos/apps/utils/net/ftp/ftp.xml b/reactos/apps/utils/net/ftp/ftp.xml
new file mode 100644
index 00000000000..c5a07d34a64
--- /dev/null
+++ b/reactos/apps/utils/net/ftp/ftp.xml
@@ -0,0 +1,15 @@
+
+ .
+
+ kernel32
+ ws2_32
+ iphlpapi
+ cmds.c
+ cmdtab.c
+ domacro.c
+ fake.c
+ ftp.c
+ main.c
+ ruserpass.c
+ ftp.rc
+
diff --git a/reactos/apps/utils/net/ftp/ftp_var.h b/reactos/apps/utils/net/ftp/ftp_var.h
new file mode 100644
index 00000000000..7c33434a7e7
--- /dev/null
+++ b/reactos/apps/utils/net/ftp/ftp_var.h
@@ -0,0 +1,181 @@
+#include "fake.h"
+#include
+#include
+
+//typedef void (*Sig_t)(int);
+
+int fgetcSocket(int s);
+char *fputsSocket(char *format, int s);
+
+char *fprintfSocket(int s, char *format, ...);
+
+int fputcSocket(int s, char putChar);
+int fputSocket(int s, char *putChar, int len);
+char *fgetsSocket(int s, char *string);
+
+/* The following defines are from ftp.h and telnet.h from bsd.h */
+/* All relevent copyrights below apply. */
+
+#define IAC 255
+#define DONT 254
+#define DO 253
+#define WONT 252
+#define WILL 251
+#define SB 250
+#define GA 249
+#define EL 248
+#define EC 247
+#define AYT 246
+#define AO 245
+#define IP 244
+#define BREAK 243
+#define DM 242
+#define NOP 241
+#define SE 240
+#define EOR 239
+#define ABORT 238
+#define SUSP 237
+#define xEOF 236
+
+
+#define MAXPATHLEN 255
+#define TYPE_A 'A'
+#define TYPE_I 'I'
+#define TYPE_E 'E'
+#define TYPE_L 'L'
+
+#define PRELIM 1
+#define COMPLETE 2
+#define CONTINUE 3
+#define TRANSIENT 4
+
+#define MODE_S 1
+#define MODE_B 2
+#define MODE_C 3
+
+#define STRU_F 1
+#define STRU_R 2
+#define STRU_P 3
+
+#define SIGQUIT 1
+#define SIGPIPE 2
+#define SIGALRM 3
+
+
+#define FORM_N 1
+#define FORM_T 2
+#define FORM_C 3
+
+
+/*
+ * Copyright (c) 1985 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the University of California, Berkeley. The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * @(#)ftp_var.h 5.5 (Berkeley) 6/29/88
+ */
+
+/*
+ * FTP global variables.
+ */
+
+/*
+ * Options and other state info.
+ */
+extern int trace; /* trace packets exchanged */
+extern int hash; /* print # for each buffer transferred */
+extern int sendport; /* use PORT cmd for each data connection */
+extern int verbose; /* print messages coming back from server */
+extern int connected; /* connected to server */
+extern int fromatty; /* input is from a terminal */
+extern int interactive; /* interactively prompt on m* cmds */
+extern int debug; /* debugging level */
+extern int bell; /* ring bell on cmd completion */
+extern int doglob; /* glob local file names */
+extern int proxy; /* proxy server connection active */
+extern int proxflag; /* proxy connection exists */
+extern int sunique; /* store files on server with unique name */
+extern int runique; /* store local files with unique name */
+extern int mcase; /* map upper to lower case for mget names */
+extern int ntflag; /* use ntin ntout tables for name translation */
+extern int mapflag; /* use mapin mapout templates on file names */
+extern int code; /* return/reply code for ftp command */
+extern int crflag; /* if 1, strip car. rets. on ascii gets */
+extern char pasv[64]; /* passive port for proxy data connection */
+extern int passivemode; /* passive mode enabled */
+extern char *altarg; /* argv[1] with no shell-like preprocessing */
+extern char ntin[17]; /* input translation table */
+extern char ntout[17]; /* output translation table */
+
+extern char mapin[MAXPATHLEN]; /* input map template */
+extern char mapout[MAXPATHLEN]; /* output map template */
+extern char typename[32]; /* name of file transfer type */
+extern int type; /* file transfer type */
+extern char structname[32]; /* name of file transfer structure */
+extern int stru; /* file transfer structure */
+extern char formname[32]; /* name of file transfer format */
+extern int form; /* file transfer format */
+extern char modename[32]; /* name of file transfer mode */
+extern int mode; /* file transfer mode */
+extern char bytename[32]; /* local byte size in ascii */
+extern int bytesize; /* local byte size in binary */
+
+extern jmp_buf toplevel; /* non-local goto stuff for cmd scanner */
+
+extern char line[200]; /* input line buffer */
+extern char *stringbase; /* current scan point in line buffer */
+extern char argbuf[200]; /* argument storage buffer */
+extern char *argbase; /* current storage point in arg buffer */
+extern int margc; /* count of arguments on input line */
+extern char *margv[20]; /* args parsed from input line */
+extern int cpend; /* flag: if != 0, then pending server reply */
+extern int mflag; /* flag: if != 0, then active multi command */
+
+extern int options; /* used during socket creation */
+
+/*
+ * Format of command table.
+ */
+struct cmd {
+ char *c_name; /* name of command */
+ char *c_help; /* help string */
+ char c_bell; /* give bell when command completes */
+ char c_conn; /* must be connected to use command */
+ char c_proxy; /* proxy server may execute */
+ int (*c_handler)(); /* function to call */
+};
+
+struct macel {
+ char mac_name[9]; /* macro name */
+ char *mac_start; /* start of macro in macbuf */
+ char *mac_end; /* end of macro in macbuf */
+};
+
+int macnum; /* number of defined macros */
+struct macel macros[16];
+char macbuf[4096];
+
+extern char *tail();
+extern char *remglob();
+extern int errno;
+extern char *mktemp();
+
+#if defined(__ANSI__) || defined(sparc)
+typedef void sig_t;
+#else
+typedef int sig_t;
+#endif
+
+typedef int uid_t;
+int herror(char *s);
diff --git a/reactos/apps/utils/net/ftp/main.c b/reactos/apps/utils/net/ftp/main.c
new file mode 100644
index 00000000000..fd6c506b2b2
--- /dev/null
+++ b/reactos/apps/utils/net/ftp/main.c
@@ -0,0 +1,602 @@
+/*
+ * Copyright (c) 1985, 1989 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the University of California, Berkeley. The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#ifndef lint
+char copyright[] =
+"@(#) Copyright (c) 1985, 1989 Regents of the University of California.\n\
+ All rights reserved.\n";
+#endif /* not lint */
+
+#ifndef lint
+static char sccsid[] = "@(#)main.c based on 5.13 (Berkeley) 3/14/89";
+#endif /* not lint */
+
+/*
+ * FTP User Program -- Command Interface.
+ */
+#if !defined(WIN32)
+#include
+#include
+#include
+#include
+#include
+#include
+#endif
+#include "ftp_var.h"
+#include "prototypes.h"
+#include
+
+#include
+#include
+
+#include
+#include
+#include
+#include
+
+
+#if defined(sun) && !defined(FD_SET)
+typedef int uid_t;
+#endif
+
+uid_t getuid();
+void intr();
+void lostpeer();
+char *getlogin();
+
+short portnum;
+
+char home[128];
+char *globerr;
+int autologin;
+
+
+
+/* Lot's of options... */
+/*
+ * Options and other state info.
+ */
+int trace; /* trace packets exchanged */
+int hash; /* print # for each buffer transferred */
+int sendport; /* use PORT cmd for each data connection */
+int verbose; /* print messages coming back from server */
+int connected; /* connected to server */
+int fromatty; /* input is from a terminal */
+int interactive; /* interactively prompt on m* cmds */
+int debug; /* debugging level */
+int bell; /* ring bell on cmd completion */
+int doglob; /* glob local file names */
+int proxy; /* proxy server connection active */
+int passivemode;
+int proxflag; /* proxy connection exists */
+int sunique; /* store files on server with unique name */
+int runique; /* store local files with unique name */
+int mcase; /* map upper to lower case for mget names */
+int ntflag; /* use ntin ntout tables for name translation */
+int mapflag; /* use mapin mapout templates on file names */
+int code; /* return/reply code for ftp command */
+int crflag; /* if 1, strip car. rets. on ascii gets */
+char pasv[64]; /* passive port for proxy data connection */
+char *altarg; /* argv[1] with no shell-like preprocessing */
+char ntin[17]; /* input translation table */
+char ntout[17]; /* output translation table */
+// #include
+char mapin[MAXPATHLEN]; /* input map template */
+char mapout[MAXPATHLEN]; /* output map template */
+char typename[32]; /* name of file transfer type */
+int type; /* file transfer type */
+char structname[32]; /* name of file transfer structure */
+int stru; /* file transfer structure */
+char formname[32]; /* name of file transfer format */
+int form; /* file transfer format */
+char modename[32]; /* name of file transfer mode */
+int mode; /* file transfer mode */
+char bytename[32]; /* local byte size in ascii */
+int bytesize; /* local byte size in binary */
+
+jmp_buf toplevel; /* non-local goto stuff for cmd scanner */
+
+char line[200]; /* input line buffer */
+char *stringbase; /* current scan point in line buffer */
+char argbuf[200]; /* argument storage buffer */
+char *argbase; /* current storage point in arg buffer */
+int margc; /* count of arguments on input line */
+char *margv[20]; /* args parsed from input line */
+int cpend; /* flag: if != 0, then pending server reply */
+int mflag; /* flag: if != 0, then active multi command */
+
+int options; /* used during socket creation */
+
+
+
+int main(int argc, char *argv[])
+{
+ register char *cp;
+ int top;
+ struct passwd *pw = NULL;
+#if 0
+ char homedir[MAXPATHLEN];
+#endif
+
+ int err;
+ WORD wVerReq;
+
+ WSADATA WSAData;
+ struct servent *sp; /* service spec for tcp/ftp */
+
+ /* Disable output buffering, for the benefit of Emacs. */
+ //setbuf(stdout, NULL);
+
+ _fmode = O_BINARY; // This causes an error somewhere.
+
+ wVerReq = MAKEWORD(1,1);
+
+ err = WSAStartup(wVerReq, &WSAData);
+ if (err != 0)
+ {
+ fprintf(stderr, "Could not initialize Windows socket interface.");
+ exit(1);
+ }
+
+ sp = getservbyname("ftp", "tcp");
+ if (sp == 0) {
+ fprintf(stderr, "ftp: ftp/tcp: unknown service\n");
+ exit(1);
+ }
+
+ portnum = sp->s_port;
+
+
+ doglob = 1;
+ interactive = 1;
+ autologin = 1;
+ argc--, argv++;
+ while (argc > 0 && **argv == '-') {
+ for (cp = *argv + 1; *cp; cp++)
+ switch (*cp) {
+
+ case 'd':
+ options |= SO_DEBUG;
+ debug++;
+ break;
+
+ case 'v':
+ verbose++;
+ break;
+
+ case 't':
+ trace++;
+ break;
+
+ case 'i':
+ interactive = 0;
+ break;
+
+ case 'n':
+ autologin = 0;
+ break;
+
+ case 'g':
+ doglob = 0;
+ break;
+
+ default:
+ fprintf(stdout,
+ "ftp: %c: unknown option\n", *cp);
+ exit(1);
+ }
+ argc--, argv++;
+ }
+// fromatty = isatty(fileno(stdin));
+ fromatty = 1; // Strengthen this test
+ /*
+ * Set up defaults for FTP.
+ */
+ (void) strcpy(typename, "ascii"), type = TYPE_A;
+ (void) strcpy(formname, "non-print"), form = FORM_N;
+ (void) strcpy(modename, "stream"), mode = MODE_S;
+ (void) strcpy(structname, "file"), stru = STRU_F;
+ (void) strcpy(bytename, "8"), bytesize = 8;
+ if (fromatty)
+ verbose++;
+ cpend = 0; /* no pending replies */
+ proxy = 0; /* proxy not active */
+ passivemode = 1; /* passive mode *is* active */
+ crflag = 1; /* strip c.r. on ascii gets */
+ /*
+ * Set up the home directory in case we're globbing.
+ */
+#if 0
+ cp = getlogin();
+ if (cp != NULL) {
+ pw = getpwnam(cp);
+ }
+ if (pw == NULL)
+ pw = getpwuid(getuid());
+ if (pw != NULL) {
+ home = homedir;
+ (void) strcpy(home, pw->pw_dir);
+ }
+#endif
+ strcpy(home, "C:/");
+ if (argc > 0) {
+ if (setjmp(toplevel))
+ exit(0);
+// (void) signal(SIGINT, intr);
+// (void) signal(SIGPIPE, lostpeer);
+ setpeer(argc + 1, argv - 1);
+ }
+ top = setjmp(toplevel) == 0;
+ if (top) {
+// (void) signal(SIGINT, intr);
+// (void) signal(SIGPIPE, lostpeer);
+ }
+ for (;;) {
+ cmdscanner(top);
+ top = 1;
+ }
+}
+
+void
+intr()
+{
+
+ longjmp(toplevel, 1);
+}
+
+void lostpeer(void)
+{
+ extern int cout;
+ extern int data;
+
+ if (connected) {
+ if (cout != (int) NULL) {
+ closesocket(cout);
+ cout = (int) NULL;
+ }
+ if (data >= 0) {
+ (void) shutdown(data, 1+1);
+ (void) close(data);
+ data = -1;
+ }
+ connected = 0;
+ }
+ pswitch(1);
+ if (connected) {
+ if (cout != (int)NULL) {
+ closesocket(cout);
+ cout = (int) NULL;
+ }
+ connected = 0;
+ }
+ proxflag = 0;
+ pswitch(0);
+}
+
+/*char *
+tail(filename)
+ char *filename;
+{
+ register char *s;
+
+ while (*filename) {
+ s = rindex(filename, '/');
+ if (s == NULL)
+ break;
+ if (s[1])
+ return (s + 1);
+ *s = '\0';
+ }
+ return (filename);
+}
+*/
+/*
+ * Command parser.
+ */
+void cmdscanner(top)
+ int top;
+{
+ register struct cmd *c;
+ struct cmd *getcmd();
+ extern int help();
+
+ if (!top)
+ (void) putchar('\n');
+ for (;;) {
+ (void) fflush(stdout);
+ if (fromatty) {
+ printf("ftp> ");
+ (void) fflush(stdout);
+ }
+ if (gets(line) == 0) {
+ if (feof(stdin) || ferror(stdin))
+ quit();
+ break;
+ }
+ if (line[0] == 0)
+ break;
+ makeargv();
+ if (margc == 0) {
+ continue;
+ }
+ c = getcmd(margv[0]);
+ if (c == (struct cmd *)-1) {
+ printf("?Ambiguous command\n");
+ continue;
+ }
+ if (c == 0) {
+ printf("?Invalid command\n");
+ continue;
+ }
+ if (c->c_conn && !connected) {
+ printf ("Not connected.\n");
+ continue;
+ }
+ (*c->c_handler)(margc, margv);
+ if (bell && c->c_bell)
+ (void) putchar('\007');
+ if (c->c_handler != help)
+ break;
+ }
+ (void) fflush(stdout);
+// (void) signal(SIGINT, intr);
+// (void) signal(SIGPIPE, lostpeer);
+}
+
+struct cmd *
+getcmd(name)
+ register char *name;
+{
+ extern struct cmd cmdtab[];
+ register char *p, *q;
+ register struct cmd *c, *found;
+ register int nmatches, longest;
+
+ longest = 0;
+ nmatches = 0;
+ found = 0;
+ for (c = cmdtab; p = c->c_name; c++) {
+ for (q = name; *q == *p++; q++)
+ if (*q == 0) /* exact match? */
+ return (c);
+ if (!*q) { /* the name was a prefix */
+ if (q - name > longest) {
+ longest = q - name;
+ nmatches = 1;
+ found = c;
+ } else if (q - name == longest)
+ nmatches++;
+ }
+ }
+ if (nmatches > 1)
+ return ((struct cmd *)-1);
+ return (found);
+}
+
+/*
+ * Slice a string up into argc/argv.
+ */
+
+int slrflag;
+
+void makeargv()
+{
+ char **argp;
+ char *slurpstring();
+
+ margc = 0;
+ argp = margv;
+ stringbase = line; /* scan from first of buffer */
+ argbase = argbuf; /* store from first of buffer */
+ slrflag = 0;
+ while (*argp++ = slurpstring())
+ margc++;
+}
+
+/*
+ * Parse string into argbuf;
+ * implemented with FSM to
+ * handle quoting and strings
+ */
+char *
+slurpstring()
+{
+ int got_one = 0;
+ register char *sb = stringbase;
+ register char *ap = argbase;
+ char *tmp = argbase; /* will return this if token found */
+
+ if (*sb == '!' || *sb == '$') { /* recognize ! as a token for shell */
+ switch (slrflag) { /* and $ as token for macro invoke */
+ case 0:
+ slrflag++;
+ stringbase++;
+ return ((*sb == '!') ? "!" : "$");
+ /* NOTREACHED */
+ case 1:
+ slrflag++;
+ altarg = stringbase;
+ break;
+ default:
+ break;
+ }
+ }
+
+S0:
+ switch (*sb) {
+
+ case '\0':
+ goto OUT1;
+
+ case ' ':
+ case '\t':
+ sb++; goto S0;
+
+ default:
+ switch (slrflag) {
+ case 0:
+ slrflag++;
+ break;
+ case 1:
+ slrflag++;
+ altarg = sb;
+ break;
+ default:
+ break;
+ }
+ goto S1;
+ }
+
+S1:
+ switch (*sb) {
+
+ case ' ':
+ case '\t':
+ case '\0':
+ goto OUT1; /* end of token */
+
+ case '\\':
+ sb++; goto S2; /* slurp next character */
+
+ case '"':
+ sb++; goto S3; /* slurp quoted string */
+
+ default:
+ *ap++ = *sb++; /* add character to token */
+ got_one = 1;
+ goto S1;
+ }
+
+S2:
+ switch (*sb) {
+
+ case '\0':
+ goto OUT1;
+
+ default:
+ *ap++ = *sb++;
+ got_one = 1;
+ goto S1;
+ }
+
+S3:
+ switch (*sb) {
+
+ case '\0':
+ goto OUT1;
+
+ case '"':
+ sb++; goto S1;
+
+ default:
+ *ap++ = *sb++;
+ got_one = 1;
+ goto S3;
+ }
+
+OUT1:
+ if (got_one)
+ *ap++ = '\0';
+ argbase = ap; /* update storage pointer */
+ stringbase = sb; /* update scan pointer */
+ if (got_one) {
+ return(tmp);
+ }
+ switch (slrflag) {
+ case 0:
+ slrflag++;
+ break;
+ case 1:
+ slrflag++;
+ altarg = (char *) 0;
+ break;
+ default:
+ break;
+ }
+ return((char *)0);
+}
+
+#define HELPINDENT (sizeof ("directory"))
+
+/*
+ * Help command.
+ * Call each command handler with argc == 0 and argv[0] == name.
+ */
+int help(argc, argv)
+ int argc;
+ char *argv[];
+{
+ extern struct cmd cmdtab[];
+ register struct cmd *c;
+
+ if (argc == 1) {
+ register int i, j, w, k;
+ int columns, width = 0, lines;
+ extern int NCMDS;
+
+ printf("Commands may be abbreviated. Commands are:\n\n");
+ for (c = cmdtab; c < &cmdtab[NCMDS]; c++) {
+ int len = strlen(c->c_name);
+
+ if (len > width)
+ width = len;
+ }
+ width = (width + 8) &~ 7;
+ columns = 80 / width;
+ if (columns == 0)
+ columns = 1;
+ lines = (NCMDS + columns - 1) / columns;
+ for (i = 0; i < lines; i++) {
+ for (j = 0; j < columns; j++) {
+ c = cmdtab + j * lines + i;
+ if (c->c_name && (!proxy || c->c_proxy)) {
+ printf("%s", c->c_name);
+ }
+ else if (c->c_name) {
+ for (k=0; k < (int) strlen(c->c_name); k++) {
+ (void) putchar(' ');
+ }
+ }
+ if (c + lines >= &cmdtab[NCMDS]) {
+ printf("\n");
+ break;
+ }
+ w = strlen(c->c_name);
+ while (w < width) {
+ w = (w + 8) &~ 7;
+ (void) putchar('\t');
+ }
+ }
+ }
+ (void) fflush(stdout);
+ return 0;
+ }
+ while (--argc > 0) {
+ register char *arg;
+ arg = *++argv;
+ c = getcmd(arg);
+ if (c == (struct cmd *)-1)
+ printf("?Ambiguous help command %s\n", arg);
+ else if (c == (struct cmd *)0)
+ printf("?Invalid help command %s\n", arg);
+ else
+ printf("%-*s\t%s\n", HELPINDENT,
+ c->c_name, c->c_help);
+ }
+ (void) fflush(stdout);
+ return 0;
+}
diff --git a/reactos/apps/utils/net/ftp/makefile b/reactos/apps/utils/net/ftp/makefile
new file mode 100644
index 00000000000..a32c246c310
--- /dev/null
+++ b/reactos/apps/utils/net/ftp/makefile
@@ -0,0 +1,27 @@
+PATH_TO_TOP = ../../../..
+
+TARGET_TYPE = program
+
+TARGET_APPTYPE = console
+
+TARGET_NAME = ftp
+
+TARGET_INSTALLDIR = system32
+
+TARGET_SDKLIBS = ws2_32.a iphlpapi.a
+# ntdll.a
+
+TARGET_OBJECTS = \
+ cmds.o \
+ cmdtab.o \
+ domacro.o \
+ fake.o \
+ ftp.o \
+ main.o \
+ ruserpass.o
+
+TARGET_GCCLIBS =
+
+include $(PATH_TO_TOP)/rules.mak
+
+include $(TOOLS_PATH)/helper.mk
diff --git a/reactos/apps/utils/net/ftp/pathnames.h b/reactos/apps/utils/net/ftp/pathnames.h
new file mode 100644
index 00000000000..676aa507daf
--- /dev/null
+++ b/reactos/apps/utils/net/ftp/pathnames.h
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 1989 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the University of California, Berkeley. The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * %W% (Berkeley) %G%
+ */
+
+#define _PATH_TMP "/tmp/ftpXXXXXX"
+#define _PATH_BSHELL "/bin/sh"
diff --git a/reactos/apps/utils/net/ftp/prototypes.h b/reactos/apps/utils/net/ftp/prototypes.h
new file mode 100644
index 00000000000..3bff115d48f
--- /dev/null
+++ b/reactos/apps/utils/net/ftp/prototypes.h
@@ -0,0 +1,32 @@
+
+int getreply(int expecteof);
+int ruserpass(char *host, char **aname, char **apass, char **aacct);
+char *getpass(const char *prompt);
+void makeargv(void);
+void domacro(int argc, char *argv[]);
+void proxtrans(char *cmd, char *local, char *remote);
+int null(void);
+int initconn(void);
+void disconnect(void);
+void ptransfer(char *direction, long bytes, struct timeval *t0, struct timeval *t1);
+void setascii(void);
+void setbinary(void);
+void setebcdic(void);
+void settenex(void);
+void tvsub(struct timeval *tdiff, struct timeval *t1, struct timeval *t0);
+void setpassive(int argc, char *argv[]);
+void setpeer(int argc, char *argv[]);
+void cmdscanner(int top);
+void pswitch(int flag);
+void quit(void);
+int login(char *host);
+int command(char *fmt, ...);
+int globulize(char **cpp);
+void sendrequest(char *cmd, char *local, char *remote, int printnames);
+void recvrequest(char *cmd, char *local, char *remote, char *mode,
+ int printnames);
+int confirm(char *cmd, char *file);
+void blkfree(char **av0);
+int getit(int argc, char *argv[], int restartit, char *mode);
+static int token(void);
+int sleep(int time);
diff --git a/reactos/apps/utils/net/ftp/ruserpass.c b/reactos/apps/utils/net/ftp/ruserpass.c
new file mode 100644
index 00000000000..ea6751bae0e
--- /dev/null
+++ b/reactos/apps/utils/net/ftp/ruserpass.c
@@ -0,0 +1,271 @@
+/*
+ * Copyright (c) 1985 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the University of California, Berkeley. The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)ruserpass.c 5.1 (Berkeley) 3/1/89";
+#endif /* not lint */
+
+#include
+#include
+//#include
+#include
+#include
+#include
+#include "ftp_var.h"
+#include "prototypes.h"
+#include
+
+char *renvlook(), *index(), *getenv(), *getpass(), *getlogin();
+void *malloc();
+char *strcpy();
+struct utmp *getutmp();
+static FILE *cfile;
+
+#ifndef MAXHOSTNAMELEN
+#define MAXHOSTNAMELEN 64
+#endif
+
+#define DEFAULT 1
+#define LOGIN 2
+#define PASSWD 3
+#define ACCOUNT 4
+#define MACDEF 5
+#define ID 10
+#define MACH 11
+
+static char tokval[100];
+
+static struct toktab {
+ char *tokstr;
+ int tval;
+} toktab[]= {
+ "default", DEFAULT,
+ "login", LOGIN,
+ "password", PASSWD,
+ "passwd", PASSWD,
+ "account", ACCOUNT,
+ "machine", MACH,
+ "macdef", MACDEF,
+ 0, 0
+};
+
+extern char *hostname;
+
+int ruserpass(char *host, char **aname, char **apass, char **aacct)
+{
+ char *hdir, buf[BUFSIZ], *tmp;
+ char myname[MAXHOSTNAMELEN], *mydomain;
+ int t, i, c, usedefault = 0;
+ struct stat stb;
+ extern int errno;
+
+ hdir = getenv("HOME");
+ if (hdir == NULL)
+ hdir = ".";
+ (void) sprintf(buf, "%s/.netrc", hdir);
+ cfile = fopen(buf, "r");
+ if (cfile == NULL) {
+ if (errno != ENOENT)
+ perror(buf);
+ return(0);
+ }
+
+
+ if (gethostname(myname, sizeof(myname)) < 0)
+ myname[0] = '\0';
+ if ((mydomain = index(myname, '.')) == NULL)
+ mydomain = "";
+next:
+ while ((t = token())) switch(t) {
+
+ case DEFAULT:
+ usedefault = 1;
+ /* FALL THROUGH */
+
+ case MACH:
+ if (!usedefault) {
+ if (token() != ID)
+ continue;
+ /*
+ * Allow match either for user's input host name
+ * or official hostname. Also allow match of
+ * incompletely-specified host in local domain.
+ */
+ if (strcasecmp(host, tokval) == 0)
+ goto match;
+ if (strcasecmp(hostname, tokval) == 0)
+ goto match;
+ if ((tmp = index(hostname, '.')) != NULL &&
+ strcasecmp(tmp, mydomain) == 0 &&
+ strncasecmp(hostname, tokval, tmp - hostname) == 0 &&
+ tokval[tmp - hostname] == '\0')
+ goto match;
+ if ((tmp = index(host, '.')) != NULL &&
+ strcasecmp(tmp, mydomain) == 0 &&
+ strncasecmp(host, tokval, tmp - host) == 0 &&
+ tokval[tmp - host] == '\0')
+ goto match;
+ continue;
+ }
+ match:
+ while ((t = token()) && t != MACH && t != DEFAULT) switch(t) {
+
+ case LOGIN:
+ if (token())
+ if (*aname == 0) {
+ *aname = malloc((unsigned) strlen(tokval) + 1);
+ (void) strcpy(*aname, tokval);
+ } else {
+ if (strcmp(*aname, tokval))
+ goto next;
+ }
+ break;
+ case PASSWD:
+ if (strcmp(*aname, "anonymous") &&
+ fstat(fileno(cfile), &stb) >= 0 &&
+ (stb.st_mode & 077) != 0) {
+ fprintf(stderr, "Error - .netrc file not correct mode.\n");
+ fprintf(stderr, "Remove password or correct mode.\n");
+ goto bad;
+ }
+ if (token() && *apass == 0) {
+ *apass = malloc((unsigned) strlen(tokval) + 1);
+ (void) strcpy(*apass, tokval);
+ }
+ break;
+ case ACCOUNT:
+ if (fstat(fileno(cfile), &stb) >= 0
+ && (stb.st_mode & 077) != 0) {
+ fprintf(stderr, "Error - .netrc file not correct mode.\n");
+ fprintf(stderr, "Remove account or correct mode.\n");
+ goto bad;
+ }
+ if (token() && *aacct == 0) {
+ *aacct = malloc((unsigned) strlen(tokval) + 1);
+ (void) strcpy(*aacct, tokval);
+ }
+ break;
+ case MACDEF:
+ if (proxy) {
+ (void) fclose(cfile);
+ return(0);
+ }
+ while ((c=getc(cfile)) != EOF && c == ' ' || c == '\t');
+ if (c == EOF || c == '\n') {
+ printf("Missing macdef name argument.\n");
+ goto bad;
+ }
+ if (macnum == 16) {
+ printf("Limit of 16 macros have already been defined\n");
+ goto bad;
+ }
+ tmp = macros[macnum].mac_name;
+ *tmp++ = c;
+ for (i=0; i < 8 && (c=getc(cfile)) != EOF &&
+ !isspace(c); ++i) {
+ *tmp++ = c;
+ }
+ if (c == EOF) {
+ printf("Macro definition missing null line terminator.\n");
+ goto bad;
+ }
+ *tmp = '\0';
+ if (c != '\n') {
+ while ((c=getc(cfile)) != EOF && c != '\n');
+ }
+ if (c == EOF) {
+ printf("Macro definition missing null line terminator.\n");
+ goto bad;
+ }
+ if (macnum == 0) {
+ macros[macnum].mac_start = macbuf;
+ }
+ else {
+ macros[macnum].mac_start = macros[macnum-1].mac_end + 1;
+ }
+ tmp = macros[macnum].mac_start;
+ while (tmp != macbuf + 4096) {
+ if ((c=getc(cfile)) == EOF) {
+ printf("Macro definition missing null line terminator.\n");
+ goto bad;
+ }
+ *tmp = c;
+ if (*tmp == '\n') {
+ if (*(tmp-1) == '\0') {
+ macros[macnum++].mac_end = tmp - 1;
+ break;
+ }
+ *tmp = '\0';
+ }
+ tmp++;
+ }
+ if (tmp == macbuf + 4096) {
+ printf("4K macro buffer exceeded\n");
+ goto bad;
+ }
+ break;
+ default:
+ fprintf(stderr, "Unknown .netrc keyword %s\n", tokval);
+ break;
+ }
+ goto done;
+ }
+done:
+ (void) fclose(cfile);
+ return(0);
+bad:
+ (void) fclose(cfile);
+ return(-1);
+}
+
+static int token(void)
+{
+ char *cp;
+ int c;
+ struct toktab *t;
+
+ if (feof(cfile))
+ return (0);
+ while ((c = getc(cfile)) != EOF &&
+ (c == '\r' || c == '\n' || c == '\t' || c == ' ' || c == ','))
+ continue;
+ if (c == EOF)
+ return (0);
+ cp = tokval;
+ if (c == '"') {
+ while ((c = getc(cfile)) != EOF && c != '"') {
+ if (c == '\\')
+ c = getc(cfile);
+ *cp++ = c;
+ }
+ } else {
+ *cp++ = c;
+ while ((c = getc(cfile)) != EOF
+ && c != '\n' && c != '\t' && c != ' ' && c != ',' && c != '\r') {
+ if (c == '\\')
+ c = getc(cfile);
+ *cp++ = c;
+ }
+ }
+ *cp = 0;
+ if (tokval[0] == 0)
+ return (0);
+ for (t = toktab; t->tokstr; t++)
+ if (!strcmp(t->tokstr, tokval))
+ return (t->tval);
+ return (ID);
+}
diff --git a/reactos/apps/utils/net/ping/ping.c b/reactos/apps/utils/net/ping/ping.c
index 0b241fa1662..5cab24632b7 100644
--- a/reactos/apps/utils/net/ping/ping.c
+++ b/reactos/apps/utils/net/ping/ping.c
@@ -331,7 +331,7 @@ BOOL Setup(VOID)
}
if (phe != NULL) {
- CopyMemory(&Target.sin_addr, phe->h_addr_list, phe->h_length);
+ CopyMemory(&Target.sin_addr, phe->h_addr, phe->h_length);
} else {
Target.sin_addr.s_addr = Addr;
}
@@ -391,19 +391,9 @@ VOID TimeToMsString(LPSTR String, LARGE_INTEGER Time)
LARGE_INTEGER LargeTime;
LargeTime.QuadPart = Time.QuadPart / TicksPerMs.QuadPart;
+
_i64toa(LargeTime.QuadPart, Convstr, 10);
strcpy(String, Convstr);
- strcat(String, ",");
-
- LargeTime.QuadPart = (Time.QuadPart % TicksPerMs.QuadPart) / TicksPerUs.QuadPart;
- _i64toa(LargeTime.QuadPart, Convstr, 10);
- Length = strlen(Convstr);
- if (Length < 4) {
- for (i = 0; i < 4 - Length; i++)
- strcat(String, "0");
- }
-
- strcat(String, Convstr);
strcat(String, "ms");
}
@@ -417,6 +407,7 @@ BOOL DecodeResponse(PCHAR buffer, UINT size, PSOCKADDR_IN from)
CHAR Time[100];
LARGE_INTEGER RelativeTime;
LARGE_INTEGER LargeTime;
+ CHAR Sign[1];
IpHeader = (PIPv4_HEADER)buffer;
@@ -449,10 +440,17 @@ BOOL DecodeResponse(PCHAR buffer, UINT size, PSOCKADDR_IN from)
RelativeTime.QuadPart = (LargeTime.QuadPart - Icmp->Timestamp.QuadPart);
- TimeToMsString(Time, RelativeTime);
+ if ((RelativeTime.QuadPart / TicksPerMs.QuadPart) < 1) {
+ strcpy(Sign, "<");
+ strcpy(Time, "1ms");
+ } else {
+ strcpy(Sign, "=");
+ TimeToMsString(Time, RelativeTime);
+ }
- printf("Reply from %s: bytes=%d time=%s TTL=%d\n", inet_ntoa(from->sin_addr),
- size - IphLength - sizeof(ICMP_ECHO_PACKET), Time, IpHeader->TTL);
+
+ printf("Reply from %s: bytes=%d time%s%s TTL=%d\n", inet_ntoa(from->sin_addr),
+ size - IphLength - sizeof(ICMP_ECHO_PACKET), Sign, Time, IpHeader->TTL);
if (RelativeTime.QuadPart < MinRTT.QuadPart) {
MinRTT.QuadPart = RelativeTime.QuadPart;
MinRTTSet = TRUE;
diff --git a/reactos/apps/utils/net/route/route.xml b/reactos/apps/utils/net/route/route.xml
new file mode 100644
index 00000000000..c1a435eb7e6
--- /dev/null
+++ b/reactos/apps/utils/net/route/route.xml
@@ -0,0 +1,8 @@
+
+ .
+ kernel32
+ ws2_32
+ iphlpapi
+ route.c
+ route.rc
+
diff --git a/reactos/apps/utils/net/tracert/ip.h b/reactos/apps/utils/net/tracert/ip.h
new file mode 100644
index 00000000000..6463b72dcc4
--- /dev/null
+++ b/reactos/apps/utils/net/tracert/ip.h
@@ -0,0 +1,195 @@
+/*
+ * Copyright (c) 1982, 1986, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)ip.h 8.2 (Berkeley) 6/1/94
+ * $FreeBSD: src/sys/netinet/ip.h,v 1.16 1999/08/28 00:49:19 peter Exp $
+ */
+
+#ifndef _NETINET_IP_H_
+#define _NETINET_IP_H_
+
+/*
+ * Definitions for internet protocol version 4.
+ * Per RFC 791, September 1981.
+ */
+#define IPVERSION 4
+
+/* A little magic to make the Windows build happy. */
+#if defined(_MSC_VER) || defined(__MINGW32__)
+#include
+#include
+#include
+
+typedef u_short n_short;
+typedef u_int n_long;
+typedef u_int n_time;
+
+#define EMSGSIZE WSAEMSGSIZE
+#define ENETUNREACH WSAENETUNREACH
+#define EHOSTUNREACH WSAEHOSTUNREACH
+#endif
+
+/*
+ * Structure of an internet header, naked of options.
+ */
+struct ip {
+#ifdef _IP_VHL
+ u_char ip_vhl; /* version << 4 | header length >> 2 */
+#else
+#if BYTE_ORDER == LITTLE_ENDIAN
+ u_int ip_hl:4, /* header length */
+ ip_v:4; /* version */
+#endif
+#if BYTE_ORDER == BIG_ENDIAN
+ u_int ip_v:4, /* version */
+ ip_hl:4; /* header length */
+#endif
+#endif /* not _IP_VHL */
+ u_char ip_tos; /* type of service */
+ u_short ip_len; /* total length */
+ u_short ip_id; /* identification */
+ u_short ip_off; /* fragment offset field */
+#define IP_RF 0x8000 /* reserved fragment flag */
+#define IP_DF 0x4000 /* don't fragment flag */
+#define IP_MF 0x2000 /* more fragments flag */
+#define IP_OFFMASK 0x1fff /* mask for fragmenting bits */
+ u_char ip_ttl; /* time to live */
+ u_char ip_p; /* protocol */
+ u_short ip_sum; /* checksum */
+ struct in_addr ip_src,ip_dst; /* source and dest address */
+};
+
+#ifdef _IP_VHL
+#define IP_MAKE_VHL(v, hl) ((v) << 4 | (hl))
+#define IP_VHL_HL(vhl) ((vhl) & 0x0f)
+#define IP_VHL_V(vhl) ((vhl) >> 4)
+#define IP_VHL_BORING 0x45
+#endif
+
+#define IP_MAXPACKET 65535 /* maximum packet size */
+
+/*
+ * Definitions for IP type of service (ip_tos)
+ */
+#define IPTOS_LOWDELAY 0x10
+#define IPTOS_THROUGHPUT 0x08
+#define IPTOS_RELIABILITY 0x04
+#define IPTOS_MINCOST 0x02
+
+/*
+ * Definitions for IP precedence (also in ip_tos) (hopefully unused)
+ */
+#define IPTOS_PREC_NETCONTROL 0xe0
+#define IPTOS_PREC_INTERNETCONTROL 0xc0
+#define IPTOS_PREC_CRITIC_ECP 0xa0
+#define IPTOS_PREC_FLASHOVERRIDE 0x80
+#define IPTOS_PREC_FLASH 0x60
+#define IPTOS_PREC_IMMEDIATE 0x40
+#define IPTOS_PREC_PRIORITY 0x20
+#define IPTOS_PREC_ROUTINE 0x00
+
+/*
+ * Definitions for options.
+ */
+#define IPOPT_COPIED(o) ((o)&0x80)
+#define IPOPT_CLASS(o) ((o)&0x60)
+#define IPOPT_NUMBER(o) ((o)&0x1f)
+
+#define IPOPT_CONTROL 0x00
+#define IPOPT_RESERVED1 0x20
+#define IPOPT_DEBMEAS 0x40
+#define IPOPT_RESERVED2 0x60
+
+#define IPOPT_EOL 0 /* end of option list */
+#define IPOPT_NOP 1 /* no operation */
+
+#define IPOPT_RR 7 /* record packet route */
+#define IPOPT_TS 68 /* timestamp */
+#define IPOPT_SECURITY 130 /* provide s,c,h,tcc */
+#define IPOPT_LSRR 131 /* loose source route */
+#define IPOPT_SATID 136 /* satnet id */
+#define IPOPT_SSRR 137 /* strict source route */
+#define IPOPT_RA 148 /* router alert */
+
+/*
+ * Offsets to fields in options other than EOL and NOP.
+ */
+#define IPOPT_OPTVAL 0 /* option ID */
+#define IPOPT_OLEN 1 /* option length */
+#define IPOPT_OFFSET 2 /* offset within option */
+#define IPOPT_MINOFF 4 /* min value of above */
+
+/*
+ * Time stamp option structure.
+ */
+struct ip_timestamp {
+ u_char ipt_code; /* IPOPT_TS */
+ u_char ipt_len; /* size of structure (variable) */
+ u_char ipt_ptr; /* index of current entry */
+#if BYTE_ORDER == LITTLE_ENDIAN
+ u_int ipt_flg:4, /* flags, see below */
+ ipt_oflw:4; /* overflow counter */
+#endif
+#if BYTE_ORDER == BIG_ENDIAN
+ u_int ipt_oflw:4, /* overflow counter */
+ ipt_flg:4; /* flags, see below */
+#endif
+ union ipt_timestamp {
+ n_long ipt_time[1];
+ struct ipt_ta {
+ struct in_addr ipt_addr;
+ n_long ipt_time;
+ } ipt_ta[1];
+ } ipt_timestamp;
+};
+
+/* flag bits for ipt_flg */
+#define IPOPT_TS_TSONLY 0 /* timestamps only */
+#define IPOPT_TS_TSANDADDR 1 /* timestamps and addresses */
+#define IPOPT_TS_PRESPEC 3 /* specified modules only */
+
+/* bits for security (not byte swapped) */
+#define IPOPT_SECUR_UNCLASS 0x0000
+#define IPOPT_SECUR_CONFID 0xf135
+#define IPOPT_SECUR_EFTO 0x789a
+#define IPOPT_SECUR_MMMM 0xbc4d
+#define IPOPT_SECUR_RESTR 0xaf13
+#define IPOPT_SECUR_SECRET 0xd788
+#define IPOPT_SECUR_TOPSECRET 0x6bc5
+
+/*
+ * Internet implementation parameters.
+ */
+#define MAXTTL 255 /* maximum time to live (seconds) */
+#define IPDEFTTL 64 /* default ttl, from RFC 1340 */
+#define IPFRAGTTL 60 /* time to live for frags, slowhz */
+#define IPTTLDEC 1 /* subtracted when forwarding */
+
+#define IP_MSS 576 /* default maximum segment size */
+
+#endif
diff --git a/reactos/apps/utils/net/tracert/ip_icmp.h b/reactos/apps/utils/net/tracert/ip_icmp.h
new file mode 100644
index 00000000000..2b3ee2eb280
--- /dev/null
+++ b/reactos/apps/utils/net/tracert/ip_icmp.h
@@ -0,0 +1,186 @@
+/*
+ * Copyright (c) 1982, 1986, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)ip_icmp.h 8.1 (Berkeley) 6/10/93
+ * $FreeBSD: src/sys/netinet/ip_icmp.h,v 1.13 1999/08/28 00:49:24 peter Exp $
+ */
+
+#ifndef _NETINET_IP_ICMP_H_
+#define _NETINET_IP_ICMP_H_
+
+/*
+ * Interface Control Message Protocol Definitions.
+ * Per RFC 792, September 1981.
+ */
+
+/*
+ * Internal of an ICMP Router Advertisement
+ */
+struct icmp_ra_addr {
+ u_int32_t ira_addr;
+ u_int32_t ira_preference;
+};
+
+/*
+ * Structure of an icmp header.
+ */
+struct icmp {
+ u_char icmp_type; /* type of message, see below */
+ u_char icmp_code; /* type sub code */
+ u_short icmp_cksum; /* ones complement cksum of struct */
+ union {
+ u_char ih_pptr; /* ICMP_PARAMPROB */
+ struct in_addr ih_gwaddr; /* ICMP_REDIRECT */
+ struct ih_idseq {
+ n_short icd_id;
+ n_short icd_seq;
+ } ih_idseq;
+ int ih_void;
+
+ /* ICMP_UNREACH_NEEDFRAG -- Path MTU Discovery (RFC1191) */
+ struct ih_pmtu {
+ n_short ipm_void;
+ n_short ipm_nextmtu;
+ } ih_pmtu;
+
+ struct ih_rtradv {
+ u_char irt_num_addrs;
+ u_char irt_wpa;
+ u_int16_t irt_lifetime;
+ } ih_rtradv;
+ } icmp_hun;
+#define icmp_pptr icmp_hun.ih_pptr
+#define icmp_gwaddr icmp_hun.ih_gwaddr
+#define icmp_id icmp_hun.ih_idseq.icd_id
+#define icmp_seq icmp_hun.ih_idseq.icd_seq
+#define icmp_void icmp_hun.ih_void
+#define icmp_pmvoid icmp_hun.ih_pmtu.ipm_void
+#define icmp_nextmtu icmp_hun.ih_pmtu.ipm_nextmtu
+#define icmp_num_addrs icmp_hun.ih_rtradv.irt_num_addrs
+#define icmp_wpa icmp_hun.ih_rtradv.irt_wpa
+#define icmp_lifetime icmp_hun.ih_rtradv.irt_lifetime
+ union {
+ struct id_ts {
+ n_time its_otime;
+ n_time its_rtime;
+ n_time its_ttime;
+ } id_ts;
+ struct id_ip {
+ struct ip idi_ip;
+ /* options and then 64 bits of data */
+ } id_ip;
+ struct icmp_ra_addr id_radv;
+ u_int32_t id_mask;
+ char id_data[1];
+ } icmp_dun;
+#define icmp_otime icmp_dun.id_ts.its_otime
+#define icmp_rtime icmp_dun.id_ts.its_rtime
+#define icmp_ttime icmp_dun.id_ts.its_ttime
+#define icmp_ip icmp_dun.id_ip.idi_ip
+#define icmp_radv icmp_dun.id_radv
+#define icmp_mask icmp_dun.id_mask
+#define icmp_data icmp_dun.id_data
+};
+
+/*
+ * Lower bounds on packet lengths for various types.
+ * For the error advice packets must first insure that the
+ * packet is large enough to contain the returned ip header.
+ * Only then can we do the check to see if 64 bits of packet
+ * data have been returned, since we need to check the returned
+ * ip header length.
+ */
+#define ICMP_MINLEN 8 /* abs minimum */
+#define ICMP_TSLEN (8 + 3 * sizeof (n_time)) /* timestamp */
+#define ICMP_MASKLEN 12 /* address mask */
+#define ICMP_ADVLENMIN (8 + sizeof (struct ip) + 8) /* min */
+#ifndef _IP_VHL
+#define ICMP_ADVLEN(p) (8 + ((p)->icmp_ip.ip_hl << 2) + 8)
+ /* N.B.: must separately check that ip_hl >= 5 */
+#else
+#define ICMP_ADVLEN(p) (8 + (IP_VHL_HL((p)->icmp_ip.ip_vhl) << 2) + 8)
+ /* N.B.: must separately check that header length >= 5 */
+#endif
+
+/*
+ * Definition of type and code field values.
+ */
+#define ICMP_ECHOREPLY 0 /* echo reply */
+#define ICMP_UNREACH 3 /* dest unreachable, codes: */
+#define ICMP_UNREACH_NET 0 /* bad net */
+#define ICMP_UNREACH_HOST 1 /* bad host */
+#define ICMP_UNREACH_PROTOCOL 2 /* bad protocol */
+#define ICMP_UNREACH_PORT 3 /* bad port */
+#define ICMP_UNREACH_NEEDFRAG 4 /* IP_DF caused drop */
+#define ICMP_UNREACH_SRCFAIL 5 /* src route failed */
+#define ICMP_UNREACH_NET_UNKNOWN 6 /* unknown net */
+#define ICMP_UNREACH_HOST_UNKNOWN 7 /* unknown host */
+#define ICMP_UNREACH_ISOLATED 8 /* src host isolated */
+#define ICMP_UNREACH_NET_PROHIB 9 /* prohibited access */
+#define ICMP_UNREACH_HOST_PROHIB 10 /* ditto */
+#define ICMP_UNREACH_TOSNET 11 /* bad tos for net */
+#define ICMP_UNREACH_TOSHOST 12 /* bad tos for host */
+#define ICMP_UNREACH_FILTER_PROHIB 13 /* admin prohib */
+#define ICMP_UNREACH_HOST_PRECEDENCE 14 /* host prec vio. */
+#define ICMP_UNREACH_PRECEDENCE_CUTOFF 15 /* prec cutoff */
+#define ICMP_SOURCEQUENCH 4 /* packet lost, slow down */
+#define ICMP_REDIRECT 5 /* shorter route, codes: */
+#define ICMP_REDIRECT_NET 0 /* for network */
+#define ICMP_REDIRECT_HOST 1 /* for host */
+#define ICMP_REDIRECT_TOSNET 2 /* for tos and net */
+#define ICMP_REDIRECT_TOSHOST 3 /* for tos and host */
+#define ICMP_ECHO 8 /* echo service */
+#define ICMP_ROUTERADVERT 9 /* router advertisement */
+#define ICMP_ROUTERSOLICIT 10 /* router solicitation */
+#define ICMP_TIMXCEED 11 /* time exceeded, code: */
+#define ICMP_TIMXCEED_INTRANS 0 /* ttl==0 in transit */
+#define ICMP_TIMXCEED_REASS 1 /* ttl==0 in reass */
+#define ICMP_PARAMPROB 12 /* ip header bad */
+#define ICMP_PARAMPROB_OPTABSENT 1 /* req. opt. absent */
+#define ICMP_TSTAMP 13 /* timestamp request */
+#define ICMP_TSTAMPREPLY 14 /* timestamp reply */
+#define ICMP_IREQ 15 /* information request */
+#define ICMP_IREQREPLY 16 /* information reply */
+#define ICMP_MASKREQ 17 /* address mask request */
+#define ICMP_MASKREPLY 18 /* address mask reply */
+
+#define ICMP_MAXTYPE 18
+
+#define ICMP_INFOTYPE(type) \
+ ((type) == ICMP_ECHOREPLY || (type) == ICMP_ECHO || \
+ (type) == ICMP_ROUTERADVERT || (type) == ICMP_ROUTERSOLICIT || \
+ (type) == ICMP_TSTAMP || (type) == ICMP_TSTAMPREPLY || \
+ (type) == ICMP_IREQ || (type) == ICMP_IREQREPLY || \
+ (type) == ICMP_MASKREQ || (type) == ICMP_MASKREPLY)
+
+#ifdef KERNEL
+void icmp_error __P((struct mbuf *, int, int, n_long, struct ifnet *));
+void icmp_input __P((struct mbuf *, int));
+#endif
+
+#endif
diff --git a/reactos/apps/utils/net/tracert/makefile b/reactos/apps/utils/net/tracert/makefile
new file mode 100644
index 00000000000..09c6c498f24
--- /dev/null
+++ b/reactos/apps/utils/net/tracert/makefile
@@ -0,0 +1,20 @@
+PATH_TO_TOP = ../../../..
+
+TARGET_TYPE = program
+
+TARGET_APPTYPE = console
+
+TARGET_NAME = tracert
+
+TARGET_INSTALLDIR = system32
+
+TARGET_SDKLIBS = ws2_32.a iphlpapi.a ntdll.a
+
+TARGET_OBJECTS = \
+$(TARGET_NAME).o
+
+TARGET_GCCLIBS =
+
+include $(PATH_TO_TOP)/rules.mak
+
+include $(TOOLS_PATH)/helper.mk
diff --git a/reactos/apps/utils/net/tracert/tracert.c b/reactos/apps/utils/net/tracert/tracert.c
new file mode 100644
index 00000000000..fb5297b1de0
--- /dev/null
+++ b/reactos/apps/utils/net/tracert/tracert.c
@@ -0,0 +1,957 @@
+/*-
+ * Copyright (c) 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Van Jacobson.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char copyright[] =
+"@(#) Copyright (c) 1990, 1993\n\
+ The Regents of the University of California. All rights reserved.\n";
+#endif /* not lint */
+
+#ifndef lint
+static char sccsid[] = "@(#)traceroute.c 8.1 (Berkeley) 6/6/93";
+#endif /* not lint */
+
+/*
+ * traceroute host - trace the route ip packets follow going to "host".
+ *
+ * Attempt to trace the route an ip packet would follow to some
+ * internet host. We find out intermediate hops by launching probe
+ * packets with a small ttl (time to live) then listening for an
+ * icmp "time exceeded" reply from a gateway. We start our probes
+ * with a ttl of one and increase by one until we get an icmp "port
+ * unreachable" (which means we got to "host") or hit a max (which
+ * defaults to 30 hops & can be changed with the -m flag). Three
+ * probes (change with -q flag) are sent at each ttl setting and a
+ * line is printed showing the ttl, address of the gateway and
+ * round trip time of each probe. If the probe answers come from
+ * different gateways, the address of each responding system will
+ * be printed. If there is no response within a 5 sec. timeout
+ * interval (changed with the -w flag), a "*" is printed for that
+ * probe.
+ *
+ * Probe packets are UDP format. We don't want the destination
+ * host to process them so the destination port is set to an
+ * unlikely value (if some clod on the destination is using that
+ * value, it can be changed with the -p flag).
+ *
+ * A sample use might be:
+ *
+ * [yak 71]% traceroute nis.nsf.net.
+ * traceroute to nis.nsf.net (35.1.1.48), 30 hops max, 56 byte packet
+ * 1 helios.ee.lbl.gov (128.3.112.1) 19 ms 19 ms 0 ms
+ * 2 lilac-dmc.Berkeley.EDU (128.32.216.1) 39 ms 39 ms 19 ms
+ * 3 lilac-dmc.Berkeley.EDU (128.32.216.1) 39 ms 39 ms 19 ms
+ * 4 ccngw-ner-cc.Berkeley.EDU (128.32.136.23) 39 ms 40 ms 39 ms
+ * 5 ccn-nerif22.Berkeley.EDU (128.32.168.22) 39 ms 39 ms 39 ms
+ * 6 128.32.197.4 (128.32.197.4) 40 ms 59 ms 59 ms
+ * 7 131.119.2.5 (131.119.2.5) 59 ms 59 ms 59 ms
+ * 8 129.140.70.13 (129.140.70.13) 99 ms 99 ms 80 ms
+ * 9 129.140.71.6 (129.140.71.6) 139 ms 239 ms 319 ms
+ * 10 129.140.81.7 (129.140.81.7) 220 ms 199 ms 199 ms
+ * 11 nic.merit.edu (35.1.1.48) 239 ms 239 ms 239 ms
+ *
+ * Note that lines 2 & 3 are the same. This is due to a buggy
+ * kernel on the 2nd hop system -- lbl-csam.arpa -- that forwards
+ * packets with a zero ttl.
+ *
+ * A more interesting example is:
+ *
+ * [yak 72]% traceroute allspice.lcs.mit.edu.
+ * traceroute to allspice.lcs.mit.edu (18.26.0.115), 30 hops max
+ * 1 helios.ee.lbl.gov (128.3.112.1) 0 ms 0 ms 0 ms
+ * 2 lilac-dmc.Berkeley.EDU (128.32.216.1) 19 ms 19 ms 19 ms
+ * 3 lilac-dmc.Berkeley.EDU (128.32.216.1) 39 ms 19 ms 19 ms
+ * 4 ccngw-ner-cc.Berkeley.EDU (128.32.136.23) 19 ms 39 ms 39 ms
+ * 5 ccn-nerif22.Berkeley.EDU (128.32.168.22) 20 ms 39 ms 39 ms
+ * 6 128.32.197.4 (128.32.197.4) 59 ms 119 ms 39 ms
+ * 7 131.119.2.5 (131.119.2.5) 59 ms 59 ms 39 ms
+ * 8 129.140.70.13 (129.140.70.13) 80 ms 79 ms 99 ms
+ * 9 129.140.71.6 (129.140.71.6) 139 ms 139 ms 159 ms
+ * 10 129.140.81.7 (129.140.81.7) 199 ms 180 ms 300 ms
+ * 11 129.140.72.17 (129.140.72.17) 300 ms 239 ms 239 ms
+ * 12 * * *
+ * 13 128.121.54.72 (128.121.54.72) 259 ms 499 ms 279 ms
+ * 14 * * *
+ * 15 * * *
+ * 16 * * *
+ * 17 * * *
+ * 18 ALLSPICE.LCS.MIT.EDU (18.26.0.115) 339 ms 279 ms 279 ms
+ *
+ * (I start to see why I'm having so much trouble with mail to
+ * MIT.) Note that the gateways 12, 14, 15, 16 & 17 hops away
+ * either don't send ICMP "time exceeded" messages or send them
+ * with a ttl too small to reach us. 14 - 17 are running the
+ * MIT C Gateway code that doesn't send "time exceeded"s. God
+ * only knows what's going on with 12.
+ *
+ * The silent gateway 12 in the above may be the result of a bug in
+ * the 4.[23]BSD network code (and its derivatives): 4.x (x <= 3)
+ * sends an unreachable message using whatever ttl remains in the
+ * original datagram. Since, for gateways, the remaining ttl is
+ * zero, the icmp "time exceeded" is guaranteed to not make it back
+ * to us. The behavior of this bug is slightly more interesting
+ * when it appears on the destination system:
+ *
+ * 1 helios.ee.lbl.gov (128.3.112.1) 0 ms 0 ms 0 ms
+ * 2 lilac-dmc.Berkeley.EDU (128.32.216.1) 39 ms 19 ms 39 ms
+ * 3 lilac-dmc.Berkeley.EDU (128.32.216.1) 19 ms 39 ms 19 ms
+ * 4 ccngw-ner-cc.Berkeley.EDU (128.32.136.23) 39 ms 40 ms 19 ms
+ * 5 ccn-nerif35.Berkeley.EDU (128.32.168.35) 39 ms 39 ms 39 ms
+ * 6 csgw.Berkeley.EDU (128.32.133.254) 39 ms 59 ms 39 ms
+ * 7 * * *
+ * 8 * * *
+ * 9 * * *
+ * 10 * * *
+ * 11 * * *
+ * 12 * * *
+ * 13 rip.Berkeley.EDU (128.32.131.22) 59 ms ! 39 ms ! 39 ms !
+ *
+ * Notice that there are 12 "gateways" (13 is the final
+ * destination) and exactly the last half of them are "missing".
+ * What's really happening is that rip (a Sun-3 running Sun OS3.5)
+ * is using the ttl from our arriving datagram as the ttl in its
+ * icmp reply. So, the reply will time out on the return path
+ * (with no notice sent to anyone since icmp's aren't sent for
+ * icmp's) until we probe with a ttl that's at least twice the path
+ * length. I.e., rip is really only 7 hops away. A reply that
+ * returns with a ttl of 1 is a clue this problem exists.
+ * Traceroute prints a "!" after the time if the ttl is <= 1.
+ * Since vendors ship a lot of obsolete (DEC's Ultrix, Sun 3.x) or
+ * non-standard (HPUX) software, expect to see this problem
+ * frequently and/or take care picking the target host of your
+ * probes.
+ *
+ * Other possible annotations after the time are !H, !N, !P (got a host,
+ * network or protocol unreachable, respectively), !S or !F (source
+ * route failed or fragmentation needed -- neither of these should
+ * ever occur and the associated gateway is busted if you see one). If
+ * almost all the probes result in some kind of unreachable, traceroute
+ * will give up and exit.
+ *
+ * Notes
+ * -----
+ * This program must be run by root or be setuid. (I suggest that
+ * you *don't* make it setuid -- casual use could result in a lot
+ * of unnecessary traffic on our poor, congested nets.)
+ *
+ * This program requires a kernel mod that does not appear in any
+ * system available from Berkeley: A raw ip socket using proto
+ * IPPROTO_RAW must interpret the data sent as an ip datagram (as
+ * opposed to data to be wrapped in a ip datagram). See the README
+ * file that came with the source to this program for a description
+ * of the mods I made to /sys/netinet/raw_ip.c. Your mileage may
+ * vary. But, again, ANY 4.x (x < 4) BSD KERNEL WILL HAVE TO BE
+ * MODIFIED TO RUN THIS PROGRAM.
+ *
+ * The udp port usage may appear bizarre (well, ok, it is bizarre).
+ * The problem is that an icmp message only contains 8 bytes of
+ * data from the original datagram. 8 bytes is the size of a udp
+ * header so, if we want to associate replies with the original
+ * datagram, the necessary information must be encoded into the
+ * udp header (the ip id could be used but there's no way to
+ * interlock with the kernel's assignment of ip id's and, anyway,
+ * it would have taken a lot more kernel hacking to allow this
+ * code to set the ip id). So, to allow two or more users to
+ * use traceroute simultaneously, we use this task's pid as the
+ * source port (the high bit is set to move the port number out
+ * of the "likely" range). To keep track of which probe is being
+ * replied to (so times and/or hop counts don't get confused by a
+ * reply that was delayed in transit), we increment the destination
+ * port number before each probe.
+ *
+ * Don't use this as a coding example. I was trying to find a
+ * routing problem and this code sort-of popped out after 48 hours
+ * without sleep. I was amazed it ever compiled, much less ran.
+ *
+ * I stole the idea for this program from Steve Deering. Since
+ * the first release, I've learned that had I attended the right
+ * IETF working group meetings, I also could have stolen it from Guy
+ * Almes or Matt Mathis. I don't know (or care) who came up with
+ * the idea first. I envy the originators' perspicacity and I'm
+ * glad they didn't keep the idea a secret.
+ *
+ * Tim Seaver, Ken Adelman and C. Philip Wood provided bug fixes and/or
+ * enhancements to the original distribution.
+ *
+ * I've hacked up a round-trip-route version of this that works by
+ * sending a loose-source-routed udp datagram through the destination
+ * back to yourself. Unfortunately, SO many gateways botch source
+ * routing, the thing is almost worthless. Maybe one day...
+ *
+ * -- Van Jacobson (van@helios.ee.lbl.gov)
+ * Tue Dec 20 03:50:13 PST 1988
+ */
+
+#define caddr_t void *
+
+#include
+#include
+#include
+#include
+#include
+
+#include
+
+
+#include
+#include
+#include
+
+//void print(buf, cc, from);
+char * inetname(struct in_addr);
+double deltaT(struct timeval *, struct timeval *);
+void usage();
+void send_probe(int, int);
+
+#define bzero( ptr, count ) memset( ptr, 0, count )
+#define bcopy(src,dest,len) memcpy(dest,src,len)
+
+// setlinebuf is equivalent to the setvbuf call below.
+inline int setlinebuf(FILE *stream)
+{
+ return setvbuf( stream, (char*)0, _IONBF, 0 );
+}
+
+#ifndef __GNUC__
+#define EPOCHFILETIME (116444736000000000i64)
+#else
+#define EPOCHFILETIME (116444736000000000LL)
+#endif
+
+struct timezone {
+ int tz_minuteswest; /* minutes W of Greenwich */
+ int tz_dsttime; /* type of dst correction */
+};
+
+int gettimeofday(struct timeval *tv, struct timezone *tz)
+{
+ FILETIME ft;
+ LARGE_INTEGER li;
+ __int64 t;
+ static int tzflag;
+
+ if (tv)
+ {
+ GetSystemTimeAsFileTime(&ft);
+ //li.LowPart = ft.dwLowDateTime;
+ //li.HighPart = ft.dwHighDateTime;
+ t = li.QuadPart; /* In 100-nanosecond intervals */
+ t -= EPOCHFILETIME; /* Offset to the Epoch time */
+ t /= 10; /* In microseconds */
+ tv->tv_sec = (long)(t / 1000000);
+ tv->tv_usec = (long)(t % 1000000);
+ }
+
+ if (tz)
+ {
+ if (!tzflag)
+ {
+ _tzset();
+ tzflag++;
+ }
+ tz->tz_minuteswest = _timezone / 60;
+ tz->tz_dsttime = _daylight;
+ }
+
+ return 0;
+}
+
+
+
+/* Set up endiannes macros for the ip and ip_icmp BSD headers */
+#ifndef BIG_ENDIAN
+#define BIG_ENDIAN 4321
+#endif
+#ifndef LITTLE_ENDIAN
+#define LITTLE_ENDIAN 1234
+#endif
+#ifndef BYTE_ORDER
+#ifdef WORDS_BIGENDIAN
+#define BYTE_ORDER BIG_ENDIAN
+#else
+#define BYTE_ORDER LITTLE_ENDIAN
+#endif
+#endif /* BYTE_ORDER */
+
+#define u_int16_t WORD
+#define u_int32_t DWORD
+
+/* These are BSD headers. We use these here because they are needed on
+ * libc5 Linux systems. On other platforms they are usually simply more
+ * complete than the native stuff, and cause less portability problems
+ * so we use them anyway.
+ */
+#include "ip.h"
+#include "ip_icmp.h"
+
+
+#define MAXPACKET 65535 /* max ip packet size */
+#ifndef MAXHOSTNAMELEN
+#define MAXHOSTNAMELEN 64
+#endif
+
+#ifndef FD_SET
+#define NFDBITS (8*sizeof(fd_set))
+#define FD_SETSIZE NFDBITS
+#define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
+#define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
+#define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
+#define FD_ZERO(p) bzero((char *)(p), sizeof(*(p)))
+#endif
+
+#define Fprintf (void)fprintf
+#define Sprintf (void)sprintf
+#define Printf (void)printf
+
+/*
+ * Define the UDP header
+ */
+typedef struct udphdr {
+ u_short uh_dport;
+ u_short uh_sport;
+ u_short uh_sum;
+ u_short uh_ulen;
+} udphdr;
+
+/*
+ * format of a (udp) probe packet.
+ */
+struct opacket {
+ struct ip ip;
+ udphdr udp;
+ u_char seq; /* sequence number of this packet */
+ u_char ttl; /* ttl packet left with */
+ struct timeval tv; /* time packet left */
+};
+
+u_char packet[512]; /* last inbound (icmp) packet */
+struct opacket *outpacket; /* last output (udp) packet */
+
+#if 0
+int wait_for_reply __P((int, struct sockaddr_in *));
+void send_probe __P((int, int));
+double deltaT __P((struct timeval *, struct timeval *));
+int packet_ok __P((u_char *, int, struct sockaddr_in *, int));
+//void print __P((u_char *, int, struct sockaddr_in *));
+void tvsub __P((struct timeval *, struct timeval *));
+char *inetname __P((struct in_addr));
+void usage __P(());
+#endif
+
+int s; /* receive (icmp) socket file descriptor */
+int sndsock; /* send (udp) socket file descriptor */
+struct timezone tz; /* leftover */
+
+struct sockaddr whereto; /* Who to try to reach */
+int datalen; /* How much data */
+
+char *source = 0;
+char *hostname;
+
+int nprobes = 3;
+int max_ttl = 30;
+u_short ident;
+u_short port = 32768+666; /* start udp dest port # for probe packets */
+int options; /* socket options */
+int verbose;
+int waittime = 5; /* time to wait for response (in seconds) */
+int nflag; /* print addresses numerically */
+
+void
+print(buf, cc, from)
+ u_char *buf;
+ int cc;
+ struct sockaddr_in *from;
+{
+ struct ip *ip;
+ int hlen;
+
+ ip = (struct ip *) buf;
+ hlen = ip->ip_hl << 2;
+ cc -= hlen;
+
+ if (nflag)
+ Printf(" %s", inet_ntoa(from->sin_addr));
+ else
+ Printf(" %s (%s)", inetname(from->sin_addr),
+ inet_ntoa(from->sin_addr));
+
+ if (verbose)
+ Printf (" %d bytes to %s", cc, inet_ntoa (ip->ip_dst));
+}
+
+
+int
+main(argc, argv)
+ int argc;
+ char *argv[];
+{
+ extern char *optarg;
+ extern int optind;
+ struct hostent *hp;
+ struct protoent *pe;
+ struct sockaddr_in from, *to;
+ int ch, i, on, probe, seq, tos, ttl;
+ WSADATA wsadata;
+ INT status;
+
+ on = 1;
+ seq = tos = 0;
+ to = (struct sockaddr_in *)&whereto;
+ while ((ch = getopt(argc, argv, "dm:np:q:rs:t:w:v")) != EOF)
+ switch(ch) {
+ case 'd':
+ options |= SO_DEBUG;
+ break;
+ case 'm':
+ max_ttl = atoi(optarg);
+ if (max_ttl <= 1) {
+ Fprintf(stderr,
+ "traceroute: max ttl must be >1.\n");
+ WSACleanup();
+ exit(1);
+ }
+ break;
+ case 'n':
+ nflag++;
+ break;
+ case 'p':
+ port = atoi(optarg);
+ if (port < 1) {
+ Fprintf(stderr,
+ "traceroute: port must be >0.\n");
+ WSACleanup();
+ exit(1);
+ }
+ break;
+ case 'q':
+ nprobes = atoi(optarg);
+ if (nprobes < 1) {
+ Fprintf(stderr,
+ "traceroute: nprobes must be >0.\n");
+ WSACleanup();
+ exit(1);
+ }
+ break;
+ case 'r':
+ options |= SO_DONTROUTE;
+ break;
+ case 's':
+ /*
+ * set the ip source address of the outbound
+ * probe (e.g., on a multi-homed host).
+ */
+ source = optarg;
+ break;
+ case 't':
+ tos = atoi(optarg);
+ if (tos < 0 || tos > 255) {
+ Fprintf(stderr,
+ "traceroute: tos must be 0 to 255.\n");
+ WSACleanup();
+ exit(1);
+ }
+ break;
+ case 'v':
+ verbose++;
+ break;
+ case 'w':
+ waittime = atoi(optarg);
+ if (waittime <= 1) {
+ Fprintf(stderr,
+ "traceroute: wait must be >1 sec.\n");
+ WSACleanup();
+ exit(1);
+ }
+ break;
+ default:
+ usage();
+ }
+ argc -= optind;
+ argv += optind;
+
+ if (argc < 1)
+ usage();
+
+ status = WSAStartup(MAKEWORD(2, 2), &wsadata);
+ if (status != 0) {
+ printf("Could not initialize winsock dll.\n");
+ return FALSE;
+ }
+
+ setlinebuf (stdout);
+
+ (void) bzero((char *)&whereto, sizeof(struct sockaddr));
+ to->sin_family = AF_INET;
+ to->sin_addr.s_addr = inet_addr(*argv);
+ if (to->sin_addr.s_addr != -1)
+ hostname = *argv;
+ else {
+ hp = gethostbyname(*argv);
+ if (hp) {
+ to->sin_family = hp->h_addrtype;
+ bcopy(hp->h_addr, (caddr_t)&to->sin_addr, hp->h_length);
+ hostname = hp->h_name;
+ } else {
+ (void)fprintf(stderr,
+ "traceroute: unknown host %s\n", *argv);
+ WSACleanup();
+ exit(1);
+ }
+ }
+ if (*++argv)
+ datalen = atoi(*argv);
+ if (datalen < 0 || datalen >= MAXPACKET - sizeof(struct opacket)) {
+ Fprintf(stderr,
+ "traceroute: packet size must be 0 <= s < %ld.\n",
+ MAXPACKET - sizeof(struct opacket));
+ WSACleanup();
+ exit(1);
+ }
+ datalen += sizeof(struct opacket);
+ outpacket = (struct opacket *)malloc((unsigned)datalen);
+ if (! outpacket) {
+ perror("traceroute: malloc");
+ WSACleanup();
+ exit(1);
+ }
+ (void) bzero((char *)outpacket, datalen);
+ outpacket->ip.ip_dst = to->sin_addr;
+ outpacket->ip.ip_tos = tos;
+ outpacket->ip.ip_v = IPVERSION;
+ outpacket->ip.ip_id = 0;
+
+ ident = (getpid() & 0xffff) | 0x8000;
+
+ if ((pe = getprotobyname("icmp")) == NULL) {
+ Fprintf(stderr, "icmp: unknown protocol\n");
+ WSACleanup();
+ exit(10);
+ }
+ if ((s = socket(AF_INET, SOCK_RAW, pe->p_proto)) < 0) {
+ perror("traceroute: icmp socket");
+ WSACleanup();
+ exit(5);
+ }
+ if (options & SO_DEBUG)
+ (void) setsockopt(s, SOL_SOCKET, SO_DEBUG,
+ (char *)&on, sizeof(on));
+ if (options & SO_DONTROUTE)
+ (void) setsockopt(s, SOL_SOCKET, SO_DONTROUTE,
+ (char *)&on, sizeof(on));
+
+ if ((sndsock = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0) {
+ perror("traceroute: raw socket");
+ WSACleanup();
+ exit(5);
+ }
+#ifdef SO_SNDBUF
+ if (setsockopt(sndsock, SOL_SOCKET, SO_SNDBUF, (char *)&datalen,
+ sizeof(datalen)) < 0) {
+ perror("traceroute: SO_SNDBUF");
+ WSACleanup();
+ exit(6);
+ }
+#endif /* SO_SNDBUF */
+#ifdef IP_HDRINCL
+ if (setsockopt(sndsock, IPPROTO_IP, IP_HDRINCL, (char *)&on,
+ sizeof(on)) < 0) {
+ perror("traceroute: IP_HDRINCL");
+ WSACleanup();
+ exit(6);
+ }
+#endif /* IP_HDRINCL */
+ if (options & SO_DEBUG)
+ (void) setsockopt(sndsock, SOL_SOCKET, SO_DEBUG,
+ (char *)&on, sizeof(on));
+ if (options & SO_DONTROUTE)
+ (void) setsockopt(sndsock, SOL_SOCKET, SO_DONTROUTE,
+ (char *)&on, sizeof(on));
+
+ if (source) {
+ (void) bzero((char *)&from, sizeof(struct sockaddr));
+ from.sin_family = AF_INET;
+ from.sin_addr.s_addr = inet_addr(source);
+ if (from.sin_addr.s_addr == -1) {
+ Printf("traceroute: unknown host %s\n", source);
+ WSACleanup();
+ exit(1);
+ }
+ outpacket->ip.ip_src = from.sin_addr;
+#ifndef IP_HDRINCL
+ if (bind(sndsock, (struct sockaddr *)&from, sizeof(from)) < 0) {
+ perror ("traceroute: bind:");
+ WSACleanup();
+ exit (1);
+ }
+#endif /* IP_HDRINCL */
+ }
+
+ Fprintf(stderr, "traceroute to %s (%s)", hostname,
+ inet_ntoa(to->sin_addr));
+ if (source)
+ Fprintf(stderr, " from %s", source);
+ Fprintf(stderr, ", %d hops max, %d byte packets\n", max_ttl, datalen);
+ (void) fflush(stderr);
+
+ for (ttl = 1; ttl <= max_ttl; ++ttl) {
+ u_long lastaddr = 0;
+ int got_there = 0;
+ int unreachable = 0;
+
+ Printf("%2d ", ttl);
+ for (probe = 0; probe < nprobes; ++probe) {
+ int cc;
+ struct timeval t1, t2;
+ struct timezone tz;
+ struct ip *ip;
+
+ (void) gettimeofday(&t1, &tz);
+ send_probe(++seq, ttl);
+ while (cc = wait_for_reply(s, &from)) {
+ (void) gettimeofday(&t2, &tz);
+ if ((i = packet_ok(packet, cc, &from, seq))) {
+ if (from.sin_addr.s_addr != lastaddr) {
+ print(packet, cc, &from);
+ lastaddr = from.sin_addr.s_addr;
+ }
+ Printf(" %g ms", deltaT(&t1, &t2));
+ switch(i - 1) {
+ case ICMP_UNREACH_PORT:
+#ifndef ARCHAIC
+ ip = (struct ip *)packet;
+ if (ip->ip_ttl <= 1)
+ Printf(" !");
+#endif /* ARCHAIC */
+ ++got_there;
+ break;
+ case ICMP_UNREACH_NET:
+ ++unreachable;
+ Printf(" !N");
+ break;
+ case ICMP_UNREACH_HOST:
+ ++unreachable;
+ Printf(" !H");
+ break;
+ case ICMP_UNREACH_PROTOCOL:
+ ++got_there;
+ Printf(" !P");
+ break;
+ case ICMP_UNREACH_NEEDFRAG:
+ ++unreachable;
+ Printf(" !F");
+ break;
+ case ICMP_UNREACH_SRCFAIL:
+ ++unreachable;
+ Printf(" !S");
+ break;
+ }
+ break;
+ }
+ }
+ if (cc == 0)
+ Printf(" *");
+ (void) fflush(stdout);
+ }
+ putchar('\n');
+ if (got_there || unreachable >= nprobes-1) {
+ WSACleanup();
+ exit(0);
+ }
+ }
+
+ WSACleanup();
+ return 0;
+}
+
+int
+wait_for_reply(sock, from)
+ int sock;
+ struct sockaddr_in *from;
+{
+ fd_set fds;
+ struct timeval wait;
+ int cc = 0;
+ int fromlen = sizeof (*from);
+
+ FD_ZERO(&fds);
+ FD_SET(sock, &fds);
+ wait.tv_sec = waittime; wait.tv_usec = 0;
+
+ if (select(sock+1, &fds, (fd_set *)0, (fd_set *)0, &wait) > 0)
+ cc=recvfrom(s, (char *)packet, sizeof(packet), 0,
+ (struct sockaddr *)from, &fromlen);
+
+ return(cc);
+}
+
+
+void
+send_probe(seq, ttl)
+ int seq, ttl;
+{
+ struct opacket *op = outpacket;
+ struct ip *ip = &op->ip;
+ struct udphdr *up = &op->udp;
+ int i;
+
+ ip->ip_off = 0;
+ ip->ip_hl = sizeof(*ip) >> 2;
+ ip->ip_p = IPPROTO_UDP;
+ ip->ip_len = datalen;
+ ip->ip_ttl = ttl;
+ ip->ip_v = IPVERSION;
+ ip->ip_id = htons(ident+seq);
+
+ up->uh_sport = htons(ident);
+ up->uh_dport = htons(port+seq);
+ up->uh_ulen = htons((u_short)(datalen - sizeof(struct ip)));
+ up->uh_sum = 0;
+
+ op->seq = seq;
+ op->ttl = ttl;
+ (void) gettimeofday(&op->tv, &tz);
+
+ i = sendto(sndsock, (char *)outpacket, datalen, 0, &whereto,
+ sizeof(struct sockaddr));
+ if (i < 0 || i != datalen) {
+ if (i<0)
+ perror("sendto");
+ Printf("traceroute: wrote %s %d chars, ret=%d\n", hostname,
+ datalen, i);
+ (void) fflush(stdout);
+ }
+}
+
+
+double
+deltaT(t1p, t2p)
+ struct timeval *t1p, *t2p;
+{
+ register double dt;
+
+ dt = (double)(t2p->tv_sec - t1p->tv_sec) * 1000.0 +
+ (double)(t2p->tv_usec - t1p->tv_usec) / 1000.0;
+ return (dt);
+}
+
+
+/*
+ * Convert an ICMP "type" field to a printable string.
+ */
+char *
+pr_type(t)
+ u_char t;
+{
+ static char *ttab[] = {
+ "Echo Reply", "ICMP 1", "ICMP 2", "Dest Unreachable",
+ "Source Quench", "Redirect", "ICMP 6", "ICMP 7",
+ "Echo", "ICMP 9", "ICMP 10", "Time Exceeded",
+ "Param Problem", "Timestamp", "Timestamp Reply", "Info Request",
+ "Info Reply"
+ };
+
+ if(t > 16)
+ return("OUT-OF-RANGE");
+
+ return(ttab[t]);
+}
+
+
+int
+packet_ok(buf, cc, from, seq)
+ u_char *buf;
+ int cc;
+ struct sockaddr_in *from;
+ int seq;
+{
+ register struct icmp *icp;
+ u_char type, code;
+ int hlen;
+#ifndef ARCHAIC
+ struct ip *ip;
+
+ ip = (struct ip *) buf;
+ hlen = ip->ip_hl << 2;
+ if (cc < hlen + ICMP_MINLEN) {
+ if (verbose)
+ Printf("packet too short (%d bytes) from %s\n", cc,
+ inet_ntoa(from->sin_addr));
+ return (0);
+ }
+ cc -= hlen;
+ icp = (struct icmp *)(buf + hlen);
+#else
+ icp = (struct icmp *)buf;
+#endif /* ARCHAIC */
+ type = icp->icmp_type; code = icp->icmp_code;
+ if ((type == ICMP_TIMXCEED && code == ICMP_TIMXCEED_INTRANS) ||
+ type == ICMP_UNREACH) {
+ struct ip *hip;
+ struct udphdr *up;
+
+ hip = &icp->icmp_ip;
+ hlen = hip->ip_hl << 2;
+ up = (struct udphdr *)((u_char *)hip + hlen);
+ if (hlen + 12 <= cc && hip->ip_p == IPPROTO_UDP &&
+ up->uh_sport == htons(ident) &&
+ up->uh_dport == htons(port+seq))
+ if (hlen + 12 <= cc && hip->ip_p == IPPROTO_UDP)
+ return (type == ICMP_TIMXCEED? -1 : code+1);
+ }
+#ifndef ARCHAIC
+ if (verbose) {
+ int i;
+ u_long *lp = (u_long *)&icp->icmp_ip;
+
+ Printf("\n%d bytes from %s to %s", cc,
+ inet_ntoa(from->sin_addr), inet_ntoa(ip->ip_dst));
+ Printf(": icmp type %d (%s) code %d\n", type, pr_type(type),
+ icp->icmp_code);
+ for (i = 4; i < cc ; i += sizeof(long))
+ Printf("%2d: x%8.8lx\n", i, *lp++);
+ }
+#endif /* ARCHAIC */
+ return(0);
+}
+
+#ifdef notyet
+/*
+ * Checksum routine for Internet Protocol family headers (C Version)
+ */
+u_short
+in_cksum(addr, len)
+ u_short *addr;
+ int len;
+{
+ register int nleft = len;
+ register u_short *w = addr;
+ register u_short answer;
+ register int sum = 0;
+
+ /*
+ * Our algorithm is simple, using a 32 bit accumulator (sum),
+ * we add sequential 16 bit words to it, and at the end, fold
+ * back all the carry bits from the top 16 bits into the lower
+ * 16 bits.
+ */
+ while (nleft > 1) {
+ sum += *w++;
+ nleft -= 2;
+ }
+
+ /* mop up an odd byte, if necessary */
+ if (nleft == 1)
+ sum += *(u_char *)w;
+
+ /*
+ * add back carry outs from top 16 bits to low 16 bits
+ */
+ sum = (sum >> 16) + (sum & 0xffff); /* add hi 16 to low 16 */
+ sum += (sum >> 16); /* add carry */
+ answer = ~sum; /* truncate to 16 bits */
+ return (answer);
+}
+#endif /* notyet */
+
+/*
+ * Subtract 2 timeval structs: out = out - in.
+ * Out is assumed to be >= in.
+ */
+void
+tvsub(out, in)
+ register struct timeval *out, *in;
+{
+ if ((out->tv_usec -= in->tv_usec) < 0) {
+ out->tv_sec--;
+ out->tv_usec += 1000000;
+ }
+ out->tv_sec -= in->tv_sec;
+}
+
+
+/*
+ * Construct an Internet address representation.
+ * If the nflag has been supplied, give
+ * numeric value, otherwise try for symbolic name.
+ */
+char *
+inetname(in)
+ struct in_addr in;
+{
+ register char *cp;
+ static char line[50];
+ struct hostent *hp;
+ static char domain[MAXHOSTNAMELEN + 1];
+ static int first = 1;
+
+ if (first && !nflag) {
+ first = 0;
+ if (gethostname(domain, MAXHOSTNAMELEN) == 0 &&
+ (cp = strrchr(domain, '.')))
+ (void) strcpy(domain, cp + 1);
+ else
+ domain[0] = 0;
+ }
+ cp = 0;
+ if (!nflag && in.s_addr != INADDR_ANY) {
+ hp = gethostbyaddr((char *)&in, sizeof (in), AF_INET);
+ if (hp) {
+ if ((cp = strrchr(hp->h_name, '.')) &&
+ !strcmp(cp + 1, domain))
+ *cp = 0;
+ cp = hp->h_name;
+ }
+ }
+ if (cp)
+ (void) strcpy(line, cp);
+ else {
+ in.s_addr = ntohl(in.s_addr);
+#define C(x) ((x) & 0xff)
+ Sprintf(line, "%lu.%lu.%lu.%lu", C(in.s_addr >> 24),
+ C(in.s_addr >> 16), C(in.s_addr >> 8), C(in.s_addr));
+ }
+ return (line);
+}
+
+void
+usage()
+{
+ (void)fprintf(stderr,
+"usage: traceroute [-dnrv] [-m max_ttl] [-p port#] [-q nqueries]\n\t\
+[-s src_addr] [-t tos] [-w wait] host [data size]\n");
+ exit(1);
+}
diff --git a/reactos/apps/utils/net/tracert/tracert.rc b/reactos/apps/utils/net/tracert/tracert.rc
new file mode 100644
index 00000000000..f1351caf1a0
--- /dev/null
+++ b/reactos/apps/utils/net/tracert/tracert.rc
@@ -0,0 +1,6 @@
+/* $Id: route.rc 11816 2004-11-26 06:51:47Z arty $ */
+
+#define REACTOS_STR_FILE_DESCRIPTION "ReactOS TCP/IPv4 Traceroute\0"
+#define REACTOS_STR_INTERNAL_NAME "tracert\0"
+#define REACTOS_STR_ORIGINAL_FILENAME "tracert.exe\0"
+#include
diff --git a/reactos/apps/utils/net/whois/whois.rc b/reactos/apps/utils/net/whois/whois.rc
index 3346e8e9ca1..e706ac8d0d8 100644
--- a/reactos/apps/utils/net/whois/whois.rc
+++ b/reactos/apps/utils/net/whois/whois.rc
@@ -3,5 +3,4 @@
#define REACTOS_STR_FILE_DESCRIPTION "ReactOS TCP/IPv4 Win32 Whois\0"
#define REACTOS_STR_INTERNAL_NAME "whois\0"
#define REACTOS_STR_ORIGINAL_FILENAME "whois.exe\0"
-#define REACTOS_STR_ORIGINAL_COPYRIGHT "Steven Edwards (Isolation@users.sourceforge.net)\0"
#include
diff --git a/reactos/apps/utils/objdir/objdir.c b/reactos/apps/utils/objdir/objdir.c
index 15e63ad4cb2..82516fdb309 100644
--- a/reactos/apps/utils/objdir/objdir.c
+++ b/reactos/apps/utils/objdir/objdir.c
@@ -79,10 +79,14 @@ StatusToName (NTSTATUS Status)
return "STATUS_PATH_SYNTAX_BAD";
case STATUS_NO_MORE_ENTRIES:
return "STATUS_NO_MORE_ENTRIES";
+ case STATUS_MORE_ENTRIES:
+ return "STATUS_MORE_ENTRIES";
case STATUS_ACCESS_DENIED:
return "STATUS_ACCESS_DENIED";
case STATUS_UNSUCCESSFUL:
return "STATUS_UNSUCCESSFUL";
+ case STATUS_INVALID_HANDLE:
+ return "STATUS_INVALID_HANDLE";
}
sprintf (RawValue, "0x%08lx", Status);
return (const char *) RawValue;
@@ -173,8 +177,9 @@ ListDirectory (
OBJECT_ATTRIBUTES ObjectAttributes;
NTSTATUS Status;
HANDLE DirectoryHandle;
- BYTE DirectoryEntry [MAX_DIR_ENTRY * sizeof(DIRECTORY_BASIC_INFORMATION)];
- PDIRECTORY_BASIC_INFORMATION pDirectoryEntry = (PDIRECTORY_BASIC_INFORMATION) DirectoryEntry;
+ BYTE DirectoryEntry [512];
+ POBJECT_DIRECTORY_INFORMATION pDirectoryEntry = (POBJECT_DIRECTORY_INFORMATION) DirectoryEntry;
+ POBJECT_DIRECTORY_INFORMATION pDirectoryEntries = (POBJECT_DIRECTORY_INFORMATION) DirectoryEntry;
ULONG Context = 0;
ULONG ReturnLength = 0;
ULONG EntryCount = 0;
@@ -217,25 +222,23 @@ ListDirectory (
return (FALSE);
}
printf ("\n Directory of %s\n\n", DirectoryNameA);
+
+ for(;;)
+ {
/*
* Enumerate each item in the directory.
*/
Status = NtQueryDirectoryObject (
DirectoryHandle,
- pDirectoryEntry,
+ pDirectoryEntries,
sizeof DirectoryEntry,
FALSE,/* ReturnSingleEntry */
- TRUE, /* RestartScan */
+ FALSE, /* RestartScan */
& Context,
& ReturnLength
);
- if (!NT_SUCCESS(Status))
+ if (!NT_SUCCESS(Status) && Status != STATUS_NO_MORE_ENTRIES)
{
- if (STATUS_NO_MORE_ENTRIES == Status)
- {
- NtClose (DirectoryHandle);
- return TRUE;
- }
printf (
"Failed to query directory object (Status: %s)\n",
StatusToName (Status)
@@ -243,12 +246,17 @@ ListDirectory (
NtClose (DirectoryHandle);
return (FALSE);
}
- while (0 != pDirectoryEntry->ObjectTypeName.Length)
+ if (Status == STATUS_NO_MORE_ENTRIES)
+ {
+ break;
+ }
+ pDirectoryEntry = pDirectoryEntries;
+ while (EntryCount < Context)
{
CHAR ObjectNameA [MAX_PATH];
CHAR TypeNameA [MAX_PATH];
CHAR TargetNameA [MAX_PATH];
-
+
if (0 == wcscmp (L"SymbolicLink", pDirectoryEntry->ObjectTypeName.Buffer))
{
if (TRUE == ExpandSymbolicLink (
@@ -258,7 +266,7 @@ ListDirectory (
)
)
{
-
+
printf (
"%-16s %s -> %s\n",
RawUszAsz (pDirectoryEntry->ObjectTypeName.Buffer, TypeNameA),
@@ -283,9 +291,10 @@ ListDirectory (
RawUszAsz (pDirectoryEntry->ObjectName.Buffer, ObjectNameA)
);
}
- ++ EntryCount;
++ pDirectoryEntry;
+ ++ EntryCount;
}
+ };
printf ("\n\t%lu object(s)\n", EntryCount);
/*
* Free any resource.
@@ -296,7 +305,7 @@ ListDirectory (
*/
if (FALSE != Recurse)
{
- pDirectoryEntry = (PDIRECTORY_BASIC_INFORMATION) DirectoryEntry;
+ pDirectoryEntry = (POBJECT_DIRECTORY_INFORMATION) DirectoryEntry;
while (0 != pDirectoryEntry->ObjectTypeName.Length)
{
if (0 == wcscmp (L"Directory", pDirectoryEntry->ObjectTypeName.Buffer))
diff --git a/reactos/apps/utils/rosperf/Makefile b/reactos/apps/utils/rosperf/Makefile
new file mode 100644
index 00000000000..d14bdf4227a
--- /dev/null
+++ b/reactos/apps/utils/rosperf/Makefile
@@ -0,0 +1,24 @@
+PATH_TO_TOP = ../../..
+
+TARGET_TYPE = program
+
+TARGET_APPTYPE = console
+
+TARGET_NAME = rosperf
+
+TARGET_SDKLIBS = version.a gdi32.a user32.a kernel32.a ntdll.a
+
+TARGET_OBJECTS = rosperf.o testlist.o fill.o lines.o
+
+TARGET_CFLAGS = -Wall -Werror -D__USE_W32API
+
+include $(PATH_TO_TOP)/rules.mak
+
+include $(TOOLS_PATH)/helper.mk
+
+# Automatic dependency tracking
+DEP_OBJECTS := $(TARGET_OBJECTS)
+
+include $(PATH_TO_TOP)/tools/depend.mk
+
+# EOF
diff --git a/reactos/apps/utils/rosperf/fill.c b/reactos/apps/utils/rosperf/fill.c
new file mode 100644
index 00000000000..422be8d982e
--- /dev/null
+++ b/reactos/apps/utils/rosperf/fill.c
@@ -0,0 +1,60 @@
+/*
+ * ReactOS RosPerf - ReactOS GUI performance test program
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include
+#include "rosperf.h"
+
+void
+FillProc(void *Context, PPERF_INFO PerfInfo, unsigned Reps)
+{
+ unsigned Rep;
+
+ for (Rep = 0; Rep < Reps; Rep++)
+ {
+ PatBlt((Rep & 0x100) ? PerfInfo->BackgroundDc : PerfInfo->ForegroundDc, 0, 0,
+ PerfInfo->WndWidth, PerfInfo->WndHeight, PATCOPY);
+ }
+}
+
+void
+FillSmallProc(void *Context, PPERF_INFO PerfInfo, unsigned Reps)
+{
+#define SMALL_SIZE 16
+ unsigned Rep;
+ unsigned x, y;
+
+ x = 0;
+ y = 0;
+
+ for (Rep = 0; Rep < Reps; Rep++)
+ {
+ PatBlt((Rep & 0x10000) ? PerfInfo->BackgroundDc : PerfInfo->ForegroundDc, x, y,
+ SMALL_SIZE, SMALL_SIZE, PATCOPY);
+ x += SMALL_SIZE + 1;
+ if (PerfInfo->WndWidth < x + SMALL_SIZE)
+ {
+ x = 0;
+ y += SMALL_SIZE + 1;
+ if (PerfInfo->WndHeight < y + SMALL_SIZE)
+ {
+ y = 0;
+ }
+ }
+ }
+}
+/* EOF */
diff --git a/reactos/apps/utils/rosperf/lines.c b/reactos/apps/utils/rosperf/lines.c
new file mode 100644
index 00000000000..14824c950ab
--- /dev/null
+++ b/reactos/apps/utils/rosperf/lines.c
@@ -0,0 +1,97 @@
+/*
+ * ReactOS RosPerf - ReactOS GUI performance test program
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include
+#include "rosperf.h"
+
+void
+LinesProc(void *Context, PPERF_INFO PerfInfo, unsigned Reps)
+{
+ unsigned Rep;
+ int Dest;
+ HDC Dc;
+
+ for (Rep = 0; Rep < Reps; )
+ {
+ Dc = (Rep & 0x1000) ? PerfInfo->BackgroundDc : PerfInfo->ForegroundDc;
+
+ for (Dest = 2; Dest < PerfInfo->WndHeight && Rep < Reps; Rep++, Dest += 2)
+ {
+ MoveToEx(Dc, 0, 0, NULL);
+ LineTo(Dc, PerfInfo->WndWidth, Dest);
+ }
+
+ for (Dest = PerfInfo->WndWidth - 2; 0 <= Dest && Rep < Reps; Rep++, Dest -= 2)
+ {
+ MoveToEx(Dc, PerfInfo->WndWidth, 0, NULL);
+ LineTo(Dc, Dest, PerfInfo->WndHeight);
+ }
+
+ for (Dest = PerfInfo->WndHeight - 2; 0 <= Dest && Rep < Reps; Rep++, Dest -= 2)
+ {
+ MoveToEx(Dc, PerfInfo->WndWidth, PerfInfo->WndHeight, NULL);
+ LineTo(Dc, 0, Dest);
+ }
+
+ for (Dest = 2; Dest < PerfInfo->WndWidth && Rep < Reps; Rep++, Dest += 2)
+ {
+ MoveToEx(Dc, 0, PerfInfo->WndHeight, NULL);
+ LineTo(Dc, Dest, 0);
+ }
+ }
+}
+
+void
+LinesHorizontalProc(void *Context, PPERF_INFO PerfInfo, unsigned Reps)
+{
+ unsigned Rep;
+ unsigned y;
+ HDC Dc;
+
+ for (Rep = 0; Rep < Reps; )
+ {
+ Dc = (Rep & 0x10000) ? PerfInfo->BackgroundDc : PerfInfo->ForegroundDc;
+
+ for (y = 0; y < PerfInfo->WndHeight && Rep < Reps; Rep++, y += 3)
+ {
+ MoveToEx(Dc, 0, y, NULL);
+ LineTo(Dc, PerfInfo->WndWidth, y);
+ }
+ }
+}
+
+void
+LinesVerticalProc(void *Context, PPERF_INFO PerfInfo, unsigned Reps)
+{
+ unsigned Rep;
+ unsigned x;
+ HDC Dc;
+
+ for (Rep = 0; Rep < Reps; )
+ {
+ Dc = (Rep & 0x1000) ? PerfInfo->BackgroundDc : PerfInfo->ForegroundDc;
+
+ for (x = 0; x < PerfInfo->WndWidth && Rep < Reps; Rep++, x += 3)
+ {
+ MoveToEx(Dc, x, 0, NULL);
+ LineTo(Dc, x, PerfInfo->WndHeight);
+ }
+ }
+}
+
+/* EOF */
diff --git a/reactos/apps/utils/rosperf/rosperf.c b/reactos/apps/utils/rosperf/rosperf.c
new file mode 100644
index 00000000000..de47d6bec84
--- /dev/null
+++ b/reactos/apps/utils/rosperf/rosperf.c
@@ -0,0 +1,923 @@
+/*
+ * ReactOS RosPerf - ReactOS GUI performance test program
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+/*
+ * Ideas copied from x11perf:
+ *
+ * Copyright 1988, 1989 by Digital Equipment Corporation, Maynard, Massachusetts.
+ *
+ * All Rights Reserved
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of Digital not be
+ * used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission.
+ *
+ * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+
+#include
+#include
+#include
+#include
+#include
+
+#include "rosperf.h"
+
+#define MAINWND_WIDTH 400
+#define MAINWND_HEIGHT 400
+
+static HWND LabelWnd;
+
+unsigned
+NullInit(void **Context, PPERF_INFO PerfInfo, unsigned Reps)
+{
+ *Context = NULL;
+
+ return Reps;
+}
+
+void
+NullCleanup(void *Context, PPERF_INFO PerfInfo)
+{
+}
+
+static void
+ProcessMessages(void)
+{
+ MSG Msg;
+
+ while (PeekMessageW(&Msg, NULL, 0, 0, PM_REMOVE))
+ {
+ if (WM_QUIT == Msg.message)
+ {
+ exit(Msg.wParam);
+ }
+ TranslateMessage(&Msg);
+ DispatchMessageW(&Msg);
+ }
+}
+
+static void
+ClearWindow(PPERF_INFO PerfInfo)
+{
+ InvalidateRect(PerfInfo->Wnd, NULL, TRUE);
+ UpdateWindow(PerfInfo->Wnd);
+}
+
+static unsigned
+CalibrateTest(PTEST Test, PPERF_INFO PerfInfo)
+{
+#define GOAL 2500 /* Try to get up to 2.5 seconds */
+#define ENOUGH 2000 /* But settle for 2.0 seconds */
+#define TICK 10 /* Assume clock not faster than .01 seconds */
+
+ unsigned Reps, DidReps; /* Reps desired, reps performed */
+ unsigned Exponent;
+ void *Context;
+ DWORD StartTick;
+ DWORD Duration;
+
+ /* Attempt to get an idea how long each rep lasts by getting enough
+ reps to last more than ENOUGH. Then scale that up to the number of
+ seconds desired.
+
+ If init call to test ever fails, return False and test will be skipped.
+ */
+
+ Reps = 1;
+ for (;;)
+ {
+ ClearWindow(PerfInfo);
+ DidReps = (*Test->Init)(&Context, PerfInfo, Reps);
+ ProcessMessages();
+ if (0 == DidReps)
+ {
+ return 0;
+ }
+ StartTick = GetTickCount();
+ (*Test->Proc)(Context, PerfInfo, Reps);
+ Duration = GetTickCount() - StartTick;
+ (*Test->PassCleanup) (Context, PerfInfo);
+ (*Test->Cleanup)(Context, PerfInfo);
+ ProcessMessages();
+
+ if (DidReps != Reps)
+ {
+ /* The test can't do the number of reps as we asked for.
+ Give up */
+ return DidReps;
+ }
+ /* Did we go long enough? */
+ if (ENOUGH <= Duration)
+ {
+ break;
+ }
+
+ /* Don't let too short a clock make new reps wildly high */
+ if (Duration <= TICK)
+ {
+ Reps *= 10;
+ }
+ else
+ {
+ /* Try to get up to GOAL seconds. */
+ Reps = (int)(GOAL * (double) Reps / (double) Duration) + 1;
+ }
+ }
+
+ Reps = (int) ((double) PerfInfo->Seconds * 1000.0 * (double) Reps / (double) Duration) + 1;
+
+ /* Now round reps up to 1 digit accuracy, so we don't get stupid-looking
+ numbers of repetitions. */
+ Reps--;
+ Exponent = 1;
+ while (9 < Reps)
+ {
+ Reps /= 10;
+ Exponent *= 10;
+ }
+ Reps = (Reps + 1) * Exponent;
+
+ return Reps;
+}
+
+static void
+DisplayStatus(HWND Label, LPCWSTR Message, LPCWSTR Test, int Try)
+{
+ WCHAR Status[128];
+
+ snwprintf(Status, sizeof(Status) / sizeof(Status[0]), L"%d %s %s", Try, Message, Test);
+ SetWindowTextW(Label, Status);
+ InvalidateRect(Label, NULL, TRUE);
+ UpdateWindow(Label);
+}
+
+static double
+RoundTo3Digits(double d)
+{
+ /* It's kind of silly to print out things like ``193658.4/sec'' so just
+ junk all but 3 most significant digits. */
+
+ double exponent, sign;
+
+ exponent = 1.0;
+ /* the code below won't work if d should happen to be non-positive. */
+ if (d < 0.0)
+ {
+ d = -d;
+ sign = -1.0;
+ }
+ else
+ {
+ sign = 1.0;
+ }
+
+ if (1000.0 <= d)
+ {
+ do
+ {
+ exponent *= 10.0;
+ }
+ while (1000.0 <= d / exponent);
+ d = (double)((int)(d / exponent + 0.5));
+ d *= exponent;
+ }
+ else
+ {
+ if (0.0 != d)
+ {
+ while (d * exponent < 100.0)
+ {
+ exponent *= 10.0;
+ }
+ }
+ d = (double)((int)(d * exponent + 0.5));
+ d /= exponent;
+ }
+
+ return d * sign;
+}
+
+static void
+ReportTimes(DWORD Time, int Reps, LPCWSTR Label, BOOL Average)
+{
+ double MSecsPerObj, ObjsPerSec;
+
+ if (0 != Time)
+ {
+ MSecsPerObj = (double) Time / (double) Reps;
+ ObjsPerSec = (double) Reps * 1000.0 / (double) Time;
+
+ /* Round obj/sec to 3 significant digits. Leave msec untouched, to
+ allow averaging results from several repetitions. */
+ ObjsPerSec = RoundTo3Digits(ObjsPerSec);
+
+ wprintf(L"%7d %s @ %8.4f msec (%8.1f/sec): %s\n",
+ Reps, Average ? L"trep" : L"reps", MSecsPerObj, ObjsPerSec, Label);
+ }
+ else
+ {
+ wprintf(L"%6d %sreps @ 0.0 msec (unmeasurably fast): %s\n",
+ Reps, Average ? L"t" : L"", Label);
+ }
+
+}
+
+static void
+ProcessTest(PTEST Test, PPERF_INFO PerfInfo)
+{
+ unsigned Reps;
+ unsigned Repeat;
+ void *Context;
+ DWORD StartTick;
+ DWORD Time, TotalTime;
+
+ DisplayStatus(LabelWnd, L"Calibrating", Test->Label, 0);
+ Reps = CalibrateTest(Test, PerfInfo);
+ if (0 == Reps)
+ {
+ return;
+ }
+
+ Reps = Test->Init(&Context, PerfInfo, Reps);
+ if (0 == Reps)
+ {
+ return;
+ }
+ TotalTime = 0;
+ for (Repeat = 0; Repeat < PerfInfo->Repeats; Repeat++)
+ {
+ DisplayStatus(LabelWnd, L"Testing", Test->Label, Repeat + 1);
+ ClearWindow(PerfInfo);
+ StartTick = GetTickCount();
+ (*Test->Proc)(Context, PerfInfo, Reps);
+ Time = GetTickCount() - StartTick;
+ ProcessMessages();
+ TotalTime += Time;
+ ReportTimes(Time, Reps, Test->Label, FALSE);
+ (*Test->PassCleanup)(Context, PerfInfo);
+ ProcessMessages();
+ }
+ (*Test->Cleanup)(Context, PerfInfo);
+ ReportTimes(TotalTime, Repeat * Reps, Test->Label, TRUE);
+ ProcessMessages();
+}
+
+static void
+PrintOSVersion(void)
+{
+#define BUFSIZE 160
+ OSVERSIONINFOEXW VersionInfo;
+ BOOL OsVersionInfoEx;
+ HKEY hKey;
+ WCHAR ProductType[BUFSIZE];
+ DWORD BufLen;
+ LONG Ret;
+ unsigned RosVersionLen;
+ LPWSTR RosVersion;
+
+ /* Try calling GetVersionEx using the OSVERSIONINFOEX structure.
+ * If that fails, try using the OSVERSIONINFO structure. */
+
+ ZeroMemory(&VersionInfo, sizeof(OSVERSIONINFOEXW));
+ VersionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXW);
+
+ OsVersionInfoEx = GetVersionExW((OSVERSIONINFOW *) &VersionInfo);
+ if (! OsVersionInfoEx)
+ {
+ VersionInfo.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
+ if (! GetVersionExW((OSVERSIONINFOW *) &VersionInfo))
+ {
+ return;
+ }
+ }
+
+ RosVersion = VersionInfo.szCSDVersion + wcslen(VersionInfo.szCSDVersion) + 1;
+ RosVersionLen = sizeof(VersionInfo.szCSDVersion) / sizeof(VersionInfo.szCSDVersion[0]) -
+ (RosVersion - VersionInfo.szCSDVersion);
+ if (7 <= RosVersionLen && 0 == wcsnicmp(RosVersion, L"ReactOS", 7))
+ {
+ wprintf(L"Running on %s\n", RosVersion);
+ return;
+ }
+
+ switch (VersionInfo.dwPlatformId)
+ {
+ /* Test for the Windows NT product family. */
+ case VER_PLATFORM_WIN32_NT:
+
+ /* Test for the specific product. */
+ if (5 == VersionInfo.dwMajorVersion && 2 == VersionInfo.dwMinorVersion)
+ {
+ wprintf(L"Running on Microsoft Windows Server 2003, ");
+ }
+ else if (5 == VersionInfo.dwMajorVersion && 1 == VersionInfo.dwMinorVersion)
+ {
+ wprintf(L"Running on Microsoft Windows XP ");
+ }
+ else if (5 == VersionInfo.dwMajorVersion && 0 == VersionInfo.dwMinorVersion)
+ {
+ wprintf(L"Running on Microsoft Windows 2000 ");
+ }
+ else if (VersionInfo.dwMajorVersion <= 4 )
+ {
+ wprintf(L"Running on Microsoft Windows NT ");
+ }
+
+ /* Test for specific product on Windows NT 4.0 SP6 and later. */
+ if (OsVersionInfoEx)
+ {
+ /* Test for the workstation type. */
+ if (VER_NT_WORKSTATION == VersionInfo.wProductType)
+ {
+ if (4 == VersionInfo.dwMajorVersion)
+ {
+ wprintf(L"Workstation 4.0 ");
+ }
+ else if (0 != (VersionInfo.wSuiteMask & VER_SUITE_PERSONAL))
+ {
+ wprintf(L"Home Edition ");
+ }
+ else
+ {
+ wprintf(L"Professional ");
+ }
+ }
+
+ /* Test for the server type. */
+ else if (VER_NT_SERVER == VersionInfo.wProductType ||
+ VER_NT_DOMAIN_CONTROLLER == VersionInfo.wProductType)
+ {
+ if (5 == VersionInfo.dwMajorVersion && 2 == VersionInfo.dwMinorVersion)
+ {
+ if (0 != (VersionInfo.wSuiteMask & VER_SUITE_DATACENTER))
+ {
+ wprintf(L"Datacenter Edition ");
+ }
+ else if (0 != (VersionInfo.wSuiteMask & VER_SUITE_ENTERPRISE))
+ {
+ wprintf(L"Enterprise Edition ");
+ }
+ else if (VER_SUITE_BLADE == VersionInfo.wSuiteMask)
+ {
+ wprintf(L"Web Edition ");
+ }
+ else
+ {
+ wprintf(L"Standard Edition ");
+ }
+ }
+
+ else if (5 == VersionInfo.dwMajorVersion && 0 == VersionInfo.dwMinorVersion)
+ {
+ if (0 != (VersionInfo.wSuiteMask & VER_SUITE_DATACENTER))
+ {
+ wprintf(L"Datacenter Server ");
+ }
+ else if (0 != (VersionInfo.wSuiteMask & VER_SUITE_ENTERPRISE))
+ {
+ wprintf(L"Advanced Server " );
+ }
+ else
+ {
+ wprintf(L"Server " );
+ }
+ }
+
+ else /* Windows NT 4.0 */
+ {
+ if (0 != (VersionInfo.wSuiteMask & VER_SUITE_ENTERPRISE))
+ {
+ wprintf(L"Server 4.0, Enterprise Edition ");
+ }
+ else
+ {
+ wprintf(L"Server 4.0 ");
+ }
+ }
+ }
+ }
+ else /* Test for specific product on Windows NT 4.0 SP5 and earlier */
+ {
+ BufLen = BUFSIZE;
+
+ Ret = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
+ L"SYSTEM\\CurrentControlSet\\Control\\ProductOptions",
+ 0, KEY_QUERY_VALUE, &hKey);
+ if (ERROR_SUCCESS != Ret)
+ {
+ return;
+ }
+
+ Ret = RegQueryValueExW(hKey, L"ProductType", NULL, NULL,
+ (LPBYTE) ProductType, &BufLen);
+ if (ERROR_SUCCESS != Ret || BUFSIZE < BufLen)
+ {
+ return;
+ }
+
+ RegCloseKey(hKey);
+
+ if (0 == lstrcmpiW(L"WINNT", ProductType))
+ {
+ wprintf(L"Workstation ");
+ }
+ else if (0 == lstrcmpiW(L"LANMANNT", ProductType))
+ {
+ wprintf(L"Server ");
+ }
+ else if (0 == lstrcmpiW(L"SERVERNT", ProductType))
+ {
+ wprintf(L"Advanced Server ");
+ }
+
+ wprintf(L"%d.%d ", VersionInfo.dwMajorVersion, VersionInfo.dwMinorVersion);
+ }
+
+ /* Display service pack (if any) and build number. */
+
+ if (4 == VersionInfo.dwMajorVersion &&
+ 0 == lstrcmpiW(VersionInfo.szCSDVersion, L"Service Pack 6"))
+ {
+ /* Test for SP6 versus SP6a. */
+ Ret = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
+ L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Hotfix\\Q246009",
+ 0, KEY_QUERY_VALUE, &hKey);
+ if (ERROR_SUCCESS == Ret)
+ {
+ wprintf(L"Service Pack 6a (Build %d)\n", VersionInfo.dwBuildNumber & 0xFFFF);
+ }
+ else /* Windows NT 4.0 prior to SP6a */
+ {
+ wprintf(L"%s (Build %d)\n",
+ VersionInfo.szCSDVersion,
+ VersionInfo.dwBuildNumber & 0xFFFF);
+ }
+
+ RegCloseKey(hKey);
+ }
+ else /* not Windows NT 4.0 */
+ {
+ wprintf(L"%s (Build %d)\n",
+ VersionInfo.szCSDVersion,
+ VersionInfo.dwBuildNumber & 0xFFFF);
+ }
+
+
+ break;
+
+ /* Test for the Windows Me/98/95. A bit silly since we're using Unicode... */
+ case VER_PLATFORM_WIN32_WINDOWS:
+
+ if (4 == VersionInfo.dwMajorVersion && 0 == VersionInfo.dwMinorVersion)
+ {
+ wprintf(L"Running on Microsoft Windows 95 ");
+ if (L'C' == VersionInfo.szCSDVersion[1] || L'B' == VersionInfo.szCSDVersion[1])
+ {
+ wprintf(L"OSR2");
+ }
+ }
+
+ else if (4 == VersionInfo.dwMajorVersion && 10 == VersionInfo.dwMinorVersion)
+ {
+ wprintf(L"Running on Microsoft Windows 98 ");
+ if (L'A' == VersionInfo.szCSDVersion[1])
+ {
+ wprintf(L"SE");
+ }
+ }
+
+ else if (4 == VersionInfo.dwMajorVersion && 90 == VersionInfo.dwMinorVersion)
+ {
+ wprintf(L"Running on Microsoft Windows Millennium Edition");
+ }
+ wprintf(L"\n");
+ break;
+
+ case VER_PLATFORM_WIN32s: /* Even silier... */
+
+ wprintf(L"Running on Microsoft Win32s\n");
+ break;
+ }
+}
+
+static void
+PrintAppVersion(void)
+{
+ wprintf(L"RosPerf %S (Build %S)\n", KERNEL_VERSION_STR, KERNEL_VERSION_BUILD_STR);
+}
+
+static void
+PrintDisplayInfo(void)
+{
+ HDC Dc;
+
+ Dc = GetDC(NULL);
+ if (NULL == Dc)
+ {
+ return;
+ }
+
+ wprintf(L"Display settings %d * %d * %d\n", GetDeviceCaps(Dc, HORZRES),
+ GetDeviceCaps(Dc, VERTRES), GetDeviceCaps(Dc, BITSPIXEL) * GetDeviceCaps(Dc, PLANES));
+
+ ReleaseDC(NULL, Dc);
+}
+
+static void
+PrintStartupInfo(void)
+{
+ PrintAppVersion();
+ PrintOSVersion();
+ PrintDisplayInfo();
+}
+
+static LRESULT CALLBACK
+MainWndProc(HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam)
+{
+ PAINTSTRUCT Ps;
+ HDC Dc;
+ LRESULT Result;
+
+ switch (Msg)
+ {
+ case WM_DESTROY:
+ PostQuitMessage(0);
+ Result = 0;
+ break;
+
+ case WM_PAINT:
+ Dc = BeginPaint(Wnd, &Ps);
+ EndPaint (Wnd, &Ps);
+ Result = 0;
+ break;
+
+ default:
+ Result = DefWindowProcW(Wnd, Msg, wParam, lParam);
+ break;
+ }
+
+ return Result;
+}
+
+static LRESULT CALLBACK
+LabelWndProc(HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam)
+{
+ PAINTSTRUCT Ps;
+ HDC Dc;
+ RECT ClientRect, WindowRect;
+ TEXTMETRICW Tm;
+ LRESULT Result;
+ WCHAR Title[80];
+
+ switch (Msg)
+ {
+ case WM_CREATE:
+ /* Make text fit */
+ Dc = GetDC(Wnd);
+ if (NULL != Dc && GetClientRect(Wnd, &ClientRect) && GetWindowRect(Wnd, &WindowRect)
+ && GetTextMetricsW(Dc, &Tm))
+ {
+ if (Tm.tmHeight != ClientRect.bottom)
+ {
+ SetWindowPos(Wnd, NULL, 0, 0, WindowRect.right - WindowRect.left,
+ (WindowRect.bottom - WindowRect.top) + (Tm.tmHeight - ClientRect.bottom),
+ SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOZORDER);
+ }
+ }
+ if (NULL != Dc)
+ {
+ ReleaseDC(Wnd, Dc);
+ }
+ Result = DefWindowProcW(Wnd, Msg, wParam, lParam);
+ break;
+
+ case WM_PAINT:
+ Dc = BeginPaint(Wnd, &Ps);
+ GetWindowTextW(Wnd, Title, sizeof(Title) / sizeof(Title[0]));
+ TextOutW(Dc, 0, 0, Title, wcslen(Title));
+ EndPaint (Wnd, &Ps);
+ Result = 0;
+ break;
+
+ default:
+ Result = DefWindowProcW(Wnd, Msg, wParam, lParam);
+ break;
+ }
+
+ return Result;
+}
+
+static HWND
+CreatePerfWindows(HINSTANCE hInstance, PPERF_INFO PerfInfo)
+{
+ WNDCLASSW wc;
+ HWND MainWnd;
+
+ wc.lpszClassName = L"RosPerfMain";
+ wc.lpfnWndProc = MainWndProc;
+ wc.style = 0;
+ wc.hInstance = hInstance;
+ wc.hIcon = LoadIconW(NULL, (LPCWSTR) IDI_APPLICATION);
+ wc.hCursor = LoadCursorW(NULL, (LPCWSTR)IDC_ARROW);
+ wc.hbrBackground = CreateSolidBrush(PerfInfo->BackgroundColor);
+ wc.lpszMenuName = NULL;
+ wc.cbClsExtra = 0;
+ wc.cbWndExtra = 0;
+ if (RegisterClassW(&wc) == 0)
+ {
+ fwprintf(stderr, L"Failed to register RosPerfMain (last error %d)\n",
+ GetLastError());
+ return NULL;
+ }
+
+ wc.lpszClassName = L"RosPerfLabel";
+ wc.lpfnWndProc = LabelWndProc;
+ wc.style = 0;
+ wc.hInstance = hInstance;
+ wc.hIcon = LoadIconW(NULL, (LPCWSTR) IDI_APPLICATION);
+ wc.hCursor = LoadCursorW(NULL, (LPCWSTR)IDC_ARROW);
+ wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
+ wc.lpszMenuName = NULL;
+ wc.cbClsExtra = 0;
+ wc.cbWndExtra = 0;
+ if (RegisterClassW(&wc) == 0)
+ {
+ fwprintf(stderr, L"Failed to register RosPerfLabel (last error %d)\n",
+ GetLastError());
+ return NULL;
+ }
+
+ MainWnd = CreateWindowW(L"RosPerfMain",
+ L"ReactOS performance test",
+ WS_OVERLAPPEDWINDOW | WS_VISIBLE,
+ 0,
+ 0,
+ MAINWND_WIDTH,
+ MAINWND_HEIGHT,
+ NULL,
+ NULL,
+ hInstance,
+ NULL);
+ if (NULL == MainWnd)
+ {
+ fwprintf(stderr, L"Failed to create main window (last error %d)\n",
+ GetLastError());
+ return NULL;
+ }
+
+ LabelWnd = CreateWindowW(L"RosPerfLabel",
+ L"",
+ WS_POPUP | WS_THICKFRAME | WS_VISIBLE,
+ 0,
+ MAINWND_HEIGHT + 10,
+ MAINWND_WIDTH,
+ 20,
+ MainWnd,
+ NULL,
+ hInstance,
+ NULL);
+ if (NULL == LabelWnd)
+ {
+ fwprintf(stderr, L"Failed to create label window (last error 0x%lX)\n",
+ GetLastError());
+ return NULL;
+ }
+
+ SetActiveWindow(MainWnd);
+
+ return MainWnd;
+}
+
+static BOOL
+ProcessCommandLine(PPERF_INFO PerfInfo, unsigned *TestCount, PTEST *Tests)
+{
+ int ArgC, Arg;
+ LPWSTR *ArgV;
+ LPWSTR EndPtr;
+ PTEST AllTests;
+ BOOL *DoTest;
+ BOOL DoAll;
+ unsigned AllTestCount, i, j;
+
+ ArgV = CommandLineToArgvW(GetCommandLineW(), &ArgC);
+ if (NULL == ArgV)
+ {
+ fwprintf(stderr, L"CommandLineToArgvW failed\n");
+ return FALSE;
+ }
+
+ GetTests(&AllTestCount, &AllTests);
+ DoTest = malloc(AllTestCount * sizeof(BOOL));
+ if (NULL == DoTest)
+ {
+ fwprintf(stderr, L"Out of memory\n");
+ return FALSE;
+ }
+ DoAll = TRUE;
+
+ for (Arg = 1; Arg < ArgC; Arg++)
+ {
+ if (L'/' == ArgV[Arg][0] || L'-' == ArgV[Arg][0])
+ {
+ if (0 == wcsicmp(ArgV[Arg] + 1, L"repeat"))
+ {
+ if (ArgC <= Arg + 1)
+ {
+ fwprintf(stderr, L"%s needs a repeat count\n", ArgV[Arg]);
+ free(DoTest);
+ GlobalFree(ArgV);
+ return FALSE;
+ }
+ Arg++;
+ PerfInfo->Repeats = wcstoul(ArgV[Arg], &EndPtr, 0);
+ if (L'\0' != *EndPtr || (long) PerfInfo->Repeats <= 0 || ULONG_MAX == PerfInfo->Repeats)
+ {
+ fwprintf(stderr, L"Invalid repeat count %s\n", ArgV[Arg]);
+ free(DoTest);
+ GlobalFree(ArgV);
+ return FALSE;
+ }
+ }
+ else if (0 == wcsicmp(ArgV[Arg] + 1, L"seconds"))
+ {
+ if (ArgC <= Arg + 1)
+ {
+ fwprintf(stderr, L"%s needs a number of seconds\n", ArgV[Arg]);
+ free(DoTest);
+ GlobalFree(ArgV);
+ return FALSE;
+ }
+ Arg++;
+ PerfInfo->Seconds = wcstoul(ArgV[Arg], &EndPtr, 0);
+ if (L'\0' != *EndPtr || (long) PerfInfo->Seconds < 0 || ULONG_MAX == PerfInfo->Seconds)
+ {
+ fwprintf(stderr, L"Invalid duration %s\n", ArgV[Arg]);
+ free(DoTest);
+ GlobalFree(ArgV);
+ return FALSE;
+ }
+ }
+ else
+ {
+ fwprintf(stderr, L"Unrecognized option %s\n", ArgV[Arg]);
+ free(DoTest);
+ GlobalFree(ArgV);
+ return FALSE;
+ }
+ }
+ else
+ {
+ if (DoAll)
+ {
+ for (i = 0; i < AllTestCount; i++)
+ {
+ DoTest[i] = FALSE;
+ }
+ DoAll = FALSE;
+ }
+ for (i = 0; i < AllTestCount; i++)
+ {
+ if (0 == wcsicmp(ArgV[Arg], AllTests[i].Option))
+ {
+ DoTest[i] = TRUE;
+ break;
+ }
+ }
+ if (AllTestCount <= i)
+ {
+ fwprintf(stderr, L"Unrecognized test %s\n", ArgV[Arg]);
+ free(DoTest);
+ GlobalFree(ArgV);
+ return FALSE;
+ }
+ }
+ }
+
+ GlobalFree(ArgV);
+
+ if (DoAll)
+ {
+ for (i = 0; i < AllTestCount; i++)
+ {
+ DoTest[i] = TRUE;
+ }
+ }
+
+ *TestCount = 0;
+ for (i = 0; i < AllTestCount; i++)
+ {
+ if (DoTest[i])
+ {
+ (*TestCount)++;
+ }
+ }
+ *Tests = malloc(*TestCount * sizeof(TEST));
+ if (NULL == *Tests)
+ {
+ fwprintf(stderr, L"Out of memory\n");
+ free(DoTest);
+ return FALSE;
+ }
+ j = 0;
+ for (i = 0; i < AllTestCount; i++)
+ {
+ if (DoTest[i])
+ {
+ (*Tests)[j] = AllTests[i];
+ j++;
+ }
+ }
+ free(DoTest);
+
+ return TRUE;
+}
+
+int WINAPI
+WinMain(HINSTANCE hInstance,
+ HINSTANCE hPrevInstance,
+ LPSTR lpszCmdLine,
+ int nCmdShow)
+{
+ PTEST Tests;
+ unsigned TestCount;
+ unsigned CurrentTest;
+ RECT Rect;
+ PERF_INFO PerfInfo;
+
+ PrintStartupInfo();
+
+ PerfInfo.Seconds = 15;
+ PerfInfo.Repeats = 4;
+ PerfInfo.ForegroundColor = RGB(0, 0, 0);
+ PerfInfo.BackgroundColor = RGB(255, 255, 255);
+
+ if (! ProcessCommandLine(&PerfInfo, &TestCount, &Tests))
+ {
+ exit(1);
+ }
+
+ PerfInfo.Wnd = CreatePerfWindows(hInstance, &PerfInfo);
+ if (NULL == PerfInfo.Wnd)
+ {
+ exit(1);
+ }
+
+ GetClientRect(PerfInfo.Wnd, &Rect);
+ PerfInfo.WndWidth = Rect.right - Rect.left;
+ PerfInfo.WndHeight = Rect.bottom - Rect.top;
+ PerfInfo.ForegroundDc = GetDC(PerfInfo.Wnd);
+ PerfInfo.BackgroundDc = GetDC(PerfInfo.Wnd);
+ if (NULL == PerfInfo.ForegroundDc || NULL == PerfInfo.BackgroundDc)
+ {
+ fwprintf(stderr, L"Failed to create device contexts (last error %d)\n",
+ GetLastError());
+ exit(1);
+ }
+ SelectObject(PerfInfo.ForegroundDc, CreateSolidBrush(PerfInfo.ForegroundColor));
+ SelectObject(PerfInfo.ForegroundDc, CreatePen(PS_SOLID, 0, PerfInfo.ForegroundColor));
+ SelectObject(PerfInfo.BackgroundDc, CreateSolidBrush(PerfInfo.BackgroundColor));
+ SelectObject(PerfInfo.BackgroundDc, CreatePen(PS_SOLID, 0, PerfInfo.BackgroundColor));
+
+ ProcessMessages();
+
+ /* Move cursor out of the way */
+ GetWindowRect(LabelWnd, &Rect);
+ SetCursorPos(Rect.right, Rect.bottom);
+
+ for (CurrentTest = 0; CurrentTest < TestCount; CurrentTest++)
+ {
+ wprintf(L"\n");
+ ProcessTest(Tests + CurrentTest, &PerfInfo);
+ }
+
+ GlobalFree(Tests);
+
+ return 0;
+}
+
+/* EOF */
diff --git a/reactos/apps/utils/rosperf/rosperf.h b/reactos/apps/utils/rosperf/rosperf.h
new file mode 100644
index 00000000000..4eb1144a797
--- /dev/null
+++ b/reactos/apps/utils/rosperf/rosperf.h
@@ -0,0 +1,64 @@
+/*
+ * ReactOS RosPerf - ReactOS GUI performance test program
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef ROSPERF_H_INCLUDED
+#define ROSPERF_H_INCLUDED
+
+typedef struct tagPERF_INFO
+{
+ HWND Wnd;
+ unsigned Seconds;
+ unsigned Repeats;
+ COLORREF ForegroundColor;
+ COLORREF BackgroundColor;
+ HDC ForegroundDc;
+ HDC BackgroundDc;
+ ULONG WndWidth;
+ ULONG WndHeight;
+} PERF_INFO, *PPERF_INFO;
+
+typedef unsigned (*INITTESTPROC)(void **Context, PPERF_INFO PerfInfo, unsigned Reps);
+typedef void (*TESTPROC)(void *Context, PPERF_INFO PerfInfo, unsigned Reps);
+typedef void (*CLEANUPTESTPROC)(void *Context, PPERF_INFO PerfInfo);
+
+typedef struct tagTEST
+{
+ LPCWSTR Option;
+ LPCWSTR Label;
+ INITTESTPROC Init;
+ TESTPROC Proc;
+ CLEANUPTESTPROC PassCleanup;
+ CLEANUPTESTPROC Cleanup;
+} TEST, *PTEST;
+
+void GetTests(unsigned *TestCount, PTEST *Tests);
+
+/* Tests */
+unsigned NullInit(void **Context, PPERF_INFO PerfInfo, unsigned Reps);
+void NullCleanup(void *Context, PPERF_INFO PerfInfo);
+
+void FillProc(void *Context, PPERF_INFO PerfInfo, unsigned Reps);
+void FillSmallProc(void *Context, PPERF_INFO PerfInfo, unsigned Reps);
+
+void LinesHorizontalProc(void *Context, PPERF_INFO PerfInfo, unsigned Reps);
+void LinesVerticalProc(void *Context, PPERF_INFO PerfInfo, unsigned Reps);
+void LinesProc(void *Context, PPERF_INFO PerfInfo, unsigned Reps);
+
+#endif /* ROSPERF_H_INCLUDED */
+
+/* EOF */
diff --git a/reactos/apps/utils/rosperf/rosperf.rc b/reactos/apps/utils/rosperf/rosperf.rc
new file mode 100644
index 00000000000..26841ca1d03
--- /dev/null
+++ b/reactos/apps/utils/rosperf/rosperf.rc
@@ -0,0 +1,4 @@
+#define REACTOS_STR_FILE_DESCRIPTION "ReactOS performance tester\0"
+#define REACTOS_STR_INTERNAL_NAME "rosperf\0"
+#define REACTOS_STR_ORIGINAL_FILENAME "rosperf.exe\0"
+#include
diff --git a/reactos/apps/utils/rosperf/testlist.c b/reactos/apps/utils/rosperf/testlist.c
new file mode 100644
index 00000000000..6b86e7d7ea1
--- /dev/null
+++ b/reactos/apps/utils/rosperf/testlist.c
@@ -0,0 +1,39 @@
+/*
+ * ReactOS RosPerf - ReactOS GUI performance test program
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include
+#include "rosperf.h"
+
+static TEST TestList[] =
+ {
+ { L"fill", L"Fill", NullInit, FillProc, NullCleanup, NullCleanup },
+ { L"smallfill", L"Small Fill", NullInit, FillSmallProc, NullCleanup, NullCleanup },
+ { L"hlines", L"Horizontal Lines", NullInit, LinesHorizontalProc, NullCleanup, NullCleanup },
+ { L"vlines", L"Vertical Lines", NullInit, LinesVerticalProc, NullCleanup, NullCleanup },
+ { L"lines", L"Lines", NullInit, LinesProc, NullCleanup, NullCleanup }
+ };
+
+
+void
+GetTests(unsigned *TestCount, PTEST *Tests)
+ {
+ *TestCount = sizeof(TestList) / sizeof(TEST);
+ *Tests = TestList;
+ }
+
+/* EOF */
diff --git a/reactos/apps/utils/shutdown/shutdown.c b/reactos/apps/utils/shutdown/shutdown.c
index 2f999898d1f..4bec4789434 100644
--- a/reactos/apps/utils/shutdown/shutdown.c
+++ b/reactos/apps/utils/shutdown/shutdown.c
@@ -146,7 +146,6 @@ _tmain(int argc, TCHAR *argv[])
if (! AdjustTokenPrivileges(hToken, FALSE, &npr, 0, 0, 0)
|| ERROR_SUCCESS != GetLastError())
{
- CloseHandle(hToken);
if (ERROR_NOT_ALL_ASSIGNED == GetLastError())
{
_ftprintf(stderr, _T("You are not authorized to shutdown the system\n"));
@@ -155,6 +154,7 @@ _tmain(int argc, TCHAR *argv[])
{
_ftprintf(stderr, _T("AdjustTokenPrivileges failed with error %d\n"), (int) GetLastError());
}
+ CloseHandle(hToken);
exit(1);
}
CloseHandle(hToken);
diff --git a/reactos/apps/utils/tickcount/makefile b/reactos/apps/utils/tickcount/makefile
index 9e8a3e042fb..37fd9534e7a 100644
--- a/reactos/apps/utils/tickcount/makefile
+++ b/reactos/apps/utils/tickcount/makefile
@@ -12,7 +12,7 @@ TARGET_SDKLIBS = kernel32.a
TARGET_OBJECTS = tickcount.o
-TARGET_CFLAGS = -Wall -Werror
+TARGET_CFLAGS = -Wall -Werror -D__USE_W32API
include $(PATH_TO_TOP)/rules.mak
diff --git a/reactos/apps/utils/tickcount/tickcount.c b/reactos/apps/utils/tickcount/tickcount.c
index d64a515fb96..9ee52a43e0e 100644
--- a/reactos/apps/utils/tickcount/tickcount.c
+++ b/reactos/apps/utils/tickcount/tickcount.c
@@ -1,30 +1,32 @@
/* $Id$
*/
/*
- tickcount -- Display the kernel tick count in human-readable format
+ tickcount -- Display the kernel tick count (or any tick count passed as an
+ argument or as input) in human-readable format
This is public domain software
*/
#include
#include
+#include
#include
#include
-typedef __int64 int64_t;
-typedef unsigned __int64 uint64_t;
+typedef __int64 int64_;
+typedef unsigned __int64 uint64_;
-#define TICKS_YEAR (TICKS_DAY * ((uint64_t)365))
-#define TICKS_MONTH (TICKS_DAY * ((uint64_t)30))
-#define TICKS_WEEK (TICKS_DAY * ((uint64_t)7))
-#define TICKS_DAY (TICKS_HOUR * ((uint64_t)24))
-#define TICKS_HOUR (TICKS_MINUTE * ((uint64_t)60))
-#define TICKS_MINUTE (TICKS_SECOND * ((uint64_t)60))
-#define TICKS_SECOND ((uint64_t)1000)
+#define TICKS_YEAR (TICKS_DAY * ((uint64_)365))
+#define TICKS_MONTH (TICKS_DAY * ((uint64_)30))
+#define TICKS_WEEK (TICKS_DAY * ((uint64_)7))
+#define TICKS_DAY (TICKS_HOUR * ((uint64_)24))
+#define TICKS_HOUR (TICKS_MINUTE * ((uint64_)60))
+#define TICKS_MINUTE (TICKS_SECOND * ((uint64_)60))
+#define TICKS_SECOND ((uint64_)1000)
#define SLICES_COUNT (sizeof(ticks_per_slice) / sizeof(ticks_per_slice[0]))
-uint64_t ticks_per_slice[] =
+uint64_ ticks_per_slice[] =
{
TICKS_YEAR,
TICKS_MONTH,
@@ -36,7 +38,7 @@ uint64_t ticks_per_slice[] =
1
};
-_TCHAR * slice_names_singular[] =
+_TCHAR * slice_names_singular[SLICES_COUNT] =
{
_T("year"),
_T("month"),
@@ -48,7 +50,7 @@ _TCHAR * slice_names_singular[] =
_T("millisecond")
};
-_TCHAR * slice_names_plural[] =
+_TCHAR * slice_names_plural[SLICES_COUNT] =
{
_T("years"),
_T("months"),
@@ -62,16 +64,16 @@ _TCHAR * slice_names_plural[] =
void print_uptime
(
- uint64_t tickcount,
- uint64_t prevsliceval,
+ uint64_ tickcount,
+ uint64_ prevsliceval,
_TCHAR * prevsliceunit,
int curslice
)
{
- uint64_t tick_cur = tickcount / ticks_per_slice[curslice];
- uint64_t tick_residual = tickcount % ticks_per_slice[curslice];
+ uint64_ tick_cur = tickcount / ticks_per_slice[curslice];
+ uint64_ tick_residual = tickcount % ticks_per_slice[curslice];
- assert(tick_cur <= (~((uint64_t)0)));
+ assert(tick_cur <= (~((uint64_)0)));
if(tick_residual == 0)
{
@@ -134,9 +136,56 @@ void print_uptime
}
}
-int _tmain()
+int parse_print(const _TCHAR * str)
{
- print_uptime((uint64_t)GetTickCount(), 0, NULL, 0);
+ int64_ tickcount;
+
+ tickcount = _ttoi64(str);
+
+ if(tickcount < 0)
+ tickcount = - tickcount;
+ else if(tickcount == 0)
+ return 1;
+
+ print_uptime(tickcount, 0, NULL, 0);
_puttc(_T('\n'), stdout);
+
+ return 0;
+}
+
+int _tmain(int argc, _TCHAR * argv[])
+{
+ int r;
+
+ if(argc <= 1)
+ {
+ print_uptime((uint64_)GetTickCount(), 0, NULL, 0);
+ _puttc(_T('\n'), stdout);
+ }
+ else if(argc == 2 && argv[1][0] == _T('-') && argv[1][1] == 0)
+ {
+ while(!feof(stdin))
+ {
+ _TCHAR buf[23];
+ _TCHAR * str;
+
+ str = _fgetts(buf, 22, stdin);
+
+ if(str == NULL)
+ return 0;
+
+ if((r = parse_print(str)) != 0)
+ return r;
+ }
+ }
+ else
+ {
+ int i;
+
+ for(i = 1; i < argc; ++ i)
+ if((r = parse_print(argv[i])) != 0)
+ return r;
+ }
+
return 0;
}
diff --git a/reactos/baseaddress.cfg b/reactos/baseaddress.cfg
index ef506fde45f..1d8b8b6168a 100644
--- a/reactos/baseaddress.cfg
+++ b/reactos/baseaddress.cfg
@@ -88,9 +88,9 @@ TARGET_BASE_LIB_VERSION =0x77a90000
TARGET_BASE_LIB_ADVAPI32 =0x77dc0000
TARGET_BASE_LIB_USER32 =0x77e60000
TARGET_BASE_LIB_GDI32 =0x77ed0000
-TARGET_BASE_LIB_DNSAPI =0x78000000
+TARGET_BASE_LIB_DNSAPI =0x77f00000
TARGET_BASE_LIB_MSVCRT =0x78000000
-TARGET_BASE_LIB_MSVCRT20 =0x78000000
+TARGET_BASE_LIB_MSVCRT20 =0x78500000
TARGET_BASE_LIB_EXPAT =0x79000000
TARGET_BASE_LIB_KERNEL32 =0x7C800000
TARGET_BASE_LIB_NTDLL =0x7C900000
diff --git a/reactos/boot/freeldr/freeldr/CHANGELOG b/reactos/boot/freeldr/freeldr/CHANGELOG
index 7b1a3de91b0..d232950622b 100644
--- a/reactos/boot/freeldr/freeldr/CHANGELOG
+++ b/reactos/boot/freeldr/freeldr/CHANGELOG
@@ -1,3 +1,9 @@
+Changes in v2.0.0 (02/07/2005) (alex ionesco)
+
+- PE loading of ntoskrnl.exe
+- Work on 3GB support
+- w32api conversion
+
Changes in v1.8.26 (10/30/2004) (chorns)
- Print stack frames on crashes.
diff --git a/reactos/boot/freeldr/freeldr/Makefile b/reactos/boot/freeldr/freeldr/Makefile
index 13612b2d29d..b44ba98a800 100644
--- a/reactos/boot/freeldr/freeldr/Makefile
+++ b/reactos/boot/freeldr/freeldr/Makefile
@@ -83,7 +83,7 @@ setup_loader : setupldr.sys
$(CP) setupldr.sys $(BOOTCD_DIR)/disk/loader/setupldr.sys
-COMPILER_OPTIONS = -Wall -Werror -nostdlib -nostdinc -ffreestanding -fno-builtin -fno-inline \
+COMPILER_OPTIONS = -Wall -Werror -nostdlib -ffreestanding -fno-builtin -fno-inline \
-fno-zero-initialized-in-bss -O1 -MD
# FreeLoader does not use any of the standard libraries, includes, or built-in functions
@@ -95,7 +95,7 @@ endif
COMPILER_DEFINES = -D__$(TARGET)__ $(COMPILER_DEBUG_DEFINES)
-COMPILER_INCLUDES = -I$(SRCDIR)/include
+COMPILER_INCLUDES = -I$(SRCDIR)/include -I$(PATH_TO_TOP)/w32api/include -I$(PATH_TO_TOP)/include -I$(PATH_TO_TOP)/ntoskrnl/include
CFLAGS = $(COMPILER_OPTIONS) \
$(COMPILER_DEFINES) \
@@ -262,9 +262,9 @@ all : freeldr.sys setupldr.sys
@echo Make ALL done.
-freeldr.sys : $(ALL_OBJS)
+freeldr.sys : $(ALL_OBJS) $(PATH_TO_TOP)/dk/w32/lib/librossym.a
@echo ===================================================== LINKING $@
- @$(LD) $(LFLAGS) -o freeldr.exe $(F_OBJS)
+ @$(LD) $(LFLAGS) -o freeldr.exe $(F_OBJS) $(PATH_TO_TOP)/dk/w32/lib/librossym.a
ifeq ($(FULL_MAP),yes)
@$(OBJDUMP) -d -S freeldr.exe > freeldr.map
else
diff --git a/reactos/boot/freeldr/freeldr/arch/i386/archmach.c b/reactos/boot/freeldr/freeldr/arch/i386/archmach.c
index ad503bd2e05..347d8f56e22 100644
--- a/reactos/boot/freeldr/freeldr/arch/i386/archmach.c
+++ b/reactos/boot/freeldr/freeldr/arch/i386/archmach.c
@@ -29,14 +29,14 @@
VOID
MachInit(VOID)
{
- U32 PciId;
+ ULONG PciId;
memset(&MachVtbl, 0, sizeof(MACHVTBL));
/* Check for Xbox by identifying device at PCI 0:0:0, if it's
* 0x10de/0x02a5 then we're running on an Xbox */
- WRITE_PORT_ULONG((U32*) 0xcf8, CONFIG_CMD(0, 0, 0));
- PciId = READ_PORT_ULONG((U32*) 0xcfc);
+ WRITE_PORT_ULONG((ULONG*) 0xcf8, CONFIG_CMD(0, 0, 0));
+ PciId = READ_PORT_ULONG((ULONG*) 0xcfc);
if (0x02a510de == PciId)
{
XboxMachInit();
diff --git a/reactos/boot/freeldr/freeldr/arch/i386/hardware.c b/reactos/boot/freeldr/freeldr/arch/i386/hardware.c
index afb2a376baf..71876f10abf 100644
--- a/reactos/boot/freeldr/freeldr/arch/i386/hardware.c
+++ b/reactos/boot/freeldr/freeldr/arch/i386/hardware.c
@@ -89,96 +89,43 @@
#define CONTROLLER_TIMEOUT 250
-typedef struct _CM_INT13_DRIVE_PARAMETER
-{
- U16 DriveSelect;
- U32 MaxCylinders;
- U16 SectorsPerTrack;
- U16 MaxHeads;
- U16 NumberDrives;
-} CM_INT13_DRIVE_PARAMETER, *PCM_INT13_DRIVE_PARAMETER;
-
-
typedef struct _CM_DISK_GEOMETRY_DEVICE_DATA
{
- U32 BytesPerSector;
- U32 NumberOfCylinders;
- U32 SectorsPerTrack;
- U32 NumberOfHeads;
+ ULONG BytesPerSector;
+ ULONG NumberOfCylinders;
+ ULONG SectorsPerTrack;
+ ULONG NumberOfHeads;
} CM_DISK_GEOMETRY_DEVICE_DATA, *PCM_DISK_GEOMETRY_DEVICE_DATA;
typedef struct _CM_PNP_BIOS_DEVICE_NODE
{
- U16 Size;
- U8 Node;
- U32 ProductId;
- U8 DeviceType[3];
- U16 DeviceAttributes;
+ USHORT Size;
+ UCHAR Node;
+ ULONG ProductId;
+ UCHAR DeviceType[3];
+ USHORT DeviceAttributes;
} __attribute__((packed)) CM_PNP_BIOS_DEVICE_NODE, *PCM_PNP_BIOS_DEVICE_NODE;
typedef struct _CM_PNP_BIOS_INSTALLATION_CHECK
{
- U8 Signature[4];
- U8 Revision;
- U8 Length;
- U16 ControlField;
- U8 Checksum;
- U32 EventFlagAddress;
- U16 RealModeEntryOffset;
- U16 RealModeEntrySegment;
- U16 ProtectedModeEntryOffset;
- U32 ProtectedModeCodeBaseAddress;
- U32 OemDeviceId;
- U16 RealModeDataBaseAddress;
- U32 ProtectedModeDataBaseAddress;
+ UCHAR Signature[4];
+ UCHAR Revision;
+ UCHAR Length;
+ USHORT ControlField;
+ UCHAR Checksum;
+ ULONG EventFlagAddress;
+ USHORT RealModeEntryOffset;
+ USHORT RealModeEntrySegment;
+ USHORT ProtectedModeEntryOffset;
+ ULONG ProtectedModeCodeBaseAddress;
+ ULONG OemDeviceId;
+ USHORT RealModeDataBaseAddress;
+ ULONG ProtectedModeDataBaseAddress;
} __attribute__((packed)) CM_PNP_BIOS_INSTALLATION_CHECK, *PCM_PNP_BIOS_INSTALLATION_CHECK;
-typedef struct _CM_SERIAL_DEVICE_DATA
-{
- U16 Version;
- U16 Revision;
- U32 BaudClock;
-} __attribute__((packed)) CM_SERIAL_DEVICE_DATA, *PCM_SERIAL_DEVICE_DATA;
-
-
-typedef struct _CM_FLOPPY_DEVICE_DATA
-{
- U16 Version;
- U16 Revision;
- CHAR Size[8];
- U32 MaxDensity;
- U32 MountDensity;
-
- /* Version 2.0 data */
- U8 StepRateHeadUnloadTime;
- U8 HeadLoadTime;
- U8 MotorOffTime;
- U8 SectorLengthCode;
- U8 SectorPerTrack;
- U8 ReadWriteGapLength;
- U8 DataTransferLength;
- U8 FormatGapLength;
- U8 FormatFillCharacter;
- U8 HeadSettleTime;
- U8 MotorSettleTime;
- U8 MaximumTrackValue;
- U8 DataTransferRate;
-} __attribute__((packed)) CM_FLOPPY_DEVICE_DATA, *PCM_FLOPPY_DEVICE_DATA;
-
-
-typedef struct _CM_KEYBOARD_DEVICE_DATA
-{
- U16 Version;
- U16 Revision;
- U8 Type;
- U8 Subtype;
- U16 KeyboardFlags;
-} __attribute__((packed)) CM_KEYBOARD_DEVICE_DATA, *PCM_KEYBOARD_DEVICE_DATA;
-
-
static char Hex[] = "0123456789ABCDEF";
static unsigned int delay_count = 1;
@@ -187,28 +134,28 @@ static unsigned int delay_count = 1;
static VOID
-__KeStallExecutionProcessor(U32 Loops)
+__StallExecutionProcessor(ULONG Loops)
{
register unsigned int i;
for (i = 0; i < Loops; i++);
}
-VOID KeStallExecutionProcessor(U32 Microseconds)
+VOID StallExecutionProcessor(ULONG Microseconds)
{
- U64 LoopCount = ((U64)delay_count * (U64)Microseconds) / 1000ULL;
- __KeStallExecutionProcessor((U32)LoopCount);
+ ULONGLONG LoopCount = ((ULONGLONG)delay_count * (ULONGLONG)Microseconds) / 1000ULL;
+ __StallExecutionProcessor((ULONG)LoopCount);
}
-static U32
+static ULONG
Read8254Timer(VOID)
{
- U32 Count;
+ ULONG Count;
- WRITE_PORT_UCHAR((PU8)0x43, 0x00);
- Count = READ_PORT_UCHAR((PU8)0x40);
- Count |= READ_PORT_UCHAR((PU8)0x40) << 8;
+ WRITE_PORT_UCHAR((PUCHAR)0x43, 0x00);
+ Count = READ_PORT_UCHAR((PUCHAR)0x40);
+ Count |= READ_PORT_UCHAR((PUCHAR)0x40) << 8;
return Count;
}
@@ -217,9 +164,9 @@ Read8254Timer(VOID)
static VOID
WaitFor8254Wraparound(VOID)
{
- U32 CurCount;
- U32 PrevCount = ~0;
- S32 Delta;
+ ULONG CurCount;
+ ULONG PrevCount = ~0;
+ LONG Delta;
CurCount = Read8254Timer();
@@ -242,14 +189,14 @@ WaitFor8254Wraparound(VOID)
VOID
HalpCalibrateStallExecution(VOID)
{
- U32 i;
- U32 calib_bit;
- U32 CurCount;
+ ULONG i;
+ ULONG calib_bit;
+ ULONG CurCount;
/* Initialise timer interrupt with MILLISECOND ms interval */
- WRITE_PORT_UCHAR((PU8)0x43, 0x34); /* binary, mode 2, LSB/MSB, ch 0 */
- WRITE_PORT_UCHAR((PU8)0x40, LATCH & 0xff); /* LSB */
- WRITE_PORT_UCHAR((PU8)0x40, LATCH >> 8); /* MSB */
+ WRITE_PORT_UCHAR((PUCHAR)0x43, 0x34); /* binary, mode 2, LSB/MSB, ch 0 */
+ WRITE_PORT_UCHAR((PUCHAR)0x40, LATCH & 0xff); /* LSB */
+ WRITE_PORT_UCHAR((PUCHAR)0x40, LATCH >> 8); /* MSB */
/* Stage 1: Coarse calibration */
@@ -262,7 +209,7 @@ HalpCalibrateStallExecution(VOID)
WaitFor8254Wraparound();
- __KeStallExecutionProcessor(delay_count); /* Do the delay */
+ __StallExecutionProcessor(delay_count); /* Do the delay */
CurCount = Read8254Timer();
} while (CurCount > LATCH / 2);
@@ -281,7 +228,7 @@ HalpCalibrateStallExecution(VOID)
WaitFor8254Wraparound();
- __KeStallExecutionProcessor(delay_count); /* Do the delay */
+ __StallExecutionProcessor(delay_count); /* Do the delay */
CurCount = Read8254Timer();
if (CurCount <= LATCH / 2) /* If a tick has passed, turn the */
@@ -294,13 +241,13 @@ HalpCalibrateStallExecution(VOID)
VOID
-SetComponentInformation(HKEY ComponentKey,
- U32 Flags,
- U32 Key,
- U32 Affinity)
+SetComponentInformation(FRLDRHKEY ComponentKey,
+ ULONG Flags,
+ ULONG Key,
+ ULONG Affinity)
{
CM_COMPONENT_INFORMATION CompInfo;
- S32 Error;
+ LONG Error;
CompInfo.Flags = Flags;
CompInfo.Version = 0;
@@ -311,7 +258,7 @@ SetComponentInformation(HKEY ComponentKey,
Error = RegSetValue(ComponentKey,
"Component Information",
REG_BINARY,
- (PU8)&CompInfo,
+ (PUCHAR)&CompInfo,
sizeof(CM_COMPONENT_INFORMATION));
if (Error != ERROR_SUCCESS)
{
@@ -321,23 +268,23 @@ SetComponentInformation(HKEY ComponentKey,
static VOID
-DetectPnpBios(HKEY SystemKey, U32 *BusNumber)
+DetectPnpBios(FRLDRHKEY SystemKey, ULONG *BusNumber)
{
PCM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor;
PCM_PNP_BIOS_DEVICE_NODE DeviceNode;
PCM_PNP_BIOS_INSTALLATION_CHECK InstData;
char Buffer[80];
- HKEY BusKey;
- U32 x;
- U32 NodeSize = 0;
- U32 NodeCount = 0;
- U8 NodeNumber;
- U32 FoundNodeCount;
+ FRLDRHKEY BusKey;
+ ULONG x;
+ ULONG NodeSize = 0;
+ ULONG NodeCount = 0;
+ UCHAR NodeNumber;
+ ULONG FoundNodeCount;
int i;
- U32 PnpBufferSize;
- U32 Size;
+ ULONG PnpBufferSize;
+ ULONG Size;
char *Ptr;
- S32 Error;
+ LONG Error;
InstData = (PCM_PNP_BIOS_INSTALLATION_CHECK)PnpBiosSupported();
if (InstData == NULL || strncmp(InstData->Signature, "$PnP", 4))
@@ -351,6 +298,9 @@ DetectPnpBios(HKEY SystemKey, U32 *BusNumber)
x = PnpBiosGetDeviceNodeCount(&NodeSize, &NodeCount);
+ NodeCount &= 0xFF; // needed since some fscked up BIOSes return
+ // wrong info (e.g. Mac Virtual PC)
+ // e.g. look: http://my.execpc.com/~geezer/osd/pnp/pnp16.c
if (x != 0 || NodeSize == 0 || NodeCount == 0)
{
DbgPrint((DPRINT_HWDETECT, "PnP-BIOS failed to enumerate device nodes\n"));
@@ -385,7 +335,7 @@ DetectPnpBios(HKEY SystemKey, U32 *BusNumber)
Error = RegSetValue(BusKey,
"Identifier",
REG_SZ,
- (PU8)"PNP BIOS",
+ (PUCHAR)"PNP BIOS",
9);
if (Error != ERROR_SUCCESS)
{
@@ -425,7 +375,7 @@ DetectPnpBios(HKEY SystemKey, U32 *BusNumber)
PnpBufferSize = sizeof(CM_PNP_BIOS_INSTALLATION_CHECK);
for (i = 0; i < 0xFF; i++)
{
- NodeNumber = (U8)i;
+ NodeNumber = (UCHAR)i;
x = PnpBiosGetDeviceNode(&NodeNumber, (PVOID)DISKREADBUFFER);
if (x == 0)
@@ -463,7 +413,7 @@ DetectPnpBios(HKEY SystemKey, U32 *BusNumber)
Error = RegSetValue(BusKey,
"Configuration Data",
REG_FULL_RESOURCE_DESCRIPTOR,
- (PU8) FullResourceDescriptor,
+ (PUCHAR) FullResourceDescriptor,
Size);
MmFreeMemory(FullResourceDescriptor);
if (Error != ERROR_SUCCESS)
@@ -477,15 +427,15 @@ DetectPnpBios(HKEY SystemKey, U32 *BusNumber)
static VOID
-SetHarddiskConfigurationData(HKEY DiskKey,
- U32 DriveNumber)
+SetHarddiskConfigurationData(FRLDRHKEY DiskKey,
+ ULONG DriveNumber)
{
PCM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor;
PCM_DISK_GEOMETRY_DEVICE_DATA DiskGeometry;
EXTENDED_GEOMETRY ExtGeometry;
GEOMETRY Geometry;
- U32 Size;
- S32 Error;
+ ULONG Size;
+ LONG Error;
/* Set 'Configuration Data' value */
Size = sizeof(CM_FULL_RESOURCE_DESCRIPTOR) +
@@ -545,7 +495,7 @@ SetHarddiskConfigurationData(HKEY DiskKey,
Error = RegSetValue(DiskKey,
"Configuration Data",
REG_FULL_RESOURCE_DESCRIPTOR,
- (PU8) FullResourceDescriptor,
+ (PUCHAR) FullResourceDescriptor,
Size);
MmFreeMemory(FullResourceDescriptor);
if (Error != ERROR_SUCCESS)
@@ -558,16 +508,16 @@ SetHarddiskConfigurationData(HKEY DiskKey,
static VOID
-SetHarddiskIdentifier(HKEY DiskKey,
- U32 DriveNumber)
+SetHarddiskIdentifier(FRLDRHKEY DiskKey,
+ ULONG DriveNumber)
{
PMASTER_BOOT_RECORD Mbr;
- U32 *Buffer;
- U32 i;
- U32 Checksum;
- U32 Signature;
+ ULONG *Buffer;
+ ULONG i;
+ ULONG Checksum;
+ ULONG Signature;
char Identifier[20];
- S32 Error;
+ LONG Error;
/* Read the MBR */
if (!MachDiskReadLogicalSectors(DriveNumber, 0ULL, 1, (PVOID)DISKREADBUFFER))
@@ -576,7 +526,7 @@ SetHarddiskIdentifier(HKEY DiskKey,
return;
}
- Buffer = (U32*)DISKREADBUFFER;
+ Buffer = (ULONG*)DISKREADBUFFER;
Mbr = (PMASTER_BOOT_RECORD)DISKREADBUFFER;
Signature = Mbr->Signature;
@@ -618,7 +568,7 @@ SetHarddiskIdentifier(HKEY DiskKey,
Error = RegSetValue(DiskKey,
"Identifier",
REG_SZ,
- (PU8) Identifier,
+ (PUCHAR) Identifier,
20);
if (Error != ERROR_SUCCESS)
{
@@ -630,18 +580,18 @@ SetHarddiskIdentifier(HKEY DiskKey,
static VOID
-DetectBiosDisks(HKEY SystemKey,
- HKEY BusKey)
+DetectBiosDisks(FRLDRHKEY SystemKey,
+ FRLDRHKEY BusKey)
{
PCM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor;
PCM_INT13_DRIVE_PARAMETER Int13Drives;
GEOMETRY Geometry;
CHAR Buffer[80];
- HKEY DiskKey;
- U32 DiskCount;
- U32 Size;
- U32 i;
- S32 Error;
+ FRLDRHKEY DiskKey;
+ ULONG DiskCount;
+ ULONG Size;
+ ULONG i;
+ LONG Error;
BOOL Changed;
/* Count the number of visible drives */
@@ -723,7 +673,7 @@ DetectBiosDisks(HKEY SystemKey,
Error = RegSetValue(SystemKey,
"Configuration Data",
REG_FULL_RESOURCE_DESCRIPTOR,
- (PU8) FullResourceDescriptor,
+ (PUCHAR) FullResourceDescriptor,
Size);
MmFreeMemory(FullResourceDescriptor);
if (Error != ERROR_SUCCESS)
@@ -759,10 +709,10 @@ DetectBiosDisks(HKEY SystemKey,
}
-static U32
+static ULONG
GetFloppyCount(VOID)
{
- U8 Data;
+ UCHAR Data;
WRITE_PORT_UCHAR((PUCHAR)0x70, 0x10);
Data = READ_PORT_UCHAR((PUCHAR)0x71);
@@ -771,10 +721,10 @@ GetFloppyCount(VOID)
}
-static U8
-GetFloppyType(U8 DriveNumber)
+static UCHAR
+GetFloppyType(UCHAR DriveNumber)
{
- U8 Data;
+ UCHAR Data;
WRITE_PORT_UCHAR((PUCHAR)0x70, 0x10);
Data = READ_PORT_UCHAR((PUCHAR)0x71);
@@ -791,28 +741,28 @@ GetFloppyType(U8 DriveNumber)
static PVOID
GetInt1eTable(VOID)
{
- PU16 SegPtr = (PU16)0x7A;
- PU16 OfsPtr = (PU16)0x78;
+ PUSHORT SegPtr = (PUSHORT)0x7A;
+ PUSHORT OfsPtr = (PUSHORT)0x78;
- return (PVOID)(((U32)(*SegPtr)) << 4) + (U32)(*OfsPtr);
+ return (PVOID)(((ULONG)(*SegPtr)) << 4) + (ULONG)(*OfsPtr);
}
static VOID
-DetectBiosFloppyPeripheral(HKEY ControllerKey)
+DetectBiosFloppyPeripheral(FRLDRHKEY ControllerKey)
{
PCM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor;
PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
PCM_FLOPPY_DEVICE_DATA FloppyData;
char KeyName[32];
char Identifier[20];
- HKEY PeripheralKey;
- U32 Size;
- S32 Error;
- U32 FloppyNumber;
- U8 FloppyType;
- U32 MaxDensity[6] = {0, 360, 1200, 720, 1440, 2880};
- PU8 Ptr;
+ FRLDRHKEY PeripheralKey;
+ ULONG Size;
+ LONG Error;
+ ULONG FloppyNumber;
+ UCHAR FloppyType;
+ ULONG MaxDensity[6] = {0, 360, 1200, 720, 1440, 2880};
+ PUCHAR Ptr;
for (FloppyNumber = 0; FloppyNumber < 2; FloppyNumber++)
{
@@ -879,7 +829,7 @@ DetectBiosFloppyPeripheral(HKEY ControllerKey)
Error = RegSetValue(PeripheralKey,
"Configuration Data",
REG_FULL_RESOURCE_DESCRIPTOR,
- (PU8) FullResourceDescriptor,
+ (PUCHAR) FullResourceDescriptor,
Size);
MmFreeMemory(FullResourceDescriptor);
if (Error != ERROR_SUCCESS)
@@ -895,7 +845,7 @@ DetectBiosFloppyPeripheral(HKEY ControllerKey)
Error = RegSetValue(PeripheralKey,
"Identifier",
REG_SZ,
- (PU8)Identifier,
+ (PUCHAR)Identifier,
strlen(Identifier) + 1);
if (Error != ERROR_SUCCESS)
{
@@ -908,15 +858,15 @@ DetectBiosFloppyPeripheral(HKEY ControllerKey)
static VOID
-DetectBiosFloppyController(HKEY SystemKey,
- HKEY BusKey)
+DetectBiosFloppyController(FRLDRHKEY SystemKey,
+ FRLDRHKEY BusKey)
{
PCM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor;
PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
- HKEY ControllerKey;
- U32 Size;
- S32 Error;
- U32 FloppyCount;
+ FRLDRHKEY ControllerKey;
+ ULONG Size;
+ LONG Error;
+ ULONG FloppyCount;
FloppyCount = GetFloppyCount();
DbgPrint((DPRINT_HWDETECT,
@@ -964,7 +914,8 @@ DetectBiosFloppyController(HKEY SystemKey,
PartialDescriptor->Type = CmResourceTypePort;
PartialDescriptor->ShareDisposition = CmResourceShareDeviceExclusive;
PartialDescriptor->Flags = CM_RESOURCE_PORT_IO;
- PartialDescriptor->u.Port.Start = (U64)0x03F0;
+ PartialDescriptor->u.Port.Start.LowPart = 0x03F0;
+ PartialDescriptor->u.Port.Start.HighPart = 0x0;
PartialDescriptor->u.Port.Length = 8;
/* Set Interrupt */
@@ -988,7 +939,7 @@ DetectBiosFloppyController(HKEY SystemKey,
Error = RegSetValue(ControllerKey,
"Configuration Data",
REG_FULL_RESOURCE_DESCRIPTOR,
- (PU8) FullResourceDescriptor,
+ (PUCHAR) FullResourceDescriptor,
Size);
MmFreeMemory(FullResourceDescriptor);
if (Error != ERROR_SUCCESS)
@@ -1004,8 +955,8 @@ DetectBiosFloppyController(HKEY SystemKey,
static VOID
-InitializeSerialPort(U32 Port,
- U32 LineControl)
+InitializeSerialPort(ULONG Port,
+ ULONG LineControl)
{
WRITE_PORT_UCHAR((PUCHAR)Port + 3, 0x80); /* set DLAB on */
WRITE_PORT_UCHAR((PUCHAR)Port, 0x60); /* speed LO byte */
@@ -1017,18 +968,18 @@ InitializeSerialPort(U32 Port,
}
-static U32
-DetectSerialMouse(U32 Port)
+static ULONG
+DetectSerialMouse(ULONG Port)
{
CHAR Buffer[4];
- U32 i;
- U32 TimeOut = 200;
- U8 LineControl;
+ ULONG i;
+ ULONG TimeOut = 200;
+ UCHAR LineControl;
/* Shutdown mouse or something like that */
LineControl = READ_PORT_UCHAR((PUCHAR)Port + 4);
WRITE_PORT_UCHAR((PUCHAR)Port + 4, (LineControl & ~0x02) | 0x01);
- KeStallExecutionProcessor(100000);
+ StallExecutionProcessor(100000);
/* Clear buffer */
while (READ_PORT_UCHAR((PUCHAR)Port + 5) & 0x01)
@@ -1041,14 +992,14 @@ DetectSerialMouse(U32 Port)
WRITE_PORT_UCHAR((PUCHAR)Port + 4, 0x0b);
/* Wait 10 milliseconds for the mouse getting ready */
- KeStallExecutionProcessor(10000);
+ StallExecutionProcessor(10000);
/* Read first four bytes, which contains Microsoft Mouse signs */
for (i = 0; i < 4; i++)
{
while (((READ_PORT_UCHAR((PUCHAR)Port + 5) & 1) == 0) && (TimeOut > 0))
{
- KeStallExecutionProcessor(1000);
+ StallExecutionProcessor(1000);
--TimeOut;
if (TimeOut == 0)
return MOUSE_TYPE_NONE;
@@ -1104,29 +1055,29 @@ DetectSerialMouse(U32 Port)
}
-static U32
-GetSerialMousePnpId(U32 Port, char *Buffer)
+static ULONG
+GetSerialMousePnpId(ULONG Port, char *Buffer)
{
- U32 TimeOut;
- U32 i = 0;
+ ULONG TimeOut;
+ ULONG i = 0;
char c;
char x;
WRITE_PORT_UCHAR((PUCHAR)Port + 4, 0x09);
/* Wait 10 milliseconds for the mouse getting ready */
- KeStallExecutionProcessor(10000);
+ StallExecutionProcessor(10000);
WRITE_PORT_UCHAR((PUCHAR)Port + 4, 0x0b);
- KeStallExecutionProcessor(10000);
+ StallExecutionProcessor(10000);
for (;;)
{
TimeOut = 200;
while (((READ_PORT_UCHAR((PUCHAR)Port + 5) & 1) == 0) && (TimeOut > 0))
{
- KeStallExecutionProcessor(1000);
+ StallExecutionProcessor(1000);
--TimeOut;
if (TimeOut == 0)
{
@@ -1147,7 +1098,7 @@ GetSerialMousePnpId(U32 Port, char *Buffer)
TimeOut = 200;
while (((READ_PORT_UCHAR((PUCHAR)Port + 5) & 1) == 0) && (TimeOut > 0))
{
- KeStallExecutionProcessor(1000);
+ StallExecutionProcessor(1000);
--TimeOut;
if (TimeOut == 0)
return 0;
@@ -1165,18 +1116,18 @@ GetSerialMousePnpId(U32 Port, char *Buffer)
static VOID
-DetectSerialPointerPeripheral(HKEY ControllerKey,
- U32 Base)
+DetectSerialPointerPeripheral(FRLDRHKEY ControllerKey,
+ ULONG Base)
{
CM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor;
char Buffer[256];
char Identifier[256];
- HKEY PeripheralKey;
- U32 MouseType;
- U32 Length;
- U32 i;
- U32 j;
- S32 Error;
+ FRLDRHKEY PeripheralKey;
+ ULONG MouseType;
+ ULONG Length;
+ ULONG i;
+ ULONG j;
+ LONG Error;
DbgPrint((DPRINT_HWDETECT,
"DetectSerialPointerPeripheral()\n"));
@@ -1329,7 +1280,7 @@ DetectSerialPointerPeripheral(HKEY ControllerKey,
Error = RegSetValue(PeripheralKey,
"Configuration Data",
REG_FULL_RESOURCE_DESCRIPTOR,
- (PU8)&FullResourceDescriptor,
+ (PUCHAR)&FullResourceDescriptor,
sizeof(CM_FULL_RESOURCE_DESCRIPTOR) -
sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR));
if (Error != ERROR_SUCCESS)
@@ -1343,7 +1294,7 @@ DetectSerialPointerPeripheral(HKEY ControllerKey,
Error = RegSetValue(PeripheralKey,
"Identifier",
REG_SZ,
- (PU8)Identifier,
+ (PUCHAR)Identifier,
strlen(Identifier) + 1);
if (Error != ERROR_SUCCESS)
{
@@ -1356,28 +1307,28 @@ DetectSerialPointerPeripheral(HKEY ControllerKey,
static VOID
-DetectSerialPorts(HKEY BusKey)
+DetectSerialPorts(FRLDRHKEY BusKey)
{
PCM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor;
PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
PCM_SERIAL_DEVICE_DATA SerialDeviceData;
- U32 Irq[4] = {4, 3, 4, 3};
- U32 Base;
+ ULONG Irq[4] = {4, 3, 4, 3};
+ ULONG Base;
char Buffer[80];
- PU16 BasePtr;
- U32 ControllerNumber = 0;
- HKEY ControllerKey;
- U32 i;
- S32 Error;
- U32 Size;
+ PUSHORT BasePtr;
+ ULONG ControllerNumber = 0;
+ FRLDRHKEY ControllerKey;
+ ULONG i;
+ LONG Error;
+ ULONG Size;
DbgPrint((DPRINT_HWDETECT, "DetectSerialPorts()\n"));
ControllerNumber = 0;
- BasePtr = (PU16)0x400;
+ BasePtr = (PUSHORT)0x400;
for (i = 0; i < 4; i++, BasePtr++)
{
- Base = (U32)*BasePtr;
+ Base = (ULONG)*BasePtr;
if (Base == 0)
continue;
@@ -1430,7 +1381,8 @@ DetectSerialPorts(HKEY BusKey)
PartialDescriptor->Type = CmResourceTypePort;
PartialDescriptor->ShareDisposition = CmResourceShareDeviceExclusive;
PartialDescriptor->Flags = CM_RESOURCE_PORT_IO;
- PartialDescriptor->u.Port.Start = (U64)Base;
+ PartialDescriptor->u.Port.Start.LowPart = Base;
+ PartialDescriptor->u.Port.Start.HighPart = 0x0;
PartialDescriptor->u.Port.Length = 7;
/* Set Interrupt */
@@ -1457,7 +1409,7 @@ DetectSerialPorts(HKEY BusKey)
Error = RegSetValue(ControllerKey,
"Configuration Data",
REG_FULL_RESOURCE_DESCRIPTOR,
- (PU8) FullResourceDescriptor,
+ (PUCHAR) FullResourceDescriptor,
Size);
MmFreeMemory(FullResourceDescriptor);
if (Error != ERROR_SUCCESS)
@@ -1474,7 +1426,7 @@ DetectSerialPorts(HKEY BusKey)
Error = RegSetValue(ControllerKey,
"Identifier",
REG_SZ,
- (PU8)Buffer,
+ (PUCHAR)Buffer,
strlen(Buffer) + 1);
if (Error != ERROR_SUCCESS)
{
@@ -1496,27 +1448,27 @@ DetectSerialPorts(HKEY BusKey)
static VOID
-DetectParallelPorts(HKEY BusKey)
+DetectParallelPorts(FRLDRHKEY BusKey)
{
PCM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor;
PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
- U32 Irq[3] = {7, 5, (U32)-1};
+ ULONG Irq[3] = {7, 5, (ULONG)-1};
char Buffer[80];
- HKEY ControllerKey;
- PU16 BasePtr;
- U32 Base;
- U32 ControllerNumber;
- U32 i;
- S32 Error;
- U32 Size;
+ FRLDRHKEY ControllerKey;
+ PUSHORT BasePtr;
+ ULONG Base;
+ ULONG ControllerNumber;
+ ULONG i;
+ LONG Error;
+ ULONG Size;
DbgPrint((DPRINT_HWDETECT, "DetectParallelPorts() called\n"));
ControllerNumber = 0;
- BasePtr = (PU16)0x408;
+ BasePtr = (PUSHORT)0x408;
for (i = 0; i < 3; i++, BasePtr++)
{
- Base = (U32)*BasePtr;
+ Base = (ULONG)*BasePtr;
if (Base == 0)
continue;
@@ -1548,7 +1500,7 @@ DetectParallelPorts(HKEY BusKey)
/* Build full device descriptor */
Size = sizeof(CM_FULL_RESOURCE_DESCRIPTOR);
- if (Irq[i] != (U32)-1)
+ if (Irq[i] != (ULONG)-1)
Size += sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR);
FullResourceDescriptor = MmAllocateMemory(Size);
@@ -1563,18 +1515,19 @@ DetectParallelPorts(HKEY BusKey)
/* Initialize resource descriptor */
FullResourceDescriptor->InterfaceType = Isa;
FullResourceDescriptor->BusNumber = 0;
- FullResourceDescriptor->PartialResourceList.Count = (Irq[i] != (U32)-1) ? 2 : 1;
+ FullResourceDescriptor->PartialResourceList.Count = (Irq[i] != (ULONG)-1) ? 2 : 1;
/* Set IO Port */
PartialDescriptor = &FullResourceDescriptor->PartialResourceList.PartialDescriptors[0];
PartialDescriptor->Type = CmResourceTypePort;
PartialDescriptor->ShareDisposition = CmResourceShareDeviceExclusive;
PartialDescriptor->Flags = CM_RESOURCE_PORT_IO;
- PartialDescriptor->u.Port.Start = (U64)Base;
+ PartialDescriptor->u.Port.Start.LowPart = Base;
+ PartialDescriptor->u.Port.Start.HighPart = 0x0;
PartialDescriptor->u.Port.Length = 3;
/* Set Interrupt */
- if (Irq[i] != (U32)-1)
+ if (Irq[i] != (ULONG)-1)
{
PartialDescriptor = &FullResourceDescriptor->PartialResourceList.PartialDescriptors[1];
PartialDescriptor->Type = CmResourceTypeInterrupt;
@@ -1589,7 +1542,7 @@ DetectParallelPorts(HKEY BusKey)
Error = RegSetValue(ControllerKey,
"Configuration Data",
REG_FULL_RESOURCE_DESCRIPTOR,
- (PU8) FullResourceDescriptor,
+ (PUCHAR) FullResourceDescriptor,
Size);
MmFreeMemory(FullResourceDescriptor);
if (Error != ERROR_SUCCESS)
@@ -1606,7 +1559,7 @@ DetectParallelPorts(HKEY BusKey)
Error = RegSetValue(ControllerKey,
"Identifier",
REG_SZ,
- (PU8)Buffer,
+ (PUCHAR)Buffer,
strlen(Buffer) + 1);
if (Error != ERROR_SUCCESS)
{
@@ -1635,7 +1588,7 @@ DetectKeyboardDevice(VOID)
WRITE_PORT_UCHAR((PUCHAR)CONTROLLER_REGISTER_DATA,
0xF2);
- KeStallExecutionProcessor(10000);
+ StallExecutionProcessor(10000);
Status = READ_PORT_UCHAR((PUCHAR)CONTROLLER_REGISTER_STATUS);
if ((Status & 0x01) != 0x01)
@@ -1651,7 +1604,7 @@ DetectKeyboardDevice(VOID)
return FALSE;
}
- KeStallExecutionProcessor(10000);
+ StallExecutionProcessor(10000);
Status = READ_PORT_UCHAR((PUCHAR)CONTROLLER_REGISTER_STATUS);
if ((Status & 0x01) != 0x01)
{
@@ -1666,7 +1619,7 @@ DetectKeyboardDevice(VOID)
return FALSE;
}
- KeStallExecutionProcessor(10000);
+ StallExecutionProcessor(10000);
Status = READ_PORT_UCHAR((PUCHAR)CONTROLLER_REGISTER_STATUS);
if ((Status & 0x01) != 0x01)
{
@@ -1687,15 +1640,15 @@ DetectKeyboardDevice(VOID)
static VOID
-DetectKeyboardPeripheral(HKEY ControllerKey)
+DetectKeyboardPeripheral(FRLDRHKEY ControllerKey)
{
PCM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor;
PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
PCM_KEYBOARD_DEVICE_DATA KeyboardData;
- HKEY PeripheralKey;
+ FRLDRHKEY PeripheralKey;
char Buffer[80];
- U32 Size;
- S32 Error;
+ ULONG Size;
+ LONG Error;
if (DetectKeyboardDevice())
{
@@ -1749,7 +1702,7 @@ DetectKeyboardPeripheral(HKEY ControllerKey)
Error = RegSetValue(PeripheralKey,
"Configuration Data",
REG_FULL_RESOURCE_DESCRIPTOR,
- (PU8)FullResourceDescriptor,
+ (PUCHAR)FullResourceDescriptor,
Size);
MmFreeMemory(FullResourceDescriptor);
if (Error != ERROR_SUCCESS)
@@ -1765,7 +1718,7 @@ DetectKeyboardPeripheral(HKEY ControllerKey)
Error = RegSetValue(ControllerKey,
"Identifier",
REG_SZ,
- (PU8)Buffer,
+ (PUCHAR)Buffer,
strlen(Buffer) + 1);
if (Error != ERROR_SUCCESS)
{
@@ -1778,13 +1731,13 @@ DetectKeyboardPeripheral(HKEY ControllerKey)
static VOID
-DetectKeyboardController(HKEY BusKey)
+DetectKeyboardController(FRLDRHKEY BusKey)
{
PCM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor;
PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
- HKEY ControllerKey;
- U32 Size;
- S32 Error;
+ FRLDRHKEY ControllerKey;
+ ULONG Size;
+ LONG Error;
/* Create controller key */
Error = RegCreateKey(BusKey,
@@ -1834,7 +1787,8 @@ DetectKeyboardController(HKEY BusKey)
PartialDescriptor->Type = CmResourceTypePort;
PartialDescriptor->ShareDisposition = CmResourceShareDeviceExclusive;
PartialDescriptor->Flags = CM_RESOURCE_PORT_IO;
- PartialDescriptor->u.Port.Start = (U64)0x60;
+ PartialDescriptor->u.Port.Start.LowPart = 0x60;
+ PartialDescriptor->u.Port.Start.HighPart = 0x0;
PartialDescriptor->u.Port.Length = 1;
/* Set IO Port 0x64 */
@@ -1842,14 +1796,15 @@ DetectKeyboardController(HKEY BusKey)
PartialDescriptor->Type = CmResourceTypePort;
PartialDescriptor->ShareDisposition = CmResourceShareDeviceExclusive;
PartialDescriptor->Flags = CM_RESOURCE_PORT_IO;
- PartialDescriptor->u.Port.Start = (U64)0x64;
+ PartialDescriptor->u.Port.Start.LowPart = 0x64;
+ PartialDescriptor->u.Port.Start.HighPart = 0x0;
PartialDescriptor->u.Port.Length = 1;
/* Set 'Configuration Data' value */
Error = RegSetValue(ControllerKey,
"Configuration Data",
REG_FULL_RESOURCE_DESCRIPTOR,
- (PU8)FullResourceDescriptor,
+ (PUCHAR)FullResourceDescriptor,
Size);
MmFreeMemory(FullResourceDescriptor);
if (Error != ERROR_SUCCESS)
@@ -1867,8 +1822,8 @@ DetectKeyboardController(HKEY BusKey)
static VOID
PS2ControllerWait(VOID)
{
- U32 Timeout;
- U8 Status;
+ ULONG Timeout;
+ UCHAR Status;
for (Timeout = 0; Timeout < CONTROLLER_TIMEOUT; Timeout++)
{
@@ -1877,7 +1832,7 @@ PS2ControllerWait(VOID)
return;
/* Sleep for one millisecond */
- KeStallExecutionProcessor(1000);
+ StallExecutionProcessor(1000);
}
}
@@ -1885,9 +1840,9 @@ PS2ControllerWait(VOID)
static BOOLEAN
DetectPS2AuxPort(VOID)
{
- U32 Loops;
- U8 Scancode;
- U8 Status;
+ ULONG Loops;
+ UCHAR Scancode;
+ UCHAR Status;
/* Put the value 0x5A in the output buffer using the
* "WriteAuxiliary Device Output Buffer" command (0xD3).
@@ -1919,7 +1874,7 @@ DetectPS2AuxPort(VOID)
break;
}
- KeStallExecutionProcessor(10000);
+ StallExecutionProcessor(10000);
}
return FALSE;
@@ -1929,8 +1884,8 @@ DetectPS2AuxPort(VOID)
static BOOLEAN
DetectPS2AuxDevice(VOID)
{
- U8 Scancode;
- U8 Status;
+ UCHAR Scancode;
+ UCHAR Status;
PS2ControllerWait();
WRITE_PORT_UCHAR((PUCHAR)CONTROLLER_REGISTER_CONTROL,
@@ -1941,7 +1896,7 @@ DetectPS2AuxDevice(VOID)
WRITE_PORT_UCHAR((PUCHAR)CONTROLLER_REGISTER_DATA,
0xF2);
- KeStallExecutionProcessor(10000);
+ StallExecutionProcessor(10000);
Status = READ_PORT_UCHAR((PUCHAR)CONTROLLER_REGISTER_STATUS);
if ((Status & CONTROLLER_STATUS_MOUSE_OUTPUT_BUFFER_FULL) == 0)
@@ -1953,7 +1908,7 @@ DetectPS2AuxDevice(VOID)
if (Scancode != 0xFA)
return FALSE;
- KeStallExecutionProcessor(10000);
+ StallExecutionProcessor(10000);
Status = READ_PORT_UCHAR((PUCHAR)CONTROLLER_REGISTER_STATUS);
if ((Status & CONTROLLER_STATUS_MOUSE_OUTPUT_BUFFER_FULL) == 0)
@@ -1970,12 +1925,12 @@ DetectPS2AuxDevice(VOID)
static VOID
-DetectPS2Mouse(HKEY BusKey)
+DetectPS2Mouse(FRLDRHKEY BusKey)
{
CM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor;
- HKEY ControllerKey;
- HKEY PeripheralKey;
- S32 Error;
+ FRLDRHKEY ControllerKey;
+ FRLDRHKEY PeripheralKey;
+ LONG Error;
if (DetectPS2AuxPort())
{
@@ -2017,7 +1972,7 @@ DetectPS2Mouse(HKEY BusKey)
Error = RegSetValue(ControllerKey,
"Configuration Data",
REG_FULL_RESOURCE_DESCRIPTOR,
- (PU8)&FullResourceDescriptor,
+ (PUCHAR)&FullResourceDescriptor,
sizeof(CM_FULL_RESOURCE_DESCRIPTOR));
if (Error != ERROR_SUCCESS)
{
@@ -2059,7 +2014,7 @@ DetectPS2Mouse(HKEY BusKey)
Error = RegSetValue(PeripheralKey,
"Configuration Data",
REG_FULL_RESOURCE_DESCRIPTOR,
- (PU8)&FullResourceDescriptor,
+ (PUCHAR)&FullResourceDescriptor,
sizeof(CM_FULL_RESOURCE_DESCRIPTOR) -
sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR));
if (Error != ERROR_SUCCESS)
@@ -2074,7 +2029,7 @@ DetectPS2Mouse(HKEY BusKey)
Error = RegSetValue(PeripheralKey,
"Identifier",
REG_SZ,
- (PU8)"MICROSOFT PS2 MOUSE",
+ (PUCHAR)"MICROSOFT PS2 MOUSE",
20);
if (Error != ERROR_SUCCESS)
{
@@ -2089,12 +2044,12 @@ DetectPS2Mouse(HKEY BusKey)
static VOID
-DetectDisplayController(HKEY BusKey)
+DetectDisplayController(FRLDRHKEY BusKey)
{
CHAR Buffer[80];
- HKEY ControllerKey;
- U16 VesaVersion;
- S32 Error;
+ FRLDRHKEY ControllerKey;
+ USHORT VesaVersion;
+ LONG Error;
Error = RegCreateKey(BusKey,
"DisplayController\\0",
@@ -2143,7 +2098,7 @@ DetectDisplayController(HKEY BusKey)
Error = RegSetValue(ControllerKey,
"Identifier",
REG_SZ,
- (PU8)Buffer,
+ (PUCHAR)Buffer,
strlen(Buffer) + 1);
if (Error != ERROR_SUCCESS)
{
@@ -2158,13 +2113,13 @@ DetectDisplayController(HKEY BusKey)
static VOID
-DetectIsaBios(HKEY SystemKey, U32 *BusNumber)
+DetectIsaBios(FRLDRHKEY SystemKey, ULONG *BusNumber)
{
PCM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor;
char Buffer[80];
- HKEY BusKey;
- U32 Size;
- S32 Error;
+ FRLDRHKEY BusKey;
+ ULONG Size;
+ LONG Error;
/* Create new bus key */
sprintf(Buffer,
@@ -2191,7 +2146,7 @@ DetectIsaBios(HKEY SystemKey, U32 *BusNumber)
Error = RegSetValue(BusKey,
"Identifier",
REG_SZ,
- (PU8)"ISA",
+ (PUCHAR)"ISA",
4);
if (Error != ERROR_SUCCESS)
{
@@ -2220,7 +2175,7 @@ DetectIsaBios(HKEY SystemKey, U32 *BusNumber)
Error = RegSetValue(BusKey,
"Configuration Data",
REG_FULL_RESOURCE_DESCRIPTOR,
- (PU8) FullResourceDescriptor,
+ (PUCHAR) FullResourceDescriptor,
Size);
MmFreeMemory(FullResourceDescriptor);
if (Error != ERROR_SUCCESS)
@@ -2253,9 +2208,9 @@ DetectIsaBios(HKEY SystemKey, U32 *BusNumber)
VOID
PcHwDetect(VOID)
{
- HKEY SystemKey;
- U32 BusNumber = 0;
- S32 Error;
+ FRLDRHKEY SystemKey;
+ ULONG BusNumber = 0;
+ LONG Error;
DbgPrint((DPRINT_HWDETECT, "DetectHardware()\n"));
diff --git a/reactos/boot/freeldr/freeldr/arch/i386/hardware.h b/reactos/boot/freeldr/freeldr/arch/i386/hardware.h
index fe5720a5f29..49a39dd893d 100644
--- a/reactos/boot/freeldr/freeldr/arch/i386/hardware.h
+++ b/reactos/boot/freeldr/freeldr/arch/i386/hardware.h
@@ -25,91 +25,6 @@
#include "../../reactos/registry.h"
#endif
-typedef enum
-{
- InterfaceTypeUndefined = -1,
- Internal,
- Isa,
- Eisa,
- MicroChannel,
- TurboChannel,
- PCIBus,
- VMEBus,
- NuBus,
- PCMCIABus,
- CBus,
- MPIBus,
- MPSABus,
- ProcessorInternal,
- InternalPowerBus,
- PNPISABus,
- MaximumInterfaceType
-} INTERFACE_TYPE, *PINTERFACE_TYPE;
-
-
-typedef enum _CM_RESOURCE_TYPE
-{
- CmResourceTypeNull = 0,
- CmResourceTypePort,
- CmResourceTypeInterrupt,
- CmResourceTypeMemory,
- CmResourceTypeDma,
- CmResourceTypeDeviceSpecific,
- CmResourceTypeMaximum
-} CM_RESOURCE_TYPE;
-
-
-typedef enum _CM_SHARE_DISPOSITION
-{
- CmResourceShareUndetermined = 0,
- CmResourceShareDeviceExclusive,
- CmResourceShareDriverExclusive,
- CmResourceShareShared
-} CM_SHARE_DISPOSITION;
-
-
-typedef U64 PHYSICAL_ADDRESS;
-
-
-typedef struct
-{
- U8 Type;
- U8 ShareDisposition;
- U16 Flags;
- union
- {
- struct
- {
- PHYSICAL_ADDRESS Start;
- U32 Length;
- } __attribute__((packed)) Port;
- struct
- {
- U32 Level;
- U32 Vector;
- U32 Affinity;
- } __attribute__((packed)) Interrupt;
- struct
- {
- PHYSICAL_ADDRESS Start;
- U32 Length;
- } __attribute__((packed)) Memory;
- struct
- {
- U32 Channel;
- U32 Port;
- U32 Reserved1;
- } __attribute__((packed)) Dma;
- struct
- {
- U32 DataSize;
- U32 Reserved1;
- U32 Reserved2;
- } __attribute__((packed)) DeviceSpecificData;
- } __attribute__((packed)) u;
-} __attribute__((packed)) CM_PARTIAL_RESOURCE_DESCRIPTOR, *PCM_PARTIAL_RESOURCE_DESCRIPTOR;
-
-
/* CM_PARTIAL_RESOURCE_DESCRIPTOR.Flags */
#define CM_RESOURCE_PORT_MEMORY 0x0000
#define CM_RESOURCE_PORT_IO 0x0001
@@ -117,30 +32,12 @@ typedef struct
#define CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE 0x0000
#define CM_RESOURCE_INTERRUPT_LATCHED 0x0001
-
-typedef struct
-{
- U16 Version;
- U16 Revision;
- U32 Count;
- CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1];
-} __attribute__((packed))CM_PARTIAL_RESOURCE_LIST, *PCM_PARTIAL_RESOURCE_LIST;
-
-
-typedef struct
-{
- INTERFACE_TYPE InterfaceType;
- U32 BusNumber;
- CM_PARTIAL_RESOURCE_LIST PartialResourceList;
-} __attribute__((packed)) CM_FULL_RESOURCE_DESCRIPTOR, *PCM_FULL_RESOURCE_DESCRIPTOR;
-
-
typedef struct _CM_COMPONENT_INFORMATION
{
- U32 Flags;
- U32 Version;
- U32 Key;
- U32 Affinity;
+ ULONG Flags;
+ ULONG Version;
+ ULONG Key;
+ ULONG Affinity;
} __attribute__((packed)) CM_COMPONENT_INFORMATION, *PCM_COMPONENT_INFORMATION;
@@ -154,46 +51,48 @@ typedef struct _CM_COMPONENT_INFORMATION
#define Output 0x00000040
#define CONFIG_CMD(bus, dev_fn, where) \
- (0x80000000 | (((U32)(bus)) << 16) | (((dev_fn) & 0x1F) << 11) | (((dev_fn) & 0xE0) << 3) | ((where) & ~3))
+ (0x80000000 | (((ULONG)(bus)) << 16) | (((dev_fn) & 0x1F) << 11) | (((dev_fn) & 0xE0) << 3) | ((where) & ~3))
/* PROTOTYPES ***************************************************************/
/* hardware.c */
-VOID HalpCalibrateStallExecution(VOID);
-VOID KeStallExecutionProcessor(U32 Microseconds);
-VOID SetComponentInformation(HKEY ComponentKey,
- U32 Flags,
- U32 Key,
- U32 Affinity);
+VOID StallExecutionProcessor(ULONG Microseconds);
+
+VOID HalpCalibrateStallExecution(VOID);
+
+VOID SetComponentInformation(FRLDRHKEY ComponentKey,
+ ULONG Flags,
+ ULONG Key,
+ ULONG Affinity);
/* hwacpi.c */
-VOID DetectAcpiBios(HKEY SystemKey, U32 *BusNumber);
+VOID DetectAcpiBios(FRLDRHKEY SystemKey, ULONG *BusNumber);
/* hwapm.c */
-VOID DetectApmBios(HKEY SystemKey, U32 *BusNumber);
+VOID DetectApmBios(FRLDRHKEY SystemKey, ULONG *BusNumber);
/* hwcpu.c */
-VOID DetectCPUs(HKEY SystemKey);
+VOID DetectCPUs(FRLDRHKEY SystemKey);
/* hwpci.c */
-VOID DetectPciBios(HKEY SystemKey, U32 *BusNumber);
+VOID DetectPciBios(FRLDRHKEY SystemKey, ULONG *BusNumber);
/* i386cpu.S */
-U32 CpuidSupported(VOID);
-VOID GetCpuid(U32 Level,
- U32 *eax,
- U32 *ebx,
- U32 *ecx,
- U32 *edx);
-U64 RDTSC(VOID);
+ULONG CpuidSupported(VOID);
+VOID GetCpuid(ULONG Level,
+ ULONG *eax,
+ ULONG *ebx,
+ ULONG *ecx,
+ ULONG *edx);
+ULONGLONG RDTSC(VOID);
/* i386pnp.S */
-U32 PnpBiosSupported(VOID);
-U32 PnpBiosGetDeviceNodeCount(U32 *NodeSize,
- U32 *NodeCount);
-U32 PnpBiosGetDeviceNode(U8 *NodeId,
- U8 *NodeBuffer);
+ULONG PnpBiosSupported(VOID);
+ULONG PnpBiosGetDeviceNodeCount(ULONG *NodeSize,
+ ULONG *NodeCount);
+ULONG PnpBiosGetDeviceNode(UCHAR *NodeId,
+ UCHAR *NodeBuffer);
#endif /* __I386_HARDWARE_H_ */
diff --git a/reactos/boot/freeldr/freeldr/arch/i386/hwacpi.c b/reactos/boot/freeldr/freeldr/arch/i386/hwacpi.c
index c8dacbc1a68..733f71a8a36 100644
--- a/reactos/boot/freeldr/freeldr/arch/i386/hwacpi.c
+++ b/reactos/boot/freeldr/freeldr/arch/i386/hwacpi.c
@@ -32,11 +32,11 @@
static BOOL
FindAcpiBios(VOID)
{
- PU8 Ptr;
+ PUCHAR Ptr;
/* Find the 'Root System Descriptor Table Pointer' */
- Ptr = (PU8)0xE0000;
- while ((U32)Ptr < 0x100000)
+ Ptr = (PUCHAR)0xE0000;
+ while ((ULONG)Ptr < 0x100000)
{
if (!memcmp(Ptr, "RSD PTR ", 8))
{
@@ -45,7 +45,7 @@ FindAcpiBios(VOID)
return TRUE;
}
- Ptr = (PU8)((U32)Ptr + 0x10);
+ Ptr = (PUCHAR)((ULONG)Ptr + 0x10);
}
DbgPrint((DPRINT_HWDETECT, "ACPI not supported\n"));
@@ -55,11 +55,11 @@ FindAcpiBios(VOID)
VOID
-DetectAcpiBios(HKEY SystemKey, U32 *BusNumber)
+DetectAcpiBios(FRLDRHKEY SystemKey, ULONG *BusNumber)
{
char Buffer[80];
- HKEY BiosKey;
- S32 Error;
+ FRLDRHKEY BiosKey;
+ LONG Error;
if (FindAcpiBios())
{
@@ -90,7 +90,7 @@ DetectAcpiBios(HKEY SystemKey, U32 *BusNumber)
Error = RegSetValue(BiosKey,
"Identifier",
REG_SZ,
- (PU8)"ACPI BIOS",
+ (PUCHAR)"ACPI BIOS",
10);
if (Error != ERROR_SUCCESS)
{
diff --git a/reactos/boot/freeldr/freeldr/arch/i386/hwapm.c b/reactos/boot/freeldr/freeldr/arch/i386/hwapm.c
index 7da6d7d48f4..a4c43b18247 100644
--- a/reactos/boot/freeldr/freeldr/arch/i386/hwapm.c
+++ b/reactos/boot/freeldr/freeldr/arch/i386/hwapm.c
@@ -60,11 +60,11 @@ FindApmBios(VOID)
VOID
-DetectApmBios(HKEY SystemKey, U32 *BusNumber)
+DetectApmBios(FRLDRHKEY SystemKey, ULONG *BusNumber)
{
char Buffer[80];
- HKEY BiosKey;
- S32 Error;
+ FRLDRHKEY BiosKey;
+ LONG Error;
if (FindApmBios())
{
@@ -95,7 +95,7 @@ DetectApmBios(HKEY SystemKey, U32 *BusNumber)
Error = RegSetValue(BiosKey,
"Identifier",
REG_SZ,
- (PU8)"APM",
+ (PUCHAR)"APM",
4);
if (Error != ERROR_SUCCESS)
{
diff --git a/reactos/boot/freeldr/freeldr/arch/i386/hwcpu.c b/reactos/boot/freeldr/freeldr/arch/i386/hwcpu.c
index 80ed3f482ed..072d60d7b7d 100644
--- a/reactos/boot/freeldr/freeldr/arch/i386/hwcpu.c
+++ b/reactos/boot/freeldr/freeldr/arch/i386/hwcpu.c
@@ -35,60 +35,60 @@
typedef struct _MP_FLOATING_POINT_TABLE
{
- U32 Signature; /* "_MP_" */
- U32 PhysicalAddressPointer;
- U8 Length;
- U8 SpecRev;
- U8 Checksum;
- U8 FeatureByte[5];
+ ULONG Signature; /* "_MP_" */
+ ULONG PhysicalAddressPointer;
+ UCHAR Length;
+ UCHAR SpecRev;
+ UCHAR Checksum;
+ UCHAR FeatureByte[5];
} PACKED MP_FLOATING_POINT_TABLE, *PMP_FLOATING_POINT_TABLE;
typedef struct _MPS_CONFIG_TABLE_HEADER
{
- U32 Signature; /* "PCMP" */
- U16 BaseTableLength;
- U8 SpecRev;
- U8 Checksum;
- U8 OemIdString[8];
- U8 ProductIdString[12];
- U32 OemTablePointer;
- U16 OemTableLength;
- U16 EntryCount;
- U32 AddressOfLocalAPIC;
- U16 ExtendedTableLength;
- U8 ExtendedTableChecksum;
- U8 Reserved;
+ ULONG Signature; /* "PCMP" */
+ USHORT BaseTableLength;
+ UCHAR SpecRev;
+ UCHAR Checksum;
+ UCHAR OemIdString[8];
+ UCHAR ProductIdString[12];
+ ULONG OemTablePointer;
+ USHORT OemTableLength;
+ USHORT EntryCount;
+ ULONG AddressOfLocalAPIC;
+ USHORT ExtendedTableLength;
+ UCHAR ExtendedTableChecksum;
+ UCHAR Reserved;
} PACKED MP_CONFIGURATION_TABLE, *PMP_CONFIGURATION_TABLE;
typedef struct _MP_PROCESSOR_ENTRY
{
- U8 EntryType;
- U8 LocalApicId;
- U8 LocalApicVersion;
- U8 CpuFlags;
- U32 CpuSignature;
- U32 FeatureFlags;
- U32 Reserved1;
- U32 Reserved2;
+ UCHAR EntryType;
+ UCHAR LocalApicId;
+ UCHAR LocalApicVersion;
+ UCHAR CpuFlags;
+ ULONG CpuSignature;
+ ULONG FeatureFlags;
+ ULONG Reserved1;
+ ULONG Reserved2;
} PACKED MP_PROCESSOR_ENTRY, *PMP_PROCESSOR_ENTRY;
/* FUNCTIONS ****************************************************************/
-static U32
+static ULONG
GetCpuSpeed(VOID)
{
- U64 Timestamp1;
- U64 Timestamp2;
- U64 Diff;
+ ULONGLONG Timestamp1;
+ ULONGLONG Timestamp2;
+ ULONGLONG Diff;
/* Read TSC (Time Stamp Counter) */
Timestamp1 = RDTSC();
/* Wait for 0.1 seconds (= 100 milliseconds = 100000 microseconds)*/
- KeStallExecutionProcessor(100000);
+ StallExecutionProcessor(100000);
/* Read TSC (Time Stamp Counter) again */
Timestamp2 = RDTSC();
@@ -100,30 +100,30 @@ GetCpuSpeed(VOID)
}
else
{
- Diff = Timestamp2 + (((U64)-1) - Timestamp1);
+ Diff = Timestamp2 + (((ULONGLONG)-1) - Timestamp1);
}
- return (U32)(Diff / 100000);
+ return (ULONG)(Diff / 100000);
}
static VOID
-DetectCPU(HKEY CpuKey,
- HKEY FpuKey)
+DetectCPU(FRLDRHKEY CpuKey,
+ FRLDRHKEY FpuKey)
{
char VendorIdentifier[13];
char Identifier[64];
- U32 FeatureSet;
- HKEY CpuInstKey;
- HKEY FpuInstKey;
- U32 eax = 0;
- U32 ebx = 0;
- U32 ecx = 0;
- U32 edx = 0;
- U32 *Ptr;
- S32 Error;
+ ULONG FeatureSet;
+ FRLDRHKEY CpuInstKey;
+ FRLDRHKEY FpuInstKey;
+ ULONG eax = 0;
+ ULONG ebx = 0;
+ ULONG ecx = 0;
+ ULONG edx = 0;
+ ULONG *Ptr;
+ LONG Error;
BOOL SupportTSC = FALSE;
- U32 CpuSpeed;
+ ULONG CpuSpeed;
/* Create the CPU instance key */
@@ -154,7 +154,7 @@ DetectCPU(HKEY CpuKey,
/* Get vendor identifier */
GetCpuid(0, &eax, &ebx, &ecx, &edx);
VendorIdentifier[12] = 0;
- Ptr = (U32*)&VendorIdentifier[0];
+ Ptr = (ULONG*)&VendorIdentifier[0];
*Ptr = ebx;
Ptr++;
*Ptr = edx;
@@ -195,8 +195,8 @@ DetectCPU(HKEY CpuKey,
Error = RegSetValue(CpuInstKey,
"FeatureSet",
REG_DWORD,
- (PU8)&FeatureSet,
- sizeof(U32));
+ (PUCHAR)&FeatureSet,
+ sizeof(ULONG));
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT, "RegSetValue() failed (Error %u)\n", (int)Error));
@@ -208,7 +208,7 @@ DetectCPU(HKEY CpuKey,
Error = RegSetValue(CpuInstKey,
"Identifier",
REG_SZ,
- (PU8)Identifier,
+ (PUCHAR)Identifier,
strlen(Identifier) + 1);
if (Error != ERROR_SUCCESS)
{
@@ -218,7 +218,7 @@ DetectCPU(HKEY CpuKey,
Error = RegSetValue(FpuInstKey,
"Identifier",
REG_SZ,
- (PU8)Identifier,
+ (PUCHAR)Identifier,
strlen(Identifier) + 1);
if (Error != ERROR_SUCCESS)
{
@@ -231,7 +231,7 @@ DetectCPU(HKEY CpuKey,
Error = RegSetValue(CpuInstKey,
"VendorIdentifier",
REG_SZ,
- (PU8)VendorIdentifier,
+ (PUCHAR)VendorIdentifier,
strlen(VendorIdentifier) + 1);
if (Error != ERROR_SUCCESS)
{
@@ -250,8 +250,8 @@ DetectCPU(HKEY CpuKey,
Error = RegSetValue(CpuInstKey,
"~MHz",
REG_DWORD,
- (PU8)&CpuSpeed,
- sizeof(U32));
+ (PUCHAR)&CpuSpeed,
+ sizeof(ULONG));
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT, "RegSetValue() failed (Error %u)\n", (int)Error));
@@ -261,23 +261,23 @@ DetectCPU(HKEY CpuKey,
static VOID
-SetMpsProcessor(HKEY CpuKey,
- HKEY FpuKey,
+SetMpsProcessor(FRLDRHKEY CpuKey,
+ FRLDRHKEY FpuKey,
PMP_PROCESSOR_ENTRY CpuEntry)
{
char VendorIdentifier[13];
char Identifier[64];
char Buffer[8];
- U32 FeatureSet;
- HKEY CpuInstKey;
- HKEY FpuInstKey;
- U32 eax = 0;
- U32 ebx = 0;
- U32 ecx = 0;
- U32 edx = 0;
- U32 *Ptr;
- S32 Error;
- U32 CpuSpeed;
+ ULONG FeatureSet;
+ FRLDRHKEY CpuInstKey;
+ FRLDRHKEY FpuInstKey;
+ ULONG eax = 0;
+ ULONG ebx = 0;
+ ULONG ecx = 0;
+ ULONG edx = 0;
+ ULONG *Ptr;
+ LONG Error;
+ ULONG CpuSpeed;
/* Get processor instance number */
sprintf(Buffer, "%u", CpuEntry->LocalApicId);
@@ -305,7 +305,7 @@ SetMpsProcessor(HKEY CpuKey,
/* Get 'VendorIdentifier' */
GetCpuid(0, &eax, &ebx, &ecx, &edx);
VendorIdentifier[12] = 0;
- Ptr = (U32*)&VendorIdentifier[0];
+ Ptr = (ULONG*)&VendorIdentifier[0];
*Ptr = ebx;
Ptr++;
*Ptr = edx;
@@ -315,9 +315,9 @@ SetMpsProcessor(HKEY CpuKey,
/* Get 'Identifier' */
sprintf(Identifier,
"x86 Family %u Model %u Stepping %u",
- (U32)((CpuEntry->CpuSignature >> 8) & 0x0F),
- (U32)((CpuEntry->CpuSignature >> 4) & 0x0F),
- (U32)(CpuEntry->CpuSignature & 0x0F));
+ (ULONG)((CpuEntry->CpuSignature >> 8) & 0x0F),
+ (ULONG)((CpuEntry->CpuSignature >> 4) & 0x0F),
+ (ULONG)(CpuEntry->CpuSignature & 0x0F));
/* Get FeatureSet */
FeatureSet = CpuEntry->FeatureFlags;
@@ -339,8 +339,8 @@ SetMpsProcessor(HKEY CpuKey,
Error = RegSetValue(CpuInstKey,
"FeatureSet",
REG_DWORD,
- (PU8)&FeatureSet,
- sizeof(U32));
+ (PUCHAR)&FeatureSet,
+ sizeof(ULONG));
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT, "RegSetValue() failed (Error %u)\n", (int)Error));
@@ -352,7 +352,7 @@ SetMpsProcessor(HKEY CpuKey,
Error = RegSetValue(CpuInstKey,
"Identifier",
REG_SZ,
- (PU8)Identifier,
+ (PUCHAR)Identifier,
strlen(Identifier) + 1);
if (Error != ERROR_SUCCESS)
{
@@ -362,7 +362,7 @@ SetMpsProcessor(HKEY CpuKey,
Error = RegSetValue(FpuInstKey,
"Identifier",
REG_SZ,
- (PU8)Identifier,
+ (PUCHAR)Identifier,
strlen(Identifier) + 1);
if (Error != ERROR_SUCCESS)
{
@@ -375,7 +375,7 @@ SetMpsProcessor(HKEY CpuKey,
Error = RegSetValue(CpuInstKey,
"VendorIdentifier",
REG_SZ,
- (PU8)VendorIdentifier,
+ (PUCHAR)VendorIdentifier,
strlen(VendorIdentifier) + 1);
if (Error != ERROR_SUCCESS)
{
@@ -394,8 +394,8 @@ SetMpsProcessor(HKEY CpuKey,
Error = RegSetValue(CpuInstKey,
"~MHz",
REG_DWORD,
- (PU8)&CpuSpeed,
- sizeof(U32));
+ (PUCHAR)&CpuSpeed,
+ sizeof(ULONG));
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT, "RegSetValue() failed (Error %u)\n", (int)Error));
@@ -409,12 +409,12 @@ GetMpFloatingPointTable(VOID)
{
PMP_FLOATING_POINT_TABLE FpTable;
char *Ptr;
- U8 Sum;
- U32 Length;
- U32 i;
+ UCHAR Sum;
+ ULONG Length;
+ ULONG i;
FpTable = (PMP_FLOATING_POINT_TABLE)0xF0000;
- while ((U32)FpTable < 0x100000)
+ while ((ULONG)FpTable < 0x100000)
{
if (FpTable->Signature == MP_FP_SIGNATURE)
{
@@ -440,7 +440,7 @@ GetMpFloatingPointTable(VOID)
return FpTable;
}
- FpTable = (PMP_FLOATING_POINT_TABLE)((U32)FpTable + 0x10);
+ FpTable = (PMP_FLOATING_POINT_TABLE)((ULONG)FpTable + 0x10);
}
return NULL;
@@ -452,9 +452,9 @@ GetMpConfigurationTable(PMP_FLOATING_POINT_TABLE FpTable)
{
PMP_CONFIGURATION_TABLE ConfigTable;
char *Ptr;
- U8 Sum;
- U32 Length;
- U32 i;
+ UCHAR Sum;
+ ULONG Length;
+ ULONG i;
if (FpTable->FeatureByte[0] != 0 ||
FpTable->PhysicalAddressPointer == 0)
@@ -466,7 +466,7 @@ GetMpConfigurationTable(PMP_FLOATING_POINT_TABLE FpTable)
DbgPrint((DPRINT_HWDETECT,
"MP Configuration Table at: %x\n",
- (U32)ConfigTable));
+ (ULONG)ConfigTable));
/* Calculate base table checksum */
Length = ConfigTable->BaseTableLength;
@@ -498,14 +498,14 @@ GetMpConfigurationTable(PMP_FLOATING_POINT_TABLE FpTable)
static BOOL
-DetectMps(HKEY CpuKey,
- HKEY FpuKey)
+DetectMps(FRLDRHKEY CpuKey,
+ FRLDRHKEY FpuKey)
{
PMP_FLOATING_POINT_TABLE FpTable;
PMP_CONFIGURATION_TABLE ConfigTable;
PMP_PROCESSOR_ENTRY CpuEntry;
char *Ptr;
- U32 Offset;
+ ULONG Offset;
/* Get floating point table */
FpTable = GetMpFloatingPointTable();
@@ -514,7 +514,7 @@ DetectMps(HKEY CpuKey,
DbgPrint((DPRINT_HWDETECT,
"MP Floating Point Table at: %x\n",
- (U32)FpTable));
+ (ULONG)FpTable));
if (FpTable->FeatureByte[0] == 0)
{
@@ -530,7 +530,7 @@ DetectMps(HKEY CpuKey,
Offset = sizeof(MP_CONFIGURATION_TABLE);
while (Offset < ConfigTable->BaseTableLength)
{
- Ptr = (char*)((U32)ConfigTable + Offset);
+ Ptr = (char*)((ULONG)ConfigTable + Offset);
switch (*Ptr)
{
@@ -548,9 +548,9 @@ DetectMps(HKEY CpuKey,
DbgPrint((DPRINT_HWDETECT,
"Processor %u: x86 Family %u Model %u Stepping %u\n",
CpuEntry->LocalApicId,
- (U32)((CpuEntry->CpuSignature >> 8) & 0x0F),
- (U32)((CpuEntry->CpuSignature >> 4) & 0x0F),
- (U32)(CpuEntry->CpuSignature & 0x0F)));
+ (ULONG)((CpuEntry->CpuSignature >> 8) & 0x0F),
+ (ULONG)((CpuEntry->CpuSignature >> 4) & 0x0F),
+ (ULONG)(CpuEntry->CpuSignature & 0x0F)));
SetMpsProcessor(CpuKey, FpuKey, CpuEntry);
Offset += 0x14;
@@ -577,7 +577,7 @@ DetectMps(HKEY CpuKey,
break;
default:
- DbgPrint((DPRINT_HWDETECT, "Unknown Entry %u\n",(U32)*Ptr));
+ DbgPrint((DPRINT_HWDETECT, "Unknown Entry %u\n",(ULONG)*Ptr));
return FALSE;
}
}
@@ -599,11 +599,11 @@ DetectMps(HKEY CpuKey,
VOID
-DetectCPUs(HKEY SystemKey)
+DetectCPUs(FRLDRHKEY SystemKey)
{
- HKEY CpuKey;
- HKEY FpuKey;
- S32 Error;
+ FRLDRHKEY CpuKey;
+ FRLDRHKEY FpuKey;
+ LONG Error;
/* Create the 'CentralProcessor' key */
Error = RegCreateKey(SystemKey,
diff --git a/reactos/boot/freeldr/freeldr/arch/i386/hwpci.c b/reactos/boot/freeldr/freeldr/arch/i386/hwpci.c
index 2285a7f9391..c4cba0ad12c 100644
--- a/reactos/boot/freeldr/freeldr/arch/i386/hwpci.c
+++ b/reactos/boot/freeldr/freeldr/arch/i386/hwpci.c
@@ -30,40 +30,40 @@
typedef struct _ROUTING_SLOT
{
- U8 BusNumber;
- U8 DeviceNumber;
- U8 LinkA;
- U16 BitmapA;
- U8 LinkB;
- U16 BitmapB;
- U8 LinkC;
- U16 BitmapC;
- U8 LinkD;
- U16 BitmapD;
- U8 SlotNumber;
- U8 Reserved;
+ UCHAR BusNumber;
+ UCHAR DeviceNumber;
+ UCHAR LinkA;
+ USHORT BitmapA;
+ UCHAR LinkB;
+ USHORT BitmapB;
+ UCHAR LinkC;
+ USHORT BitmapC;
+ UCHAR LinkD;
+ USHORT BitmapD;
+ UCHAR SlotNumber;
+ UCHAR Reserved;
} __attribute__((packed)) ROUTING_SLOT, *PROUTING_SLOT;
typedef struct _PCI_IRQ_ROUTING_TABLE
{
- U32 Signature;
- U16 Version;
- U16 Size;
- U8 RouterBus;
- U8 RouterSlot;
- U16 ExclusiveIRQs;
- U32 CompatibleRouter;
- U32 MiniportData;
- U8 Reserved[11];
- U8 Checksum;
+ ULONG Signature;
+ USHORT Version;
+ USHORT Size;
+ UCHAR RouterBus;
+ UCHAR RouterSlot;
+ USHORT ExclusiveIRQs;
+ ULONG CompatibleRouter;
+ ULONG MiniportData;
+ UCHAR Reserved[11];
+ UCHAR Checksum;
ROUTING_SLOT Slot[1];
} __attribute__((packed)) PCI_IRQ_ROUTING_TABLE, *PPCI_IRQ_ROUTING_TABLE;
typedef struct _CM_PCI_BUS_DATA
{
- U8 BusCount;
- U16 PciVersion;
- U8 HardwareMechanism;
+ UCHAR BusCount;
+ USHORT PciVersion;
+ UCHAR HardwareMechanism;
} __attribute__((packed)) CM_PCI_BUS_DATA, *PCM_PCI_BUS_DATA;
@@ -71,19 +71,19 @@ static PPCI_IRQ_ROUTING_TABLE
GetPciIrqRoutingTable(VOID)
{
PPCI_IRQ_ROUTING_TABLE Table;
- PU8 Ptr;
- U32 Sum;
- U32 i;
+ PUCHAR Ptr;
+ ULONG Sum;
+ ULONG i;
Table = (PPCI_IRQ_ROUTING_TABLE)0xF0000;
- while ((U32)Table < 0x100000)
+ while ((ULONG)Table < 0x100000)
{
if (Table->Signature == 0x52495024)
{
DbgPrint((DPRINT_HWDETECT,
"Found signature\n"));
- Ptr = (PU8)Table;
+ Ptr = (PUCHAR)Table;
Sum = 0;
for (i = 0; i < Table->Size; i++)
{
@@ -103,7 +103,7 @@ GetPciIrqRoutingTable(VOID)
return Table;
}
- Table = (PPCI_IRQ_ROUTING_TABLE)((U32)Table + 0x10);
+ Table = (PPCI_IRQ_ROUTING_TABLE)((ULONG)Table + 0x10);
}
return NULL;
@@ -145,14 +145,14 @@ FindPciBios(PCM_PCI_BUS_DATA BusData)
static VOID
-DetectPciIrqRoutingTable(HKEY BusKey)
+DetectPciIrqRoutingTable(FRLDRHKEY BusKey)
{
PCM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor;
PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
PPCI_IRQ_ROUTING_TABLE Table;
- HKEY TableKey;
- U32 Size;
- S32 Error;
+ FRLDRHKEY TableKey;
+ ULONG Size;
+ LONG Error;
Table = GetPciIrqRoutingTable();
if (Table != NULL)
@@ -178,7 +178,7 @@ DetectPciIrqRoutingTable(HKEY BusKey)
Error = RegSetValue(TableKey,
"Identifier",
REG_SZ,
- (PU8)"PCI Real-mode IRQ Routing Table",
+ (PUCHAR)"PCI Real-mode IRQ Routing Table",
32);
if (Error != ERROR_SUCCESS)
{
@@ -216,7 +216,7 @@ DetectPciIrqRoutingTable(HKEY BusKey)
Error = RegSetValue(TableKey,
"Configuration Data",
REG_FULL_RESOURCE_DESCRIPTOR,
- (PU8) FullResourceDescriptor,
+ (PUCHAR) FullResourceDescriptor,
Size);
MmFreeMemory(FullResourceDescriptor);
if (Error != ERROR_SUCCESS)
@@ -231,17 +231,17 @@ DetectPciIrqRoutingTable(HKEY BusKey)
VOID
-DetectPciBios(HKEY SystemKey, U32 *BusNumber)
+DetectPciBios(FRLDRHKEY SystemKey, ULONG *BusNumber)
{
PCM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor;
CM_PCI_BUS_DATA BusData;
char Buffer[80];
- HKEY BiosKey;
- U32 Size;
- S32 Error;
+ FRLDRHKEY BiosKey;
+ ULONG Size;
+ LONG Error;
#if 0
- HKEY BusKey;
- U32 i;
+ FRLDRHKEY BusKey;
+ ULONG i;
#endif
/* Report the PCI BIOS */
@@ -272,7 +272,7 @@ DetectPciBios(HKEY SystemKey, U32 *BusNumber)
Error = RegSetValue(BiosKey,
"Identifier",
REG_SZ,
- (PU8)"PCI BIOS",
+ (PUCHAR)"PCI BIOS",
9);
if (Error != ERROR_SUCCESS)
{
@@ -301,7 +301,7 @@ DetectPciBios(HKEY SystemKey, U32 *BusNumber)
Error = RegSetValue(BiosKey,
"Configuration Data",
REG_FULL_RESOURCE_DESCRIPTOR,
- (PU8) FullResourceDescriptor,
+ (PUCHAR) FullResourceDescriptor,
Size);
MmFreeMemory(FullResourceDescriptor);
if (Error != ERROR_SUCCESS)
@@ -322,7 +322,7 @@ DetectPciBios(HKEY SystemKey, U32 *BusNumber)
*/
/* Report PCI buses */
- for (i = 0; i < (U32)BusData.BusCount; i++)
+ for (i = 0; i < (ULONG)BusData.BusCount; i++)
{
sprintf(Buffer,
"MultifunctionAdapter\\%u", *BusNumber);
@@ -350,7 +350,7 @@ DetectPciBios(HKEY SystemKey, U32 *BusNumber)
Error = RegSetValue(BusKey,
"Identifier",
REG_SZ,
- (PU8)"PCI",
+ (PUCHAR)"PCI",
4);
if (Error != ERROR_SUCCESS)
{
diff --git a/reactos/boot/freeldr/freeldr/arch/i386/i386disk.c b/reactos/boot/freeldr/freeldr/arch/i386/i386disk.c
index 46c3116cc58..cc0bdb3ffc7 100644
--- a/reactos/boot/freeldr/freeldr/arch/i386/i386disk.c
+++ b/reactos/boot/freeldr/freeldr/arch/i386/i386disk.c
@@ -18,13 +18,7 @@
*/
#include "freeldr.h"
-#include "disk.h"
-#include "rtl.h"
-#include "arch.h"
#include "debug.h"
-#include "portio.h"
-#include "machine.h"
-
/////////////////////////////////////////////////////////////////////////////////////////////
// FUNCTIONS
@@ -32,7 +26,7 @@
#ifdef __i386__
-BOOL DiskResetController(U32 DriveNumber)
+BOOL DiskResetController(ULONG DriveNumber)
{
REGS RegsIn;
REGS RegsOut;
@@ -55,7 +49,7 @@ BOOL DiskResetController(U32 DriveNumber)
return INT386_SUCCESS(RegsOut);
}
-BOOL DiskInt13ExtensionsSupported(U32 DriveNumber)
+BOOL DiskInt13ExtensionsSupported(ULONG DriveNumber)
{
REGS RegsIn;
REGS RegsOut;
@@ -133,11 +127,11 @@ VOID DiskStopFloppyMotor(VOID)
WRITE_PORT_UCHAR((PUCHAR)0x3F2, 0);
}
-BOOL DiskGetExtendedDriveParameters(U32 DriveNumber, PVOID Buffer, U16 BufferSize)
+BOOL DiskGetExtendedDriveParameters(ULONG DriveNumber, PVOID Buffer, USHORT BufferSize)
{
REGS RegsIn;
REGS RegsOut;
- PU16 Ptr = (PU16)(BIOSCALLBUFFER);
+ PUSHORT Ptr = (PUSHORT)(BIOSCALLBUFFER);
DbgPrint((DPRINT_DISK, "DiskGetExtendedDriveParameters()\n"));
diff --git a/reactos/boot/freeldr/freeldr/arch/i386/i386rtl.c b/reactos/boot/freeldr/freeldr/arch/i386/i386rtl.c
index 281ffa37901..0612acee30e 100644
--- a/reactos/boot/freeldr/freeldr/arch/i386/i386rtl.c
+++ b/reactos/boot/freeldr/freeldr/arch/i386/i386rtl.c
@@ -18,9 +18,6 @@
*/
#include
-#include
-#include
-#include
void beep(void)
{
diff --git a/reactos/boot/freeldr/freeldr/arch/i386/i386vid.c b/reactos/boot/freeldr/freeldr/arch/i386/i386vid.c
index 59f5af2652f..6ee0e0a59e1 100644
--- a/reactos/boot/freeldr/freeldr/arch/i386/i386vid.c
+++ b/reactos/boot/freeldr/freeldr/arch/i386/i386vid.c
@@ -30,31 +30,31 @@
typedef struct
{
- U8 Signature[4]; // (ret) signature ("VESA")
+ UCHAR Signature[4]; // (ret) signature ("VESA")
// (call) VESA 2.0 request signature ("VBE2"), required to receive
// version 2.0 info
- U16 VesaVersion; // VESA version number (one-digit minor version -- 0102h = v1.2)
- U32 OemNamePtr; // pointer to OEM name
+ USHORT VesaVersion; // VESA version number (one-digit minor version -- 0102h = v1.2)
+ ULONG OemNamePtr; // pointer to OEM name
// "761295520" for ATI
- U32 Capabilities; // capabilities flags (see #00078)
- U32 SupportedModeListPtr; // pointer to list of supported VESA and OEM video modes
+ ULONG Capabilities; // capabilities flags (see #00078)
+ ULONG SupportedModeListPtr; // pointer to list of supported VESA and OEM video modes
// (list of words terminated with FFFFh)
- U16 TotalVideoMemory; // total amount of video memory in 64K blocks
+ USHORT TotalVideoMemory; // total amount of video memory in 64K blocks
// ---VBE v1.x ---
- //U8 Reserved[236];
+ //UCHAR Reserved[236];
// ---VBE v2.0 ---
- U16 OemSoftwareVersion; // OEM software version (BCD, high byte = major, low byte = minor)
- U32 VendorNamePtr; // pointer to vendor name
- U32 ProductNamePtr; // pointer to product name
- U32 ProductRevisionStringPtr; // pointer to product revision string
- U16 VBE_AF_Version; // (if capabilities bit 3 set) VBE/AF version (BCD)
+ USHORT OemSoftwareVersion; // OEM software version (BCD, high byte = major, low byte = minor)
+ ULONG VendorNamePtr; // pointer to vendor name
+ ULONG ProductNamePtr; // pointer to product name
+ ULONG ProductRevisionStringPtr; // pointer to product revision string
+ USHORT VBE_AF_Version; // (if capabilities bit 3 set) VBE/AF version (BCD)
// 0100h for v1.0P
- U32 AcceleratedModeListPtr; // (if capabilities bit 3 set) pointer to list of supported
+ ULONG AcceleratedModeListPtr; // (if capabilities bit 3 set) pointer to list of supported
// accelerated video modes (list of words terminated with FFFFh)
- U8 Reserved[216]; // reserved for VBE implementation
- U8 ScratchPad[256]; // OEM scratchpad (for OEM strings, etc.)
+ UCHAR Reserved[216]; // reserved for VBE implementation
+ UCHAR ScratchPad[256]; // OEM scratchpad (for OEM strings, etc.)
} PACKED VESA_SVGA_INFO, *PVESA_SVGA_INFO;
// Bitfields for VESA capabilities:
@@ -106,11 +106,11 @@ VOID BiosSetVideoFont8x16(VOID)
Int386(0x10, &Regs, &Regs);
}
-VOID VideoSetTextCursorPosition(U32 X, U32 Y)
+VOID VideoSetTextCursorPosition(ULONG X, ULONG Y)
{
}
-U32 VideoGetTextCursorPositionX(VOID)
+ULONG VideoGetTextCursorPositionX(VOID)
{
REGS Regs;
@@ -135,7 +135,7 @@ U32 VideoGetTextCursorPositionX(VOID)
return Regs.b.dl;
}
-U32 VideoGetTextCursorPositionY(VOID)
+ULONG VideoGetTextCursorPositionY(VOID)
{
REGS Regs;
@@ -160,13 +160,13 @@ U32 VideoGetTextCursorPositionY(VOID)
return Regs.b.dh;
}
-U16 BiosIsVesaSupported(VOID)
+USHORT BiosIsVesaSupported(VOID)
{
REGS Regs;
PVESA_SVGA_INFO SvgaInfo = (PVESA_SVGA_INFO)BIOSCALLBUFFER;
#ifdef DEBUG
- //U16* VideoModes;
- //U16 Index;
+ //USHORT* VideoModes;
+ //USHORT Index;
#endif // defined DEBUG
DbgPrint((DPRINT_UI, "BiosIsVesaSupported()\n"));
@@ -227,7 +227,7 @@ U16 BiosIsVesaSupported(VOID)
DbgPrint((DPRINT_UI, "SvgaInfo->VBE/AF Version = 0x%x (BCD WORD)\n", SvgaInfo->VBE_AF_Version));
//DbgPrint((DPRINT_UI, "\nSupported VESA and OEM video modes:\n"));
- //VideoModes = (U16*)SvgaInfo->SupportedModeListPtr;
+ //VideoModes = (USHORT*)SvgaInfo->SupportedModeListPtr;
//for (Index=0; VideoModes[Index]!=0xFFFF; Index++)
//{
// DbgPrint((DPRINT_UI, "Mode %d: 0x%x\n", Index, VideoModes[Index]));
@@ -236,7 +236,7 @@ U16 BiosIsVesaSupported(VOID)
//if (SvgaInfo->VesaVersion >= 0x0200)
//{
// DbgPrint((DPRINT_UI, "\nSupported accelerated video modes (VESA v2.0):\n"));
- // VideoModes = (U16*)SvgaInfo->AcceleratedModeListPtr;
+ // VideoModes = (USHORT*)SvgaInfo->AcceleratedModeListPtr;
// for (Index=0; VideoModes[Index]!=0xFFFF; Index++)
// {
// DbgPrint((DPRINT_UI, "Mode %d: 0x%x\n", Index, VideoModes[Index]));
diff --git a/reactos/boot/freeldr/freeldr/arch/i386/machpc.h b/reactos/boot/freeldr/freeldr/arch/i386/machpc.h
index 656bf451d9b..5462a10effa 100644
--- a/reactos/boot/freeldr/freeldr/arch/i386/machpc.h
+++ b/reactos/boot/freeldr/freeldr/arch/i386/machpc.h
@@ -32,28 +32,28 @@ VOID PcConsPutChar(int Ch);
BOOL PcConsKbHit();
int PcConsGetCh();
-VOID PcVideoClearScreen(U8 Attr);
+VOID PcVideoClearScreen(UCHAR Attr);
VIDEODISPLAYMODE PcVideoSetDisplayMode(char *DisplayMode, BOOL Init);
-VOID PcVideoGetDisplaySize(PU32 Width, PU32 Height, PU32 Depth);
-U32 PcVideoGetBufferSize(VOID);
-VOID PcVideoSetTextCursorPosition(U32 X, U32 Y);
+VOID PcVideoGetDisplaySize(PULONG Width, PULONG Height, PULONG Depth);
+ULONG PcVideoGetBufferSize(VOID);
+VOID PcVideoSetTextCursorPosition(ULONG X, ULONG Y);
VOID PcVideoHideShowTextCursor(BOOL Show);
-VOID PcVideoPutChar(int Ch, U8 Attr, unsigned X, unsigned Y);
+VOID PcVideoPutChar(int Ch, UCHAR Attr, unsigned X, unsigned Y);
VOID PcVideoCopyOffScreenBufferToVRAM(PVOID Buffer);
BOOL PcVideoIsPaletteFixed(VOID);
-VOID PcVideoSetPaletteColor(U8 Color, U8 Red, U8 Green, U8 Blue);
-VOID PcVideoGetPaletteColor(U8 Color, U8* Red, U8* Green, U8* Blue);
+VOID PcVideoSetPaletteColor(UCHAR Color, UCHAR Red, UCHAR Green, UCHAR Blue);
+VOID PcVideoGetPaletteColor(UCHAR Color, UCHAR* Red, UCHAR* Green, UCHAR* Blue);
VOID PcVideoSync(VOID);
VOID PcVideoPrepareForReactOS(VOID);
-U32 PcMemGetMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, U32 MaxMemoryMapSize);
+ULONG PcMemGetMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, ULONG MaxMemoryMapSize);
-BOOL PcDiskReadLogicalSectors(U32 DriveNumber, U64 SectorNumber, U32 SectorCount, PVOID Buffer);
-BOOL PcDiskGetPartitionEntry(U32 DriveNumber, U32 PartitionNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry);
-BOOL PcDiskGetDriveGeometry(U32 DriveNumber, PGEOMETRY DriveGeometry);
-U32 PcDiskGetCacheableBlockCount(U32 DriveNumber);
+BOOL PcDiskReadLogicalSectors(ULONG DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer);
+BOOL PcDiskGetPartitionEntry(ULONG DriveNumber, ULONG PartitionNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry);
+BOOL PcDiskGetDriveGeometry(ULONG DriveNumber, PGEOMETRY DriveGeometry);
+ULONG PcDiskGetCacheableBlockCount(ULONG DriveNumber);
-VOID PcRTCGetCurrentDateTime(PU32 Year, PU32 Month, PU32 Day, PU32 Hour, PU32 Minute, PU32 Second);
+VOID PcRTCGetCurrentDateTime(PULONG Year, PULONG Month, PULONG Day, PULONG Hour, PULONG Minute, PULONG Second);
VOID PcHwDetect(VOID);
diff --git a/reactos/boot/freeldr/freeldr/arch/i386/machxbox.h b/reactos/boot/freeldr/freeldr/arch/i386/machxbox.h
index 13ce64c94e5..845f242e8b0 100644
--- a/reactos/boot/freeldr/freeldr/arch/i386/machxbox.h
+++ b/reactos/boot/freeldr/freeldr/arch/i386/machxbox.h
@@ -24,7 +24,7 @@
#include "mm.h"
#endif
-U8 XboxFont8x16[256 * 16];
+UCHAR XboxFont8x16[256 * 16];
VOID XboxMachInit(VOID);
@@ -33,30 +33,30 @@ BOOL XboxConsKbHit();
int XboxConsGetCh();
VOID XboxVideoInit(VOID);
-VOID XboxVideoClearScreen(U8 Attr);
+VOID XboxVideoClearScreen(UCHAR Attr);
VIDEODISPLAYMODE XboxVideoSetDisplayMode(char *DisplayModem, BOOL Init);
-VOID XboxVideoGetDisplaySize(PU32 Width, PU32 Height, PU32 Depth);
-U32 XboxVideoGetBufferSize(VOID);
-VOID XboxVideoSetTextCursorPosition(U32 X, U32 Y);
+VOID XboxVideoGetDisplaySize(PULONG Width, PULONG Height, PULONG Depth);
+ULONG XboxVideoGetBufferSize(VOID);
+VOID XboxVideoSetTextCursorPosition(ULONG X, ULONG Y);
VOID XboxVideoHideShowTextCursor(BOOL Show);
-VOID XboxVideoPutChar(int Ch, U8 Attr, unsigned X, unsigned Y);
+VOID XboxVideoPutChar(int Ch, UCHAR Attr, unsigned X, unsigned Y);
VOID XboxVideoCopyOffScreenBufferToVRAM(PVOID Buffer);
BOOL XboxVideoIsPaletteFixed(VOID);
-VOID XboxVideoSetPaletteColor(U8 Color, U8 Red, U8 Green, U8 Blue);
-VOID XboxVideoGetPaletteColor(U8 Color, U8* Red, U8* Green, U8* Blue);
+VOID XboxVideoSetPaletteColor(UCHAR Color, UCHAR Red, UCHAR Green, UCHAR Blue);
+VOID XboxVideoGetPaletteColor(UCHAR Color, UCHAR* Red, UCHAR* Green, UCHAR* Blue);
VOID XboxVideoSync(VOID);
VOID XboxVideoPrepareForReactOS(VOID);
VOID XboxMemInit(VOID);
-PVOID XboxMemReserveMemory(U32 MbToReserve);
-U32 XboxMemGetMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, U32 MaxMemoryMapSize);
+PVOID XboxMemReserveMemory(ULONG MbToReserve);
+ULONG XboxMemGetMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, ULONG MaxMemoryMapSize);
-BOOL XboxDiskReadLogicalSectors(U32 DriveNumber, U64 SectorNumber, U32 SectorCount, PVOID Buffer);
-BOOL XboxDiskGetPartitionEntry(U32 DriveNumber, U32 PartitionNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry);
-BOOL XboxDiskGetDriveGeometry(U32 DriveNumber, PGEOMETRY DriveGeometry);
-U32 XboxDiskGetCacheableBlockCount(U32 DriveNumber);
+BOOL XboxDiskReadLogicalSectors(ULONG DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer);
+BOOL XboxDiskGetPartitionEntry(ULONG DriveNumber, ULONG PartitionNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry);
+BOOL XboxDiskGetDriveGeometry(ULONG DriveNumber, PGEOMETRY DriveGeometry);
+ULONG XboxDiskGetCacheableBlockCount(ULONG DriveNumber);
-VOID XboxRTCGetCurrentDateTime(PU32 Year, PU32 Month, PU32 Day, PU32 Hour, PU32 Minute, PU32 Second);
+VOID XboxRTCGetCurrentDateTime(PULONG Year, PULONG Month, PULONG Day, PULONG Hour, PULONG Minute, PULONG Second);
VOID XboxHwDetect(VOID);
diff --git a/reactos/boot/freeldr/freeldr/arch/i386/mb.S b/reactos/boot/freeldr/freeldr/arch/i386/mb.S
index e77b380f4bb..78a3f49aeb2 100644
--- a/reactos/boot/freeldr/freeldr/arch/i386/mb.S
+++ b/reactos/boot/freeldr/freeldr/arch/i386/mb.S
@@ -29,116 +29,29 @@
* This boots the kernel
*/
.code32
-EXTERN(_boot_reactos)
- call _MachVideoPrepareForReactOS
+ .globl _PageDirectoryStart
+
+ .globl _startup_pagedirectory
+ .globl _lowmem_pagetable
+ .globl _kernel_pagetable
+ .globl _hyperspace_pagetable
+ .globl _apic_pagetable
+ .globl _kpcr_pagetable
- call _multi_boot
-
- // Should never get here
- cli
-bootloop:
- hlt
- jmp bootloop
-
-
- /*
- * After you have setup the _mb_header and _mb_info structures
- * then call this routine to transfer control to the kernel.
- */
-EXTERN(_multi_boot)
-
- cli
-
- /*
- * Load the absolute address of the multiboot information structure
- */
- movl $_mb_info,%ebx
-
- /*
- * Initalize eflags
- */
- pushl $0
- popfl
-
- /*
- * Load the multiboot magic value into eax
- */
- movl $0x2badb002,%eax
-
- /*
- * Jump to start of 32 bit code at 0xc0000000 + 0x1000
- */
-
- pushl $KERNEL_CS
- pushl _mb_entry_addr
- lretl
-
-
-EXTERN(_mb_header)
-_mb_magic:
- .long 0 // unsigned long magic;
-_mb_flags:
- .long 0 // unsigned long flags;
-_mb_checksum:
- .long 0 // unsigned long checksum;
-_mb_header_addr:
- .long 0 // unsigned long header_addr;
-_mb_load_addr:
- .long 0 // unsigned long load_addr;
-_mb_load_end_addr:
- .long 0 // unsigned long load_end_addr;
-_mb_bss_end_addr:
- .long 0 // unsigned long bss_end_addr;
-_mb_entry_addr:
- .long 0 // unsigned long entry_addr;
+ .globl _startup_pagedirectorytable_pae
+ .globl _startup_pagedirectory_pae
+ .globl _lowmem_pagetable_pae
+ .globl _kernel_pagetable_pae
+ .globl _hyperspace_pagetable_pae
+ .globl _apic_pagetable_pae
+ .globl _kpcr_pagetable_pae
+
+ .globl _PageDirectoryEnd
//
// Boot information structure
//
-EXTERN(_mb_info)
-_multiboot_flags:
- .long 0
-_multiboot_mem_lower:
- .long 0
-_multiboot_mem_upper:
- .long 0
-_multiboot_boot_device:
- .long 0
-_multiboot_cmdline:
- .long 0
-_multiboot_mods_count:
- .long 0
-_multiboot_mods_addr:
- .long 0
-_multiboot_syms:
- .rept 12
- .byte 0
- .endr
-_multiboot_mmap_length:
- .long 0
-_multiboot_mmap_addr:
- .long 0
-_multiboot_drives_count:
- .long 0
-_multiboot_drives_addr:
- .long 0
-_multiboot_config_table:
- .long 0
-_multiboot_boot_loader_name:
- .long 0
-_multiboot_apm_table:
- .long 0
-
-EXTERN(_multiboot_modules)
- .rept (64 * /*multiboot_module_size*/ 16)
- .byte 0
- .endr
-EXTERN(_multiboot_module_strings)
- .rept (64*256)
- .byte 0
- .endr
-
EXTERN(_multiboot_memory_map_descriptor_size)
.long 0
@@ -147,7 +60,44 @@ EXTERN(_multiboot_memory_map)
.byte 0
.endr
-EXTERN(_multiboot_kernel_cmdline)
- .rept 255
- .byte 0
- .endr
+.bss
+_PageDirectoryStart:
+_startup_pagedirectory:
+ .fill 4096, 1, 0
+
+_lowmem_pagetable:
+ .fill 4096, 1, 0
+
+_kernel_pagetable:
+ .fill 2*4096, 1, 0
+
+_hyperspace_pagetable:
+ .fill 4096, 1, 0
+
+_apic_pagetable:
+ .fill 4096, 1, 0
+
+_kpcr_pagetable:
+ .fill 4096, 1, 0
+
+_startup_pagedirectory_pae:
+ .fill 4 * 4096, 1, 0
+
+_lowmem_pagetable_pae:
+ .fill 2 * 4096, 1, 0
+
+_kernel_pagetable_pae:
+ .fill 3*4096, 1, 0
+
+_hyperspace_pagetable_pae:
+ .fill 2*4096, 1, 0
+
+_apic_pagetable_pae:
+ .fill 2*4096, 1, 0
+
+_kpcr_pagetable_pae:
+ .fill 4*4096, 1, 0
+
+_startup_pagedirectorytable_pae:
+ .fill 4096, 1, 0
+_PageDirectoryEnd:
diff --git a/reactos/boot/freeldr/freeldr/arch/i386/pcdisk.c b/reactos/boot/freeldr/freeldr/arch/i386/pcdisk.c
index b915141c399..5e344bbe3cf 100644
--- a/reactos/boot/freeldr/freeldr/arch/i386/pcdisk.c
+++ b/reactos/boot/freeldr/freeldr/arch/i386/pcdisk.c
@@ -29,13 +29,13 @@
typedef struct
{
- U8 PacketSize; // 00h - Size of packet (10h or 18h)
- U8 Reserved; // 01h - Reserved (0)
- U16 LBABlockCount; // 02h - Number of blocks to transfer (max 007Fh for Phoenix EDD)
- U16 TransferBufferOffset; // 04h - Transfer buffer offset (seg:off)
- U16 TransferBufferSegment; // Transfer buffer segment (seg:off)
- U64 LBAStartBlock; // 08h - Starting absolute block number
- U64 TransferBuffer64; // 10h - (EDD-3.0, optional) 64-bit flat address of transfer buffer
+ UCHAR PacketSize; // 00h - Size of packet (10h or 18h)
+ UCHAR Reserved; // 01h - Reserved (0)
+ USHORT LBABlockCount; // 02h - Number of blocks to transfer (max 007Fh for Phoenix EDD)
+ USHORT TransferBufferOffset; // 04h - Transfer buffer offset (seg:off)
+ USHORT TransferBufferSegment; // Transfer buffer segment (seg:off)
+ ULONGLONG LBAStartBlock; // 08h - Starting absolute block number
+ ULONGLONG TransferBuffer64; // 10h - (EDD-3.0, optional) 64-bit flat address of transfer buffer
// used if DWORD at 04h is FFFFh:FFFFh
} PACKED I386_DISK_ADDRESS_PACKET, *PI386_DISK_ADDRESS_PACKET;
@@ -43,7 +43,7 @@ typedef struct
// FUNCTIONS
/////////////////////////////////////////////////////////////////////////////////////////////
-static BOOL PcDiskResetController(U32 DriveNumber)
+static BOOL PcDiskResetController(ULONG DriveNumber)
{
REGS RegsIn;
REGS RegsOut;
@@ -66,11 +66,11 @@ static BOOL PcDiskResetController(U32 DriveNumber)
return INT386_SUCCESS(RegsOut);
}
-static BOOL PcDiskReadLogicalSectorsLBA(U32 DriveNumber, U64 SectorNumber, U32 SectorCount, PVOID Buffer)
+static BOOL PcDiskReadLogicalSectorsLBA(ULONG DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer)
{
REGS RegsIn;
REGS RegsOut;
- U32 RetryCount;
+ ULONG RetryCount;
PI386_DISK_ADDRESS_PACKET Packet = (PI386_DISK_ADDRESS_PACKET)(BIOSCALLBUFFER);
DbgPrint((DPRINT_DISK, "PcDiskReadLogicalSectorsLBA() DriveNumber: 0x%x SectorNumber: %I64d SectorCount: %d Buffer: 0x%x\n", DriveNumber, SectorNumber, SectorCount, Buffer));
@@ -86,8 +86,8 @@ static BOOL PcDiskReadLogicalSectorsLBA(U32 DriveNumber, U64 SectorNumber, U32 S
Packet->PacketSize = sizeof(I386_DISK_ADDRESS_PACKET);
Packet->Reserved = 0;
Packet->LBABlockCount = SectorCount;
- Packet->TransferBufferOffset = ((U32)Buffer) & 0x0F;
- Packet->TransferBufferSegment = ((U32)Buffer) >> 4;
+ Packet->TransferBufferOffset = ((ULONG)Buffer) & 0x0F;
+ Packet->TransferBufferSegment = ((ULONG)Buffer) >> 4;
Packet->LBAStartBlock = SectorNumber;
Packet->TransferBuffer64 = 0;
@@ -130,23 +130,25 @@ static BOOL PcDiskReadLogicalSectorsLBA(U32 DriveNumber, U64 SectorNumber, U32 S
return FALSE;
}
-static BOOL PcDiskReadLogicalSectorsCHS(U32 DriveNumber, U64 SectorNumber, U32 SectorCount, PVOID Buffer)
+static BOOL PcDiskReadLogicalSectorsCHS(ULONG DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer)
{
- U32 PhysicalSector;
- U32 PhysicalHead;
- U32 PhysicalTrack;
+ ULONG PhysicalSector;
+ ULONG PhysicalHead;
+ ULONG PhysicalTrack;
GEOMETRY DriveGeometry;
- U32 NumberOfSectorsToRead;
+ ULONG NumberOfSectorsToRead;
REGS RegsIn;
REGS RegsOut;
- U32 RetryCount;
+ ULONG RetryCount;
DbgPrint((DPRINT_DISK, "PcDiskReadLogicalSectorsCHS()\n"));
//
// Get the drive geometry
//
- if (!MachDiskGetDriveGeometry(DriveNumber, &DriveGeometry))
+ if (!MachDiskGetDriveGeometry(DriveNumber, &DriveGeometry) ||
+ DriveGeometry.Sectors == 0 ||
+ DriveGeometry.Heads == 0)
{
return FALSE;
}
@@ -213,8 +215,8 @@ static BOOL PcDiskReadLogicalSectorsCHS(U32 DriveNumber, U64 SectorNumber, U32 S
RegsIn.b.cl = (PhysicalSector + ((PhysicalTrack & 0x300) >> 2));
RegsIn.b.dh = PhysicalHead;
RegsIn.b.dl = DriveNumber;
- RegsIn.w.es = ((U32)Buffer) >> 4;
- RegsIn.w.bx = ((U32)Buffer) & 0x0F;
+ RegsIn.w.es = ((ULONG)Buffer) >> 4;
+ RegsIn.w.bx = ((ULONG)Buffer) & 0x0F;
//
// Perform the read
@@ -264,9 +266,9 @@ static BOOL PcDiskReadLogicalSectorsCHS(U32 DriveNumber, U64 SectorNumber, U32 S
return TRUE;
}
-static BOOL PcDiskInt13ExtensionsSupported(U32 DriveNumber)
+static BOOL PcDiskInt13ExtensionsSupported(ULONG DriveNumber)
{
- static U32 LastDriveNumber = 0xffffffff;
+ static ULONG LastDriveNumber = 0xffffffff;
static BOOL LastSupported;
REGS RegsIn;
REGS RegsOut;
@@ -353,7 +355,7 @@ static BOOL PcDiskInt13ExtensionsSupported(U32 DriveNumber)
return TRUE;
}
-BOOL PcDiskReadLogicalSectors(U32 DriveNumber, U64 SectorNumber, U32 SectorCount, PVOID Buffer)
+BOOL PcDiskReadLogicalSectors(ULONG DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer)
{
DbgPrint((DPRINT_DISK, "PcDiskReadLogicalSectors() DriveNumber: 0x%x SectorNumber: %I64d SectorCount: %d Buffer: 0x%x\n", DriveNumber, SectorNumber, SectorCount, Buffer));
@@ -383,18 +385,18 @@ BOOL PcDiskReadLogicalSectors(U32 DriveNumber, U64 SectorNumber, U32 SectorCount
}
BOOL
-PcDiskGetPartitionEntry(U32 DriveNumber, U32 PartitionNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry)
+PcDiskGetPartitionEntry(ULONG DriveNumber, ULONG PartitionNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry)
{
/* Just use the standard routine */
return DiskGetPartitionEntry(DriveNumber, PartitionNumber, PartitionTableEntry);
}
BOOL
-PcDiskGetDriveGeometry(U32 DriveNumber, PGEOMETRY Geometry)
+PcDiskGetDriveGeometry(ULONG DriveNumber, PGEOMETRY Geometry)
{
REGS RegsIn;
REGS RegsOut;
- U32 Cylinders;
+ ULONG Cylinders;
DbgPrint((DPRINT_DISK, "DiskGetDriveGeometry()\n"));
@@ -440,8 +442,8 @@ PcDiskGetDriveGeometry(U32 DriveNumber, PGEOMETRY Geometry)
return TRUE;
}
-U32
-PcDiskGetCacheableBlockCount(U32 DriveNumber)
+ULONG
+PcDiskGetCacheableBlockCount(ULONG DriveNumber)
{
GEOMETRY Geometry;
diff --git a/reactos/boot/freeldr/freeldr/arch/i386/pcmem.c b/reactos/boot/freeldr/freeldr/arch/i386/pcmem.c
index bb5b409ef64..e9da602bab6 100644
--- a/reactos/boot/freeldr/freeldr/arch/i386/pcmem.c
+++ b/reactos/boot/freeldr/freeldr/arch/i386/pcmem.c
@@ -28,12 +28,12 @@
#include "portio.h"
#include "rtl.h"
-static U32
+static ULONG
PcMemGetExtendedMemorySize(VOID)
{
REGS RegsIn;
REGS RegsOut;
- U32 MemorySize;
+ ULONG MemorySize;
DbgPrint((DPRINT_MEMORY, "GetExtendedMemorySize()\n"));
@@ -119,7 +119,7 @@ PcMemGetExtendedMemorySize(VOID)
return MemorySize;
}
-static U32
+static ULONG
PcMemGetConventionalMemorySize(VOID)
{
REGS Regs;
@@ -141,14 +141,14 @@ PcMemGetConventionalMemorySize(VOID)
DbgPrint((DPRINT_MEMORY, "Int12h\n"));
DbgPrint((DPRINT_MEMORY, "AX = 0x%x\n\n", Regs.w.ax));
- return (U32)Regs.w.ax;
+ return (ULONG)Regs.w.ax;
}
-static U32
-PcMemGetBiosMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, U32 MaxMemoryMapSize)
+static ULONG
+PcMemGetBiosMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, ULONG MaxMemoryMapSize)
{
REGS Regs;
- U32 MapCount;
+ ULONG MapCount;
DbgPrint((DPRINT_MEMORY, "GetBiosMemoryMap()\n"));
@@ -225,10 +225,10 @@ PcMemGetBiosMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, U32 MaxMemoryMapSize)
return MapCount;
}
-U32
-PcMemGetMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, U32 MaxMemoryMapSize)
+ULONG
+PcMemGetMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, ULONG MaxMemoryMapSize)
{
- U32 EntryCount;
+ ULONG EntryCount;
EntryCount = PcMemGetBiosMemoryMap(BiosMemoryMap, MaxMemoryMapSize);
diff --git a/reactos/boot/freeldr/freeldr/arch/i386/pcrtc.c b/reactos/boot/freeldr/freeldr/arch/i386/pcrtc.c
index c6823d064e5..aad76981444 100644
--- a/reactos/boot/freeldr/freeldr/arch/i386/pcrtc.c
+++ b/reactos/boot/freeldr/freeldr/arch/i386/pcrtc.c
@@ -25,7 +25,7 @@
#define BCD_INT(bcd) (((bcd & 0xf0) >> 4) * 10 + (bcd &0x0f))
VOID
-PcRTCGetCurrentDateTime(PU32 Year, PU32 Month, PU32 Day, PU32 Hour, PU32 Minute, PU32 Second)
+PcRTCGetCurrentDateTime(PULONG Year, PULONG Month, PULONG Day, PULONG Hour, PULONG Minute, PULONG Second)
{
REGS Regs;
@@ -55,7 +55,7 @@ PcRTCGetCurrentDateTime(PU32 Year, PU32 Month, PU32 Day, PU32 Hour, PU32 Minute,
if (NULL != Year)
{
- *Year = 100 * BCD_INT(Regs.b.cl) + BCD_INT(Regs.b.ch);
+ *Year = 100 * BCD_INT(Regs.b.ch) + BCD_INT(Regs.b.cl);
}
if (NULL != Month)
{
diff --git a/reactos/boot/freeldr/freeldr/arch/i386/pcvideo.c b/reactos/boot/freeldr/freeldr/arch/i386/pcvideo.c
index a4bf82079dd..2baac362952 100644
--- a/reactos/boot/freeldr/freeldr/arch/i386/pcvideo.c
+++ b/reactos/boot/freeldr/freeldr/arch/i386/pcvideo.c
@@ -56,69 +56,69 @@
typedef struct
{
- U16 ModeAttributes; /* mode attributes (see #00080) */
- U8 WindowAttributesA; /* window attributes, window A (see #00081) */
- U8 WindowsAttributesB; /* window attributes, window B (see #00081) */
- U16 WindowGranularity; /* window granularity in KB */
- U16 WindowSize; /* window size in KB */
- U16 WindowAStartSegment; /* start segment of window A (0000h if not supported) */
- U16 WindowBStartSegment; /* start segment of window B (0000h if not supported) */
- U32 WindowPositioningFunction; /* -> FAR window positioning function (equivalent to AX=4F05h) */
- U16 BytesPerScanLine; /* bytes per scan line */
+ USHORT ModeAttributes; /* mode attributes (see #00080) */
+ UCHAR WindowAttributesA; /* window attributes, window A (see #00081) */
+ UCHAR WindowsAttributesB; /* window attributes, window B (see #00081) */
+ USHORT WindowGranularity; /* window granularity in KB */
+ USHORT WindowSize; /* window size in KB */
+ USHORT WindowAStartSegment; /* start segment of window A (0000h if not supported) */
+ USHORT WindowBStartSegment; /* start segment of window B (0000h if not supported) */
+ ULONG WindowPositioningFunction; /* -> FAR window positioning function (equivalent to AX=4F05h) */
+ USHORT BytesPerScanLine; /* bytes per scan line */
/* ---remainder is optional for VESA modes in v1.0/1.1, needed for OEM modes--- */
- U16 WidthInPixels; /* width in pixels (graphics) or characters (text) */
- U16 HeightInPixels; /* height in pixels (graphics) or characters (text) */
- U8 CharacterWidthInPixels; /* width of character cell in pixels */
- U8 CharacterHeightInPixels; /* height of character cell in pixels */
- U8 NumberOfMemoryPlanes; /* number of memory planes */
- U8 BitsPerPixel; /* number of bits per pixel */
- U8 NumberOfBanks; /* number of banks */
- U8 MemoryModel; /* memory model type (see #00082) */
- U8 BankSize; /* size of bank in KB */
- U8 NumberOfImagePanes; /* number of image pages (less one) that will fit in video RAM */
- U8 Reserved1; /* reserved (00h for VBE 1.0-2.0, 01h for VBE 3.0) */
+ USHORT WidthInPixels; /* width in pixels (graphics) or characters (text) */
+ USHORT HeightInPixels; /* height in pixels (graphics) or characters (text) */
+ UCHAR CharacterWidthInPixels; /* width of character cell in pixels */
+ UCHAR CharacterHeightInPixels; /* height of character cell in pixels */
+ UCHAR NumberOfMemoryPlanes; /* number of memory planes */
+ UCHAR BitsPerPixel; /* number of bits per pixel */
+ UCHAR NumberOfBanks; /* number of banks */
+ UCHAR MemoryModel; /* memory model type (see #00082) */
+ UCHAR BankSize; /* size of bank in KB */
+ UCHAR NumberOfImagePanes; /* number of image pages (less one) that will fit in video RAM */
+ UCHAR Reserved1; /* reserved (00h for VBE 1.0-2.0, 01h for VBE 3.0) */
/* ---VBE v1.2+ --- */
- U8 RedMaskSize; /* red mask size */
- U8 RedMaskPosition; /* red field position */
- U8 GreenMaskSize; /* green mask size */
- U8 GreenMaskPosition; /* green field size */
- U8 BlueMaskSize; /* blue mask size */
- U8 BlueMaskPosition; /* blue field size */
- U8 ReservedMaskSize; /* reserved mask size */
- U8 ReservedMaskPosition; /* reserved mask position */
- U8 DirectColorModeInfo; /* direct color mode info */
+ UCHAR RedMaskSize; /* red mask size */
+ UCHAR RedMaskPosition; /* red field position */
+ UCHAR GreenMaskSize; /* green mask size */
+ UCHAR GreenMaskPosition; /* green field size */
+ UCHAR BlueMaskSize; /* blue mask size */
+ UCHAR BlueMaskPosition; /* blue field size */
+ UCHAR ReservedMaskSize; /* reserved mask size */
+ UCHAR ReservedMaskPosition; /* reserved mask position */
+ UCHAR DirectColorModeInfo; /* direct color mode info */
/* bit 0:Color ramp is programmable */
/* bit 1:Bytes in reserved field may be used by application */
/* ---VBE v2.0+ --- */
- U32 LinearVideoBufferAddress; /* physical address of linear video buffer */
- U32 OffscreenMemoryPointer; /* pointer to start of offscreen memory */
- U16 OffscreenMemorySize; /* KB of offscreen memory */
+ ULONG LinearVideoBufferAddress; /* physical address of linear video buffer */
+ ULONG OffscreenMemoryPointer; /* pointer to start of offscreen memory */
+ USHORT OffscreenMemorySize; /* KB of offscreen memory */
/* ---VBE v3.0 --- */
- U16 LinearBytesPerScanLine; /* bytes per scan line in linear modes */
- U8 BankedNumberOfImages; /* number of images (less one) for banked video modes */
- U8 LinearNumberOfImages; /* number of images (less one) for linear video modes */
- U8 LinearRedMaskSize; /* linear modes:Size of direct color red mask (in bits) */
- U8 LinearRedMaskPosition; /* linear modes:Bit position of red mask LSB (e.g. shift count) */
- U8 LinearGreenMaskSize; /* linear modes:Size of direct color green mask (in bits) */
- U8 LinearGreenMaskPosition; /* linear modes:Bit position of green mask LSB (e.g. shift count) */
- U8 LinearBlueMaskSize; /* linear modes:Size of direct color blue mask (in bits) */
- U8 LinearBlueMaskPosition; /* linear modes:Bit position of blue mask LSB (e.g. shift count) */
- U8 LinearReservedMaskSize; /* linear modes:Size of direct color reserved mask (in bits) */
- U8 LinearReservedMaskPosition; /* linear modes:Bit position of reserved mask LSB */
- U32 MaximumPixelClock; /* maximum pixel clock for graphics video mode, in Hz */
- U8 Reserved2[190]; /* 190 BYTEs reserved (0) */
+ USHORT LinearBytesPerScanLine; /* bytes per scan line in linear modes */
+ UCHAR BankedNumberOfImages; /* number of images (less one) for banked video modes */
+ UCHAR LinearNumberOfImages; /* number of images (less one) for linear video modes */
+ UCHAR LinearRedMaskSize; /* linear modes:Size of direct color red mask (in bits) */
+ UCHAR LinearRedMaskPosition; /* linear modes:Bit position of red mask LSB (e.g. shift count) */
+ UCHAR LinearGreenMaskSize; /* linear modes:Size of direct color green mask (in bits) */
+ UCHAR LinearGreenMaskPosition; /* linear modes:Bit position of green mask LSB (e.g. shift count) */
+ UCHAR LinearBlueMaskSize; /* linear modes:Size of direct color blue mask (in bits) */
+ UCHAR LinearBlueMaskPosition; /* linear modes:Bit position of blue mask LSB (e.g. shift count) */
+ UCHAR LinearReservedMaskSize; /* linear modes:Size of direct color reserved mask (in bits) */
+ UCHAR LinearReservedMaskPosition; /* linear modes:Bit position of reserved mask LSB */
+ ULONG MaximumPixelClock; /* maximum pixel clock for graphics video mode, in Hz */
+ UCHAR Reserved2[190]; /* 190 BYTEs reserved (0) */
} PACKED SVGA_MODE_INFORMATION, *PSVGA_MODE_INFORMATION;
-static U32 BiosVideoMode; /* Current video mode as known by BIOS */
-static U32 ScreenWidth = 80; /* Screen Width in characters */
-static U32 ScreenHeight = 25; /* Screen Height in characters */
-static U32 BytesPerScanLine = 160; /* Number of bytes per scanline (delta) */
+static ULONG BiosVideoMode; /* Current video mode as known by BIOS */
+static ULONG ScreenWidth = 80; /* Screen Width in characters */
+static ULONG ScreenHeight = 25; /* Screen Height in characters */
+static ULONG BytesPerScanLine = 160; /* Number of bytes per scanline (delta) */
static VIDEODISPLAYMODE DisplayMode = VideoTextMode; /* Current display mode */
static BOOL VesaVideoMode = FALSE; /* Are we using a VESA mode? */
static SVGA_MODE_INFORMATION VesaVideoModeInformation; /* Only valid when in VESA mode */
-static U32 CurrentMemoryBank = 0; /* Currently selected VESA bank */
+static ULONG CurrentMemoryBank = 0; /* Currently selected VESA bank */
-static U32
+static ULONG
PcVideoDetectVideoCard(VOID)
{
REGS Regs;
@@ -192,7 +192,7 @@ PcVideoDetectVideoCard(VOID)
}
}
-static VOID PcVideoSetBiosMode(U32 VideoMode)
+static VOID PcVideoSetBiosMode(ULONG VideoMode)
{
REGS Regs;
@@ -297,7 +297,7 @@ VOID PcVideoDisableCursorEmulation(VOID)
}
static VOID
-PcVideoDefineCursor(U32 StartScanLine, U32 EndScanLine)
+PcVideoDefineCursor(ULONG StartScanLine, ULONG EndScanLine)
{
REGS Regs;
@@ -333,7 +333,7 @@ PcVideoDefineCursor(U32 StartScanLine, U32 EndScanLine)
}
static VOID
-PcVideoSetVerticalResolution(U32 ScanLines)
+PcVideoSetVerticalResolution(ULONG ScanLines)
{
REGS Regs;
@@ -439,7 +439,7 @@ PcVideoSetDisplayEnd(VOID)
}
static BOOL
-PcVideoVesaGetSVGAModeInformation(U16 Mode, PSVGA_MODE_INFORMATION ModeInformation)
+PcVideoVesaGetSVGAModeInformation(USHORT Mode, PSVGA_MODE_INFORMATION ModeInformation)
{
REGS Regs;
@@ -511,7 +511,7 @@ PcVideoVesaGetSVGAModeInformation(U16 Mode, PSVGA_MODE_INFORMATION ModeInformati
}
static BOOL
-PcVideoSetBiosVesaMode(U16 Mode)
+PcVideoSetBiosVesaMode(USHORT Mode)
{
REGS Regs;
@@ -697,7 +697,7 @@ PcVideoSetMode80x60(VOID)
}
static BOOL
-PcVideoSetMode(U32 NewMode)
+PcVideoSetMode(ULONG NewMode)
{
CurrentMemoryBank = 0;
@@ -735,7 +735,7 @@ PcVideoSetMode(U32 NewMode)
{
/* 640x480x16 */
PcVideoSetBiosMode(NewMode);
- WRITE_PORT_USHORT((U16*)0x03CE, 0x0F01); /* For some reason this is necessary? */
+ WRITE_PORT_USHORT((USHORT*)0x03CE, 0x0F01); /* For some reason this is necessary? */
ScreenWidth = 640;
ScreenHeight = 480;
BytesPerScanLine = 80;
@@ -830,7 +830,7 @@ PcVideoSetBlinkBit(BOOL Enable)
}
static VOID
-PcVideoSetMemoryBank(U16 BankNumber)
+PcVideoSetMemoryBank(USHORT BankNumber)
{
REGS Regs;
@@ -870,7 +870,7 @@ PcVideoSetMemoryBank(U16 BankNumber)
VIDEODISPLAYMODE
PcVideoSetDisplayMode(char *DisplayModeName, BOOL Init)
{
- U32 VideoMode = VIDEOMODE_NORMAL_TEXT;
+ ULONG VideoMode = VIDEOMODE_NORMAL_TEXT;
if (NULL == DisplayModeName || '\0' == *DisplayModeName)
{
@@ -927,7 +927,7 @@ PcVideoSetDisplayMode(char *DisplayModeName, BOOL Init)
}
VOID
-PcVideoGetDisplaySize(PU32 Width, PU32 Height, PU32 Depth)
+PcVideoGetDisplaySize(PULONG Width, PULONG Height, PULONG Depth)
{
*Width = ScreenWidth;
*Height = ScreenHeight;
@@ -950,14 +950,14 @@ PcVideoGetDisplaySize(PU32 Width, PU32 Height, PU32 Depth)
}
}
-U32
+ULONG
PcVideoGetBufferSize(VOID)
{
return ScreenHeight * BytesPerScanLine;
}
VOID
-PcVideoSetTextCursorPosition(U32 X, U32 Y)
+PcVideoSetTextCursorPosition(ULONG X, ULONG Y)
{
REGS Regs;
@@ -997,10 +997,10 @@ PcVideoHideShowTextCursor(BOOL Show)
VOID
PcVideoCopyOffScreenBufferToVRAM(PVOID Buffer)
{
- U32 BanksToCopy;
- U32 BytesInLastBank;
- U32 CurrentBank;
- U32 BankSize;
+ ULONG BanksToCopy;
+ ULONG BytesInLastBank;
+ ULONG CurrentBank;
+ ULONG BankSize;
/* PcVideoWaitForVerticalRetrace(); */
@@ -1036,14 +1036,14 @@ PcVideoCopyOffScreenBufferToVRAM(PVOID Buffer)
}
VOID
-PcVideoClearScreen(U8 Attr)
+PcVideoClearScreen(UCHAR Attr)
{
- U16 AttrChar;
- U16 *BufPtr;
+ USHORT AttrChar;
+ USHORT *BufPtr;
- AttrChar = ((U16) Attr << 8) | ' ';
- for (BufPtr = (U16 *) VIDEOTEXT_MEM_ADDRESS;
- BufPtr < (U16 *) (VIDEOTEXT_MEM_ADDRESS + VIDEOTEXT_MEM_SIZE);
+ AttrChar = ((USHORT) Attr << 8) | ' ';
+ for (BufPtr = (USHORT *) VIDEOTEXT_MEM_ADDRESS;
+ BufPtr < (USHORT *) (VIDEOTEXT_MEM_ADDRESS + VIDEOTEXT_MEM_SIZE);
BufPtr++)
{
*BufPtr = AttrChar;
@@ -1051,12 +1051,12 @@ PcVideoClearScreen(U8 Attr)
}
VOID
-PcVideoPutChar(int Ch, U8 Attr, unsigned X, unsigned Y)
+PcVideoPutChar(int Ch, UCHAR Attr, unsigned X, unsigned Y)
{
- U16 *BufPtr;
+ USHORT *BufPtr;
- BufPtr = (U16 *) (VIDEOTEXT_MEM_ADDRESS + Y * BytesPerScanLine + X * 2);
- *BufPtr = ((U16) Attr << 8) | (Ch & 0xff);
+ BufPtr = (USHORT *) (VIDEOTEXT_MEM_ADDRESS + Y * BytesPerScanLine + X * 2);
+ *BufPtr = ((USHORT) Attr << 8) | (Ch & 0xff);
}
BOOL
@@ -1066,27 +1066,27 @@ PcVideoIsPaletteFixed(VOID)
}
VOID
-PcVideoSetPaletteColor(U8 Color, U8 Red, U8 Green, U8 Blue)
+PcVideoSetPaletteColor(UCHAR Color, UCHAR Red, UCHAR Green, UCHAR Blue)
{
- WRITE_PORT_UCHAR((U8*) VIDEOPORT_PALETTE_WRITE, Color);
- WRITE_PORT_UCHAR((U8*) VIDEOPORT_PALETTE_DATA, Red);
- WRITE_PORT_UCHAR((U8*) VIDEOPORT_PALETTE_DATA, Green);
- WRITE_PORT_UCHAR((U8*) VIDEOPORT_PALETTE_DATA, Blue);
+ WRITE_PORT_UCHAR((UCHAR*) VIDEOPORT_PALETTE_WRITE, Color);
+ WRITE_PORT_UCHAR((UCHAR*) VIDEOPORT_PALETTE_DATA, Red);
+ WRITE_PORT_UCHAR((UCHAR*) VIDEOPORT_PALETTE_DATA, Green);
+ WRITE_PORT_UCHAR((UCHAR*) VIDEOPORT_PALETTE_DATA, Blue);
}
VOID
-PcVideoGetPaletteColor(U8 Color, U8* Red, U8* Green, U8* Blue)
+PcVideoGetPaletteColor(UCHAR Color, UCHAR* Red, UCHAR* Green, UCHAR* Blue)
{
- WRITE_PORT_UCHAR((U8*) VIDEOPORT_PALETTE_READ, Color);
- *Red = READ_PORT_UCHAR((U8*) VIDEOPORT_PALETTE_DATA);
- *Green = READ_PORT_UCHAR((U8*) VIDEOPORT_PALETTE_DATA);
- *Blue = READ_PORT_UCHAR((U8*) VIDEOPORT_PALETTE_DATA);
+ WRITE_PORT_UCHAR((UCHAR*) VIDEOPORT_PALETTE_READ, Color);
+ *Red = READ_PORT_UCHAR((UCHAR*) VIDEOPORT_PALETTE_DATA);
+ *Green = READ_PORT_UCHAR((UCHAR*) VIDEOPORT_PALETTE_DATA);
+ *Blue = READ_PORT_UCHAR((UCHAR*) VIDEOPORT_PALETTE_DATA);
}
VOID
PcVideoSync(VOID)
{
- while (1 == (READ_PORT_UCHAR((U8*)VIDEOPORT_VERTICAL_RETRACE) & 0x08))
+ while (1 == (READ_PORT_UCHAR((UCHAR*)VIDEOPORT_VERTICAL_RETRACE) & 0x08))
{
/*
* Keep reading the port until bit 3 is clear
@@ -1096,7 +1096,7 @@ PcVideoSync(VOID)
*/
}
- while (0 == (READ_PORT_UCHAR((U8*)VIDEOPORT_VERTICAL_RETRACE) & 0x08))
+ while (0 == (READ_PORT_UCHAR((UCHAR*)VIDEOPORT_VERTICAL_RETRACE) & 0x08))
{
/*
* Keep reading the port until bit 3 is set
diff --git a/reactos/boot/freeldr/freeldr/arch/i386/portio.c b/reactos/boot/freeldr/freeldr/arch/i386/portio.c
index ba3361aa4df..feebd228414 100644
--- a/reactos/boot/freeldr/freeldr/arch/i386/portio.c
+++ b/reactos/boot/freeldr/freeldr/arch/i386/portio.c
@@ -51,37 +51,45 @@
#define SLOW_DOWN_IO __SLOW_DOWN_IO
#endif
-VOID /*STDCALL*/
+#undef READ_PORT_BUFFER_UCHAR
+VOID
+STDCALL
READ_PORT_BUFFER_UCHAR (PUCHAR Port,
PUCHAR Buffer,
- U32 Count)
+ ULONG Count)
{
__asm__ __volatile__ ("cld ; rep ; insb\n\t"
: "=D" (Buffer), "=c" (Count)
: "d" (Port),"0" (Buffer),"1" (Count));
}
-VOID /*STDCALL*/
-READ_PORT_BUFFER_USHORT (U16* Port,
- U16* Buffer,
- U32 Count)
+#undef READ_PORT_BUFFER_USHORT
+VOID
+STDCALL
+READ_PORT_BUFFER_USHORT (USHORT* Port,
+ USHORT* Buffer,
+ ULONG Count)
{
__asm__ __volatile__ ("cld ; rep ; insw"
: "=D" (Buffer), "=c" (Count)
: "d" (Port),"0" (Buffer),"1" (Count));
}
-VOID /*STDCALL*/
-READ_PORT_BUFFER_ULONG (U32* Port,
- U32* Buffer,
- U32 Count)
+#undef READ_PORT_BUFFER_ULONG
+VOID
+STDCALL
+READ_PORT_BUFFER_ULONG (ULONG* Port,
+ ULONG* Buffer,
+ ULONG Count)
{
__asm__ __volatile__ ("cld ; rep ; insl"
: "=D" (Buffer), "=c" (Count)
: "d" (Port),"0" (Buffer),"1" (Count));
}
-UCHAR /*STDCALL*/
+#undef READ_PORT_UCHAR
+UCHAR
+STDCALL
READ_PORT_UCHAR (PUCHAR Port)
{
UCHAR Value;
@@ -93,10 +101,12 @@ READ_PORT_UCHAR (PUCHAR Port)
return(Value);
}
-U16 /*STDCALL*/
-READ_PORT_USHORT (U16* Port)
+#undef READ_PORT_USHORT
+USHORT
+STDCALL
+READ_PORT_USHORT (USHORT* Port)
{
- U16 Value;
+ USHORT Value;
__asm__("inw %w1, %0\n\t"
: "=a" (Value)
@@ -105,10 +115,12 @@ READ_PORT_USHORT (U16* Port)
return(Value);
}
-U32 /*STDCALL*/
-READ_PORT_ULONG (U32* Port)
+#undef READ_PORT_ULONG
+ULONG
+STDCALL
+READ_PORT_ULONG (ULONG* Port)
{
- U32 Value;
+ ULONG Value;
__asm__("inl %w1, %0\n\t"
: "=a" (Value)
@@ -117,37 +129,45 @@ READ_PORT_ULONG (U32* Port)
return(Value);
}
-VOID /*STDCALL*/
+#undef WRITE_PORT_BUFFER_UCHAR
+VOID
+STDCALL
WRITE_PORT_BUFFER_UCHAR (PUCHAR Port,
PUCHAR Buffer,
- U32 Count)
+ ULONG Count)
{
__asm__ __volatile__ ("cld ; rep ; outsb"
: "=S" (Buffer), "=c" (Count)
: "d" (Port),"0" (Buffer),"1" (Count));
}
-VOID /*STDCALL*/
-WRITE_PORT_BUFFER_USHORT (U16* Port,
- U16* Buffer,
- U32 Count)
+#undef WRITE_PORT_BUFFER_USHORT
+VOID
+STDCALL
+WRITE_PORT_BUFFER_USHORT (USHORT* Port,
+ USHORT* Buffer,
+ ULONG Count)
{
__asm__ __volatile__ ("cld ; rep ; outsw"
: "=S" (Buffer), "=c" (Count)
: "d" (Port),"0" (Buffer),"1" (Count));
}
-VOID /*STDCALL*/
-WRITE_PORT_BUFFER_ULONG (U32* Port,
- U32* Buffer,
- U32 Count)
+#undef WRITE_PORT_BUFFER_ULONG
+VOID
+STDCALL
+WRITE_PORT_BUFFER_ULONG (ULONG* Port,
+ ULONG* Buffer,
+ ULONG Count)
{
__asm__ __volatile__ ("cld ; rep ; outsl"
: "=S" (Buffer), "=c" (Count)
: "d" (Port),"0" (Buffer),"1" (Count));
}
-VOID /*STDCALL*/
+#undef WRITE_PORT_UCHAR
+VOID
+STDCALL
WRITE_PORT_UCHAR (PUCHAR Port,
UCHAR Value)
{
@@ -158,9 +178,11 @@ WRITE_PORT_UCHAR (PUCHAR Port,
SLOW_DOWN_IO;
}
-VOID /*STDCALL*/
-WRITE_PORT_USHORT (U16* Port,
- U16 Value)
+#undef WRITE_PORT_USHORT
+VOID
+STDCALL
+WRITE_PORT_USHORT (USHORT* Port,
+ USHORT Value)
{
__asm__("outw %0, %w1\n\t"
:
@@ -169,9 +191,11 @@ WRITE_PORT_USHORT (U16* Port,
SLOW_DOWN_IO;
}
-VOID /*STDCALL*/
-WRITE_PORT_ULONG (U32* Port,
- U32 Value)
+#undef WRITE_PORT_ULONG
+VOID
+STDCALL
+WRITE_PORT_ULONG (ULONG* Port,
+ ULONG Value)
{
__asm__("outl %0, %w1\n\t"
:
diff --git a/reactos/boot/freeldr/freeldr/arch/i386/xboxcons.c b/reactos/boot/freeldr/freeldr/arch/i386/xboxcons.c
index 179b9f85cdf..d803144bc27 100644
--- a/reactos/boot/freeldr/freeldr/arch/i386/xboxcons.c
+++ b/reactos/boot/freeldr/freeldr/arch/i386/xboxcons.c
@@ -28,9 +28,9 @@ static unsigned CurrentAttr = 0x0f;
VOID
XboxConsPutChar(int c)
{
- U32 Width;
- U32 Height;
- U32 Depth;
+ ULONG Width;
+ ULONG Height;
+ ULONG Depth;
if ('\r' == c)
{
diff --git a/reactos/boot/freeldr/freeldr/arch/i386/xboxdisk.c b/reactos/boot/freeldr/freeldr/arch/i386/xboxdisk.c
index 7fb1cd6fc4d..68d805b4ab2 100644
--- a/reactos/boot/freeldr/freeldr/arch/i386/xboxdisk.c
+++ b/reactos/boot/freeldr/freeldr/arch/i386/xboxdisk.c
@@ -38,9 +38,9 @@
static struct
{
- U32 SectorCountBeforePartition;
- U32 PartitionSectorCount;
- U8 SystemIndicator;
+ ULONG SectorCountBeforePartition;
+ ULONG PartitionSectorCount;
+ UCHAR SystemIndicator;
} XboxPartitions[] =
{
/* This is in the \Device\Harddisk0\Partition.. order used by the Xbox kernel */
@@ -155,17 +155,17 @@ static struct
* Data block read and write commands
*/
#define IDEReadBlock(Address, Buffer, Count) \
- (READ_PORT_BUFFER_USHORT((PU16)((Address) + IDE_REG_DATA_PORT), (PU16)(Buffer), (Count) / 2))
+ (READ_PORT_BUFFER_USHORT((PUSHORT)((Address) + IDE_REG_DATA_PORT), (PUSHORT)(Buffer), (Count) / 2))
#define IDEWriteBlock(Address, Buffer, Count) \
- (WRITE_PORT_BUFFER_USHORT((PU16)((Address) + IDE_REG_DATA_PORT), (PU16)(Buffer), (Count) / 2))
+ (WRITE_PORT_BUFFER_USHORT((PUSHORT)((Address) + IDE_REG_DATA_PORT), (PUSHORT)(Buffer), (Count) / 2))
#define IDEReadBlock32(Address, Buffer, Count) \
- (READ_PORT_BUFFER_ULONG((PU32)((Address) + IDE_REG_DATA_PORT), (PU32)(Buffer), (Count) / 4))
+ (READ_PORT_BUFFER_ULONG((PULONG)((Address) + IDE_REG_DATA_PORT), (PULONG)(Buffer), (Count) / 4))
#define IDEWriteBlock32(Address, Buffer, Count) \
- (WRITE_PORT_BUFFER_ULONG((PU32)((Address) + IDE_REG_DATA_PORT), (PU32)(Buffer), (Count) / 4))
+ (WRITE_PORT_BUFFER_ULONG((PULONG)((Address) + IDE_REG_DATA_PORT), (PULONG)(Buffer), (Count) / 4))
#define IDEReadWord(Address) \
- (READ_PORT_USHORT((PU16)((Address) + IDE_REG_DATA_PORT)))
+ (READ_PORT_USHORT((PUSHORT)((Address) + IDE_REG_DATA_PORT)))
/*
* Access macros for control registers
@@ -180,64 +180,64 @@ static struct
typedef struct _IDE_DRIVE_IDENTIFY
{
- U16 ConfigBits; /*00*/
- U16 LogicalCyls; /*01*/
- U16 Reserved02; /*02*/
- U16 LogicalHeads; /*03*/
- U16 BytesPerTrack; /*04*/
- U16 BytesPerSector; /*05*/
- U16 SectorsPerTrack; /*06*/
- U8 InterSectorGap; /*07*/
- U8 InterSectorGapSize;
- U8 Reserved08H; /*08*/
- U8 BytesInPLO;
- U16 VendorUniqueCnt; /*09*/
+ USHORT ConfigBits; /*00*/
+ USHORT LogicalCyls; /*01*/
+ USHORT Reserved02; /*02*/
+ USHORT LogicalHeads; /*03*/
+ USHORT BytesPerTrack; /*04*/
+ USHORT BytesPerSector; /*05*/
+ USHORT SectorsPerTrack; /*06*/
+ UCHAR InterSectorGap; /*07*/
+ UCHAR InterSectorGapSize;
+ UCHAR Reserved08H; /*08*/
+ UCHAR BytesInPLO;
+ USHORT VendorUniqueCnt; /*09*/
char SerialNumber[20]; /*10*/
- U16 ControllerType; /*20*/
- U16 BufferSize; /*21*/
- U16 ECCByteCnt; /*22*/
+ USHORT ControllerType; /*20*/
+ USHORT BufferSize; /*21*/
+ USHORT ECCByteCnt; /*22*/
char FirmwareRev[8]; /*23*/
char ModelNumber[40]; /*27*/
- U16 RWMultImplemented; /*47*/
- U16 DWordIo; /*48*/
- U16 Capabilities; /*49*/
+ USHORT RWMultImplemented; /*47*/
+ USHORT DWordIo; /*48*/
+ USHORT Capabilities; /*49*/
#define IDE_DRID_STBY_SUPPORTED 0x2000
#define IDE_DRID_IORDY_SUPPORTED 0x0800
#define IDE_DRID_IORDY_DISABLE 0x0400
#define IDE_DRID_LBA_SUPPORTED 0x0200
#define IDE_DRID_DMA_SUPPORTED 0x0100
- U16 Reserved50; /*50*/
- U16 MinPIOTransTime; /*51*/
- U16 MinDMATransTime; /*52*/
- U16 TMFieldsValid; /*53*/
- U16 TMCylinders; /*54*/
- U16 TMHeads; /*55*/
- U16 TMSectorsPerTrk; /*56*/
- U16 TMCapacityLo; /*57*/
- U16 TMCapacityHi; /*58*/
- U16 RWMultCurrent; /*59*/
- U16 TMSectorCountLo; /*60*/
- U16 TMSectorCountHi; /*61*/
- U16 DmaModes; /*62*/
- U16 MultiDmaModes; /*63*/
- U16 Reserved64[5]; /*64*/
- U16 Reserved69[2]; /*69*/
- U16 Reserved71[4]; /*71*/
- U16 MaxQueueDepth; /*75*/
- U16 Reserved76[4]; /*76*/
- U16 MajorRevision; /*80*/
- U16 MinorRevision; /*81*/
- U16 SupportedFeatures82; /*82*/
- U16 SupportedFeatures83; /*83*/
- U16 SupportedFeatures84; /*84*/
- U16 EnabledFeatures85; /*85*/
- U16 EnabledFeatures86; /*86*/
- U16 EnabledFeatures87; /*87*/
- U16 UltraDmaModes; /*88*/
- U16 Reserved89[11]; /*89*/
- U16 Max48BitAddress[4]; /*100*/
- U16 Reserved104[151]; /*104*/
- U16 Checksum; /*255*/
+ USHORT Reserved50; /*50*/
+ USHORT MinPIOTransTime; /*51*/
+ USHORT MinDMATransTime; /*52*/
+ USHORT TMFieldsValid; /*53*/
+ USHORT TMCylinders; /*54*/
+ USHORT TMHeads; /*55*/
+ USHORT TMSectorsPerTrk; /*56*/
+ USHORT TMCapacityLo; /*57*/
+ USHORT TMCapacityHi; /*58*/
+ USHORT RWMultCurrent; /*59*/
+ USHORT TMSectorCountLo; /*60*/
+ USHORT TMSectorCountHi; /*61*/
+ USHORT DmaModes; /*62*/
+ USHORT MultiDmaModes; /*63*/
+ USHORT Reserved64[5]; /*64*/
+ USHORT Reserved69[2]; /*69*/
+ USHORT Reserved71[4]; /*71*/
+ USHORT MaxQueueDepth; /*75*/
+ USHORT Reserved76[4]; /*76*/
+ USHORT MajorRevision; /*80*/
+ USHORT MinorRevision; /*81*/
+ USHORT SupportedFeatures82; /*82*/
+ USHORT SupportedFeatures83; /*83*/
+ USHORT SupportedFeatures84; /*84*/
+ USHORT EnabledFeatures85; /*85*/
+ USHORT EnabledFeatures86; /*86*/
+ USHORT EnabledFeatures87; /*87*/
+ USHORT UltraDmaModes; /*88*/
+ USHORT Reserved89[11]; /*89*/
+ USHORT Max48BitAddress[4]; /*100*/
+ USHORT Reserved104[151]; /*104*/
+ USHORT Checksum; /*255*/
} IDE_DRIVE_IDENTIFY, *PIDE_DRIVE_IDENTIFY;
/* XboxDiskPolledRead
@@ -249,15 +249,15 @@ typedef struct _IDE_DRIVE_IDENTIFY
* PASSIVE_LEVEL
*
* ARGUMENTS:
- * U32 CommandPort Address of command port for drive
- * U32 ControlPort Address of control port for drive
- * U8 PreComp Value to write to precomp register
- * U8 SectorCnt Value to write to sectorCnt register
- * U8 SectorNum Value to write to sectorNum register
- * U8 CylinderLow Value to write to CylinderLow register
- * U8 CylinderHigh Value to write to CylinderHigh register
- * U8 DrvHead Value to write to Drive/Head register
- * U8 Command Value to write to Command register
+ * ULONG CommandPort Address of command port for drive
+ * ULONG ControlPort Address of control port for drive
+ * UCHAR PreComp Value to write to precomp register
+ * UCHAR SectorCnt Value to write to sectorCnt register
+ * UCHAR SectorNum Value to write to sectorNum register
+ * UCHAR CylinderLow Value to write to CylinderLow register
+ * UCHAR CylinderHigh Value to write to CylinderHigh register
+ * UCHAR DrvHead Value to write to Drive/Head register
+ * UCHAR Command Value to write to Command register
* PVOID Buffer Buffer for output data
*
* RETURNS:
@@ -265,21 +265,21 @@ typedef struct _IDE_DRIVE_IDENTIFY
*/
static BOOL
-XboxDiskPolledRead(U32 CommandPort,
- U32 ControlPort,
- U8 PreComp,
- U8 SectorCnt,
- U8 SectorNum,
- U8 CylinderLow,
- U8 CylinderHigh,
- U8 DrvHead,
- U8 Command,
+XboxDiskPolledRead(ULONG CommandPort,
+ ULONG ControlPort,
+ UCHAR PreComp,
+ UCHAR SectorCnt,
+ UCHAR SectorNum,
+ UCHAR CylinderLow,
+ UCHAR CylinderHigh,
+ UCHAR DrvHead,
+ UCHAR Command,
PVOID Buffer)
{
- U32 SectorCount = 0;
- U32 RetryCount;
+ ULONG SectorCount = 0;
+ ULONG RetryCount;
BOOL Junk = FALSE;
- U8 Status;
+ UCHAR Status;
/* Wait for BUSY to clear */
for (RetryCount = 0; RetryCount < IDE_MAX_BUSY_RETRIES; RetryCount++)
@@ -289,7 +289,7 @@ XboxDiskPolledRead(U32 CommandPort,
{
break;
}
- KeStallExecutionProcessor(10);
+ StallExecutionProcessor(10);
}
DbgPrint((DPRINT_DISK, "status=0x%x\n", Status));
DbgPrint((DPRINT_DISK, "waited %d usecs for busy to clear\n", RetryCount * 10));
@@ -301,11 +301,11 @@ XboxDiskPolledRead(U32 CommandPort,
/* Write Drive/Head to select drive */
IDEWriteDriveHead(CommandPort, IDE_DH_FIXED | DrvHead);
- KeStallExecutionProcessor(500);
+ StallExecutionProcessor(500);
/* Disable interrupts */
IDEWriteDriveControl(ControlPort, IDE_DC_nIEN);
- KeStallExecutionProcessor(500);
+ StallExecutionProcessor(500);
/* Issue command to drive */
if (DrvHead & IDE_DH_LBA)
@@ -338,7 +338,7 @@ XboxDiskPolledRead(U32 CommandPort,
/* Issue the command */
IDEWriteCommand(CommandPort, Command);
- KeStallExecutionProcessor(50);
+ StallExecutionProcessor(50);
/* wait for DRQ or error */
for (RetryCount = 0; RetryCount < IDE_MAX_POLL_RETRIES; RetryCount++)
@@ -349,7 +349,7 @@ XboxDiskPolledRead(U32 CommandPort,
if (Status & IDE_SR_ERR)
{
IDEWriteDriveControl(ControlPort, 0);
- KeStallExecutionProcessor(50);
+ StallExecutionProcessor(50);
IDEReadStatus(CommandPort);
return FALSE;
@@ -362,20 +362,20 @@ XboxDiskPolledRead(U32 CommandPort,
else
{
IDEWriteDriveControl(ControlPort, 0);
- KeStallExecutionProcessor(50);
+ StallExecutionProcessor(50);
IDEReadStatus(CommandPort);
return FALSE;
}
}
- KeStallExecutionProcessor(10);
+ StallExecutionProcessor(10);
}
/* timed out */
if (RetryCount >= IDE_MAX_POLL_RETRIES)
{
IDEWriteDriveControl(ControlPort, 0);
- KeStallExecutionProcessor(50);
+ StallExecutionProcessor(50);
IDEReadStatus(CommandPort);
return FALSE;
@@ -405,7 +405,7 @@ XboxDiskPolledRead(U32 CommandPort,
if (Status & IDE_SR_ERR)
{
IDEWriteDriveControl(ControlPort, 0);
- KeStallExecutionProcessor(50);
+ StallExecutionProcessor(50);
IDEReadStatus(CommandPort);
return FALSE;
@@ -427,7 +427,7 @@ XboxDiskPolledRead(U32 CommandPort,
SectorCount - SectorCnt));
}
IDEWriteDriveControl(ControlPort, 0);
- KeStallExecutionProcessor(50);
+ StallExecutionProcessor(50);
IDEReadStatus(CommandPort);
return TRUE;
@@ -438,10 +438,10 @@ XboxDiskPolledRead(U32 CommandPort,
}
BOOL
-XboxDiskReadLogicalSectors(U32 DriveNumber, U64 SectorNumber, U32 SectorCount, PVOID Buffer)
+XboxDiskReadLogicalSectors(ULONG DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer)
{
- U32 StartSector;
- U8 Count;
+ ULONG StartSector;
+ UCHAR Count;
if (DriveNumber < 0x80 || 2 <= (DriveNumber & 0x0f))
{
@@ -456,7 +456,7 @@ XboxDiskReadLogicalSectors(U32 DriveNumber, U64 SectorNumber, U32 SectorCount, P
return FALSE;
}
- StartSector = (U32) SectorNumber;
+ StartSector = (ULONG) SectorNumber;
while (0 < SectorCount)
{
Count = (SectorCount <= 255 ? SectorCount : 255);
@@ -481,9 +481,9 @@ XboxDiskReadLogicalSectors(U32 DriveNumber, U64 SectorNumber, U32 SectorCount, P
}
BOOL
-XboxDiskGetPartitionEntry(U32 DriveNumber, U32 PartitionNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry)
+XboxDiskGetPartitionEntry(ULONG DriveNumber, ULONG PartitionNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry)
{
- U8 SectorData[IDE_SECTOR_BUF_SZ];
+ UCHAR SectorData[IDE_SECTOR_BUF_SZ];
/* This is the Xbox, chances are that there is a Xbox-standard partitionless
* disk in it so let's check that first */
@@ -491,7 +491,7 @@ XboxDiskGetPartitionEntry(U32 DriveNumber, U32 PartitionNumber, PPARTITION_TABLE
if (1 <= PartitionNumber && PartitionNumber <= sizeof(XboxPartitions) / sizeof(XboxPartitions[0]) &&
MachDiskReadLogicalSectors(DriveNumber, XBOX_SIGNATURE_SECTOR, 1, SectorData))
{
- if (*((PU32) SectorData) == XBOX_SIGNATURE)
+ if (*((PULONG) SectorData) == XBOX_SIGNATURE)
{
memset(PartitionTableEntry, 0, sizeof(PARTITION_TABLE_ENTRY));
PartitionTableEntry->SystemIndicator = XboxPartitions[PartitionNumber - 1].SystemIndicator;
@@ -506,10 +506,10 @@ XboxDiskGetPartitionEntry(U32 DriveNumber, U32 PartitionNumber, PPARTITION_TABLE
}
BOOL
-XboxDiskGetDriveGeometry(U32 DriveNumber, PGEOMETRY Geometry)
+XboxDiskGetDriveGeometry(ULONG DriveNumber, PGEOMETRY Geometry)
{
IDE_DRIVE_IDENTIFY DrvParms;
- U32 i;
+ ULONG i;
BOOL Atapi;
Atapi = FALSE; /* FIXME */
@@ -565,8 +565,8 @@ XboxDiskGetDriveGeometry(U32 DriveNumber, PGEOMETRY Geometry)
return TRUE;
}
-U32
-XboxDiskGetCacheableBlockCount(U32 DriveNumber)
+ULONG
+XboxDiskGetCacheableBlockCount(ULONG DriveNumber)
{
/* 64 seems a nice number, it is used by the machpc code for LBA devices */
return 64;
diff --git a/reactos/boot/freeldr/freeldr/arch/i386/xboxfont.c b/reactos/boot/freeldr/freeldr/arch/i386/xboxfont.c
index 359baac9174..b07a81b01cc 100644
--- a/reactos/boot/freeldr/freeldr/arch/i386/xboxfont.c
+++ b/reactos/boot/freeldr/freeldr/arch/i386/xboxfont.c
@@ -23,7 +23,7 @@
#include "machine.h"
#include "machxbox.h"
-U8 XboxFont8x16[256 * 16] =
+UCHAR XboxFont8x16[256 * 16] =
{
0x00,0x00,0x00,0x7c,0xc6,0xc6,0xde,0xde,0xde,0xdc,0xc0,0x7c,0x00,0x00,0x00,0x00, /* 0x00 */
0x00,0x00,0x7e,0x81,0xa5,0x81,0x81,0xa5,0x99,0x81,0x81,0x7e,0x00,0x00,0x00,0x00, /* 0x01 */
diff --git a/reactos/boot/freeldr/freeldr/arch/i386/xboxmem.c b/reactos/boot/freeldr/freeldr/arch/i386/xboxmem.c
index 1f5aad57c72..67e244a9a8f 100644
--- a/reactos/boot/freeldr/freeldr/arch/i386/xboxmem.c
+++ b/reactos/boot/freeldr/freeldr/arch/i386/xboxmem.c
@@ -29,8 +29,8 @@
#include "machxbox.h"
#include "portio.h"
-static U32 InstalledMemoryMb = 0;
-static U32 AvailableMemoryMb = 0;
+static ULONG InstalledMemoryMb = 0;
+static ULONG AvailableMemoryMb = 0;
#define TEST_SIZE 0x200
#define TEST_PATTERN1 0xaa
@@ -39,15 +39,15 @@ static U32 AvailableMemoryMb = 0;
VOID
XboxMemInit(VOID)
{
- U8 ControlRegion[TEST_SIZE];
+ UCHAR ControlRegion[TEST_SIZE];
PVOID MembaseTop = (PVOID)(64 * 1024 * 1024);
PVOID MembaseLow = (PVOID)0;
- (*(PU32)(0xfd000000 + 0x100200)) = 0x03070103 ;
- (*(PU32)(0xfd000000 + 0x100204)) = 0x11448000 ;
+ (*(PULONG)(0xfd000000 + 0x100200)) = 0x03070103 ;
+ (*(PULONG)(0xfd000000 + 0x100204)) = 0x11448000 ;
- WRITE_PORT_ULONG((U32*) 0xcf8, CONFIG_CMD(0, 0, 0x84));
- WRITE_PORT_ULONG((U32*) 0xcfc, 0x7ffffff); /* Prep hardware for 128 Mb */
+ WRITE_PORT_ULONG((ULONG*) 0xcf8, CONFIG_CMD(0, 0, 0x84));
+ WRITE_PORT_ULONG((ULONG*) 0xcfc, 0x7ffffff); /* Prep hardware for 128 Mb */
InstalledMemoryMb = 64;
memset(ControlRegion, TEST_PATTERN1, TEST_SIZE);
@@ -76,16 +76,16 @@ XboxMemInit(VOID)
}
/* Set hardware for amount of memory detected */
- WRITE_PORT_ULONG((U32*) 0xcf8, CONFIG_CMD(0, 0, 0x84));
- WRITE_PORT_ULONG((U32*) 0xcfc, InstalledMemoryMb * 1024 * 1024 - 1);
+ WRITE_PORT_ULONG((ULONG*) 0xcf8, CONFIG_CMD(0, 0, 0x84));
+ WRITE_PORT_ULONG((ULONG*) 0xcfc, InstalledMemoryMb * 1024 * 1024 - 1);
AvailableMemoryMb = InstalledMemoryMb;
}
-U32
-XboxMemGetMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, U32 MaxMemoryMapSize)
+ULONG
+XboxMemGetMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, ULONG MaxMemoryMapSize)
{
- U32 EntryCount = 0;
+ ULONG EntryCount = 0;
/* Synthesize memory map */
if (1 <= MaxMemoryMapSize)
@@ -110,7 +110,7 @@ XboxMemGetMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, U32 MaxMemoryMapSize)
}
PVOID
-XboxMemReserveMemory(U32 MbToReserve)
+XboxMemReserveMemory(ULONG MbToReserve)
{
if (0 == InstalledMemoryMb)
{
diff --git a/reactos/boot/freeldr/freeldr/arch/i386/xboxrtc.c b/reactos/boot/freeldr/freeldr/arch/i386/xboxrtc.c
index 0e869841013..d6000b7cf93 100644
--- a/reactos/boot/freeldr/freeldr/arch/i386/xboxrtc.c
+++ b/reactos/boot/freeldr/freeldr/arch/i386/xboxrtc.c
@@ -41,7 +41,7 @@ HalpQueryCMOS(UCHAR Reg)
}
VOID
-XboxRTCGetCurrentDateTime(PU32 Year, PU32 Month, PU32 Day, PU32 Hour, PU32 Minute, PU32 Second)
+XboxRTCGetCurrentDateTime(PULONG Year, PULONG Month, PULONG Day, PULONG Hour, PULONG Minute, PULONG Second)
{
while (HalpQueryCMOS (RTC_REGISTER_A) & RTC_REG_A_UIP)
{
diff --git a/reactos/boot/freeldr/freeldr/arch/i386/xboxvideo.c b/reactos/boot/freeldr/freeldr/arch/i386/xboxvideo.c
index 8457b2beb80..fdcb67aaf0b 100644
--- a/reactos/boot/freeldr/freeldr/arch/i386/xboxvideo.c
+++ b/reactos/boot/freeldr/freeldr/arch/i386/xboxvideo.c
@@ -30,10 +30,10 @@
#define I2C_IO_BASE 0xc000
static PVOID FrameBuffer;
-static U32 ScreenWidth;
-static U32 ScreenHeight;
-static U32 BytesPerPixel;
-static U32 Delta;
+static ULONG ScreenWidth;
+static ULONG ScreenHeight;
+static ULONG BytesPerPixel;
+static ULONG Delta;
#define CHAR_WIDTH 8
#define CHAR_HEIGHT 16
@@ -45,16 +45,16 @@ static U32 Delta;
#define MAKE_COLOR(Red, Green, Blue) (0xff000000 | (((Red) & 0xff) << 16) | (((Green) & 0xff) << 8) | ((Blue) & 0xff))
static VOID
-XboxVideoOutputChar(U8 Char, unsigned X, unsigned Y, U32 FgColor, U32 BgColor)
+XboxVideoOutputChar(UCHAR Char, unsigned X, unsigned Y, ULONG FgColor, ULONG BgColor)
{
- PU8 FontPtr;
- PU32 Pixel;
- U8 Mask;
+ PUCHAR FontPtr;
+ PULONG Pixel;
+ UCHAR Mask;
unsigned Line;
unsigned Col;
FontPtr = XboxFont8x16 + Char * 16;
- Pixel = (PU32) ((char *) FrameBuffer + (Y * CHAR_HEIGHT + TOP_BOTTOM_LINES) * Delta
+ Pixel = (PULONG) ((char *) FrameBuffer + (Y * CHAR_HEIGHT + TOP_BOTTOM_LINES) * Delta
+ X * CHAR_WIDTH * BytesPerPixel);
for (Line = 0; Line < CHAR_HEIGHT; Line++)
{
@@ -64,14 +64,14 @@ XboxVideoOutputChar(U8 Char, unsigned X, unsigned Y, U32 FgColor, U32 BgColor)
Pixel[Col] = (0 != (FontPtr[Line] & Mask) ? FgColor : BgColor);
Mask = Mask >> 1;
}
- Pixel = (PU32) ((char *) Pixel + Delta);
+ Pixel = (PULONG) ((char *) Pixel + Delta);
}
}
-static U32
-XboxVideoAttrToSingleColor(U8 Attr)
+static ULONG
+XboxVideoAttrToSingleColor(UCHAR Attr)
{
- U8 Intensity;
+ UCHAR Intensity;
Intensity = (0 == (Attr & 0x08) ? 127 : 255);
@@ -82,21 +82,21 @@ XboxVideoAttrToSingleColor(U8 Attr)
}
static VOID
-XboxVideoAttrToColors(U8 Attr, U32 *FgColor, U32 *BgColor)
+XboxVideoAttrToColors(UCHAR Attr, ULONG *FgColor, ULONG *BgColor)
{
*FgColor = XboxVideoAttrToSingleColor(Attr & 0xf);
*BgColor = XboxVideoAttrToSingleColor((Attr >> 4) & 0xf);
}
static VOID
-XboxVideoClearScreenColor(U32 Color, BOOL FullScreen)
+XboxVideoClearScreenColor(ULONG Color, BOOL FullScreen)
{
- U32 Line, Col;
- PU32 p;
+ ULONG Line, Col;
+ PULONG p;
for (Line = 0; Line < ScreenHeight - (FullScreen ? 0 : 2 * TOP_BOTTOM_LINES); Line++)
{
- p = (PU32) ((char *) FrameBuffer + (Line + (FullScreen ? 0 : TOP_BOTTOM_LINES)) * Delta);
+ p = (PULONG) ((char *) FrameBuffer + (Line + (FullScreen ? 0 : TOP_BOTTOM_LINES)) * Delta);
for (Col = 0; Col < ScreenWidth; Col++)
{
*p++ = Color;
@@ -105,9 +105,9 @@ XboxVideoClearScreenColor(U32 Color, BOOL FullScreen)
}
VOID
-XboxVideoClearScreen(U8 Attr)
+XboxVideoClearScreen(UCHAR Attr)
{
- U32 FgColor, BgColor;
+ ULONG FgColor, BgColor;
XboxVideoAttrToColors(Attr, &FgColor, &BgColor);
@@ -115,9 +115,9 @@ XboxVideoClearScreen(U8 Attr)
}
VOID
-XboxVideoPutChar(int Ch, U8 Attr, unsigned X, unsigned Y)
+XboxVideoPutChar(int Ch, UCHAR Attr, unsigned X, unsigned Y)
{
- U32 FgColor, BgColor;
+ ULONG FgColor, BgColor;
XboxVideoAttrToColors(Attr, &FgColor, &BgColor);
@@ -125,11 +125,11 @@ XboxVideoPutChar(int Ch, U8 Attr, unsigned X, unsigned Y)
}
static BOOL
-ReadfromSMBus(UCHAR Address, UCHAR bRegister, UCHAR Size, U32 *Data_to_smbus)
+ReadfromSMBus(UCHAR Address, UCHAR bRegister, UCHAR Size, ULONG *Data_to_smbus)
{
int nRetriesToLive=50;
- while (0 != (READ_PORT_USHORT((PU16) (I2C_IO_BASE + 0)) & 0x0800))
+ while (0 != (READ_PORT_USHORT((PUSHORT) (I2C_IO_BASE + 0)) & 0x0800))
{
; /* Franz's spin while bus busy with any master traffic */
}
@@ -142,8 +142,8 @@ ReadfromSMBus(UCHAR Address, UCHAR bRegister, UCHAR Size, U32 *Data_to_smbus)
WRITE_PORT_UCHAR((PUCHAR) (I2C_IO_BASE + 4), (Address << 1) | 1);
WRITE_PORT_UCHAR((PUCHAR) (I2C_IO_BASE + 8), bRegister);
- temp = READ_PORT_USHORT((U16 *) (I2C_IO_BASE + 0));
- WRITE_PORT_USHORT((PU16) (I2C_IO_BASE + 0), temp); /* clear down all preexisting errors */
+ temp = READ_PORT_USHORT((USHORT *) (I2C_IO_BASE + 0));
+ WRITE_PORT_USHORT((PUSHORT) (I2C_IO_BASE + 0), temp); /* clear down all preexisting errors */
switch (Size)
{
@@ -186,7 +186,7 @@ ReadfromSMBus(UCHAR Address, UCHAR bRegister, UCHAR Size, U32 *Data_to_smbus)
READ_PORT_UCHAR((PUCHAR) (I2C_IO_BASE + 9));
break;
case 2:
- *Data_to_smbus = READ_PORT_USHORT((U16 *) (I2C_IO_BASE + 6));
+ *Data_to_smbus = READ_PORT_USHORT((USHORT *) (I2C_IO_BASE + 6));
break;
default:
*Data_to_smbus = READ_PORT_UCHAR((PUCHAR) (I2C_IO_BASE + 6));
@@ -203,7 +203,7 @@ ReadfromSMBus(UCHAR Address, UCHAR bRegister, UCHAR Size, U32 *Data_to_smbus)
static BOOL
-I2CTransmitByteGetReturn(UCHAR bPicAddressI2cFormat, UCHAR bDataToWrite, U32 *Return)
+I2CTransmitByteGetReturn(UCHAR bPicAddressI2cFormat, UCHAR bDataToWrite, ULONG *Return)
{
return ReadfromSMBus(bPicAddressI2cFormat, bDataToWrite, 1, Return);
}
@@ -212,9 +212,9 @@ I2CTransmitByteGetReturn(UCHAR bPicAddressI2cFormat, UCHAR bDataToWrite, U32 *Re
VOID
XboxVideoInit(VOID)
{
- U32 AvMode;
+ ULONG AvMode;
- FrameBuffer = (PVOID)((U32) XboxMemReserveMemory(FB_SIZE_MB) | 0xf0000000);
+ FrameBuffer = (PVOID)((ULONG) XboxMemReserveMemory(FB_SIZE_MB) | 0xf0000000);
if (I2CTransmitByteGetReturn(0x10, 0x04, &AvMode))
{
@@ -247,7 +247,7 @@ XboxVideoInit(VOID)
XboxVideoClearScreenColor(MAKE_COLOR(0, 0, 0), TRUE);
/* Tell the nVidia controller about the framebuffer */
- *((PU32) 0xfd600800) = (U32) FrameBuffer;
+ *((PULONG) 0xfd600800) = (ULONG) FrameBuffer;
}
VIDEODISPLAYMODE
@@ -258,21 +258,21 @@ XboxVideoSetDisplayMode(char *DisplayMode, BOOL Init)
}
VOID
-XboxVideoGetDisplaySize(PU32 Width, PU32 Height, PU32 Depth)
+XboxVideoGetDisplaySize(PULONG Width, PULONG Height, PULONG Depth)
{
*Width = ScreenWidth / CHAR_WIDTH;
*Height = (ScreenHeight - 2 * TOP_BOTTOM_LINES) / CHAR_HEIGHT;
*Depth = 0;
}
-U32
+ULONG
XboxVideoGetBufferSize(VOID)
{
return (ScreenHeight - 2 * TOP_BOTTOM_LINES) / CHAR_HEIGHT * (ScreenWidth / CHAR_WIDTH) * 2;
}
VOID
-XboxVideoSetTextCursorPosition(U32 X, U32 Y)
+XboxVideoSetTextCursorPosition(ULONG X, ULONG Y)
{
/* We don't have a cursor yet */
}
@@ -286,8 +286,8 @@ XboxVideoHideShowTextCursor(BOOL Show)
VOID
XboxVideoCopyOffScreenBufferToVRAM(PVOID Buffer)
{
- PU8 OffScreenBuffer = (PU8) Buffer;
- U32 Col, Line;
+ PUCHAR OffScreenBuffer = (PUCHAR) Buffer;
+ ULONG Col, Line;
for (Line = 0; Line < (ScreenHeight - 2 * TOP_BOTTOM_LINES) / CHAR_HEIGHT; Line++)
{
@@ -306,13 +306,13 @@ XboxVideoIsPaletteFixed(VOID)
}
VOID
-XboxVideoSetPaletteColor(U8 Color, U8 Red, U8 Green, U8 Blue)
+XboxVideoSetPaletteColor(UCHAR Color, UCHAR Red, UCHAR Green, UCHAR Blue)
{
/* Not supported */
}
VOID
-XboxVideoGetPaletteColor(U8 Color, U8* Red, U8* Green, U8* Blue)
+XboxVideoGetPaletteColor(UCHAR Color, UCHAR* Red, UCHAR* Green, UCHAR* Blue)
{
/* Not supported */
}
diff --git a/reactos/boot/freeldr/freeldr/bootmgr.c b/reactos/boot/freeldr/freeldr/bootmgr.c
index 23fc12ed148..01cd5212462 100644
--- a/reactos/boot/freeldr/freeldr/bootmgr.c
+++ b/reactos/boot/freeldr/freeldr/bootmgr.c
@@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-
+
#include
#include
#include
@@ -41,13 +41,13 @@ VOID RunLoader(VOID)
{
UCHAR SettingName[80];
UCHAR SettingValue[80];
- U32 SectionId;
- U32 OperatingSystemCount;
+ ULONG SectionId;
+ ULONG OperatingSystemCount;
PUCHAR *OperatingSystemSectionNames;
PUCHAR *OperatingSystemDisplayNames;
- U32 DefaultOperatingSystem;
- S32 TimeOut;
- U32 SelectedOperatingSystem;
+ ULONG DefaultOperatingSystem;
+ LONG TimeOut;
+ ULONG SelectedOperatingSystem;
if (!IniFileInitialize())
{
@@ -70,14 +70,14 @@ VOID RunLoader(VOID)
MachConsGetCh();
return;
}
-
+
if (!InitOperatingSystemList(&OperatingSystemSectionNames, &OperatingSystemDisplayNames, &OperatingSystemCount))
{
UiMessageBox("Press ENTER to reboot.\n");
goto reboot;
}
-
+
if (OperatingSystemCount == 0)
{
UiMessageBox("There were no operating systems listed in freeldr.ini.\nPress ENTER to reboot.");
@@ -85,7 +85,7 @@ VOID RunLoader(VOID)
}
DefaultOperatingSystem = GetDefaultOperatingSystem(OperatingSystemSectionNames, OperatingSystemCount);
-
+
//
// Find all the message box settings and run them
//
@@ -93,12 +93,13 @@ VOID RunLoader(VOID)
for (;;)
{
-
+
/* If Timeout is 0, don't even bother loading any gui */
if (!UserInterfaceUp) {
+ SelectedOperatingSystem = DefaultOperatingSystem;
goto NoGui;
}
-
+
// Redraw the backdrop
UiDrawBackdrop();
@@ -108,10 +109,9 @@ VOID RunLoader(VOID)
UiMessageBox("Press ENTER to reboot.\n");
goto reboot;
}
-
+
NoGui:
TimeOut = -1;
- DefaultOperatingSystem = SelectedOperatingSystem;
// Try to open the operating system section in the .ini file
if (!IniOpenSection(OperatingSystemSectionNames[SelectedOperatingSystem], &SectionId))
@@ -153,19 +153,19 @@ NoGui:
}
}
-
+
reboot:
UiUnInitialize("Rebooting...");
return;
}
-U32 GetDefaultOperatingSystem(PUCHAR OperatingSystemList[], U32 OperatingSystemCount)
+ULONG GetDefaultOperatingSystem(PUCHAR OperatingSystemList[], ULONG OperatingSystemCount)
{
UCHAR DefaultOSText[80];
char* DefaultOSName;
- U32 SectionId;
- U32 DefaultOS = 0;
- U32 Idx;
+ ULONG SectionId;
+ ULONG DefaultOS = 0;
+ ULONG Idx;
if (!IniOpenSection("FreeLoader", &SectionId))
{
@@ -196,11 +196,11 @@ U32 GetDefaultOperatingSystem(PUCHAR OperatingSystemList[], U32 OperatingSyste
return DefaultOS;
}
-S32 GetTimeOut(VOID)
+LONG GetTimeOut(VOID)
{
UCHAR TimeOutText[20];
- S32 TimeOut;
- U32 SectionId;
+ LONG TimeOut;
+ ULONG SectionId;
TimeOut = CmdLineGetTimeOut();
if (0 <= TimeOut)
@@ -225,7 +225,7 @@ S32 GetTimeOut(VOID)
return TimeOut;
}
-BOOL MainBootMenuKeyPressFilter(U32 KeyPress)
+BOOL MainBootMenuKeyPressFilter(ULONG KeyPress)
{
if (KeyPress == KEY_F8)
{
diff --git a/reactos/boot/freeldr/freeldr/cache/blocklist.c b/reactos/boot/freeldr/freeldr/cache/blocklist.c
index 2a9cb6acce5..81b3cb61b9d 100644
--- a/reactos/boot/freeldr/freeldr/cache/blocklist.c
+++ b/reactos/boot/freeldr/freeldr/cache/blocklist.c
@@ -30,7 +30,7 @@
// Returns a pointer to a CACHE_BLOCK structure
// Adds the block to the cache manager block list
// in cache memory if it isn't already there
-PCACHE_BLOCK CacheInternalGetBlockPointer(PCACHE_DRIVE CacheDrive, U32 BlockNumber)
+PCACHE_BLOCK CacheInternalGetBlockPointer(PCACHE_DRIVE CacheDrive, ULONG BlockNumber)
{
PCACHE_BLOCK CacheBlock = NULL;
@@ -55,7 +55,7 @@ PCACHE_BLOCK CacheInternalGetBlockPointer(PCACHE_DRIVE CacheDrive, U32 BlockNumb
return CacheBlock;
}
-PCACHE_BLOCK CacheInternalFindBlock(PCACHE_DRIVE CacheDrive, U32 BlockNumber)
+PCACHE_BLOCK CacheInternalFindBlock(PCACHE_DRIVE CacheDrive, ULONG BlockNumber)
{
PCACHE_BLOCK CacheBlock = NULL;
@@ -93,7 +93,7 @@ PCACHE_BLOCK CacheInternalFindBlock(PCACHE_DRIVE CacheDrive, U32 BlockNumber)
return NULL;
}
-PCACHE_BLOCK CacheInternalAddBlockToCache(PCACHE_DRIVE CacheDrive, U32 BlockNumber)
+PCACHE_BLOCK CacheInternalAddBlockToCache(PCACHE_DRIVE CacheDrive, ULONG BlockNumber)
{
PCACHE_BLOCK CacheBlock = NULL;
@@ -195,7 +195,7 @@ BOOL CacheInternalFreeBlock(PCACHE_DRIVE CacheDrive)
VOID CacheInternalCheckCacheSizeLimits(PCACHE_DRIVE CacheDrive)
{
- U32 NewCacheSize;
+ ULONG NewCacheSize;
DbgPrint((DPRINT_CACHE, "CacheInternalCheckCacheSizeLimits()\n"));
diff --git a/reactos/boot/freeldr/freeldr/cache/cache.c b/reactos/boot/freeldr/freeldr/cache/cache.c
index 363653f13d4..2344e1ee7fd 100644
--- a/reactos/boot/freeldr/freeldr/cache/cache.c
+++ b/reactos/boot/freeldr/freeldr/cache/cache.c
@@ -34,11 +34,11 @@
CACHE_DRIVE CacheManagerDrive;
BOOL CacheManagerInitialized = FALSE;
BOOL CacheManagerDataInvalid = FALSE;
-U32 CacheBlockCount = 0;
-U32 CacheSizeLimit = 0;
-U32 CacheSizeCurrent = 0;
+ULONG CacheBlockCount = 0;
+ULONG CacheSizeLimit = 0;
+ULONG CacheSizeCurrent = 0;
-BOOL CacheInitializeDrive(U32 DriveNumber)
+BOOL CacheInitializeDrive(ULONG DriveNumber)
{
PCACHE_BLOCK NextCacheBlock;
GEOMETRY DriveGeometry;
@@ -116,16 +116,16 @@ VOID CacheInvalidateCacheData(VOID)
CacheManagerDataInvalid = TRUE;
}
-BOOL CacheReadDiskSectors(U32 DiskNumber, U32 StartSector, U32 SectorCount, PVOID Buffer)
+BOOL CacheReadDiskSectors(ULONG DiskNumber, ULONG StartSector, ULONG SectorCount, PVOID Buffer)
{
PCACHE_BLOCK CacheBlock;
- U32 StartBlock;
- U32 SectorOffsetInStartBlock;
- U32 CopyLengthInStartBlock;
- U32 EndBlock;
- U32 SectorOffsetInEndBlock;
- U32 BlockCount;
- U32 Idx;
+ ULONG StartBlock;
+ ULONG SectorOffsetInStartBlock;
+ ULONG CopyLengthInStartBlock;
+ ULONG EndBlock;
+ ULONG SectorOffsetInEndBlock;
+ ULONG BlockCount;
+ ULONG Idx;
DbgPrint((DPRINT_CACHE, "CacheReadDiskSectors() DiskNumber: 0x%x StartSector: %d SectorCount: %d Buffer: 0x%x\n", DiskNumber, StartSector, SectorCount, Buffer));
@@ -248,13 +248,13 @@ BOOL CacheReadDiskSectors(U32 DiskNumber, U32 StartSector, U32 SectorCount, PVOI
return TRUE;
}
-BOOL CacheForceDiskSectorsIntoCache(U32 DiskNumber, U32 StartSector, U32 SectorCount)
+BOOL CacheForceDiskSectorsIntoCache(ULONG DiskNumber, ULONG StartSector, ULONG SectorCount)
{
PCACHE_BLOCK CacheBlock;
- U32 StartBlock;
- U32 EndBlock;
- U32 BlockCount;
- U32 Idx;
+ ULONG StartBlock;
+ ULONG EndBlock;
+ ULONG BlockCount;
+ ULONG Idx;
DbgPrint((DPRINT_CACHE, "CacheForceDiskSectorsIntoCache() DiskNumber: 0x%x StartSector: %d SectorCount: %d\n", DiskNumber, StartSector, SectorCount));
@@ -294,9 +294,9 @@ BOOL CacheForceDiskSectorsIntoCache(U32 DiskNumber, U32 StartSector, U32 SectorC
return TRUE;
}
-BOOL CacheReleaseMemory(U32 MinimumAmountToRelease)
+BOOL CacheReleaseMemory(ULONG MinimumAmountToRelease)
{
- U32 AmountReleased;
+ ULONG AmountReleased;
DbgPrint((DPRINT_CACHE, "CacheReleaseMemory() MinimumAmountToRelease = %d\n", MinimumAmountToRelease));
diff --git a/reactos/boot/freeldr/freeldr/cache/cm.h b/reactos/boot/freeldr/freeldr/cache/cm.h
index 6780fff6b07..fd47241e866 100644
--- a/reactos/boot/freeldr/freeldr/cache/cm.h
+++ b/reactos/boot/freeldr/freeldr/cache/cm.h
@@ -38,9 +38,9 @@ typedef struct
{
LIST_ITEM ListEntry; // Doubly linked list synchronization member
- U32 BlockNumber; // Track index for CHS, 64k block index for LBA
+ ULONG BlockNumber; // Track index for CHS, 64k block index for LBA
BOOL LockedInCache; // Indicates that this block is locked in cache memory
- U32 AccessCount; // Access count for this block
+ ULONG AccessCount; // Access count for this block
PVOID BlockData; // Pointer to block data
@@ -55,10 +55,10 @@ typedef struct
///////////////////////////////////////////////////////////////////////////////////////
typedef struct
{
- U32 DriveNumber;
- U32 BytesPerSector;
+ ULONG DriveNumber;
+ ULONG BytesPerSector;
- U32 BlockSize; // Block size (in sectors)
+ ULONG BlockSize; // Block size (in sectors)
PCACHE_BLOCK CacheBlockHead;
} CACHE_DRIVE, *PCACHE_DRIVE;
@@ -71,18 +71,18 @@ typedef struct
///////////////////////////////////////////////////////////////////////////////////////
extern CACHE_DRIVE CacheManagerDrive;
extern BOOL CacheManagerInitialized;
-extern U32 CacheBlockCount;
-extern U32 CacheSizeLimit;
-extern U32 CacheSizeCurrent;
+extern ULONG CacheBlockCount;
+extern ULONG CacheSizeLimit;
+extern ULONG CacheSizeCurrent;
///////////////////////////////////////////////////////////////////////////////////////
//
// Internal functions
//
///////////////////////////////////////////////////////////////////////////////////////
-PCACHE_BLOCK CacheInternalGetBlockPointer(PCACHE_DRIVE CacheDrive, U32 BlockNumber); // Returns a pointer to a CACHE_BLOCK structure given a block number
-PCACHE_BLOCK CacheInternalFindBlock(PCACHE_DRIVE CacheDrive, U32 BlockNumber); // Searches the block list for a particular block
-PCACHE_BLOCK CacheInternalAddBlockToCache(PCACHE_DRIVE CacheDrive, U32 BlockNumber); // Adds a block to the cache's block list
+PCACHE_BLOCK CacheInternalGetBlockPointer(PCACHE_DRIVE CacheDrive, ULONG BlockNumber); // Returns a pointer to a CACHE_BLOCK structure given a block number
+PCACHE_BLOCK CacheInternalFindBlock(PCACHE_DRIVE CacheDrive, ULONG BlockNumber); // Searches the block list for a particular block
+PCACHE_BLOCK CacheInternalAddBlockToCache(PCACHE_DRIVE CacheDrive, ULONG BlockNumber); // Adds a block to the cache's block list
BOOL CacheInternalFreeBlock(PCACHE_DRIVE CacheDrive); // Removes a block from the cache's block list & frees the memory
VOID CacheInternalCheckCacheSizeLimits(PCACHE_DRIVE CacheDrive); // Checks the cache size limits to see if we can add a new block, if not calls CacheInternalFreeBlock()
VOID CacheInternalDumpBlockList(PCACHE_DRIVE CacheDrive); // Dumps the list of cached blocks to the debug output port
diff --git a/reactos/boot/freeldr/freeldr/cmdline.c b/reactos/boot/freeldr/freeldr/cmdline.c
index f45a1cfe248..a18002c4d20 100644
--- a/reactos/boot/freeldr/freeldr/cmdline.c
+++ b/reactos/boot/freeldr/freeldr/cmdline.c
@@ -112,7 +112,7 @@ CmdLineGetDefaultOS(void)
return CmdLineInfo.DefaultOperatingSystem;
}
-S32
+LONG
CmdLineGetTimeOut(void)
{
return CmdLineInfo.TimeOut;
diff --git a/reactos/boot/freeldr/freeldr/comm/rs232.c b/reactos/boot/freeldr/freeldr/comm/rs232.c
index f203655fbfd..e814b0335ce 100644
--- a/reactos/boot/freeldr/freeldr/comm/rs232.c
+++ b/reactos/boot/freeldr/freeldr/comm/rs232.c
@@ -61,8 +61,8 @@
/* STATIC VARIABLES *********************************************************/
-static U32 Rs232ComPort = 0;
-static U32 Rs232BaudRate = 0;
+static ULONG Rs232ComPort = 0;
+static ULONG Rs232BaudRate = 0;
static PUCHAR Rs232PortBase = (PUCHAR)0;
/* The com port must only be initialized once! */
@@ -73,8 +73,8 @@ static BOOLEAN PortInitialized = FALSE;
static BOOL Rs232DoesComPortExist(PUCHAR BaseAddress)
{
BOOLEAN found;
- U8 mcr;
- U8 msr;
+ UCHAR mcr;
+ UCHAR msr;
found = FALSE;
@@ -118,12 +118,12 @@ static BOOL Rs232DoesComPortExist(PUCHAR BaseAddress)
/* FUNCTIONS *********************************************************/
-BOOL Rs232PortInitialize(U32 ComPort, U32 BaudRate)
+BOOL Rs232PortInitialize(ULONG ComPort, ULONG BaudRate)
{
- U32 BaseArray[5] = {0, 0x3F8, 0x2F8, 0x3E8, 0x2E8};
+ ULONG BaseArray[5] = {0, 0x3F8, 0x2F8, 0x3E8, 0x2E8};
//char buffer[80];
- U32 divisor;
- U8 lcr;
+ ULONG divisor;
+ UCHAR lcr;
if (PortInitialized == FALSE)
{
@@ -146,7 +146,7 @@ BOOL Rs232PortInitialize(U32 ComPort, U32 BaudRate)
sprintf (buffer,
"\nSerial port COM%ld found at 0x%lx\n",
ComPort,
- (U32)PortBase);
+ (ULONG)PortBase);
HalDisplayString (buffer);
#endif*/ /* NDEBUG */
}
@@ -158,7 +158,7 @@ BOOL Rs232PortInitialize(U32 ComPort, U32 BaudRate)
sprintf (buffer,
"\nSerial port COM%ld found at 0x%lx\n",
ComPort,
- (U32)PortBase);
+ (ULONG)PortBase);
HalDisplayString (buffer);
#endif*/ /* NDEBUG */
}
@@ -180,7 +180,7 @@ BOOL Rs232PortInitialize(U32 ComPort, U32 BaudRate)
sprintf (buffer,
"\nSerial port COM%ld found at 0x%lx\n",
ComPort,
- (U32)PortBase);
+ (ULONG)PortBase);
HalDisplayString (buffer);
#endif*/ /* NDEBUG */
}
@@ -222,7 +222,7 @@ BOOL Rs232PortInitialize(U32 ComPort, U32 BaudRate)
/*
* set global info
*/
- //KdComPortInUse = (U32)PortBase;
+ //KdComPortInUse = (ULONG)PortBase;
/*
* print message to blue screen
@@ -230,7 +230,7 @@ BOOL Rs232PortInitialize(U32 ComPort, U32 BaudRate)
/*sprintf (buffer,
"\nKernel Debugger: COM%ld (Port 0x%lx) BaudRate %ld\n\n",
ComPort,
- (U32)PortBase,
+ (ULONG)PortBase,
BaudRate);
HalDisplayString (buffer);*/
diff --git a/reactos/boot/freeldr/freeldr/custom.c b/reactos/boot/freeldr/freeldr/custom.c
index f3899ba86a7..da0da4198d8 100644
--- a/reactos/boot/freeldr/freeldr/custom.c
+++ b/reactos/boot/freeldr/freeldr/custom.c
@@ -46,8 +46,8 @@ UCHAR CustomBootPrompt[] = "Press ENTER to boot your custom boot setup.";
VOID OptionMenuCustomBoot(VOID)
{
PUCHAR CustomBootMenuList[] = { "Disk", "Partition", "Boot Sector File", "ReactOS", "Linux" };
- U32 CustomBootMenuCount = sizeof(CustomBootMenuList) / sizeof(CustomBootMenuList[0]);
- U32 SelectedMenuItem;
+ ULONG CustomBootMenuCount = sizeof(CustomBootMenuList) / sizeof(CustomBootMenuList[0]);
+ ULONG SelectedMenuItem;
if (!UiDisplayMenu(CustomBootMenuList, CustomBootMenuCount, 0, -1, &SelectedMenuItem, TRUE, NULL))
{
@@ -79,8 +79,8 @@ VOID OptionMenuCustomBootDisk(VOID)
{
UCHAR SectionName[100];
UCHAR BootDriveString[20];
- U32 SectionId;
- U32 Year, Month, Day, Hour, Minute, Second;
+ ULONG SectionId;
+ ULONG Year, Month, Day, Hour, Minute, Second;
RtlZeroMemory(SectionName, sizeof(SectionName));
RtlZeroMemory(BootDriveString, sizeof(BootDriveString));
@@ -122,8 +122,8 @@ VOID OptionMenuCustomBootPartition(VOID)
UCHAR SectionName[100];
UCHAR BootDriveString[20];
UCHAR BootPartitionString[20];
- U32 SectionId;
- U32 Year, Month, Day, Hour, Minute, Second;
+ ULONG SectionId;
+ ULONG Year, Month, Day, Hour, Minute, Second;
RtlZeroMemory(SectionName, sizeof(SectionName));
RtlZeroMemory(BootDriveString, sizeof(BootDriveString));
@@ -178,8 +178,8 @@ VOID OptionMenuCustomBootBootSectorFile(VOID)
UCHAR BootDriveString[20];
UCHAR BootPartitionString[20];
UCHAR BootSectorFileString[200];
- U32 SectionId;
- U32 Year, Month, Day, Hour, Minute, Second;
+ ULONG SectionId;
+ ULONG Year, Month, Day, Hour, Minute, Second;
RtlZeroMemory(SectionName, sizeof(SectionName));
RtlZeroMemory(BootDriveString, sizeof(BootDriveString));
@@ -248,8 +248,8 @@ VOID OptionMenuCustomBootReactOS(VOID)
UCHAR ReactOSSystemPath[200];
UCHAR ReactOSARCPath[200];
UCHAR ReactOSOptions[200];
- U32 SectionId;
- U32 Year, Month, Day, Hour, Minute, Second;
+ ULONG SectionId;
+ ULONG Year, Month, Day, Hour, Minute, Second;
RtlZeroMemory(SectionName, sizeof(SectionName));
RtlZeroMemory(BootDriveString, sizeof(BootDriveString));
@@ -321,8 +321,8 @@ VOID OptionMenuCustomBootLinux(VOID)
UCHAR LinuxKernelString[200];
UCHAR LinuxInitrdString[200];
UCHAR LinuxCommandLineString[200];
- U32 SectionId;
- U32 Year, Month, Day, Hour, Minute, Second;
+ ULONG SectionId;
+ ULONG Year, Month, Day, Hour, Minute, Second;
RtlZeroMemory(SectionName, sizeof(SectionName));
RtlZeroMemory(BootDriveString, sizeof(BootDriveString));
diff --git a/reactos/boot/freeldr/freeldr/debug.c b/reactos/boot/freeldr/freeldr/debug.c
index abd8ec38aab..93193ceaf01 100644
--- a/reactos/boot/freeldr/freeldr/debug.c
+++ b/reactos/boot/freeldr/freeldr/debug.c
@@ -33,22 +33,22 @@
#define DEBUG_NONE
#if defined (DEBUG_ALL)
-U32 DebugPrintMask = DPRINT_WARNING | DPRINT_MEMORY | DPRINT_FILESYSTEM |
- DPRINT_UI | DPRINT_DISK | DPRINT_CACHE | DPRINT_REACTOS |
- DPRINT_LINUX;
+ULONG DebugPrintMask = DPRINT_WARNING | DPRINT_MEMORY | DPRINT_FILESYSTEM |
+ DPRINT_UI | DPRINT_DISK | DPRINT_CACHE | DPRINT_REACTOS |
+ DPRINT_LINUX | DPRINT_HWDETECT;
#elif defined (DEBUG_INIFILE)
-U32 DebugPrintMask = DPRINT_INIFILE;
+ULONG DebugPrintMask = DPRINT_INIFILE;
#elif defined (DEBUG_REACTOS)
-U32 DebugPrintMask = DPRINT_REACTOS | DPRINT_REGISTRY;
+ULONG DebugPrintMask = DPRINT_REACTOS | DPRINT_REGISTRY;
#elif defined (DEBUG_CUSTOM)
-U32 DebugPrintMask = DPRINT_WARNING|DPRINT_FILESYSTEM|DPRINT_MEMORY|DPRINT_LINUX;
+ULONG DebugPrintMask = DPRINT_WARNING|DPRINT_FILESYSTEM|DPRINT_MEMORY|DPRINT_LINUX;
#else //#elif defined (DEBUG_NONE)
-U32 DebugPrintMask = 0;
+ULONG DebugPrintMask = 0;
#endif
-#define SCREEN 0
-#define RS232 1
-#define BOCHS 2
+#define SCREEN 1
+#define RS232 2
+#define BOCHS 4
#define COM1 1
#define COM2 2
@@ -57,12 +57,13 @@ U32 DebugPrintMask = 0;
#define BOCHS_OUTPUT_PORT 0xe9
-U32 DebugPort = RS232;
-//U32 DebugPort = SCREEN;
-//U32 DebugPort = BOCHS;
-U32 ComPort = COM1;
-//U32 BaudRate = 19200;
-U32 BaudRate = 115200;
+ULONG DebugPort = RS232;
+//ULONG DebugPort = SCREEN;
+//ULONG DebugPort = BOCHS;
+//ULONG DebugPort = SCREEN|BOCHS;
+ULONG ComPort = COM1;
+//ULONG BaudRate = 19200;
+ULONG BaudRate = 115200;
BOOL DebugStartOfLine = TRUE;
@@ -81,7 +82,7 @@ VOID DebugPrintChar(UCHAR Character)
DebugStartOfLine = TRUE;
}
- if (DebugPort == RS232)
+ if (DebugPort & RS232)
{
if (Character == '\n')
{
@@ -89,17 +90,17 @@ VOID DebugPrintChar(UCHAR Character)
}
Rs232PortPutByte(Character);
}
- else if (DebugPort == BOCHS)
+ if (DebugPort & BOCHS)
{
WRITE_PORT_UCHAR((PUCHAR)BOCHS_OUTPUT_PORT, Character);
}
- else
+ if (DebugPort & SCREEN)
{
MachConsPutChar(Character);
}
}
-VOID DebugPrintHeader(U32 Mask)
+VOID DebugPrintHeader(ULONG Mask)
{
/* No header */
if (Mask == 0)
@@ -257,7 +258,7 @@ static VOID DebugPrintV(char *format, int *dataptr)
switch (c = *(format++))
{
case 'd': case 'u': case 'x':
-
+
if (ll)
{
*convert_i64_to_ascii(str, c, *((unsigned long long*) dataptr)) = 0;
@@ -308,10 +309,10 @@ static VOID DebugPrintV(char *format, int *dataptr)
}
-VOID DebugPrint(U32 Mask, char *format, ...)
+VOID DebugPrint(ULONG Mask, char *format, ...)
{
int *dataptr = (int *) &format;
-
+
// Mask out unwanted debug messages
if (!(Mask & DebugPrintMask))
{
@@ -335,12 +336,12 @@ VOID DebugPrint1(char *format, ...)
DebugPrintV(format, ++dataptr);
}
-VOID DebugDumpBuffer(U32 Mask, PVOID Buffer, U32 Length)
+VOID DebugDumpBuffer(ULONG Mask, PVOID Buffer, ULONG Length)
{
PUCHAR BufPtr = (PUCHAR)Buffer;
- U32 Idx;
- U32 Idx2;
-
+ ULONG Idx;
+ ULONG Idx2;
+
// Mask out unwanted debug messages
if (!(Mask & DebugPrintMask))
{
diff --git a/reactos/boot/freeldr/freeldr/disk/disk.c b/reactos/boot/freeldr/freeldr/disk/disk.c
index c298b51079e..9a3e6835096 100644
--- a/reactos/boot/freeldr/freeldr/disk/disk.c
+++ b/reactos/boot/freeldr/freeldr/disk/disk.c
@@ -39,7 +39,7 @@ VOID DiskReportError (BOOL bError)
bReportError = bError;
}
-VOID DiskError(PUCHAR ErrorString, U32 ErrorCode)
+VOID DiskError(PUCHAR ErrorString, ULONG ErrorCode)
{
UCHAR ErrorCodeString[200];
@@ -53,7 +53,7 @@ VOID DiskError(PUCHAR ErrorString, U32 ErrorCode)
UiMessageBox(ErrorCodeString);
}
-PUCHAR DiskGetErrorCodeString(U32 ErrorCode)
+PUCHAR DiskGetErrorCodeString(ULONG ErrorCode)
{
switch (ErrorCode)
{
@@ -89,9 +89,9 @@ PUCHAR DiskGetErrorCodeString(U32 ErrorCode)
}
// This function is in arch/i386/i386disk.c
-//BOOL DiskReadLogicalSectors(U32 DriveNumber, U64 SectorNumber, U32 SectorCount, PVOID Buffer)
+//BOOL DiskReadLogicalSectors(ULONG DriveNumber, U64 SectorNumber, ULONG SectorCount, PVOID Buffer)
-BOOL DiskIsDriveRemovable(U32 DriveNumber)
+BOOL DiskIsDriveRemovable(ULONG DriveNumber)
{
// Hard disks use drive numbers >= 0x80
// So if the drive number indicates a hard disk
@@ -109,4 +109,4 @@ BOOL DiskIsDriveRemovable(U32 DriveNumber)
//VOID DiskStopFloppyMotor(VOID)
// This function is in arch/i386/i386disk.c
-//U32 DiskGetCacheableBlockCount(U32 DriveNumber)
+//ULONG DiskGetCacheableBlockCount(ULONG DriveNumber)
diff --git a/reactos/boot/freeldr/freeldr/disk/partition.c b/reactos/boot/freeldr/freeldr/disk/partition.c
index 0a0e4e4a922..4c1aa01c035 100644
--- a/reactos/boot/freeldr/freeldr/disk/partition.c
+++ b/reactos/boot/freeldr/freeldr/disk/partition.c
@@ -26,9 +26,9 @@
#include
-BOOL DiskGetActivePartitionEntry(U32 DriveNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry)
+BOOL DiskGetActivePartitionEntry(ULONG DriveNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry)
{
- U32 BootablePartitionCount = 0;
+ ULONG BootablePartitionCount = 0;
MASTER_BOOT_RECORD MasterBootRecord;
// Read master boot record
@@ -77,13 +77,13 @@ BOOL DiskGetActivePartitionEntry(U32 DriveNumber, PPARTITION_TABLE_ENTRY Partiti
return TRUE;
}
-BOOL DiskGetPartitionEntry(U32 DriveNumber, U32 PartitionNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry)
+BOOL DiskGetPartitionEntry(ULONG DriveNumber, ULONG PartitionNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry)
{
MASTER_BOOT_RECORD MasterBootRecord;
PARTITION_TABLE_ENTRY ExtendedPartitionTableEntry;
- U32 ExtendedPartitionNumber;
- U32 ExtendedPartitionOffset;
- U32 Index;
+ ULONG ExtendedPartitionNumber;
+ ULONG ExtendedPartitionOffset;
+ ULONG Index;
// Read master boot record
if (!DiskReadBootRecord(DriveNumber, 0, &MasterBootRecord))
@@ -157,7 +157,7 @@ BOOL DiskGetPartitionEntry(U32 DriveNumber, U32 PartitionNumber, PPARTITION_TABL
BOOL DiskGetFirstPartitionEntry(PMASTER_BOOT_RECORD MasterBootRecord, PPARTITION_TABLE_ENTRY PartitionTableEntry)
{
- U32 Index;
+ ULONG Index;
for (Index=0; Index<4; Index++)
{
@@ -178,7 +178,7 @@ BOOL DiskGetFirstPartitionEntry(PMASTER_BOOT_RECORD MasterBootRecord, PPARTITION
BOOL DiskGetFirstExtendedPartitionEntry(PMASTER_BOOT_RECORD MasterBootRecord, PPARTITION_TABLE_ENTRY PartitionTableEntry)
{
- U32 Index;
+ ULONG Index;
for (Index=0; Index<4; Index++)
{
@@ -195,11 +195,11 @@ BOOL DiskGetFirstExtendedPartitionEntry(PMASTER_BOOT_RECORD MasterBootRecord, PP
return FALSE;
}
-BOOL DiskReadBootRecord(U32 DriveNumber, U64 LogicalSectorNumber, PMASTER_BOOT_RECORD BootRecord)
+BOOL DiskReadBootRecord(ULONG DriveNumber, ULONGLONG LogicalSectorNumber, PMASTER_BOOT_RECORD BootRecord)
{
char ErrMsg[64];
#ifdef DEBUG
- U32 Index;
+ ULONG Index;
#endif
// Read master boot record
diff --git a/reactos/boot/freeldr/freeldr/drivemap.c b/reactos/boot/freeldr/freeldr/drivemap.c
index f32fd718661..5a5ff3d0d0e 100644
--- a/reactos/boot/freeldr/freeldr/drivemap.c
+++ b/reactos/boot/freeldr/freeldr/drivemap.c
@@ -26,9 +26,9 @@
#include
BOOL DriveMapInstalled = FALSE; // Tells us if we have already installed our drive map int 13h handler code
-U32 OldInt13HandlerAddress = 0; // Address of BIOS int 13h handler
-U32 DriveMapHandlerAddress = 0; // Linear address of our drive map handler
-U32 DriveMapHandlerSegOff = 0; // Segment:offset style address of our drive map handler
+ULONG OldInt13HandlerAddress = 0; // Address of BIOS int 13h handler
+ULONG DriveMapHandlerAddress = 0; // Linear address of our drive map handler
+ULONG DriveMapHandlerSegOff = 0; // Segment:offset style address of our drive map handler
VOID DriveMapMapDrivesInSection(PUCHAR SectionName)
{
@@ -37,10 +37,10 @@ VOID DriveMapMapDrivesInSection(PUCHAR SectionName)
UCHAR ErrorText[260];
UCHAR Drive1[80];
UCHAR Drive2[80];
- U32 SectionId;
- U32 SectionItemCount;
- U32 Index;
- U32 Index2;
+ ULONG SectionId;
+ ULONG SectionItemCount;
+ ULONG Index;
+ ULONG Index2;
DRIVE_MAP_LIST DriveMapList;
RtlZeroMemory(&DriveMapList, sizeof(DRIVE_MAP_LIST));
@@ -119,7 +119,7 @@ VOID DriveMapMapDrivesInSection(PUCHAR SectionName)
BOOL DriveMapIsValidDriveString(PUCHAR DriveString)
{
- U32 Index;
+ ULONG Index;
// Now verify that the user has given us appropriate strings
if ((strlen(DriveString) < 3) ||
@@ -147,9 +147,9 @@ BOOL DriveMapIsValidDriveString(PUCHAR DriveString)
return TRUE;
}
-U32 DriveMapGetBiosDriveNumber(PUCHAR DeviceName)
+ULONG DriveMapGetBiosDriveNumber(PUCHAR DeviceName)
{
- U32 BiosDriveNumber = 0;
+ ULONG BiosDriveNumber = 0;
// If they passed in a number string then just
// convert it to decimal and return it
@@ -174,8 +174,8 @@ U32 DriveMapGetBiosDriveNumber(PUCHAR DeviceName)
VOID DriveMapInstallInt13Handler(PDRIVE_MAP_LIST DriveMap)
{
- U32* RealModeIVT = (U32*)0x00000000;
- U16* BiosLowMemorySize = (U16*)0x00000413;
+ ULONG* RealModeIVT = (ULONG*)0x00000000;
+ USHORT* BiosLowMemorySize = (USHORT*)0x00000413;
if (!DriveMapInstalled)
{
@@ -186,7 +186,7 @@ VOID DriveMapInstallInt13Handler(PDRIVE_MAP_LIST DriveMap)
(*BiosLowMemorySize)--;
// Get linear address for drive map handler
- DriveMapHandlerAddress = (U32)(*BiosLowMemorySize) << 10;
+ DriveMapHandlerAddress = (ULONG)(*BiosLowMemorySize) << 10;
// Convert to segment:offset style address
DriveMapHandlerSegOff = (DriveMapHandlerAddress << 12) & 0xffff0000;
@@ -199,7 +199,7 @@ VOID DriveMapInstallInt13Handler(PDRIVE_MAP_LIST DriveMap)
DriveMapOldInt13HandlerAddress = OldInt13HandlerAddress;
// Copy the code to our reserved area
- RtlCopyMemory((PVOID)DriveMapHandlerAddress, &DriveMapInt13HandlerStart, ((U32)&DriveMapInt13HandlerEnd - (U32)&DriveMapInt13HandlerStart));
+ RtlCopyMemory((PVOID)DriveMapHandlerAddress, &DriveMapInt13HandlerStart, ((ULONG)&DriveMapInt13HandlerEnd - (ULONG)&DriveMapInt13HandlerStart));
// Update the IVT
RealModeIVT[0x13] = DriveMapHandlerSegOff;
@@ -210,8 +210,8 @@ VOID DriveMapInstallInt13Handler(PDRIVE_MAP_LIST DriveMap)
VOID DriveMapRemoveInt13Handler(VOID)
{
- U32* RealModeIVT = (U32*)0x00000000;
- U16* BiosLowMemorySize = (U16*)0x00000413;
+ ULONG* RealModeIVT = (ULONG*)0x00000000;
+ USHORT* BiosLowMemorySize = (USHORT*)0x00000413;
if (DriveMapInstalled)
{
diff --git a/reactos/boot/freeldr/freeldr/freeldr.xml b/reactos/boot/freeldr/freeldr/freeldr.xml
index 563d99db7f0..eaa46f3de70 100644
--- a/reactos/boot/freeldr/freeldr/freeldr.xml
+++ b/reactos/boot/freeldr/freeldr/freeldr.xml
@@ -3,4 +3,5 @@
freeldr_base64k
freeldr_base
freeldr_main
+ rossym
diff --git a/reactos/boot/freeldr/freeldr/freeldr_base.xml b/reactos/boot/freeldr/freeldr/freeldr_base.xml
index 3024356e7ac..f08569ed98c 100644
--- a/reactos/boot/freeldr/freeldr/freeldr_base.xml
+++ b/reactos/boot/freeldr/freeldr/freeldr_base.xml
@@ -1,8 +1,9 @@
include
cache
+ include
+
-nostdlib
- -nostdinc
-ffreestanding
-fno-builtin
-fno-inline
diff --git a/reactos/boot/freeldr/freeldr/freeldr_base64k.xml b/reactos/boot/freeldr/freeldr/freeldr_base64k.xml
index d783e49a05a..a170dd67209 100644
--- a/reactos/boot/freeldr/freeldr/freeldr_base64k.xml
+++ b/reactos/boot/freeldr/freeldr/freeldr_base64k.xml
@@ -1,7 +1,8 @@
include
+ include
+
-nostdlib
- -nostdinc
-ffreestanding
-fno-builtin
-fno-inline
diff --git a/reactos/boot/freeldr/freeldr/freeldr_main.xml b/reactos/boot/freeldr/freeldr/freeldr_main.xml
index 9c8dd4cc129..820e4a6e44d 100644
--- a/reactos/boot/freeldr/freeldr/freeldr_main.xml
+++ b/reactos/boot/freeldr/freeldr/freeldr_main.xml
@@ -1,7 +1,8 @@
include
+ include
+
-nostdlib
- -nostdinc
-ffreestanding
-fno-builtin
-fno-inline
diff --git a/reactos/boot/freeldr/freeldr/freeldr_startup.xml b/reactos/boot/freeldr/freeldr/freeldr_startup.xml
index 238d487f537..d69984cf13e 100644
--- a/reactos/boot/freeldr/freeldr/freeldr_startup.xml
+++ b/reactos/boot/freeldr/freeldr/freeldr_startup.xml
@@ -1,7 +1,8 @@
include
+ include
+
-nostdlib
- -nostdinc
-ffreestanding
-fno-builtin
-fno-inline
diff --git a/reactos/boot/freeldr/freeldr/fs/ext2.c b/reactos/boot/freeldr/freeldr/fs/ext2.c
index 0710196df09..8825c87f471 100644
--- a/reactos/boot/freeldr/freeldr/fs/ext2.c
+++ b/reactos/boot/freeldr/freeldr/fs/ext2.c
@@ -35,17 +35,17 @@ GEOMETRY Ext2DiskGeometry; // Ext2 file system disk geometry
PEXT2_SUPER_BLOCK Ext2SuperBlock = NULL; // Ext2 file system super block
PEXT2_GROUP_DESC Ext2GroupDescriptors = NULL; // Ext2 file system group descriptors
-U8 Ext2DriveNumber = 0; // Ext2 file system drive number
-U64 Ext2VolumeStartSector = 0; // Ext2 file system starting sector
-U32 Ext2BlockSizeInBytes = 0; // Block size in bytes
-U32 Ext2BlockSizeInSectors = 0; // Block size in sectors
-U32 Ext2FragmentSizeInBytes = 0; // Fragment size in bytes
-U32 Ext2FragmentSizeInSectors = 0; // Fragment size in sectors
-U32 Ext2GroupCount = 0; // Number of groups in this file system
-U32 Ext2InodesPerBlock = 0; // Number of inodes in one block
-U32 Ext2GroupDescPerBlock = 0; // Number of group descriptors in one block
+UCHAR Ext2DriveNumber = 0; // Ext2 file system drive number
+ULONGLONG Ext2VolumeStartSector = 0; // Ext2 file system starting sector
+ULONG Ext2BlockSizeInBytes = 0; // Block size in bytes
+ULONG Ext2BlockSizeInSectors = 0; // Block size in sectors
+ULONG Ext2FragmentSizeInBytes = 0; // Fragment size in bytes
+ULONG Ext2FragmentSizeInSectors = 0; // Fragment size in sectors
+ULONG Ext2GroupCount = 0; // Number of groups in this file system
+ULONG Ext2InodesPerBlock = 0; // Number of inodes in one block
+ULONG Ext2GroupDescPerBlock = 0; // Number of group descriptors in one block
-BOOL Ext2OpenVolume(U8 DriveNumber, U64 VolumeStartSector)
+BOOL Ext2OpenVolume(UCHAR DriveNumber, ULONGLONG VolumeStartSector)
{
DbgPrint((DPRINT_FILESYSTEM, "Ext2OpenVolume() DriveNumber = 0x%x VolumeStartSector = %d\n", DriveNumber, VolumeStartSector));
@@ -93,7 +93,7 @@ FILE* Ext2OpenFile(PUCHAR FileName)
PEXT2_FILE_INFO FileHandle;
UCHAR SymLinkPath[EXT3_NAME_LEN];
UCHAR FullPath[EXT3_NAME_LEN * 2];
- U32 Index;
+ ULONG Index;
DbgPrint((DPRINT_FILESYSTEM, "Ext2OpenFile() FileName = %s\n", FileName));
@@ -193,10 +193,10 @@ FILE* Ext2OpenFile(PUCHAR FileName)
BOOL Ext2LookupFile(PUCHAR FileName, PEXT2_FILE_INFO Ext2FileInfoPointer)
{
int i;
- U32 NumberOfPathParts;
+ ULONG NumberOfPathParts;
UCHAR PathPart[261];
PVOID DirectoryBuffer;
- U32 DirectoryInode = EXT3_ROOT_INO;
+ ULONG DirectoryInode = EXT3_ROOT_INO;
EXT2_INODE InodeData;
EXT2_DIR_ENTRY DirectoryEntry;
@@ -238,7 +238,7 @@ BOOL Ext2LookupFile(PUCHAR FileName, PEXT2_FILE_INFO Ext2FileInfoPointer)
//
// Search for file name in directory
//
- if (!Ext2SearchDirectoryBufferForFile(DirectoryBuffer, (U32)Ext2GetInodeFileSize(&InodeData), PathPart, &DirectoryEntry))
+ if (!Ext2SearchDirectoryBufferForFile(DirectoryBuffer, (ULONG)Ext2GetInodeFileSize(&InodeData), PathPart, &DirectoryEntry))
{
MmFreeMemory(DirectoryBuffer);
return FALSE;
@@ -289,9 +289,9 @@ BOOL Ext2LookupFile(PUCHAR FileName, PEXT2_FILE_INFO Ext2FileInfoPointer)
return TRUE;
}
-BOOL Ext2SearchDirectoryBufferForFile(PVOID DirectoryBuffer, U32 DirectorySize, PUCHAR FileName, PEXT2_DIR_ENTRY DirectoryEntry)
+BOOL Ext2SearchDirectoryBufferForFile(PVOID DirectoryBuffer, ULONG DirectorySize, PUCHAR FileName, PEXT2_DIR_ENTRY DirectoryEntry)
{
- U32 CurrentOffset;
+ ULONG CurrentOffset;
PEXT2_DIR_ENTRY CurrentDirectoryEntry;
DbgPrint((DPRINT_FILESYSTEM, "Ext2SearchDirectoryBufferForFile() DirectoryBuffer = 0x%x DirectorySize = %d FileName = %s\n", DirectoryBuffer, DirectorySize, FileName));
@@ -345,16 +345,16 @@ BOOL Ext2SearchDirectoryBufferForFile(PVOID DirectoryBuffer, U32 DirectorySize,
* Reads BytesToRead from open file and
* returns the number of bytes read in BytesRead
*/
-BOOL Ext2ReadFile(FILE *FileHandle, U64 BytesToRead, U64* BytesRead, PVOID Buffer)
+BOOL Ext2ReadFile(FILE *FileHandle, ULONGLONG BytesToRead, ULONGLONG* BytesRead, PVOID Buffer)
{
PEXT2_FILE_INFO Ext2FileInfo = (PEXT2_FILE_INFO)FileHandle;
- U32 BlockNumber;
- U32 BlockNumberIndex;
- U32 OffsetInBlock;
- U32 LengthInBlock;
- U32 NumberOfBlocks;
+ ULONG BlockNumber;
+ ULONG BlockNumberIndex;
+ ULONG OffsetInBlock;
+ ULONG LengthInBlock;
+ ULONG NumberOfBlocks;
- DbgPrint((DPRINT_FILESYSTEM, "Ext2ReadFile() BytesToRead = %d Buffer = 0x%x\n", (U32)BytesToRead, Buffer));
+ DbgPrint((DPRINT_FILESYSTEM, "Ext2ReadFile() BytesToRead = %d Buffer = 0x%x\n", (ULONG)BytesToRead, Buffer));
if (BytesRead != NULL)
{
@@ -529,7 +529,7 @@ BOOL Ext2ReadFile(FILE *FileHandle, U64 BytesToRead, U64* BytesRead, PVOID Buffe
return TRUE;
}
-U64 Ext2GetFileSize(FILE *FileHandle)
+ULONGLONG Ext2GetFileSize(FILE *FileHandle)
{
PEXT2_FILE_INFO Ext2FileHandle = (PEXT2_FILE_INFO)FileHandle;
@@ -538,7 +538,7 @@ U64 Ext2GetFileSize(FILE *FileHandle)
return Ext2FileHandle->FileSize;
}
-VOID Ext2SetFilePointer(FILE *FileHandle, U64 NewFilePointer)
+VOID Ext2SetFilePointer(FILE *FileHandle, ULONGLONG NewFilePointer)
{
PEXT2_FILE_INFO Ext2FileHandle = (PEXT2_FILE_INFO)FileHandle;
@@ -547,7 +547,7 @@ VOID Ext2SetFilePointer(FILE *FileHandle, U64 NewFilePointer)
Ext2FileHandle->FilePointer = NewFilePointer;
}
-U64 Ext2GetFilePointer(FILE *FileHandle)
+ULONGLONG Ext2GetFilePointer(FILE *FileHandle)
{
PEXT2_FILE_INFO Ext2FileHandle = (PEXT2_FILE_INFO)FileHandle;
@@ -556,7 +556,7 @@ U64 Ext2GetFilePointer(FILE *FileHandle)
return Ext2FileHandle->FilePointer;
}
-BOOL Ext2ReadVolumeSectors(U8 DriveNumber, U64 SectorNumber, U64 SectorCount, PVOID Buffer)
+BOOL Ext2ReadVolumeSectors(UCHAR DriveNumber, ULONGLONG SectorNumber, ULONGLONG SectorCount, PVOID Buffer)
{
//GEOMETRY DiskGeometry;
//BOOL ReturnValue;
@@ -734,8 +734,8 @@ BOOL Ext2ReadSuperBlock(VOID)
BOOL Ext2ReadGroupDescriptors(VOID)
{
- U32 GroupDescBlockCount;
- U32 CurrentGroupDescBlock;
+ ULONG GroupDescBlockCount;
+ ULONG CurrentGroupDescBlock;
DbgPrint((DPRINT_FILESYSTEM, "Ext2ReadGroupDescriptors()\n"));
@@ -778,7 +778,7 @@ BOOL Ext2ReadGroupDescriptors(VOID)
return TRUE;
}
-BOOL Ext2ReadDirectory(U32 Inode, PVOID* DirectoryBuffer, PEXT2_INODE InodePointer)
+BOOL Ext2ReadDirectory(ULONG Inode, PVOID* DirectoryBuffer, PEXT2_INODE InodePointer)
{
EXT2_FILE_INFO DirectoryFileInfo;
@@ -837,7 +837,7 @@ BOOL Ext2ReadDirectory(U32 Inode, PVOID* DirectoryBuffer, PEXT2_INODE InodePoint
return TRUE;
}
-BOOL Ext2ReadBlock(U32 BlockNumber, PVOID Buffer)
+BOOL Ext2ReadBlock(ULONG BlockNumber, PVOID Buffer)
{
UCHAR ErrorString[80];
@@ -861,14 +861,14 @@ BOOL Ext2ReadBlock(U32 BlockNumber, PVOID Buffer)
return TRUE;
}
- return Ext2ReadVolumeSectors(Ext2DriveNumber, (U64)BlockNumber * Ext2BlockSizeInSectors, Ext2BlockSizeInSectors, Buffer);
+ return Ext2ReadVolumeSectors(Ext2DriveNumber, (ULONGLONG)BlockNumber * Ext2BlockSizeInSectors, Ext2BlockSizeInSectors, Buffer);
}
/*
* Ext2ReadPartialBlock()
* Reads part of a block into memory
*/
-BOOL Ext2ReadPartialBlock(U32 BlockNumber, U32 StartingOffset, U32 Length, PVOID Buffer)
+BOOL Ext2ReadPartialBlock(ULONG BlockNumber, ULONG StartingOffset, ULONG Length, PVOID Buffer)
{
DbgPrint((DPRINT_FILESYSTEM, "Ext2ReadPartialBlock() BlockNumber = %d StartingOffset = %d Length = %d Buffer = 0x%x\n", BlockNumber, StartingOffset, Length, Buffer));
@@ -883,36 +883,36 @@ BOOL Ext2ReadPartialBlock(U32 BlockNumber, U32 StartingOffset, U32 Length, PVOID
return TRUE;
}
-U32 Ext2GetGroupDescBlockNumber(U32 Group)
+ULONG Ext2GetGroupDescBlockNumber(ULONG Group)
{
return (((Group * sizeof(EXT2_GROUP_DESC)) / Ext2GroupDescPerBlock) + Ext2SuperBlock->s_first_data_block + 1);
}
-U32 Ext2GetGroupDescOffsetInBlock(U32 Group)
+ULONG Ext2GetGroupDescOffsetInBlock(ULONG Group)
{
return ((Group * sizeof(EXT2_GROUP_DESC)) % Ext2GroupDescPerBlock);
}
-U32 Ext2GetInodeGroupNumber(U32 Inode)
+ULONG Ext2GetInodeGroupNumber(ULONG Inode)
{
return ((Inode - 1) / Ext2SuperBlock->s_inodes_per_group);
}
-U32 Ext2GetInodeBlockNumber(U32 Inode)
+ULONG Ext2GetInodeBlockNumber(ULONG Inode)
{
return (((Inode - 1) % Ext2SuperBlock->s_inodes_per_group) / Ext2InodesPerBlock);
}
-U32 Ext2GetInodeOffsetInBlock(U32 Inode)
+ULONG Ext2GetInodeOffsetInBlock(ULONG Inode)
{
return (((Inode - 1) % Ext2SuperBlock->s_inodes_per_group) % Ext2InodesPerBlock);
}
-BOOL Ext2ReadInode(U32 Inode, PEXT2_INODE InodeBuffer)
+BOOL Ext2ReadInode(ULONG Inode, PEXT2_INODE InodeBuffer)
{
- U32 InodeGroupNumber;
- U32 InodeBlockNumber;
- U32 InodeOffsetInBlock;
+ ULONG InodeGroupNumber;
+ ULONG InodeBlockNumber;
+ ULONG InodeOffsetInBlock;
UCHAR ErrorString[80];
EXT2_GROUP_DESC GroupDescriptor;
@@ -978,7 +978,7 @@ BOOL Ext2ReadInode(U32 Inode, PEXT2_INODE InodeBuffer)
return TRUE;
}
-BOOL Ext2ReadGroupDescriptor(U32 Group, PEXT2_GROUP_DESC GroupBuffer)
+BOOL Ext2ReadGroupDescriptor(ULONG Group, PEXT2_GROUP_DESC GroupBuffer)
{
DbgPrint((DPRINT_FILESYSTEM, "Ext2ReadGroupDescriptor()\n"));
@@ -1002,13 +1002,13 @@ BOOL Ext2ReadGroupDescriptor(U32 Group, PEXT2_GROUP_DESC GroupBuffer)
return TRUE;
}
-U32* Ext2ReadBlockPointerList(PEXT2_INODE Inode)
+ULONG* Ext2ReadBlockPointerList(PEXT2_INODE Inode)
{
- U64 FileSize;
- U32 BlockCount;
- U32* BlockList;
- U32 CurrentBlockInList;
- U32 CurrentBlock;
+ ULONGLONG FileSize;
+ ULONG BlockCount;
+ ULONG* BlockList;
+ ULONG CurrentBlockInList;
+ ULONG CurrentBlock;
DbgPrint((DPRINT_FILESYSTEM, "Ext2ReadBlockPointerList()\n"));
@@ -1023,13 +1023,13 @@ U32* Ext2ReadBlockPointerList(PEXT2_INODE Inode)
BlockCount = (FileSize / Ext2BlockSizeInBytes);
// Allocate the memory for the block list
- BlockList = MmAllocateMemory(BlockCount * sizeof(U32));
+ BlockList = MmAllocateMemory(BlockCount * sizeof(ULONG));
if (BlockList == NULL)
{
return NULL;
}
- RtlZeroMemory(BlockList, BlockCount * sizeof(U32));
+ RtlZeroMemory(BlockList, BlockCount * sizeof(ULONG));
CurrentBlockInList = 0;
// Copy the direct block pointers
@@ -1072,27 +1072,27 @@ U32* Ext2ReadBlockPointerList(PEXT2_INODE Inode)
return BlockList;
}
-U64 Ext2GetInodeFileSize(PEXT2_INODE Inode)
+ULONGLONG Ext2GetInodeFileSize(PEXT2_INODE Inode)
{
if ((Inode->i_mode & EXT2_S_IFMT) == EXT2_S_IFDIR)
{
- return (U64)(Inode->i_size);
+ return (ULONGLONG)(Inode->i_size);
}
else
{
- return ((U64)(Inode->i_size) | ((U64)(Inode->i_dir_acl) << 32));
+ return ((ULONGLONG)(Inode->i_size) | ((ULONGLONG)(Inode->i_dir_acl) << 32));
}
}
-BOOL Ext2CopyIndirectBlockPointers(U32* BlockList, U32* CurrentBlockInList, U32 BlockCount, U32 IndirectBlock)
+BOOL Ext2CopyIndirectBlockPointers(ULONG* BlockList, ULONG* CurrentBlockInList, ULONG BlockCount, ULONG IndirectBlock)
{
- U32* BlockBuffer = (U32*)FILESYSBUFFER;
- U32 CurrentBlock;
- U32 BlockPointersPerBlock;
+ ULONG* BlockBuffer = (ULONG*)FILESYSBUFFER;
+ ULONG CurrentBlock;
+ ULONG BlockPointersPerBlock;
DbgPrint((DPRINT_FILESYSTEM, "Ext2CopyIndirectBlockPointers() BlockCount = %d\n", BlockCount));
- BlockPointersPerBlock = Ext2BlockSizeInBytes / sizeof(U32);
+ BlockPointersPerBlock = Ext2BlockSizeInBytes / sizeof(ULONG);
if (!Ext2ReadBlock(IndirectBlock, BlockBuffer))
{
@@ -1108,17 +1108,17 @@ BOOL Ext2CopyIndirectBlockPointers(U32* BlockList, U32* CurrentBlockInList, U32
return TRUE;
}
-BOOL Ext2CopyDoubleIndirectBlockPointers(U32* BlockList, U32* CurrentBlockInList, U32 BlockCount, U32 DoubleIndirectBlock)
+BOOL Ext2CopyDoubleIndirectBlockPointers(ULONG* BlockList, ULONG* CurrentBlockInList, ULONG BlockCount, ULONG DoubleIndirectBlock)
{
- U32* BlockBuffer;
- U32 CurrentBlock;
- U32 BlockPointersPerBlock;
+ ULONG* BlockBuffer;
+ ULONG CurrentBlock;
+ ULONG BlockPointersPerBlock;
DbgPrint((DPRINT_FILESYSTEM, "Ext2CopyDoubleIndirectBlockPointers() BlockCount = %d\n", BlockCount));
- BlockPointersPerBlock = Ext2BlockSizeInBytes / sizeof(U32);
+ BlockPointersPerBlock = Ext2BlockSizeInBytes / sizeof(ULONG);
- BlockBuffer = (U32*)MmAllocateMemory(Ext2BlockSizeInBytes);
+ BlockBuffer = (ULONG*)MmAllocateMemory(Ext2BlockSizeInBytes);
if (BlockBuffer == NULL)
{
return FALSE;
@@ -1143,17 +1143,17 @@ BOOL Ext2CopyDoubleIndirectBlockPointers(U32* BlockList, U32* CurrentBlockInList
return TRUE;
}
-BOOL Ext2CopyTripleIndirectBlockPointers(U32* BlockList, U32* CurrentBlockInList, U32 BlockCount, U32 TripleIndirectBlock)
+BOOL Ext2CopyTripleIndirectBlockPointers(ULONG* BlockList, ULONG* CurrentBlockInList, ULONG BlockCount, ULONG TripleIndirectBlock)
{
- U32* BlockBuffer;
- U32 CurrentBlock;
- U32 BlockPointersPerBlock;
+ ULONG* BlockBuffer;
+ ULONG CurrentBlock;
+ ULONG BlockPointersPerBlock;
DbgPrint((DPRINT_FILESYSTEM, "Ext2CopyTripleIndirectBlockPointers() BlockCount = %d\n", BlockCount));
- BlockPointersPerBlock = Ext2BlockSizeInBytes / sizeof(U32);
+ BlockPointersPerBlock = Ext2BlockSizeInBytes / sizeof(ULONG);
- BlockBuffer = (U32*)MmAllocateMemory(Ext2BlockSizeInBytes);
+ BlockBuffer = (ULONG*)MmAllocateMemory(Ext2BlockSizeInBytes);
if (BlockBuffer == NULL)
{
return FALSE;
diff --git a/reactos/boot/freeldr/freeldr/fs/ext2.h b/reactos/boot/freeldr/freeldr/fs/ext2.h
index 8204f1eac3e..5f3f02d6eed 100644
--- a/reactos/boot/freeldr/freeldr/fs/ext2.h
+++ b/reactos/boot/freeldr/freeldr/fs/ext2.h
@@ -113,7 +113,7 @@
# define EXT3_BLOCK_SIZE(s) (EXT3_MIN_BLOCK_SIZE << (s)->s_log_block_size)
#endif
#define EXT3_ACLE_PER_BLOCK(s) (EXT3_BLOCK_SIZE(s) / sizeof (struct ext3_acl_entry))
-#define EXT3_ADDR_PER_BLOCK(s) (EXT3_BLOCK_SIZE(s) / sizeof (__u32))
+#define EXT3_ADDR_PER_BLOCK(s) (EXT3_BLOCK_SIZE(s) / sizeof (ULONG))
#ifdef __KERNEL__
# define EXT3_BLOCK_SIZE_BITS(s) ((s)->s_blocksize_bits)
#else
@@ -151,20 +151,20 @@
*/
struct ext3_acl_header /* Header of Access Control Lists */
{
- __u32 aclh_size;
- __u32 aclh_file_count;
- __u32 aclh_acle_count;
- __u32 aclh_first_acle;
+ ULONG aclh_size;
+ ULONG aclh_file_count;
+ ULONG aclh_acle_count;
+ ULONG aclh_first_acle;
};
struct ext3_acl_entry /* Access Control List Entry */
{
- __u32 acle_size;
- __u16 acle_perms; /* Access permissions */
- __u16 acle_type; /* Type of entry */
- __u16 acle_tag; /* User or group identity */
- __u16 acle_pad1;
- __u32 acle_next; /* Pointer on next entry for the */
+ ULONG acle_size;
+ USHORT acle_perms; /* Access permissions */
+ USHORT acle_type; /* Type of entry */
+ USHORT acle_tag; /* User or group identity */
+ USHORT acle_pad1;
+ ULONG acle_next; /* Pointer on next entry for the */
/* same inode or on next free entry */
};
@@ -173,14 +173,14 @@ struct ext3_acl_entry /* Access Control List Entry */
*/
struct ext3_group_desc
{
- __u32 bg_block_bitmap; /* Blocks bitmap block */
- __u32 bg_inode_bitmap; /* Inodes bitmap block */
- __u32 bg_inode_table; /* Inodes table block */
- __u16 bg_free_blocks_count; /* Free blocks count */
- __u16 bg_free_inodes_count; /* Free inodes count */
- __u16 bg_used_dirs_count; /* Directories count */
- __u16 bg_pad;
- __u32 bg_reserved[3];
+ 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];
};
/*
@@ -254,55 +254,55 @@ struct ext3_group_desc
* Structure of an inode on the disk
*/
struct ext3_inode {
- __u16 i_mode; /* File mode */
- __u16 i_uid; /* Low 16 bits of Owner Uid */
- __u32 i_size; /* Size in bytes */
- __u32 i_atime; /* Access time */
- __u32 i_ctime; /* Creation time */
- __u32 i_mtime; /* Modification time */
- __u32 i_dtime; /* Deletion Time */
- __u16 i_gid; /* Low 16 bits of Group Id */
- __u16 i_links_count; /* Links count */
- __u32 i_blocks; /* Blocks count */
- __u32 i_flags; /* File flags */
+ USHORT i_mode; /* File mode */
+ USHORT i_uid; /* Low 16 bits of 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; /* Low 16 bits of Group Id */
+ USHORT i_links_count; /* Links count */
+ ULONG i_blocks; /* Blocks count */
+ ULONG i_flags; /* File flags */
union {
struct {
- __u32 l_i_reserved1;
+ ULONG l_i_reserved1;
} linux1;
struct {
- __u32 h_i_translator;
+ ULONG h_i_translator;
} hurd1;
struct {
- __u32 m_i_reserved1;
+ ULONG m_i_reserved1;
} masix1;
} osd1; /* OS dependent 1 */
- __u32 i_block[EXT3_N_BLOCKS];/* Pointers to blocks */
- __u32 i_generation; /* File version (for NFS) */
- __u32 i_file_acl; /* File ACL */
- __u32 i_dir_acl; /* Directory ACL */
- __u32 i_faddr; /* Fragment address */
+ ULONG i_block[EXT3_N_BLOCKS];/* Pointers to blocks */
+ ULONG i_generation; /* File version (for NFS) */
+ ULONG i_file_acl; /* File ACL */
+ ULONG i_dir_acl; /* Directory ACL */
+ ULONG i_faddr; /* Fragment address */
union {
struct {
- __u8 l_i_frag; /* Fragment number */
- __u8 l_i_fsize; /* Fragment size */
- __u16 i_pad1;
- __u16 l_i_uid_high; /* these 2 fields */
- __u16 l_i_gid_high; /* were reserved2[0] */
- __u32 l_i_reserved2;
+ UCHAR l_i_frag; /* Fragment number */
+ UCHAR l_i_fsize; /* Fragment size */
+ USHORT i_pad1;
+ USHORT l_i_uid_high; /* these 2 fields */
+ USHORT l_i_gid_high; /* were reserved2[0] */
+ ULONG l_i_reserved2;
} linux2;
struct {
- __u8 h_i_frag; /* Fragment number */
- __u8 h_i_fsize; /* Fragment size */
- __u16 h_i_mode_high;
- __u16 h_i_uid_high;
- __u16 h_i_gid_high;
- __u32 h_i_author;
+ 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 {
- __u8 m_i_frag; /* Fragment number */
- __u8 m_i_fsize; /* Fragment size */
- __u16 m_pad1;
- __u32 m_i_reserved2[2];
+ 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 */
};
@@ -398,31 +398,31 @@ struct ext3_inode {
* Structure of the super block
*/
struct ext3_super_block {
-/*00*/ __u32 s_inodes_count; /* Inodes count */
- __u32 s_blocks_count; /* Blocks count */
- __u32 s_r_blocks_count; /* Reserved blocks count */
- __u32 s_free_blocks_count; /* Free blocks count */
-/*10*/ __u32 s_free_inodes_count; /* Free inodes count */
- __u32 s_first_data_block; /* First Data Block */
- __u32 s_log_block_size; /* Block size */
- __s32 s_log_frag_size; /* Fragment size */
-/*20*/ __u32 s_blocks_per_group; /* # Blocks per group */
- __u32 s_frags_per_group; /* # Fragments per group */
- __u32 s_inodes_per_group; /* # Inodes per group */
- __u32 s_mtime; /* Mount time */
-/*30*/ __u32 s_wtime; /* Write time */
- __u16 s_mnt_count; /* Mount count */
- __s16 s_max_mnt_count; /* Maximal mount count */
- __u16 s_magic; /* Magic signature */
- __u16 s_state; /* File system state */
- __u16 s_errors; /* Behaviour when detecting errors */
- __u16 s_minor_rev_level; /* minor revision level */
-/*40*/ __u32 s_lastcheck; /* time of last check */
- __u32 s_checkinterval; /* max. time between checks */
- __u32 s_creator_os; /* OS */
- __u32 s_rev_level; /* Revision level */
-/*50*/ __u16 s_def_resuid; /* Default uid for reserved blocks */
- __u16 s_def_resgid; /* Default gid for reserved blocks */
+/*00*/ 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 */
+/*10*/ 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 */
+/*20*/ 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 */
+/*30*/ 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 */
+/*40*/ 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 */
+/*50*/ USHORT s_def_resuid; /* Default uid for reserved blocks */
+ USHORT s_def_resgid; /* Default gid for reserved blocks */
/*
* These fields are for EXT3_DYNAMIC_REV superblocks only.
*
@@ -436,32 +436,32 @@ struct ext3_super_block {
* feature set, it must abort and not try to meddle with
* things it doesn't understand...
*/
- __u32 s_first_ino; /* First non-reserved inode */
- __u16 s_inode_size; /* size of inode structure */
- __u16 s_block_group_nr; /* block group # of this superblock */
- __u32 s_feature_compat; /* compatible feature set */
-/*60*/ __u32 s_feature_incompat; /* incompatible feature set */
- __u32 s_feature_ro_compat; /* readonly-compatible feature set */
-/*68*/ __u8 s_uuid[16]; /* 128-bit uuid for volume */
+ 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 */
+/*60*/ ULONG s_feature_incompat; /* incompatible feature set */
+ ULONG s_feature_ro_compat; /* readonly-compatible feature set */
+/*68*/ UCHAR s_uuid[16]; /* 128-bit uuid for volume */
/*78*/ char s_volume_name[16]; /* volume name */
/*88*/ char s_last_mounted[64]; /* directory where last mounted */
-/*C8*/ __u32 s_algorithm_usage_bitmap; /* For compression */
+/*C8*/ ULONG s_algorithm_usage_bitmap; /* For compression */
/*
* Performance hints. Directory preallocation should only
* happen if the EXT3_FEATURE_COMPAT_DIR_PREALLOC flag is on.
*/
- __u8 s_prealloc_blocks; /* Nr of blocks to try to preallocate*/
- __u8 s_prealloc_dir_blocks; /* Nr to preallocate for dirs */
- __u16 s_padding1;
+ UCHAR s_prealloc_blocks; /* Nr of blocks to try to preallocate*/
+ UCHAR s_prealloc_dir_blocks; /* Nr to preallocate for dirs */
+ USHORT s_padding1;
/*
* Journaling support valid if EXT3_FEATURE_COMPAT_HAS_JOURNAL set.
*/
-/*D0*/ __u8 s_journal_uuid[16]; /* uuid of journal superblock */
-/*E0*/ __u32 s_journal_inum; /* inode number of journal file */
- __u32 s_journal_dev; /* device number of journal file */
- __u32 s_last_orphan; /* start of list of inodes to delete */
+/*D0*/ UCHAR s_journal_uuid[16]; /* uuid of journal superblock */
+/*E0*/ ULONG s_journal_inum; /* inode number of journal file */
+ ULONG s_journal_dev; /* device number of journal file */
+ ULONG s_last_orphan; /* start of list of inodes to delete */
-/*EC*/ __u32 s_reserved[197]; /* Padding to the end of the block */
+/*EC*/ ULONG s_reserved[197]; /* Padding to the end of the block */
};
#ifdef __KERNEL__
@@ -555,9 +555,9 @@ struct ext3_super_block {
#define EXT3_NAME_LEN 255
struct ext3_dir_entry {
- __u32 inode; /* Inode number */
- __u16 rec_len; /* Directory entry length */
- __u16 name_len; /* Name length */
+ ULONG inode; /* Inode number */
+ USHORT rec_len; /* Directory entry length */
+ USHORT name_len; /* Name length */
char name[EXT3_NAME_LEN]; /* File name */
};
@@ -568,10 +568,10 @@ struct ext3_dir_entry {
* file_type field.
*/
struct ext3_dir_entry_2 {
- __u32 inode; /* Inode number */
- __u16 rec_len; /* Directory entry length */
- __u8 name_len; /* Name length */
- __u8 file_type;
+ ULONG inode; /* Inode number */
+ USHORT rec_len; /* Directory entry length */
+ UCHAR name_len; /* Name length */
+ UCHAR file_type;
char name[EXT3_NAME_LEN]; /* File name */
};
@@ -653,45 +653,45 @@ typedef struct ext3_dir_entry_2 EXT2_DIR_ENTRY, *PEXT2_DIR_ENTRY;
#define EXT2_S_IFLNK 0xA000 // Symbolic link
#define EXT2_S_IFSOCK 0xC000 // Socket
-#define FAST_SYMLINK_MAX_NAME_SIZE (EXT3_N_BLOCKS * sizeof(U32)) /* 60 bytes */
+#define FAST_SYMLINK_MAX_NAME_SIZE (EXT3_N_BLOCKS * sizeof(ULONG)) /* 60 bytes */
typedef struct
{
- U64 FileSize; // File size
- U64 FilePointer; // File pointer
- U32* FileBlockList; // File block list
- U8 DriveNumber; // Drive number of open file
+ ULONGLONG FileSize; // File size
+ ULONGLONG FilePointer; // File pointer
+ ULONG* FileBlockList; // File block list
+ UCHAR DriveNumber; // Drive number of open file
EXT2_INODE Inode; // File's inode
} EXT2_FILE_INFO, * PEXT2_FILE_INFO;
-BOOL Ext2OpenVolume(U8 DriveNumber, U64 VolumeStartSector);
+BOOL Ext2OpenVolume(UCHAR DriveNumber, ULONGLONG VolumeStartSector);
FILE* Ext2OpenFile(PUCHAR FileName);
BOOL Ext2LookupFile(PUCHAR FileName, PEXT2_FILE_INFO Ext2FileInfoPointer);
-BOOL Ext2SearchDirectoryBufferForFile(PVOID DirectoryBuffer, U32 DirectorySize, PUCHAR FileName, PEXT2_DIR_ENTRY DirectoryEntry);
-BOOL Ext2ReadFile(FILE *FileHandle, U64 BytesToRead, U64* BytesRead, PVOID Buffer);
-U64 Ext2GetFileSize(FILE *FileHandle);
-VOID Ext2SetFilePointer(FILE *FileHandle, U64 NewFilePointer);
-U64 Ext2GetFilePointer(FILE *FileHandle);
-BOOL Ext2ReadVolumeSectors(U8 DriveNumber, U64 SectorNumber, U64 SectorCount, PVOID Buffer);
+BOOL Ext2SearchDirectoryBufferForFile(PVOID DirectoryBuffer, ULONG DirectorySize, PUCHAR FileName, PEXT2_DIR_ENTRY DirectoryEntry);
+BOOL Ext2ReadFile(FILE *FileHandle, ULONGLONG BytesToRead, ULONGLONG* BytesRead, PVOID Buffer);
+ULONGLONG Ext2GetFileSize(FILE *FileHandle);
+VOID Ext2SetFilePointer(FILE *FileHandle, ULONGLONG NewFilePointer);
+ULONGLONG Ext2GetFilePointer(FILE *FileHandle);
+BOOL Ext2ReadVolumeSectors(UCHAR DriveNumber, ULONGLONG SectorNumber, ULONGLONG SectorCount, PVOID Buffer);
BOOL Ext2ReadSuperBlock(VOID);
BOOL Ext2ReadGroupDescriptors(VOID);
-BOOL Ext2ReadDirectory(U32 Inode, PVOID* DirectoryBuffer, PEXT2_INODE InodePointer);
-BOOL Ext2ReadBlock(U32 BlockNumber, PVOID Buffer);
-BOOL Ext2ReadPartialBlock(U32 BlockNumber, U32 StartingOffset, U32 Length, PVOID Buffer);
-U32 Ext2GetGroupDescBlockNumber(U32 Group);
-U32 Ext2GetGroupDescOffsetInBlock(U32 Group);
-U32 Ext2GetInodeGroupNumber(U32 Inode);
-U32 Ext2GetInodeBlockNumber(U32 Inode);
-U32 Ext2GetInodeOffsetInBlock(U32 Inode);
-BOOL Ext2ReadInode(U32 Inode, PEXT2_INODE InodeBuffer);
-BOOL Ext2ReadGroupDescriptor(U32 Group, PEXT2_GROUP_DESC GroupBuffer);
-U32* Ext2ReadBlockPointerList(PEXT2_INODE Inode);
-U64 Ext2GetInodeFileSize(PEXT2_INODE Inode);
-BOOL Ext2CopyIndirectBlockPointers(U32* BlockList, U32* CurrentBlockInList, U32 BlockCount, U32 IndirectBlock);
-BOOL Ext2CopyDoubleIndirectBlockPointers(U32* BlockList, U32* CurrentBlockInList, U32 BlockCount, U32 DoubleIndirectBlock);
-BOOL Ext2CopyTripleIndirectBlockPointers(U32* BlockList, U32* CurrentBlockInList, U32 BlockCount, U32 TripleIndirectBlock);
+BOOL Ext2ReadDirectory(ULONG Inode, PVOID* DirectoryBuffer, PEXT2_INODE InodePointer);
+BOOL Ext2ReadBlock(ULONG BlockNumber, PVOID Buffer);
+BOOL Ext2ReadPartialBlock(ULONG BlockNumber, ULONG StartingOffset, ULONG Length, PVOID Buffer);
+ULONG Ext2GetGroupDescBlockNumber(ULONG Group);
+ULONG Ext2GetGroupDescOffsetInBlock(ULONG Group);
+ULONG Ext2GetInodeGroupNumber(ULONG Inode);
+ULONG Ext2GetInodeBlockNumber(ULONG Inode);
+ULONG Ext2GetInodeOffsetInBlock(ULONG Inode);
+BOOL Ext2ReadInode(ULONG Inode, PEXT2_INODE InodeBuffer);
+BOOL Ext2ReadGroupDescriptor(ULONG Group, PEXT2_GROUP_DESC GroupBuffer);
+ULONG* Ext2ReadBlockPointerList(PEXT2_INODE Inode);
+ULONGLONG Ext2GetInodeFileSize(PEXT2_INODE Inode);
+BOOL Ext2CopyIndirectBlockPointers(ULONG* BlockList, ULONG* CurrentBlockInList, ULONG BlockCount, ULONG IndirectBlock);
+BOOL Ext2CopyDoubleIndirectBlockPointers(ULONG* BlockList, ULONG* CurrentBlockInList, ULONG BlockCount, ULONG DoubleIndirectBlock);
+BOOL Ext2CopyTripleIndirectBlockPointers(ULONG* BlockList, ULONG* CurrentBlockInList, ULONG BlockCount, ULONG TripleIndirectBlock);
#endif // #defined __EXT2_H
diff --git a/reactos/boot/freeldr/freeldr/fs/fat.c b/reactos/boot/freeldr/freeldr/fs/fat.c
index 65f8a95a043..973cf55383c 100644
--- a/reactos/boot/freeldr/freeldr/fs/fat.c
+++ b/reactos/boot/freeldr/freeldr/fs/fat.c
@@ -29,25 +29,25 @@
#include
#include
-U32 BytesPerSector; /* Number of bytes per sector */
-U32 SectorsPerCluster; /* Number of sectors per cluster */
-U32 FatVolumeStartSector; /* Absolute starting sector of the partition */
-U32 FatSectorStart; /* Starting sector of 1st FAT table */
-U32 ActiveFatSectorStart; /* Starting sector of active FAT table */
-U32 NumberOfFats; /* Number of FAT tables */
-U32 SectorsPerFat; /* Sectors per FAT table */
-U32 RootDirSectorStart; /* Starting sector of the root directory (non-fat32) */
-U32 RootDirSectors; /* Number of sectors of the root directory (non-fat32) */
-U32 RootDirStartCluster; /* Starting cluster number of the root directory (fat32 only) */
-U32 DataSectorStart; /* Starting sector of the data area */
+ULONG BytesPerSector; /* Number of bytes per sector */
+ULONG SectorsPerCluster; /* Number of sectors per cluster */
+ULONG FatVolumeStartSector; /* Absolute starting sector of the partition */
+ULONG FatSectorStart; /* Starting sector of 1st FAT table */
+ULONG ActiveFatSectorStart; /* Starting sector of active FAT table */
+ULONG NumberOfFats; /* Number of FAT tables */
+ULONG SectorsPerFat; /* Sectors per FAT table */
+ULONG RootDirSectorStart; /* Starting sector of the root directory (non-fat32) */
+ULONG RootDirSectors; /* Number of sectors of the root directory (non-fat32) */
+ULONG RootDirStartCluster; /* Starting cluster number of the root directory (fat32 only) */
+ULONG DataSectorStart; /* Starting sector of the data area */
-U32 FatType = 0; /* FAT12, FAT16, FAT32, FATX16 or FATX32 */
-U32 FatDriveNumber = 0;
+ULONG FatType = 0; /* FAT12, FAT16, FAT32, FATX16 or FATX32 */
+ULONG FatDriveNumber = 0;
-BOOL FatOpenVolume(U32 DriveNumber, U32 VolumeStartSector, U32 PartitionSectorCount)
+BOOL FatOpenVolume(ULONG DriveNumber, ULONG VolumeStartSector, ULONG PartitionSectorCount)
{
char ErrMsg[80];
- U32 FatSize;
+ ULONG FatSize;
PFAT_BOOTSECTOR FatVolumeBootSector;
PFAT32_BOOTSECTOR Fat32VolumeBootSector;
PFATX_BOOTSECTOR FatXVolumeBootSector;
@@ -288,13 +288,13 @@ BOOL FatOpenVolume(U32 DriveNumber, U32 VolumeStartSector, U32 PartitionSectorCo
return TRUE;
}
-U32 FatDetermineFatType(PFAT_BOOTSECTOR FatBootSector, U32 PartitionSectorCount)
+ULONG FatDetermineFatType(PFAT_BOOTSECTOR FatBootSector, ULONG PartitionSectorCount)
{
- U32 RootDirSectors;
- U32 DataSectorCount;
- U32 SectorsPerFat;
- U32 TotalSectors;
- U32 CountOfClusters;
+ ULONG RootDirSectors;
+ ULONG DataSectorCount;
+ ULONG SectorsPerFat;
+ ULONG TotalSectors;
+ ULONG CountOfClusters;
PFAT32_BOOTSECTOR Fat32BootSector = (PFAT32_BOOTSECTOR)FatBootSector;
PFATX_BOOTSECTOR FatXBootSector = (PFATX_BOOTSECTOR)FatBootSector;
@@ -343,7 +343,7 @@ U32 FatDetermineFatType(PFAT_BOOTSECTOR FatBootSector, U32 PartitionSectorCount)
}
}
-PVOID FatBufferDirectory(U32 DirectoryStartCluster, U32 *DirectorySize, BOOL RootDirectory)
+PVOID FatBufferDirectory(ULONG DirectoryStartCluster, ULONG *DirectorySize, BOOL RootDirectory)
{
PVOID DirectoryBuffer;
@@ -405,15 +405,15 @@ PVOID FatBufferDirectory(U32 DirectoryStartCluster, U32 *DirectorySize, BOOL Roo
return DirectoryBuffer;
}
-BOOL FatSearchDirectoryBufferForFile(PVOID DirectoryBuffer, U32 DirectorySize, PUCHAR FileName, PFAT_FILE_INFO FatFileInfoPointer)
+BOOL FatSearchDirectoryBufferForFile(PVOID DirectoryBuffer, ULONG DirectorySize, PUCHAR FileName, PFAT_FILE_INFO FatFileInfoPointer)
{
- U32 EntryCount;
- U32 CurrentEntry;
+ ULONG EntryCount;
+ ULONG CurrentEntry;
PDIRENTRY DirEntry;
PLFN_DIRENTRY LfnDirEntry;
UCHAR LfnNameBuffer[265];
UCHAR ShortNameBuffer[20];
- U32 StartCluster;
+ ULONG StartCluster;
EntryCount = DirectorySize / sizeof(DIRENTRY);
@@ -590,7 +590,7 @@ BOOL FatSearchDirectoryBufferForFile(PVOID DirectoryBuffer, U32 DirectorySize, P
//
// Get the cluster chain
//
- StartCluster = ((U32)DirEntry->ClusterHigh << 16) + DirEntry->ClusterLow;
+ StartCluster = ((ULONG)DirEntry->ClusterHigh << 16) + DirEntry->ClusterLow;
DbgPrint((DPRINT_FILESYSTEM, "StartCluster = 0x%x\n", StartCluster));
FatFileInfoPointer->FileFatChain = FatGetClusterChainArray(StartCluster);
@@ -616,12 +616,12 @@ BOOL FatSearchDirectoryBufferForFile(PVOID DirectoryBuffer, U32 DirectorySize, P
return FALSE;
}
-BOOL FatXSearchDirectoryBufferForFile(PVOID DirectoryBuffer, U32 DirectorySize, PUCHAR FileName, PFAT_FILE_INFO FatFileInfoPointer)
+BOOL FatXSearchDirectoryBufferForFile(PVOID DirectoryBuffer, ULONG DirectorySize, PUCHAR FileName, PFAT_FILE_INFO FatFileInfoPointer)
{
- U32 EntryCount;
- U32 CurrentEntry;
+ ULONG EntryCount;
+ ULONG CurrentEntry;
PFATX_DIRENTRY DirEntry;
- U32 FileNameLen;
+ ULONG FileNameLen;
EntryCount = DirectorySize / sizeof(FATX_DIRENTRY);
@@ -690,11 +690,11 @@ BOOL FatXSearchDirectoryBufferForFile(PVOID DirectoryBuffer, U32 DirectorySize,
BOOL FatLookupFile(PUCHAR FileName, PFAT_FILE_INFO FatFileInfoPointer)
{
int i;
- U32 NumberOfPathParts;
+ ULONG NumberOfPathParts;
UCHAR PathPart[261];
PVOID DirectoryBuffer;
- U32 DirectoryStartCluster = 0;
- U32 DirectorySize;
+ ULONG DirectoryStartCluster = 0;
+ ULONG DirectorySize;
FAT_FILE_INFO FatFileInfo;
DbgPrint((DPRINT_FILESYSTEM, "FatLookupFile() FileName = %s\n", FileName));
@@ -779,7 +779,7 @@ BOOL FatLookupFile(PUCHAR FileName, PFAT_FILE_INFO FatFileInfoPointer)
*/
void FatParseShortFileName(PUCHAR Buffer, PDIRENTRY DirEntry)
{
- U32 Idx;
+ ULONG Idx;
Idx = 0;
RtlZeroMemory(Buffer, 13);
@@ -824,9 +824,9 @@ void FatParseShortFileName(PUCHAR Buffer, PDIRENTRY DirEntry)
* FatGetFatEntry()
* returns the Fat entry for a given cluster number
*/
-BOOL FatGetFatEntry(U32 Cluster, U32* ClusterPointer)
+BOOL FatGetFatEntry(ULONG Cluster, ULONG* ClusterPointer)
{
- U32 fat = 0;
+ ULONG fat = 0;
int FatOffset;
int ThisFatSecNum;
int ThisFatEntOffset;
@@ -860,7 +860,7 @@ BOOL FatGetFatEntry(U32 Cluster, U32* ClusterPointer)
}
}
- fat = *((U16 *) ((PVOID)FILESYSBUFFER + ThisFatEntOffset));
+ fat = *((USHORT *) ((PVOID)FILESYSBUFFER + ThisFatEntOffset));
if (Cluster & 0x0001)
fat = fat >> 4; /* Cluster number is ODD */
else
@@ -880,7 +880,7 @@ BOOL FatGetFatEntry(U32 Cluster, U32* ClusterPointer)
return FALSE;
}
- fat = *((U16 *) ((PVOID)FILESYSBUFFER + ThisFatEntOffset));
+ fat = *((USHORT *) ((PVOID)FILESYSBUFFER + ThisFatEntOffset));
break;
@@ -897,7 +897,7 @@ BOOL FatGetFatEntry(U32 Cluster, U32* ClusterPointer)
}
// Get the fat entry
- fat = (*((U32 *) ((PVOID)FILESYSBUFFER + ThisFatEntOffset))) & 0x0FFFFFFF;
+ fat = (*((ULONG *) ((PVOID)FILESYSBUFFER + ThisFatEntOffset))) & 0x0FFFFFFF;
break;
@@ -939,9 +939,9 @@ FILE* FatOpenFile(PUCHAR FileName)
return (FILE*)FileHandle;
}
-U32 FatCountClustersInChain(U32 StartCluster)
+ULONG FatCountClustersInChain(ULONG StartCluster)
{
- U32 ClusterCount = 0;
+ ULONG ClusterCount = 0;
DbgPrint((DPRINT_FILESYSTEM, "FatCountClustersInChain() StartCluster = %d\n", StartCluster));
@@ -976,17 +976,17 @@ U32 FatCountClustersInChain(U32 StartCluster)
return ClusterCount;
}
-U32* FatGetClusterChainArray(U32 StartCluster)
+ULONG* FatGetClusterChainArray(ULONG StartCluster)
{
- U32 ClusterCount;
- U32 ArraySize;
- U32* ArrayPointer;
- U32 Idx;
+ ULONG ClusterCount;
+ ULONG ArraySize;
+ ULONG* ArrayPointer;
+ ULONG Idx;
DbgPrint((DPRINT_FILESYSTEM, "FatGetClusterChainArray() StartCluster = %d\n", StartCluster));
ClusterCount = FatCountClustersInChain(StartCluster) + 1; // Lets get the 0x0ffffff8 on the end of the array
- ArraySize = ClusterCount * sizeof(U32);
+ ArraySize = ClusterCount * sizeof(ULONG);
//
// Allocate array memory
@@ -1036,9 +1036,9 @@ U32* FatGetClusterChainArray(U32 StartCluster)
* FatReadCluster()
* Reads the specified cluster into memory
*/
-BOOL FatReadCluster(U32 ClusterNumber, PVOID Buffer)
+BOOL FatReadCluster(ULONG ClusterNumber, PVOID Buffer)
{
- U32 ClusterStartSector;
+ ULONG ClusterStartSector;
ClusterStartSector = ((ClusterNumber - 2) * SectorsPerCluster) + DataSectorStart;
@@ -1058,9 +1058,9 @@ BOOL FatReadCluster(U32 ClusterNumber, PVOID Buffer)
* FatReadClusterChain()
* Reads the specified clusters into memory
*/
-BOOL FatReadClusterChain(U32 StartClusterNumber, U32 NumberOfClusters, PVOID Buffer)
+BOOL FatReadClusterChain(ULONG StartClusterNumber, ULONG NumberOfClusters, PVOID Buffer)
{
- U32 ClusterStartSector;
+ ULONG ClusterStartSector;
DbgPrint((DPRINT_FILESYSTEM, "FatReadClusterChain() StartClusterNumber = %d NumberOfClusters = %d Buffer = 0x%x\n", StartClusterNumber, NumberOfClusters, Buffer));
@@ -1119,9 +1119,9 @@ BOOL FatReadClusterChain(U32 StartClusterNumber, U32 NumberOfClusters, PVOID Buf
* FatReadPartialCluster()
* Reads part of a cluster into memory
*/
-BOOL FatReadPartialCluster(U32 ClusterNumber, U32 StartingOffset, U32 Length, PVOID Buffer)
+BOOL FatReadPartialCluster(ULONG ClusterNumber, ULONG StartingOffset, ULONG Length, PVOID Buffer)
{
- U32 ClusterStartSector;
+ ULONG ClusterStartSector;
DbgPrint((DPRINT_FILESYSTEM, "FatReadPartialCluster() ClusterNumber = %d StartingOffset = %d Length = %d Buffer = 0x%x\n", ClusterNumber, StartingOffset, Length, Buffer));
@@ -1142,14 +1142,14 @@ BOOL FatReadPartialCluster(U32 ClusterNumber, U32 StartingOffset, U32 Length, PV
* Reads BytesToRead from open file and
* returns the number of bytes read in BytesRead
*/
-BOOL FatReadFile(FILE *FileHandle, U32 BytesToRead, U32* BytesRead, PVOID Buffer)
+BOOL FatReadFile(FILE *FileHandle, ULONG BytesToRead, ULONG* BytesRead, PVOID Buffer)
{
PFAT_FILE_INFO FatFileInfo = (PFAT_FILE_INFO)FileHandle;
- U32 ClusterNumber;
- U32 OffsetInCluster;
- U32 LengthInCluster;
- U32 NumberOfClusters;
- U32 BytesPerCluster;
+ ULONG ClusterNumber;
+ ULONG OffsetInCluster;
+ ULONG LengthInCluster;
+ ULONG NumberOfClusters;
+ ULONG BytesPerCluster;
DbgPrint((DPRINT_FILESYSTEM, "FatReadFile() BytesToRead = %d Buffer = 0x%x\n", BytesToRead, Buffer));
@@ -1296,7 +1296,7 @@ BOOL FatReadFile(FILE *FileHandle, U32 BytesToRead, U32* BytesRead, PVOID Buffer
return TRUE;
}
-U32 FatGetFileSize(FILE *FileHandle)
+ULONG FatGetFileSize(FILE *FileHandle)
{
PFAT_FILE_INFO FatFileHandle = (PFAT_FILE_INFO)FileHandle;
@@ -1305,7 +1305,7 @@ U32 FatGetFileSize(FILE *FileHandle)
return FatFileHandle->FileSize;
}
-VOID FatSetFilePointer(FILE *FileHandle, U32 NewFilePointer)
+VOID FatSetFilePointer(FILE *FileHandle, ULONG NewFilePointer)
{
PFAT_FILE_INFO FatFileHandle = (PFAT_FILE_INFO)FileHandle;
@@ -1314,7 +1314,7 @@ VOID FatSetFilePointer(FILE *FileHandle, U32 NewFilePointer)
FatFileHandle->FilePointer = NewFilePointer;
}
-U32 FatGetFilePointer(FILE *FileHandle)
+ULONG FatGetFilePointer(FILE *FileHandle)
{
PFAT_FILE_INFO FatFileHandle = (PFAT_FILE_INFO)FileHandle;
@@ -1323,7 +1323,7 @@ U32 FatGetFilePointer(FILE *FileHandle)
return FatFileHandle->FilePointer;
}
-BOOL FatReadVolumeSectors(U32 DriveNumber, U32 SectorNumber, U32 SectorCount, PVOID Buffer)
+BOOL FatReadVolumeSectors(ULONG DriveNumber, ULONG SectorNumber, ULONG SectorCount, PVOID Buffer)
{
return CacheReadDiskSectors(DriveNumber, SectorNumber + FatVolumeStartSector, SectorCount, Buffer);
}
diff --git a/reactos/boot/freeldr/freeldr/fs/fat.h b/reactos/boot/freeldr/freeldr/fs/fat.h
index db21e0f315f..d697e4840f7 100644
--- a/reactos/boot/freeldr/freeldr/fs/fat.h
+++ b/reactos/boot/freeldr/freeldr/fs/fat.h
@@ -22,77 +22,77 @@
typedef struct _FAT_BOOTSECTOR
{
- U8 JumpBoot[3]; // Jump instruction to boot code
- U8 OemName[8]; // "MSWIN4.1" for MS formatted volumes
- U16 BytesPerSector; // Bytes per sector
- U8 SectorsPerCluster; // Number of sectors in a cluster
- U16 ReservedSectors; // Reserved sectors, usually 1 (the bootsector)
- U8 NumberOfFats; // Number of FAT tables
- U16 RootDirEntries; // Number of root directory entries (fat12/16)
- U16 TotalSectors; // Number of total sectors on the drive, 16-bit
- U8 MediaDescriptor; // Media descriptor byte
- U16 SectorsPerFat; // Sectors per FAT table (fat12/16)
- U16 SectorsPerTrack; // Number of sectors in a track
- U16 NumberOfHeads; // Number of heads on the disk
- U32 HiddenSectors; // Hidden sectors (sectors before the partition start like the partition table)
- U32 TotalSectorsBig; // This field is the new 32-bit total count of sectors on the volume
- U8 DriveNumber; // Int 0x13 drive number (e.g. 0x80)
- U8 Reserved1; // Reserved (used by Windows NT). Code that formats FAT volumes should always set this byte to 0.
- U8 BootSignature; // Extended boot signature (0x29). This is a signature byte that indicates that the following three fields in the boot sector are present.
- U32 VolumeSerialNumber; // Volume serial number
- U8 VolumeLabel[11]; // Volume label. This field matches the 11-byte volume label recorded in the root directory
- U8 FileSystemType[8]; // One of the strings "FAT12 ", "FAT16 ", or "FAT "
+ UCHAR JumpBoot[3]; // Jump instruction to boot code
+ UCHAR OemName[8]; // "MSWIN4.1" for MS formatted volumes
+ USHORT BytesPerSector; // Bytes per sector
+ UCHAR SectorsPerCluster; // Number of sectors in a cluster
+ USHORT ReservedSectors; // Reserved sectors, usually 1 (the bootsector)
+ UCHAR NumberOfFats; // Number of FAT tables
+ USHORT RootDirEntries; // Number of root directory entries (fat12/16)
+ USHORT TotalSectors; // Number of total sectors on the drive, 16-bit
+ UCHAR MediaDescriptor; // Media descriptor byte
+ USHORT SectorsPerFat; // Sectors per FAT table (fat12/16)
+ USHORT SectorsPerTrack; // Number of sectors in a track
+ USHORT NumberOfHeads; // Number of heads on the disk
+ ULONG HiddenSectors; // Hidden sectors (sectors before the partition start like the partition table)
+ ULONG TotalSectorsBig; // This field is the new 32-bit total count of sectors on the volume
+ UCHAR DriveNumber; // Int 0x13 drive number (e.g. 0x80)
+ UCHAR Reserved1; // Reserved (used by Windows NT). Code that formats FAT volumes should always set this byte to 0.
+ UCHAR BootSignature; // Extended boot signature (0x29). This is a signature byte that indicates that the following three fields in the boot sector are present.
+ ULONG VolumeSerialNumber; // Volume serial number
+ UCHAR VolumeLabel[11]; // Volume label. This field matches the 11-byte volume label recorded in the root directory
+ UCHAR FileSystemType[8]; // One of the strings "FAT12 ", "FAT16 ", or "FAT "
- U8 BootCodeAndData[448]; // The remainder of the boot sector
+ UCHAR BootCodeAndData[448]; // The remainder of the boot sector
- U16 BootSectorMagic; // 0xAA55
+ USHORT BootSectorMagic; // 0xAA55
} PACKED FAT_BOOTSECTOR, *PFAT_BOOTSECTOR;
typedef struct _FAT32_BOOTSECTOR
{
- U8 JumpBoot[3]; // Jump instruction to boot code
- U8 OemName[8]; // "MSWIN4.1" for MS formatted volumes
- U16 BytesPerSector; // Bytes per sector
- U8 SectorsPerCluster; // Number of sectors in a cluster
- U16 ReservedSectors; // Reserved sectors, usually 1 (the bootsector)
- U8 NumberOfFats; // Number of FAT tables
- U16 RootDirEntries; // Number of root directory entries (fat12/16)
- U16 TotalSectors; // Number of total sectors on the drive, 16-bit
- U8 MediaDescriptor; // Media descriptor byte
- U16 SectorsPerFat; // Sectors per FAT table (fat12/16)
- U16 SectorsPerTrack; // Number of sectors in a track
- U16 NumberOfHeads; // Number of heads on the disk
- U32 HiddenSectors; // Hidden sectors (sectors before the partition start like the partition table)
- U32 TotalSectorsBig; // This field is the new 32-bit total count of sectors on the volume
- U32 SectorsPerFatBig; // This field is the FAT32 32-bit count of sectors occupied by ONE FAT. BPB_FATSz16 must be 0
- U16 ExtendedFlags; // Extended flags (fat32)
- U16 FileSystemVersion; // File system version (fat32)
- U32 RootDirStartCluster; // Starting cluster of the root directory (fat32)
- U16 FsInfo; // Sector number of FSINFO structure in the reserved area of the FAT32 volume. Usually 1.
- U16 BackupBootSector; // If non-zero, indicates the sector number in the reserved area of the volume of a copy of the boot record. Usually 6.
- U8 Reserved[12]; // Reserved for future expansion
- U8 DriveNumber; // Int 0x13 drive number (e.g. 0x80)
- U8 Reserved1; // Reserved (used by Windows NT). Code that formats FAT volumes should always set this byte to 0.
- U8 BootSignature; // Extended boot signature (0x29). This is a signature byte that indicates that the following three fields in the boot sector are present.
- U32 VolumeSerialNumber; // Volume serial number
- U8 VolumeLabel[11]; // Volume label. This field matches the 11-byte volume label recorded in the root directory
- U8 FileSystemType[8]; // Always set to the string "FAT32 "
+ UCHAR JumpBoot[3]; // Jump instruction to boot code
+ UCHAR OemName[8]; // "MSWIN4.1" for MS formatted volumes
+ USHORT BytesPerSector; // Bytes per sector
+ UCHAR SectorsPerCluster; // Number of sectors in a cluster
+ USHORT ReservedSectors; // Reserved sectors, usually 1 (the bootsector)
+ UCHAR NumberOfFats; // Number of FAT tables
+ USHORT RootDirEntries; // Number of root directory entries (fat12/16)
+ USHORT TotalSectors; // Number of total sectors on the drive, 16-bit
+ UCHAR MediaDescriptor; // Media descriptor byte
+ USHORT SectorsPerFat; // Sectors per FAT table (fat12/16)
+ USHORT SectorsPerTrack; // Number of sectors in a track
+ USHORT NumberOfHeads; // Number of heads on the disk
+ ULONG HiddenSectors; // Hidden sectors (sectors before the partition start like the partition table)
+ ULONG TotalSectorsBig; // This field is the new 32-bit total count of sectors on the volume
+ ULONG SectorsPerFatBig; // This field is the FAT32 32-bit count of sectors occupied by ONE FAT. BPB_FATSz16 must be 0
+ USHORT ExtendedFlags; // Extended flags (fat32)
+ USHORT FileSystemVersion; // File system version (fat32)
+ ULONG RootDirStartCluster; // Starting cluster of the root directory (fat32)
+ USHORT FsInfo; // Sector number of FSINFO structure in the reserved area of the FAT32 volume. Usually 1.
+ USHORT BackupBootSector; // If non-zero, indicates the sector number in the reserved area of the volume of a copy of the boot record. Usually 6.
+ UCHAR Reserved[12]; // Reserved for future expansion
+ UCHAR DriveNumber; // Int 0x13 drive number (e.g. 0x80)
+ UCHAR Reserved1; // Reserved (used by Windows NT). Code that formats FAT volumes should always set this byte to 0.
+ UCHAR BootSignature; // Extended boot signature (0x29). This is a signature byte that indicates that the following three fields in the boot sector are present.
+ ULONG VolumeSerialNumber; // Volume serial number
+ UCHAR VolumeLabel[11]; // Volume label. This field matches the 11-byte volume label recorded in the root directory
+ UCHAR FileSystemType[8]; // Always set to the string "FAT32 "
- U8 BootCodeAndData[420]; // The remainder of the boot sector
+ UCHAR BootCodeAndData[420]; // The remainder of the boot sector
- U16 BootSectorMagic; // 0xAA55
+ USHORT BootSectorMagic; // 0xAA55
} PACKED FAT32_BOOTSECTOR, *PFAT32_BOOTSECTOR;
typedef struct _FATX_BOOTSECTOR
{
- U8 FileSystemType[4]; /* String "FATX" */
- U32 VolumeSerialNumber; /* Volume serial number */
- U32 SectorsPerCluster; /* Number of sectors in a cluster */
- U16 NumberOfFats; /* Number of FAT tables */
- U32 Unknown; /* Always 0? */
- U8 Unused[494]; /* Actually size should be 4078 (boot block is 4096 bytes) */
+ UCHAR FileSystemType[4]; /* String "FATX" */
+ ULONG VolumeSerialNumber; /* Volume serial number */
+ ULONG SectorsPerCluster; /* Number of sectors in a cluster */
+ USHORT NumberOfFats; /* Number of FAT tables */
+ ULONG Unknown; /* Always 0? */
+ UCHAR Unused[494]; /* Actually size should be 4078 (boot block is 4096 bytes) */
} PACKED FATX_BOOTSECTOR, *PFATX_BOOTSECTOR;
@@ -102,74 +102,74 @@ typedef struct _FATX_BOOTSECTOR
typedef struct //_DIRENTRY
{
UCHAR FileName[11]; /* Filename + extension */
- U8 Attr; /* File attributes */
- U8 ReservedNT; /* Reserved for use by Windows NT */
- U8 TimeInTenths; /* Millisecond stamp at file creation */
- U16 CreateTime; /* Time file was created */
- U16 CreateDate; /* Date file was created */
- U16 LastAccessDate; /* Date file was last accessed */
- U16 ClusterHigh; /* High word of this entry's start cluster */
- U16 Time; /* Time last modified */
- U16 Date; /* Date last modified */
- U16 ClusterLow; /* First cluster number low word */
- U32 Size; /* File size */
+ UCHAR Attr; /* File attributes */
+ UCHAR ReservedNT; /* Reserved for use by Windows NT */
+ UCHAR TimeInTenths; /* Millisecond stamp at file creation */
+ USHORT CreateTime; /* Time file was created */
+ USHORT CreateDate; /* Date file was created */
+ USHORT LastAccessDate; /* Date file was last accessed */
+ USHORT ClusterHigh; /* High word of this entry's start cluster */
+ USHORT Time; /* Time last modified */
+ USHORT Date; /* Date last modified */
+ USHORT ClusterLow; /* First cluster number low word */
+ ULONG Size; /* File size */
} PACKED DIRENTRY, * PDIRENTRY;
typedef struct
{
- U8 SequenceNumber; /* Sequence number for slot */
+ UCHAR SequenceNumber; /* Sequence number for slot */
WCHAR Name0_4[5]; /* First 5 characters in name */
- U8 EntryAttributes; /* Attribute byte */
- U8 Reserved; /* Always 0 */
- U8 AliasChecksum; /* Checksum for 8.3 alias */
+ UCHAR EntryAttributes; /* Attribute byte */
+ UCHAR Reserved; /* Always 0 */
+ UCHAR AliasChecksum; /* Checksum for 8.3 alias */
WCHAR Name5_10[6]; /* 6 more characters in name */
- U16 StartCluster; /* Starting cluster number */
+ USHORT StartCluster; /* Starting cluster number */
WCHAR Name11_12[2]; /* Last 2 characters in name */
} PACKED LFN_DIRENTRY, * PLFN_DIRENTRY;
typedef struct
{
- U8 FileNameSize; /* Size of filename (max 42) */
- U8 Attr; /* File attributes */
+ UCHAR FileNameSize; /* Size of filename (max 42) */
+ UCHAR Attr; /* File attributes */
UCHAR FileName[42]; /* Filename in ASCII, padded with 0xff (not zero-terminated) */
- U32 StartCluster; /* Starting cluster number */
- U32 Size; /* File size */
- U16 Time; /* Time last modified */
- U16 Date; /* Date last modified */
- U16 CreateTime; /* Time file was created */
- U16 CreateDate; /* Date file was created */
- U16 LastAccessTime; /* Time file was last accessed */
- U16 LastAccessDate; /* Date file was last accessed */
+ ULONG StartCluster; /* Starting cluster number */
+ ULONG Size; /* File size */
+ USHORT Time; /* Time last modified */
+ USHORT Date; /* Date last modified */
+ USHORT CreateTime; /* Time file was created */
+ USHORT CreateDate; /* Date file was created */
+ USHORT LastAccessTime; /* Time file was last accessed */
+ USHORT LastAccessDate; /* Date file was last accessed */
} PACKED FATX_DIRENTRY, * PFATX_DIRENTRY;
typedef struct
{
- U32 FileSize; /* File size */
- U32 FilePointer; /* File pointer */
- U32* FileFatChain; /* File fat chain array */
- U32 DriveNumber;
+ ULONG FileSize; /* File size */
+ ULONG FilePointer; /* File pointer */
+ ULONG* FileFatChain; /* File fat chain array */
+ ULONG DriveNumber;
} FAT_FILE_INFO, * PFAT_FILE_INFO;
-BOOL FatOpenVolume(U32 DriveNumber, U32 VolumeStartSector, U32 PartitionSectorCount);
-U32 FatDetermineFatType(PFAT_BOOTSECTOR FatBootSector, U32 PartitionSectorCount);
-PVOID FatBufferDirectory(U32 DirectoryStartCluster, U32* EntryCountPointer, BOOL RootDirectory);
-BOOL FatSearchDirectoryBufferForFile(PVOID DirectoryBuffer, U32 EntryCount, PUCHAR FileName, PFAT_FILE_INFO FatFileInfoPointer);
+BOOL FatOpenVolume(ULONG DriveNumber, ULONG VolumeStartSector, ULONG PartitionSectorCount);
+ULONG FatDetermineFatType(PFAT_BOOTSECTOR FatBootSector, ULONG PartitionSectorCount);
+PVOID FatBufferDirectory(ULONG DirectoryStartCluster, ULONG* EntryCountPointer, BOOL RootDirectory);
+BOOL FatSearchDirectoryBufferForFile(PVOID DirectoryBuffer, ULONG EntryCount, PUCHAR FileName, PFAT_FILE_INFO FatFileInfoPointer);
BOOL FatLookupFile(PUCHAR FileName, PFAT_FILE_INFO FatFileInfoPointer);
void FatParseShortFileName(PUCHAR Buffer, PDIRENTRY DirEntry);
-BOOL FatGetFatEntry(U32 Cluster, U32* ClusterPointer);
+BOOL FatGetFatEntry(ULONG Cluster, ULONG* ClusterPointer);
FILE* FatOpenFile(PUCHAR FileName);
-U32 FatCountClustersInChain(U32 StartCluster);
-U32* FatGetClusterChainArray(U32 StartCluster);
-BOOL FatReadCluster(U32 ClusterNumber, PVOID Buffer);
-BOOL FatReadClusterChain(U32 StartClusterNumber, U32 NumberOfClusters, PVOID Buffer);
-BOOL FatReadPartialCluster(U32 ClusterNumber, U32 StartingOffset, U32 Length, PVOID Buffer);
-BOOL FatReadFile(FILE *FileHandle, U32 BytesToRead, U32* BytesRead, PVOID Buffer);
-U32 FatGetFileSize(FILE *FileHandle);
-VOID FatSetFilePointer(FILE *FileHandle, U32 NewFilePointer);
-U32 FatGetFilePointer(FILE *FileHandle);
-BOOL FatReadVolumeSectors(U32 DriveNumber, U32 SectorNumber, U32 SectorCount, PVOID Buffer);
+ULONG FatCountClustersInChain(ULONG StartCluster);
+ULONG* FatGetClusterChainArray(ULONG StartCluster);
+BOOL FatReadCluster(ULONG ClusterNumber, PVOID Buffer);
+BOOL FatReadClusterChain(ULONG StartClusterNumber, ULONG NumberOfClusters, PVOID Buffer);
+BOOL FatReadPartialCluster(ULONG ClusterNumber, ULONG StartingOffset, ULONG Length, PVOID Buffer);
+BOOL FatReadFile(FILE *FileHandle, ULONG BytesToRead, ULONG* BytesRead, PVOID Buffer);
+ULONG FatGetFileSize(FILE *FileHandle);
+VOID FatSetFilePointer(FILE *FileHandle, ULONG NewFilePointer);
+ULONG FatGetFilePointer(FILE *FileHandle);
+BOOL FatReadVolumeSectors(ULONG DriveNumber, ULONG SectorNumber, ULONG SectorCount, PVOID Buffer);
#define ATTR_NORMAL 0x00
diff --git a/reactos/boot/freeldr/freeldr/fs/fs.c b/reactos/boot/freeldr/freeldr/fs/fs.c
index 22aa1e6b2b2..c91813f95d6 100644
--- a/reactos/boot/freeldr/freeldr/fs/fs.c
+++ b/reactos/boot/freeldr/freeldr/fs/fs.c
@@ -36,7 +36,7 @@
// DATA
/////////////////////////////////////////////////////////////////////////////////////////////
-U32 FileSystemType = 0; // Type of filesystem on boot device, set by FsOpenVolume()
+ULONG FsType = 0; // Type of filesystem on boot device, set by FsOpenVolume()
/////////////////////////////////////////////////////////////////////////////////////////////
// FUNCTIONS
@@ -51,7 +51,7 @@ VOID FileSystemError(PUCHAR ErrorString)
/*
*
- * BOOL FsOpenVolume(U32 DriveNumber, U32 PartitionNumber);
+ * BOOL FsOpenVolume(ULONG DriveNumber, ULONG PartitionNumber);
*
* This function is called to open a disk volume for file access.
* It must be called before any of the file functions will work.
@@ -64,11 +64,11 @@ VOID FileSystemError(PUCHAR ErrorString)
* If it is zero then it opens the active (bootable) partition
*
*/
-BOOL FsOpenVolume(U32 DriveNumber, U32 PartitionNumber)
+BOOL FsOpenVolume(ULONG DriveNumber, ULONG PartitionNumber)
{
PARTITION_TABLE_ENTRY PartitionTableEntry;
UCHAR ErrorText[80];
- U8 VolumeType;
+ UCHAR VolumeType;
DbgPrint((DPRINT_FILESYSTEM, "FsOpenVolume() DriveNumber: 0x%x PartitionNumber: 0x%x\n", DriveNumber, PartitionNumber));
@@ -78,7 +78,7 @@ BOOL FsOpenVolume(U32 DriveNumber, U32 PartitionNumber)
{
DbgPrint((DPRINT_FILESYSTEM, "Drive is a floppy diskette drive. Assuming FAT12 file system.\n"));
- FileSystemType = FS_FAT;
+ FsType = FS_FAT;
return FatOpenVolume(DriveNumber, 0, 0);
}
@@ -87,7 +87,7 @@ BOOL FsOpenVolume(U32 DriveNumber, U32 PartitionNumber)
{
DbgPrint((DPRINT_FILESYSTEM, "Drive is a cdrom drive. Assuming ISO-9660 file system.\n"));
- FileSystemType = FS_ISO9660;
+ FsType = FS_ISO9660;
return IsoOpenVolume(DriveNumber);
}
@@ -137,16 +137,16 @@ BOOL FsOpenVolume(U32 DriveNumber, U32 PartitionNumber)
case PARTITION_XINT13:
case PARTITION_FAT32:
case PARTITION_FAT32_XINT13:
- FileSystemType = FS_FAT;
+ FsType = FS_FAT;
return FatOpenVolume(DriveNumber, PartitionTableEntry.SectorCountBeforePartition, PartitionTableEntry.PartitionSectorCount);
case PARTITION_EXT2:
- FileSystemType = FS_EXT2;
+ FsType = FS_EXT2;
return Ext2OpenVolume(DriveNumber, PartitionTableEntry.SectorCountBeforePartition);
case PARTITION_NTFS:
- FileSystemType = FS_NTFS;
+ FsType = FS_NTFS;
return NtfsOpenVolume(DriveNumber, PartitionTableEntry.SectorCountBeforePartition);
default:
- FileSystemType = 0;
+ FsType = 0;
sprintf(ErrorText, "Unsupported file system. Type: 0x%x", VolumeType);
FileSystemError(ErrorText);
return FALSE;
@@ -175,7 +175,7 @@ PFILE FsOpenFile(PUCHAR FileName)
//
// Check file system type and pass off to appropriate handler
//
- switch (FileSystemType)
+ switch (FsType)
{
case FS_FAT:
FileHandle = FatOpenFile(FileName);
@@ -219,9 +219,9 @@ VOID FsCloseFile(PFILE FileHandle)
* ReadFile()
* returns number of bytes read or EOF
*/
-BOOL FsReadFile(PFILE FileHandle, U32 BytesToRead, U32* BytesRead, PVOID Buffer)
+BOOL FsReadFile(PFILE FileHandle, ULONG BytesToRead, ULONG* BytesRead, PVOID Buffer)
{
- U64 BytesReadBig;
+ ULONGLONG BytesReadBig;
BOOL Success;
//
@@ -232,7 +232,7 @@ BOOL FsReadFile(PFILE FileHandle, U32 BytesToRead, U32* BytesRead, PVOID Buffer)
*BytesRead = 0;
}
- switch (FileSystemType)
+ switch (FsType)
{
case FS_FAT:
@@ -246,7 +246,7 @@ BOOL FsReadFile(PFILE FileHandle, U32 BytesToRead, U32* BytesRead, PVOID Buffer)
//return Ext2ReadFile(FileHandle, BytesToRead, BytesRead, Buffer);
Success = Ext2ReadFile(FileHandle, BytesToRead, &BytesReadBig, Buffer);
- *BytesRead = (U32)BytesReadBig;
+ *BytesRead = (ULONG)BytesReadBig;
return Success;
case FS_NTFS:
@@ -262,9 +262,9 @@ BOOL FsReadFile(PFILE FileHandle, U32 BytesToRead, U32* BytesRead, PVOID Buffer)
return FALSE;
}
-U32 FsGetFileSize(PFILE FileHandle)
+ULONG FsGetFileSize(PFILE FileHandle)
{
- switch (FileSystemType)
+ switch (FsType)
{
case FS_FAT:
@@ -290,9 +290,9 @@ U32 FsGetFileSize(PFILE FileHandle)
return 0;
}
-VOID FsSetFilePointer(PFILE FileHandle, U32 NewFilePointer)
+VOID FsSetFilePointer(PFILE FileHandle, ULONG NewFilePointer)
{
- switch (FileSystemType)
+ switch (FsType)
{
case FS_FAT:
@@ -320,9 +320,9 @@ VOID FsSetFilePointer(PFILE FileHandle, U32 NewFilePointer)
}
}
-U32 FsGetFilePointer(PFILE FileHandle)
+ULONG FsGetFilePointer(PFILE FileHandle)
{
- switch (FileSystemType)
+ switch (FsType)
{
case FS_FAT:
@@ -369,10 +369,10 @@ BOOL FsIsEndOfFile(PFILE FileHandle)
* This function parses a path in the form of dir1\dir2\file1.ext
* and returns the number of parts it has (i.e. 3 - dir1,dir2,file1.ext)
*/
-U32 FsGetNumPathParts(PUCHAR Path)
+ULONG FsGetNumPathParts(PUCHAR Path)
{
- U32 i;
- U32 num;
+ ULONG i;
+ ULONG num;
for (i=0,num=0; i<(int)strlen(Path); i++)
{
@@ -396,7 +396,7 @@ U32 FsGetNumPathParts(PUCHAR Path)
*/
VOID FsGetFirstNameFromPath(PUCHAR Buffer, PUCHAR Path)
{
- U32 i;
+ ULONG i;
// Copy all the characters up to the end of the
// string or until we hit a '\' character
diff --git a/reactos/boot/freeldr/freeldr/fs/fsrec.c b/reactos/boot/freeldr/freeldr/fs/fsrec.c
index b3c84062f9b..8c0a2e69e3c 100644
--- a/reactos/boot/freeldr/freeldr/fs/fsrec.c
+++ b/reactos/boot/freeldr/freeldr/fs/fsrec.c
@@ -39,10 +39,10 @@
/*
*
- * BOOL FsRecognizeVolume(U32 DriveNumber, U32 VolumeStartSector, U8* VolumeType);
+ * BOOL FsRecognizeVolume(ULONG DriveNumber, ULONG VolumeStartSector, UCHAR* VolumeType);
*
*/
-BOOL FsRecognizeVolume(U32 DriveNumber, U32 VolumeStartSector, U8* VolumeType)
+BOOL FsRecognizeVolume(ULONG DriveNumber, ULONG VolumeStartSector, UCHAR* VolumeType)
{
DbgPrint((DPRINT_FILESYSTEM, "FsRecognizeVolume() DriveNumber: 0x%x VolumeStartSector: %d\n", DriveNumber, VolumeStartSector));
@@ -66,7 +66,7 @@ BOOL FsRecognizeVolume(U32 DriveNumber, U32 VolumeStartSector, U8* VolumeType)
return FALSE;
}
-BOOL FsRecIsIso9660(U32 DriveNumber)
+BOOL FsRecIsIso9660(ULONG DriveNumber)
{
PUCHAR Sector = (PUCHAR)DISKREADBUFFER;
@@ -84,7 +84,7 @@ BOOL FsRecIsIso9660(U32 DriveNumber)
Sector[5] == '1');
}
-BOOL FsRecIsExt2(U32 DriveNumber, U32 VolumeStartSector)
+BOOL FsRecIsExt2(ULONG DriveNumber, ULONG VolumeStartSector)
{
PEXT2_SUPER_BLOCK SuperBlock = (PEXT2_SUPER_BLOCK)DISKREADBUFFER;
@@ -102,7 +102,7 @@ BOOL FsRecIsExt2(U32 DriveNumber, U32 VolumeStartSector)
return FALSE;
}
-BOOL FsRecIsFat(U32 DriveNumber, U32 VolumeStartSector)
+BOOL FsRecIsFat(ULONG DriveNumber, ULONG VolumeStartSector)
{
PFAT_BOOTSECTOR BootSector = (PFAT_BOOTSECTOR)DISKREADBUFFER;
PFAT32_BOOTSECTOR BootSector32 = (PFAT32_BOOTSECTOR)DISKREADBUFFER;
@@ -124,7 +124,7 @@ BOOL FsRecIsFat(U32 DriveNumber, U32 VolumeStartSector)
return FALSE;
}
-BOOL FsRecIsNtfs(U32 DriveNumber, U32 VolumeStartSector)
+BOOL FsRecIsNtfs(ULONG DriveNumber, ULONG VolumeStartSector)
{
PNTFS_BOOTSECTOR BootSector = (PNTFS_BOOTSECTOR)DISKREADBUFFER;
if (!MachDiskReadLogicalSectors(DriveNumber, VolumeStartSector, 1, BootSector))
diff --git a/reactos/boot/freeldr/freeldr/fs/fsrec.h b/reactos/boot/freeldr/freeldr/fs/fsrec.h
index 210a4acebcf..2f8dd0bb5a5 100644
--- a/reactos/boot/freeldr/freeldr/fs/fsrec.h
+++ b/reactos/boot/freeldr/freeldr/fs/fsrec.h
@@ -20,10 +20,10 @@
#ifndef __FSREC_H
#define __FSREC_H
-BOOL FsRecognizeVolume(U32 DriveNumber, U32 VolumeStartSector, U8* VolumeType);
-BOOL FsRecIsIso9660(U32 DriveNumber);
-BOOL FsRecIsExt2(U32 DriveNumber, U32 VolumeStartSector);
-BOOL FsRecIsFat(U32 DriveNumber, U32 VolumeStartSector);
-BOOL FsRecIsNtfs(U32 DriveNumber, U32 VolumeStartSector);
+BOOL FsRecognizeVolume(ULONG DriveNumber, ULONG VolumeStartSector, UCHAR* VolumeType);
+BOOL FsRecIsIso9660(ULONG DriveNumber);
+BOOL FsRecIsExt2(ULONG DriveNumber, ULONG VolumeStartSector);
+BOOL FsRecIsFat(ULONG DriveNumber, ULONG VolumeStartSector);
+BOOL FsRecIsNtfs(ULONG DriveNumber, ULONG VolumeStartSector);
#endif // #defined __FSREC_H
diff --git a/reactos/boot/freeldr/freeldr/fs/iso.c b/reactos/boot/freeldr/freeldr/fs/iso.c
index 54e7aa38c88..58e881bff74 100644
--- a/reactos/boot/freeldr/freeldr/fs/iso.c
+++ b/reactos/boot/freeldr/freeldr/fs/iso.c
@@ -32,13 +32,13 @@
#define SECTORSIZE 2048
-static U32 IsoRootSector; // Starting sector of the root directory
-static U32 IsoRootLength; // Length of the root directory
+static ULONG IsoRootSector; // Starting sector of the root directory
+static ULONG IsoRootLength; // Length of the root directory
-U32 IsoDriveNumber = 0;
+ULONG IsoDriveNumber = 0;
-BOOL IsoOpenVolume(U32 DriveNumber)
+BOOL IsoOpenVolume(ULONG DriveNumber)
{
PPVD Pvd = (PPVD)DISKREADBUFFER;
@@ -65,11 +65,11 @@ BOOL IsoOpenVolume(U32 DriveNumber)
}
-static BOOL IsoSearchDirectoryBufferForFile(PVOID DirectoryBuffer, U32 DirectoryLength, PUCHAR FileName, PISO_FILE_INFO IsoFileInfoPointer)
+static BOOL IsoSearchDirectoryBufferForFile(PVOID DirectoryBuffer, ULONG DirectoryLength, PUCHAR FileName, PISO_FILE_INFO IsoFileInfoPointer)
{
PDIR_RECORD Record;
- U32 Offset;
- U32 i;
+ ULONG Offset;
+ ULONG i;
UCHAR Name[32];
DbgPrint((DPRINT_FILESYSTEM, "IsoSearchDirectoryBufferForFile() DirectoryBuffer = 0x%x DirectoryLength = %d FileName = %s\n", DirectoryBuffer, DirectoryLength, FileName));
@@ -133,12 +133,12 @@ static BOOL IsoSearchDirectoryBufferForFile(PVOID DirectoryBuffer, U32 Directory
* if allocation or read fails. The directory is specified by its
* starting sector and length.
*/
-static PVOID IsoBufferDirectory(U32 DirectoryStartSector, U32 DirectoryLength)
+static PVOID IsoBufferDirectory(ULONG DirectoryStartSector, ULONG DirectoryLength)
{
PVOID DirectoryBuffer;
PVOID Ptr;
- U32 SectorCount;
- U32 i;
+ ULONG SectorCount;
+ ULONG i;
DbgPrint((DPRINT_FILESYSTEM, "IsoBufferDirectory() DirectoryStartSector = %d DirectoryLength = %d\n", DirectoryStartSector, DirectoryLength));
@@ -183,11 +183,11 @@ static PVOID IsoBufferDirectory(U32 DirectoryStartSector, U32 DirectoryLength)
static BOOL IsoLookupFile(PUCHAR FileName, PISO_FILE_INFO IsoFileInfoPointer)
{
int i;
- U32 NumberOfPathParts;
+ ULONG NumberOfPathParts;
UCHAR PathPart[261];
PVOID DirectoryBuffer;
- U32 DirectorySector;
- U32 DirectoryLength;
+ ULONG DirectorySector;
+ ULONG DirectoryLength;
ISO_FILE_INFO IsoFileInfo;
DbgPrint((DPRINT_FILESYSTEM, "IsoLookupFile() FileName = %s\n", FileName));
@@ -293,14 +293,14 @@ FILE* IsoOpenFile(PUCHAR FileName)
* Reads BytesToRead from open file and
* returns the number of bytes read in BytesRead
*/
-BOOL IsoReadFile(FILE *FileHandle, U32 BytesToRead, U32* BytesRead, PVOID Buffer)
+BOOL IsoReadFile(FILE *FileHandle, ULONG BytesToRead, ULONG* BytesRead, PVOID Buffer)
{
PISO_FILE_INFO IsoFileInfo = (PISO_FILE_INFO)FileHandle;
- U32 SectorNumber;
- U32 OffsetInSector;
- U32 LengthInSector;
- U32 NumberOfSectors;
- U32 i;
+ ULONG SectorNumber;
+ ULONG OffsetInSector;
+ ULONG LengthInSector;
+ ULONG NumberOfSectors;
+ ULONG i;
DbgPrint((DPRINT_FILESYSTEM, "IsoReadFile() BytesToRead = %d Buffer = 0x%x\n", BytesToRead, Buffer));
@@ -451,7 +451,7 @@ BOOL IsoReadFile(FILE *FileHandle, U32 BytesToRead, U32* BytesRead, PVOID Buffer
}
-U32 IsoGetFileSize(FILE *FileHandle)
+ULONG IsoGetFileSize(FILE *FileHandle)
{
PISO_FILE_INFO IsoFileHandle = (PISO_FILE_INFO)FileHandle;
@@ -460,7 +460,7 @@ U32 IsoGetFileSize(FILE *FileHandle)
return IsoFileHandle->FileSize;
}
-VOID IsoSetFilePointer(FILE *FileHandle, U32 NewFilePointer)
+VOID IsoSetFilePointer(FILE *FileHandle, ULONG NewFilePointer)
{
PISO_FILE_INFO IsoFileHandle = (PISO_FILE_INFO)FileHandle;
@@ -469,7 +469,7 @@ VOID IsoSetFilePointer(FILE *FileHandle, U32 NewFilePointer)
IsoFileHandle->FilePointer = NewFilePointer;
}
-U32 IsoGetFilePointer(FILE *FileHandle)
+ULONG IsoGetFilePointer(FILE *FileHandle)
{
PISO_FILE_INFO IsoFileHandle = (PISO_FILE_INFO)FileHandle;
diff --git a/reactos/boot/freeldr/freeldr/fs/iso.h b/reactos/boot/freeldr/freeldr/fs/iso.h
index feaa1b57896..db549a40b37 100644
--- a/reactos/boot/freeldr/freeldr/fs/iso.h
+++ b/reactos/boot/freeldr/freeldr/fs/iso.h
@@ -25,10 +25,10 @@ struct _DIR_RECORD
{
UCHAR RecordLength; // 1
UCHAR ExtAttrRecordLength; // 2
- U32 ExtentLocationL; // 3-6
- U32 ExtentLocationM; // 7-10
- U32 DataLengthL; // 11-14
- U32 DataLengthM; // 15-18
+ ULONG ExtentLocationL; // 3-6
+ ULONG ExtentLocationM; // 7-10
+ ULONG DataLengthL; // 11-14
+ ULONG DataLengthM; // 15-18
UCHAR Year; // 19
UCHAR Month; // 20
UCHAR Day; // 21
@@ -39,7 +39,7 @@ struct _DIR_RECORD
UCHAR FileFlags; // 26
UCHAR FileUnitSize; // 27
UCHAR InterleaveGapSize; // 28
- U32 VolumeSequenceNumber; // 29-32
+ ULONG VolumeSequenceNumber; // 29-32
UCHAR FileIdLength; // 33
UCHAR FileId[1]; // 34
} __attribute__((packed));
@@ -71,18 +71,18 @@ struct _PVD
UCHAR SystemId[32]; // 9-40
UCHAR VolumeId[32]; // 41-72
UCHAR unused1[8]; // 73-80
- U32 VolumeSpaceSizeL; // 81-84
- U32 VolumeSpaceSizeM; // 85-88
+ ULONG VolumeSpaceSizeL; // 81-84
+ ULONG VolumeSpaceSizeM; // 85-88
UCHAR unused2[32]; // 89-120
- U32 VolumeSetSize; // 121-124
- U32 VolumeSequenceNumber; // 125-128
- U32 LogicalBlockSize; // 129-132
- U32 PathTableSizeL; // 133-136
- U32 PathTableSizeM; // 137-140
- U32 LPathTablePos; // 141-144
- U32 LOptPathTablePos; // 145-148
- U32 MPathTablePos; // 149-152
- U32 MOptPathTablePos; // 153-156
+ ULONG VolumeSetSize; // 121-124
+ ULONG VolumeSequenceNumber; // 125-128
+ ULONG LogicalBlockSize; // 129-132
+ ULONG PathTableSizeL; // 133-136
+ ULONG PathTableSizeM; // 137-140
+ ULONG LPathTablePos; // 141-144
+ ULONG LOptPathTablePos; // 145-148
+ ULONG MPathTablePos; // 149-152
+ ULONG MOptPathTablePos; // 153-156
DIR_RECORD RootDirRecord; // 157-190
UCHAR VolumeSetIdentifier[128]; // 191-318
UCHAR PublisherIdentifier[128]; // 319-446
@@ -97,19 +97,19 @@ typedef struct _PVD PVD, *PPVD;
typedef struct
{
- U32 FileStart; // File start sector
- U32 FileSize; // File size
- U32 FilePointer; // File pointer
+ ULONG FileStart; // File start sector
+ ULONG FileSize; // File size
+ ULONG FilePointer; // File pointer
BOOL Directory;
- U32 DriveNumber;
+ ULONG DriveNumber;
} ISO_FILE_INFO, * PISO_FILE_INFO;
-BOOL IsoOpenVolume(U32 DriveNumber);
+BOOL IsoOpenVolume(ULONG DriveNumber);
FILE* IsoOpenFile(PUCHAR FileName);
-BOOL IsoReadFile(FILE *FileHandle, U32 BytesToRead, U32* BytesRead, PVOID Buffer);
-U32 IsoGetFileSize(FILE *FileHandle);
-VOID IsoSetFilePointer(FILE *FileHandle, U32 NewFilePointer);
-U32 IsoGetFilePointer(FILE *FileHandle);
+BOOL IsoReadFile(FILE *FileHandle, ULONG BytesToRead, ULONG* BytesRead, PVOID Buffer);
+ULONG IsoGetFileSize(FILE *FileHandle);
+VOID IsoSetFilePointer(FILE *FileHandle, ULONG NewFilePointer);
+ULONG IsoGetFilePointer(FILE *FileHandle);
#endif // #defined __FAT_H
diff --git a/reactos/boot/freeldr/freeldr/fs/ntfs.c b/reactos/boot/freeldr/freeldr/fs/ntfs.c
index 6f6aebf86c9..625020a549f 100644
--- a/reactos/boot/freeldr/freeldr/fs/ntfs.c
+++ b/reactos/boot/freeldr/freeldr/fs/ntfs.c
@@ -37,19 +37,19 @@
#include "ntfs.h"
PNTFS_BOOTSECTOR NtfsBootSector;
-U32 NtfsClusterSize;
-U32 NtfsMftRecordSize;
-U32 NtfsIndexRecordSize;
-U32 NtfsDriveNumber;
-U32 NtfsSectorOfClusterZero;
+ULONG NtfsClusterSize;
+ULONG NtfsMftRecordSize;
+ULONG NtfsIndexRecordSize;
+ULONG NtfsDriveNumber;
+ULONG NtfsSectorOfClusterZero;
PNTFS_MFT_RECORD NtfsMasterFileTable;
NTFS_ATTR_CONTEXT NtfsMFTContext;
-PUCHAR NtfsDecodeRun(PUCHAR DataRun, S64 *DataRunOffset, U64 *DataRunLength)
+PUCHAR NtfsDecodeRun(PUCHAR DataRun, LONGLONG *DataRunOffset, ULONGLONG *DataRunLength)
{
- U8 DataRunOffsetSize;
- U8 DataRunLengthSize;
- S8 i;
+ UCHAR DataRunOffsetSize;
+ UCHAR DataRunLengthSize;
+ CHAR i;
DataRunOffsetSize = (*DataRun >> 4) & 0xF;
DataRunLengthSize = *DataRun & 0xF;
@@ -75,7 +75,7 @@ PUCHAR NtfsDecodeRun(PUCHAR DataRun, S64 *DataRunOffset, U64 *DataRunLength)
DataRun++;
}
/* The last byte contains sign so we must process it different way. */
- *DataRunOffset = ((S8)(*(DataRun++)) << (i << 3)) + *DataRunOffset;
+ *DataRunOffset = ((CHAR)(*(DataRun++)) << (i << 3)) + *DataRunOffset;
}
DbgPrint((DPRINT_FILESYSTEM, "DataRunOffsetSize: %x\n", DataRunOffsetSize));
@@ -87,11 +87,11 @@ PUCHAR NtfsDecodeRun(PUCHAR DataRun, S64 *DataRunOffset, U64 *DataRunLength)
}
/* FIXME: Add support for attribute lists! */
-BOOL NtfsFindAttribute(PNTFS_ATTR_CONTEXT Context, PNTFS_MFT_RECORD MftRecord, U32 Type, PWCHAR Name)
+BOOL NtfsFindAttribute(PNTFS_ATTR_CONTEXT Context, PNTFS_MFT_RECORD MftRecord, ULONG Type, PWCHAR Name)
{
PNTFS_ATTR_RECORD AttrRecord;
PNTFS_ATTR_RECORD AttrRecordEnd;
- U32 NameLength;
+ ULONG NameLength;
PWCHAR AttrName;
AttrRecord = (PNTFS_ATTR_RECORD)((PCHAR)MftRecord + MftRecord->AttributesOffset);
@@ -115,8 +115,8 @@ BOOL NtfsFindAttribute(PNTFS_ATTR_CONTEXT Context, PNTFS_MFT_RECORD MftRecord, U
Context->Record = AttrRecord;
if (AttrRecord->IsNonResident)
{
- S64 DataRunOffset;
- U64 DataRunLength;
+ LONGLONG DataRunOffset;
+ ULONGLONG DataRunLength;
Context->CacheRun = (PUCHAR)Context->Record + Context->Record->NonResident.MappingPairsOffset;
Context->CacheRunOffset = 0;
@@ -148,9 +148,9 @@ BOOL NtfsFindAttribute(PNTFS_ATTR_CONTEXT Context, PNTFS_MFT_RECORD MftRecord, U
}
/* FIXME: Optimize for multisector reads. */
-BOOL NtfsDiskRead(U64 Offset, U64 Length, PCHAR Buffer)
+BOOL NtfsDiskRead(ULONGLONG Offset, ULONGLONG Length, PCHAR Buffer)
{
- U16 ReadLength;
+ USHORT ReadLength;
DbgPrint((DPRINT_FILESYSTEM, "NtfsDiskRead - Offset: %I64d Length: %I64d\n", Offset, Length));
RtlZeroMemory((PCHAR)DISKREADBUFFER, 0x1000);
@@ -190,16 +190,16 @@ BOOL NtfsDiskRead(U64 Offset, U64 Length, PCHAR Buffer)
return TRUE;
}
-U64 NtfsReadAttribute(PNTFS_ATTR_CONTEXT Context, U64 Offset, PCHAR Buffer, U64 Length)
+ULONGLONG NtfsReadAttribute(PNTFS_ATTR_CONTEXT Context, ULONGLONG Offset, PCHAR Buffer, ULONGLONG Length)
{
- U64 LastLCN;
+ ULONGLONG LastLCN;
PUCHAR DataRun;
- S64 DataRunOffset;
- U64 DataRunLength;
- S64 DataRunStartLCN;
- U64 CurrentOffset;
- U64 ReadLength;
- U64 AlreadyRead;
+ LONGLONG DataRunOffset;
+ ULONGLONG DataRunLength;
+ LONGLONG DataRunStartLCN;
+ ULONGLONG CurrentOffset;
+ ULONGLONG ReadLength;
+ ULONGLONG AlreadyRead;
if (!Context->Record->IsNonResident)
{
@@ -316,31 +316,31 @@ U64 NtfsReadAttribute(PNTFS_ATTR_CONTEXT Context, U64 Offset, PCHAR Buffer, U64
BOOL NtfsFixupRecord(PNTFS_RECORD Record)
{
- U16 *USA;
- U16 USANumber;
- U16 USACount;
- U16 *Block;
+ USHORT *USA;
+ USHORT USANumber;
+ USHORT USACount;
+ USHORT *Block;
- USA = (U16*)((PCHAR)Record + Record->USAOffset);
+ USA = (USHORT*)((PCHAR)Record + Record->USAOffset);
USANumber = *(USA++);
USACount = Record->USACount - 1; /* Exclude the USA Number. */
- Block = (U16*)((PCHAR)Record + NtfsBootSector->BytesPerSector - 2);
+ Block = (USHORT*)((PCHAR)Record + NtfsBootSector->BytesPerSector - 2);
while (USACount)
{
if (*Block != USANumber)
return FALSE;
*Block = *(USA++);
- Block = (U16*)((PCHAR)Block + NtfsBootSector->BytesPerSector);
+ Block = (USHORT*)((PCHAR)Block + NtfsBootSector->BytesPerSector);
USACount--;
}
return TRUE;
}
-BOOL NtfsReadMftRecord(U32 MFTIndex, PNTFS_MFT_RECORD Buffer)
+BOOL NtfsReadMftRecord(ULONG MFTIndex, PNTFS_MFT_RECORD Buffer)
{
- U64 BytesRead;
+ ULONGLONG BytesRead;
BytesRead = NtfsReadAttribute(&NtfsMFTContext, MFTIndex * NtfsMftRecordSize, (PCHAR)Buffer, NtfsMftRecordSize);
if (BytesRead != NtfsMftRecordSize)
@@ -354,9 +354,9 @@ BOOL NtfsReadMftRecord(U32 MFTIndex, PNTFS_MFT_RECORD Buffer)
VOID NtfsPrintFile(PNTFS_INDEX_ENTRY IndexEntry)
{
PWCHAR FileName;
- U8 FileNameLength;
+ UCHAR FileNameLength;
CHAR AnsiFileName[256];
- U8 i;
+ UCHAR i;
FileName = IndexEntry->FileName.FileName;
FileNameLength = IndexEntry->FileName.FileNameLength;
@@ -372,8 +372,8 @@ VOID NtfsPrintFile(PNTFS_INDEX_ENTRY IndexEntry)
BOOL NtfsCompareFileName(PCHAR FileName, PNTFS_INDEX_ENTRY IndexEntry)
{
PWCHAR EntryFileName;
- U8 EntryFileNameLength;
- U8 i;
+ UCHAR EntryFileNameLength;
+ UCHAR i;
EntryFileName = IndexEntry->FileName.FileName;
EntryFileNameLength = IndexEntry->FileName.FileNameLength;
@@ -402,21 +402,21 @@ BOOL NtfsCompareFileName(PCHAR FileName, PNTFS_INDEX_ENTRY IndexEntry)
return TRUE;
}
-BOOL NtfsFindMftRecord(U32 MFTIndex, PCHAR FileName, U32 *OutMFTIndex)
+BOOL NtfsFindMftRecord(ULONG MFTIndex, PCHAR FileName, ULONG *OutMFTIndex)
{
PNTFS_MFT_RECORD MftRecord;
- U32 Magic;
+ ULONG Magic;
NTFS_ATTR_CONTEXT IndexRootCtx;
NTFS_ATTR_CONTEXT IndexBitmapCtx;
NTFS_ATTR_CONTEXT IndexAllocationCtx;
PNTFS_INDEX_ROOT IndexRoot;
- U64 BitmapDataSize;
- U64 IndexAllocationSize;
+ ULONGLONG BitmapDataSize;
+ ULONGLONG IndexAllocationSize;
PCHAR BitmapData;
PCHAR IndexRecord;
PNTFS_INDEX_ENTRY IndexEntry, IndexEntryEnd;
- U32 RecordOffset;
- U32 IndexBlockSize;
+ ULONG RecordOffset;
+ ULONG IndexBlockSize;
MftRecord = MmAllocateMemory(NtfsMftRecordSize);
if (MftRecord == NULL)
@@ -508,8 +508,8 @@ BOOL NtfsFindMftRecord(U32 MFTIndex, PCHAR FileName, U32 *OutMFTIndex)
DbgPrint((DPRINT_FILESYSTEM, "RecordOffset: %x IndexAllocationSize: %x\n", RecordOffset, IndexAllocationSize));
for (; RecordOffset < IndexAllocationSize;)
{
- U8 Bit = 1 << ((RecordOffset / IndexBlockSize) & 7);
- U32 Byte = (RecordOffset / IndexBlockSize) >> 3;
+ UCHAR Bit = 1 << ((RecordOffset / IndexBlockSize) & 7);
+ ULONG Byte = (RecordOffset / IndexBlockSize) >> 3;
if ((BitmapData[Byte] & Bit))
break;
RecordOffset += IndexBlockSize;
@@ -528,7 +528,7 @@ BOOL NtfsFindMftRecord(U32 MFTIndex, PCHAR FileName, U32 *OutMFTIndex)
}
/* FIXME */
- IndexEntry = (PNTFS_INDEX_ENTRY)(IndexRecord + 0x18 + *(U16 *)(IndexRecord + 0x18));
+ IndexEntry = (PNTFS_INDEX_ENTRY)(IndexRecord + 0x18 + *(USHORT *)(IndexRecord + 0x18));
IndexEntryEnd = (PNTFS_INDEX_ENTRY)(IndexRecord + IndexBlockSize);
while (IndexEntry < IndexEntryEnd &&
@@ -565,10 +565,10 @@ BOOL NtfsFindMftRecord(U32 MFTIndex, PCHAR FileName, U32 *OutMFTIndex)
BOOL NtfsLookupFile(PUCHAR FileName, PNTFS_MFT_RECORD MftRecord, PNTFS_ATTR_CONTEXT DataContext)
{
- U32 NumberOfPathParts;
+ ULONG NumberOfPathParts;
UCHAR PathPart[261];
- U32 CurrentMFTIndex;
- U8 i;
+ ULONG CurrentMFTIndex;
+ UCHAR i;
DbgPrint((DPRINT_FILESYSTEM, "NtfsLookupFile() FileName = %s\n", FileName));
@@ -606,7 +606,7 @@ BOOL NtfsLookupFile(PUCHAR FileName, PNTFS_MFT_RECORD MftRecord, PNTFS_ATTR_CONT
return TRUE;
}
-BOOL NtfsOpenVolume(U32 DriveNumber, U32 VolumeStartSector)
+BOOL NtfsOpenVolume(ULONG DriveNumber, ULONG VolumeStartSector)
{
NtfsBootSector = (PNTFS_BOOTSECTOR)DISKREADBUFFER;
@@ -703,36 +703,36 @@ FILE* NtfsOpenFile(PUCHAR FileName)
return (FILE*)FileHandle;
}
-BOOL NtfsReadFile(FILE *File, U32 BytesToRead, U32* BytesRead, PVOID Buffer)
+BOOL NtfsReadFile(FILE *File, ULONG BytesToRead, ULONG* BytesRead, PVOID Buffer)
{
PNTFS_FILE_HANDLE FileHandle = (PNTFS_FILE_HANDLE)File;
- U64 BytesRead64;
+ ULONGLONG BytesRead64;
BytesRead64 = NtfsReadAttribute(&FileHandle->DataContext, FileHandle->Offset, Buffer, BytesToRead);
if (BytesRead64)
{
- *BytesRead = (U32)BytesRead64;
+ *BytesRead = (ULONG)BytesRead64;
FileHandle->Offset += BytesRead64;
return TRUE;
}
return FALSE;
}
-U32 NtfsGetFileSize(FILE *File)
+ULONG NtfsGetFileSize(FILE *File)
{
PNTFS_FILE_HANDLE FileHandle = (PNTFS_FILE_HANDLE)File;
if (FileHandle->DataContext.Record->IsNonResident)
- return (U32)FileHandle->DataContext.Record->NonResident.DataSize;
+ return (ULONG)FileHandle->DataContext.Record->NonResident.DataSize;
else
- return (U32)FileHandle->DataContext.Record->Resident.ValueLength;
+ return (ULONG)FileHandle->DataContext.Record->Resident.ValueLength;
}
-VOID NtfsSetFilePointer(FILE *File, U32 NewFilePointer)
+VOID NtfsSetFilePointer(FILE *File, ULONG NewFilePointer)
{
PNTFS_FILE_HANDLE FileHandle = (PNTFS_FILE_HANDLE)File;
FileHandle->Offset = NewFilePointer;
}
-U32 NtfsGetFilePointer(FILE *File)
+ULONG NtfsGetFilePointer(FILE *File)
{
PNTFS_FILE_HANDLE FileHandle = (PNTFS_FILE_HANDLE)File;
return FileHandle->Offset;
diff --git a/reactos/boot/freeldr/freeldr/fs/ntfs.h b/reactos/boot/freeldr/freeldr/fs/ntfs.h
index af51534d365..5c99fb9c638 100644
--- a/reactos/boot/freeldr/freeldr/fs/ntfs.h
+++ b/reactos/boot/freeldr/freeldr/fs/ntfs.h
@@ -61,122 +61,122 @@
typedef struct
{
- U8 JumpBoot[3]; // Jump to the boot loader routine
- U8 SystemId[8]; // System Id ("NTFS ")
- U16 BytesPerSector; // Bytes per sector
- U8 SectorsPerCluster; // Number of sectors in a cluster
- U8 Unused1[7];
- U8 MediaDescriptor; // Media descriptor byte
- U8 Unused2[2];
- U16 SectorsPerTrack; // Number of sectors in a track
- U16 NumberOfHeads; // Number of heads on the disk
- U8 Unused3[8];
- U8 DriveNumber; // Int 0x13 drive number (e.g. 0x80)
- U8 CurrentHead;
- U8 BootSignature; // Extended boot signature (0x80)
- U8 Unused4;
- U64 VolumeSectorCount; // Number of sectors in the volume
- U64 MftLocation;
- U64 MftMirrorLocation;
- S8 ClustersPerMftRecord; // Clusters per MFT Record
- U8 Unused5[3];
- S8 ClustersPerIndexRecord; // Clusters per Index Record
- U8 Unused6[3];
- U64 VolumeSerialNumber; // Volume serial number
- U8 BootCodeAndData[430]; // The remainder of the boot sector
- U16 BootSectorMagic; // 0xAA55
+ UCHAR JumpBoot[3]; // Jump to the boot loader routine
+ UCHAR SystemId[8]; // System Id ("NTFS ")
+ USHORT BytesPerSector; // Bytes per sector
+ UCHAR SectorsPerCluster; // Number of sectors in a cluster
+ UCHAR Unused1[7];
+ UCHAR MediaDescriptor; // Media descriptor byte
+ UCHAR Unused2[2];
+ USHORT SectorsPerTrack; // Number of sectors in a track
+ USHORT NumberOfHeads; // Number of heads on the disk
+ UCHAR Unused3[8];
+ UCHAR DriveNumber; // Int 0x13 drive number (e.g. 0x80)
+ UCHAR CurrentHead;
+ UCHAR BootSignature; // Extended boot signature (0x80)
+ UCHAR Unused4;
+ ULONGLONG VolumeSectorCount; // Number of sectors in the volume
+ ULONGLONG MftLocation;
+ ULONGLONG MftMirrorLocation;
+ CHAR ClustersPerMftRecord; // Clusters per MFT Record
+ UCHAR Unused5[3];
+ CHAR ClustersPerIndexRecord; // Clusters per Index Record
+ UCHAR Unused6[3];
+ ULONGLONG VolumeSerialNumber; // Volume serial number
+ UCHAR BootCodeAndData[430]; // The remainder of the boot sector
+ USHORT BootSectorMagic; // 0xAA55
} PACKED NTFS_BOOTSECTOR, *PNTFS_BOOTSECTOR;
typedef struct
{
- U32 Magic;
- U16 USAOffset; // Offset to the Update Sequence Array from the start of the ntfs record
- U16 USACount;
+ ULONG Magic;
+ USHORT USAOffset; // Offset to the Update Sequence Array from the start of the ntfs record
+ USHORT USACount;
} PACKED NTFS_RECORD, *PNTFS_RECORD;
typedef struct
{
- U32 Magic;
- U16 USAOffset; // Offset to the Update Sequence Array from the start of the ntfs record
- U16 USACount;
- U64 LogSequenceNumber;
- U16 SequenceNumber;
- U16 LinkCount;
- U16 AttributesOffset;
- U16 Flags;
- U32 BytesInUse; // Number of bytes used in this mft record.
- U32 BytesAllocated;
- U64 BaseMFTRecord;
- U16 NextAttributeInstance;
+ ULONG Magic;
+ USHORT USAOffset; // Offset to the Update Sequence Array from the start of the ntfs record
+ USHORT USACount;
+ ULONGLONG LogSequenceNumber;
+ USHORT SequenceNumber;
+ USHORT LinkCount;
+ USHORT AttributesOffset;
+ USHORT Flags;
+ ULONG BytesInUse; // Number of bytes used in this mft record.
+ ULONG BytesAllocated;
+ ULONGLONG BaseMFTRecord;
+ USHORT NextAttributeInstance;
} PACKED NTFS_MFT_RECORD, *PNTFS_MFT_RECORD;
typedef struct
{
- U32 Type;
- U32 Length;
- U8 IsNonResident;
- U8 NameLength;
- U16 NameOffset;
- U16 Flags;
- U16 Instance;
+ ULONG Type;
+ ULONG Length;
+ UCHAR IsNonResident;
+ UCHAR NameLength;
+ USHORT NameOffset;
+ USHORT Flags;
+ USHORT Instance;
union
{
// Resident attributes
struct
{
- U32 ValueLength;
- U16 ValueOffset;
- U16 Flags;
+ ULONG ValueLength;
+ USHORT ValueOffset;
+ USHORT Flags;
} PACKED Resident;
// Non-resident attributes
struct
{
- U64 LowestVCN;
- U64 HighestVCN;
- U16 MappingPairsOffset;
- U8 CompressionUnit;
- U8 Reserved[5];
- S64 AllocatedSize;
- S64 DataSize;
- S64 InitializedSize;
- S64 CompressedSize;
+ ULONGLONG LowestVCN;
+ ULONGLONG HighestVCN;
+ USHORT MappingPairsOffset;
+ UCHAR CompressionUnit;
+ UCHAR Reserved[5];
+ LONGLONG AllocatedSize;
+ LONGLONG DataSize;
+ LONGLONG InitializedSize;
+ LONGLONG CompressedSize;
} PACKED NonResident;
} PACKED;
} PACKED NTFS_ATTR_RECORD, *PNTFS_ATTR_RECORD;
typedef struct
{
- U32 EntriesOffset;
- U32 IndexLength;
- U32 AllocatedSize;
- U8 Flags;
- U8 Reserved[3];
+ ULONG EntriesOffset;
+ ULONG IndexLength;
+ ULONG AllocatedSize;
+ UCHAR Flags;
+ UCHAR Reserved[3];
} PACKED NTFS_INDEX_HEADER, *PNTFS_INDEX_HEADER;
typedef struct
{
- U32 Type;
- U32 CollationRule;
- U32 IndexBlockSize;
- U8 ClustersPerIndexBlock;
- U8 Reserved[3];
+ ULONG Type;
+ ULONG CollationRule;
+ ULONG IndexBlockSize;
+ UCHAR ClustersPerIndexBlock;
+ UCHAR Reserved[3];
NTFS_INDEX_HEADER IndexHeader;
} PACKED NTFS_INDEX_ROOT, *PNTFS_INDEX_ROOT;
typedef struct
{
- U64 ParentDirectory;
- S64 CreationTime;
- S64 LastDataChangeTime;
- S64 LastMftChangeTime;
- S64 LastAccessTime;
- S64 AllocatedSize;
- S64 DataSize;
- U32 FileAttributes;
- U16 PackedExtendedAttributeSize;
- U16 Reserved;
- U8 FileNameLength;
- U8 FileNameType;
+ ULONGLONG ParentDirectory;
+ LONGLONG CreationTime;
+ LONGLONG LastDataChangeTime;
+ LONGLONG LastMftChangeTime;
+ LONGLONG LastAccessTime;
+ LONGLONG AllocatedSize;
+ LONGLONG DataSize;
+ ULONG FileAttributes;
+ USHORT PackedExtendedAttributeSize;
+ USHORT Reserved;
+ UCHAR FileNameLength;
+ UCHAR FileNameType;
WCHAR FileName[0];
} PACKED NTFS_FILE_NAME_ATTR, *PNTFS_FILE_NAME_ATTR;
@@ -185,19 +185,19 @@ typedef struct {
{
struct
{
- U64 IndexedFile;
+ ULONGLONG IndexedFile;
} PACKED Directory;
struct
{
- U16 DataOffset;
- U16 DataLength;
- U32 Reserved;
+ USHORT DataOffset;
+ USHORT DataLength;
+ ULONG Reserved;
} PACKED ViewIndex;
} PACKED Data;
- U16 Length;
- U16 KeyLength;
- U16 Flags;
- U16 Reserved;
+ USHORT Length;
+ USHORT KeyLength;
+ USHORT Flags;
+ USHORT Reserved;
NTFS_FILE_NAME_ATTR FileName;
} PACKED NTFS_INDEX_ENTRY, *PNTFS_INDEX_ENTRY;
@@ -205,24 +205,24 @@ typedef struct
{
PNTFS_ATTR_RECORD Record;
PUCHAR CacheRun;
- U64 CacheRunOffset;
- S64 CacheRunStartLCN;
- U64 CacheRunLength;
- S64 CacheRunLastLCN;
- U64 CacheRunCurrentOffset;
+ ULONGLONG CacheRunOffset;
+ LONGLONG CacheRunStartLCN;
+ ULONGLONG CacheRunLength;
+ LONGLONG CacheRunLastLCN;
+ ULONGLONG CacheRunCurrentOffset;
} NTFS_ATTR_CONTEXT, *PNTFS_ATTR_CONTEXT;
typedef struct
{
NTFS_ATTR_CONTEXT DataContext;
- U64 Offset;
+ ULONGLONG Offset;
} PACKED NTFS_FILE_HANDLE, *PNTFS_FILE_HANDLE;
-BOOL NtfsOpenVolume(U32 DriveNumber, U32 VolumeStartSector);
+BOOL NtfsOpenVolume(ULONG DriveNumber, ULONG VolumeStartSector);
FILE* NtfsOpenFile(PUCHAR FileName);
-BOOL NtfsReadFile(FILE *FileHandle, U32 BytesToRead, U32* BytesRead, PVOID Buffer);
-U32 NtfsGetFileSize(FILE *FileHandle);
-VOID NtfsSetFilePointer(FILE *FileHandle, U32 NewFilePointer);
-U32 NtfsGetFilePointer(FILE *FileHandle);
+BOOL NtfsReadFile(FILE *FileHandle, ULONG BytesToRead, ULONG* BytesRead, PVOID Buffer);
+ULONG NtfsGetFileSize(FILE *FileHandle);
+VOID NtfsSetFilePointer(FILE *FileHandle, ULONG NewFilePointer);
+ULONG NtfsGetFilePointer(FILE *FileHandle);
#endif // #defined __NTFS_H
diff --git a/reactos/boot/freeldr/freeldr/include/bootmgr.h b/reactos/boot/freeldr/freeldr/include/bootmgr.h
index 330010d2523..9d61a176eeb 100644
--- a/reactos/boot/freeldr/freeldr/include/bootmgr.h
+++ b/reactos/boot/freeldr/freeldr/include/bootmgr.h
@@ -21,9 +21,9 @@
#define __BOOTMGR_H
-U32 GetDefaultOperatingSystem(PUCHAR OperatingSystemList[], U32 OperatingSystemCount);
-S32 GetTimeOut(VOID);
-BOOL MainBootMenuKeyPressFilter(U32 KeyPress);
+ULONG GetDefaultOperatingSystem(PUCHAR OperatingSystemList[], ULONG OperatingSystemCount);
+LONG GetTimeOut(VOID);
+BOOL MainBootMenuKeyPressFilter(ULONG KeyPress);
#endif // #defined __BOOTMGR_H
diff --git a/reactos/boot/freeldr/freeldr/include/cache.h b/reactos/boot/freeldr/freeldr/include/cache.h
index c9b07c759f9..f1f7529f2e7 100644
--- a/reactos/boot/freeldr/freeldr/include/cache.h
+++ b/reactos/boot/freeldr/freeldr/include/cache.h
@@ -21,10 +21,10 @@
#ifndef __CACHE_H
#define __CACHE_H
-BOOL CacheInitializeDrive(U32 DriveNumber);
+BOOL CacheInitializeDrive(ULONG DriveNumber);
VOID CacheInvalidateCacheData(VOID);
-BOOL CacheReadDiskSectors(U32 DiskNumber, U32 StartSector, U32 SectorCount, PVOID Buffer);
-BOOL CacheForceDiskSectorsIntoCache(U32 DiskNumber, U32 StartSector, U32 SectorCount);
-BOOL CacheReleaseMemory(U32 MinimumAmountToRelease);
+BOOL CacheReadDiskSectors(ULONG DiskNumber, ULONG StartSector, ULONG SectorCount, PVOID Buffer);
+BOOL CacheForceDiskSectorsIntoCache(ULONG DiskNumber, ULONG StartSector, ULONG SectorCount);
+BOOL CacheReleaseMemory(ULONG MinimumAmountToRelease);
#endif // defined __CACHE_H
diff --git a/reactos/boot/freeldr/freeldr/include/cmdline.h b/reactos/boot/freeldr/freeldr/include/cmdline.h
index ddb11fccae4..5bfc3ff84bf 100644
--- a/reactos/boot/freeldr/freeldr/include/cmdline.h
+++ b/reactos/boot/freeldr/freeldr/include/cmdline.h
@@ -24,13 +24,13 @@
typedef struct tagCMDLINEINFO
{
char *DefaultOperatingSystem;
- S32 TimeOut;
+ LONG TimeOut;
} CMDLINEINFO, *PCMDLINEINFO;
extern void CmdLineParse(char *CmdLine);
extern char *CmdLineGetDefaultOS(void);
-extern S32 CmdLineGetTimeOut(void);
+extern LONG CmdLineGetTimeOut(void);
#endif /* __CMDLINE_H__ */
diff --git a/reactos/boot/freeldr/freeldr/include/comm.h b/reactos/boot/freeldr/freeldr/include/comm.h
index 84fa9a6b98a..bef0d583ab8 100644
--- a/reactos/boot/freeldr/freeldr/include/comm.h
+++ b/reactos/boot/freeldr/freeldr/include/comm.h
@@ -22,7 +22,7 @@
#ifndef __RS232_H
#define __RS232_H
-BOOL Rs232PortInitialize(U32 ComPort, U32 BaudRate);
+BOOL Rs232PortInitialize(ULONG ComPort, ULONG BaudRate);
BOOL Rs232PortGetByte(PUCHAR ByteRecieved);
BOOL Rs232PortPollByte(PUCHAR ByteRecieved);
VOID Rs232PortPutByte(UCHAR ByteToSend);
diff --git a/reactos/boot/freeldr/freeldr/include/debug.h b/reactos/boot/freeldr/freeldr/include/debug.h
index 9098dbd7857..d489199d964 100644
--- a/reactos/boot/freeldr/freeldr/include/debug.h
+++ b/reactos/boot/freeldr/freeldr/include/debug.h
@@ -37,9 +37,9 @@
#define DPRINT_HWDETECT 0x00000400 // OR this with DebugPrintMask to enable hardware detection messages
VOID DebugInit(VOID);
- VOID DebugPrint(U32 Mask, char *format, ...);
+ VOID DebugPrint(ULONG Mask, char *format, ...);
VOID DebugPrint1(char *format, ...);
- VOID DebugDumpBuffer(U32 Mask, PVOID Buffer, U32 Length);
+ VOID DebugDumpBuffer(ULONG Mask, PVOID Buffer, ULONG Length);
#define DbgPrint(_x_) DebugPrint _x_ ;
#define DPRINT1 DebugPrint1
diff --git a/reactos/boot/freeldr/freeldr/include/disk.h b/reactos/boot/freeldr/freeldr/include/disk.h
index bc4451b29c0..dc5abcb4f73 100644
--- a/reactos/boot/freeldr/freeldr/include/disk.h
+++ b/reactos/boot/freeldr/freeldr/include/disk.h
@@ -23,10 +23,10 @@
typedef struct _GEOMETRY
{
- U32 Cylinders; // Number of cylinders on the disk
- U32 Heads; // Number of heads on the disk
- U32 Sectors; // Number of sectors per track
- U32 BytesPerSector; // Number of bytes per sector
+ ULONG Cylinders; // Number of cylinders on the disk
+ ULONG Heads; // Number of heads on the disk
+ ULONG Sectors; // Number of sectors per track
+ ULONG BytesPerSector; // Number of bytes per sector
} GEOMETRY, *PGEOMETRY;
@@ -35,14 +35,14 @@ typedef struct _GEOMETRY
//
typedef struct _EXTENDED_GEOMETRY
{
- U16 Size;
- U16 Flags;
- U32 Cylinders;
- U32 Heads;
- U32 SectorsPerTrack;
- U64 Sectors;
- U16 BytesPerSector;
- U32 PDPTE;
+ USHORT Size;
+ USHORT Flags;
+ ULONG Cylinders;
+ ULONG Heads;
+ ULONG SectorsPerTrack;
+ ULONGLONG Sectors;
+ USHORT BytesPerSector;
+ ULONG PDPTE;
} __attribute__((packed)) EXTENDED_GEOMETRY, *PEXTENDED_GEOMETRY;
//
@@ -50,16 +50,16 @@ typedef struct _EXTENDED_GEOMETRY
//
typedef struct _PARTITION_TABLE_ENTRY
{
- U8 BootIndicator; // 0x00 - non-bootable partition, 0x80 - bootable partition (one partition only)
- U8 StartHead; // Beginning head number
- U8 StartSector; // Beginning sector (2 high bits of cylinder #)
- U8 StartCylinder; // Beginning cylinder# (low order bits of cylinder #)
- U8 SystemIndicator; // System indicator
- U8 EndHead; // Ending head number
- U8 EndSector; // Ending sector (2 high bits of cylinder #)
- U8 EndCylinder; // Ending cylinder# (low order bits of cylinder #)
- U32 SectorCountBeforePartition; // Number of sectors preceding the partition
- U32 PartitionSectorCount; // Number of sectors in the partition
+ UCHAR BootIndicator; // 0x00 - non-bootable partition, 0x80 - bootable partition (one partition only)
+ UCHAR StartHead; // Beginning head number
+ UCHAR StartSector; // Beginning sector (2 high bits of cylinder #)
+ UCHAR StartCylinder; // Beginning cylinder# (low order bits of cylinder #)
+ UCHAR SystemIndicator; // System indicator
+ UCHAR EndHead; // Ending head number
+ UCHAR EndSector; // Ending sector (2 high bits of cylinder #)
+ UCHAR EndCylinder; // Ending cylinder# (low order bits of cylinder #)
+ ULONG SectorCountBeforePartition; // Number of sectors preceding the partition
+ ULONG PartitionSectorCount; // Number of sectors in the partition
} PACKED PARTITION_TABLE_ENTRY, *PPARTITION_TABLE_ENTRY;
@@ -68,11 +68,11 @@ typedef struct _PARTITION_TABLE_ENTRY
//
typedef struct _MASTER_BOOT_RECORD
{
- U8 MasterBootRecordCodeAndData[0x1b8]; /* 0x000 */
- U32 Signature; /* 0x1B8 */
- U16 Reserved; /* 0x1BC */
+ UCHAR MasterBootRecordCodeAndData[0x1b8]; /* 0x000 */
+ ULONG Signature; /* 0x1B8 */
+ USHORT Reserved; /* 0x1BC */
PARTITION_TABLE_ENTRY PartitionTable[4]; /* 0x1BE */
- U16 MasterBootRecordMagic; /* 0x1FE */
+ USHORT MasterBootRecordMagic; /* 0x1FE */
} PACKED MASTER_BOOT_RECORD, *PMASTER_BOOT_RECORD;
@@ -106,10 +106,10 @@ typedef struct _MASTER_BOOT_RECORD
///////////////////////////////////////////////////////////////////////////////////////
#ifdef __i386__
-BOOL DiskResetController(U32 DriveNumber);
-BOOL DiskInt13ExtensionsSupported(U32 DriveNumber);
+BOOL DiskResetController(ULONG DriveNumber);
+BOOL DiskInt13ExtensionsSupported(ULONG DriveNumber);
//VOID DiskStopFloppyMotor(VOID);
-BOOL DiskGetExtendedDriveParameters(U32 DriveNumber, PVOID Buffer, U16 BufferSize);
+BOOL DiskGetExtendedDriveParameters(ULONG DriveNumber, PVOID Buffer, USHORT BufferSize);
#endif // defined __i386__
@@ -119,10 +119,10 @@ BOOL DiskGetExtendedDriveParameters(U32 DriveNumber, PVOID Buffer, U16 BufferSiz
//
///////////////////////////////////////////////////////////////////////////////////////
VOID DiskReportError (BOOL bError);
-VOID DiskError(PUCHAR ErrorString, U32 ErrorCode);
-PUCHAR DiskGetErrorCodeString(U32 ErrorCode);
-BOOL DiskReadLogicalSectors(U32 DriveNumber, U64 SectorNumber, U32 SectorCount, PVOID Buffer); // Implemented in i386disk.c
-BOOL DiskIsDriveRemovable(U32 DriveNumber);
+VOID DiskError(PUCHAR ErrorString, ULONG ErrorCode);
+PUCHAR DiskGetErrorCodeString(ULONG ErrorCode);
+BOOL DiskReadLogicalSectors(ULONG DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer); // Implemented in i386disk.c
+BOOL DiskIsDriveRemovable(ULONG DriveNumber);
VOID DiskStopFloppyMotor(VOID); // Implemented in i386disk.c
///////////////////////////////////////////////////////////////////////////////////////
@@ -130,10 +130,10 @@ VOID DiskStopFloppyMotor(VOID); // Implemented in i386disk.c
// Fixed Disk Partition Management Functions
//
///////////////////////////////////////////////////////////////////////////////////////
-BOOL DiskGetActivePartitionEntry(U32 DriveNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry);
-BOOL DiskGetPartitionEntry(U32 DriveNumber, U32 PartitionNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry);
+BOOL DiskGetActivePartitionEntry(ULONG DriveNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry);
+BOOL DiskGetPartitionEntry(ULONG DriveNumber, ULONG PartitionNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry);
BOOL DiskGetFirstPartitionEntry(PMASTER_BOOT_RECORD MasterBootRecord, PPARTITION_TABLE_ENTRY PartitionTableEntry);
BOOL DiskGetFirstExtendedPartitionEntry(PMASTER_BOOT_RECORD MasterBootRecord, PPARTITION_TABLE_ENTRY PartitionTableEntry);
-BOOL DiskReadBootRecord(U32 DriveNumber, U64 LogicalSectorNumber, PMASTER_BOOT_RECORD BootRecord);
+BOOL DiskReadBootRecord(ULONG DriveNumber, ULONGLONG LogicalSectorNumber, PMASTER_BOOT_RECORD BootRecord);
#endif // defined __DISK_H
diff --git a/reactos/boot/freeldr/freeldr/include/drivemap.h b/reactos/boot/freeldr/freeldr/include/drivemap.h
index af4b1c91c87..2aeaf662089 100644
--- a/reactos/boot/freeldr/freeldr/include/drivemap.h
+++ b/reactos/boot/freeldr/freeldr/include/drivemap.h
@@ -23,21 +23,21 @@
typedef struct
{
- U8 DriveMapCount; // Count of drives currently mapped
+ UCHAR DriveMapCount; // Count of drives currently mapped
- U8 DriveMap[8]; // Map of BIOS drives
+ UCHAR DriveMap[8]; // Map of BIOS drives
} PACKED DRIVE_MAP_LIST, *PDRIVE_MAP_LIST;
VOID DriveMapMapDrivesInSection(PUCHAR SectionName);
BOOL DriveMapIsValidDriveString(PUCHAR DriveString); // Checks the drive string ("hd0") for validity
-U32 DriveMapGetBiosDriveNumber(PUCHAR DeviceName); // Returns a BIOS drive number for any given device name (e.g. 0x80 for 'hd0')
+ULONG DriveMapGetBiosDriveNumber(PUCHAR DeviceName); // Returns a BIOS drive number for any given device name (e.g. 0x80 for 'hd0')
VOID DriveMapInstallInt13Handler(PDRIVE_MAP_LIST DriveMap); // Installs the int 13h handler for the drive mapper
VOID DriveMapRemoveInt13Handler(VOID); // Removes a previously installed int 13h drive map handler
extern PVOID DriveMapInt13HandlerStart;
extern PVOID DriveMapInt13HandlerEnd;
-extern U32 DriveMapOldInt13HandlerAddress;
+extern ULONG DriveMapOldInt13HandlerAddress;
extern DRIVE_MAP_LIST DriveMapInt13HandlerMapList;
#endif // #defined __DRIVEMAP_H
diff --git a/reactos/boot/freeldr/freeldr/include/freeldr.h b/reactos/boot/freeldr/freeldr/include/freeldr.h
index 3f3ca67235d..3b41ac30190 100644
--- a/reactos/boot/freeldr/freeldr/include/freeldr.h
+++ b/reactos/boot/freeldr/freeldr/include/freeldr.h
@@ -20,62 +20,29 @@
#ifndef __FREELDR_H
#define __FREELDR_H
-#define NULL 0
-#define TRUE 1
-#define FALSE 0
-
-#define BOOL int
-#define BOOLEAN int
-typedef BOOLEAN *PBOOLEAN;
-
-#define CHAR char
-#define PCHAR char *
-#define UCHAR unsigned char
-#define PUCHAR unsigned char *
-#define WCHAR unsigned short
-#define PWCHAR unsigned short *
-
-#define VOID void
-#define PVOID VOID*
-
-#ifdef __i386__
-
-#define size_t unsigned int
-
-typedef unsigned char U8;
-typedef char S8;
-typedef unsigned short U16;
-typedef short S16;
-typedef unsigned long U32;
-typedef long S32;
-typedef unsigned long long U64;
-typedef long long S64;
-
-typedef U8 __u8;
-typedef S8 __s8;
-typedef U16 __u16;
-typedef S16 __s16;
-typedef U32 __u32;
-typedef S32 __s32;
-typedef U64 __u64;
-typedef S64 __s64;
-
-#endif // __i386__
-
-typedef U8 *PU8;
-typedef U16 *PU16;
-typedef U32 *PU32;
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
#define ROUND_UP(N, S) (((N) + (S) - 1) & ~((S) - 1))
#define ROUND_DOWN(N, S) ((N) & ~((S) - 1))
+#define Ke386EraseFlags(x) __asm__ __volatile__("pushl $0 ; popfl\n")
+
+extern ULONG BootDrive; /* BIOS boot drive, 0-A:, 1-B:, 0x80-C:, 0x81-D:, etc. */
+extern ULONG BootPartition; /* Boot Partition, 1-4 */
+extern BOOL UserInterfaceUp; /* Tells us if the user interface is displayed */
-#define PACKED __attribute__((packed))
-
-extern U32 BootDrive; // BIOS boot drive, 0-A:, 1-B:, 0x80-C:, 0x81-D:, etc.
-extern U32 BootPartition; // Boot Partition, 1-4
-extern BOOL UserInterfaceUp; // Tells us if the user interface is displayed
-
-void BootMain(char *CmdLine);
-VOID RunLoader(VOID);
+VOID BootMain(LPSTR CmdLine);
+VOID RunLoader(VOID);
#endif // defined __FREELDR_H
diff --git a/reactos/boot/freeldr/freeldr/include/fs.h b/reactos/boot/freeldr/freeldr/include/fs.h
index 35ab38f4c09..6b2d57d774a 100644
--- a/reactos/boot/freeldr/freeldr/include/fs.h
+++ b/reactos/boot/freeldr/freeldr/include/fs.h
@@ -33,15 +33,15 @@
#define PFILE FILE *
VOID FileSystemError(PUCHAR ErrorString);
-BOOL FsOpenVolume(U32 DriveNumber, U32 PartitionNumber);
+BOOL FsOpenVolume(ULONG DriveNumber, ULONG PartitionNumber);
PFILE FsOpenFile(PUCHAR FileName);
VOID FsCloseFile(PFILE FileHandle);
-BOOL FsReadFile(PFILE FileHandle, U32 BytesToRead, U32* BytesRead, PVOID Buffer);
-U32 FsGetFileSize(PFILE FileHandle);
-VOID FsSetFilePointer(PFILE FileHandle, U32 NewFilePointer);
-U32 FsGetFilePointer(PFILE FileHandle);
+BOOL FsReadFile(PFILE FileHandle, ULONG BytesToRead, ULONG* BytesRead, PVOID Buffer);
+ULONG FsGetFileSize(PFILE FileHandle);
+VOID FsSetFilePointer(PFILE FileHandle, ULONG NewFilePointer);
+ULONG FsGetFilePointer(PFILE FileHandle);
BOOL FsIsEndOfFile(PFILE FileHandle);
-U32 FsGetNumPathParts(PUCHAR Path);
+ULONG FsGetNumPathParts(PUCHAR Path);
VOID FsGetFirstNameFromPath(PUCHAR Buffer, PUCHAR Path);
#endif // #defined __FS_H
diff --git a/reactos/boot/freeldr/freeldr/include/inffile.h b/reactos/boot/freeldr/freeldr/include/inffile.h
index e386324aee3..5848be34f50 100644
--- a/reactos/boot/freeldr/freeldr/include/inffile.h
+++ b/reactos/boot/freeldr/freeldr/include/inffile.h
@@ -36,7 +36,7 @@
#define MAX_INF_STRING_LENGTH 512
-typedef PU32 HINF, *PHINF;
+typedef PULONG HINF, *PHINF;
typedef struct _INFCONTEXT
{
@@ -52,7 +52,7 @@ typedef struct _INFCONTEXT
BOOLEAN
InfOpenFile (PHINF InfHandle,
PCHAR FileName,
- PU32 ErrorLine);
+ PULONG ErrorLine);
VOID
InfCloseFile (HINF InfHandle);
@@ -79,39 +79,39 @@ InfFindNextMatchLine (PINFCONTEXT ContextIn,
PINFCONTEXT ContextOut);
-S32
+LONG
InfGetLineCount (HINF InfHandle,
PCHAR Section);
-S32
+LONG
InfGetFieldCount (PINFCONTEXT Context);
BOOLEAN
InfGetBinaryField (PINFCONTEXT Context,
- U32 FieldIndex,
- PU8 ReturnBuffer,
- U32 ReturnBufferSize,
- PU32 RequiredSize);
+ ULONG FieldIndex,
+ PUCHAR ReturnBuffer,
+ ULONG ReturnBufferSize,
+ PULONG RequiredSize);
BOOLEAN
InfGetIntField (PINFCONTEXT Context,
- U32 FieldIndex,
- S32 *IntegerValue);
+ ULONG FieldIndex,
+ LONG *IntegerValue);
BOOLEAN
InfGetMultiSzField (PINFCONTEXT Context,
- U32 FieldIndex,
+ ULONG FieldIndex,
PCHAR ReturnBuffer,
- U32 ReturnBufferSize,
- PU32 RequiredSize);
+ ULONG ReturnBufferSize,
+ PULONG RequiredSize);
BOOLEAN
InfGetStringField (PINFCONTEXT Context,
- U32 FieldIndex,
+ ULONG FieldIndex,
PCHAR ReturnBuffer,
- U32 ReturnBufferSize,
- PU32 RequiredSize);
+ ULONG ReturnBufferSize,
+ PULONG RequiredSize);
@@ -122,7 +122,7 @@ InfGetData (PINFCONTEXT Context,
BOOLEAN
InfGetDataField (PINFCONTEXT Context,
- U32 FieldIndex,
+ ULONG FieldIndex,
PCHAR *Data);
#endif /* __INFCACHE_H__ */
diff --git a/reactos/boot/freeldr/freeldr/include/inifile.h b/reactos/boot/freeldr/freeldr/include/inifile.h
index 646d5319a3f..4b218363eb2 100644
--- a/reactos/boot/freeldr/freeldr/include/inifile.h
+++ b/reactos/boot/freeldr/freeldr/include/inifile.h
@@ -22,14 +22,14 @@
BOOL IniFileInitialize(VOID);
-BOOL IniOpenSection(PUCHAR SectionName, U32* SectionId);
-U32 IniGetNumSectionItems(U32 SectionId);
-U32 IniGetSectionSettingNameSize(U32 SectionId, U32 SettingIndex);
-U32 IniGetSectionSettingValueSize(U32 SectionId, U32 SettingIndex);
-BOOL IniReadSettingByNumber(U32 SectionId, U32 SettingNumber, PUCHAR SettingName, U32 NameSize, PUCHAR SettingValue, U32 ValueSize);
-BOOL IniReadSettingByName(U32 SectionId, PUCHAR SettingName, PUCHAR Buffer, U32 BufferSize);
-BOOL IniAddSection(PUCHAR SectionName, U32* SectionId);
-BOOL IniAddSettingValueToSection(U32 SectionId, PUCHAR SettingName, PUCHAR SettingValue);
+BOOL IniOpenSection(PUCHAR SectionName, ULONG* SectionId);
+ULONG IniGetNumSectionItems(ULONG SectionId);
+ULONG IniGetSectionSettingNameSize(ULONG SectionId, ULONG SettingIndex);
+ULONG IniGetSectionSettingValueSize(ULONG SectionId, ULONG SettingIndex);
+BOOL IniReadSettingByNumber(ULONG SectionId, ULONG SettingNumber, PUCHAR SettingName, ULONG NameSize, PUCHAR SettingValue, ULONG ValueSize);
+BOOL IniReadSettingByName(ULONG SectionId, PUCHAR SettingName, PUCHAR Buffer, ULONG BufferSize);
+BOOL IniAddSection(PUCHAR SectionName, ULONG* SectionId);
+BOOL IniAddSettingValueToSection(ULONG SectionId, PUCHAR SettingName, PUCHAR SettingValue);
#endif // defined __PARSEINI_H
diff --git a/reactos/boot/freeldr/freeldr/include/linux.h b/reactos/boot/freeldr/freeldr/include/linux.h
index 280cbf762ad..dc19f971b76 100644
--- a/reactos/boot/freeldr/freeldr/include/linux.h
+++ b/reactos/boot/freeldr/freeldr/include/linux.h
@@ -45,34 +45,34 @@
typedef struct
{
- U8 BootCode1[0x20];
+ UCHAR BootCode1[0x20];
- U16 CommandLineMagic;
- U16 CommandLineOffset;
+ USHORT CommandLineMagic;
+ USHORT CommandLineOffset;
- U8 BootCode2[0x1CD];
+ UCHAR BootCode2[0x1CD];
- U8 SetupSectors;
- U16 RootFlags;
- U16 SystemSize;
- U16 SwapDevice;
- U16 RamSize;
- U16 VideoMode;
- U16 RootDevice;
- U16 BootFlag; // 0xAA55
+ UCHAR SetupSectors;
+ USHORT RootFlags;
+ USHORT SystemSize;
+ USHORT SwapDevice;
+ USHORT RamSize;
+ USHORT VideoMode;
+ USHORT RootDevice;
+ USHORT BootFlag; // 0xAA55
} PACKED LINUX_BOOTSECTOR, *PLINUX_BOOTSECTOR;
typedef struct
{
- U8 JumpInstruction[2];
- U32 SetupHeaderSignature; // Signature for SETUP-header
- U16 Version; // Version number of header format
- U16 RealModeSwitch; // Default switch
- U16 SetupSeg; // SETUPSEG
- U16 StartSystemSeg;
- U16 KernelVersion; // Offset to kernel version string
- U8 TypeOfLoader; // Loader ID
+ UCHAR JumpInstruction[2];
+ ULONG SetupHeaderSignature; // Signature for SETUP-header
+ USHORT Version; // Version number of header format
+ USHORT RealModeSwitch; // Default switch
+ USHORT SetupSeg; // SETUPSEG
+ USHORT StartSystemSeg;
+ USHORT KernelVersion; // Offset to kernel version string
+ UCHAR TypeOfLoader; // Loader ID
// =0, old one (LILO, Loadlin,
// Bootlin, SYSLX, bootsect...)
// else it is set by the loader:
@@ -83,7 +83,7 @@ typedef struct
// T=4 for ETHERBOOT
// V = version
- U8 LoadFlags; // flags, unused bits must be zero (RFU)
+ UCHAR LoadFlags; // flags, unused bits must be zero (RFU)
// LOADED_HIGH = 1
// bit within loadflags,
// if set, then the kernel is loaded high
@@ -93,39 +93,39 @@ typedef struct
// can be used for heap purposes.
// Only the loader knows what is free!
- U16 SetupMoveSize; // size to move, when we (setup) are not
+ USHORT SetupMoveSize; // size to move, when we (setup) are not
// loaded at 0x90000. We will move ourselves
// to 0x90000 then just before jumping into
// the kernel. However, only the loader
// know how much of data behind us also needs
// to be loaded.
- U32 Code32Start; // here loaders can put a different
+ ULONG Code32Start; // here loaders can put a different
// start address for 32-bit code.
//
// 0x1000 = default for zImage
//
// 0x100000 = default for big kernel
- U32 RamdiskAddress; // address of loaded ramdisk image
+ ULONG RamdiskAddress; // address of loaded ramdisk image
// Here the loader (or kernel generator) puts
// the 32-bit address were it loaded the image.
- U32 RamdiskSize; // its size in bytes
+ ULONG RamdiskSize; // its size in bytes
- U16 BootSectKludgeOffset;
- U16 BootSectKludgeSegment;
- U16 HeapEnd; // space from here (exclusive) down to
+ USHORT BootSectKludgeOffset;
+ USHORT BootSectKludgeSegment;
+ USHORT HeapEnd; // space from here (exclusive) down to
// end of setup code can be used by setup
// for local heap purposes.
- U16 Pad1;
- U32 CommandLinePointer; // 32-bit pointer to the kernel command line
- U32 InitrdAddressMax; // Highest legal initrd address
+ USHORT Pad1;
+ ULONG CommandLinePointer; // 32-bit pointer to the kernel command line
+ ULONG InitrdAddressMax; // Highest legal initrd address
} PACKED LINUX_SETUPSECTOR, *PLINUX_SETUPSECTOR;
VOID BootNewLinuxKernel(VOID); // Implemented in linux.S
-VOID BootOldLinuxKernel(U32 KernelSize); // Implemented in linux.S
+VOID BootOldLinuxKernel(ULONG KernelSize); // Implemented in linux.S
VOID LoadAndBootLinux(PUCHAR OperatingSystemName, PUCHAR Description);
diff --git a/reactos/boot/freeldr/freeldr/include/machine.h b/reactos/boot/freeldr/freeldr/include/machine.h
index 3da9b3b4d9d..2642ed57f8e 100644
--- a/reactos/boot/freeldr/freeldr/include/machine.h
+++ b/reactos/boot/freeldr/freeldr/include/machine.h
@@ -40,28 +40,28 @@ typedef struct tagMACHVTBL
BOOL (*ConsKbHit)(VOID);
int (*ConsGetCh)(VOID);
- VOID (*VideoClearScreen)(U8 Attr);
+ VOID (*VideoClearScreen)(UCHAR Attr);
VIDEODISPLAYMODE (*VideoSetDisplayMode)(char *DisplayMode, BOOL Init);
- VOID (*VideoGetDisplaySize)(PU32 Width, PU32 Height, PU32 Depth);
- U32 (*VideoGetBufferSize)(VOID);
- VOID (*VideoSetTextCursorPosition)(U32 X, U32 Y);
+ VOID (*VideoGetDisplaySize)(PULONG Width, PULONG Height, PULONG Depth);
+ ULONG (*VideoGetBufferSize)(VOID);
+ VOID (*VideoSetTextCursorPosition)(ULONG X, ULONG Y);
VOID (*VideoHideShowTextCursor)(BOOL Show);
- VOID (*VideoPutChar)(int Ch, U8 Attr, unsigned X, unsigned Y);
+ VOID (*VideoPutChar)(int Ch, UCHAR Attr, unsigned X, unsigned Y);
VOID (*VideoCopyOffScreenBufferToVRAM)(PVOID Buffer);
BOOL (*VideoIsPaletteFixed)(VOID);
- VOID (*VideoSetPaletteColor)(U8 Color, U8 Red, U8 Green, U8 Blue);
- VOID (*VideoGetPaletteColor)(U8 Color, U8* Red, U8* Green, U8* Blue);
+ VOID (*VideoSetPaletteColor)(UCHAR Color, UCHAR Red, UCHAR Green, UCHAR Blue);
+ VOID (*VideoGetPaletteColor)(UCHAR Color, UCHAR* Red, UCHAR* Green, UCHAR* Blue);
VOID (*VideoSync)(VOID);
VOID (*VideoPrepareForReactOS)(VOID);
- U32 (*GetMemoryMap)(PBIOS_MEMORY_MAP BiosMemoryMap, U32 MaxMemoryMapSize);
+ ULONG (*GetMemoryMap)(PBIOS_MEMORY_MAP BiosMemoryMap, ULONG MaxMemoryMapSize);
- BOOL (*DiskReadLogicalSectors)(U32 DriveNumber, U64 SectorNumber, U32 SectorCount, PVOID Buffer);
- BOOL (*DiskGetPartitionEntry)(U32 DriveNumber, U32 PartitionNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry);
- BOOL (*DiskGetDriveGeometry)(U32 DriveNumber, PGEOMETRY DriveGeometry);
- U32 (*DiskGetCacheableBlockCount)(U32 DriveNumber);
+ BOOL (*DiskReadLogicalSectors)(ULONG DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer);
+ BOOL (*DiskGetPartitionEntry)(ULONG DriveNumber, ULONG PartitionNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry);
+ BOOL (*DiskGetDriveGeometry)(ULONG DriveNumber, PGEOMETRY DriveGeometry);
+ ULONG (*DiskGetCacheableBlockCount)(ULONG DriveNumber);
- VOID (*RTCGetCurrentDateTime)(PU32 Year, PU32 Month, PU32 Day, PU32 Hour, PU32 Minute, PU32 Second);
+ VOID (*RTCGetCurrentDateTime)(PULONG Year, PULONG Month, PULONG Day, PULONG Hour, PULONG Minute, PULONG Second);
VOID (*HwDetect)(VOID);
} MACHVTBL, *PMACHVTBL;
diff --git a/reactos/boot/freeldr/freeldr/include/mm.h b/reactos/boot/freeldr/freeldr/include/mm.h
index 96c87de24a9..ccd6aaaa933 100644
--- a/reactos/boot/freeldr/freeldr/include/mm.h
+++ b/reactos/boot/freeldr/freeldr/include/mm.h
@@ -29,23 +29,23 @@
typedef struct
{
- U64 BaseAddress;
- U64 Length;
- U32 Type;
- U32 Reserved;
+ ULONGLONG BaseAddress;
+ ULONGLONG Length;
+ ULONG Type;
+ ULONG Reserved;
} PACKED BIOS_MEMORY_MAP, *PBIOS_MEMORY_MAP;
-U32 GetSystemMemorySize(VOID); // Returns the amount of total memory in the system
+ULONG GetSystemMemorySize(VOID); // Returns the amount of total memory in the system
-//BOOL MmInitializeMemoryManager(U32 LowMemoryStart, U32 LowMemoryLength);
+//BOOL MmInitializeMemoryManager(ULONG LowMemoryStart, ULONG LowMemoryLength);
BOOL MmInitializeMemoryManager(VOID);
-PVOID MmAllocateMemory(U32 MemorySize);
+PVOID MmAllocateMemory(ULONG MemorySize);
VOID MmFreeMemory(PVOID MemoryPointer);
-//PVOID MmAllocateLowMemory(U32 MemorySize);
+//PVOID MmAllocateLowMemory(ULONG MemorySize);
//VOID MmFreeLowMemory(PVOID MemoryPointer);
-PVOID MmAllocateMemoryAtAddress(U32 MemorySize, PVOID DesiredAddress);
-PVOID MmAllocateHighestMemoryBelowAddress(U32 MemorySize, PVOID DesiredAddress);
+PVOID MmAllocateMemoryAtAddress(ULONG MemorySize, PVOID DesiredAddress);
+PVOID MmAllocateHighestMemoryBelowAddress(ULONG MemorySize, PVOID DesiredAddress);
#endif // defined __MEMORY_H
diff --git a/reactos/boot/freeldr/freeldr/include/multiboot.h b/reactos/boot/freeldr/freeldr/include/multiboot.h
index 755a7c829b2..f4e2cb42cf7 100644
--- a/reactos/boot/freeldr/freeldr/include/multiboot.h
+++ b/reactos/boot/freeldr/freeldr/include/multiboot.h
@@ -89,38 +89,34 @@ typedef struct elf_section_header_table
unsigned long shndx;
} elf_section_header_table_t;
-/* The Multiboot information. */
-typedef struct multiboot_info
+typedef struct _LOADER_PARAMETER_BLOCK
{
- unsigned long flags;
- unsigned long mem_lower;
- unsigned long mem_upper;
- unsigned long boot_device;
- unsigned long cmdline;
- unsigned long mods_count;
- unsigned long mods_addr;
-#if 0
- /* reactos and loadros define this entry with a size of 12 byte but the union is 16 byte */
- union
- {
- aout_symbol_table_t aout_sym;
- elf_section_header_table_t elf_sec;
- } u;
-#else
- char syms[12];
-#endif
- unsigned long mmap_length;
- unsigned long mmap_addr;
-} multiboot_info_t;
+ ULONG Flags;
+ ULONG MemLower;
+ ULONG MemHigher;
+ ULONG BootDevice;
+ ULONG CommandLine;
+ ULONG ModsCount;
+ ULONG ModsAddr;
+ UCHAR Syms[12];
+ ULONG MmapLength;
+ ULONG MmapAddr;
+ ULONG DrivesCount;
+ ULONG DrivesAddr;
+ ULONG ConfigTable;
+ ULONG BootLoaderName;
+ ULONG PageDirectoryStart;
+ ULONG PageDirectoryEnd;
+ ULONG KernelBase;
+} LOADER_PARAMETER_BLOCK, *PLOADER_PARAMETER_BLOCK;
/* The module structure. */
-typedef struct module
-{
- unsigned long mod_start;
- unsigned long mod_end;
- unsigned long string;
- unsigned long reserved;
-} module_t;
+typedef struct _FRLDR_MODULE {
+ ULONG_PTR ModuleStart;
+ ULONG_PTR ModuleEnd;
+ LPSTR ModuleName;
+ ULONG Reserved;
+} FRLDR_MODULE, *PFRLDR_MODULE;
/* The memory map. Be careful that the offset 0 is base_addr_low
but no size. */
@@ -136,27 +132,92 @@ typedef struct memory_map
} memory_map_t;
-multiboot_header_t mb_header; // Multiboot header structure defined in kernel image file
-multiboot_info_t mb_info; // Multiboot info structure passed to kernel
-char multiboot_kernel_cmdline[255]; // Command line passed to kernel
-module_t multiboot_modules[64]; // Array to hold boot module info loaded for the kernel
+LOADER_PARAMETER_BLOCK LoaderBlock; /* Multiboot info structure passed to kernel */
+char multiboot_kernel_cmdline[255]; // Command line passed to kernel
+FRLDR_MODULE multiboot_modules[64]; // Array to hold boot module info loaded for the kernel
char multiboot_module_strings[64][256]; // Array to hold module names
unsigned long multiboot_memory_map_descriptor_size;
-memory_map_t multiboot_memory_map[32]; // Memory map
+memory_map_t multiboot_memory_map[32]; // Memory map
void boot_reactos(void);
#include "fs.h" // Included FILE structure definition
-BOOL MultiBootLoadKernel(FILE *KernelImage);
-//BOOL MultiBootLoadModule(FILE *ModuleImage, char *ModuleName);
-PVOID MultiBootLoadModule(FILE *ModuleImage, char *ModuleName, U32* ModuleSize);
+BOOL
+STDCALL
+FrLdrBootReactOs(VOID);
+
+BOOL
+STDCALL
+FrLdrMapKernel(FILE *KernelImage);
+
+ULONG_PTR
+STDCALL
+FrLdrCreateModule(LPSTR ModuleName);
+
+ULONG_PTR
+STDCALL
+FrLdrLoadModule(FILE *ModuleImage,
+ LPSTR ModuleName,
+ PULONG ModuleSize);
+
+BOOL
+STDCALL
+FrLdrLoadKernel(PCHAR szFileName,
+ INT nPos);
+
+BOOL
+FrLdrLoadNlsFile(PCHAR szSystemRoot,
+ PCHAR szErrorOut);
+
+BOOL
+FrLdrLoadDriver(PCHAR szFileName,
+ INT nPos);
+BOOL
+LoadSymbolFile(PCHAR szSystemRoot,
+ PCHAR ModuleName,
+ INT nPos);
+
+VOID
+FrLdrLoadBootDrivers(PCHAR szSystemRoot,
+ INT nPos);
+
+BOOL
+STDCALL
+FrLdrCloseModule(ULONG_PTR ModuleBase,
+ ULONG dwModuleSize);
+
+VOID
+STDCALL
+FrLdrStartup(ULONG Magic);
+
+VOID
+FASTCALL
+FrLdrGetKernelBase(VOID);
+
+VOID
+FASTCALL
+FrLdrSetupPae(ULONG Magic);
+
+VOID
+FASTCALL
+FrLdrGetPaeMode(VOID);
+
+VOID
+FASTCALL
+FrLdrSetupPageDirectory(VOID);
+
+VOID
+LoadAndBootReactOS(PUCHAR OperatingSystemName);
+
+VOID FASTCALL AsmCode(VOID);
+typedef VOID (FASTCALL *ASMCODE)(ULONG Magic,
+ PLOADER_PARAMETER_BLOCK LoaderBlock);
int GetBootPartition(char *OperatingSystemName);
-PVOID MultiBootCreateModule(char *ModuleName);
-BOOL MultiBootCloseModule(PVOID ModuleBase, U32 dwModuleSize);
+
#endif /* ! ASM */
diff --git a/reactos/boot/freeldr/freeldr/include/oslist.h b/reactos/boot/freeldr/freeldr/include/oslist.h
index 5f874066bd6..3376df9e74d 100644
--- a/reactos/boot/freeldr/freeldr/include/oslist.h
+++ b/reactos/boot/freeldr/freeldr/include/oslist.h
@@ -20,9 +20,9 @@
#ifndef __OSLIST_H
#define __OSLIST_H
-BOOL InitOperatingSystemList(PUCHAR **SectionNamesPointer, PUCHAR **DisplayNamesPointer, U32* OperatingSystemCountPointer);
-U32 CountOperatingSystems(U32 SectionId);
-BOOL AllocateListMemory(PUCHAR **SectionNamesPointer, PUCHAR **DisplayNamesPointer, U32 OperatingSystemCount);
+BOOL InitOperatingSystemList(PUCHAR **SectionNamesPointer, PUCHAR **DisplayNamesPointer, ULONG* OperatingSystemCountPointer);
+ULONG CountOperatingSystems(ULONG SectionId);
+BOOL AllocateListMemory(PUCHAR **SectionNamesPointer, PUCHAR **DisplayNamesPointer, ULONG OperatingSystemCount);
BOOL RemoveQuotes(PUCHAR QuotedString);
#endif // #defined __OSLIST_H
diff --git a/reactos/boot/freeldr/freeldr/include/portio.h b/reactos/boot/freeldr/freeldr/include/portio.h
index f7aba205aa0..f4550bf2f50 100644
--- a/reactos/boot/freeldr/freeldr/include/portio.h
+++ b/reactos/boot/freeldr/freeldr/include/portio.h
@@ -27,52 +27,52 @@
*/
VOID
-/*STDCALL*/
-READ_PORT_BUFFER_UCHAR (PUCHAR Port, PUCHAR Value, U32 Count);
+STDCALL
+READ_PORT_BUFFER_UCHAR (PUCHAR Port, PUCHAR Value, ULONG Count);
VOID
-/*STDCALL*/
-READ_PORT_BUFFER_ULONG (U32* Port, U32* Value, U32 Count);
+STDCALL
+READ_PORT_BUFFER_ULONG (ULONG* Port, ULONG* Value, ULONG Count);
VOID
-/*STDCALL*/
-READ_PORT_BUFFER_USHORT (U16* Port, U16* Value, U32 Count);
+STDCALL
+READ_PORT_BUFFER_USHORT (USHORT* Port, USHORT* Value, ULONG Count);
UCHAR
-/*STDCALL*/
+STDCALL
READ_PORT_UCHAR (PUCHAR Port);
-U32
-/*STDCALL*/
-READ_PORT_ULONG (U32* Port);
+ULONG
+STDCALL
+READ_PORT_ULONG (ULONG* Port);
-U16
-/*STDCALL*/
-READ_PORT_USHORT (U16* Port);
+USHORT
+STDCALL
+READ_PORT_USHORT (USHORT* Port);
VOID
-/*STDCALL*/
-WRITE_PORT_BUFFER_UCHAR (PUCHAR Port, PUCHAR Value, U32 Count);
+STDCALL
+WRITE_PORT_BUFFER_UCHAR (PUCHAR Port, PUCHAR Value, ULONG Count);
VOID
-/*STDCALL*/
-WRITE_PORT_BUFFER_ULONG (U32* Port, U32* Value, U32 Count);
+STDCALL
+WRITE_PORT_BUFFER_ULONG (ULONG* Port, ULONG* Value, ULONG Count);
VOID
-/*STDCALL*/
-WRITE_PORT_BUFFER_USHORT (U16* Port, U16* Value, U32 Count);
+STDCALL
+WRITE_PORT_BUFFER_USHORT (USHORT* Port, USHORT* Value, ULONG Count);
VOID
-/*STDCALL*/
+STDCALL
WRITE_PORT_UCHAR (PUCHAR Port, UCHAR Value);
VOID
-/*STDCALL*/
-WRITE_PORT_ULONG (U32* Port, U32 Value);
+STDCALL
+WRITE_PORT_ULONG (ULONG* Port, ULONG Value);
VOID
-/*STDCALL*/
-WRITE_PORT_USHORT (U16* Port, U16 Value);
+STDCALL
+WRITE_PORT_USHORT (USHORT* Port, USHORT Value);
#endif // defined __PORTIO_H
diff --git a/reactos/boot/freeldr/freeldr/include/reactos.h b/reactos/boot/freeldr/freeldr/include/reactos.h
index 780bb139afc..c553754b2e6 100644
--- a/reactos/boot/freeldr/freeldr/include/reactos.h
+++ b/reactos/boot/freeldr/freeldr/include/reactos.h
@@ -26,23 +26,23 @@
// ReactOS Loading Functions
//
///////////////////////////////////////////////////////////////////////////////////////
-void LoadAndBootReactOS(PUCHAR OperatingSystemName);
+VOID LoadAndBootReactOS(PUCHAR OperatingSystemName);
///////////////////////////////////////////////////////////////////////////////////////
//
// ReactOS Setup Loader Functions
//
///////////////////////////////////////////////////////////////////////////////////////
-VOID ReactOSRunSetupLoader(VOID);
+VOID ReactOSRunSetupLoader(VOID);
///////////////////////////////////////////////////////////////////////////////////////
//
// ARC Path Functions
//
///////////////////////////////////////////////////////////////////////////////////////
-BOOL DissectArcPath(char *ArcPath, char *BootPath, U32* BootDrive, U32* BootPartition);
-void ConstructArcPath(PUCHAR ArcPath, PUCHAR SystemFolder, U32 Disk, U32 Partition);
-U32 ConvertArcNameToBiosDriveNumber(PUCHAR ArcPath);
+BOOL DissectArcPath(LPSTR ArcPath, LPSTR BootPath, PULONG BootDrive, PULONG BootPartition);
+VOID ConstructArcPath(PUCHAR ArcPath, PUCHAR SystemFolder, ULONG Disk, ULONG Partition);
+ULONG ConvertArcNameToBiosDriveNumber(PUCHAR ArcPath);
#endif // defined __REACTOS_H
diff --git a/reactos/boot/freeldr/freeldr/include/rtl.h b/reactos/boot/freeldr/freeldr/include/rtl.h
index 8fd5384b5af..bcf796de590 100644
--- a/reactos/boot/freeldr/freeldr/include/rtl.h
+++ b/reactos/boot/freeldr/freeldr/include/rtl.h
@@ -22,23 +22,6 @@
#include
-///////////////////////////////////////////////////////////////////////////////////////
-//
-// String Functions
-//
-///////////////////////////////////////////////////////////////////////////////////////
-int strlen(char *str);
-char * strcpy(char *dest, char *src);
-char * strncpy(char *dest, char *src, size_t count);
-char * strcat(char *dest, char *src);
-char * strncat(char *dst, const char *src, size_t n);
-char * strchr(const char *s, int c);
-char * strrchr(const char *s, int c);
-int strcmp(const char *string1, const char *string2);
-int stricmp(const char *string1, const char *string2);
-int strncmp(const char *string1, const char *string2, size_t length);
-int strnicmp(const char *string1, const char *string2, size_t length);
-
///////////////////////////////////////////////////////////////////////////////////////
//
// Memory Functions
@@ -52,7 +35,6 @@ void * memset(void *src, int val, size_t count);
#define RtlCompareMemory(Source1, Source2, Length) memcmp(Source1, Source2, Length)
#define RtlCopyMemory(Destination, Source, Length) memcpy(Destination, Source, Length)
#define RtlFillMemory(Destination, Length, Fill) memset(Destination, Fill, Length)
-#define RtlMoveMemory(Destination, Source, Length) memmove(Destination, Source, Length)
#define RtlZeroMemory(Destination, Length) memset(Destination, 0, Length)
///////////////////////////////////////////////////////////////////////////////////////
@@ -117,7 +99,7 @@ PLIST_ITEM RtlListRemoveTail(PLIST_ITEM ListHead); // Removes the entry a
PLIST_ITEM RtlListGetHead(PLIST_ITEM ListHead); // Returns the entry at the head of the list
PLIST_ITEM RtlListGetTail(PLIST_ITEM ListHead); // Returns the entry at the tail of the list
BOOL RtlListIsEmpty(PLIST_ITEM ListHead); // Indicates whether a doubly linked list is empty
-U32 RtlListCountEntries(PLIST_ITEM ListHead); // Counts the entries in a doubly linked list
+ULONG RtlListCountEntries(PLIST_ITEM ListHead); // Counts the entries in a doubly linked list
PLIST_ITEM RtlListGetPrevious(PLIST_ITEM ListEntry); // Returns the previous item in the list
PLIST_ITEM RtlListGetNext(PLIST_ITEM ListEntry); // Returns the next item in the list
PLIST_ITEM RtlListRemoveEntry(PLIST_ITEM ListEntry); // Removes the entry from the list
diff --git a/reactos/boot/freeldr/freeldr/include/ui.h b/reactos/boot/freeldr/freeldr/include/ui.h
index 34c7016c878..997b1e6e824 100644
--- a/reactos/boot/freeldr/freeldr/include/ui.h
+++ b/reactos/boot/freeldr/freeldr/include/ui.h
@@ -21,8 +21,8 @@
#define __UI_H
-extern U32 UiScreenWidth; // Screen Width
-extern U32 UiScreenHeight; // Screen Height
+extern ULONG UiScreenWidth; // Screen Width
+extern ULONG UiScreenHeight; // Screen Height
extern UCHAR UiStatusBarFgColor; // Status bar foreground color
extern UCHAR UiStatusBarBgColor; // Status bar background color
@@ -57,26 +57,26 @@ extern UCHAR UiMonthNames[12][15];
BOOL UiInitialize(BOOLEAN ShowGui); // Initialize User-Interface
VOID UiUnInitialize(PUCHAR BootText); // Un-initialize User-Interface
VOID UiDrawBackdrop(VOID); // Fills the entire screen with a backdrop
-VOID UiFillArea(U32 Left, U32 Top, U32 Right, U32 Bottom, UCHAR FillChar, UCHAR Attr /* Color Attributes */); // Fills the area specified with FillChar and Attr
-VOID UiDrawShadow(U32 Left, U32 Top, U32 Right, U32 Bottom); // Draws a shadow on the bottom and right sides of the area specified
-VOID UiDrawBox(U32 Left, U32 Top, U32 Right, U32 Bottom, UCHAR VertStyle, UCHAR HorzStyle, BOOL Fill, BOOL Shadow, UCHAR Attr); // Draws a box around the area specified
-VOID UiDrawText(U32 X, U32 Y, PUCHAR Text, UCHAR Attr); // Draws text at coordinates specified
-VOID UiDrawCenteredText(U32 Left, U32 Top, U32 Right, U32 Bottom, PUCHAR TextString, UCHAR Attr); // Draws centered text at the coordinates specified and clips the edges
+VOID UiFillArea(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, UCHAR FillChar, UCHAR Attr /* Color Attributes */); // Fills the area specified with FillChar and Attr
+VOID UiDrawShadow(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom); // Draws a shadow on the bottom and right sides of the area specified
+VOID UiDrawBox(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, UCHAR VertStyle, UCHAR HorzStyle, BOOL Fill, BOOL Shadow, UCHAR Attr); // Draws a box around the area specified
+VOID UiDrawText(ULONG X, ULONG Y, PUCHAR Text, UCHAR Attr); // Draws text at coordinates specified
+VOID UiDrawCenteredText(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, PUCHAR TextString, UCHAR Attr); // Draws centered text at the coordinates specified and clips the edges
VOID UiDrawStatusText(PUCHAR StatusText); // Draws text at the very bottom line on the screen
VOID UiUpdateDateTime(VOID); // Updates the date and time
VOID UiInfoBox(PUCHAR MessageText); // Displays a info box on the screen
VOID UiMessageBox(PUCHAR MessageText); // Displays a message box on the screen with an ok button
VOID UiMessageBoxCritical(PUCHAR MessageText); // Displays a message box on the screen with an ok button using no system resources
-VOID UiDrawProgressBarCenter(U32 Position, U32 Range, PUCHAR ProgressText); // Draws the progress bar showing nPos percent filled
-VOID UiDrawProgressBar(U32 Left, U32 Top, U32 Right, U32 Bottom, U32 Position, U32 Range, PUCHAR ProgressText); // Draws the progress bar showing nPos percent filled
+VOID UiDrawProgressBarCenter(ULONG Position, ULONG Range, PUCHAR ProgressText); // Draws the progress bar showing nPos percent filled
+VOID UiDrawProgressBar(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, ULONG Position, ULONG Range, PUCHAR ProgressText); // Draws the progress bar showing nPos percent filled
VOID UiShowMessageBoxesInSection(PUCHAR SectionName); // Displays all the message boxes in a given section
VOID UiEscapeString(PUCHAR String); // Processes a string and changes all occurances of "\n" to '\n'
-BOOL UiEditBox(PUCHAR MessageText, PUCHAR EditTextBuffer, U32 Length);
+BOOL UiEditBox(PUCHAR MessageText, PUCHAR EditTextBuffer, ULONG Length);
UCHAR UiTextToColor(PUCHAR ColorText); // Converts the text color into it's equivalent color value
UCHAR UiTextToFillStyle(PUCHAR FillStyleText); // Converts the text fill into it's equivalent fill value
-VOID UiTruncateStringEllipsis(PUCHAR StringText, U32 MaxChars); // Truncates a string to MaxChars by adding an ellipsis on the end '...'
+VOID UiTruncateStringEllipsis(PUCHAR StringText, ULONG MaxChars); // Truncates a string to MaxChars by adding an ellipsis on the end '...'
VOID UiFadeInBackdrop(VOID); // Draws the backdrop and fades the screen in
VOID UiFadeOut(VOID); // Fades the screen out
@@ -86,9 +86,9 @@ VOID UiFadeOut(VOID); // Fades the screen out
// Menu Functions
//
///////////////////////////////////////////////////////////////////////////////////////
-typedef BOOL (*UiMenuKeyPressFilterCallback)(U32 KeyPress);
+typedef BOOL (*UiMenuKeyPressFilterCallback)(ULONG KeyPress);
-BOOL UiDisplayMenu(PUCHAR MenuItemList[], U32 MenuItemCount, U32 DefaultMenuItem, S32 MenuTimeOut, U32* SelectedMenuItem, BOOL CanEscape, UiMenuKeyPressFilterCallback KeyPressFilter);
+BOOL UiDisplayMenu(PUCHAR MenuItemList[], ULONG MenuItemCount, ULONG DefaultMenuItem, LONG MenuTimeOut, ULONG* SelectedMenuItem, BOOL CanEscape, UiMenuKeyPressFilterCallback KeyPressFilter);
diff --git a/reactos/boot/freeldr/freeldr/include/version.h b/reactos/boot/freeldr/freeldr/include/version.h
index 0ca8cfc9034..b51df4ada21 100644
--- a/reactos/boot/freeldr/freeldr/include/version.h
+++ b/reactos/boot/freeldr/freeldr/include/version.h
@@ -22,7 +22,7 @@
/* just some stuff */
-#define VERSION "FreeLoader v1.9"
+#define VERSION "FreeLoader v2.0"
#define COPYRIGHT "Copyright (C) 1998-2003 Brian Palmer "
#define AUTHOR_EMAIL ""
#define BY_AUTHOR "by Brian Palmer"
@@ -34,8 +34,8 @@
// If you add features then you increment the minor version and zero the patch version
// If you add major functionality then you increment the major version and zero the minor & patch versions
//
-#define FREELOADER_MAJOR_VERSION 1
-#define FREELOADER_MINOR_VERSION 9
+#define FREELOADER_MAJOR_VERSION 2
+#define FREELOADER_MINOR_VERSION 0
#define FREELOADER_PATCH_VERSION 0
diff --git a/reactos/boot/freeldr/freeldr/include/video.h b/reactos/boot/freeldr/freeldr/include/video.h
index f269c2530db..ba66d7771c4 100644
--- a/reactos/boot/freeldr/freeldr/include/video.h
+++ b/reactos/boot/freeldr/freeldr/include/video.h
@@ -22,42 +22,25 @@
typedef struct
{
- U8 Red;
- U8 Green;
- U8 Blue;
+ UCHAR Red;
+ UCHAR Green;
+ UCHAR Blue;
} PACKED PALETTE_ENTRY, *PPALETTE_ENTRY;
extern PVOID VideoOffScreenBuffer;
-U16 BiosIsVesaSupported(VOID); // Implemented in i386vid.S, returns the VESA version
+USHORT BiosIsVesaSupported(VOID); // Implemented in i386vid.S, returns the VESA version
PVOID VideoAllocateOffScreenBuffer(VOID); // Returns a pointer to an off-screen buffer sufficient for the current video mode
-#if 0 /* Not used */
-U32 VideoGetMemoryBankForPixel(U32 X, U32 Y);
-U32 VideoGetMemoryBankForPixel16(U32 X, U32 Y);
-U32 VideoGetBankOffsetForPixel(U32 X, U32 Y);
-U32 VideoGetBankOffsetForPixel16(U32 X, U32 Y);
-VOID VideoSetMemoryBank(U16 BankNumber);
-U32 VideoGetOffScreenMemoryOffsetForPixel(U32 X, U32 Y);
-#endif
VOID VideoCopyOffScreenBufferToVRAM(VOID);
-VOID VideoSavePaletteState(PPALETTE_ENTRY Palette, U32 ColorCount);
-VOID VideoRestorePaletteState(PPALETTE_ENTRY Palette, U32 ColorCount);
+VOID VideoSavePaletteState(PPALETTE_ENTRY Palette, ULONG ColorCount);
+VOID VideoRestorePaletteState(PPALETTE_ENTRY Palette, ULONG ColorCount);
-#if 0 /* Not used */
-VOID VideoSetPixel16(U32 X, U32 Y, U8 Color);
-VOID VideoSetPixel256(U32 X, U32 Y, U8 Color);
-VOID VideoSetPixelRGB(U32 X, U32 Y, U8 Red, U8 Green, U8 Blue);
-VOID VideoSetPixel16_OffScreen(U32 X, U32 Y, U8 Color);
-VOID VideoSetPixel256_OffScreen(U32 X, U32 Y, U8 Color);
-VOID VideoSetPixelRGB_OffScreen(U32 X, U32 Y, U8 Red, U8 Green, U8 Blue);
-#endif
-
-VOID VideoSetAllColorsToBlack(U32 ColorCount);
-VOID VideoFadeIn(PPALETTE_ENTRY Palette, U32 ColorCount);
-VOID VideoFadeOut(U32 ColorCount);
+VOID VideoSetAllColorsToBlack(ULONG ColorCount);
+VOID VideoFadeIn(PPALETTE_ENTRY Palette, ULONG ColorCount);
+VOID VideoFadeOut(ULONG ColorCount);
#endif // defined __VIDEO_H
diff --git a/reactos/boot/freeldr/freeldr/inffile/inffile.c b/reactos/boot/freeldr/freeldr/inffile/inffile.c
index 0f4cb50642e..255e0c0f6de 100644
--- a/reactos/boot/freeldr/freeldr/inffile/inffile.c
+++ b/reactos/boot/freeldr/freeldr/inffile/inffile.c
@@ -56,7 +56,7 @@ typedef struct _INFCACHELINE
struct _INFCACHELINE *Next;
struct _INFCACHELINE *Prev;
- S32 FieldCount;
+ LONG FieldCount;
PCHAR Key;
@@ -74,7 +74,7 @@ typedef struct _INFCACHESECTION
PINFCACHELINE FirstLine;
PINFCACHELINE LastLine;
- S32 LineCount;
+ LONG LineCount;
CHAR Name[1];
} INFCACHESECTION, *PINFCACHESECTION;
@@ -241,7 +241,7 @@ InfpCacheAddSection (PINFCACHE Cache,
PCHAR Name)
{
PINFCACHESECTION Section = NULL;
- U32 Size;
+ ULONG Size;
if (Cache == NULL || Name == NULL)
{
@@ -341,7 +341,7 @@ InfpAddFieldToLine (PINFCACHELINE Line,
PCHAR Data)
{
PINFCACHEFIELD Field;
- U32 Size;
+ ULONG Size;
Size = sizeof(INFCACHEFIELD) + strlen(Data);
Field = (PINFCACHEFIELD)MmAllocateMemory (Size);
@@ -839,7 +839,7 @@ static BOOLEAN
InfpParseBuffer (PINFCACHE file,
const CHAR *buffer,
const CHAR *end,
- PU32 error_line)
+ PULONG error_line)
{
struct parser parser;
const CHAR *pos = buffer;
@@ -877,17 +877,17 @@ InfpParseBuffer (PINFCACHE file,
BOOLEAN
InfOpenFile(PHINF InfHandle,
PCHAR FileName,
- PU32 ErrorLine)
+ PULONG ErrorLine)
{
PFILE FileHandle;
PCHAR FileBuffer;
- U32 FileSize;
+ ULONG FileSize;
PINFCACHE Cache;
BOOLEAN Success;
*InfHandle = NULL;
- *ErrorLine = (U32)-1;
+ *ErrorLine = (ULONG)-1;
/* Open the inf file */
@@ -1144,7 +1144,7 @@ InfFindNextMatchLine (PINFCONTEXT ContextIn,
}
-S32
+LONG
InfGetLineCount(HINF InfHandle,
PCHAR Section)
{
@@ -1184,7 +1184,7 @@ InfGetLineCount(HINF InfHandle,
/* InfGetLineText */
-S32
+LONG
InfGetFieldCount(PINFCONTEXT Context)
{
if (Context == NULL || Context->Line == NULL)
@@ -1196,16 +1196,16 @@ InfGetFieldCount(PINFCONTEXT Context)
BOOLEAN
InfGetBinaryField (PINFCONTEXT Context,
- U32 FieldIndex,
- PU8 ReturnBuffer,
- U32 ReturnBufferSize,
- PU32 RequiredSize)
+ ULONG FieldIndex,
+ PUCHAR ReturnBuffer,
+ ULONG ReturnBufferSize,
+ PULONG RequiredSize)
{
PINFCACHELINE CacheLine;
PINFCACHEFIELD CacheField;
- U32 Index;
- U32 Size;
- PU8 Ptr;
+ ULONG Index;
+ ULONG Size;
+ PUCHAR Ptr;
if (Context == NULL || Context->Line == NULL || FieldIndex == 0)
{
@@ -1252,12 +1252,12 @@ InfGetBinaryField (PINFCONTEXT Context,
BOOLEAN
InfGetIntField (PINFCONTEXT Context,
- U32 FieldIndex,
- S32 *IntegerValue)
+ ULONG FieldIndex,
+ LONG *IntegerValue)
{
PINFCACHELINE CacheLine;
PINFCACHEFIELD CacheField;
- U32 Index;
+ ULONG Index;
PCHAR Ptr;
if (Context == NULL || Context->Line == NULL || IntegerValue == NULL)
@@ -1295,16 +1295,16 @@ InfGetIntField (PINFCONTEXT Context,
BOOLEAN
InfGetMultiSzField (PINFCONTEXT Context,
- U32 FieldIndex,
+ ULONG FieldIndex,
PCHAR ReturnBuffer,
- U32 ReturnBufferSize,
- PU32 RequiredSize)
+ ULONG ReturnBufferSize,
+ PULONG RequiredSize)
{
PINFCACHELINE CacheLine;
PINFCACHEFIELD CacheField;
PINFCACHEFIELD FieldPtr;
- U32 Index;
- U32 Size;
+ ULONG Index;
+ ULONG Size;
PCHAR Ptr;
if (Context == NULL || Context->Line == NULL || FieldIndex == 0)
@@ -1364,16 +1364,16 @@ InfGetMultiSzField (PINFCONTEXT Context,
BOOLEAN
InfGetStringField (PINFCONTEXT Context,
- U32 FieldIndex,
+ ULONG FieldIndex,
PCHAR ReturnBuffer,
- U32 ReturnBufferSize,
- PU32 RequiredSize)
+ ULONG ReturnBufferSize,
+ PULONG RequiredSize)
{
PINFCACHELINE CacheLine;
PINFCACHEFIELD CacheField;
- U32 Index;
+ ULONG Index;
PCHAR Ptr;
- U32 Size;
+ ULONG Size;
if (Context == NULL || Context->Line == NULL || FieldIndex == 0)
{
@@ -1456,12 +1456,12 @@ InfGetData (PINFCONTEXT Context,
BOOLEAN
InfGetDataField (PINFCONTEXT Context,
- U32 FieldIndex,
+ ULONG FieldIndex,
PCHAR *Data)
{
PINFCACHELINE CacheLine;
PINFCACHEFIELD CacheField;
- U32 Index;
+ ULONG Index;
if (Context == NULL || Context->Line == NULL || Data == NULL)
{
diff --git a/reactos/boot/freeldr/freeldr/inifile/ini.h b/reactos/boot/freeldr/freeldr/inifile/ini.h
index b24c1f0cab2..98a74967d33 100644
--- a/reactos/boot/freeldr/freeldr/inifile/ini.h
+++ b/reactos/boot/freeldr/freeldr/inifile/ini.h
@@ -48,29 +48,29 @@ typedef struct
{
LIST_ITEM ListEntry;
PUCHAR SectionName;
- U32 SectionItemCount;
+ ULONG SectionItemCount;
PINI_SECTION_ITEM SectionItemList;
} INI_SECTION, *PINI_SECTION;
extern PINI_SECTION IniFileSectionListHead;
-extern U32 IniFileSectionCount;
-extern U32 IniFileSettingCount;
+extern ULONG IniFileSectionCount;
+extern ULONG IniFileSettingCount;
-PFILE IniOpenIniFile(U8 BootDriveNumber, U8 BootPartitionNumber);
+PFILE IniOpenIniFile(UCHAR BootDriveNumber, UCHAR BootPartitionNumber);
-BOOL IniParseFile(PUCHAR IniFileData, U32 IniFileSize);
-U32 IniGetNextLineSize(PUCHAR IniFileData, U32 IniFileSize, U32 CurrentOffset);
-U32 IniGetNextLine(PUCHAR IniFileData, U32 IniFileSize, PUCHAR Buffer, U32 BufferSize, U32 CurrentOffset);
-BOOL IniIsLineEmpty(PUCHAR LineOfText, U32 TextLength);
-BOOL IniIsCommentLine(PUCHAR LineOfText, U32 TextLength);
-BOOL IniIsSectionName(PUCHAR LineOfText, U32 TextLength);
-U32 IniGetSectionNameSize(PUCHAR SectionNameLine, U32 LineLength);
-VOID IniExtractSectionName(PUCHAR SectionName, PUCHAR SectionNameLine, U32 LineLength);
-BOOL IniIsSetting(PUCHAR LineOfText, U32 TextLength);
-U32 IniGetSettingNameSize(PUCHAR SettingNameLine, U32 LineLength);
-U32 IniGetSettingValueSize(PUCHAR SettingValueLine, U32 LineLength);
-VOID IniExtractSettingName(PUCHAR SettingName, PUCHAR SettingNameLine, U32 LineLength);
-VOID IniExtractSettingValue(PUCHAR SettingValue, PUCHAR SettingValueLine, U32 LineLength);
+BOOL IniParseFile(PUCHAR IniFileData, ULONG IniFileSize);
+ULONG IniGetNextLineSize(PUCHAR IniFileData, ULONG IniFileSize, ULONG CurrentOffset);
+ULONG IniGetNextLine(PUCHAR IniFileData, ULONG IniFileSize, PUCHAR Buffer, ULONG BufferSize, ULONG CurrentOffset);
+BOOL IniIsLineEmpty(PUCHAR LineOfText, ULONG TextLength);
+BOOL IniIsCommentLine(PUCHAR LineOfText, ULONG TextLength);
+BOOL IniIsSectionName(PUCHAR LineOfText, ULONG TextLength);
+ULONG IniGetSectionNameSize(PUCHAR SectionNameLine, ULONG LineLength);
+VOID IniExtractSectionName(PUCHAR SectionName, PUCHAR SectionNameLine, ULONG LineLength);
+BOOL IniIsSetting(PUCHAR LineOfText, ULONG TextLength);
+ULONG IniGetSettingNameSize(PUCHAR SettingNameLine, ULONG LineLength);
+ULONG IniGetSettingValueSize(PUCHAR SettingValueLine, ULONG LineLength);
+VOID IniExtractSettingName(PUCHAR SettingName, PUCHAR SettingNameLine, ULONG LineLength);
+VOID IniExtractSettingValue(PUCHAR SettingValue, PUCHAR SettingValueLine, ULONG LineLength);
#endif // defined __INI_H
diff --git a/reactos/boot/freeldr/freeldr/inifile/ini_init.c b/reactos/boot/freeldr/freeldr/inifile/ini_init.c
index d47cdc11ad6..046133e4c1b 100644
--- a/reactos/boot/freeldr/freeldr/inifile/ini_init.c
+++ b/reactos/boot/freeldr/freeldr/inifile/ini_init.c
@@ -29,7 +29,7 @@ BOOL IniFileInitialize(VOID)
{
PFILE Freeldr_Ini; // File handle for freeldr.ini
PUCHAR FreeLoaderIniFileData;
- U32 FreeLoaderIniFileSize;
+ ULONG FreeLoaderIniFileSize;
BOOL Success;
// Open freeldr.ini
@@ -87,7 +87,7 @@ BOOL IniFileInitialize(VOID)
return Success;
}
-PFILE IniOpenIniFile(U8 BootDriveNumber, U8 BootPartitionNumber)
+PFILE IniOpenIniFile(UCHAR BootDriveNumber, UCHAR BootPartitionNumber)
{
PFILE IniFileHandle; // File handle for freeldr.ini
diff --git a/reactos/boot/freeldr/freeldr/inifile/inifile.c b/reactos/boot/freeldr/freeldr/inifile/inifile.c
index 4456df98834..9f8c19b8e5b 100644
--- a/reactos/boot/freeldr/freeldr/inifile/inifile.c
+++ b/reactos/boot/freeldr/freeldr/inifile/inifile.c
@@ -24,7 +24,7 @@
#include
#include
-BOOL IniOpenSection(PUCHAR SectionName, U32* SectionId)
+BOOL IniOpenSection(PUCHAR SectionName, ULONG* SectionId)
{
PINI_SECTION Section;
@@ -41,7 +41,7 @@ BOOL IniOpenSection(PUCHAR SectionName, U32* SectionId)
if (stricmp(SectionName, Section->SectionName) == 0)
{
// We found it
- *SectionId = (U32)Section;
+ *SectionId = (ULONG)Section;
DbgPrint((DPRINT_INIFILE, "IniOpenSection() Found it! SectionId = 0x%x\n", SectionId));
return TRUE;
}
@@ -55,7 +55,7 @@ BOOL IniOpenSection(PUCHAR SectionName, U32* SectionId)
return FALSE;
}
-U32 IniGetNumSectionItems(U32 SectionId)
+ULONG IniGetNumSectionItems(ULONG SectionId)
{
PINI_SECTION Section = (PINI_SECTION)SectionId;
@@ -65,7 +65,7 @@ U32 IniGetNumSectionItems(U32 SectionId)
return Section->SectionItemCount;
}
-U32 IniGetSectionSettingNameSize(U32 SectionId, U32 SettingIndex)
+ULONG IniGetSectionSettingNameSize(ULONG SectionId, ULONG SettingIndex)
{
PINI_SECTION Section = (PINI_SECTION)SectionId;
@@ -73,7 +73,7 @@ U32 IniGetSectionSettingNameSize(U32 SectionId, U32 SettingIndex)
return (strlen(Section->SectionItemList[SettingIndex].ItemName) + 1);
}
-U32 IniGetSectionSettingValueSize(U32 SectionId, U32 SettingIndex)
+ULONG IniGetSectionSettingValueSize(ULONG SectionId, ULONG SettingIndex)
{
PINI_SECTION Section = (PINI_SECTION)SectionId;
@@ -81,12 +81,12 @@ U32 IniGetSectionSettingValueSize(U32 SectionId, U32 SettingIndex)
return (strlen(Section->SectionItemList[SettingIndex].ItemValue) + 1);
}
-BOOL IniReadSettingByNumber(U32 SectionId, U32 SettingNumber, PUCHAR SettingName, U32 NameSize, PUCHAR SettingValue, U32 ValueSize)
+BOOL IniReadSettingByNumber(ULONG SectionId, ULONG SettingNumber, PUCHAR SettingName, ULONG NameSize, PUCHAR SettingValue, ULONG ValueSize)
{
PINI_SECTION Section = (PINI_SECTION)SectionId;
PINI_SECTION_ITEM SectionItem;
#ifdef DEBUG
- U32 RealSettingNumber = SettingNumber;
+ ULONG RealSettingNumber = SettingNumber;
#endif
DbgPrint((DPRINT_INIFILE, ".001 NameSize = %d ValueSize = %d\n", NameSize, ValueSize));
@@ -131,7 +131,7 @@ BOOL IniReadSettingByNumber(U32 SectionId, U32 SettingNumber, PUCHAR SettingName
return FALSE;
}
-BOOL IniReadSettingByName(U32 SectionId, PUCHAR SettingName, PUCHAR Buffer, U32 BufferSize)
+BOOL IniReadSettingByName(ULONG SectionId, PUCHAR SettingName, PUCHAR Buffer, ULONG BufferSize)
{
PINI_SECTION Section = (PINI_SECTION)SectionId;
PINI_SECTION_ITEM SectionItem;
@@ -163,7 +163,7 @@ BOOL IniReadSettingByName(U32 SectionId, PUCHAR SettingName, PUCHAR Buffer, U32
return FALSE;
}
-BOOL IniAddSection(PUCHAR SectionName, U32* SectionId)
+BOOL IniAddSection(PUCHAR SectionName, ULONG* SectionId)
{
PINI_SECTION Section;
@@ -198,12 +198,12 @@ BOOL IniAddSection(PUCHAR SectionName, U32* SectionId)
RtlListInsertTail((PLIST_ITEM)IniFileSectionListHead, (PLIST_ITEM)Section);
}
- *SectionId = (U32)Section;
+ *SectionId = (ULONG)Section;
return TRUE;
}
-BOOL IniAddSettingValueToSection(U32 SectionId, PUCHAR SettingName, PUCHAR SettingValue)
+BOOL IniAddSettingValueToSection(ULONG SectionId, PUCHAR SettingName, PUCHAR SettingValue)
{
PINI_SECTION Section = (PINI_SECTION)SectionId;
PINI_SECTION_ITEM SectionItem;
diff --git a/reactos/boot/freeldr/freeldr/inifile/parse.c b/reactos/boot/freeldr/freeldr/inifile/parse.c
index f490b1d733c..87f6bbd1035 100644
--- a/reactos/boot/freeldr/freeldr/inifile/parse.c
+++ b/reactos/boot/freeldr/freeldr/inifile/parse.c
@@ -26,17 +26,17 @@
PINI_SECTION IniFileSectionListHead = NULL;
-U32 IniFileSectionCount = 0;
-U32 IniFileSettingCount = 0;
+ULONG IniFileSectionCount = 0;
+ULONG IniFileSettingCount = 0;
-BOOL IniParseFile(PUCHAR IniFileData, U32 IniFileSize)
+BOOL IniParseFile(PUCHAR IniFileData, ULONG IniFileSize)
{
- U32 CurrentOffset;
- U32 CurrentLineNumber;
+ ULONG CurrentOffset;
+ ULONG CurrentLineNumber;
PUCHAR IniFileLine;
- U32 IniFileLineSize;
- U32 LineLength;
+ ULONG IniFileLineSize;
+ ULONG LineLength;
PINI_SECTION CurrentSection = NULL;
PINI_SECTION_ITEM CurrentItem = NULL;
@@ -189,10 +189,10 @@ BOOL IniParseFile(PUCHAR IniFileData, U32 IniFileSize)
return TRUE;
}
-U32 IniGetNextLineSize(PUCHAR IniFileData, U32 IniFileSize, U32 CurrentOffset)
+ULONG IniGetNextLineSize(PUCHAR IniFileData, ULONG IniFileSize, ULONG CurrentOffset)
{
- U32 Idx;
- U32 LineCharCount = 0;
+ ULONG Idx;
+ ULONG LineCharCount = 0;
// Loop through counting chars until we hit the end of the
// file or we encounter a new line char
@@ -216,9 +216,9 @@ U32 IniGetNextLineSize(PUCHAR IniFileData, U32 IniFileSize, U32 CurrentOffset)
return LineCharCount;
}
-U32 IniGetNextLine(PUCHAR IniFileData, U32 IniFileSize, PUCHAR Buffer, U32 BufferSize, U32 CurrentOffset)
+ULONG IniGetNextLine(PUCHAR IniFileData, ULONG IniFileSize, PUCHAR Buffer, ULONG BufferSize, ULONG CurrentOffset)
{
- U32 Idx;
+ ULONG Idx;
// Loop through grabbing chars until we hit the end of the
// file or we encounter a new line char
@@ -252,9 +252,9 @@ U32 IniGetNextLine(PUCHAR IniFileData, U32 IniFileSize, PUCHAR Buffer, U32 Buffe
return CurrentOffset;
}
-BOOL IniIsLineEmpty(PUCHAR LineOfText, U32 TextLength)
+BOOL IniIsLineEmpty(PUCHAR LineOfText, ULONG TextLength)
{
- U32 Idx;
+ ULONG Idx;
// Check for text (skipping whitespace)
for (Idx=0; IdxRamdiskAddress = (U32)LinuxInitrdLoadAddress;
+ LinuxSetupSector->RamdiskAddress = (ULONG)LinuxInitrdLoadAddress;
LinuxSetupSector->RamdiskSize = LinuxInitrdSize;
DbgPrint((DPRINT_LINUX, "RamdiskAddress: 0x%x\n", LinuxSetupSector->RamdiskAddress));
diff --git a/reactos/boot/freeldr/freeldr/machine.c b/reactos/boot/freeldr/freeldr/machine.c
index 993a9a43591..520769e3b06 100644
--- a/reactos/boot/freeldr/freeldr/machine.c
+++ b/reactos/boot/freeldr/freeldr/machine.c
@@ -65,7 +65,7 @@ MachConsGetCh()
}
VOID
-MachVideoClearScreen(U8 Attr)
+MachVideoClearScreen(UCHAR Attr)
{
MachVtbl.VideoClearScreen(Attr);
}
@@ -77,19 +77,19 @@ MachVideoSetDisplayMode(char *DisplayMode, BOOL Init)
}
VOID
-MachVideoGetDisplaySize(PU32 Width, PU32 Height, PU32 Depth)
+MachVideoGetDisplaySize(PULONG Width, PULONG Height, PULONG Depth)
{
return MachVtbl.VideoGetDisplaySize(Width, Height, Depth);
}
-U32
+ULONG
MachVideoGetBufferSize(VOID)
{
return MachVtbl.VideoGetBufferSize();
}
VOID
-MachVideoSetTextCursorPosition(U32 X, U32 Y)
+MachVideoSetTextCursorPosition(ULONG X, ULONG Y)
{
return MachVtbl.VideoSetTextCursorPosition(X, Y);
}
@@ -101,7 +101,7 @@ MachVideoHideShowTextCursor(BOOL Show)
}
VOID
-MachVideoPutChar(int Ch, U8 Attr, unsigned X, unsigned Y)
+MachVideoPutChar(int Ch, UCHAR Attr, unsigned X, unsigned Y)
{
MachVtbl.VideoPutChar(Ch, Attr, X, Y);
}
@@ -119,13 +119,13 @@ MachVideoIsPaletteFixed(VOID)
}
VOID
-MachVideoSetPaletteColor(U8 Color, U8 Red, U8 Green, U8 Blue)
+MachVideoSetPaletteColor(UCHAR Color, UCHAR Red, UCHAR Green, UCHAR Blue)
{
return MachVtbl.VideoSetPaletteColor(Color, Red, Green, Blue);
}
VOID
-MachVideoGetPaletteColor(U8 Color, U8 *Red, U8 *Green, U8 *Blue)
+MachVideoGetPaletteColor(UCHAR Color, UCHAR *Red, UCHAR *Green, UCHAR *Blue)
{
return MachVtbl.VideoGetPaletteColor(Color, Red, Green, Blue);
}
@@ -142,38 +142,38 @@ MachVideoPrepareForReactOS(VOID)
MachVtbl.VideoPrepareForReactOS();
}
-U32
-MachGetMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, U32 MaxMemoryMapSize)
+ULONG
+MachGetMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, ULONG MaxMemoryMapSize)
{
return MachVtbl.GetMemoryMap(BiosMemoryMap, MaxMemoryMapSize);
}
BOOL
-MachDiskReadLogicalSectors(U32 DriveNumber, U64 SectorNumber, U32 SectorCount, PVOID Buffer)
+MachDiskReadLogicalSectors(ULONG DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer)
{
return MachVtbl.DiskReadLogicalSectors(DriveNumber, SectorNumber, SectorCount, Buffer);
}
BOOL
-MachDiskGetPartitionEntry(U32 DriveNumber, U32 PartitionNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry)
+MachDiskGetPartitionEntry(ULONG DriveNumber, ULONG PartitionNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry)
{
return MachVtbl.DiskGetPartitionEntry(DriveNumber, PartitionNumber, PartitionTableEntry);
}
BOOL
-MachDiskGetDriveGeometry(U32 DriveNumber, PGEOMETRY DriveGeometry)
+MachDiskGetDriveGeometry(ULONG DriveNumber, PGEOMETRY DriveGeometry)
{
return MachVtbl.DiskGetDriveGeometry(DriveNumber, DriveGeometry);
}
-U32
-MachDiskGetCacheableBlockCount(U32 DriveNumber)
+ULONG
+MachDiskGetCacheableBlockCount(ULONG DriveNumber)
{
return MachVtbl.DiskGetCacheableBlockCount(DriveNumber);
}
VOID
-MachRTCGetCurrentDateTime(PU32 Year, PU32 Month, PU32 Day, PU32 Hour, PU32 Minute, PU32 Second)
+MachRTCGetCurrentDateTime(PULONG Year, PULONG Month, PULONG Day, PULONG Hour, PULONG Minute, PULONG Second)
{
MachVtbl.RTCGetCurrentDateTime(Year, Month, Day, Hour, Minute, Second);
}
diff --git a/reactos/boot/freeldr/freeldr/miscboot.c b/reactos/boot/freeldr/freeldr/miscboot.c
index 5b4828cfbc8..3531fe254f0 100644
--- a/reactos/boot/freeldr/freeldr/miscboot.c
+++ b/reactos/boot/freeldr/freeldr/miscboot.c
@@ -34,9 +34,9 @@ VOID LoadAndBootBootSector(PUCHAR OperatingSystemName)
PFILE FilePointer;
UCHAR SettingName[80];
UCHAR SettingValue[80];
- U32 SectionId;
+ ULONG SectionId;
UCHAR FileName[260];
- U32 BytesRead;
+ ULONG BytesRead;
// Find all the message box settings and run them
UiShowMessageBoxesInSection(OperatingSystemName);
@@ -90,7 +90,7 @@ VOID LoadAndBootBootSector(PUCHAR OperatingSystemName)
}
// Check for validity
- if (*((U16*)(0x7c00 + 0x1fe)) != 0xaa55)
+ if (*((USHORT*)(0x7c00 + 0x1fe)) != 0xaa55)
{
UiMessageBox("Invalid boot sector magic (0xaa55)");
return;
@@ -113,7 +113,7 @@ VOID LoadAndBootPartition(PUCHAR OperatingSystemName)
{
UCHAR SettingName[80];
UCHAR SettingValue[80];
- U32 SectionId;
+ ULONG SectionId;
PARTITION_TABLE_ENTRY PartitionTableEntry;
// Find all the message box settings and run them
@@ -159,7 +159,7 @@ VOID LoadAndBootPartition(PUCHAR OperatingSystemName)
}
// Check for validity
- if (*((U16*)(0x7c00 + 0x1fe)) != 0xaa55)
+ if (*((USHORT*)(0x7c00 + 0x1fe)) != 0xaa55)
{
UiMessageBox("Invalid boot sector magic (0xaa55)");
return;
@@ -182,7 +182,7 @@ VOID LoadAndBootDrive(PUCHAR OperatingSystemName)
{
UCHAR SettingName[80];
UCHAR SettingValue[80];
- U32 SectionId;
+ ULONG SectionId;
// Find all the message box settings and run them
UiShowMessageBoxesInSection(OperatingSystemName);
@@ -211,7 +211,7 @@ VOID LoadAndBootDrive(PUCHAR OperatingSystemName)
}
// Check for validity
- if (*((U16*)(0x7c00 + 0x1fe)) != 0xaa55)
+ if (*((USHORT*)(0x7c00 + 0x1fe)) != 0xaa55)
{
UiMessageBox("Invalid boot sector magic (0xaa55)");
return;
diff --git a/reactos/boot/freeldr/freeldr/mm/mem.h b/reactos/boot/freeldr/freeldr/mm/mem.h
index 7d24552d6f0..168f3f4027e 100644
--- a/reactos/boot/freeldr/freeldr/mm/mem.h
+++ b/reactos/boot/freeldr/freeldr/mm/mem.h
@@ -30,8 +30,8 @@
typedef struct
{
- U32 PageAllocated; // Zero = free, non-zero = allocated
- U32 PageAllocationLength; // Number of pages allocated (or zero if this isn't the first page in the chain)
+ ULONG PageAllocated; // Zero = free, non-zero = allocated
+ ULONG PageAllocationLength; // Number of pages allocated (or zero if this isn't the first page in the chain)
} PACKED PAGE_LOOKUP_TABLE_ITEM, *PPAGE_LOOKUP_TABLE_ITEM;
//
@@ -44,27 +44,27 @@ typedef struct
extern PVOID PageLookupTableAddress;
-extern U32 TotalPagesInLookupTable;
-extern U32 FreePagesInLookupTable;
-extern U32 LastFreePageHint;
+extern ULONG TotalPagesInLookupTable;
+extern ULONG FreePagesInLookupTable;
+extern ULONG LastFreePageHint;
#ifdef DEBUG
-PUCHAR MmGetSystemMemoryMapTypeString(U32 Type);
+PUCHAR MmGetSystemMemoryMapTypeString(ULONG Type);
#endif
-U32 MmGetPageNumberFromAddress(PVOID Address); // Returns the page number that contains a linear address
-PVOID MmGetEndAddressOfAnyMemory(PBIOS_MEMORY_MAP BiosMemoryMap, U32 MapCount); // Returns the last address of memory from the memory map
-U32 MmGetAddressablePageCountIncludingHoles(PBIOS_MEMORY_MAP BiosMemoryMap, U32 MapCount); // Returns the count of addressable pages from address zero including any memory holes and reserved memory regions
-PVOID MmFindLocationForPageLookupTable(PBIOS_MEMORY_MAP BiosMemoryMap, U32 MapCount); // Returns the address for a memory chunk big enough to hold the page lookup table (starts search from end of memory)
-VOID MmSortBiosMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, U32 MapCount); // Sorts the BIOS_MEMORY_MAP array so the first element corresponds to the first address in memory
-VOID MmInitPageLookupTable(PVOID PageLookupTable, U32 TotalPageCount, PBIOS_MEMORY_MAP BiosMemoryMap, U32 MapCount); // Inits the page lookup table according to the memory types in the memory map
-VOID MmMarkPagesInLookupTable(PVOID PageLookupTable, U32 StartPage, U32 PageCount, U32 PageAllocated); // Marks the specified pages as allocated or free in the lookup table
-VOID MmAllocatePagesInLookupTable(PVOID PageLookupTable, U32 StartPage, U32 PageCount); // Allocates the specified pages in the lookup table
-U32 MmCountFreePagesInLookupTable(PVOID PageLookupTable, U32 TotalPageCount); // Returns the number of free pages in the lookup table
-U32 MmFindAvailablePagesFromEnd(PVOID PageLookupTable, U32 TotalPageCount, U32 PagesNeeded); // Returns the page number of the first available page range from the end of memory
-U32 MmFindAvailablePagesBeforePage(PVOID PageLookupTable, U32 TotalPageCount, U32 PagesNeeded, U32 LastPage); // Returns the page number of the first available page range before the specified page
-VOID MmFixupSystemMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, U32* MapCount); // Removes entries in the memory map that describe memory above 4G
-VOID MmUpdateLastFreePageHint(PVOID PageLookupTable, U32 TotalPageCount); // Sets the LastFreePageHint to the last usable page of memory
-BOOL MmAreMemoryPagesAvailable(PVOID PageLookupTable, U32 TotalPageCount, PVOID PageAddress, U32 PageCount); // Returns TRUE if the specified pages of memory are available, otherwise FALSE
+ULONG MmGetPageNumberFromAddress(PVOID Address); // Returns the page number that contains a linear address
+PVOID MmGetEndAddressOfAnyMemory(PBIOS_MEMORY_MAP BiosMemoryMap, ULONG MapCount); // Returns the last address of memory from the memory map
+ULONG MmGetAddressablePageCountIncludingHoles(PBIOS_MEMORY_MAP BiosMemoryMap, ULONG MapCount); // Returns the count of addressable pages from address zero including any memory holes and reserved memory regions
+PVOID MmFindLocationForPageLookupTable(PBIOS_MEMORY_MAP BiosMemoryMap, ULONG MapCount); // Returns the address for a memory chunk big enough to hold the page lookup table (starts search from end of memory)
+VOID MmSortBiosMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, ULONG MapCount); // Sorts the BIOS_MEMORY_MAP array so the first element corresponds to the first address in memory
+VOID MmInitPageLookupTable(PVOID PageLookupTable, ULONG TotalPageCount, PBIOS_MEMORY_MAP BiosMemoryMap, ULONG MapCount); // Inits the page lookup table according to the memory types in the memory map
+VOID MmMarkPagesInLookupTable(PVOID PageLookupTable, ULONG StartPage, ULONG PageCount, ULONG PageAllocated); // Marks the specified pages as allocated or free in the lookup table
+VOID MmAllocatePagesInLookupTable(PVOID PageLookupTable, ULONG StartPage, ULONG PageCount); // Allocates the specified pages in the lookup table
+ULONG MmCountFreePagesInLookupTable(PVOID PageLookupTable, ULONG TotalPageCount); // Returns the number of free pages in the lookup table
+ULONG MmFindAvailablePagesFromEnd(PVOID PageLookupTable, ULONG TotalPageCount, ULONG PagesNeeded); // Returns the page number of the first available page range from the end of memory
+ULONG MmFindAvailablePagesBeforePage(PVOID PageLookupTable, ULONG TotalPageCount, ULONG PagesNeeded, ULONG LastPage); // Returns the page number of the first available page range before the specified page
+VOID MmFixupSystemMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, ULONG* MapCount); // Removes entries in the memory map that describe memory above 4G
+VOID MmUpdateLastFreePageHint(PVOID PageLookupTable, ULONG TotalPageCount); // Sets the LastFreePageHint to the last usable page of memory
+BOOL MmAreMemoryPagesAvailable(PVOID PageLookupTable, ULONG TotalPageCount, PVOID PageAddress, ULONG PageCount); // Returns TRUE if the specified pages of memory are available, otherwise FALSE
#endif // defined __MEM_H
diff --git a/reactos/boot/freeldr/freeldr/mm/meminit.c b/reactos/boot/freeldr/freeldr/mm/meminit.c
index 408e4ff6490..1d93653f4ca 100644
--- a/reactos/boot/freeldr/freeldr/mm/meminit.c
+++ b/reactos/boot/freeldr/freeldr/mm/meminit.c
@@ -30,11 +30,11 @@
#ifdef DEBUG
typedef struct
{
- U32 Type;
+ ULONG Type;
UCHAR TypeString[20];
} MEMORY_TYPE, *PMEMORY_TYPE;
-U32 MemoryTypeCount = 5;
+ULONG MemoryTypeCount = 5;
MEMORY_TYPE MemoryTypeArray[] =
{
{ 0, "Unknown Memory" },
@@ -46,16 +46,16 @@ MEMORY_TYPE MemoryTypeArray[] =
#endif
PVOID PageLookupTableAddress = NULL;
-U32 TotalPagesInLookupTable = 0;
-U32 FreePagesInLookupTable = 0;
-U32 LastFreePageHint = 0;
+ULONG TotalPagesInLookupTable = 0;
+ULONG FreePagesInLookupTable = 0;
+ULONG LastFreePageHint = 0;
BOOL MmInitializeMemoryManager(VOID)
{
BIOS_MEMORY_MAP BiosMemoryMap[32];
- U32 BiosMemoryMapEntryCount;
+ ULONG BiosMemoryMapEntryCount;
#ifdef DEBUG
- U32 Index;
+ ULONG Index;
#endif
DbgPrint((DPRINT_MEMORY, "Initializing Memory Manager.\n"));
@@ -105,9 +105,9 @@ BOOL MmInitializeMemoryManager(VOID)
}
#ifdef DEBUG
-PUCHAR MmGetSystemMemoryMapTypeString(U32 Type)
+PUCHAR MmGetSystemMemoryMapTypeString(ULONG Type)
{
- U32 Index;
+ ULONG Index;
for (Index=1; Index= PageLookupTableSize)
{
- PageLookupTableMemAddress = (PVOID)(U32)(TempBiosMemoryMap[Index].BaseAddress + (TempBiosMemoryMap[Index].Length - PageLookupTableSize));
+ PageLookupTableMemAddress = (PVOID)(ULONG)(TempBiosMemoryMap[Index].BaseAddress + (TempBiosMemoryMap[Index].Length - PageLookupTableSize));
break;
}
}
@@ -209,10 +209,10 @@ PVOID MmFindLocationForPageLookupTable(PBIOS_MEMORY_MAP BiosMemoryMap, U32 MapCo
return PageLookupTableMemAddress;
}
-VOID MmSortBiosMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, U32 MapCount)
+VOID MmSortBiosMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, ULONG MapCount)
{
- U32 Index;
- U32 LoopCount;
+ ULONG Index;
+ ULONG LoopCount;
BIOS_MEMORY_MAP TempMapItem;
// Loop once for each entry in the memory map minus one
@@ -231,15 +231,15 @@ VOID MmSortBiosMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, U32 MapCount)
}
}
-VOID MmInitPageLookupTable(PVOID PageLookupTable, U32 TotalPageCount, PBIOS_MEMORY_MAP BiosMemoryMap, U32 MapCount)
+VOID MmInitPageLookupTable(PVOID PageLookupTable, ULONG TotalPageCount, PBIOS_MEMORY_MAP BiosMemoryMap, ULONG MapCount)
{
- U32 MemoryMapStartPage;
- U32 MemoryMapEndPage;
- U32 MemoryMapPageCount;
- U32 MemoryMapPageAllocated;
- U32 PageLookupTableStartPage;
- U32 PageLookupTablePageCount;
- U32 Index;
+ ULONG MemoryMapStartPage;
+ ULONG MemoryMapEndPage;
+ ULONG MemoryMapPageCount;
+ ULONG MemoryMapPageAllocated;
+ ULONG PageLookupTableStartPage;
+ ULONG PageLookupTablePageCount;
+ ULONG Index;
DbgPrint((DPRINT_MEMORY, "MmInitPageLookupTable()\n"));
@@ -250,8 +250,8 @@ VOID MmInitPageLookupTable(PVOID PageLookupTable, U32 TotalPageCount, PBIOS_MEMO
for (Index=0; Index TotalPageCount)
{
@@ -349,11 +349,11 @@ U32 MmFindAvailablePagesFromEnd(PVOID PageLookupTable, U32 TotalPageCount, U32 P
return 0;
}
-U32 MmFindAvailablePagesBeforePage(PVOID PageLookupTable, U32 TotalPageCount, U32 PagesNeeded, U32 LastPage)
+ULONG MmFindAvailablePagesBeforePage(PVOID PageLookupTable, ULONG TotalPageCount, ULONG PagesNeeded, ULONG LastPage)
{
PPAGE_LOOKUP_TABLE_ITEM RealPageLookupTable = (PPAGE_LOOKUP_TABLE_ITEM)PageLookupTable;
- U32 AvailablePagesSoFar;
- U32 Index;
+ ULONG AvailablePagesSoFar;
+ ULONG Index;
if (LastPage > TotalPageCount)
{
@@ -382,7 +382,7 @@ U32 MmFindAvailablePagesBeforePage(PVOID PageLookupTable, U32 TotalPageCount, U3
return 0;
}
-VOID MmFixupSystemMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, U32* MapCount)
+VOID MmFixupSystemMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, ULONG* MapCount)
{
int Index;
int Index2;
@@ -406,10 +406,10 @@ VOID MmFixupSystemMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, U32* MapCount)
}
}
-VOID MmUpdateLastFreePageHint(PVOID PageLookupTable, U32 TotalPageCount)
+VOID MmUpdateLastFreePageHint(PVOID PageLookupTable, ULONG TotalPageCount)
{
PPAGE_LOOKUP_TABLE_ITEM RealPageLookupTable = (PPAGE_LOOKUP_TABLE_ITEM)PageLookupTable;
- U32 Index;
+ ULONG Index;
for (Index=TotalPageCount-1; Index>0; Index--)
{
@@ -421,11 +421,11 @@ VOID MmUpdateLastFreePageHint(PVOID PageLookupTable, U32 TotalPageCount)
}
}
-BOOL MmAreMemoryPagesAvailable(PVOID PageLookupTable, U32 TotalPageCount, PVOID PageAddress, U32 PageCount)
+BOOL MmAreMemoryPagesAvailable(PVOID PageLookupTable, ULONG TotalPageCount, PVOID PageAddress, ULONG PageCount)
{
PPAGE_LOOKUP_TABLE_ITEM RealPageLookupTable = (PPAGE_LOOKUP_TABLE_ITEM)PageLookupTable;
- U32 StartPage;
- U32 Index;
+ ULONG StartPage;
+ ULONG Index;
StartPage = MmGetPageNumberFromAddress(PageAddress);
diff --git a/reactos/boot/freeldr/freeldr/mm/mm.c b/reactos/boot/freeldr/freeldr/mm/mm.c
index 1eb5bfdd971..402069a634e 100644
--- a/reactos/boot/freeldr/freeldr/mm/mm.c
+++ b/reactos/boot/freeldr/freeldr/mm/mm.c
@@ -27,7 +27,7 @@
#ifdef DEBUG
-U32 AllocationCount = 0;
+ULONG AllocationCount = 0;
VOID VerifyHeap(VOID);
VOID DumpMemoryAllocMap(VOID);
@@ -36,10 +36,10 @@ VOID DecrementAllocationCount(VOID);
VOID MemAllocTest(VOID);
#endif // DEBUG
-PVOID MmAllocateMemory(U32 MemorySize)
+PVOID MmAllocateMemory(ULONG MemorySize)
{
- U32 PagesNeeded;
- U32 FirstFreePageFromEnd;
+ ULONG PagesNeeded;
+ ULONG FirstFreePageFromEnd;
PVOID MemPointer;
if (MemorySize == 0)
@@ -87,10 +87,10 @@ PVOID MmAllocateMemory(U32 MemorySize)
return MemPointer;
}
-PVOID MmAllocateMemoryAtAddress(U32 MemorySize, PVOID DesiredAddress)
+PVOID MmAllocateMemoryAtAddress(ULONG MemorySize, PVOID DesiredAddress)
{
- U32 PagesNeeded;
- U32 StartPageNumber;
+ ULONG PagesNeeded;
+ ULONG StartPageNumber;
PVOID MemPointer;
if (MemorySize == 0)
@@ -139,11 +139,11 @@ PVOID MmAllocateMemoryAtAddress(U32 MemorySize, PVOID DesiredAddress)
return MemPointer;
}
-PVOID MmAllocateHighestMemoryBelowAddress(U32 MemorySize, PVOID DesiredAddress)
+PVOID MmAllocateHighestMemoryBelowAddress(ULONG MemorySize, PVOID DesiredAddress)
{
- U32 PagesNeeded;
- U32 FirstFreePageFromEnd;
- U32 DesiredAddressPageNumber;
+ ULONG PagesNeeded;
+ ULONG FirstFreePageFromEnd;
+ ULONG DesiredAddressPageNumber;
PVOID MemPointer;
if (MemorySize == 0)
@@ -158,7 +158,7 @@ PVOID MmAllocateHighestMemoryBelowAddress(U32 MemorySize, PVOID DesiredAddress)
PagesNeeded = ROUND_UP(MemorySize, MM_PAGE_SIZE) / MM_PAGE_SIZE;
// Get the page number for their desired address
- DesiredAddressPageNumber = (U32)DesiredAddress / MM_PAGE_SIZE;
+ DesiredAddressPageNumber = (ULONG)DesiredAddress / MM_PAGE_SIZE;
// If we don't have enough available mem
// then return NULL
@@ -196,9 +196,9 @@ PVOID MmAllocateHighestMemoryBelowAddress(U32 MemorySize, PVOID DesiredAddress)
VOID MmFreeMemory(PVOID MemoryPointer)
{
- U32 PageNumber;
- U32 PageCount;
- U32 Idx;
+ ULONG PageNumber;
+ ULONG PageCount;
+ ULONG Idx;
PPAGE_LOOKUP_TABLE_ITEM RealPageLookupTable = (PPAGE_LOOKUP_TABLE_ITEM)PageLookupTableAddress;
#ifdef DEBUG
@@ -255,9 +255,9 @@ VOID MmFreeMemory(PVOID MemoryPointer)
#ifdef DEBUG
VOID VerifyHeap(VOID)
{
- U32 Idx;
- U32 Idx2;
- U32 Count;
+ ULONG Idx;
+ ULONG Idx2;
+ ULONG Count;
PPAGE_LOOKUP_TABLE_ITEM RealPageLookupTable = (PPAGE_LOOKUP_TABLE_ITEM)PageLookupTableAddress;
if (DUMP_MEM_MAP_ON_VERIFY)
@@ -315,7 +315,7 @@ VOID VerifyHeap(VOID)
VOID DumpMemoryAllocMap(VOID)
{
- U32 Idx;
+ ULONG Idx;
PPAGE_LOOKUP_TABLE_ITEM RealPageLookupTable = (PPAGE_LOOKUP_TABLE_ITEM)PageLookupTableAddress;
DbgPrint((DPRINT_MEMORY, "----------- Memory Allocation Bitmap -----------\n"));
@@ -400,7 +400,7 @@ VOID MemAllocTest(VOID)
}
#endif // DEBUG
-U32 GetSystemMemorySize(VOID)
+ULONG GetSystemMemorySize(VOID)
{
return (TotalPagesInLookupTable * MM_PAGE_SIZE);
}
diff --git a/reactos/boot/freeldr/freeldr/multiboot.c b/reactos/boot/freeldr/freeldr/multiboot.c
index 5db72524353..97b7191e8f3 100644
--- a/reactos/boot/freeldr/freeldr/multiboot.c
+++ b/reactos/boot/freeldr/freeldr/multiboot.c
@@ -1,271 +1,728 @@
/*
- * FreeLoader
- * Copyright (C) 1998-2003 Brian Palmer
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: Freeloader
+ * FILE: boot/freeldr/freeldr/multiboot.c
+ * PURPOSE: ReactOS Loader
+ * PROGRAMMERS: Alex Ionescu (alex@relsoft.net)
+ * Hartmutt Birr - SMP/PAE Code
*/
-
#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
+#include
-unsigned long next_module_load_base = 0;
-module_t* pOpenModule = NULL;
+#define NDEBUG
+#include
+
+/* Base Addres of Kernel in Physical Memory */
+#define KERNEL_BASE_PHYS 0x200000
+
+/* Bits to shift to convert a Virtual Address into an Offset in the Page Table */
+#define PFN_SHIFT 12
+
+/* Bits to shift to convert a Virtual Address into an Offset in the Page Directory */
+#define PDE_SHIFT 20
+#define PDE_SHIFT_PAE 18
+
+
+/* Converts a Relative Address read from the Kernel into a Physical Address */
+#define RaToPa(p) \
+ (ULONG_PTR)((ULONG_PTR)p + KERNEL_BASE_PHYS)
+
+/* Converts a Phsyical Address Pointer into a Page Frame Number */
+#define PaPtrToPfn(p) \
+ (((ULONG_PTR)&p) >> PFN_SHIFT)
+
+/* Converts a Phsyical Address into a Page Frame Number */
+#define PaToPfn(p) \
+ ((p) >> PFN_SHIFT)
+
+#define STARTUP_BASE 0xF0000000
+#define HYPERSPACE_BASE 0xF0800000
+#define APIC_BASE 0xFEC00000
+#define KPCR_BASE 0xFF000000
+
+#define LowMemPageTableIndex 0
+#define StartupPageTableIndex (STARTUP_BASE >> 20) / sizeof(HARDWARE_PTE_X86)
+#define HyperspacePageTableIndex (HYPERSPACE_BASE >> 20) / sizeof(HARDWARE_PTE_X86)
+#define KpcrPageTableIndex (KPCR_BASE >> 20) / sizeof(HARDWARE_PTE_X86)
+#define ApicPageTableIndex (APIC_BASE >> 20) / sizeof(HARDWARE_PTE_X86)
+
+#define LowMemPageTableIndexPae 0
+#define StartupPageTableIndexPae (STARTUP_BASE >> 21)
+#define HyperspacePageTableIndexPae (HYPERSPACE_BASE >> 21)
+#define KpcrPageTableIndexPae (KPCR_BASE >> 21)
+#define ApicPageTableIndexPae (APIC_BASE >> 21)
-BOOL MultiBootLoadKernel(FILE *KernelImage)
-{
- U32* ImageHeaders;
- int Idx;
- U32 dwHeaderChecksum;
- U32 dwFileLoadOffset;
- U32 dwDataSize;
- U32 dwBssSize;
+#define KernelEntryPoint (KernelEntry - KERNEL_BASE_PHYS) + KernelBase
- // Allocate 8192 bytes for multiboot header
- ImageHeaders = (U32*)MmAllocateMemory(8192);
- if (ImageHeaders == NULL)
- {
- return FALSE;
- }
+/* Load Address of Next Module */
+ULONG_PTR NextModuleBase = 0;
- /*
- * Load the first 8192 bytes of the kernel image
- * so we can search for the multiboot header
- */
- if (!FsReadFile(KernelImage, 8192, NULL, ImageHeaders))
- {
- MmFreeMemory(ImageHeaders);
- return FALSE;
- }
+/* Currently Opened Module */
+PFRLDR_MODULE CurrentModule = NULL;
- /*
- * Now find the multiboot header and copy it
- */
- for (Idx=0; Idx<2048; Idx++)
- {
- // Did we find it?
- if (ImageHeaders[Idx] == MULTIBOOT_HEADER_MAGIC)
- {
- // Yes, copy it and break out of this loop
- memcpy(&mb_header, &ImageHeaders[Idx], sizeof(multiboot_header_t));
+/* Unrelocated Kernel Base in Virtual Memory */
+ULONG_PTR KernelBase;
- break;
- }
- }
+/* Wether PAE is to be used or not */
+BOOLEAN PaeModeEnabled;
- MmFreeMemory(ImageHeaders);
+/* Kernel Entrypoint in Physical Memory */
+ULONG_PTR KernelEntry;
- /*
- * If we reached the end of the 8192 bytes without
- * finding the multiboot header then return error
- */
- if (Idx == 2048)
- {
- UiMessageBox("No multiboot header found!");
- return FALSE;
- }
+/* Page Directory and Tables for non-PAE Systems */
+extern ULONG_PTR startup_pagedirectory;
+extern ULONG_PTR lowmem_pagetable;
+extern ULONG_PTR kernel_pagetable;
+extern ULONG_PTR hyperspace_pagetable;
+extern ULONG_PTR _pae_pagedirtable;
+extern ULONG_PTR apic_pagetable;
+extern ULONG_PTR kpcr_pagetable;
- /*printf("multiboot header:\n");
- printf("0x%x\n", mb_header.magic);
- printf("0x%x\n", mb_header.flags);
- printf("0x%x\n", mb_header.checksum);
- printf("0x%x\n", mb_header.header_addr);
- printf("0x%x\n", mb_header.load_addr);
- printf("0x%x\n", mb_header.load_end_addr);
- printf("0x%x\n", mb_header.bss_end_addr);
- printf("0x%x\n", mb_header.entry_addr);
- getch();*/
+/* Page Directory and Tables for PAE Systems */
+extern ULONG_PTR startup_pagedirectorytable_pae;
+extern ULONG_PTR startup_pagedirectory_pae;
+extern ULONG_PTR lowmem_pagetable_pae;
+extern ULONG_PTR kernel_pagetable_pae;
+extern ULONG_PTR hyperspace_pagetable_pae;
+extern ULONG_PTR pagedirtable_pae;
+extern ULONG_PTR apic_pagetable_pae;
+extern ULONG_PTR kpcr_pagetable_pae;
- /*
- * Calculate the checksum and make sure it matches
- */
- dwHeaderChecksum = mb_header.magic;
- dwHeaderChecksum += mb_header.flags;
- dwHeaderChecksum += mb_header.checksum;
- if (dwHeaderChecksum != 0)
- {
- UiMessageBox("Multiboot header checksum invalid!");
- return FALSE;
- }
-
- /*
- * Get the file offset, this should be 0, and move the file pointer
- */
- dwFileLoadOffset = (Idx * sizeof(U32)) - (mb_header.header_addr - mb_header.load_addr);
- FsSetFilePointer(KernelImage, dwFileLoadOffset);
-
- /*
- * Load the file image
- */
- dwDataSize = (mb_header.load_end_addr - mb_header.load_addr);
- FsReadFile(KernelImage, dwDataSize, NULL, (void*)mb_header.load_addr);
+typedef struct _HARDWARE_PTE_X86 {
+ ULONG Valid : 1;
+ ULONG Write : 1;
+ ULONG Owner : 1;
+ ULONG WriteThrough : 1;
+ ULONG CacheDisable : 1;
+ ULONG Accessed : 1;
+ ULONG Dirty : 1;
+ ULONG LargePage : 1;
+ ULONG Global : 1;
+ ULONG CopyOnWrite : 1;
+ ULONG Prototype : 1;
+ ULONG reserved : 1;
+ ULONG PageFrameNumber : 20;
+} HARDWARE_PTE_X86, *PHARDWARE_PTE_X86;
- /*
- * Initialize bss area
- */
- dwBssSize = (mb_header.bss_end_addr - mb_header.load_end_addr);
- memset((void*)mb_header.load_end_addr, 0, dwBssSize);
+typedef struct _HARDWARE_PTE_X64 {
+ ULONG Valid : 1;
+ ULONG Write : 1;
+ ULONG Owner : 1;
+ ULONG WriteThrough : 1;
+ ULONG CacheDisable : 1;
+ ULONG Accessed : 1;
+ ULONG Dirty : 1;
+ ULONG LargePage : 1;
+ ULONG Global : 1;
+ ULONG CopyOnWrite : 1;
+ ULONG Prototype : 1;
+ ULONG reserved : 1;
+ ULONG PageFrameNumber : 20;
+ ULONG reserved2 : 31;
+ ULONG NoExecute : 1;
+} HARDWARE_PTE_X64, *PHARDWARE_PTE_X64;
- next_module_load_base = ROUND_UP(mb_header.bss_end_addr, /*PAGE_SIZE*/4096);
+typedef struct _PAGE_DIRECTORY_X86 {
+ HARDWARE_PTE_X86 Pde[1024];
+} PAGE_DIRECTORY_x86, *PPAGE_DIRECTORY_X86;
- return TRUE;
+typedef struct _PAGE_DIRECTORY_X64 {
+ HARDWARE_PTE_X64 Pde[2048];
+} PAGE_DIRECTORY_X64, *PPAGE_DIRECTORY_X64;
+
+typedef struct _PAGE_DIRECTORY_TABLE_X64 {
+ HARDWARE_PTE_X64 Pde[4];
+} PAGE_DIRECTORY_TABLE_X64, *PPAGE_DIRECTORY_TABLE_X64;
+
+/* FUNCTIONS *****************************************************************/
+
+/*++
+ * FrLdrStartup
+ * INTERNAL
+ *
+ * Prepares the system for loading the Kernel.
+ *
+ * Params:
+ * Magic - Multiboot Magic
+ *
+ * Returns:
+ * None.
+ *
+ * Remarks:
+ * None.
+ *
+ *--*/
+VOID
+STDCALL
+FrLdrStartup(ULONG Magic)
+{
+ /* Disable Interrupts */
+ Ke386DisableInterrupts();
+
+ /* Re-initalize EFLAGS */
+ Ke386EraseFlags();
+
+ /* Get Kernel Base and Set MmSystemRangeStart */
+ FrLdrGetKernelBase();
+
+ FrLdrGetPaeMode();
+
+ /* Initialize the page directory */
+ FrLdrSetupPageDirectory();
+
+ /* Initialize Paging, Write-Protection and Load NTOSKRNL */
+ FrLdrSetupPae(Magic);
}
-#if 0
-BOOL MultiBootLoadModule(FILE *ModuleImage, char *ModuleName)
+/*++
+ * FrLdrSetupPae
+ * INTERNAL
+ *
+ * Configures PAE on a MP System, and sets the PDBR if it's supported, or if
+ * the system is UP.
+ *
+ * Params:
+ * Magic - Multiboot Magic
+ *
+ * Returns:
+ * None.
+ *
+ * Remarks:
+ * None.
+ *
+ *--*/
+VOID
+FASTCALL
+FrLdrSetupPae(ULONG Magic)
{
- U32 dwModuleSize;
- module_t* pModule;
- char* ModuleNameString;
- char * TempName;
-
- /*
- * Get current module data structure and module name string array
- */
- pModule = &multiboot_modules[mb_info.mods_count];
- do {
- TempName = strchr( ModuleName, '\\' );
- if( TempName )
- ModuleName = TempName + 1;
- } while( TempName );
+ ULONG_PTR PageDirectoryBaseAddress = (ULONG_PTR)&startup_pagedirectory;
+ ASMCODE PagedJump;
- ModuleNameString = multiboot_module_strings[mb_info.mods_count];
-
- dwModuleSize = FsGetFileSize(ModuleImage);
- pModule->mod_start = next_module_load_base;
- pModule->mod_end = next_module_load_base + dwModuleSize;
- strcpy(ModuleNameString, ModuleName);
- pModule->string = (unsigned long)ModuleNameString;
-
- /*
- * Load the file image
- */
- FsReadFile(ModuleImage, dwModuleSize, NULL, (void*)next_module_load_base);
+ if (PaeModeEnabled)
+ {
+ PageDirectoryBaseAddress = (ULONG_PTR)&startup_pagedirectorytable_pae;
+
+ /* Enable PAE */
+ Ke386SetCr4(Ke386GetCr4() | X86_CR4_PAE);
+ }
+
+ /* Set the PDBR */
+ Ke386SetPageTableDirectory(PageDirectoryBaseAddress);
+
+ /* Enable Paging and Write Protect*/
+ Ke386SetCr0(Ke386GetCr0() | X86_CR0_PG | X86_CR0_WP);
+
+ /* Jump to Kernel */
+ PagedJump = (ASMCODE)KernelEntryPoint;
+ PagedJump(Magic, &LoaderBlock);
+ }
- next_module_load_base = ROUND_UP(pModule->mod_end, /*PAGE_SIZE*/4096);
- mb_info.mods_count++;
-
- return TRUE;
-}
-#endif
-
-PVOID MultiBootLoadModule(FILE *ModuleImage, char *ModuleName, U32* ModuleSize)
+/*++
+ * FrLdrGetKernelBase
+ * INTERNAL
+ *
+ * Gets the Kernel Base to use.
+ *
+ * Params:
+ *
+ * Returns:
+ * None.
+ *
+ * Remarks:
+ * Sets both the FreeLdr internal variable as well as the one which
+ * will be used by the Kernel.
+ *
+ *--*/
+VOID
+FASTCALL
+FrLdrGetKernelBase(VOID)
{
- U32 dwModuleSize;
- module_t* pModule;
- char* ModuleNameString;
- char * TempName;
-
- /*
- * Get current module data structure and module name string array
- */
- pModule = &multiboot_modules[mb_info.mods_count];
- do {
- TempName = strchr( ModuleName, '\\' );
- if( TempName )
- ModuleName = TempName + 1;
- } while( TempName );
-
- ModuleNameString = multiboot_module_strings[mb_info.mods_count];
-
- dwModuleSize = FsGetFileSize(ModuleImage);
- pModule->mod_start = next_module_load_base;
- pModule->mod_end = next_module_load_base + dwModuleSize;
- strcpy(ModuleNameString, ModuleName);
- pModule->string = (unsigned long)ModuleNameString;
-
- /*
- * Load the file image
- */
- FsReadFile(ModuleImage, dwModuleSize, NULL, (void*)next_module_load_base);
-
- next_module_load_base = ROUND_UP(pModule->mod_end, /*PAGE_SIZE*/4096);
- mb_info.mods_count++;
-
- if (ModuleSize != NULL)
- *ModuleSize = dwModuleSize;
-
- return((PVOID)pModule->mod_start);
+ PCHAR p1;
+ PCHAR p2;
+
+ /* Read Command Line */
+ for(p1 = (PCHAR)&LoaderBlock.CommandLine; *p1 && (p2 = strchr(p1, '/')); p2++) {
+
+ /* Find "/3GB" */
+ if (!strnicmp(p2, "3GB", 3)) {
+
+ /* Make sure there's nothing following it */
+ if (p2[3] == ' ' || p2[3] == 0) {
+
+ /* Use 3GB */
+ KernelBase = 0xC0000000;
+
+ } else {
+
+ /* Use 2GB */
+ KernelBase = 0x80000000;
+ }
+ }
+ }
+
+ /* Set KernelBase */
+ LoaderBlock.KernelBase = KernelBase;
}
-#if 0
-int GetBootPartition(char *OperatingSystemName)
+/*++
+ * FrLdrGetPaeMode
+ * INTERNAL
+ *
+ * Determines whether PAE mode shoudl be enabled or not.
+ *
+ * Params:
+ * None.
+ *
+ * Returns:
+ * None.
+ *
+ * Remarks:
+ * None.
+ *
+ *--*/
+VOID
+FASTCALL
+FrLdrGetPaeMode(VOID)
{
- int BootPartitionNumber = -1;
- char value[1024];
- U32 SectionId;
+ /* FIXME: Read command line */
+ PaeModeEnabled = FALSE;
- if (IniOpenSection(OperatingSystemName, &SectionId))
- {
- if (IniReadSettingByName(SectionId, "BootPartition", value, 1024))
- {
- BootPartitionNumber = atoi(value);
- }
- }
-
- return BootPartitionNumber;
-}
-#endif
-
-PVOID MultiBootCreateModule(char *ModuleName)
-{
- module_t* pModule;
- char* ModuleNameString;
-
- /*
- * Get current module data structure and module name string array
- */
- pModule = &multiboot_modules[mb_info.mods_count];
-
- ModuleNameString = multiboot_module_strings[mb_info.mods_count];
-
- pModule->mod_start = next_module_load_base;
- pModule->mod_end = -1;
- strcpy(ModuleNameString, ModuleName);
- pModule->string = (unsigned long)ModuleNameString;
-
- pOpenModule = pModule;
-
- return((PVOID)pModule->mod_start);
+ if (PaeModeEnabled)
+ {
+ }
}
-
-BOOL MultiBootCloseModule(PVOID ModuleBase, U32 dwModuleSize)
+/*++
+ * FrLdrSetupPageDirectory
+ * INTERNAL
+ *
+ * Sets up the ReactOS Startup Page Directory.
+ *
+ * Params:
+ * None.
+ *
+ * Returns:
+ * None.
+ *
+ * Remarks:
+ * We are setting PDEs, but using the equvivalent (for our purpose) PTE structure.
+ * As such, please note that PageFrameNumber == PageEntryNumber.
+ *
+ *--*/
+VOID
+FASTCALL
+FrLdrSetupPageDirectory(VOID)
{
- module_t* pModule;
+ PPAGE_DIRECTORY_X86 PageDir;
+ PPAGE_DIRECTORY_TABLE_X64 PageDirTablePae;
+ PPAGE_DIRECTORY_X64 PageDirPae;
+ ULONG KernelPageTableIndex;
+ ULONG i;
- if ((pOpenModule != NULL) &&
- ((module_t*)ModuleBase == (module_t*)pOpenModule->mod_start) &&
- (pOpenModule->mod_end == -1))
- {
- pModule = pOpenModule;
- pModule->mod_end = pModule->mod_start + dwModuleSize;
+ if (PaeModeEnabled) {
+
+ /* Get the Kernel Table Index */
+ KernelPageTableIndex = (KernelBase >> 21);
- next_module_load_base = ROUND_UP(pModule->mod_end, /*PAGE_SIZE*/4096);
- mb_info.mods_count++;
- pOpenModule = NULL;
+ /* Get the Startup Page Directory Table */
+ PageDirTablePae = (PPAGE_DIRECTORY_TABLE_X64)&startup_pagedirectorytable_pae;
- return(TRUE);
- }
+ /* Get the Startup Page Directory */
+ PageDirPae = (PPAGE_DIRECTORY_X64)&startup_pagedirectory_pae;
- return(FALSE);
+ /* Set the Startup page directory table */
+ for (i = 0; i < 4; i++)
+ {
+ PageDirTablePae->Pde[i].Valid = 1;
+ PageDirTablePae->Pde[i].PageFrameNumber = PaPtrToPfn(startup_pagedirectory_pae) + i;
+ }
+
+ /* Set up the Low Memory PDE */
+ for (i = 0; i < 2; i++)
+ {
+ PageDirPae->Pde[LowMemPageTableIndexPae + i].Valid = 1;
+ PageDirPae->Pde[LowMemPageTableIndexPae + i].Write = 1;
+ PageDirPae->Pde[LowMemPageTableIndexPae + i].PageFrameNumber = PaPtrToPfn(lowmem_pagetable_pae) + i;
+ }
+
+ /* Set up the Kernel PDEs */
+ for (i = 0; i < 3; i++)
+ {
+ PageDirPae->Pde[KernelPageTableIndex + i].Valid = 1;
+ PageDirPae->Pde[KernelPageTableIndex + i].Write = 1;
+ PageDirPae->Pde[KernelPageTableIndex + i].PageFrameNumber = PaPtrToPfn(kernel_pagetable_pae) + i;
+ }
+
+ /* Set up the Startup PDE */
+ for (i = 0; i < 4; i++)
+ {
+ PageDirPae->Pde[StartupPageTableIndexPae + i].Valid = 1;
+ PageDirPae->Pde[StartupPageTableIndexPae + i].Write = 1;
+ PageDirPae->Pde[StartupPageTableIndexPae + i].PageFrameNumber = PaPtrToPfn(startup_pagedirectory_pae) + i;
+ }
+
+ /* Set up the Hyperspace PDE */
+ for (i = 0; i < 2; i++)
+ {
+ PageDirPae->Pde[HyperspacePageTableIndexPae + i].Valid = 1;
+ PageDirPae->Pde[HyperspacePageTableIndexPae + i].Write = 1;
+ PageDirPae->Pde[HyperspacePageTableIndexPae + i].PageFrameNumber = PaPtrToPfn(hyperspace_pagetable_pae) + i;
+ }
+
+ /* Set up the Apic PDE */
+ for (i = 0; i < 2; i++)
+ {
+ PageDirPae->Pde[ApicPageTableIndexPae + i].Valid = 1;
+ PageDirPae->Pde[ApicPageTableIndexPae + i].Write = 1;
+ PageDirPae->Pde[ApicPageTableIndexPae + i].PageFrameNumber = PaPtrToPfn(apic_pagetable_pae) + i;
+ }
+
+ /* Set up the KPCR PDE */
+ PageDirPae->Pde[KpcrPageTableIndexPae].Valid = 1;
+ PageDirPae->Pde[KpcrPageTableIndexPae].Write = 1;
+ PageDirPae->Pde[KpcrPageTableIndexPae].PageFrameNumber = PaPtrToPfn(kpcr_pagetable_pae);
+
+ /* Set up Low Memory PTEs */
+ PageDirPae = (PPAGE_DIRECTORY_X64)&lowmem_pagetable_pae;
+ for (i=0; i<1024; i++) {
+
+ PageDirPae->Pde[i].Valid = 1;
+ PageDirPae->Pde[i].Write = 1;
+ PageDirPae->Pde[i].Owner = 1;
+ PageDirPae->Pde[i].PageFrameNumber = i;
+ }
+
+ /* Set up Kernel PTEs */
+ PageDirPae = (PPAGE_DIRECTORY_X64)&kernel_pagetable_pae;
+ for (i=0; i<1536; i++) {
+
+ PageDirPae->Pde[i].Valid = 1;
+ PageDirPae->Pde[i].Write = 1;
+ PageDirPae->Pde[i].PageFrameNumber = PaToPfn(KERNEL_BASE_PHYS) + i;
+ }
+
+ /* Set up APIC PTEs */
+ PageDirPae = (PPAGE_DIRECTORY_X64)&apic_pagetable_pae;
+ PageDirPae->Pde[0].Valid = 1;
+ PageDirPae->Pde[0].Write = 1;
+ PageDirPae->Pde[0].CacheDisable = 1;
+ PageDirPae->Pde[0].WriteThrough = 1;
+ PageDirPae->Pde[0].PageFrameNumber = PaToPfn(APIC_BASE);
+ PageDirPae->Pde[0x200].Valid = 1;
+ PageDirPae->Pde[0x200].Write = 1;
+ PageDirPae->Pde[0x200].CacheDisable = 1;
+ PageDirPae->Pde[0x200].WriteThrough = 1;
+ PageDirPae->Pde[0x200].PageFrameNumber = PaToPfn(APIC_BASE + KERNEL_BASE_PHYS);
+
+ /* Set up KPCR PTEs */
+ PageDirPae = (PPAGE_DIRECTORY_X64)&kpcr_pagetable_pae;
+ PageDirPae->Pde[0].Valid = 1;
+ PageDirPae->Pde[0].Write = 1;
+ PageDirPae->Pde[0].PageFrameNumber = 1;
+
+ } else {
+
+ /* Get the Kernel Table Index */
+ KernelPageTableIndex = (KernelBase >> PDE_SHIFT) / sizeof(HARDWARE_PTE_X86);
+
+ /* Get the Startup Page Directory */
+ PageDir = (PPAGE_DIRECTORY_X86)&startup_pagedirectory;
+
+ /* Set up the Low Memory PDE */
+ PageDir->Pde[LowMemPageTableIndex].Valid = 1;
+ PageDir->Pde[LowMemPageTableIndex].Write = 1;
+ PageDir->Pde[LowMemPageTableIndex].PageFrameNumber = PaPtrToPfn(lowmem_pagetable);
+
+ /* Set up the Kernel PDEs */
+ PageDir->Pde[KernelPageTableIndex].Valid = 1;
+ PageDir->Pde[KernelPageTableIndex].Write = 1;
+ PageDir->Pde[KernelPageTableIndex].PageFrameNumber = PaPtrToPfn(kernel_pagetable);
+ PageDir->Pde[KernelPageTableIndex + 1].Valid = 1;
+ PageDir->Pde[KernelPageTableIndex + 1].Write = 1;
+ PageDir->Pde[KernelPageTableIndex + 1].PageFrameNumber = PaPtrToPfn(kernel_pagetable + 4096);
+
+ /* Set up the Startup PDE */
+ PageDir->Pde[StartupPageTableIndex].Valid = 1;
+ PageDir->Pde[StartupPageTableIndex].Write = 1;
+ PageDir->Pde[StartupPageTableIndex].PageFrameNumber = PaPtrToPfn(startup_pagedirectory);
+
+ /* Set up the Hyperspace PDE */
+ PageDir->Pde[HyperspacePageTableIndex].Valid = 1;
+ PageDir->Pde[HyperspacePageTableIndex].Write = 1;
+ PageDir->Pde[HyperspacePageTableIndex].PageFrameNumber = PaPtrToPfn(hyperspace_pagetable);
+
+ /* Set up the Apic PDE */
+ PageDir->Pde[ApicPageTableIndex].Valid = 1;
+ PageDir->Pde[ApicPageTableIndex].Write = 1;
+ PageDir->Pde[ApicPageTableIndex].PageFrameNumber = PaPtrToPfn(apic_pagetable);
+
+ /* Set up the KPCR PDE */
+ PageDir->Pde[KpcrPageTableIndex].Valid = 1;
+ PageDir->Pde[KpcrPageTableIndex].Write = 1;
+ PageDir->Pde[KpcrPageTableIndex].PageFrameNumber = PaPtrToPfn(kpcr_pagetable);
+
+ /* Set up Low Memory PTEs */
+ PageDir = (PPAGE_DIRECTORY_X86)&lowmem_pagetable;
+ for (i=0; i<1024; i++) {
+
+ PageDir->Pde[i].Valid = 1;
+ PageDir->Pde[i].Write = 1;
+ PageDir->Pde[i].Owner = 1;
+ PageDir->Pde[i].PageFrameNumber = PaToPfn(i * PAGE_SIZE);
+ }
+
+ /* Set up Kernel PTEs */
+ PageDir = (PPAGE_DIRECTORY_X86)&kernel_pagetable;
+ for (i=0; i<1536; i++) {
+
+ PageDir->Pde[i].Valid = 1;
+ PageDir->Pde[i].Write = 1;
+ PageDir->Pde[i].PageFrameNumber = PaToPfn(KERNEL_BASE_PHYS + i * PAGE_SIZE);
+ }
+
+ /* Set up APIC PTEs */
+ PageDir = (PPAGE_DIRECTORY_X86)&apic_pagetable;
+ PageDir->Pde[0].Valid = 1;
+ PageDir->Pde[0].Write = 1;
+ PageDir->Pde[0].CacheDisable = 1;
+ PageDir->Pde[0].WriteThrough = 1;
+ PageDir->Pde[0].PageFrameNumber = PaToPfn(APIC_BASE);
+ PageDir->Pde[0x200].Valid = 1;
+ PageDir->Pde[0x200].Write = 1;
+ PageDir->Pde[0x200].CacheDisable = 1;
+ PageDir->Pde[0x200].WriteThrough = 1;
+ PageDir->Pde[0x200].PageFrameNumber = PaToPfn(APIC_BASE + KERNEL_BASE_PHYS);
+
+ /* Set up KPCR PTEs */
+ PageDir = (PPAGE_DIRECTORY_X86)&kpcr_pagetable;
+ PageDir->Pde[0].Valid = 1;
+ PageDir->Pde[0].Write = 1;
+ PageDir->Pde[0].PageFrameNumber = 1;
+ }
+ return;
+}
+
+/*++
+ * FrLdrMapKernel
+ * INTERNAL
+ *
+ * Maps the Kernel into memory, does PE Section Mapping, initalizes the
+ * uninitialized data sections, and relocates the image.
+ *
+ * Params:
+ * KernelImage - FILE Structure representing the ntoskrnl image file.
+ *
+ * Returns:
+ * TRUE if the Kernel was mapped.
+ *
+ * Remarks:
+ * None.
+ *
+ *--*/
+BOOL
+STDCALL
+FrLdrMapKernel(FILE *KernelImage)
+{
+ PIMAGE_DOS_HEADER ImageHeader;
+ PIMAGE_NT_HEADERS NtHeader;
+ PIMAGE_SECTION_HEADER Section;
+ ULONG SectionCount;
+ ULONG ImageSize;
+ ULONG_PTR SourceSection;
+ ULONG_PTR TargetSection;
+ ULONG SectionSize;
+ LONG i;
+
+ /* Allocate 1024 bytes for PE Header */
+ ImageHeader = (PIMAGE_DOS_HEADER)MmAllocateMemory(1024);
+
+ /* Make sure it was succesful */
+ if (ImageHeader == NULL) {
+
+ return FALSE;
+ }
+
+ /* Load the first 1024 bytes of the kernel image so we can read the PE header */
+ if (!FsReadFile(KernelImage, 1024, NULL, ImageHeader)) {
+
+ /* Fail if we couldn't read */
+ MmFreeMemory(ImageHeader);
+ return FALSE;
+ }
+
+ /* Now read the MZ header to get the offset to the PE Header */
+ NtHeader = (PIMAGE_NT_HEADERS)((PCHAR)ImageHeader + ImageHeader->e_lfanew);
+
+ /* Save the Image Base */
+ KernelBase = NtHeader->OptionalHeader.ImageBase;
+
+ /* Save Entrypoint */
+ KernelEntry = RaToPa(NtHeader->OptionalHeader.AddressOfEntryPoint);
+
+ /* Save the Image Size */
+ ImageSize = NtHeader->OptionalHeader.SizeOfImage;
+
+ /* Free the Header */
+ MmFreeMemory(ImageHeader);
+
+ /* Set the file pointer to zero */
+ FsSetFilePointer(KernelImage, 0);
+
+ /* Load the file image */
+ FsReadFile(KernelImage, ImageSize, NULL, (PVOID)KERNEL_BASE_PHYS);
+
+ /* Reload the NT Header */
+ NtHeader = (PIMAGE_NT_HEADERS)((PCHAR)KERNEL_BASE_PHYS + ImageHeader->e_lfanew);
+
+ /* Load the first section */
+ Section = IMAGE_FIRST_SECTION(NtHeader);
+ SectionCount = NtHeader->FileHeader.NumberOfSections - 1;
+
+ /* Now go to the last section */
+ Section += SectionCount;
+
+ /* Walk each section backwards */
+ for (i=SectionCount; i >= 0; i--, Section--) {
+
+ /* Get the disk location and the memory location, and the size */
+ SourceSection = RaToPa(Section->PointerToRawData);
+ TargetSection = RaToPa(Section->VirtualAddress);
+ SectionSize = Section->SizeOfRawData;
+
+ /* If the section is already mapped correctly, go to the next */
+ if (SourceSection == TargetSection) continue;
+
+ /* Load it into memory */
+ memmove((PVOID)TargetSection, (PVOID)SourceSection, SectionSize);
+
+ /* Check for unitilizated data */
+ if (Section->SizeOfRawData < Section->Misc.VirtualSize) {
+
+ /* Zero it out */
+ memset((PVOID)RaToPa(Section->VirtualAddress + Section->SizeOfRawData),
+ 0,
+ Section->Misc.VirtualSize - Section->SizeOfRawData);
+ }
+ }
+
+ /* Now relocate the file */
+ /* FIXME: ADD RELOC CODE */
+
+ /* Increase the next Load Base */
+ NextModuleBase = ROUND_UP(KERNEL_BASE_PHYS + ImageSize, PAGE_SIZE);
+
+ /* Return Success */
+ return TRUE;
+}
+
+ULONG_PTR
+STDCALL
+FrLdrLoadModule(FILE *ModuleImage,
+ LPSTR ModuleName,
+ PULONG ModuleSize)
+{
+ ULONG LocalModuleSize;
+ PFRLDR_MODULE ModuleData;
+ LPSTR NameBuffer;
+ LPSTR TempName;
+
+ /* Get current module data structure and module name string array */
+ ModuleData = &multiboot_modules[LoaderBlock.ModsCount];
+
+ /* Get only the Module Name */
+ do {
+
+ TempName = strchr(ModuleName, '\\');
+
+ if(TempName) {
+ ModuleName = TempName + 1;
+ }
+
+ } while(TempName);
+ NameBuffer = multiboot_module_strings[LoaderBlock.ModsCount];
+
+ /* Get Module Size */
+ LocalModuleSize = FsGetFileSize(ModuleImage);
+
+ /* Fill out Module Data Structure */
+ ModuleData->ModuleStart = NextModuleBase;
+ ModuleData->ModuleEnd = NextModuleBase + LocalModuleSize;
+
+ /* Save name */
+ strcpy(NameBuffer, ModuleName);
+ ModuleData->ModuleName = NameBuffer;
+
+ /* Load the file image */
+ FsReadFile(ModuleImage, LocalModuleSize, NULL, (PVOID)NextModuleBase);
+
+ /* Move to next memory block and increase Module Count */
+ NextModuleBase = ROUND_UP(ModuleData->ModuleEnd, PAGE_SIZE);
+ LoaderBlock.ModsCount++;
+
+ /* Return Module Size if required */
+ if (ModuleSize != NULL) {
+ *ModuleSize = LocalModuleSize;
+ }
+
+ return(ModuleData->ModuleStart);
+}
+
+ULONG_PTR
+STDCALL
+FrLdrCreateModule(LPSTR ModuleName)
+{
+ PFRLDR_MODULE ModuleData;
+ LPSTR NameBuffer;
+
+ /* Get current module data structure and module name string array */
+ ModuleData = &multiboot_modules[LoaderBlock.ModsCount];
+ NameBuffer = multiboot_module_strings[LoaderBlock.ModsCount];
+
+ /* Set up the structure */
+ ModuleData->ModuleStart = NextModuleBase;
+ ModuleData->ModuleEnd = -1;
+
+ /* Copy the name */
+ strcpy(NameBuffer, ModuleName);
+ ModuleData->ModuleName = NameBuffer;
+
+ /* Set the current Module */
+ CurrentModule = ModuleData;
+
+ /* Return Module Base Address */
+ return(ModuleData->ModuleStart);
+}
+
+BOOL
+STDCALL
+FrLdrCloseModule(ULONG_PTR ModuleBase,
+ ULONG ModuleSize)
+{
+ PFRLDR_MODULE ModuleData = CurrentModule;
+
+ /* Make sure a module is opened */
+ if (ModuleData) {
+
+ /* Make sure this is the right module and that it hasn't been closed */
+ if ((ModuleBase == ModuleData->ModuleStart) && (ModuleData->ModuleEnd == -1)) {
+
+ /* Close the Module */
+ ModuleData->ModuleEnd = ModuleData->ModuleStart + ModuleSize;
+
+ /* Set the next Module Base and increase the number of modules */
+ NextModuleBase = ROUND_UP(ModuleData->ModuleEnd, PAGE_SIZE);
+ LoaderBlock.ModsCount++;
+
+ /* Close the currently opened module */
+ CurrentModule = NULL;
+
+ /* Success */
+ return(TRUE);
+ }
+ }
+
+ /* Failure path */
+ return(FALSE);
}
diff --git a/reactos/boot/freeldr/freeldr/options.c b/reactos/boot/freeldr/freeldr/options.c
index e56480c4703..4260283905f 100644
--- a/reactos/boot/freeldr/freeldr/options.c
+++ b/reactos/boot/freeldr/freeldr/options.c
@@ -67,11 +67,11 @@ enum OptionMenuItems
REBOOT = 11,
};
-U32 OptionsMenuItemCount = sizeof(OptionsMenuList) / sizeof(OptionsMenuList[0]);
+ULONG OptionsMenuItemCount = sizeof(OptionsMenuList) / sizeof(OptionsMenuList[0]);
VOID DoOptionsMenu(VOID)
{
- U32 SelectedMenuItem;
+ ULONG SelectedMenuItem;
if (!UiDisplayMenu(OptionsMenuList, OptionsMenuItemCount, 0, -1, &SelectedMenuItem, TRUE, NULL))
{
diff --git a/reactos/boot/freeldr/freeldr/oslist.c b/reactos/boot/freeldr/freeldr/oslist.c
index 8c2c5b5eb45..4dbe7ed13f8 100644
--- a/reactos/boot/freeldr/freeldr/oslist.c
+++ b/reactos/boot/freeldr/freeldr/oslist.c
@@ -24,16 +24,16 @@
#include
#include
-BOOL InitOperatingSystemList(PUCHAR **SectionNamesPointer, PUCHAR **DisplayNamesPointer, U32* OperatingSystemCountPointer)
+BOOL InitOperatingSystemList(PUCHAR **SectionNamesPointer, PUCHAR **DisplayNamesPointer, ULONG* OperatingSystemCountPointer)
{
- U32 Idx;
- U32 CurrentOperatingSystemIndex;
+ ULONG Idx;
+ ULONG CurrentOperatingSystemIndex;
UCHAR SettingName[260];
UCHAR SettingValue[260];
- U32 OperatingSystemCount;
- U32 SectionId;
- U32 OperatingSystemSectionId;
- U32 SectionSettingCount;
+ ULONG OperatingSystemCount;
+ ULONG SectionId;
+ ULONG OperatingSystemSectionId;
+ ULONG SectionSettingCount;
PUCHAR *OperatingSystemSectionNames;
PUCHAR *OperatingSystemDisplayNames;
@@ -85,13 +85,13 @@ BOOL InitOperatingSystemList(PUCHAR **SectionNamesPointer, PUCHAR **DisplayNames
return TRUE;
}
-U32 CountOperatingSystems(U32 SectionId)
+ULONG CountOperatingSystems(ULONG SectionId)
{
- U32 Idx;
+ ULONG Idx;
UCHAR SettingName[260];
UCHAR SettingValue[260];
- U32 OperatingSystemCount = 0;
- U32 SectionSettingCount;
+ ULONG OperatingSystemCount = 0;
+ ULONG SectionSettingCount;
//
// Loop through and count the operating systems
@@ -115,9 +115,9 @@ U32 CountOperatingSystems(U32 SectionId)
return OperatingSystemCount;
}
-BOOL AllocateListMemory(PUCHAR **SectionNamesPointer, PUCHAR **DisplayNamesPointer, U32 OperatingSystemCount)
+BOOL AllocateListMemory(PUCHAR **SectionNamesPointer, PUCHAR **DisplayNamesPointer, ULONG OperatingSystemCount)
{
- U32 Idx;
+ ULONG Idx;
PUCHAR *OperatingSystemSectionNames = NULL;
PUCHAR *OperatingSystemDisplayNames = NULL;
diff --git a/reactos/boot/freeldr/freeldr/reactos/arcname.c b/reactos/boot/freeldr/freeldr/reactos/arcname.c
index 94304459cab..9b1f1487cca 100644
--- a/reactos/boot/freeldr/freeldr/reactos/arcname.c
+++ b/reactos/boot/freeldr/freeldr/reactos/arcname.c
@@ -23,7 +23,7 @@
#include
-BOOL DissectArcPath(char *ArcPath, char *BootPath, U32* BootDrive, U32* BootPartition)
+BOOL DissectArcPath(char *ArcPath, char *BootPath, ULONG* BootDrive, ULONG* BootPartition)
{
char *p;
@@ -73,7 +73,7 @@ BOOL DissectArcPath(char *ArcPath, char *BootPath, U32* BootDrive, U32* BootPart
return TRUE;
}
-void ConstructArcPath(PUCHAR ArcPath, PUCHAR SystemFolder, U32 Disk, U32 Partition)
+void ConstructArcPath(PUCHAR ArcPath, PUCHAR SystemFolder, ULONG Disk, ULONG Partition)
{
char tmp[50];
@@ -109,10 +109,10 @@ void ConstructArcPath(PUCHAR ArcPath, PUCHAR SystemFolder, U32 Disk, U32 Partiti
}
}
-U32 ConvertArcNameToBiosDriveNumber(PUCHAR ArcPath)
+ULONG ConvertArcNameToBiosDriveNumber(PUCHAR ArcPath)
{
char * p;
- U32 DriveNumber = 0;
+ ULONG DriveNumber = 0;
if (strnicmp(ArcPath, "multi(0)disk(0)", 15) != 0)
return 0;
diff --git a/reactos/boot/freeldr/freeldr/reactos/binhive.c b/reactos/boot/freeldr/freeldr/reactos/binhive.c
index 60f7329253c..8a94e812a8e 100644
--- a/reactos/boot/freeldr/freeldr/reactos/binhive.c
+++ b/reactos/boot/freeldr/freeldr/reactos/binhive.c
@@ -45,119 +45,119 @@
/* BLOCK_OFFSET = offset in file after header block */
-typedef U32 BLOCK_OFFSET, *PBLOCK_OFFSET;
+typedef ULONG BLOCK_OFFSET, *PBLOCK_OFFSET;
/* header for registry hive file : */
typedef struct _HIVE_HEADER
{
/* Hive identifier "regf" (0x66676572) */
- U32 BlockId;
+ ULONG BlockId;
/* Update counter */
- U32 UpdateCounter1;
+ ULONG UpdateCounter1;
/* Update counter */
- U32 UpdateCounter2;
+ ULONG UpdateCounter2;
/* When this hive file was last modified */
- U64 DateModified; /* FILETIME */
+ ULONGLONG DateModified; /* FILETIME */
/* Registry format version ? (1?) */
- U32 Unused3;
+ ULONG Unused3;
/* Registry format version ? (3?) */
- U32 Unused4;
+ ULONG Unused4;
/* Registry format version ? (0?) */
- U32 Unused5;
+ ULONG Unused5;
/* Registry format version ? (1?) */
- U32 Unused6;
+ ULONG Unused6;
/* Offset into file from the byte after the end of the base block.
If the hive is volatile, this is the actual pointer to the KEY_CELL */
BLOCK_OFFSET RootKeyOffset;
/* Size of each hive block ? */
- U32 BlockSize;
+ ULONG BlockSize;
/* (1?) */
- U32 Unused7;
+ ULONG Unused7;
/* Name of hive file */
WCHAR FileName[64];
/* ? */
- U32 Unused8[83];
+ ULONG Unused8[83];
/* Checksum of first 0x200 bytes */
- U32 Checksum;
+ ULONG Checksum;
} __attribute__((packed)) HIVE_HEADER, *PHIVE_HEADER;
typedef struct _BIN_HEADER
{
/* Bin identifier "hbin" (0x6E696268) */
- U32 HeaderId;
+ ULONG HeaderId;
/* Bin offset */
BLOCK_OFFSET BinOffset;
/* Size in bytes, multiple of the block size (4KB) */
- U32 BinSize;
+ ULONG BinSize;
/* ? */
- U32 Unused1;
+ ULONG Unused1;
/* When this bin was last modified */
- U64 DateModified; /* FILETIME */
+ ULONGLONG DateModified; /* FILETIME */
/* ? */
- U32 Unused2;
+ ULONG Unused2;
} __attribute__((packed)) HBIN, *PHBIN;
typedef struct _CELL_HEADER
{
/* <0 if used, >0 if free */
- S32 CellSize;
+ LONG CellSize;
} __attribute__((packed)) CELL_HEADER, *PCELL_HEADER;
typedef struct _KEY_CELL
{
/* Size of this cell */
- S32 CellSize;
+ LONG CellSize;
/* Key cell identifier "kn" (0x6b6e) */
- U16 Id;
+ USHORT Id;
/* ? */
- U16 Type;
+ USHORT Type;
/* Time of last flush */
- U64 LastWriteTime; /* FILETIME */
+ ULONGLONG LastWriteTime; /* FILETIME */
/* ? */
- U32 UnUsed1;
+ ULONG UnUsed1;
/* Block offset of parent key cell */
BLOCK_OFFSET ParentKeyOffset;
/* Count of sub keys for the key in this key cell */
- U32 NumberOfSubKeys;
+ ULONG NumberOfSubKeys;
/* ? */
- U32 UnUsed2;
+ ULONG UnUsed2;
/* Block offset of has table for FIXME: subkeys/values? */
BLOCK_OFFSET HashTableOffset;
/* ? */
- U32 UnUsed3;
+ ULONG UnUsed3;
/* Count of values contained in this key cell */
- U32 NumberOfValues;
+ ULONG NumberOfValues;
/* Block offset of VALUE_LIST_CELL */
BLOCK_OFFSET ValueListOffset;
@@ -169,16 +169,16 @@ typedef struct _KEY_CELL
BLOCK_OFFSET ClassNameOffset;
/* ? */
- U32 Unused4[5];
+ ULONG Unused4[5];
/* Size in bytes of key name */
- U16 NameSize;
+ USHORT NameSize;
/* Size of class name in bytes */
- U16 ClassSize;
+ USHORT ClassSize;
/* Name of key (not zero terminated) */
- U8 Name[0];
+ UCHAR Name[0];
} __attribute__((packed)) KEY_CELL, *PKEY_CELL;
@@ -193,36 +193,36 @@ typedef struct _KEY_CELL
typedef struct _HASH_RECORD
{
BLOCK_OFFSET KeyOffset;
- U32 HashValue;
+ ULONG HashValue;
} __attribute__((packed)) HASH_RECORD, *PHASH_RECORD;
typedef struct _HASH_TABLE_CELL
{
- S32 CellSize;
- U16 Id;
- U16 HashTableSize;
+ LONG CellSize;
+ USHORT Id;
+ USHORT HashTableSize;
HASH_RECORD Table[0];
} __attribute__((packed)) HASH_TABLE_CELL, *PHASH_TABLE_CELL;
typedef struct _VALUE_LIST_CELL
{
- S32 CellSize;
+ LONG CellSize;
BLOCK_OFFSET ValueOffset[0];
} __attribute__((packed)) VALUE_LIST_CELL, *PVALUE_LIST_CELL;
typedef struct _VALUE_CELL
{
- S32 CellSize;
- U16 Id; // "kv"
- U16 NameSize; // length of Name
- U32 DataSize; // length of datas in the cell pointed by DataOffset
+ LONG CellSize;
+ USHORT Id; // "kv"
+ USHORT NameSize; // length of Name
+ ULONG DataSize; // length of datas in the cell pointed by DataOffset
BLOCK_OFFSET DataOffset;// datas are here if high bit of DataSize is set
- U32 DataType;
- U16 Flags;
- U16 Unused1;
+ ULONG DataType;
+ USHORT Flags;
+ USHORT Unused1;
UCHAR Name[0]; /* warning : not zero terminated */
} __attribute__((packed)) VALUE_CELL, *PVALUE_CELL;
@@ -236,26 +236,26 @@ typedef struct _VALUE_CELL
typedef struct _DATA_CELL
{
- S32 CellSize;
+ LONG CellSize;
UCHAR Data[0];
} __attribute__((packed)) DATA_CELL, *PDATA_CELL;
typedef struct _REGISTRY_HIVE
{
- U32 FileSize;
+ ULONG FileSize;
PHIVE_HEADER HiveHeader;
- U32 BlockListSize;
+ ULONG BlockListSize;
PHBIN *BlockList;
- U32 FreeListSize;
- U32 FreeListMax;
+ ULONG FreeListSize;
+ ULONG FreeListMax;
PCELL_HEADER *FreeList;
BLOCK_OFFSET *FreeListOffset;
} REGISTRY_HIVE, *PREGISTRY_HIVE;
static PVOID MbBase = NULL;
-static U32 MbSize = 0;
+static ULONG MbSize = 0;
/* FUNCTIONS ****************************************************************/
@@ -268,13 +268,13 @@ InitMbMemory (PVOID ChunkBase)
static PVOID
-AllocateMbMemory (U32 MemSize)
+AllocateMbMemory (ULONG MemSize)
{
PVOID CurBase;
CurBase = MbBase;
- MbBase = (PVOID)((U32)MbBase + MemSize);
+ MbBase = (PVOID)((ULONG)MbBase + MemSize);
MbSize += MemSize;
return CurBase;
@@ -286,7 +286,7 @@ FreeMbMemory (VOID)
MbSize = 0;
}
-static U32
+static ULONG
GetMbAllocatedSize (VOID)
{
return MbSize;
@@ -329,8 +329,8 @@ static VOID
CmiCreateDefaultRootKeyCell (PKEY_CELL RootKeyCell, PCHAR KeyName)
{
PCHAR BaseKeyName;
- U32 NameSize;
- U32 CellSize;
+ ULONG NameSize;
+ ULONG CellSize;
assert (RootKeyCell);
@@ -428,12 +428,12 @@ CmiCreateHive (PCHAR KeyName)
BinCell->BinOffset = 0;
/* Init root key cell */
- RootKeyCell = (PKEY_CELL)((U32)BinCell + REG_HBIN_DATA_OFFSET);
+ RootKeyCell = (PKEY_CELL)((ULONG)BinCell + REG_HBIN_DATA_OFFSET);
CmiCreateDefaultRootKeyCell(RootKeyCell, KeyName);
Hive->HiveHeader->RootKeyOffset = REG_HBIN_DATA_OFFSET;
/* Init free cell */
- FreeCell = (PCELL_HEADER)((U32)RootKeyCell - RootKeyCell->CellSize);
+ FreeCell = (PCELL_HEADER)((ULONG)RootKeyCell - RootKeyCell->CellSize);
FreeCell->CellSize = REG_BLOCK_SIZE - (REG_HBIN_DATA_OFFSET - RootKeyCell->CellSize);
Hive->FreeList[0] = FreeCell;
@@ -463,9 +463,9 @@ static PHBIN
CmiGetBin (PREGISTRY_HIVE Hive,
BLOCK_OFFSET BlockOffset)
{
- U32 BlockIndex;
+ ULONG BlockIndex;
- if (BlockOffset == (U32) -1)
+ if (BlockOffset == (ULONG) -1)
return NULL;
BlockIndex = BlockOffset / REG_BLOCK_SIZE;
@@ -483,10 +483,10 @@ CmiMergeFree(PREGISTRY_HIVE RegistryHive,
{
BLOCK_OFFSET BlockOffset;
BLOCK_OFFSET BinOffset;
- U32 BlockSize;
- U32 BinSize;
+ ULONG BlockSize;
+ ULONG BinSize;
PHBIN Bin;
- U32 i;
+ ULONG i;
DbgPrint((DPRINT_REGISTRY, "CmiMergeFree(Block %lx Offset %lx Size %lx) called\n",
FreeBlock, FreeOffset, FreeBlock->CellSize));
@@ -574,9 +574,9 @@ CmiAddFree(PREGISTRY_HIVE RegistryHive,
{
PCELL_HEADER *tmpList;
BLOCK_OFFSET *tmpListOffset;
- S32 minInd;
- S32 maxInd;
- S32 medInd;
+ LONG minInd;
+ LONG maxInd;
+ LONG medInd;
assert(RegistryHive);
assert(FreeBlock);
@@ -675,15 +675,15 @@ CmiAddFree(PREGISTRY_HIVE RegistryHive,
static BOOL
CmiAddBin(PREGISTRY_HIVE RegistryHive,
- U32 BlockCount,
+ ULONG BlockCount,
PVOID *NewBlock,
PBLOCK_OFFSET NewBlockOffset)
{
PCELL_HEADER tmpBlock;
PHBIN *BlockList;
PHBIN tmpBin;
- U32 BinSize;
- U32 i;
+ ULONG BinSize;
+ ULONG i;
BinSize = BlockCount * REG_BLOCK_SIZE;
tmpBin = AllocateMbMemory (BinSize);
@@ -722,7 +722,7 @@ CmiAddBin(PREGISTRY_HIVE RegistryHive,
RegistryHive->BlockListSize += BlockCount;
/* Initialize a free block in this heap : */
- tmpBlock = (PCELL_HEADER)((U32) tmpBin + REG_HBIN_DATA_OFFSET);
+ tmpBlock = (PCELL_HEADER)((ULONG) tmpBin + REG_HBIN_DATA_OFFSET);
tmpBlock->CellSize = (REG_BLOCK_SIZE - REG_HBIN_DATA_OFFSET);
*NewBlock = (PVOID) tmpBlock;
@@ -736,12 +736,12 @@ CmiAddBin(PREGISTRY_HIVE RegistryHive,
static BOOL
CmiAllocateCell (PREGISTRY_HIVE RegistryHive,
- S32 CellSize,
+ LONG CellSize,
PVOID *Block,
PBLOCK_OFFSET pBlockOffset)
{
PCELL_HEADER NewBlock;
- U32 i;
+ ULONG i;
*Block = NULL;
@@ -790,7 +790,7 @@ CmiAllocateCell (PREGISTRY_HIVE RegistryHive,
/* Split the block in two parts */
if (NewBlock->CellSize > CellSize)
{
- NewBlock = (PCELL_HEADER) ((U32)NewBlock + CellSize);
+ NewBlock = (PCELL_HEADER) ((ULONG)NewBlock + CellSize);
NewBlock->CellSize = ((PCELL_HEADER) (*Block))->CellSize - CellSize;
CmiAddFree (RegistryHive,
NewBlock,
@@ -814,9 +814,9 @@ CmiGetCell (PREGISTRY_HIVE Hive,
BLOCK_OFFSET BlockOffset)
{
PHBIN Bin;
- U32 BlockIndex;
+ ULONG BlockIndex;
- if (BlockOffset == (U32) -1)
+ if (BlockOffset == (ULONG) -1)
return NULL;
BlockIndex = BlockOffset / REG_BLOCK_SIZE;
@@ -827,17 +827,17 @@ CmiGetCell (PREGISTRY_HIVE Hive,
if (Bin == NULL)
return NULL;
- return (PVOID)((U32)Bin + (BlockOffset - Bin->BinOffset));
+ return (PVOID)((ULONG)Bin + (BlockOffset - Bin->BinOffset));
}
static BOOL
CmiAllocateHashTableCell (PREGISTRY_HIVE Hive,
PBLOCK_OFFSET HBOffset,
- U32 SubKeyCount)
+ ULONG SubKeyCount)
{
PHASH_TABLE_CELL HashCell;
- U32 NewHashSize;
+ ULONG NewHashSize;
BOOL Status;
NewHashSize = sizeof(HASH_TABLE_CELL) +
@@ -866,7 +866,7 @@ CmiAddKeyToParentHashTable (PREGISTRY_HIVE Hive,
{
PHASH_TABLE_CELL HashBlock;
PKEY_CELL ParentKeyCell;
- U32 i;
+ ULONG i;
ParentKeyCell = CmiGetCell (Hive, ParentKeyOffset);
if (ParentKeyCell == NULL)
@@ -902,10 +902,10 @@ CmiAddKeyToParentHashTable (PREGISTRY_HIVE Hive,
static BOOL
CmiAllocateValueListCell (PREGISTRY_HIVE Hive,
PBLOCK_OFFSET ValueListOffset,
- U32 ValueCount)
+ ULONG ValueCount)
{
PVALUE_LIST_CELL ValueListCell;
- U32 ValueListSize;
+ ULONG ValueListSize;
BOOL Status;
ValueListSize = sizeof(VALUE_LIST_CELL) +
@@ -931,7 +931,7 @@ CmiAllocateValueCell(PREGISTRY_HIVE Hive,
PCHAR ValueName)
{
PVALUE_CELL NewValueCell;
- U32 NameSize;
+ ULONG NameSize;
BOOL Status;
NameSize = (ValueName == NULL) ? 0 : strlen (ValueName);
@@ -996,9 +996,9 @@ CmiAddValueToKeyValueList(PREGISTRY_HIVE Hive,
static VOID
memexpand (PWCHAR Dst,
PCHAR Src,
- U32 Length)
+ ULONG Length)
{
- U32 i;
+ ULONG i;
for (i = 0; i < Length; i++)
Dst[i] = (WCHAR)Src[i];
@@ -1008,16 +1008,16 @@ memexpand (PWCHAR Dst,
static BOOL
CmiExportValue (PREGISTRY_HIVE Hive,
BLOCK_OFFSET KeyCellOffset,
- HKEY Key,
+ FRLDRHKEY Key,
PVALUE Value)
{
BLOCK_OFFSET ValueCellOffset;
BLOCK_OFFSET DataCellOffset;
PVALUE_CELL ValueCell;
PDATA_CELL DataCell;
- U32 SrcDataSize;
- U32 DstDataSize;
- U32 DataType;
+ ULONG SrcDataSize;
+ ULONG DstDataSize;
+ ULONG DataType;
PUCHAR Data;
BOOL Expand = FALSE;
@@ -1121,16 +1121,16 @@ CmiExportValue (PREGISTRY_HIVE Hive,
static BOOL
CmiExportSubKey (PREGISTRY_HIVE Hive,
BLOCK_OFFSET ParentKeyOffset,
- HKEY ParentKey,
- HKEY Key)
+ FRLDRHKEY ParentKey,
+ FRLDRHKEY Key)
{
BLOCK_OFFSET NKBOffset;
PKEY_CELL NewKeyCell;
- U32 KeyCellSize;
- U32 SubKeyCount;
- U32 ValueCount;
+ ULONG KeyCellSize;
+ ULONG SubKeyCount;
+ ULONG ValueCount;
PLIST_ENTRY Entry;
- HKEY SubKey;
+ FRLDRHKEY SubKey;
PVALUE Value;
DbgPrint((DPRINT_REGISTRY, "CmiExportSubKey('%s') called\n", Key->Name));
@@ -1243,11 +1243,11 @@ CmiExportSubKey (PREGISTRY_HIVE Hive,
static VOID
CmiCalcHiveChecksum (PREGISTRY_HIVE Hive)
{
- U32 *Buffer;
- U32 Sum;
- U32 i;
+ ULONG *Buffer;
+ ULONG Sum;
+ ULONG i;
- Buffer = (U32*)Hive->HiveHeader;
+ Buffer = (ULONG*)Hive->HiveHeader;
Sum = 0;
for (i = 0; i < 127; i++)
Sum += Buffer[i];
@@ -1261,11 +1261,11 @@ CmiExportHive (PREGISTRY_HIVE Hive,
PCHAR KeyName)
{
PKEY_CELL KeyCell;
- HKEY Key;
- U32 SubKeyCount;
- U32 ValueCount;
+ FRLDRHKEY Key;
+ ULONG SubKeyCount;
+ ULONG ValueCount;
PLIST_ENTRY Entry;
- HKEY SubKey;
+ FRLDRHKEY SubKey;
PVALUE Value;
DbgPrint((DPRINT_REGISTRY, "CmiExportHive(%x, '%s') called\n", Hive, KeyName));
@@ -1354,16 +1354,16 @@ CmiExportHive (PREGISTRY_HIVE Hive,
static BOOL
RegImportValue (PHBIN RootBin,
PVALUE_CELL ValueCell,
- HKEY Key)
+ FRLDRHKEY Key)
{
PDATA_CELL DataCell;
PWCHAR wName;
PCHAR cName;
- S32 Error;
- S32 DataSize;
+ LONG Error;
+ LONG DataSize;
PCHAR cBuffer;
PWCHAR wBuffer;
- S32 i;
+ LONG i;
if (ValueCell->CellSize >= 0 || ValueCell->Id != REG_VALUE_CELL_ID)
{
@@ -1461,16 +1461,16 @@ RegImportValue (PHBIN RootBin,
static BOOL
RegImportSubKey(PHBIN RootBin,
PKEY_CELL KeyCell,
- HKEY ParentKey)
+ FRLDRHKEY ParentKey)
{
PHASH_TABLE_CELL HashCell;
PKEY_CELL SubKeyCell;
PVALUE_LIST_CELL ValueListCell;
PVALUE_CELL ValueCell = NULL;
PCHAR cName;
- HKEY SubKey;
- S32 Error;
- U32 i;
+ FRLDRHKEY SubKey;
+ LONG Error;
+ ULONG i;
DbgPrint((DPRINT_REGISTRY, "KeyCell: %x\n", KeyCell));
@@ -1548,16 +1548,16 @@ RegImportSubKey(PHBIN RootBin,
BOOL
RegImportBinaryHive(PCHAR ChunkBase,
- U32 ChunkSize)
+ ULONG ChunkSize)
{
PHIVE_HEADER HiveHeader;
PHBIN RootBin;
PKEY_CELL KeyCell;
PHASH_TABLE_CELL HashCell;
PKEY_CELL SubKeyCell;
- HKEY SystemKey;
- U32 i;
- S32 Error;
+ FRLDRHKEY SystemKey;
+ ULONG i;
+ LONG Error;
DbgPrint((DPRINT_REGISTRY, "RegImportBinaryHive(%x, %u) called\n",ChunkBase,ChunkSize));
@@ -1569,7 +1569,7 @@ RegImportBinaryHive(PCHAR ChunkBase,
return FALSE;
}
- RootBin = (PHBIN)((U32)HiveHeader + REG_BLOCK_SIZE);
+ RootBin = (PHBIN)((ULONG)HiveHeader + REG_BLOCK_SIZE);
DbgPrint((DPRINT_REGISTRY, "RootBin: %x\n", RootBin));
if (RootBin->HeaderId != REG_BIN_ID || RootBin->BinSize == 0)
{
@@ -1577,7 +1577,7 @@ RegImportBinaryHive(PCHAR ChunkBase,
return FALSE;
}
- KeyCell = (PKEY_CELL)((U32)RootBin + REG_HBIN_DATA_OFFSET);
+ KeyCell = (PKEY_CELL)((ULONG)RootBin + REG_HBIN_DATA_OFFSET);
DbgPrint((DPRINT_REGISTRY, "KeyCell: %x\n", KeyCell));
DbgPrint((DPRINT_REGISTRY, "KeyCell->CellSize: %x\n", KeyCell->CellSize));
DbgPrint((DPRINT_REGISTRY, "KeyCell->Id: %x\n", KeyCell->Id));
@@ -1603,14 +1603,14 @@ RegImportBinaryHive(PCHAR ChunkBase,
/* Enumerate and add subkeys */
if (KeyCell->NumberOfSubKeys > 0)
{
- HashCell = (PHASH_TABLE_CELL)((U32)RootBin + KeyCell->HashTableOffset);
+ HashCell = (PHASH_TABLE_CELL)((ULONG)RootBin + KeyCell->HashTableOffset);
DbgPrint((DPRINT_REGISTRY, "HashCell: %x\n", HashCell));
for (i = 0; i < KeyCell->NumberOfSubKeys; i++)
{
DbgPrint((DPRINT_REGISTRY, "KeyOffset[%d]: %x\n", i, HashCell->Table[i].KeyOffset));
- SubKeyCell = (PKEY_CELL)((U32)RootBin + HashCell->Table[i].KeyOffset);
+ SubKeyCell = (PKEY_CELL)((ULONG)RootBin + HashCell->Table[i].KeyOffset);
DbgPrint((DPRINT_REGISTRY, "SubKeyCell[%d]: %x\n", i, SubKeyCell));
@@ -1626,7 +1626,7 @@ RegImportBinaryHive(PCHAR ChunkBase,
BOOL
RegExportBinaryHive(PCHAR KeyName,
PCHAR ChunkBase,
- U32* ChunkSize)
+ ULONG* ChunkSize)
{
PREGISTRY_HIVE Hive;
diff --git a/reactos/boot/freeldr/freeldr/reactos/reactos.c b/reactos/boot/freeldr/freeldr/reactos/reactos.c
index fda39008d78..427f34e6c23 100644
--- a/reactos/boot/freeldr/freeldr/reactos/reactos.c
+++ b/reactos/boot/freeldr/freeldr/reactos/reactos.c
@@ -1,40 +1,19 @@
/*
- * FreeLoader
- *
- * Copyright (C) 1998-2003 Brian Palmer
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: Freeloader
+ * FILE: boot/freeldr/freeldr/reactos/rosboot.c
+ * PURPOSE: ReactOS Loader
+ * PROGRAMMERS: Alex Ionescu (alex@relsoft.net)
*/
#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
+#include
+#include
#include "registry.h"
-
#define NDEBUG
+#include
#define IsRecognizedPartition(P) \
((P) == PARTITION_FAT_12 || \
@@ -46,549 +25,561 @@
(P) == PARTITION_FAT32_XINT13 || \
(P) == PARTITION_XINT13)
-static BOOL
-LoadKernel(PCHAR szFileName, int nPos)
+BOOL
+STDCALL
+FrLdrLoadKernel(PCHAR szFileName,
+ INT nPos)
{
- PFILE FilePointer;
- PCHAR szShortName;
- char szBuffer[256];
+ PFILE FilePointer;
+ PCHAR szShortName;
+ CHAR szBuffer[256];
- szShortName = strrchr(szFileName, '\\');
- if (szShortName == NULL)
- szShortName = szFileName;
- else
- szShortName = szShortName + 1;
-
- FilePointer = FsOpenFile(szFileName);
- if (FilePointer == NULL)
- {
- strcpy(szBuffer, szShortName);
- strcat(szBuffer, " not found.");
- UiMessageBox(szBuffer);
- return(FALSE);
+ /* Extract Kernel filename without path */
+ szShortName = strrchr(szFileName, '\\');
+ if (szShortName == NULL) {
+
+ /* No path, leave it alone */
+ szShortName = szFileName;
+
+ } else {
+
+ /* Skip the path */
+ szShortName = szShortName + 1;
}
- /*
- * Update the status bar with the current file
- */
- strcpy(szBuffer, "Reading ");
- strcat(szBuffer, szShortName);
- UiDrawStatusText(szBuffer);
-
- /*
- * Load the kernel
- */
- MultiBootLoadKernel(FilePointer);
-
- UiDrawProgressBarCenter(nPos, 100, "Loading ReactOS...");
-
- return(TRUE);
-}
-
-static BOOL
-LoadSymbolFile(PCHAR szSystemRoot,
- PCHAR ModuleName,
- int nPos)
-{
- CHAR SymbolFileName[1024];
- PFILE FilePointer;
- U32 Length;
- PCHAR Start;
- PCHAR Ext;
- char value[256];
- char *p;
-
- /* Get the path to the symbol store */
- strcpy(SymbolFileName, szSystemRoot);
- strcat(SymbolFileName, "symbols\\");
-
- /* Get the symbol filename from the module name */
- Start = strrchr(ModuleName, '\\');
- if (Start == NULL)
- Start = ModuleName;
- else
- Start++;
-
- Ext = strrchr(ModuleName, '.');
- if (Ext != NULL)
- Length = Ext - Start;
- else
- Length = strlen(Start);
-
- strncat(SymbolFileName, Start, Length);
- strcat(SymbolFileName, ".sym");
-
- FilePointer = FsOpenFile((PCHAR)&SymbolFileName[0]);
- if (FilePointer == NULL)
- {
- DbgPrint((DPRINT_REACTOS, "Symbol file %s not loaded.\n", SymbolFileName));
- /* This is not critical */
- return FALSE;
+ /* Open the Kernel */
+ FilePointer = FsOpenFile(szFileName);
+
+ /* Make sure it worked */
+ if (FilePointer == NULL) {
+
+ /* Return failure on the short name */
+ strcpy(szBuffer, szShortName);
+ strcat(szBuffer, " not found.");
+ UiMessageBox(szBuffer);
+ return(FALSE);
}
- DbgPrint((DPRINT_REACTOS, "Symbol file %s is loaded.\n", SymbolFileName));
+ /* Update the status bar with the current file */
+ strcpy(szBuffer, "Reading ");
+ strcat(szBuffer, szShortName);
+ UiDrawStatusText(szBuffer);
- /*
- * Update the status bar with the current file
- */
- strcpy(value, "Reading ");
- p = strrchr(SymbolFileName, '\\');
- if (p == NULL)
- strcat(value, SymbolFileName);
- else
- strcat(value, p + 1);
- UiDrawStatusText(value);
+ /* Do the actual loading */
+ FrLdrMapKernel(FilePointer);
- /*
- * Load the symbol file
- */
- MultiBootLoadModule(FilePointer, SymbolFileName, NULL);
-
- UiDrawProgressBarCenter(nPos, 100, "Loading ReactOS...");
-
- return (TRUE);
+ /* Update Processbar and return success */
+ UiDrawProgressBarCenter(nPos, 100, "Loading ReactOS...");
+ return(TRUE);
}
-
-static BOOL
-LoadDriver(PCHAR szFileName, int nPos)
-{
- PFILE FilePointer;
- char value[256];
- char *p;
-
- FilePointer = FsOpenFile(szFileName);
- if (FilePointer == NULL)
- {
- strcpy(value, szFileName);
- strcat(value, " not found.");
- UiMessageBox(value);
- return(FALSE);
- }
-
- /*
- * Update the status bar with the current file
- */
- strcpy(value, "Reading ");
- p = strrchr(szFileName, '\\');
- if (p == NULL)
- strcat(value, szFileName);
- else
- strcat(value, p + 1);
- UiDrawStatusText(value);
-
- /*
- * Load the driver
- */
- MultiBootLoadModule(FilePointer, szFileName, NULL);
-
- UiDrawProgressBarCenter(nPos, 100, "Loading ReactOS...");
-
- return(TRUE);
-}
-
-
-static BOOL
-LoadNlsFile(PCHAR szFileName, PCHAR szModuleName)
-{
- PFILE FilePointer;
- char value[256];
- char *p;
-
- FilePointer = FsOpenFile(szFileName);
- if (FilePointer == NULL)
- {
- strcpy(value, szFileName);
- strcat(value, " not found.");
- UiMessageBox(value);
- return(FALSE);
- }
-
- /*
- * Update the status bar with the current file
- */
- strcpy(value, "Reading ");
- p = strrchr(szFileName, '\\');
- if (p == NULL)
- strcat(value, szFileName);
- else
- strcat(value, p + 1);
- UiDrawStatusText(value);
-
- /*
- * Load the driver
- */
- MultiBootLoadModule(FilePointer, szModuleName, NULL);
-
- return(TRUE);
-}
-
-
static VOID
-LoadBootDrivers(PCHAR szSystemRoot, int nPos)
+FreeldrFreeMem(PVOID Area)
{
- S32 rc = 0;
- HKEY hGroupKey, hOrderKey, hServiceKey, hDriverKey;
- char GroupNameBuffer[512];
- char ServiceName[256];
- U32 OrderList[128];
- U32 BufferSize;
- U32 Index;
- U32 TagIndex;
- char *GroupName;
-
- U32 ValueSize;
- U32 ValueType;
- U32 StartValue;
- U32 TagValue;
- UCHAR DriverGroup[256];
- U32 DriverGroupSize;
-
- UCHAR ImagePath[256];
- UCHAR TempImagePath[256];
-
- /* get 'service group order' key */
- rc = RegOpenKey(NULL,
- "\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\ServiceGroupOrder",
- &hGroupKey);
- if (rc != ERROR_SUCCESS)
- {
- DbgPrint((DPRINT_REACTOS, "Failed to open the 'ServiceGroupOrder' key (rc %d)\n", (int)rc));
- return;
- }
-
- /* get 'group order list' key */
- rc = RegOpenKey(NULL,
- "\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\GroupOrderList",
- &hOrderKey);
- if (rc != ERROR_SUCCESS)
- {
- DbgPrint((DPRINT_REACTOS, "Failed to open the 'GroupOrderList' key (rc %d)\n", (int)rc));
- return;
- }
-
- /* enumerate drivers */
- rc = RegOpenKey(NULL,
- "\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Services",
- &hServiceKey);
- if (rc != ERROR_SUCCESS)
- {
- DbgPrint((DPRINT_REACTOS, "Failed to open the 'Services' key (rc %d)\n", (int)rc));
- return;
- }
-
- BufferSize = sizeof(GroupNameBuffer);
- rc = RegQueryValue(hGroupKey, "List", NULL, (PUCHAR)GroupNameBuffer, &BufferSize);
- DbgPrint((DPRINT_REACTOS, "RegQueryValue(): rc %d\n", (int)rc));
- if (rc != ERROR_SUCCESS)
- return;
-
- DbgPrint((DPRINT_REACTOS, "BufferSize: %d \n", (int)BufferSize));
-
- DbgPrint((DPRINT_REACTOS, "GroupNameBuffer: '%s' \n", GroupNameBuffer));
-
- GroupName = GroupNameBuffer;
- while (*GroupName)
- {
- DbgPrint((DPRINT_REACTOS, "Driver group: '%s'\n", GroupName));
-
- BufferSize = sizeof(OrderList);
- rc = RegQueryValue(hOrderKey, GroupName, NULL, (PUCHAR)OrderList, &BufferSize);
- if (rc != ERROR_SUCCESS)
- {
- OrderList[0] = 0;
- }
-
- for (TagIndex = 1; TagIndex <= OrderList[0]; TagIndex++)
- {
- /* enumerate all drivers */
- Index = 0;
- while (TRUE)
- {
- ValueSize = sizeof(ServiceName);
- rc = RegEnumKey(hServiceKey, Index, ServiceName, &ValueSize);
- DbgPrint((DPRINT_REACTOS, "RegEnumKey(): rc %d\n", (int)rc));
- if (rc == ERROR_NO_MORE_ITEMS)
- break;
- if (rc != ERROR_SUCCESS)
- return;
- DbgPrint((DPRINT_REACTOS, "Service %d: '%s'\n", (int)Index, ServiceName));
-
- /* open driver Key */
- rc = RegOpenKey(hServiceKey, ServiceName, &hDriverKey);
-
- ValueSize = sizeof(U32);
- rc = RegQueryValue(hDriverKey, "Start", &ValueType, (PUCHAR)&StartValue, &ValueSize);
- DbgPrint((DPRINT_REACTOS, " Start: %x \n", (int)StartValue));
-
- ValueSize = sizeof(U32);
- rc = RegQueryValue(hDriverKey, "Tag", &ValueType, (PUCHAR)&TagValue, &ValueSize);
- if (rc != ERROR_SUCCESS)
- {
- TagValue = (U32)-1;
- }
- DbgPrint((DPRINT_REACTOS, " Tag: %x \n", (int)TagValue));
-
-
- DriverGroupSize = 256;
- rc = RegQueryValue(hDriverKey, "Group", NULL, (PUCHAR)DriverGroup, &DriverGroupSize);
- DbgPrint((DPRINT_REACTOS, " Group: '%s' \n", DriverGroup));
-
- if ((StartValue == 0) && (TagValue == OrderList[TagIndex]) &&(stricmp(DriverGroup, GroupName) == 0))
- {
- ValueSize = 256;
- rc = RegQueryValue(hDriverKey,
- "ImagePath",
- NULL,
- (PUCHAR)TempImagePath,
- &ValueSize);
- if (rc != ERROR_SUCCESS)
- {
- DbgPrint((DPRINT_REACTOS, " ImagePath: not found\n"));
- strcpy(ImagePath, szSystemRoot);
- strcat(ImagePath, "system32\\drivers\\");
- strcat(ImagePath, ServiceName);
- strcat(ImagePath, ".sys");
- }
- else if (TempImagePath[0] != '\\')
- {
- strcpy(ImagePath, szSystemRoot);
- strcat(ImagePath, TempImagePath);
- }
- else
- {
- strcpy(ImagePath, TempImagePath);
- DbgPrint((DPRINT_REACTOS, " ImagePath: '%s'\n", ImagePath));
- }
- DbgPrint((DPRINT_REACTOS, " Loading driver: '%s'\n", ImagePath));
-
- if (nPos < 100)
- nPos += 5;
-
- LoadDriver(ImagePath, nPos);
- LoadSymbolFile(szSystemRoot, ImagePath, nPos);
- }
- else
- {
- DbgPrint((DPRINT_REACTOS, " Skipping driver '%s' with Start %d, Tag %d and Group '%s' (Current Tag %d, current group '%s')\n",
- ServiceName, StartValue, TagValue, DriverGroup, OrderList[TagIndex], GroupName));
- }
- Index++;
- }
- }
-
- Index = 0;
- while (TRUE)
- {
- ValueSize = sizeof(ServiceName);
- rc = RegEnumKey(hServiceKey, Index, ServiceName, &ValueSize);
- DbgPrint((DPRINT_REACTOS, "RegEnumKey(): rc %d\n", (int)rc));
- if (rc == ERROR_NO_MORE_ITEMS)
- break;
- if (rc != ERROR_SUCCESS)
- return;
- DbgPrint((DPRINT_REACTOS, "Service %d: '%s'\n", (int)Index, ServiceName));
-
- /* open driver Key */
- rc = RegOpenKey(hServiceKey, ServiceName, &hDriverKey);
-
- ValueSize = sizeof(U32);
- rc = RegQueryValue(hDriverKey, "Start", &ValueType, (PUCHAR)&StartValue, &ValueSize);
- DbgPrint((DPRINT_REACTOS, " Start: %x \n", (int)StartValue));
-
- ValueSize = sizeof(U32);
- rc = RegQueryValue(hDriverKey, "Tag", &ValueType, (PUCHAR)&TagValue, &ValueSize);
- if (rc != ERROR_SUCCESS)
- {
- TagValue = (U32)-1;
- }
- DbgPrint((DPRINT_REACTOS, " Tag: %x \n", (int)TagValue));
-
- DriverGroupSize = 256;
- rc = RegQueryValue(hDriverKey, "Group", NULL, (PUCHAR)DriverGroup, &DriverGroupSize);
- DbgPrint((DPRINT_REACTOS, " Group: '%s' \n", DriverGroup));
-
- for (TagIndex = 1; TagIndex <= OrderList[0]; TagIndex++)
- {
- if (TagValue == OrderList[TagIndex])
- break;
- }
-
- if ((StartValue == 0) && (TagIndex > OrderList[0]) && (stricmp(DriverGroup, GroupName) == 0))
- {
- ValueSize = 256;
- rc = RegQueryValue(hDriverKey,
- "ImagePath",
- NULL,
- (PUCHAR)TempImagePath,
- &ValueSize);
- if (rc != ERROR_SUCCESS)
- {
- DbgPrint((DPRINT_REACTOS, " ImagePath: not found\n"));
- strcpy(ImagePath, szSystemRoot);
- strcat(ImagePath, "system32\\drivers\\");
- strcat(ImagePath, ServiceName);
- strcat(ImagePath, ".sys");
- }
- else if (TempImagePath[0] != '\\')
- {
- strcpy(ImagePath, szSystemRoot);
- strcat(ImagePath, TempImagePath);
- }
- else
- {
- strcpy(ImagePath, TempImagePath);
- DbgPrint((DPRINT_REACTOS, " ImagePath: '%s'\n", ImagePath));
- }
- DbgPrint((DPRINT_REACTOS, " Loading driver: '%s'\n", ImagePath));
-
- if (nPos < 100)
- nPos += 5;
-
- LoadDriver(ImagePath, nPos);
- LoadSymbolFile(szSystemRoot, ImagePath, nPos);
- }
- else
- {
- DbgPrint((DPRINT_REACTOS, " Skipping driver '%s' with Start %d, Tag %d and Group '%s' (Current group '%s')\n",
- ServiceName, StartValue, TagValue, DriverGroup, GroupName));
- }
- Index++;
- }
-
- GroupName = GroupName + strlen(GroupName) + 1;
- }
+ MmFreeMemory(Area);
}
+static PVOID
+FreeldrAllocMem(ULONG_PTR Size)
+{
+ return MmAllocateMemory((ULONG) Size);
+}
+
+static BOOLEAN
+FreeldrReadFile(PVOID FileContext, PVOID Buffer, ULONG Size)
+{
+ ULONG BytesRead;
+
+ return FsReadFile((PFILE) FileContext, (ULONG) Size, &BytesRead, Buffer)
+ && Size == BytesRead;
+}
+
+static BOOLEAN
+FreeldrSeekFile(PVOID FileContext, ULONG_PTR Position)
+{
+ FsSetFilePointer((PFILE) FileContext, (ULONG) Position);
+ return TRUE;
+}
static BOOL
-LoadNlsFiles(PCHAR szSystemRoot, PCHAR szErrorOut)
+LoadKernelSymbols(PCHAR szKernelName, int nPos)
{
- S32 rc = ERROR_SUCCESS;
- HKEY hKey;
- char szIdBuffer[80];
- char szNameBuffer[80];
- char szFileName[256];
- U32 BufferSize;
+ static ROSSYM_CALLBACKS FreeldrCallbacks =
+ {
+ FreeldrAllocMem,
+ FreeldrFreeMem,
+ FreeldrReadFile,
+ FreeldrSeekFile
+ };
+ PFILE FilePointer;
+ PROSSYM_INFO RosSymInfo;
+ ULONG Size;
+ ULONG_PTR Base;
- /* open the codepage key */
- rc = RegOpenKey(NULL,
- "\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\NLS\\CodePage",
- &hKey);
- if (rc != ERROR_SUCCESS) {
- strcpy(szErrorOut, "Couldn't open CodePage registry key");
- return(FALSE);
- }
+ RosSymInit(&FreeldrCallbacks);
+ FilePointer = FsOpenFile(szKernelName);
+ if (FilePointer == NULL)
+ {
+ return FALSE;
+ }
+ if (! RosSymCreateFromFile(FilePointer, &RosSymInfo))
+ {
+ return FALSE;
+ }
+ Base = FrLdrCreateModule("NTOSKRNL.SYM");
+ Size = RosSymGetRawDataLength(RosSymInfo);
+ RosSymGetRawData(RosSymInfo, (PVOID)Base);
+ FrLdrCloseModule(Base, Size);
+ RosSymDelete(RosSymInfo);
+ return TRUE;
+}
+
+BOOL
+FrLdrLoadNlsFile(PCHAR szFileName,
+ PCHAR szModuleName)
+{
+ PFILE FilePointer;
+ CHAR value[256];
+ LPSTR p;
- /* get ANSI codepage */
- BufferSize = 80;
- rc = RegQueryValue(hKey, "ACP", NULL, (PUCHAR)szIdBuffer, &BufferSize);
- if (rc != ERROR_SUCCESS) {
- strcpy(szErrorOut, "Couldn't get ACP NLS setting");
- return(FALSE);
- }
+ /* Open the Driver */
+ FilePointer = FsOpenFile(szFileName);
+
+ /* Make sure we did */
+ if (FilePointer == NULL) {
+
+ /* Fail if file wasn't opened */
+ strcpy(value, szFileName);
+ strcat(value, " not found.");
+ UiMessageBox(value);
+ return(FALSE);
+ }
- BufferSize = 80;
- rc = RegQueryValue(hKey, szIdBuffer, NULL, (PUCHAR)szNameBuffer, &BufferSize);
- if (rc != ERROR_SUCCESS) {
- strcpy(szErrorOut, "ACP NLS Setting exists, but isn't readable");
- return(FALSE);
- }
+ /* Update the status bar with the current file */
+ strcpy(value, "Reading ");
+ p = strrchr(szFileName, '\\');
+ if (p == NULL) {
+
+ strcat(value, szFileName);
+
+ } else {
+
+ strcat(value, p + 1);
+ }
+ UiDrawStatusText(value);
- /* load ANSI codepage table */
- strcpy(szFileName, szSystemRoot);
- strcat(szFileName, "system32\\");
- strcat(szFileName, szNameBuffer);
- DbgPrint((DPRINT_REACTOS, "ANSI file: %s\n", szFileName));
- if (!LoadNlsFile(szFileName, "ansi.nls")) {
- strcpy(szErrorOut, "Couldn't load ansi.nls");
- return(FALSE);
- }
-
- /* get OEM codepage */
- BufferSize = 80;
- rc = RegQueryValue(hKey, "OEMCP", NULL, (PUCHAR)szIdBuffer, &BufferSize);
- if (rc != ERROR_SUCCESS) {
- strcpy(szErrorOut, "Couldn't get OEMCP NLS setting");
- return(FALSE);
- }
-
- BufferSize = 80;
- rc = RegQueryValue(hKey, szIdBuffer, NULL, (PUCHAR)szNameBuffer, &BufferSize);
- if (rc != ERROR_SUCCESS) {
- strcpy(szErrorOut, "OEMCP NLS setting exists, but isn't readable");
- return(FALSE);
- }
-
- /* load OEM codepage table */
- strcpy(szFileName, szSystemRoot);
- strcat(szFileName, "system32\\");
- strcat(szFileName, szNameBuffer);
- DbgPrint((DPRINT_REACTOS, "Oem file: %s\n", szFileName));
- if (!LoadNlsFile(szFileName, "oem.nls")) {
- strcpy(szErrorOut, "Couldn't load oem.nls");
- return(FALSE);
- }
-
- /* open the language key */
- rc = RegOpenKey(NULL,
- "\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\NLS\\Language",
- &hKey);
- if (rc != ERROR_SUCCESS) {
- strcpy(szErrorOut, "Couldn't open Language registry key");
- return(FALSE);
- }
-
- /* get the Unicode case table */
- BufferSize = 80;
- rc = RegQueryValue(hKey, "Default", NULL, (PUCHAR)szIdBuffer, &BufferSize);
- if (rc != ERROR_SUCCESS) {
- strcpy(szErrorOut, "Couldn't get Language Default setting");
- return(FALSE);
- }
-
- BufferSize = 80;
- rc = RegQueryValue(hKey, szIdBuffer, NULL, (PUCHAR)szNameBuffer, &BufferSize);
- if (rc != ERROR_SUCCESS) {
- strcpy(szErrorOut,
- "Language Default setting exists, but isn't readable");
- return(FALSE);
- }
-
- /* load Unicode case table */
- strcpy(szFileName, szSystemRoot);
- strcat(szFileName, "system32\\");
- strcat(szFileName, szNameBuffer);
- DbgPrint((DPRINT_REACTOS, "Casemap file: %s\n", szFileName));
- if (!LoadNlsFile(szFileName, "casemap.nls")) {
- strcpy(szErrorOut, "casemap.nls");
- return(FALSE);
- }
-
- return(TRUE);
+ /* Load the driver */
+ FrLdrLoadModule(FilePointer, szModuleName, NULL);
+ return(TRUE);
}
+BOOL
+FrLdrLoadNlsFiles(PCHAR szSystemRoot,
+ PCHAR szErrorOut)
+{
+ LONG rc = ERROR_SUCCESS;
+ FRLDRHKEY hKey;
+ CHAR szIdBuffer[80];
+ CHAR szNameBuffer[80];
+ CHAR szFileName[256];
+ ULONG BufferSize;
-void
+ /* open the codepage key */
+ rc = RegOpenKey(NULL,
+ "\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\NLS\\CodePage",
+ &hKey);
+ if (rc != ERROR_SUCCESS) {
+
+ strcpy(szErrorOut, "Couldn't open CodePage registry key");
+ return(FALSE);
+ }
+
+ /* get ANSI codepage */
+ BufferSize = 80;
+ rc = RegQueryValue(hKey, "ACP", NULL, (PUCHAR)szIdBuffer, &BufferSize);
+ if (rc != ERROR_SUCCESS) {
+
+ strcpy(szErrorOut, "Couldn't get ACP NLS setting");
+ return(FALSE);
+ }
+
+ BufferSize = 80;
+ rc = RegQueryValue(hKey, szIdBuffer, NULL, (PUCHAR)szNameBuffer, &BufferSize);
+ if (rc != ERROR_SUCCESS) {
+
+ strcpy(szErrorOut, "ACP NLS Setting exists, but isn't readable");
+ return(FALSE);
+ }
+
+ /* load ANSI codepage table */
+ strcpy(szFileName, szSystemRoot);
+ strcat(szFileName, "system32\\");
+ strcat(szFileName, szNameBuffer);
+ DbgPrint((DPRINT_REACTOS, "ANSI file: %s\n", szFileName));
+ if (!FrLdrLoadNlsFile(szFileName, "ansi.nls")) {
+
+ strcpy(szErrorOut, "Couldn't load ansi.nls");
+ return(FALSE);
+ }
+
+ /* get OEM codepage */
+ BufferSize = 80;
+ rc = RegQueryValue(hKey, "OEMCP", NULL, (PUCHAR)szIdBuffer, &BufferSize);
+ if (rc != ERROR_SUCCESS) {
+
+ strcpy(szErrorOut, "Couldn't get OEMCP NLS setting");
+ return(FALSE);
+ }
+
+ BufferSize = 80;
+ rc = RegQueryValue(hKey, szIdBuffer, NULL, (PUCHAR)szNameBuffer, &BufferSize);
+ if (rc != ERROR_SUCCESS) {
+
+ strcpy(szErrorOut, "OEMCP NLS setting exists, but isn't readable");
+ return(FALSE);
+ }
+
+ /* load OEM codepage table */
+ strcpy(szFileName, szSystemRoot);
+ strcat(szFileName, "system32\\");
+ strcat(szFileName, szNameBuffer);
+ DbgPrint((DPRINT_REACTOS, "Oem file: %s\n", szFileName));
+ if (!FrLdrLoadNlsFile(szFileName, "oem.nls")) {
+
+ strcpy(szErrorOut, "Couldn't load oem.nls");
+ return(FALSE);
+ }
+
+ /* open the language key */
+ rc = RegOpenKey(NULL,
+ "\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\NLS\\Language",
+ &hKey);
+ if (rc != ERROR_SUCCESS) {
+
+ strcpy(szErrorOut, "Couldn't open Language registry key");
+ return(FALSE);
+ }
+
+ /* get the Unicode case table */
+ BufferSize = 80;
+ rc = RegQueryValue(hKey, "Default", NULL, (PUCHAR)szIdBuffer, &BufferSize);
+ if (rc != ERROR_SUCCESS) {
+
+ strcpy(szErrorOut, "Couldn't get Language Default setting");
+ return(FALSE);
+ }
+
+ BufferSize = 80;
+ rc = RegQueryValue(hKey, szIdBuffer, NULL, (PUCHAR)szNameBuffer, &BufferSize);
+ if (rc != ERROR_SUCCESS) {
+
+ strcpy(szErrorOut, "Language Default setting exists, but isn't readable");
+ return(FALSE);
+ }
+
+ /* load Unicode case table */
+ strcpy(szFileName, szSystemRoot);
+ strcat(szFileName, "system32\\");
+ strcat(szFileName, szNameBuffer);
+ DbgPrint((DPRINT_REACTOS, "Casemap file: %s\n", szFileName));
+ if (!FrLdrLoadNlsFile(szFileName, "casemap.nls")) {
+
+ strcpy(szErrorOut, "casemap.nls");
+ return(FALSE);
+ }
+
+ return(TRUE);
+}
+
+BOOL
+FrLdrLoadDriver(PCHAR szFileName,
+ INT nPos)
+{
+ PFILE FilePointer;
+ CHAR value[256];
+ LPSTR p;
+
+ /* Open the Driver */
+ FilePointer = FsOpenFile(szFileName);
+
+ /* Make sure we did */
+ if (FilePointer == NULL) {
+
+ /* Fail if file wasn't opened */
+ strcpy(value, szFileName);
+ strcat(value, " not found.");
+ UiMessageBox(value);
+ return(FALSE);
+ }
+
+ /* Update the status bar with the current file */
+ strcpy(value, "Reading ");
+ p = strrchr(szFileName, '\\');
+ if (p == NULL) {
+
+ strcat(value, szFileName);
+
+ } else {
+
+ strcat(value, p + 1);
+
+ }
+ UiDrawStatusText(value);
+
+ /* Load the driver */
+ FrLdrLoadModule(FilePointer, szFileName, NULL);
+
+ /* Update status and return */
+ UiDrawProgressBarCenter(nPos, 100, "Loading ReactOS...");
+ return(TRUE);
+}
+
+VOID
+FrLdrLoadBootDrivers(PCHAR szSystemRoot,
+ INT nPos)
+{
+ LONG rc = 0;
+ FRLDRHKEY hGroupKey, hOrderKey, hServiceKey, hDriverKey;
+ CHAR GroupNameBuffer[512];
+ CHAR ServiceName[256];
+ ULONG OrderList[128];
+ ULONG BufferSize;
+ ULONG Index;
+ ULONG TagIndex;
+ LPSTR GroupName;
+
+ ULONG ValueSize;
+ ULONG ValueType;
+ ULONG StartValue;
+ ULONG TagValue;
+ UCHAR DriverGroup[256];
+ ULONG DriverGroupSize;
+
+ UCHAR ImagePath[256];
+ UCHAR TempImagePath[256];
+
+ /* get 'service group order' key */
+ rc = RegOpenKey(NULL,
+ "\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\ServiceGroupOrder",
+ &hGroupKey);
+ if (rc != ERROR_SUCCESS) {
+
+ DbgPrint((DPRINT_REACTOS, "Failed to open the 'ServiceGroupOrder' key (rc %d)\n", (int)rc));
+ return;
+ }
+
+ /* get 'group order list' key */
+ rc = RegOpenKey(NULL,
+ "\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\GroupOrderList",
+ &hOrderKey);
+ if (rc != ERROR_SUCCESS) {
+
+ DbgPrint((DPRINT_REACTOS, "Failed to open the 'GroupOrderList' key (rc %d)\n", (int)rc));
+ return;
+ }
+
+ /* enumerate drivers */
+ rc = RegOpenKey(NULL,
+ "\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Services",
+ &hServiceKey);
+ if (rc != ERROR_SUCCESS) {
+
+ DbgPrint((DPRINT_REACTOS, "Failed to open the 'Services' key (rc %d)\n", (int)rc));
+ return;
+ }
+
+ /* Get the Name Group */
+ BufferSize = sizeof(GroupNameBuffer);
+ rc = RegQueryValue(hGroupKey, "List", NULL, (PUCHAR)GroupNameBuffer, &BufferSize);
+ DbgPrint((DPRINT_REACTOS, "RegQueryValue(): rc %d\n", (int)rc));
+ if (rc != ERROR_SUCCESS) return;
+ DbgPrint((DPRINT_REACTOS, "BufferSize: %d \n", (int)BufferSize));
+ DbgPrint((DPRINT_REACTOS, "GroupNameBuffer: '%s' \n", GroupNameBuffer));
+
+ /* Loop through each group */
+ GroupName = GroupNameBuffer;
+ while (*GroupName) {
+ DbgPrint((DPRINT_REACTOS, "Driver group: '%s'\n", GroupName));
+
+ /* Query the Order */
+ BufferSize = sizeof(OrderList);
+ rc = RegQueryValue(hOrderKey, GroupName, NULL, (PUCHAR)OrderList, &BufferSize);
+ if (rc != ERROR_SUCCESS) OrderList[0] = 0;
+
+ /* enumerate all drivers */
+ for (TagIndex = 1; TagIndex <= OrderList[0]; TagIndex++) {
+
+ Index = 0;
+
+ while (TRUE) {
+
+ /* Get the Driver's Name */
+ ValueSize = sizeof(ServiceName);
+ rc = RegEnumKey(hServiceKey, Index, ServiceName, &ValueSize);
+ DbgPrint((DPRINT_REACTOS, "RegEnumKey(): rc %d\n", (int)rc));
+
+ /* Makre sure it's valid, and check if we're done */
+ if (rc == ERROR_NO_MORE_ITEMS) break;
+ if (rc != ERROR_SUCCESS) return;
+ DbgPrint((DPRINT_REACTOS, "Service %d: '%s'\n", (int)Index, ServiceName));
+
+ /* open driver Key */
+ rc = RegOpenKey(hServiceKey, ServiceName, &hDriverKey);
+
+ /* Read the Start Value */
+ ValueSize = sizeof(ULONG);
+ rc = RegQueryValue(hDriverKey, "Start", &ValueType, (PUCHAR)&StartValue, &ValueSize);
+ DbgPrint((DPRINT_REACTOS, " Start: %x \n", (int)StartValue));
+
+ /* Read the Tag */
+ ValueSize = sizeof(ULONG);
+ rc = RegQueryValue(hDriverKey, "Tag", &ValueType, (PUCHAR)&TagValue, &ValueSize);
+ if (rc != ERROR_SUCCESS) TagValue = (ULONG)-1;
+ DbgPrint((DPRINT_REACTOS, " Tag: %x \n", (int)TagValue));
+
+ /* Read the driver's group */
+ DriverGroupSize = 256;
+ rc = RegQueryValue(hDriverKey, "Group", NULL, (PUCHAR)DriverGroup, &DriverGroupSize);
+ DbgPrint((DPRINT_REACTOS, " Group: '%s' \n", DriverGroup));
+
+ /* Make sure it should be started */
+ if ((StartValue == 0) &&
+ (TagValue == OrderList[TagIndex]) &&
+ (stricmp(DriverGroup, GroupName) == 0)) {
+
+ /* Get the Driver's Location */
+ ValueSize = 256;
+ rc = RegQueryValue(hDriverKey, "ImagePath", NULL, (PUCHAR)TempImagePath, &ValueSize);
+
+ /* Write the whole path if it suceeded, else prepare to fail */
+ if (rc != ERROR_SUCCESS) {
+ DbgPrint((DPRINT_REACTOS, " ImagePath: not found\n"));
+ strcpy(ImagePath, szSystemRoot);
+ strcat(ImagePath, "system32\\drivers\\");
+ strcat(ImagePath, ServiceName);
+ strcat(ImagePath, ".sys");
+ } else if (TempImagePath[0] != '\\') {
+ strcpy(ImagePath, szSystemRoot);
+ strcat(ImagePath, TempImagePath);
+ } else {
+ strcpy(ImagePath, TempImagePath);
+ DbgPrint((DPRINT_REACTOS, " ImagePath: '%s'\n", ImagePath));
+ }
+
+ DbgPrint((DPRINT_REACTOS, " Loading driver: '%s'\n", ImagePath));
+
+ /* Update the position if needed */
+ if (nPos < 100) nPos += 5;
+
+ FrLdrLoadDriver(ImagePath, nPos);
+
+ } else {
+
+ DbgPrint((DPRINT_REACTOS, " Skipping driver '%s' with Start %d, Tag %d and Group '%s' (Current Tag %d, current group '%s')\n",
+ ServiceName, StartValue, TagValue, DriverGroup, OrderList[TagIndex], GroupName));
+ }
+
+ Index++;
+ }
+ }
+
+ Index = 0;
+ while (TRUE) {
+
+ /* Get the Driver's Name */
+ ValueSize = sizeof(ServiceName);
+ rc = RegEnumKey(hServiceKey, Index, ServiceName, &ValueSize);
+
+ DbgPrint((DPRINT_REACTOS, "RegEnumKey(): rc %d\n", (int)rc));
+ if (rc == ERROR_NO_MORE_ITEMS) break;
+ if (rc != ERROR_SUCCESS) return;
+ DbgPrint((DPRINT_REACTOS, "Service %d: '%s'\n", (int)Index, ServiceName));
+
+ /* open driver Key */
+ rc = RegOpenKey(hServiceKey, ServiceName, &hDriverKey);
+
+ /* Read the Start Value */
+ ValueSize = sizeof(ULONG);
+ rc = RegQueryValue(hDriverKey, "Start", &ValueType, (PUCHAR)&StartValue, &ValueSize);
+ DbgPrint((DPRINT_REACTOS, " Start: %x \n", (int)StartValue));
+
+ /* Read the Tag */
+ ValueSize = sizeof(ULONG);
+ rc = RegQueryValue(hDriverKey, "Tag", &ValueType, (PUCHAR)&TagValue, &ValueSize);
+ if (rc != ERROR_SUCCESS) TagValue = (ULONG)-1;
+ DbgPrint((DPRINT_REACTOS, " Tag: %x \n", (int)TagValue));
+
+ /* Read the driver's group */
+ DriverGroupSize = 256;
+ rc = RegQueryValue(hDriverKey, "Group", NULL, (PUCHAR)DriverGroup, &DriverGroupSize);
+ DbgPrint((DPRINT_REACTOS, " Group: '%s' \n", DriverGroup));
+
+ for (TagIndex = 1; TagIndex <= OrderList[0]; TagIndex++) {
+ if (TagValue == OrderList[TagIndex]) break;
+ }
+
+ if ((StartValue == 0) &&
+ (TagIndex > OrderList[0]) &&
+ (stricmp(DriverGroup, GroupName) == 0)) {
+
+ ValueSize = 256;
+ rc = RegQueryValue(hDriverKey, "ImagePath", NULL, (PUCHAR)TempImagePath, &ValueSize);
+ if (rc != ERROR_SUCCESS) {
+ DbgPrint((DPRINT_REACTOS, " ImagePath: not found\n"));
+ strcpy(ImagePath, szSystemRoot);
+ strcat(ImagePath, "system32\\drivers\\");
+ strcat(ImagePath, ServiceName);
+ strcat(ImagePath, ".sys");
+ } else if (TempImagePath[0] != '\\') {
+ strcpy(ImagePath, szSystemRoot);
+ strcat(ImagePath, TempImagePath);
+ } else {
+ strcpy(ImagePath, TempImagePath);
+ DbgPrint((DPRINT_REACTOS, " ImagePath: '%s'\n", ImagePath));
+ }
+ DbgPrint((DPRINT_REACTOS, " Loading driver: '%s'\n", ImagePath));
+
+ if (nPos < 100) nPos += 5;
+
+ FrLdrLoadDriver(ImagePath, nPos);
+
+ } else {
+
+ DbgPrint((DPRINT_REACTOS, " Skipping driver '%s' with Start %d, Tag %d and Group '%s' (Current group '%s')\n",
+ ServiceName, StartValue, TagValue, DriverGroup, GroupName));
+ }
+
+ Index++;
+ }
+
+ /* Move to the next group name */
+ GroupName = GroupName + strlen(GroupName) + 1;
+ }
+}
+
+VOID
LoadAndBootReactOS(PUCHAR OperatingSystemName)
{
PFILE FilePointer;
- char name[1024];
- char value[1024];
- char szKernelName[1024];
- char szHalName[1024];
- char szFileName[1024];
- char szBootPath[256];
- int i;
- char MsgBuffer[256];
- U32 SectionId;
+ CHAR name[1024];
+ CHAR value[1024];
+ CHAR szKernelName[1024];
+ CHAR szHalName[1024];
+ CHAR szFileName[1024];
+ CHAR szBootPath[256];
+ INT i;
+ CHAR MsgBuffer[256];
+ ULONG SectionId;
- char* Base;
- U32 Size;
+ ULONG_PTR Base;
+ ULONG Size;
PARTITION_TABLE_ENTRY PartitionTableEntry;
- U32 rosPartition;
+ ULONG rosPartition;
+
+ extern ULONG PageDirectoryStart;
+ extern ULONG PageDirectoryEnd;
//
// Open the operating system section
@@ -604,35 +595,37 @@ LoadAndBootReactOS(PUCHAR OperatingSystemName)
/*
* Setup multiboot information structure
*/
- mb_info.flags = MB_INFO_FLAG_MEM_SIZE | MB_INFO_FLAG_BOOT_DEVICE | MB_INFO_FLAG_COMMAND_LINE | MB_INFO_FLAG_MODULES;
- mb_info.boot_device = 0xffffffff;
- mb_info.cmdline = (unsigned long)multiboot_kernel_cmdline;
- mb_info.mods_count = 0;
- mb_info.mods_addr = (unsigned long)multiboot_modules;
- mb_info.mmap_length = (unsigned long)MachGetMemoryMap((PBIOS_MEMORY_MAP)(PVOID)&multiboot_memory_map, 32) * sizeof(memory_map_t);
- if (mb_info.mmap_length)
+ LoaderBlock.Flags = MB_INFO_FLAG_MEM_SIZE | MB_INFO_FLAG_BOOT_DEVICE | MB_INFO_FLAG_COMMAND_LINE | MB_INFO_FLAG_MODULES;
+ LoaderBlock.PageDirectoryStart = (ULONG)&PageDirectoryStart;
+ LoaderBlock.PageDirectoryEnd = (ULONG)&PageDirectoryEnd;
+ LoaderBlock.BootDevice = 0xffffffff;
+ LoaderBlock.CommandLine = (unsigned long)multiboot_kernel_cmdline;
+ LoaderBlock.ModsCount = 0;
+ LoaderBlock.ModsAddr = (unsigned long)multiboot_modules;
+ LoaderBlock.MmapLength = (unsigned long)MachGetMemoryMap((PBIOS_MEMORY_MAP)(PVOID)&multiboot_memory_map, 32) * sizeof(memory_map_t);
+ if (LoaderBlock.MmapLength)
{
- mb_info.mmap_addr = (unsigned long)&multiboot_memory_map;
- mb_info.flags |= MB_INFO_FLAG_MEM_SIZE | MB_INFO_FLAG_MEMORY_MAP;
+ LoaderBlock.MmapAddr = (unsigned long)&multiboot_memory_map;
+ LoaderBlock.Flags |= MB_INFO_FLAG_MEM_SIZE | MB_INFO_FLAG_MEMORY_MAP;
multiboot_memory_map_descriptor_size = sizeof(memory_map_t); // GetBiosMemoryMap uses a fixed value of 24
- DbgPrint((DPRINT_REACTOS, "memory map length: %d\n", mb_info.mmap_length));
+ DbgPrint((DPRINT_REACTOS, "memory map length: %d\n", LoaderBlock.MmapLength));
DbgPrint((DPRINT_REACTOS, "dumping memory map:\n"));
- for (i=0; i<(mb_info.mmap_length/sizeof(memory_map_t)); i++)
+ for (i=0; i<(LoaderBlock.MmapLength/sizeof(memory_map_t)); i++)
{
if (MEMTYPE_USABLE == multiboot_memory_map[i].type &&
0 == multiboot_memory_map[i].base_addr_low)
{
- mb_info.mem_lower = (multiboot_memory_map[i].base_addr_low + multiboot_memory_map[i].length_low) / 1024;
- if (640 < mb_info.mem_lower)
+ LoaderBlock.MemLower = (multiboot_memory_map[i].base_addr_low + multiboot_memory_map[i].length_low) / 1024;
+ if (640 < LoaderBlock.MemLower)
{
- mb_info.mem_lower = 640;
+ LoaderBlock.MemLower = 640;
}
}
if (MEMTYPE_USABLE == multiboot_memory_map[i].type &&
multiboot_memory_map[i].base_addr_low <= 1024 * 1024 &&
1024 * 1024 <= multiboot_memory_map[i].base_addr_low + multiboot_memory_map[i].length_low)
{
- mb_info.mem_upper = (multiboot_memory_map[i].base_addr_low + multiboot_memory_map[i].length_low) / 1024 - 1024;
+ LoaderBlock.MemHigher = (multiboot_memory_map[i].base_addr_low + multiboot_memory_map[i].length_low) / 1024 - 1024;
}
DbgPrint((DPRINT_REACTOS, "start: %x\t size: %x\t type %d\n",
multiboot_memory_map[i].base_addr_low,
@@ -640,8 +633,8 @@ LoadAndBootReactOS(PUCHAR OperatingSystemName)
multiboot_memory_map[i].type));
}
}
- DbgPrint((DPRINT_REACTOS, "low_mem = %d\n", mb_info.mem_lower));
- DbgPrint((DPRINT_REACTOS, "high_mem = %d\n", mb_info.mem_upper));
+ DbgPrint((DPRINT_REACTOS, "low_mem = %d\n", LoaderBlock.MemLower));
+ DbgPrint((DPRINT_REACTOS, "high_mem = %d\n", LoaderBlock.MemHigher));
/*
* Initialize the registry
@@ -713,8 +706,8 @@ LoadAndBootReactOS(PUCHAR OperatingSystemName)
}
/* Set boot drive and partition */
- ((char *)(&mb_info.boot_device))[0] = (char)BootDrive;
- ((char *)(&mb_info.boot_device))[1] = (char)BootPartition;
+ ((LPSTR )(&LoaderBlock.BootDevice))[0] = (CHAR)BootDrive;
+ ((LPSTR )(&LoaderBlock.BootDevice))[1] = (CHAR)BootPartition;
/*
* Read the optional kernel parameters (if any)
@@ -782,9 +775,8 @@ LoadAndBootReactOS(PUCHAR OperatingSystemName)
strcat(szKernelName, value);
}
- if (!LoadKernel(szKernelName, 5))
- return;
-
+ if (!FrLdrLoadKernel(szKernelName, 5)) return;
+
/*
* Find the HAL image name
* and try to load the kernel off the disk
@@ -813,7 +805,7 @@ LoadAndBootReactOS(PUCHAR OperatingSystemName)
strcat(szHalName, value);
}
- if (!LoadDriver(szHalName, 10))
+ if (!FrLdrLoadDriver(szHalName, 10))
return;
/*
@@ -843,8 +835,8 @@ LoadAndBootReactOS(PUCHAR OperatingSystemName)
/*
* Load the System hive
*/
- Base = MultiBootLoadModule(FilePointer, szFileName, &Size);
- if (Base == NULL || Size == 0)
+ Base = FrLdrLoadModule(FilePointer, szFileName, &Size);
+ if (Base == 0 || Size == 0)
{
UiMessageBox("Could not load the System hive!\n");
return;
@@ -854,7 +846,7 @@ LoadAndBootReactOS(PUCHAR OperatingSystemName)
/*
* Import the loaded system hive
*/
- RegImportBinaryHive(Base, Size);
+ RegImportBinaryHive((PCHAR)Base, Size);
/*
* Initialize the 'CurrentControlSet' link
@@ -866,59 +858,48 @@ LoadAndBootReactOS(PUCHAR OperatingSystemName)
/*
* Export the hardware hive
*/
- Base = MultiBootCreateModule ("HARDWARE");
- RegExportBinaryHive ("\\Registry\\Machine\\HARDWARE", Base, &Size);
- MultiBootCloseModule (Base, Size);
+ Base = FrLdrCreateModule ("HARDWARE");
+ RegExportBinaryHive ("\\Registry\\Machine\\HARDWARE", (PCHAR)Base, &Size);
+ FrLdrCloseModule (Base, Size);
UiDrawProgressBarCenter(20, 100, "Loading ReactOS...");
/*
* Load NLS files
*/
- if (!LoadNlsFiles(szBootPath, MsgBuffer))
+ if (!FrLdrLoadNlsFiles(szBootPath, MsgBuffer))
{
UiMessageBox(MsgBuffer);
return;
}
- UiDrawProgressBarCenter(25, 100, "Loading ReactOS...");
+ UiDrawProgressBarCenter(30, 100, "Loading ReactOS...");
/*
- * Load symbol files
+ * Load kernel symbols
*/
- LoadSymbolFile(szBootPath, szKernelName, 30);
- LoadSymbolFile(szBootPath, szHalName, 30);
-
- UiDrawProgressBarCenter(30, 100, "Loading ReactOS...");
+ LoadKernelSymbols(szKernelName, 30);
+ UiDrawProgressBarCenter(40, 100, "Loading ReactOS...");
/*
* Load boot drivers
*/
- LoadBootDrivers(szBootPath, 30);
-
-
-#if 0
- /*
- * Clear the screen and redraw the backdrop and status bar
- */
- UiDrawBackdrop();
- UiDrawStatusText("Press any key to boot");
-
- /*
- * Wait for user
- */
- strcpy(name, "Kernel and Drivers loaded.\nPress any key to boot ");
- strcat(name, OperatingSystemName);
- strcat(name, ".");
- MessageBox(name);
-#endif
-
+ FrLdrLoadBootDrivers(szBootPath, 40);
UiUnInitialize("Booting ReactOS...");
/*
* Now boot the kernel
*/
DiskStopFloppyMotor();
- boot_reactos();
+ MachVideoPrepareForReactOS();
+ FrLdrStartup(0x2badb002);
+}
+
+#undef DbgPrint
+ULONG
+DbgPrint(char *Fmt, ...)
+{
+ UiMessageBox(Fmt);
+ return 0;
}
/* EOF */
diff --git a/reactos/boot/freeldr/freeldr/reactos/registry.c b/reactos/boot/freeldr/freeldr/reactos/registry.c
index 938ec3f116a..ffc0f1a56a1 100644
--- a/reactos/boot/freeldr/freeldr/reactos/registry.c
+++ b/reactos/boot/freeldr/freeldr/reactos/registry.c
@@ -26,18 +26,18 @@
#include
-static HKEY RootKey;
+static FRLDRHKEY RootKey;
VOID
RegInitializeRegistry (VOID)
{
#if 0
- HKEY TestKey;
+ FRLDRHKEY TestKey;
#endif
/* Create root key */
- RootKey = (HKEY) MmAllocateMemory (sizeof(KEY));
+ RootKey = (FRLDRHKEY) MmAllocateMemory (sizeof(KEY));
InitializeListHead (&RootKey->SubKeyList);
InitializeListHead (&RootKey->ValueList);
@@ -94,19 +94,19 @@ RegInitializeRegistry (VOID)
}
-S32
+LONG
RegInitCurrentControlSet(BOOL LastKnownGood)
{
CHAR ControlSetKeyName[80];
- HKEY SelectKey;
- HKEY SystemKey;
- HKEY ControlSetKey;
- HKEY LinkKey;
- U32 CurrentSet = 0;
- U32 DefaultSet = 0;
- U32 LastKnownGoodSet = 0;
- U32 DataSize;
- S32 Error;
+ FRLDRHKEY SelectKey;
+ FRLDRHKEY SystemKey;
+ FRLDRHKEY ControlSetKey;
+ FRLDRHKEY LinkKey;
+ ULONG CurrentSet = 0;
+ ULONG DefaultSet = 0;
+ ULONG LastKnownGoodSet = 0;
+ ULONG DataSize;
+ LONG Error;
Error = RegOpenKey(NULL,
"\\Registry\\Machine\\SYSTEM\\Select",
@@ -117,7 +117,7 @@ RegInitCurrentControlSet(BOOL LastKnownGood)
return(Error);
}
- DataSize = sizeof(U32);
+ DataSize = sizeof(ULONG);
Error = RegQueryValue(SelectKey,
"Default",
NULL,
@@ -129,7 +129,7 @@ RegInitCurrentControlSet(BOOL LastKnownGood)
return(Error);
}
- DataSize = sizeof(U32);
+ DataSize = sizeof(ULONG);
Error = RegQueryValue(SelectKey,
"LastKnownGood",
NULL,
@@ -204,15 +204,15 @@ RegInitCurrentControlSet(BOOL LastKnownGood)
}
-S32
-RegCreateKey(HKEY ParentKey,
+LONG
+RegCreateKey(FRLDRHKEY ParentKey,
PCHAR KeyName,
- PHKEY Key)
+ PFRLDRHKEY Key)
{
PLIST_ENTRY Ptr;
- HKEY SearchKey = INVALID_HANDLE_VALUE;
- HKEY CurrentKey;
- HKEY NewKey;
+ FRLDRHKEY SearchKey = INVALID_HANDLE_VALUE;
+ FRLDRHKEY CurrentKey;
+ FRLDRHKEY NewKey;
PCHAR p;
PCHAR name;
int subkeyLength;
@@ -237,7 +237,7 @@ RegCreateKey(HKEY ParentKey,
/* Check whether current key is a link */
if (CurrentKey->DataType == REG_LINK)
{
- CurrentKey = (HKEY)CurrentKey->Data;
+ CurrentKey = (FRLDRHKEY)CurrentKey->Data;
}
while (*KeyName != 0)
@@ -279,7 +279,7 @@ RegCreateKey(HKEY ParentKey,
if (Ptr == &CurrentKey->SubKeyList)
{
/* no key found -> create new subkey */
- NewKey = (HKEY)MmAllocateMemory(sizeof(KEY));
+ NewKey = (FRLDRHKEY)MmAllocateMemory(sizeof(KEY));
if (NewKey == NULL)
return(ERROR_OUTOFMEMORY);
@@ -315,7 +315,7 @@ RegCreateKey(HKEY ParentKey,
/* Check whether current key is a link */
if (CurrentKey->DataType == REG_LINK)
{
- CurrentKey = (HKEY)CurrentKey->Data;
+ CurrentKey = (FRLDRHKEY)CurrentKey->Data;
}
}
@@ -329,8 +329,8 @@ RegCreateKey(HKEY ParentKey,
}
-S32
-RegDeleteKey(HKEY Key,
+LONG
+RegDeleteKey(FRLDRHKEY Key,
PCHAR Name)
{
@@ -344,16 +344,16 @@ RegDeleteKey(HKEY Key,
}
-S32
-RegEnumKey(HKEY Key,
- U32 Index,
+LONG
+RegEnumKey(FRLDRHKEY Key,
+ ULONG Index,
PCHAR Name,
- U32* NameSize)
+ ULONG* NameSize)
{
PLIST_ENTRY Ptr;
- HKEY SearchKey;
- U32 Count = 0;
- U32 Size;
+ FRLDRHKEY SearchKey;
+ ULONG Count = 0;
+ ULONG Size;
Ptr = Key->SubKeyList.Flink;
while (Ptr != &Key->SubKeyList)
@@ -382,14 +382,14 @@ RegEnumKey(HKEY Key,
}
-S32
-RegOpenKey(HKEY ParentKey,
+LONG
+RegOpenKey(FRLDRHKEY ParentKey,
PCHAR KeyName,
- PHKEY Key)
+ PFRLDRHKEY Key)
{
PLIST_ENTRY Ptr;
- HKEY SearchKey = INVALID_HANDLE_VALUE;
- HKEY CurrentKey;
+ FRLDRHKEY SearchKey = INVALID_HANDLE_VALUE;
+ FRLDRHKEY CurrentKey;
PCHAR p;
PCHAR name;
int subkeyLength;
@@ -416,7 +416,7 @@ RegOpenKey(HKEY ParentKey,
/* Check whether current key is a link */
if (CurrentKey->DataType == REG_LINK)
{
- CurrentKey = (HKEY)CurrentKey->Data;
+ CurrentKey = (FRLDRHKEY)CurrentKey->Data;
}
while (*KeyName != 0)
@@ -468,7 +468,7 @@ RegOpenKey(HKEY ParentKey,
/* Check whether current key is a link */
if (CurrentKey->DataType == REG_LINK)
{
- CurrentKey = (HKEY)CurrentKey->Data;
+ CurrentKey = (FRLDRHKEY)CurrentKey->Data;
}
}
@@ -482,12 +482,12 @@ RegOpenKey(HKEY ParentKey,
}
-S32
-RegSetValue(HKEY Key,
+LONG
+RegSetValue(FRLDRHKEY Key,
PCHAR ValueName,
- U32 Type,
+ ULONG Type,
PUCHAR Data,
- U32 DataSize)
+ ULONG DataSize)
{
PLIST_ENTRY Ptr;
PVALUE Value = NULL;
@@ -583,14 +583,14 @@ RegSetValue(HKEY Key,
}
-S32
-RegQueryValue(HKEY Key,
+LONG
+RegQueryValue(FRLDRHKEY Key,
PCHAR ValueName,
- U32* Type,
+ ULONG* Type,
PUCHAR Data,
- U32* DataSize)
+ ULONG* DataSize)
{
- U32 Size;
+ ULONG Size;
PLIST_ENTRY Ptr;
PVALUE Value = NULL;
@@ -670,8 +670,8 @@ RegQueryValue(HKEY Key,
}
-S32
-RegDeleteValue(HKEY Key,
+LONG
+RegDeleteValue(FRLDRHKEY Key,
PCHAR ValueName)
{
PLIST_ENTRY Ptr;
@@ -727,18 +727,18 @@ RegDeleteValue(HKEY Key,
}
-S32
-RegEnumValue(HKEY Key,
- U32 Index,
+LONG
+RegEnumValue(FRLDRHKEY Key,
+ ULONG Index,
PCHAR ValueName,
- U32* NameSize,
- U32* Type,
+ ULONG* NameSize,
+ ULONG* Type,
PUCHAR Data,
- U32* DataSize)
+ ULONG* DataSize)
{
PLIST_ENTRY Ptr;
PVALUE Value;
- U32 Count = 0;
+ ULONG Count = 0;
if (Key->Data != NULL)
{
@@ -813,15 +813,15 @@ RegEnumValue(HKEY Key,
}
-U32
-RegGetSubKeyCount (HKEY Key)
+ULONG
+RegGetSubKeyCount (FRLDRHKEY Key)
{
return Key->SubKeyCount;
}
-U32
-RegGetValueCount (HKEY Key)
+ULONG
+RegGetValueCount (FRLDRHKEY Key)
{
if (Key->DataSize != 0)
return Key->ValueCount + 1;
diff --git a/reactos/boot/freeldr/freeldr/reactos/registry.h b/reactos/boot/freeldr/freeldr/reactos/registry.h
index 4cfdb0fdc4a..6876301f78d 100644
--- a/reactos/boot/freeldr/freeldr/reactos/registry.h
+++ b/reactos/boot/freeldr/freeldr/reactos/registry.h
@@ -24,30 +24,23 @@
#define INVALID_HANDLE_VALUE NULL
-typedef struct _LIST_ENTRY
-{
- struct _LIST_ENTRY *Flink;
- struct _LIST_ENTRY *Blink;
-} LIST_ENTRY, *PLIST_ENTRY;
-
-
typedef struct _REG_KEY
{
LIST_ENTRY KeyList;
LIST_ENTRY SubKeyList;
LIST_ENTRY ValueList;
- U32 SubKeyCount;
- U32 ValueCount;
+ ULONG SubKeyCount;
+ ULONG ValueCount;
- U32 NameSize;
+ ULONG NameSize;
PUCHAR Name;
/* default data */
- U32 DataType;
- U32 DataSize;
+ ULONG DataType;
+ ULONG DataSize;
PUCHAR Data;
-} KEY, *HKEY, **PHKEY;
+} KEY, *FRLDRHKEY, **PFRLDRHKEY;
typedef struct _REG_VALUE
@@ -55,18 +48,17 @@ typedef struct _REG_VALUE
LIST_ENTRY ValueList;
/* value name */
- U32 NameSize;
+ ULONG NameSize;
PUCHAR Name;
/* value data */
- U32 DataType;
- U32 DataSize;
+ ULONG DataType;
+ ULONG DataSize;
PUCHAR Data;
} VALUE, *PVALUE;
#define ERROR_SUCCESS 0L
-#define ERROR_PATH_NOT_FOUND 2L
#define ERROR_OUTOFMEMORY 14L
#define ERROR_INVALID_PARAMETER 87L
#define ERROR_MORE_DATA 234L
@@ -149,22 +141,6 @@ typedef struct _REG_VALUE
assert((ListEntry)->Flink->Blink == (ListEntry)); \
}
-/*
- * BOOLEAN
- * IsListEmpty (
- * PLIST_ENTRY ListHead
- * );
- *
- * FUNCTION:
- * Checks if a double linked list is empty
- *
- * ARGUMENTS:
- * ListHead = Head of the list
-*/
-#define IsListEmpty(ListHead) \
- ((ListHead)->Flink == (ListHead))
-
-
/*
*VOID
*RemoveEntryList (
@@ -194,23 +170,6 @@ typedef struct _REG_VALUE
(ListEntry)->Blink = NULL; \
}
-/*
- * PURPOSE: Returns the byte offset of a field within a structure
- */
-#define FIELD_OFFSET(Type,Field) (S32)(&(((Type *)(0))->Field))
-
-/*
- * PURPOSE: Returns the base address structure if the caller knows the
- * address of a field within the structure
- * ARGUMENTS:
- * Address = address of the field
- * Type = Type of the whole structure
- * Field = Name of the field whose address is none
- */
-#define CONTAINING_RECORD(Address,Type,Field) \
- (Type *)(((S32)Address) - FIELD_OFFSET(Type,Field))
-
-
#define REG_NONE 0
#define REG_SZ 1
#define REG_EXPAND_SZ 2
@@ -229,73 +188,73 @@ typedef struct _REG_VALUE
VOID
RegInitializeRegistry(VOID);
-S32
+LONG
RegInitCurrentControlSet(BOOL LastKnownGood);
-S32
-RegCreateKey(HKEY ParentKey,
+LONG
+RegCreateKey(FRLDRHKEY ParentKey,
PCHAR KeyName,
- PHKEY Key);
+ PFRLDRHKEY Key);
-S32
-RegDeleteKey(HKEY Key,
+LONG
+RegDeleteKey(FRLDRHKEY Key,
PCHAR Name);
-S32
-RegEnumKey(HKEY Key,
- U32 Index,
+LONG
+RegEnumKey(FRLDRHKEY Key,
+ ULONG Index,
PCHAR Name,
- U32* NameSize);
+ ULONG* NameSize);
-S32
-RegOpenKey(HKEY ParentKey,
+LONG
+RegOpenKey(FRLDRHKEY ParentKey,
PCHAR KeyName,
- PHKEY Key);
+ PFRLDRHKEY Key);
-S32
-RegSetValue(HKEY Key,
+LONG
+RegSetValue(FRLDRHKEY Key,
PCHAR ValueName,
- U32 Type,
+ ULONG Type,
PUCHAR Data,
- U32 DataSize);
+ ULONG DataSize);
-S32
-RegQueryValue(HKEY Key,
+LONG
+RegQueryValue(FRLDRHKEY Key,
PCHAR ValueName,
- U32* Type,
+ ULONG* Type,
PUCHAR Data,
- U32* DataSize);
+ ULONG* DataSize);
-S32
-RegDeleteValue(HKEY Key,
+LONG
+RegDeleteValue(FRLDRHKEY Key,
PCHAR ValueName);
-S32
-RegEnumValue(HKEY Key,
- U32 Index,
+LONG
+RegEnumValue(FRLDRHKEY Key,
+ ULONG Index,
PCHAR ValueName,
- U32* NameSize,
- U32* Type,
+ ULONG* NameSize,
+ ULONG* Type,
PUCHAR Data,
- U32* DataSize);
+ ULONG* DataSize);
-U32
-RegGetSubKeyCount (HKEY Key);
+ULONG
+RegGetSubKeyCount (FRLDRHKEY Key);
-U32
-RegGetValueCount (HKEY Key);
+ULONG
+RegGetValueCount (FRLDRHKEY Key);
BOOL
RegImportBinaryHive (PCHAR ChunkBase,
- U32 ChunkSize);
+ ULONG ChunkSize);
BOOL
RegExportBinaryHive (PCHAR KeyName,
PCHAR ChunkBase,
- U32* ChunkSize);
+ ULONG* ChunkSize);
#endif /* __REGISTRY_H */
diff --git a/reactos/boot/freeldr/freeldr/reactos/setupldr.c b/reactos/boot/freeldr/freeldr/reactos/setupldr.c
index 23db7fd56ea..bc2fe82e964 100644
--- a/reactos/boot/freeldr/freeldr/reactos/setupldr.c
+++ b/reactos/boot/freeldr/freeldr/reactos/setupldr.c
@@ -97,7 +97,7 @@ LoadKernel(PCHAR szSourcePath, PCHAR szFileName)
/*
* Load the kernel
*/
- MultiBootLoadKernel(FilePointer);
+ FrLdrMapKernel(FilePointer);
return(TRUE);
}
@@ -162,7 +162,7 @@ LoadDriver(PCHAR szSourcePath, PCHAR szFileName)
#endif
/* Load the driver */
- MultiBootLoadModule(FilePointer, szFileName, NULL);
+ FrLdrLoadModule(FilePointer, szFileName, NULL);
return(TRUE);
}
@@ -227,7 +227,7 @@ LoadNlsFile(PCHAR szSourcePath, PCHAR szFileName, PCHAR szModuleName)
#endif
/* Load the driver */
- MultiBootLoadModule(FilePointer, szModuleName, NULL);
+ FrLdrLoadModule(FilePointer, szModuleName, NULL);
return(TRUE);
}
@@ -235,44 +235,49 @@ LoadNlsFile(PCHAR szSourcePath, PCHAR szFileName, PCHAR szModuleName)
VOID RunLoader(VOID)
{
- PVOID Base;
- U32 Size;
+ ULONG_PTR Base;
+ ULONG Size;
char *SourcePath;
char *LoadOptions;
int i;
HINF InfHandle;
- U32 ErrorLine;
+ ULONG ErrorLine;
INFCONTEXT InfContext;
+
+ extern ULONG PageDirectoryStart;
+ extern ULONG PageDirectoryEnd;
/* Setup multiboot information structure */
- mb_info.flags = MB_INFO_FLAG_BOOT_DEVICE | MB_INFO_FLAG_COMMAND_LINE | MB_INFO_FLAG_MODULES;
- mb_info.boot_device = 0xffffffff;
- mb_info.cmdline = (unsigned long)multiboot_kernel_cmdline;
- mb_info.mods_count = 0;
- mb_info.mods_addr = (unsigned long)multiboot_modules;
- mb_info.mmap_length = (unsigned long)MachGetMemoryMap((PBIOS_MEMORY_MAP)(PVOID)&multiboot_memory_map, 32) * sizeof(memory_map_t);
- if (mb_info.mmap_length)
+ LoaderBlock.Flags = MB_INFO_FLAG_BOOT_DEVICE | MB_INFO_FLAG_COMMAND_LINE | MB_INFO_FLAG_MODULES;
+ LoaderBlock.PageDirectoryStart = (ULONG)&PageDirectoryStart;
+ LoaderBlock.PageDirectoryEnd = (ULONG)&PageDirectoryEnd;
+ LoaderBlock.BootDevice = 0xffffffff;
+ LoaderBlock.CommandLine = (unsigned long)multiboot_kernel_cmdline;
+ LoaderBlock.ModsCount = 0;
+ LoaderBlock.ModsAddr = (unsigned long)multiboot_modules;
+ LoaderBlock.MmapLength = (unsigned long)MachGetMemoryMap((PBIOS_MEMORY_MAP)(PVOID)&multiboot_memory_map, 32) * sizeof(memory_map_t);
+ if (LoaderBlock.MmapLength)
{
- mb_info.mmap_addr = (unsigned long)&multiboot_memory_map;
- mb_info.flags |= MB_INFO_FLAG_MEM_SIZE | MB_INFO_FLAG_MEMORY_MAP;
+ LoaderBlock.MmapAddr = (unsigned long)&multiboot_memory_map;
+ LoaderBlock.Flags |= MB_INFO_FLAG_MEM_SIZE | MB_INFO_FLAG_MEMORY_MAP;
multiboot_memory_map_descriptor_size = sizeof(memory_map_t); // GetBiosMemoryMap uses a fixed value of 24
- for (i = 0; i < (mb_info.mmap_length / sizeof(memory_map_t)); i++)
+ for (i = 0; i < (LoaderBlock.MmapLength / sizeof(memory_map_t)); i++)
{
if (MEMTYPE_USABLE == multiboot_memory_map[i].type &&
0 == multiboot_memory_map[i].base_addr_low)
{
- mb_info.mem_lower = (multiboot_memory_map[i].base_addr_low + multiboot_memory_map[i].length_low) / 1024;
- if (640 < mb_info.mem_lower)
+ LoaderBlock.MemLower = (multiboot_memory_map[i].base_addr_low + multiboot_memory_map[i].length_low) / 1024;
+ if (640 < LoaderBlock.MemLower)
{
- mb_info.mem_lower = 640;
+ LoaderBlock.MemLower = 640;
}
}
if (MEMTYPE_USABLE == multiboot_memory_map[i].type &&
multiboot_memory_map[i].base_addr_low <= 1024 * 1024 &&
1024 * 1024 <= multiboot_memory_map[i].base_addr_low + multiboot_memory_map[i].length_low)
{
- mb_info.mem_upper = (multiboot_memory_map[i].base_addr_low + multiboot_memory_map[i].length_low) / 1024 - 1024;
+ LoaderBlock.MemHigher = (multiboot_memory_map[i].base_addr_low + multiboot_memory_map[i].length_low) / 1024 - 1024;
}
#if 0
printf("start: %x\t size: %x\t type %d\n",
@@ -283,8 +288,8 @@ VOID RunLoader(VOID)
}
}
#if 0
- printf("low_mem = %d\n", mb_info.mem_lower);
- printf("high_mem = %d\n", mb_info.mem_upper);
+ printf("low_mem = %d\n", LoaderBlock.MemLower);
+ printf("high_mem = %d\n", LoaderBlock.MemHigher);
MachConsGetCh();
#endif
@@ -308,8 +313,8 @@ VOID RunLoader(VOID)
#endif
/* set boot drive and partition */
- ((char *)(&mb_info.boot_device))[0] = (char)BootDrive;
- ((char *)(&mb_info.boot_device))[1] = (char)BootPartition;
+ ((char *)(&LoaderBlock.BootDevice))[0] = (char)BootDrive;
+ ((char *)(&LoaderBlock.BootDevice))[1] = (char)BootPartition;
/* Open boot drive */
@@ -383,9 +388,9 @@ VOID RunLoader(VOID)
/* Export the hardware hive */
- Base = MultiBootCreateModule ("HARDWARE");
- RegExportBinaryHive ("\\Registry\\Machine\\HARDWARE", Base, &Size);
- MultiBootCloseModule (Base, Size);
+ Base = FrLdrCreateModule ("HARDWARE");
+ RegExportBinaryHive ("\\Registry\\Machine\\HARDWARE", (PVOID)Base, &Size);
+ FrLdrCloseModule (Base, Size);
#if 0
printf("Base: %x\n", Base);
@@ -571,7 +576,8 @@ for(;;);
/* Now boot the kernel */
DiskStopFloppyMotor();
- boot_reactos();
+ MachVideoPrepareForReactOS();
+ FrLdrStartup(0x2badb002);
}
/* EOF */
diff --git a/reactos/boot/freeldr/freeldr/rtl/list.c b/reactos/boot/freeldr/freeldr/rtl/list.c
index 962289b451f..30a2d6ea33c 100644
--- a/reactos/boot/freeldr/freeldr/rtl/list.c
+++ b/reactos/boot/freeldr/freeldr/rtl/list.c
@@ -92,9 +92,9 @@ BOOL RtlListIsEmpty(PLIST_ITEM ListHead)
return (ListHead->ListNext == NULL);
}
-U32 RtlListCountEntries(PLIST_ITEM ListHead)
+ULONG RtlListCountEntries(PLIST_ITEM ListHead)
{
- U32 Count = 0;
+ ULONG Count = 0;
while (ListHead != NULL)
{
diff --git a/reactos/boot/freeldr/freeldr/rtl/string.c b/reactos/boot/freeldr/freeldr/rtl/string.c
index 369ae54e6ac..7f5c76e639c 100644
--- a/reactos/boot/freeldr/freeldr/rtl/string.c
+++ b/reactos/boot/freeldr/freeldr/rtl/string.c
@@ -19,7 +19,7 @@
#include
-int strlen(char *str)
+size_t strlen(const char *str)
{
int len;
@@ -28,7 +28,7 @@ int strlen(char *str)
return len;
}
-char *strcpy(char *dest, char *src)
+char *strcpy(char *dest, const char *src)
{
char *ret = dest;
@@ -39,7 +39,7 @@ char *strcpy(char *dest, char *src)
return ret;
}
-char *strncpy(char *dest, char *src, size_t count)
+char *strncpy(char *dest, const char *src, size_t count)
{
char *ret = dest;
@@ -52,7 +52,7 @@ char *strncpy(char *dest, char *src, size_t count)
return ret;
}
-char *strcat(char *dest, char *src)
+char *strcat(char *dest, const char *src)
{
char *ret = dest;
diff --git a/reactos/boot/freeldr/freeldr/ui/gui.c b/reactos/boot/freeldr/freeldr/ui/gui.c
index 0cdb3ae8ab6..f6bebf98506 100644
--- a/reactos/boot/freeldr/freeldr/ui/gui.c
+++ b/reactos/boot/freeldr/freeldr/ui/gui.c
@@ -30,19 +30,19 @@ VOID GuiDrawBackdrop(VOID)
{
}
-VOID GuiFillArea(U32 Left, U32 Top, U32 Right, U32 Bottom, UCHAR FillChar, UCHAR Attr /* Color Attributes */)
+VOID GuiFillArea(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, UCHAR FillChar, UCHAR Attr /* Color Attributes */)
{
}
-VOID GuiDrawShadow(U32 Left, U32 Top, U32 Right, U32 Bottom)
+VOID GuiDrawShadow(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom)
{
}
-VOID GuiDrawBox(U32 Left, U32 Top, U32 Right, U32 Bottom, UCHAR VertStyle, UCHAR HorzStyle, BOOL Fill, BOOL Shadow, UCHAR Attr)
+VOID GuiDrawBox(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, UCHAR VertStyle, UCHAR HorzStyle, BOOL Fill, BOOL Shadow, UCHAR Attr)
{
}
-VOID GuiDrawText(U32 X, U32 Y, PUCHAR Text, UCHAR Attr)
+VOID GuiDrawText(ULONG X, ULONG Y, PUCHAR Text, UCHAR Attr)
{
}
@@ -70,7 +70,7 @@ VOID GuiMessageBoxCritical(PUCHAR MessageText)
{
}
-VOID GuiDrawProgressBar(U32 Position, U32 Range)
+VOID GuiDrawProgressBar(ULONG Position, ULONG Range)
{
}
diff --git a/reactos/boot/freeldr/freeldr/ui/gui.h b/reactos/boot/freeldr/freeldr/ui/gui.h
index 4084b043cf7..ad1e031440f 100644
--- a/reactos/boot/freeldr/freeldr/ui/gui.h
+++ b/reactos/boot/freeldr/freeldr/ui/gui.h
@@ -29,17 +29,17 @@
//
///////////////////////////////////////////////////////////////////////////////////////
VOID GuiDrawBackdrop(VOID); // Fills the entire screen with a backdrop
-VOID GuiFillArea(U32 Left, U32 Top, U32 Right, U32 Bottom, UCHAR FillChar, UCHAR Attr /* Color Attributes */); // Fills the area specified with FillChar and Attr
-VOID GuiDrawShadow(U32 Left, U32 Top, U32 Right, U32 Bottom); // Draws a shadow on the bottom and right sides of the area specified
-VOID GuiDrawBox(U32 Left, U32 Top, U32 Right, U32 Bottom, UCHAR VertStyle, UCHAR HorzStyle, BOOL Fill, BOOL Shadow, UCHAR Attr); // Draws a box around the area specified
-VOID GuiDrawText(U32 X, U32 Y, PUCHAR Text, UCHAR Attr); // Draws text at coordinates specified
+VOID GuiFillArea(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, UCHAR FillChar, UCHAR Attr /* Color Attributes */); // Fills the area specified with FillChar and Attr
+VOID GuiDrawShadow(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom); // Draws a shadow on the bottom and right sides of the area specified
+VOID GuiDrawBox(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, UCHAR VertStyle, UCHAR HorzStyle, BOOL Fill, BOOL Shadow, UCHAR Attr); // Draws a box around the area specified
+VOID GuiDrawText(ULONG X, ULONG Y, PUCHAR Text, UCHAR Attr); // Draws text at coordinates specified
VOID GuiDrawStatusText(PUCHAR StatusText); // Draws text at the very bottom line on the screen
VOID GuiUpdateDateTime(VOID); // Updates the date and time
VOID GuiSaveScreen(PUCHAR Buffer); // Saves the screen so that it can be restored later
VOID GuiRestoreScreen(PUCHAR Buffer); // Restores the screen from a previous save
VOID GuiMessageBox(PUCHAR MessageText); // Displays a message box on the screen with an ok button
VOID GuiMessageBoxCritical(PUCHAR MessageText); // Displays a message box on the screen with an ok button using no system resources
-VOID GuiDrawProgressBar(U32 Position, U32 Range); // Draws the progress bar showing nPos percent filled
+VOID GuiDrawProgressBar(ULONG Position, ULONG Range); // Draws the progress bar showing nPos percent filled
UCHAR GuiTextToColor(PUCHAR ColorText); // Converts the text color into it's equivalent color value
UCHAR GuiTextToFillStyle(PUCHAR FillStyleText); // Converts the text fill into it's equivalent fill value
@@ -49,7 +49,7 @@ UCHAR GuiTextToFillStyle(PUCHAR FillStyleText); // Converts the text fill int
// Menu Functions
//
///////////////////////////////////////////////////////////////////////////////////////
-BOOL GuiDisplayMenu(PUCHAR MenuItemList[], U32 MenuItemCount, U32 DefaultMenuItem, S32 MenuTimeOut, U32* SelectedMenuItem);
+BOOL GuiDisplayMenu(PUCHAR MenuItemList[], ULONG MenuItemCount, ULONG DefaultMenuItem, LONG MenuTimeOut, ULONG* SelectedMenuItem);
diff --git a/reactos/boot/freeldr/freeldr/ui/tui.c b/reactos/boot/freeldr/freeldr/ui/tui.c
index 68bae1c99c9..c88f6655ee4 100644
--- a/reactos/boot/freeldr/freeldr/ui/tui.c
+++ b/reactos/boot/freeldr/freeldr/ui/tui.c
@@ -136,10 +136,10 @@ VOID TuiDrawBackdrop(VOID)
* FillArea()
* This function assumes coordinates are zero-based
*/
-VOID TuiFillArea(U32 Left, U32 Top, U32 Right, U32 Bottom, UCHAR FillChar, UCHAR Attr /* Color Attributes */)
+VOID TuiFillArea(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, UCHAR FillChar, UCHAR Attr /* Color Attributes */)
{
PUCHAR ScreenMemory = (PUCHAR)TextVideoBuffer;
- U32 i, j;
+ ULONG i, j;
// Clip the area to the screen
// FIXME: This code seems to have problems... Uncomment and view ;-)
@@ -172,10 +172,10 @@ VOID TuiFillArea(U32 Left, U32 Top, U32 Right, U32 Bottom, UCHAR FillChar, UCHAR
* DrawShadow()
* This function assumes coordinates are zero-based
*/
-VOID TuiDrawShadow(U32 Left, U32 Top, U32 Right, U32 Bottom)
+VOID TuiDrawShadow(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom)
{
PUCHAR ScreenMemory = (PUCHAR)TextVideoBuffer;
- U32 Idx;
+ ULONG Idx;
// Shade the bottom of the area
if (Bottom < (UiScreenHeight - 1))
@@ -232,7 +232,7 @@ VOID TuiDrawShadow(U32 Left, U32 Top, U32 Right, U32 Bottom)
* DrawBox()
* This function assumes coordinates are zero-based
*/
-VOID TuiDrawBox(U32 Left, U32 Top, U32 Right, U32 Bottom, UCHAR VertStyle, UCHAR HorzStyle, BOOL Fill, BOOL Shadow, UCHAR Attr)
+VOID TuiDrawBox(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, UCHAR VertStyle, UCHAR HorzStyle, BOOL Fill, BOOL Shadow, UCHAR Attr)
{
UCHAR ULCorner, URCorner, LLCorner, LRCorner;
@@ -304,10 +304,10 @@ VOID TuiDrawBox(U32 Left, U32 Top, U32 Right, U32 Bottom, UCHAR VertStyle, UCHAR
* DrawText()
* This function assumes coordinates are zero-based
*/
-VOID TuiDrawText(U32 X, U32 Y, PUCHAR Text, UCHAR Attr)
+VOID TuiDrawText(ULONG X, ULONG Y, PUCHAR Text, UCHAR Attr)
{
PUCHAR ScreenMemory = (PUCHAR)TextVideoBuffer;
- U32 i, j;
+ ULONG i, j;
// Draw the text
for (i=X, j=0; Text[j] && i
-BOOL TuiDisplayMenu(PUCHAR MenuItemList[], U32 MenuItemCount, U32 DefaultMenuItem, S32 MenuTimeOut, U32* SelectedMenuItem, BOOL CanEscape, UiMenuKeyPressFilterCallback KeyPressFilter)
+BOOL TuiDisplayMenu(PUCHAR MenuItemList[], ULONG MenuItemCount, ULONG DefaultMenuItem, LONG MenuTimeOut, ULONG* SelectedMenuItem, BOOL CanEscape, UiMenuKeyPressFilterCallback KeyPressFilter)
{
TUI_MENU_INFO MenuInformation;
- U32 LastClockSecond;
- U32 CurrentClockSecond;
- U32 KeyPress;
+ ULONG LastClockSecond;
+ ULONG CurrentClockSecond;
+ ULONG KeyPress;
//
// The first thing we need to check is the timeout
@@ -145,10 +145,10 @@ BOOL TuiDisplayMenu(PUCHAR MenuItemList[], U32 MenuItemCount, U32 DefaultMenuIte
VOID TuiCalcMenuBoxSize(PTUI_MENU_INFO MenuInfo)
{
- U32 Idx;
- U32 Width;
- U32 Height;
- U32 Length;
+ ULONG Idx;
+ ULONG Width;
+ ULONG Height;
+ ULONG Length;
//
// Height is the menu item count plus 2 (top border & bottom border)
@@ -186,7 +186,7 @@ VOID TuiCalcMenuBoxSize(PTUI_MENU_INFO MenuInfo)
VOID TuiDrawMenu(PTUI_MENU_INFO MenuInfo)
{
- U32 Idx;
+ ULONG Idx;
//
// Draw the backdrop
@@ -218,7 +218,7 @@ VOID TuiDrawMenuBox(PTUI_MENU_INFO MenuInfo)
{
UCHAR MenuLineText[80];
UCHAR TempString[80];
- U32 Idx;
+ ULONG Idx;
//
// Draw the menu box
@@ -262,13 +262,13 @@ VOID TuiDrawMenuBox(PTUI_MENU_INFO MenuInfo)
}
}
-VOID TuiDrawMenuItem(PTUI_MENU_INFO MenuInfo, U32 MenuItemNumber)
+VOID TuiDrawMenuItem(PTUI_MENU_INFO MenuInfo, ULONG MenuItemNumber)
{
- U32 Idx;
+ ULONG Idx;
UCHAR MenuLineText[80];
- U32 SpaceTotal;
- U32 SpaceLeft;
- U32 SpaceRight;
+ ULONG SpaceTotal;
+ ULONG SpaceLeft;
+ ULONG SpaceRight;
UCHAR Attribute;
//
@@ -335,9 +335,9 @@ VOID TuiDrawMenuItem(PTUI_MENU_INFO MenuInfo, U32 MenuItemNumber)
}
}
-U32 TuiProcessMenuKeyboardEvent(PTUI_MENU_INFO MenuInfo, UiMenuKeyPressFilterCallback KeyPressFilter)
+ULONG TuiProcessMenuKeyboardEvent(PTUI_MENU_INFO MenuInfo, UiMenuKeyPressFilterCallback KeyPressFilter)
{
- U32 KeyEvent = 0;
+ ULONG KeyEvent = 0;
//
// Check for a keypress
diff --git a/reactos/boot/freeldr/freeldr/ui/ui.c b/reactos/boot/freeldr/freeldr/ui/ui.c
index b930e7f9174..0b11262e03d 100644
--- a/reactos/boot/freeldr/freeldr/ui/ui.c
+++ b/reactos/boot/freeldr/freeldr/ui/ui.c
@@ -28,8 +28,8 @@
#include
#include
-U32 UiScreenWidth = 80; // Screen Width
-U32 UiScreenHeight = 25; // Screen Height
+ULONG UiScreenWidth = 80; // Screen Width
+ULONG UiScreenHeight = 25; // Screen Height
UCHAR UiStatusBarFgColor = COLOR_BLACK; // Status bar foreground color
UCHAR UiStatusBarBgColor = COLOR_CYAN; // Status bar background color
@@ -61,10 +61,10 @@ UCHAR UiMonthNames[12][15] = { "January ", "February ", "March ", "April ", "May
BOOL UiInitialize(BOOLEAN ShowGui)
{
- U32 SectionId;
+ ULONG SectionId;
UCHAR DisplayModeText[260];
UCHAR SettingText[260];
- U32 Depth;
+ ULONG Depth;
if (!ShowGui) {
if (!TuiInitialize())
@@ -233,7 +233,7 @@ VOID UiDrawBackdrop(VOID)
}
}
-VOID UiFillArea(U32 Left, U32 Top, U32 Right, U32 Bottom, UCHAR FillChar, UCHAR Attr /* Color Attributes */)
+VOID UiFillArea(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, UCHAR FillChar, UCHAR Attr /* Color Attributes */)
{
if (VideoTextMode == UiDisplayMode)
{
@@ -246,7 +246,7 @@ VOID UiFillArea(U32 Left, U32 Top, U32 Right, U32 Bottom, UCHAR FillChar, UCHAR
}
}
-VOID UiDrawShadow(U32 Left, U32 Top, U32 Right, U32 Bottom)
+VOID UiDrawShadow(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom)
{
if (VideoTextMode == UiDisplayMode)
{
@@ -259,7 +259,7 @@ VOID UiDrawShadow(U32 Left, U32 Top, U32 Right, U32 Bottom)
}
}
-VOID UiDrawBox(U32 Left, U32 Top, U32 Right, U32 Bottom, UCHAR VertStyle, UCHAR HorzStyle, BOOL Fill, BOOL Shadow, UCHAR Attr)
+VOID UiDrawBox(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, UCHAR VertStyle, UCHAR HorzStyle, BOOL Fill, BOOL Shadow, UCHAR Attr)
{
if (VideoTextMode == UiDisplayMode)
{
@@ -272,7 +272,7 @@ VOID UiDrawBox(U32 Left, U32 Top, U32 Right, U32 Bottom, UCHAR VertStyle, UCHAR
}
}
-VOID UiDrawText(U32 X, U32 Y, PUCHAR Text, UCHAR Attr)
+VOID UiDrawText(ULONG X, ULONG Y, PUCHAR Text, UCHAR Attr)
{
if (VideoTextMode == UiDisplayMode)
{
@@ -285,7 +285,7 @@ VOID UiDrawText(U32 X, U32 Y, PUCHAR Text, UCHAR Attr)
}
}
-VOID UiDrawCenteredText(U32 Left, U32 Top, U32 Right, U32 Bottom, PUCHAR TextString, UCHAR Attr)
+VOID UiDrawCenteredText(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, PUCHAR TextString, UCHAR Attr)
{
if (VideoTextMode == UiDisplayMode)
{
@@ -328,16 +328,16 @@ VOID UiUpdateDateTime(VOID)
VOID UiInfoBox(PUCHAR MessageText)
{
- U32 TextLength;
- U32 BoxWidth;
- U32 BoxHeight;
- U32 LineBreakCount;
- U32 Index;
- U32 LastIndex;
- U32 Left;
- U32 Top;
- U32 Right;
- U32 Bottom;
+ ULONG TextLength;
+ ULONG BoxWidth;
+ ULONG BoxHeight;
+ ULONG LineBreakCount;
+ ULONG Index;
+ ULONG LastIndex;
+ ULONG Left;
+ ULONG Top;
+ ULONG Right;
+ ULONG Bottom;
TextLength = strlen(MessageText);
@@ -465,7 +465,7 @@ UCHAR UiTextToFillStyle(PUCHAR FillStyleText)
}
}
-VOID UiDrawProgressBarCenter(U32 Position, U32 Range, PUCHAR ProgressText)
+VOID UiDrawProgressBarCenter(ULONG Position, ULONG Range, PUCHAR ProgressText)
{
if (!UserInterfaceUp) return;
@@ -480,7 +480,7 @@ VOID UiDrawProgressBarCenter(U32 Position, U32 Range, PUCHAR ProgressText)
}
}
-VOID UiDrawProgressBar(U32 Left, U32 Top, U32 Right, U32 Bottom, U32 Position, U32 Range, PUCHAR ProgressText)
+VOID UiDrawProgressBar(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, ULONG Position, ULONG Range, PUCHAR ProgressText)
{
if (VideoTextMode == UiDisplayMode)
{
@@ -495,12 +495,12 @@ VOID UiDrawProgressBar(U32 Left, U32 Top, U32 Right, U32 Bottom, U32 Position, U
VOID UiShowMessageBoxesInSection(PUCHAR SectionName)
{
- U32 Idx;
+ ULONG Idx;
UCHAR SettingName[80];
UCHAR SettingValue[80];
PUCHAR MessageBoxText;
- U32 MessageBoxTextSize;
- U32 SectionId;
+ ULONG MessageBoxTextSize;
+ ULONG SectionId;
if (!IniOpenSection(SectionName, &SectionId))
{
@@ -547,7 +547,7 @@ VOID UiShowMessageBoxesInSection(PUCHAR SectionName)
VOID UiEscapeString(PUCHAR String)
{
- U32 Idx;
+ ULONG Idx;
for (Idx=0; Idx MaxChars)
{
@@ -571,7 +571,7 @@ VOID UiTruncateStringEllipsis(PUCHAR StringText, U32 MaxChars)
}
}
-BOOL UiDisplayMenu(PUCHAR MenuItemList[], U32 MenuItemCount, U32 DefaultMenuItem, S32 MenuTimeOut, U32* SelectedMenuItem, BOOL CanEscape, UiMenuKeyPressFilterCallback KeyPressFilter)
+BOOL UiDisplayMenu(PUCHAR MenuItemList[], ULONG MenuItemCount, ULONG DefaultMenuItem, LONG MenuTimeOut, ULONG* SelectedMenuItem, BOOL CanEscape, UiMenuKeyPressFilterCallback KeyPressFilter)
{
if (VideoTextMode == UiDisplayMode)
{
@@ -611,7 +611,7 @@ VOID UiFadeOut(VOID)
}
}
-BOOL UiEditBox(PUCHAR MessageText, PUCHAR EditTextBuffer, U32 Length)
+BOOL UiEditBox(PUCHAR MessageText, PUCHAR EditTextBuffer, ULONG Length)
{
if (VideoTextMode == UiDisplayMode)
{
diff --git a/reactos/boot/freeldr/freeldr/video/fade.c b/reactos/boot/freeldr/freeldr/video/fade.c
index db8ab3d98c6..c5d69b37ef8 100644
--- a/reactos/boot/freeldr/freeldr/video/fade.c
+++ b/reactos/boot/freeldr/freeldr/video/fade.c
@@ -25,9 +25,9 @@
#define RGB_MAX 64
#define RGB_MAX_PER_ITERATION 64
-VOID VideoSetAllColorsToBlack(U32 ColorCount)
+VOID VideoSetAllColorsToBlack(ULONG ColorCount)
{
- U32 Color;
+ ULONG Color;
MachVideoSync();
@@ -37,10 +37,10 @@ VOID VideoSetAllColorsToBlack(U32 ColorCount)
}
}
-VOID VideoFadeIn(PPALETTE_ENTRY Palette, U32 ColorCount)
+VOID VideoFadeIn(PPALETTE_ENTRY Palette, ULONG ColorCount)
{
- U32 Index;
- U32 Color;
+ ULONG Index;
+ ULONG Color;
PALETTE_ENTRY PaletteColors[ColorCount];
for (Index=0; Index
#include
-VOID VideoSavePaletteState(PPALETTE_ENTRY Palette, U32 ColorCount)
+VOID VideoSavePaletteState(PPALETTE_ENTRY Palette, ULONG ColorCount)
{
- U32 Color;
+ ULONG Color;
for (Color=0; Color = ,,
diff --git a/reactos/config b/reactos/config
index 92565649585..5a8c1f69da9 100644
--- a/reactos/config
+++ b/reactos/config
@@ -8,7 +8,7 @@ ARCH := i386
#
# Which cpu should reactos optimze for
-# example : i486, i586, pentium, pentium2, pentum3, pentium4
+# example : i486, i586, pentium, pentium2, pentium3, pentium4
# athlon-xp, athlon-mp, k6-2,
#
# see gcc manual for more cpu name and which cpu it can
@@ -25,7 +25,7 @@ KDBG := 0
#
# Whether to compile for debugging
#
-DBG := 0
+DBG := 0
#
# Whether to compile with optimizations
@@ -35,7 +35,7 @@ OPTIMIZED := 0
#
# Whether to compile a multiprocessor or single processor version
#
-MP := 0
+CONFIG_SMP := 0
#
# Whether to compile for ACPI compliant systems
@@ -45,7 +45,7 @@ ACPI := 0
#
# whether to use a 3GB User, 1GB Kernel memory map
#
-3GB := 1
+3GB := 0
#
# Which version of NDIS do we support up to?
diff --git a/reactos/doc/README.WINE b/reactos/doc/README.WINE
index 0d0aa38b2a4..e1009d7acb4 100644
--- a/reactos/doc/README.WINE
+++ b/reactos/doc/README.WINE
@@ -34,39 +34,39 @@ reactos/tools/wmc # Wine Message Compiler
The following shared libraries are a 100% port from Winehq sources.
-reactos/lib/cabinet # Synced to Wine-20041201
-reactos/lib/comctl32 # Synced to Wine-20041201
-reactos/lib/comdlg32 # Synced to Wine-20041201
-reactos/lib/dinput # Synced to Wine-20041201
-reactos/lib/dinput8 # Synced to Wine-20041201
-reactos/lib/icmp # Synced to Wine-20041201
+reactos/lib/cabinet # Synced to Wine-20050111
+reactos/lib/comctl32 # Synced to Wine-20050111
+reactos/lib/comdlg32 # Synced to Wine-20050111
+reactos/lib/dinput # Synced to Wine-20050111
+reactos/lib/dinput8 # Synced to Wine-20050111
+reactos/lib/icmp # Synced to Wine-20050111
reactos/lib/iphlpapi # Out of sync
reactos/lib/imagehlp # Patches for BindImage need review and submission to winehq.
reactos/lib/msvcrt20 # Out of sync
-reactos/lib/mpr # Synced to Wine-20041201
+reactos/lib/mpr # Synced to Wine-20050111
reactos/lib/msacm # Out of sync
-reactos/lib/msi # Synced to Wine-20041201
+reactos/lib/msi # Synced to Wine-20050111
reactos/lib/msvideo # Out of sync
reactos/lib/netapi32 # Out of sync
reactos/lib/odbc32 # In sync. Depends on port of Linux ODBC.
-reactos/lib/ole32 # Synced to Wine-20041201
-reactos/lib/oleaut32 # Synced to Wine-20041201
-reactos/lib/oledlg # Synced to Wine-20041201
-reactos/lib/olepro32 # Synced to Wine-20041201
-reactos/lib/richedit # Synced to Wine-20041201
-reactos/lib/rpcrt4 # Synced to Wine-20041201
-reactos/lib/setupapi # Out of sync
-reactos/lib/shell32 # Synced to Wine-20041201
-reactos/lib/shdocvw # Synced to Wine-20041201
-reactos/lib/shlwapi # Synced to Wine-20041201
+reactos/lib/ole32 # Synced to Wine-20050111
+reactos/lib/oleaut32 # Synced to Wine-20050111
+reactos/lib/oledlg # Synced to Wine-20050111
+reactos/lib/olepro32 # Synced to Wine-20050111
+reactos/lib/richedit # Synced to Wine-20050111
+reactos/lib/rpcrt4 # Synced to Wine-20050111
+reactos/lib/setupapi # Synced to Wine-20050125 # CVS
+reactos/lib/shell32 # Synced to Wine-20050111
+reactos/lib/shdocvw # Synced to Wine-20050111
+reactos/lib/shlwapi # Synced to Wine-20050111
reactos/lib/twain # Out of sync
-reactos/lib/unicode # Dependancy on this lib needs to be removed. Synced to Wine-20041201
-reactos/lib/urlmon # Synced to Wine-20041201
+reactos/lib/unicode # Dependancy on this lib needs to be removed. Synced to Wine-20050111
+reactos/lib/urlmon # Synced to Wine-20050111
reactos/lib/version # Out of sync
reactos/lib/wininet # Out of sync
-reactos/lib/winmm # Synced to Wine-20041201
-reactos/lib/winmm/midimap # Synced to Wine-20041201
-reactos/lib/winmm/wavemap # Synced to Wine-20041201
+reactos/lib/winmm # Synced to Wine-20050111
+reactos/lib/winmm/midimap # Synced to Wine-20050111
+reactos/lib/winmm/wavemap # Synced to Wine-20050111
ReactOS shares the following programs with Winehq.
reactos/subsys/system/regedit # Out of sync
@@ -100,5 +100,3 @@ User32 -
reactos/lib/user32/misc/wsprintf.c # Out of sync
reactos/lib/user32/windows/mdi.c # Out of sync
-
- `
\ No newline at end of file
diff --git a/reactos/drivers/bus/acpi/ospm/osl.c b/reactos/drivers/bus/acpi/ospm/osl.c
index fed55a17d54..741f0714c91 100644
--- a/reactos/drivers/bus/acpi/ospm/osl.c
+++ b/reactos/drivers/bus/acpi/ospm/osl.c
@@ -219,6 +219,11 @@ acpi_os_install_interrupt_handler(u32 irq, OSD_HANDLER handler, void *context)
&DIrql,
&Affinity);
+ AcpiIrqNumber = irq;
+ AcpiIrqHandler = handler;
+ AcpiIrqContext = context;
+ AcpiInterruptHandlerRegistered = TRUE;
+
Status = IoConnectInterrupt(
&AcpiInterrupt,
OslIsrStub,
@@ -236,11 +241,6 @@ acpi_os_install_interrupt_handler(u32 irq, OSD_HANDLER handler, void *context)
return AE_ERROR;
}
- AcpiIrqNumber = irq;
- AcpiIrqHandler = handler;
- AcpiIrqContext = context;
- AcpiInterruptHandlerRegistered = TRUE;
-
return AE_OK;
}
diff --git a/reactos/drivers/dd/bootvid/bootvid.c b/reactos/drivers/dd/bootvid/bootvid.c
index c1e468da2e4..20807f34d26 100644
--- a/reactos/drivers/dd/bootvid/bootvid.c
+++ b/reactos/drivers/dd/bootvid/bootvid.c
@@ -66,7 +66,6 @@ PUCHAR VideoMemory;
/* Must be 4 bytes per entry */
long maskbit[640];
-static HANDLE BitmapThreadHandle;
static CLIENT_ID BitmapThreadId;
static PUCHAR BootimageBitmap;
@@ -556,6 +555,7 @@ STATIC BOOLEAN STDCALL
VidInitialize(VOID)
{
NTSTATUS Status;
+ HANDLE BitmapThreadHandle;
InbvMapVideoMemory();
InbvInitVGAMode();
@@ -574,7 +574,7 @@ VidInitialize(VOID)
return FALSE;
}
- NtClose(BitmapThreadHandle);
+ ZwClose(BitmapThreadHandle);
return TRUE;
}
diff --git a/reactos/drivers/dd/bootvid/pixelsup_i386.S b/reactos/drivers/dd/bootvid/pixelsup_i386.S
index 34244ec4ddb..3fd07c40375 100644
--- a/reactos/drivers/dd/bootvid/pixelsup_i386.S
+++ b/reactos/drivers/dd/bootvid/pixelsup_i386.S
@@ -28,6 +28,8 @@
_InbvPutPixels:
pushl %ebp
movl %esp, %ebp
+ pushl %esi
+ pushl %ebx
/* Compute mask and put it in EBX
mask = maskbit[x] */
@@ -66,7 +68,7 @@ _InbvPutPixels:
(UCHAR) READ_REGISTER_UCHAR(VideoMemory + offset+0); */
movl (_VideoMemory), %esi
addl %ebx, %esi
- movb 0x0(%esi), %bl
+ movb 0x0(%esi), %bl
/* Write color index for first pixel
*((PUCHAR)(VideoMemory + offset+0)) = (c >> 0*8) & 0xff; */
movl 0x10(%ebp), %eax
@@ -96,6 +98,8 @@ _InbvPutPixels:
shrl $0x8, %eax
movb %al, 0x3(%esi)
+ popl %ebx
+ popl %esi
popl %ebp
ret
diff --git a/reactos/drivers/dd/ramdrv/ramdrv.c b/reactos/drivers/dd/ramdrv/ramdrv.c
index 0f4772853ab..b3304be5bf9 100644
--- a/reactos/drivers/dd/ramdrv/ramdrv.c
+++ b/reactos/drivers/dd/ramdrv/ramdrv.c
@@ -139,7 +139,7 @@ NTSTATUS STDCALL DriverEntry(IN PDRIVER_OBJECT DriverObject,
0 );
allocsize.u.LowPart = allocsize.u.HighPart = 0;
- Status = NtOpenFile( &file,
+ Status = ZwOpenFile( &file,
GENERIC_READ,
&objattr,
&iosb,
@@ -157,7 +157,7 @@ NTSTATUS STDCALL DriverEntry(IN PDRIVER_OBJECT DriverObject,
0,
0,
0 );
- Status = NtCreateEvent( &event,
+ Status = ZwCreateEvent( &event,
0,
&objattr,
NotificationEvent,
@@ -168,7 +168,7 @@ NTSTATUS STDCALL DriverEntry(IN PDRIVER_OBJECT DriverObject,
goto cleanfile;
}
- Status = NtQueryInformationFile( file,
+ Status = ZwQueryInformationFile( file,
&iosb,
&finfo,
sizeof( finfo ),
@@ -187,7 +187,7 @@ NTSTATUS STDCALL DriverEntry(IN PDRIVER_OBJECT DriverObject,
goto cleanevent;
}
- Status = NtReadFile( file,
+ Status = ZwReadFile( file,
event,
0,
0,
@@ -202,7 +202,7 @@ NTSTATUS STDCALL DriverEntry(IN PDRIVER_OBJECT DriverObject,
DPRINT( "Failed to read floppy\n" );
goto cleantbuff;
}
- Status = NtWaitForSingleObject( event, FALSE, 0 );
+ Status = ZwWaitForSingleObject( event, FALSE, 0 );
if( Status != STATUS_WAIT_0 || !NT_SUCCESS( iosb.Status ) )
{
DPRINT( "Failed to read floppy\n" );
@@ -221,16 +221,16 @@ NTSTATUS STDCALL DriverEntry(IN PDRIVER_OBJECT DriverObject,
}
else DbgPrint( "RAMDRV: Failed to decomparess image, error: %d\n", err );
ExFreePool( tbuff );
- NtClose( file );
- NtClose( event );
+ ZwClose( file );
+ ZwClose( event );
return STATUS_SUCCESS;
cleantbuff:
ExFreePool( tbuff );
cleanevent:
- NtClose( event );
+ ZwClose( event );
cleanfile:
- NtClose( file );
+ ZwClose( file );
cleanbuffer:
ExFreePool( devext->Buffer );
diff --git a/reactos/drivers/fs/cdfs/common.c b/reactos/drivers/fs/cdfs/common.c
index 940179adbf4..9e247805872 100644
--- a/reactos/drivers/fs/cdfs/common.c
+++ b/reactos/drivers/fs/cdfs/common.c
@@ -191,6 +191,19 @@ CdfsDeviceIoControl (IN PDEVICE_OBJECT DeviceObject,
*OutputBufferSize = IoStatus.Information;
}
+ if (Status == STATUS_VERIFY_REQUIRED)
+ {
+ PDEVICE_OBJECT DeviceToVerify;
+ NTSTATUS NewStatus;
+
+ DPRINT1("STATUS_VERIFY_REQUIRED\n");
+ DeviceToVerify = IoGetDeviceToVerify(PsGetCurrentThread());
+ IoSetDeviceToVerify(PsGetCurrentThread(), NULL);
+
+ NewStatus = IoVerifyVolume(DeviceToVerify, FALSE);
+ DPRINT1("IoVerifyVolume() retuned (Status %lx)\n", NewStatus);
+ }
+
DPRINT("Returning Status %x\n", Status);
return Status;
diff --git a/reactos/drivers/fs/cdfs/create.c b/reactos/drivers/fs/cdfs/create.c
index 9ceaa6652b3..7bbef26a01c 100644
--- a/reactos/drivers/fs/cdfs/create.c
+++ b/reactos/drivers/fs/cdfs/create.c
@@ -44,7 +44,6 @@ CdfsMakeAbsoluteFilename(PFILE_OBJECT FileObject,
PUNICODE_STRING AbsoluteFileName)
{
ULONG Length;
-// PWSTR rcName;
PFCB Fcb;
NTSTATUS Status;
@@ -65,42 +64,29 @@ CdfsMakeAbsoluteFilename(PFILE_OBJECT FileObject,
sizeof(WCHAR) +
RelativeFileName->Length +
sizeof(WCHAR);
-// ASSERT(wcslen (Fcb->PathName) + 1 + wcslen (pRelativeFileName) + 1
-// <= MAX_PATH);
-// rcName = ExAllocatePool(NonPagedPool, MAX_PATH * sizeof(WCHAR));
-// if (!rcName)
-// {
-// return(STATUS_INSUFFICIENT_RESOURCES);
-// }
AbsoluteFileName->Length = 0;
AbsoluteFileName->MaximumLength = Length;
AbsoluteFileName->Buffer = ExAllocatePool(NonPagedPool,
Length);
if (AbsoluteFileName->Buffer == NULL)
{
-CHECKPOINT1;
return STATUS_INSUFFICIENT_RESOURCES;
}
-
-// wcscpy(rcName, Fcb->PathName);
Status = RtlAppendUnicodeToString(AbsoluteFileName,
Fcb->PathName);
if (!NT_SUCCESS(Status))
{
-CHECKPOINT1;
RtlFreeUnicodeString(AbsoluteFileName);
return Status;
}
if (!CdfsFCBIsRoot(Fcb))
{
-// wcscat (rcName, L"\\");
Status = RtlAppendUnicodeToString(AbsoluteFileName,
L"\\");
if (!NT_SUCCESS(Status))
{
-CHECKPOINT1;
RtlFreeUnicodeString(AbsoluteFileName);
return Status;
}
@@ -110,14 +96,10 @@ CHECKPOINT1;
RelativeFileName);
if (!NT_SUCCESS(Status))
{
-CHECKPOINT1;
RtlFreeUnicodeString(AbsoluteFileName);
return Status;
}
-// wcscat (rcName, pRelativeFileName);
-// *pAbsoluteFilename = rcName;
-
return STATUS_SUCCESS;
}
@@ -150,10 +132,6 @@ CdfsOpenFile(PDEVICE_EXTENSION DeviceExt,
}
FileName = &AbsFileName;
-
- RtlFreeUnicodeString(&AbsFileName);
-
- return STATUS_UNSUCCESSFUL;
}
Status = CdfsDeviceIoControl (DeviceExt->StorageDevice,
@@ -162,28 +140,9 @@ CdfsOpenFile(PDEVICE_EXTENSION DeviceExt,
0,
NULL,
0,
- TRUE);
+ FALSE);
DPRINT ("Status %lx\n", Status);
- if (Status == STATUS_VERIFY_REQUIRED)
- {
- PDEVICE_OBJECT DeviceToVerify;
-
- DPRINT1 ("Media change detected!\n");
- DPRINT1 ("Device %p\n", DeviceExt->VolumeDevice);
-
- DeviceToVerify = IoGetDeviceToVerify (PsGetCurrentThread ());
- IoSetDeviceToVerify (PsGetCurrentThread (),
- NULL);
-
- Status = IoVerifyVolume (DeviceToVerify,
- FALSE);
- if (!NT_SUCCESS(Status))
- {
- DPRINT1 ("Status %lx\n", Status);
- return Status;
- }
- }
- else if (!NT_SUCCESS(Status))
+ if (!NT_SUCCESS(Status))
{
DPRINT1 ("Status %lx\n", Status);
return Status;
diff --git a/reactos/drivers/fs/cdfs/fcb.c b/reactos/drivers/fs/cdfs/fcb.c
index a34a554c42e..afb602b133b 100644
--- a/reactos/drivers/fs/cdfs/fcb.c
+++ b/reactos/drivers/fs/cdfs/fcb.c
@@ -234,8 +234,6 @@ CdfsFCBInitializeCache(PVCB Vcb,
RtlZeroMemory(newCCB,
sizeof(CCB));
- FileObject->Flags = FileObject->Flags | FO_FCB_IS_VALID |
- FO_DIRECT_CACHE_PAGING_READ;
FileObject->SectionObjectPointer = &Fcb->SectionObjectPointers;
FileObject->FsContext = Fcb;
FileObject->FsContext2 = newCCB;
@@ -423,8 +421,6 @@ CdfsAttachFCBToFileObject(PDEVICE_EXTENSION Vcb,
}
memset(newCCB, 0, sizeof(CCB));
- FileObject->Flags = FileObject->Flags | FO_FCB_IS_VALID |
- FO_DIRECT_CACHE_PAGING_READ;
FileObject->SectionObjectPointer = &Fcb->SectionObjectPointers;
FileObject->FsContext = Fcb;
FileObject->FsContext2 = newCCB;
diff --git a/reactos/drivers/fs/cdfs/fsctl.c b/reactos/drivers/fs/cdfs/fsctl.c
index 15b25584c7c..85f67040781 100644
--- a/reactos/drivers/fs/cdfs/fsctl.c
+++ b/reactos/drivers/fs/cdfs/fsctl.c
@@ -345,6 +345,7 @@ CdfsMountVolume(PDEVICE_OBJECT DeviceObject,
goto ByeBye;
NewDeviceObject->Flags = NewDeviceObject->Flags | DO_DIRECT_IO;
+ NewDeviceObject->Flags &= ~DO_VERIFY_VOLUME;
DeviceExt = (PVOID)NewDeviceObject->DeviceExtension;
RtlZeroMemory(DeviceExt,
sizeof(DEVICE_EXTENSION));
@@ -385,7 +386,6 @@ CdfsMountVolume(PDEVICE_OBJECT DeviceObject,
RtlZeroMemory(Ccb,
sizeof(CCB));
- DeviceExt->StreamFileObject->Flags = DeviceExt->StreamFileObject->Flags | FO_FCB_IS_VALID | FO_DIRECT_CACHE_PAGING_READ;
DeviceExt->StreamFileObject->FsContext = Fcb;
DeviceExt->StreamFileObject->FsContext2 = Ccb;
DeviceExt->StreamFileObject->SectionObjectPointer = &Fcb->SectionObjectPointers;
diff --git a/reactos/drivers/fs/np/create.c b/reactos/drivers/fs/np/create.c
index cdbef4032ce..4c18f268e5f 100644
--- a/reactos/drivers/fs/np/create.c
+++ b/reactos/drivers/fs/np/create.c
@@ -192,14 +192,14 @@ NpfsCreate(PDEVICE_OBJECT DeviceObject,
KeInitializeEvent(&ClientFcb->Event, SynchronizationEvent, FALSE);
/*
- * Step 4. Add the client FCB to a list and connect it if necessary.
+ * Step 4. Add the client FCB to a list and connect it if possible.
*/
/* Add the client FCB to the pipe FCB list. */
InsertTailList(&Pipe->ClientFcbListHead, &ClientFcb->FcbListEntry);
- /* Connect pipes if they were created by the same thread */
- if (ServerFcb && ServerFcb->Thread == ClientFcb->Thread)
+ /* Connect to listening server side */
+ if (ServerFcb)
{
ClientFcb->OtherSide = ServerFcb;
ServerFcb->OtherSide = ClientFcb;
@@ -320,11 +320,11 @@ NpfsCreateNamedPipe(PDEVICE_OBJECT DeviceObject,
InitializeListHead(&Pipe->ClientFcbListHead);
KeInitializeMutex(&Pipe->FcbListLock, 0);
- Pipe->PipeType = Buffer->NamedPipeType ? FILE_PIPE_MESSAGE_TYPE : FILE_PIPE_BYTE_STREAM_TYPE;
- Pipe->PipeWriteMode = Buffer->NamedPipeType ? FILE_PIPE_MESSAGE_MODE : FILE_PIPE_BYTE_STREAM_MODE;
- Pipe->PipeReadMode = Buffer->ReadMode ? FILE_PIPE_MESSAGE_MODE : FILE_PIPE_BYTE_STREAM_MODE;
- Pipe->PipeBlockMode = Buffer->CompletionMode;
- Pipe->PipeConfiguration = IoStack->Parameters.Create.Options & 0x3;
+ Pipe->PipeType = Buffer->NamedPipeType;
+ Pipe->WriteMode = Buffer->ReadMode;
+ Pipe->ReadMode = Buffer->ReadMode;
+ Pipe->CompletionMode = Buffer->CompletionMode;
+ Pipe->PipeConfiguration = IoStack->Parameters.CreatePipe.Options & 0x3;
Pipe->MaximumInstances = Buffer->MaximumInstances;
Pipe->CurrentInstances = 0;
Pipe->TimeOut = Buffer->DefaultTimeout;
diff --git a/reactos/drivers/fs/np/fsctrl.c b/reactos/drivers/fs/np/fsctrl.c
index f0d9d5c4433..0e8e2633b54 100644
--- a/reactos/drivers/fs/np/fsctrl.c
+++ b/reactos/drivers/fs/np/fsctrl.c
@@ -217,64 +217,31 @@ static NTSTATUS
NpfsGetState(PIRP Irp,
PIO_STACK_LOCATION IrpSp)
{
- ULONG OutputBufferLength;
PNPFS_GET_STATE Reply;
- NTSTATUS Status;
PNPFS_PIPE Pipe;
PNPFS_FCB Fcb;
- OutputBufferLength = IrpSp->Parameters.DeviceIoControl.OutputBufferLength;
-
/* Validate parameters */
- if (OutputBufferLength >= sizeof(NPFS_GET_STATE))
+ if (IrpSp->Parameters.DeviceIoControl.OutputBufferLength < sizeof(NPFS_GET_STATE))
{
- Fcb = IrpSp->FileObject->FsContext;
- Reply = (PNPFS_GET_STATE)Irp->AssociatedIrp.SystemBuffer;
- Pipe = Fcb->Pipe;
-
- if (Pipe->PipeWriteMode == FILE_PIPE_MESSAGE_MODE)
- {
- Reply->WriteModeMessage = TRUE;
- }
- else
- {
- Reply->WriteModeMessage = FALSE;
+ DPRINT("Status (0x%X).\n", STATUS_INVALID_PARAMETER);
+ return STATUS_INVALID_PARAMETER;
}
- if (Pipe->PipeReadMode == FILE_PIPE_MESSAGE_MODE)
- {
- Reply->ReadModeMessage = TRUE;
- }
- else
- {
- Reply->ReadModeMessage = FALSE;
- }
+ Fcb = IrpSp->FileObject->FsContext;
+ Reply = (PNPFS_GET_STATE)Irp->AssociatedIrp.SystemBuffer;
+ Pipe = Fcb->Pipe;
- if (Pipe->PipeBlockMode == FILE_PIPE_QUEUE_OPERATION)
- {
- Reply->NonBlocking = TRUE;
- }
- else
- {
- Reply->NonBlocking = FALSE;
- }
+ Reply->WriteModeMessage = (Pipe->WriteMode == FILE_PIPE_MESSAGE_MODE);
+ Reply->ReadModeMessage = (Pipe->ReadMode == FILE_PIPE_MESSAGE_MODE);
+ Reply->NonBlocking = (Pipe->CompletionMode == FILE_PIPE_QUEUE_OPERATION);
+ Reply->InBufferSize = Pipe->InboundQuota;
+ Reply->OutBufferSize = Pipe->OutboundQuota;
+ Reply->Timeout = Pipe->TimeOut;
- Reply->InBufferSize = Pipe->InboundQuota;
+ DPRINT("Status (0x%X).\n", STATUS_SUCCESS);
- Reply->OutBufferSize = Pipe->OutboundQuota;
-
- Reply->Timeout = Pipe->TimeOut;
-
- Status = STATUS_SUCCESS;
- }
- else
- {
- Status = STATUS_INVALID_PARAMETER;
- }
-
- DPRINT("Status (0x%X).\n", Status);
-
- return Status;
+ return STATUS_SUCCESS;
}
@@ -290,64 +257,34 @@ static NTSTATUS
NpfsSetState(PIRP Irp,
PIO_STACK_LOCATION IrpSp)
{
- ULONG InputBufferLength;
PNPFS_SET_STATE Request;
PNPFS_PIPE Pipe;
- NTSTATUS Status;
PNPFS_FCB Fcb;
- InputBufferLength = IrpSp->Parameters.DeviceIoControl.InputBufferLength;
-
/* Validate parameters */
- if (InputBufferLength >= sizeof(NPFS_SET_STATE))
- {
- Fcb = IrpSp->FileObject->FsContext;
- Request = (PNPFS_SET_STATE)Irp->AssociatedIrp.SystemBuffer;
- Pipe = Fcb->Pipe;
-
- if (Request->WriteModeMessage)
+ if (IrpSp->Parameters.DeviceIoControl.InputBufferLength < sizeof(NPFS_SET_STATE))
{
- Pipe->PipeWriteMode = FILE_PIPE_MESSAGE_MODE;
- }
- else
- {
- Pipe->PipeWriteMode = FILE_PIPE_BYTE_STREAM_MODE;
+ DPRINT("Status (0x%X).\n", STATUS_INVALID_PARAMETER);
+ return STATUS_INVALID_PARAMETER;
}
- if (Request->ReadModeMessage)
- {
- Pipe->PipeReadMode = FILE_PIPE_MESSAGE_MODE;
- }
- else
- {
- Pipe->PipeReadMode = FILE_PIPE_BYTE_STREAM_MODE;
- }
+ Fcb = IrpSp->FileObject->FsContext;
+ Request = (PNPFS_SET_STATE)Irp->AssociatedIrp.SystemBuffer;
+ Pipe = Fcb->Pipe;
- if (Request->NonBlocking)
- {
- Pipe->PipeBlockMode = FILE_PIPE_QUEUE_OPERATION;
- }
- else
- {
- Pipe->PipeBlockMode = FILE_PIPE_COMPLETE_OPERATION;
- }
+ Pipe->WriteMode =
+ Request->WriteModeMessage ? FILE_PIPE_MESSAGE_MODE : FILE_PIPE_BYTE_STREAM_MODE;
+ Pipe->ReadMode =
+ Request->WriteModeMessage ? FILE_PIPE_MESSAGE_MODE : FILE_PIPE_BYTE_STREAM_MODE;
+ Pipe->CompletionMode =
+ Request->NonBlocking ? FILE_PIPE_QUEUE_OPERATION : FILE_PIPE_COMPLETE_OPERATION;
+ Pipe->InboundQuota = Request->InBufferSize;
+ Pipe->OutboundQuota = Request->OutBufferSize;
+ Pipe->TimeOut = Request->Timeout;
- Pipe->InboundQuota = Request->InBufferSize;
+ DPRINT("Status (0x%X).\n", STATUS_SUCCESS);
- Pipe->OutboundQuota = Request->OutBufferSize;
-
- Pipe->TimeOut = Request->Timeout;
-
- Status = STATUS_SUCCESS;
- }
- else
- {
- Status = STATUS_INVALID_PARAMETER;
- }
-
- DPRINT("Status (0x%X).\n", Status);
-
- return Status;
+ return STATUS_SUCCESS;
}
diff --git a/reactos/drivers/fs/np/npfs.h b/reactos/drivers/fs/np/npfs.h
index db552a55ec2..f7e70f463ca 100644
--- a/reactos/drivers/fs/np/npfs.h
+++ b/reactos/drivers/fs/np/npfs.h
@@ -26,9 +26,9 @@ typedef struct _NPFS_PIPE
LIST_ENTRY ServerFcbListHead;
LIST_ENTRY ClientFcbListHead;
ULONG PipeType;
- ULONG PipeReadMode;
- ULONG PipeWriteMode;
- ULONG PipeBlockMode;
+ ULONG ReadMode;
+ ULONG WriteMode;
+ ULONG CompletionMode;
ULONG PipeConfiguration;
ULONG MaximumInstances;
ULONG CurrentInstances;
diff --git a/reactos/drivers/fs/np/rw.c b/reactos/drivers/fs/np/rw.c
index 7bbf3c35bd0..aab1872ff03 100644
--- a/reactos/drivers/fs/np/rw.c
+++ b/reactos/drivers/fs/np/rw.c
@@ -168,7 +168,7 @@ NpfsRead(PDEVICE_OBJECT DeviceObject,
KeAcquireSpinLock(&ReadFcb->DataListLock, &OldIrql);
}
- if (Pipe->PipeReadMode == FILE_PIPE_BYTE_STREAM_MODE)
+ if (Pipe->ReadMode == FILE_PIPE_BYTE_STREAM_MODE)
{
DPRINT("Byte stream mode\n");
/* Byte stream mode */
@@ -363,7 +363,7 @@ NpfsWrite(PDEVICE_OBJECT DeviceObject,
KeAcquireSpinLock(&Fcb->DataListLock, &OldIrql);
}
- if (Pipe->PipeWriteMode == FILE_PIPE_BYTE_STREAM_MODE)
+ if (Pipe->WriteMode == FILE_PIPE_BYTE_STREAM_MODE)
{
DPRINT("Byte stream mode\n");
while (Length > 0 && Fcb->WriteQuotaAvailable > 0)
diff --git a/reactos/drivers/fs/ntfs/fcb.c b/reactos/drivers/fs/ntfs/fcb.c
index 77a4220b50b..31029adf4e7 100644
--- a/reactos/drivers/fs/ntfs/fcb.c
+++ b/reactos/drivers/fs/ntfs/fcb.c
@@ -235,8 +235,6 @@ NtfsFCBInitializeCache(PVCB Vcb,
RtlZeroMemory(newCCB,
sizeof(CCB));
- FileObject->Flags = FileObject->Flags | FO_FCB_IS_VALID |
- FO_DIRECT_CACHE_PAGING_READ;
FileObject->SectionObjectPointer = &Fcb->SectionObjectPointers;
FileObject->FsContext = Fcb;
FileObject->FsContext2 = newCCB;
@@ -406,8 +404,6 @@ NtfsAttachFCBToFileObject(PDEVICE_EXTENSION Vcb,
}
memset(newCCB, 0, sizeof(CCB));
- FileObject->Flags = FileObject->Flags | FO_FCB_IS_VALID |
- FO_DIRECT_CACHE_PAGING_READ;
FileObject->SectionObjectPointer = &Fcb->SectionObjectPointers;
FileObject->FsContext = Fcb;
FileObject->FsContext2 = newCCB;
diff --git a/reactos/drivers/fs/ntfs/fsctl.c b/reactos/drivers/fs/ntfs/fsctl.c
index 938fb1e5c95..41071faaf20 100644
--- a/reactos/drivers/fs/ntfs/fsctl.c
+++ b/reactos/drivers/fs/ntfs/fsctl.c
@@ -370,7 +370,6 @@ NtfsMountVolume(PDEVICE_OBJECT DeviceObject,
RtlZeroMemory(Ccb,
sizeof(CCB));
- DeviceExt->StreamFileObject->Flags = DeviceExt->StreamFileObject->Flags | FO_FCB_IS_VALID | FO_DIRECT_CACHE_PAGING_READ;
DeviceExt->StreamFileObject->FsContext = Fcb;
DeviceExt->StreamFileObject->FsContext2 = Ccb;
DeviceExt->StreamFileObject->SectionObjectPointer = &Fcb->SectionObjectPointers;
diff --git a/reactos/drivers/fs/vfat/blockdev.c b/reactos/drivers/fs/vfat/blockdev.c
index cf97ada1242..a653fe89567 100644
--- a/reactos/drivers/fs/vfat/blockdev.c
+++ b/reactos/drivers/fs/vfat/blockdev.c
@@ -10,11 +10,7 @@
/* INCLUDES *****************************************************************/
-#include
-
#define NDEBUG
-#include
-
#include "vfat.h"
/* FUNCTIONS ***************************************************************/
@@ -71,7 +67,7 @@ VfatReadDisk (IN PDEVICE_OBJECT pDeviceObject,
KeInitializeEvent (&event, NotificationEvent, FALSE);
- DPRINT ("VfatReadSectors(pDeviceObject %x, Offset %I64x, Length %d, Buffer %x)\n",
+ DPRINT ("VfatReadDisk(pDeviceObject %x, Offset %I64x, Length %d, Buffer %x)\n",
pDeviceObject, ReadOffset->QuadPart, ReadLength, Buffer);
DPRINT ("Building synchronous FSD Request...\n");
@@ -108,7 +104,7 @@ VfatReadDisk (IN PDEVICE_OBJECT pDeviceObject,
if (!NT_SUCCESS (Status))
{
- DPRINT ("IO failed!!! VfatReadSectors : Error code: %x\n", Status);
+ DPRINT ("IO failed!!! VfatReadDisk : Error code: %x\n", Status);
DPRINT ("(pDeviceObject %x, Offset %I64x, Size %d, Buffer %x\n",
pDeviceObject, ReadOffset->QuadPart, ReadLength, Buffer);
return (Status);
@@ -134,7 +130,7 @@ VfatReadDiskPartial (IN PVFAT_IRP_CONTEXT IrpContext,
DPRINT ("Building asynchronous FSD Request...\n");
- Buffer = MmGetMdlVirtualAddress(IrpContext->Irp->MdlAddress) + BufferOffset;
+ Buffer = (PCHAR)MmGetMdlVirtualAddress(IrpContext->Irp->MdlAddress) + BufferOffset;
Irp = IoAllocateIrp(IrpContext->DeviceExt->StorageDevice->StackSize, TRUE);
if (Irp == NULL)
@@ -212,7 +208,7 @@ VfatWriteDiskPartial (IN PVFAT_IRP_CONTEXT IrpContext,
DPRINT ("VfatWriteDiskPartial(IrpContext %x, WriteOffset %I64x, WriteLength %d, BufferOffset %x, Wait %d)\n",
IrpContext, WriteOffset->QuadPart, WriteLength, BufferOffset, Wait);
- Buffer = MmGetMdlVirtualAddress(IrpContext->Irp->MdlAddress) + BufferOffset;
+ Buffer = (PCHAR)MmGetMdlVirtualAddress(IrpContext->Irp->MdlAddress) + BufferOffset;
DPRINT ("Building asynchronous FSD Request...\n");
Irp = IoAllocateIrp(IrpContext->DeviceExt->StorageDevice->StackSize, TRUE);
diff --git a/reactos/drivers/fs/vfat/cleanup.c b/reactos/drivers/fs/vfat/cleanup.c
index d75c24cc16f..df24e8cbef0 100644
--- a/reactos/drivers/fs/vfat/cleanup.c
+++ b/reactos/drivers/fs/vfat/cleanup.c
@@ -10,11 +10,7 @@
/* INCLUDES *****************************************************************/
-#include
-
#define NDEBUG
-#include
-
#include "vfat.h"
/* FUNCTIONS ****************************************************************/
@@ -50,12 +46,22 @@ VfatCleanupFile(PVFAT_IRP_CONTEXT IrpContext)
VfatUpdateEntry (pFcb);
}
- /* Uninitialize file cache if initialized for this file object. */
- if (FileObject->PrivateCacheMap)
+ if (pFcb->Flags & FCB_DELETE_PENDING &&
+ pFcb->OpenHandleCount == 1)
{
- CcRosReleaseFileCache (FileObject);
+#if 0
+ /* FIXME:
+ * CcPurgeCacheSection is unimplemented.
+ */
+ CcPurgeCacheSection(FileObject->SectionObjectPointer, NULL, 0, FALSE);
+#endif
}
-
+ /* Uninitialize file cache if. */
+#ifdef USE_ROS_CC_AND_FS
+ CcRosReleaseFileCache (FileObject);
+#else
+ CcUninitializeCacheMap (FileObject, NULL, NULL);
+#endif
pFcb->OpenHandleCount--;
IoRemoveShareAccess(FileObject, &pFcb->FCBShareAccess);
}
diff --git a/reactos/drivers/fs/vfat/close.c b/reactos/drivers/fs/vfat/close.c
index b22206fc612..a3ae43f68c3 100644
--- a/reactos/drivers/fs/vfat/close.c
+++ b/reactos/drivers/fs/vfat/close.c
@@ -10,11 +10,7 @@
/* INCLUDES *****************************************************************/
-#include
-
#define NDEBUG
-#include
-
#include "vfat.h"
/* FUNCTIONS ****************************************************************/
diff --git a/reactos/drivers/fs/vfat/create.c b/reactos/drivers/fs/vfat/create.c
index 7e7b3835d8c..d11001574c1 100644
--- a/reactos/drivers/fs/vfat/create.c
+++ b/reactos/drivers/fs/vfat/create.c
@@ -27,13 +27,7 @@
/* INCLUDES *****************************************************************/
-#include
-#include
-#include
-
#define NDEBUG
-#include
-
#include "vfat.h"
/* FUNCTIONS *****************************************************************/
@@ -41,7 +35,7 @@
void vfat8Dot3ToString (PFAT_DIR_ENTRY pEntry, PUNICODE_STRING NameU)
{
OEM_STRING StringA;
- ULONG Length;
+ USHORT Length;
CHAR cString[12];
RtlCopyMemory(cString, pEntry->Filename, 11);
@@ -191,22 +185,32 @@ FindFile (PDEVICE_EXTENSION DeviceExt,
* FUNCTION: Find a file
*/
{
- WCHAR PathNameBuffer[MAX_PATH];
+ PWCHAR PathNameBuffer;
+ ULONG PathNameBufferLength;
NTSTATUS Status;
PVOID Context = NULL;
PVOID Page;
PVFATFCB rcFcb;
BOOLEAN Found;
UNICODE_STRING PathNameU;
+ UNICODE_STRING FileToFindUpcase;
BOOLEAN WildCard;
DPRINT ("FindFile(Parent %x, FileToFind '%wZ', DirIndex: %d)\n",
Parent, FileToFindU, DirContext->DirIndex);
DPRINT ("FindFile: Path %wZ)\n",&Parent->PathNameU);
+
+ PathNameBufferLength = LONGNAME_MAX_LENGTH * sizeof(WCHAR);
+ PathNameBuffer = ExAllocatePool(NonPagedPool, PathNameBufferLength + sizeof(WCHAR));
+ if (!PathNameBuffer)
+ {
+ CHECKPOINT1;
+ return STATUS_INSUFFICIENT_RESOURCES;
+ }
PathNameU.Buffer = PathNameBuffer;
PathNameU.Length = 0;
- PathNameU.MaximumLength = sizeof(PathNameBuffer);
+ PathNameU.MaximumLength = PathNameBufferLength;
DirContext->LongNameU.Length = 0;
DirContext->ShortNameU.Length = 0;
@@ -227,7 +231,12 @@ FindFile (PDEVICE_EXTENSION DeviceExt,
rcFcb = vfatGrabFCBFromTable(DeviceExt, &PathNameU);
if (rcFcb)
{
- if(rcFcb->startIndex >= DirContext->DirIndex)
+ ULONG startIndex = rcFcb->startIndex;
+ if ((rcFcb->Flags & FCB_IS_FATX_ENTRY) && !vfatFCBIsRoot(Parent))
+ {
+ startIndex += 2;
+ }
+ if(startIndex >= DirContext->DirIndex)
{
RtlCopyUnicodeString(&DirContext->LongNameU, &rcFcb->LongNameU);
RtlCopyUnicodeString(&DirContext->ShortNameU, &rcFcb->ShortNameU);
@@ -235,7 +244,7 @@ FindFile (PDEVICE_EXTENSION DeviceExt,
DirContext->StartIndex = rcFcb->startIndex;
DirContext->DirIndex = rcFcb->dirIndex;
DPRINT("FindFile: new Name %wZ, DirIndex %d (%d)\n",
- &DirContext->LongNameU, DirContext->DirIndex, DirContext->StartIndex);
+ &DirContext->LongNameU, DirContext->DirIndex, DirContext->StartIndex);
Status = STATUS_SUCCESS;
}
else
@@ -244,10 +253,21 @@ FindFile (PDEVICE_EXTENSION DeviceExt,
Status = STATUS_UNSUCCESSFUL;
}
vfatReleaseFCB(DeviceExt, rcFcb);
+ ExFreePool(PathNameBuffer);
return Status;
}
}
+ /* FsRtlIsNameInExpression need the searched string to be upcase,
+ * even if IgnoreCase is specified */
+ Status = RtlUpcaseUnicodeString(&FileToFindUpcase, FileToFindU, TRUE);
+ if (!NT_SUCCESS(Status))
+ {
+ CHECKPOINT;
+ ExFreePool(PathNameBuffer);
+ return Status;
+ }
+
while(TRUE)
{
Status = DeviceExt->GetNextDirEntry(&Context, &Page, Parent, DirContext, First);
@@ -263,14 +283,13 @@ FindFile (PDEVICE_EXTENSION DeviceExt,
}
if (WildCard)
{
- Found = FsRtlIsNameInExpression(FileToFindU, &DirContext->LongNameU, TRUE, NULL) ||
- FsRtlIsNameInExpression(FileToFindU, &DirContext->ShortNameU, TRUE, NULL);
+ Found = FsRtlIsNameInExpression(&FileToFindUpcase, &DirContext->LongNameU, TRUE, NULL) ||
+ FsRtlIsNameInExpression(&FileToFindUpcase, &DirContext->ShortNameU, TRUE, NULL);
}
else
{
- /* FIXME: Use FsRtlAreNamesEqual */
- Found = RtlEqualUnicodeString(&DirContext->LongNameU, FileToFindU, TRUE) ||
- RtlEqualUnicodeString(&DirContext->ShortNameU, FileToFindU, TRUE);
+ Found = FsRtlAreNamesEqual(&DirContext->LongNameU, FileToFindU, TRUE, NULL) ||
+ FsRtlAreNamesEqual(&DirContext->ShortNameU, FileToFindU, TRUE, NULL);
}
if (Found)
@@ -300,6 +319,8 @@ FindFile (PDEVICE_EXTENSION DeviceExt,
{
CcUnpinData(Context);
}
+ RtlFreeUnicodeString(&FileToFindUpcase);
+ ExFreePool(PathNameBuffer);
return STATUS_SUCCESS;
}
DirContext->DirIndex++;
@@ -310,6 +331,8 @@ FindFile (PDEVICE_EXTENSION DeviceExt,
CcUnpinData(Context);
}
+ RtlFreeUnicodeString(&FileToFindUpcase);
+ ExFreePool(PathNameBuffer);
return Status;
}
@@ -410,55 +433,6 @@ VfatOpenFile (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject, PVFATFCB* Pa
return Status;
}
-VOID STATIC
-VfatSupersedeFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
- PVFATFCB Fcb)
-{
- ULONG Cluster, NextCluster;
- NTSTATUS Status;
-
- if (Fcb->Flags & FCB_IS_FATX_ENTRY)
- {
- Fcb->entry.FatX.FileSize = 0;
- Cluster = Fcb->entry.FatX.FirstCluster;
- Fcb->entry.FatX.FirstCluster = 0;
- }
- else
- {
- Fcb->entry.Fat.FileSize = 0;
- if (DeviceExt->FatInfo.FatType == FAT32)
- {
- Cluster = Fcb->entry.Fat.FirstCluster + Fcb->entry.Fat.FirstClusterHigh * 65536;
- }
- else
- {
- Cluster = Fcb->entry.Fat.FirstCluster;
- }
- Fcb->entry.Fat.FirstCluster = 0;
- Fcb->entry.Fat.FirstClusterHigh = 0;
- }
- Fcb->LastOffset = Fcb->LastCluster = 0;
- VfatUpdateEntry (Fcb);
- if (Fcb->RFCB.FileSize.QuadPart > 0)
- {
- Fcb->RFCB.AllocationSize.QuadPart = 0;
- Fcb->RFCB.FileSize.QuadPart = 0;
- Fcb->RFCB.ValidDataLength.QuadPart = 0;
- /* Notify cache manager about the change in file size if caching is
- initialized on the file stream */
- if (FileObject->SectionObjectPointer->SharedCacheMap != NULL)
- {
- CcSetFileSizes(FileObject, (PCC_FILE_SIZES)&Fcb->RFCB.AllocationSize);
- }
- }
- while (Cluster != 0xffffffff && Cluster > 1)
- {
- Status = GetNextCluster (DeviceExt, Cluster, &NextCluster);
- WriteCluster (DeviceExt, Cluster, 0);
- Cluster = NextCluster;
- }
-}
-
NTSTATUS
VfatCreateFile (PDEVICE_OBJECT DeviceObject, PIRP Irp)
/*
@@ -516,7 +490,6 @@ VfatCreateFile (PDEVICE_OBJECT DeviceObject, PIRP Irp)
return (STATUS_INSUFFICIENT_RESOURCES);
}
RtlZeroMemory(pCcb, sizeof(VFATCCB));
- FileObject->Flags |= FO_FCB_IS_VALID;
FileObject->SectionObjectPointer = &pFcb->SectionObjectPointers;
FileObject->FsContext = pFcb;
FileObject->FsContext2 = pCcb;
@@ -717,7 +690,9 @@ VfatCreateFile (PDEVICE_OBJECT DeviceObject, PIRP Irp)
/* Supersede the file */
if (RequestedDisposition == FILE_SUPERSEDE)
{
- VfatSupersedeFile(DeviceExt, FileObject, pFcb);
+ LARGE_INTEGER AllocationSize;
+ AllocationSize.QuadPart = 0LL;
+ VfatSetAllocationSizeInformation(FileObject, pFcb, DeviceExt, &AllocationSize);
Irp->IoStatus.Information = FILE_SUPERSEDED;
}
else if (RequestedDisposition == FILE_OVERWRITE || RequestedDisposition == FILE_OVERWRITE_IF)
diff --git a/reactos/drivers/fs/vfat/dir.c b/reactos/drivers/fs/vfat/dir.c
index d10ab848dde..064ff79e373 100644
--- a/reactos/drivers/fs/vfat/dir.c
+++ b/reactos/drivers/fs/vfat/dir.c
@@ -10,21 +10,16 @@
*/
-#include
-#include
-
#define NDEBUG
-#include
-
#include "vfat.h"
// function like DosDateTimeToFileTime
-BOOL
-FsdDosDateTimeToSystemTime (PDEVICE_EXTENSION DeviceExt, WORD wDosDate, WORD wDosTime, PLARGE_INTEGER SystemTime)
+BOOLEAN
+FsdDosDateTimeToSystemTime (PDEVICE_EXTENSION DeviceExt, USHORT DosDate, USHORT DosTime, PLARGE_INTEGER SystemTime)
{
- PDOSTIME pdtime = (PDOSTIME) & wDosTime;
- PDOSDATE pddate = (PDOSDATE) & wDosDate;
+ PDOSTIME pdtime = (PDOSTIME) &DosTime;
+ PDOSDATE pddate = (PDOSDATE) &DosDate;
TIME_FIELDS TimeFields;
LARGE_INTEGER LocalTime;
@@ -47,11 +42,11 @@ FsdDosDateTimeToSystemTime (PDEVICE_EXTENSION DeviceExt, WORD wDosDate, WORD wDo
}
// function like FileTimeToDosDateTime
-BOOL
-FsdSystemTimeToDosDateTime (PDEVICE_EXTENSION DeviceExt, PLARGE_INTEGER SystemTime, WORD * pwDosDate, WORD * pwDosTime)
+BOOLEAN
+FsdSystemTimeToDosDateTime (PDEVICE_EXTENSION DeviceExt, PLARGE_INTEGER SystemTime, USHORT *pDosDate, USHORT *pDosTime)
{
- PDOSTIME pdtime = (PDOSTIME) pwDosTime;
- PDOSDATE pddate = (PDOSDATE) pwDosDate;
+ PDOSTIME pdtime = (PDOSTIME) pDosTime;
+ PDOSDATE pddate = (PDOSDATE) pDosDate;
TIME_FIELDS TimeFields;
LARGE_INTEGER LocalTime;
@@ -72,13 +67,13 @@ FsdSystemTimeToDosDateTime (PDEVICE_EXTENSION DeviceExt, PLARGE_INTEGER SystemTi
{
pddate->Day = TimeFields.Day;
pddate->Month = TimeFields.Month;
- pddate->Year = TimeFields.Year - DeviceExt->BaseDateYear;
+ pddate->Year = (USHORT) (TimeFields.Year - DeviceExt->BaseDateYear);
}
return TRUE;
}
-#define DWORD_ROUND_UP(x) ROUND_UP((x), (sizeof(DWORD)))
+#define ULONG_ROUND_UP(x) ROUND_UP((x), (sizeof(ULONG)))
NTSTATUS
VfatGetFileNameInformation (PVFAT_DIRENTRY_CONTEXT DirContext,
@@ -88,7 +83,7 @@ VfatGetFileNameInformation (PVFAT_DIRENTRY_CONTEXT DirContext,
return STATUS_BUFFER_OVERFLOW;
pInfo->FileNameLength = DirContext->LongNameU.Length;
pInfo->NextEntryOffset =
- DWORD_ROUND_UP (sizeof (FILE_DIRECTORY_INFORMATION) + DirContext->LongNameU.Length);
+ ULONG_ROUND_UP (sizeof (FILE_DIRECTORY_INFORMATION) + DirContext->LongNameU.Length);
RtlCopyMemory (pInfo->FileName, DirContext->LongNameU.Buffer, DirContext->LongNameU.Length);
return STATUS_SUCCESS;
}
@@ -103,7 +98,7 @@ VfatGetFileDirectoryInformation (PVFAT_DIRENTRY_CONTEXT DirContext,
return STATUS_BUFFER_OVERFLOW;
pInfo->FileNameLength = DirContext->LongNameU.Length;
pInfo->NextEntryOffset =
- DWORD_ROUND_UP (sizeof (FILE_DIRECTORY_INFORMATION) + DirContext->LongNameU.Length);
+ ULONG_ROUND_UP (sizeof (FILE_DIRECTORY_INFORMATION) + DirContext->LongNameU.Length);
RtlCopyMemory (pInfo->FileName, DirContext->LongNameU.Buffer, DirContext->LongNameU.Length);
// pInfo->FileIndex=;
if (DeviceExt->Flags & VCB_IS_FATX)
@@ -166,14 +161,14 @@ VfatGetFileDirectoryInformation (PVFAT_DIRENTRY_CONTEXT DirContext,
NTSTATUS
VfatGetFileFullDirectoryInformation (PVFAT_DIRENTRY_CONTEXT DirContext,
PDEVICE_EXTENSION DeviceExt,
- PFILE_FULL_DIRECTORY_INFORMATION pInfo,
+ PFILE_FULL_DIR_INFORMATION pInfo,
ULONG BufferLength)
{
- if ((sizeof (FILE_FULL_DIRECTORY_INFORMATION) + DirContext->LongNameU.Length) > BufferLength)
+ if ((sizeof (FILE_FULL_DIR_INFORMATION) + DirContext->LongNameU.Length) > BufferLength)
return STATUS_BUFFER_OVERFLOW;
pInfo->FileNameLength = DirContext->LongNameU.Length;
pInfo->NextEntryOffset =
- DWORD_ROUND_UP (sizeof (FILE_FULL_DIRECTORY_INFORMATION) + DirContext->LongNameU.Length);
+ ULONG_ROUND_UP (sizeof (FILE_FULL_DIR_INFORMATION) + DirContext->LongNameU.Length);
RtlCopyMemory (pInfo->FileName, DirContext->LongNameU.Buffer, DirContext->LongNameU.Length);
// pInfo->FileIndex=;
if (DeviceExt->Flags & VCB_IS_FATX)
@@ -220,10 +215,10 @@ VfatGetFileFullDirectoryInformation (PVFAT_DIRENTRY_CONTEXT DirContext,
NTSTATUS
VfatGetFileBothInformation (PVFAT_DIRENTRY_CONTEXT DirContext,
PDEVICE_EXTENSION DeviceExt,
- PFILE_BOTH_DIRECTORY_INFORMATION pInfo,
+ PFILE_BOTH_DIR_INFORMATION pInfo,
ULONG BufferLength)
{
- if ((sizeof (FILE_BOTH_DIRECTORY_INFORMATION) + DirContext->LongNameU.Length) > BufferLength)
+ if ((sizeof (FILE_BOTH_DIR_INFORMATION) + DirContext->LongNameU.Length) > BufferLength)
return STATUS_BUFFER_OVERFLOW;
if (DeviceExt->Flags & VCB_IS_FATX)
@@ -231,7 +226,7 @@ VfatGetFileBothInformation (PVFAT_DIRENTRY_CONTEXT DirContext,
pInfo->FileNameLength = DirContext->LongNameU.Length;
RtlCopyMemory(pInfo->FileName, DirContext->LongNameU.Buffer, DirContext->LongNameU.Length);
pInfo->NextEntryOffset =
- DWORD_ROUND_UP (sizeof (FILE_BOTH_DIRECTORY_INFORMATION) + DirContext->LongNameU.Length);
+ ULONG_ROUND_UP (sizeof (FILE_BOTH_DIR_INFORMATION) + DirContext->LongNameU.Length);
pInfo->ShortName[0] = 0;
pInfo->ShortNameLength = 0;
// pInfo->FileIndex=;
@@ -264,7 +259,7 @@ VfatGetFileBothInformation (PVFAT_DIRENTRY_CONTEXT DirContext,
{
pInfo->FileNameLength = DirContext->LongNameU.Length;
pInfo->NextEntryOffset =
- DWORD_ROUND_UP (sizeof (FILE_BOTH_DIRECTORY_INFORMATION) + DirContext->LongNameU.Length);
+ ULONG_ROUND_UP (sizeof (FILE_BOTH_DIR_INFORMATION) + DirContext->LongNameU.Length);
RtlCopyMemory(pInfo->ShortName, DirContext->ShortNameU.Buffer, DirContext->ShortNameU.Length);
pInfo->ShortNameLength = DirContext->ShortNameU.Length;
RtlCopyMemory (pInfo->FileName, DirContext->LongNameU.Buffer, DirContext->LongNameU.Length);
@@ -311,7 +306,7 @@ NTSTATUS DoQuery (PVFAT_IRP_CONTEXT IrpContext)
BOOLEAN First = FALSE;
BOOLEAN FirstCall;
VFAT_DIRENTRY_CONTEXT DirContext;
- WCHAR LongNameBuffer[MAX_PATH];
+ WCHAR LongNameBuffer[LONGNAME_MAX_LENGTH + 1];
WCHAR ShortNameBuffer[13];
PIO_STACK_LOCATION Stack = IrpContext->Stack;
@@ -344,7 +339,13 @@ NTSTATUS DoQuery (PVFAT_IRP_CONTEXT IrpContext)
}
/* Obtain the callers parameters */
+#ifdef _MSC_VER
+ /* HACKHACK: Bug in the MS ntifs.h header:
+ * FileName is really a PUNICODE_STRING, not a PSTRING */
+ pSearchPattern = (PUNICODE_STRING)Stack->Parameters.QueryDirectory.FileName;
+#else
pSearchPattern = Stack->Parameters.QueryDirectory.FileName;
+#endif
FileInformationClass =
Stack->Parameters.QueryDirectory.FileInformationClass;
FileIndex = Stack->Parameters.QueryDirectory.FileIndex;
@@ -427,13 +428,13 @@ NTSTATUS DoQuery (PVFAT_IRP_CONTEXT IrpContext)
case FileFullDirectoryInformation:
RC = VfatGetFileFullDirectoryInformation (&DirContext,
IrpContext->DeviceExt,
- (PFILE_FULL_DIRECTORY_INFORMATION) Buffer,
+ (PFILE_FULL_DIR_INFORMATION) Buffer,
BufferLength);
break;
case FileBothDirectoryInformation:
RC = VfatGetFileBothInformation (&DirContext,
IrpContext->DeviceExt,
- (PFILE_BOTH_DIRECTORY_INFORMATION) Buffer,
+ (PFILE_BOTH_DIR_INFORMATION) Buffer,
BufferLength);
break;
default:
diff --git a/reactos/drivers/fs/vfat/direntry.c b/reactos/drivers/fs/vfat/direntry.c
index 273dd85de14..f3efe7f3ecf 100644
--- a/reactos/drivers/fs/vfat/direntry.c
+++ b/reactos/drivers/fs/vfat/direntry.c
@@ -13,13 +13,7 @@
/* ------------------------------------------------------- INCLUDES */
-#include
-#include
-#include
-
#define NDEBUG
-#include
-
#include "vfat.h"
ULONG
@@ -45,7 +39,7 @@ vfatDirEntryGetFirstCluster (PDEVICE_EXTENSION pDeviceExt,
return cluster;
}
-BOOL FATIsDirectoryEmpty(PVFATFCB Fcb)
+BOOLEAN FATIsDirectoryEmpty(PVFATFCB Fcb)
{
LARGE_INTEGER FileOffset;
PVOID Context = NULL;
@@ -98,7 +92,7 @@ BOOL FATIsDirectoryEmpty(PVFATFCB Fcb)
return TRUE;
}
-BOOL FATXIsDirectoryEmpty(PVFATFCB Fcb)
+BOOLEAN FATXIsDirectoryEmpty(PVFATFCB Fcb)
{
LARGE_INTEGER FileOffset;
PVOID Context = NULL;
@@ -144,7 +138,7 @@ BOOL FATXIsDirectoryEmpty(PVFATFCB Fcb)
return TRUE;
}
-BOOL VfatIsDirectoryEmpty(PVFATFCB Fcb)
+BOOLEAN VfatIsDirectoryEmpty(PVFATFCB Fcb)
{
if (Fcb->Flags & FCB_IS_FATX_ENTRY)
return FATXIsDirectoryEmpty(Fcb);
@@ -181,7 +175,8 @@ NTSTATUS FATGetNextDirEntry(PVOID * pContext,
{
CcUnpinData(*pContext);
}
- if (!CcMapData(pDirFcb->FileObject, &FileOffset, PAGE_SIZE, TRUE, pContext, pPage))
+ if (FileOffset.u.LowPart >= pDirFcb->RFCB.FileSize.u.LowPart ||
+ !CcMapData(pDirFcb->FileObject, &FileOffset, PAGE_SIZE, TRUE, pContext, pPage))
{
*pContext = NULL;
return STATUS_NO_MORE_ENTRIES;
@@ -210,7 +205,8 @@ NTSTATUS FATGetNextDirEntry(PVOID * pContext,
{
CcUnpinData(*pContext);
FileOffset.u.LowPart -= PAGE_SIZE;
- if (!CcMapData(pDirFcb->FileObject, &FileOffset, PAGE_SIZE, TRUE, pContext, pPage))
+ if (FileOffset.u.LowPart >= pDirFcb->RFCB.FileSize.u.LowPart ||
+ !CcMapData(pDirFcb->FileObject, &FileOffset, PAGE_SIZE, TRUE, pContext, pPage))
{
CHECKPOINT;
*pContext = NULL;
@@ -234,7 +230,8 @@ NTSTATUS FATGetNextDirEntry(PVOID * pContext,
{
CcUnpinData(*pContext);
FileOffset.u.LowPart += PAGE_SIZE;
- if (!CcMapData(pDirFcb->FileObject, &FileOffset, PAGE_SIZE, TRUE, pContext, pPage))
+ if (FileOffset.u.LowPart >= pDirFcb->RFCB.FileSize.u.LowPart ||
+ !CcMapData(pDirFcb->FileObject, &FileOffset, PAGE_SIZE, TRUE, pContext, pPage))
{
CHECKPOINT;
*pContext = NULL;
@@ -331,7 +328,8 @@ NTSTATUS FATGetNextDirEntry(PVOID * pContext,
{
CcUnpinData(*pContext);
FileOffset.u.LowPart += PAGE_SIZE;
- if (!CcMapData(pDirFcb->FileObject, &FileOffset, PAGE_SIZE, TRUE, pContext, pPage))
+ if (FileOffset.u.LowPart >= pDirFcb->RFCB.FileSize.u.LowPart ||
+ !CcMapData(pDirFcb->FileObject, &FileOffset, PAGE_SIZE, TRUE, pContext, pPage))
{
CHECKPOINT;
*pContext = NULL;
@@ -367,7 +365,6 @@ NTSTATUS FATXGetNextDirEntry(PVOID * pContext,
ULONG DirIndex = DirContext->DirIndex;
FileOffset.u.HighPart = 0;
- FileOffset.u.LowPart = ROUND_DOWN(DirContext->DirIndex * sizeof(FATX_DIR_ENTRY), PAGE_SIZE);
if (!vfatFCBIsRoot(pDirFcb))
{
@@ -409,7 +406,9 @@ NTSTATUS FATXGetNextDirEntry(PVOID * pContext,
{
CcUnpinData(*pContext);
}
- if (!CcMapData(pDirFcb->FileObject, &FileOffset, PAGE_SIZE, TRUE, pContext, pPage))
+ FileOffset.u.LowPart = ROUND_DOWN(DirIndex * sizeof(FATX_DIR_ENTRY), PAGE_SIZE);
+ if (FileOffset.u.LowPart >= pDirFcb->RFCB.FileSize.u.LowPart ||
+ !CcMapData(pDirFcb->FileObject, &FileOffset, PAGE_SIZE, TRUE, pContext, pPage))
{
*pContext = NULL;
return STATUS_NO_MORE_ENTRIES;
@@ -418,33 +417,35 @@ NTSTATUS FATXGetNextDirEntry(PVOID * pContext,
fatxDirEntry = (PFATX_DIR_ENTRY)(*pPage) + DirIndex % FATX_ENTRIES_PER_PAGE;
- DirContext->StartIndex = DirIndex;
+ DirContext->StartIndex = DirContext->DirIndex;
while (TRUE)
{
- if (FATX_ENTRY_END(fatxDirEntry))
- {
- CcUnpinData(*pContext);
- *pContext = NULL;
- return STATUS_NO_MORE_ENTRIES;
- }
+ if (FATX_ENTRY_END(fatxDirEntry))
+ {
+ CcUnpinData(*pContext);
+ *pContext = NULL;
+ return STATUS_NO_MORE_ENTRIES;
+ }
- if (!FATX_ENTRY_DELETED(fatxDirEntry))
- {
- RtlCopyMemory(&DirContext->DirEntry.FatX, fatxDirEntry, sizeof(FATX_DIR_ENTRY));
- break;
+ if (!FATX_ENTRY_DELETED(fatxDirEntry))
+ {
+ RtlCopyMemory(&DirContext->DirEntry.FatX, fatxDirEntry, sizeof(FATX_DIR_ENTRY));
+ break;
}
- DirContext->DirIndex++;
- DirContext->StartIndex++;
- if ((DirContext->DirIndex % FATX_ENTRIES_PER_PAGE) == 0)
+ DirContext->DirIndex++;
+ DirContext->StartIndex++;
+ DirIndex++;
+ if ((DirIndex % FATX_ENTRIES_PER_PAGE) == 0)
{
CcUnpinData(*pContext);
FileOffset.u.LowPart += PAGE_SIZE;
- if (!CcMapData(pDirFcb->FileObject, &FileOffset, PAGE_SIZE, TRUE, pContext, pPage))
+ if (FileOffset.u.LowPart >= pDirFcb->RFCB.FileSize.u.LowPart ||
+ !CcMapData(pDirFcb->FileObject, &FileOffset, PAGE_SIZE, TRUE, pContext, pPage))
{
CHECKPOINT;
- *pContext = NULL;
- return STATUS_NO_MORE_ENTRIES;
+ *pContext = NULL;
+ return STATUS_NO_MORE_ENTRIES;
}
fatxDirEntry = (PFATX_DIR_ENTRY)*pPage;
}
diff --git a/reactos/drivers/fs/vfat/dirwr.c b/reactos/drivers/fs/vfat/dirwr.c
index 649a9552201..b907f3bec91 100644
--- a/reactos/drivers/fs/vfat/dirwr.c
+++ b/reactos/drivers/fs/vfat/dirwr.c
@@ -9,14 +9,7 @@
/* INCLUDES *****************************************************************/
-#include
-#include
-#include
-#include
-
#define NDEBUG
-#include
-
#include "vfat.h"
NTSTATUS
@@ -47,9 +40,16 @@ VfatUpdateEntry (PVFATFCB pFcb)
DPRINT ("updEntry dirIndex %d, PathName \'%wZ\'\n", dirIndex, &pFcb->PathNameU);
+ if (vfatFCBIsRoot(pFcb) || (pFcb->Flags & (FCB_IS_FAT|FCB_IS_VOLUME)))
+ {
+ return STATUS_SUCCESS;
+ }
+
+ ASSERT (pFcb->parrentFcb);
+
Offset.u.HighPart = 0;
Offset.u.LowPart = dirIndex * SizeDirEntry;
- if (CcMapData (pFcb->parentFcb->FileObject, &Offset, SizeDirEntry,
+ if (CcPinRead (pFcb->parentFcb->FileObject, &Offset, SizeDirEntry,
TRUE, &Context, (PVOID*)&PinEntry))
{
pFcb->Flags &= ~FCB_IS_DIRTY;
@@ -99,7 +99,7 @@ vfatFindDirSpace(PDEVICE_EXTENSION DeviceExt,
CcUnpinData(Context);
}
// FIXME: check return value
- CcMapData (pDirFcb->FileObject, &FileOffset, DeviceExt->FatInfo.BytesPerCluster,
+ CcPinRead (pDirFcb->FileObject, &FileOffset, DeviceExt->FatInfo.BytesPerCluster,
TRUE, &Context, (PVOID*)&pFatEntry);
FileOffset.u.LowPart += DeviceExt->FatInfo.BytesPerCluster;
}
@@ -151,9 +151,9 @@ vfatFindDirSpace(PDEVICE_EXTENSION DeviceExt,
return FALSE;
}
// clear the new dir cluster
- FileOffset.u.LowPart = (DWORD)(pDirFcb->RFCB.FileSize.QuadPart -
+ FileOffset.u.LowPart = (ULONG)(pDirFcb->RFCB.FileSize.QuadPart -
DeviceExt->FatInfo.BytesPerCluster);
- CcMapData (pDirFcb->FileObject, &FileOffset, DeviceExt->FatInfo.BytesPerCluster,
+ CcPinRead (pDirFcb->FileObject, &FileOffset, DeviceExt->FatInfo.BytesPerCluster,
TRUE, &Context, (PVOID*)&pFatEntry);
if (DeviceExt->Flags & VCB_IS_FATX)
memset(pFatEntry, 0xff, DeviceExt->FatInfo.BytesPerCluster);
@@ -164,7 +164,7 @@ vfatFindDirSpace(PDEVICE_EXTENSION DeviceExt,
{
// clear the entry after the last new entry
FileOffset.u.LowPart = (*start + nbSlots) * SizeDirEntry;
- CcMapData (pDirFcb->FileObject, &FileOffset, SizeDirEntry,
+ CcPinRead (pDirFcb->FileObject, &FileOffset, SizeDirEntry,
TRUE, &Context, (PVOID*)&pFatEntry);
if (DeviceExt->Flags & VCB_IS_FATX)
memset(pFatEntry, 0xff, SizeDirEntry);
@@ -195,7 +195,7 @@ FATAddEntry (PDEVICE_EXTENSION DeviceExt,
PVOID Context = NULL;
PFAT_DIR_ENTRY pFatEntry;
slot *pSlots;
- short nbSlots = 0, j, posCar;
+ USHORT nbSlots = 0, j, posCar;
PUCHAR Buffer;
BOOLEAN needTilde = FALSE, needLong = FALSE;
BOOLEAN lCaseBase = FALSE, uCaseBase, lCaseExt = FALSE, uCaseExt;
@@ -211,7 +211,7 @@ FATAddEntry (PDEVICE_EXTENSION DeviceExt,
BOOLEAN SpacesFound;
VFAT_DIRENTRY_CONTEXT DirContext;
- WCHAR LongNameBuffer[MAX_PATH];
+ WCHAR LongNameBuffer[LONGNAME_MAX_LENGTH + 1];
WCHAR ShortNameBuffer[13];
DPRINT ("addEntry: Name='%wZ', Dir='%wZ'\n", NameU, &ParentFcb->PathNameU);
@@ -402,11 +402,11 @@ FATAddEntry (PDEVICE_EXTENSION DeviceExt,
pSlots[i].attr = 0xf;
if (i)
{
- pSlots[i].id = nbSlots - i - 1;
+ pSlots[i].id = (unsigned char)(nbSlots - i - 1);
}
else
{
- pSlots[i].id = nbSlots - i - 1 + 0x40;
+ pSlots[i].id = (unsigned char)(nbSlots - i - 1 + 0x40);
}
pSlots[i].alias_checksum = pSlots[0].alias_checksum;
RtlCopyMemory (pSlots[i].name0_4, DirContext.LongNameU.Buffer + (nbSlots - i - 2) * 13, 10);
@@ -448,7 +448,7 @@ FATAddEntry (PDEVICE_EXTENSION DeviceExt,
{
/* one cluster */
CHECKPOINT;
- CcMapData (ParentFcb->FileObject, &FileOffset, nbSlots * sizeof(FAT_DIR_ENTRY),
+ CcPinRead (ParentFcb->FileObject, &FileOffset, nbSlots * sizeof(FAT_DIR_ENTRY),
TRUE, &Context, (PVOID*)&pFatEntry);
if (nbSlots > 1)
{
@@ -463,13 +463,13 @@ FATAddEntry (PDEVICE_EXTENSION DeviceExt,
size = DeviceExt->FatInfo.BytesPerCluster -
(DirContext.StartIndex * sizeof(FAT_DIR_ENTRY)) % DeviceExt->FatInfo.BytesPerCluster;
i = size / sizeof(FAT_DIR_ENTRY);
- CcMapData (ParentFcb->FileObject, &FileOffset, size, TRUE,
+ CcPinRead (ParentFcb->FileObject, &FileOffset, size, TRUE,
&Context, (PVOID*)&pFatEntry);
RtlCopyMemory(pFatEntry, Buffer, size);
CcSetDirtyPinnedData(Context, NULL);
CcUnpinData(Context);
FileOffset.u.LowPart += size;
- CcMapData (ParentFcb->FileObject, &FileOffset,
+ CcPinRead (ParentFcb->FileObject, &FileOffset,
nbSlots * sizeof(FAT_DIR_ENTRY) - size,
TRUE, &Context, (PVOID*)&pFatEntry);
if (nbSlots - 1 > i)
@@ -551,6 +551,7 @@ FATXAddEntry (PDEVICE_EXTENSION DeviceExt,
if (!vfatFCBIsRoot(ParentFcb))
{
DirContext.DirIndex += 2;
+ DirContext.StartIndex += 2;
}
DirContext.ShortNameU.Buffer = 0;
@@ -566,7 +567,7 @@ FATXAddEntry (PDEVICE_EXTENSION DeviceExt,
NameA.Length = 0;
NameA.MaximumLength = 42;
RtlUnicodeStringToOemString(&NameA, &DirContext.LongNameU, FALSE);
- DirContext.DirEntry.FatX.FilenameLength = NameA.Length;
+ DirContext.DirEntry.FatX.FilenameLength = (unsigned char)NameA.Length;
/* set attributes */
DirContext.DirEntry.FatX.Attrib = ReqAttr;
@@ -587,7 +588,7 @@ FATXAddEntry (PDEVICE_EXTENSION DeviceExt,
/* add entry into parent directory */
FileOffset.u.HighPart = 0;
FileOffset.u.LowPart = DirContext.StartIndex * sizeof(FATX_DIR_ENTRY);
- CcMapData(ParentFcb->FileObject, &FileOffset, sizeof(FATX_DIR_ENTRY),
+ CcPinRead(ParentFcb->FileObject, &FileOffset, sizeof(FATX_DIR_ENTRY),
TRUE, &Context, (PVOID*)&pFatXDirEntry);
RtlCopyMemory(pFatXDirEntry, &DirContext.DirEntry.FatX, sizeof(FATX_DIR_ENTRY));
CcSetDirtyPinnedData(Context, NULL);
@@ -641,7 +642,7 @@ FATDelEntry (PDEVICE_EXTENSION DeviceExt, PVFATFCB pFcb)
CcUnpinData(Context);
}
Offset.u.LowPart = (i * sizeof(FAT_DIR_ENTRY) / PAGE_SIZE) * PAGE_SIZE;
- CcMapData (pFcb->parentFcb->FileObject, &Offset, PAGE_SIZE, TRUE,
+ CcPinRead (pFcb->parentFcb->FileObject, &Offset, PAGE_SIZE, TRUE,
&Context, (PVOID*)&pDirEntry);
}
pDirEntry[i % (PAGE_SIZE / sizeof(FAT_DIR_ENTRY))].Filename[0] = 0xe5;
@@ -690,10 +691,10 @@ FATXDelEntry (PDEVICE_EXTENSION DeviceExt, PVFATFCB pFcb)
DPRINT ("delete entry: %d\n", StartIndex);
Offset.u.HighPart = 0;
Offset.u.LowPart = (StartIndex * sizeof(FATX_DIR_ENTRY) / PAGE_SIZE) * PAGE_SIZE;
- if (!CcMapData (pFcb->parentFcb->FileObject, &Offset, PAGE_SIZE, TRUE,
+ if (!CcPinRead (pFcb->parentFcb->FileObject, &Offset, PAGE_SIZE, TRUE,
&Context, (PVOID*)&pDirEntry))
{
- DPRINT1("CcMapData(Offset %x:%x, Length %d) failed\n", Offset.u.HighPart, Offset.u.LowPart, PAGE_SIZE);
+ DPRINT1("CcPinRead(Offset %x:%x, Length %d) failed\n", Offset.u.HighPart, Offset.u.LowPart, PAGE_SIZE);
return STATUS_UNSUCCESSFUL;
}
pDirEntry = &pDirEntry[StartIndex % (PAGE_SIZE / sizeof(FATX_DIR_ENTRY))];
diff --git a/reactos/drivers/fs/vfat/ea.c b/reactos/drivers/fs/vfat/ea.c
index 93058681071..e597d4b27f4 100644
--- a/reactos/drivers/fs/vfat/ea.c
+++ b/reactos/drivers/fs/vfat/ea.c
@@ -27,13 +27,7 @@
/* INCLUDES *****************************************************************/
-#include
-#include
-#include
-
#define NDEBUG
-#include
-
#include "vfat.h"
/* FUNCTIONS *****************************************************************/
diff --git a/reactos/drivers/fs/vfat/fastio.c b/reactos/drivers/fs/vfat/fastio.c
new file mode 100644
index 00000000000..6d7b0010734
--- /dev/null
+++ b/reactos/drivers/fs/vfat/fastio.c
@@ -0,0 +1,399 @@
+/* $Id$
+ *
+ *
+ * FILE: drivers/fs/vfat/fastio.c
+ * PURPOSE: Fast IO routines.
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS kernel
+ * PROGRAMMER: Herve Poussineau (reactos@poussine.freesurf.fr)
+ * Hartmut Birr
+ */
+
+#define NDEBUG
+#include "vfat.h"
+
+BOOLEAN STDCALL
+VfatFastIoCheckIfPossible(IN PFILE_OBJECT FileObject,
+ IN PLARGE_INTEGER FileOffset,
+ IN ULONG Lenght,
+ IN BOOLEAN Wait,
+ IN ULONG LockKey,
+ IN BOOLEAN CheckForReadOperation,
+ OUT PIO_STATUS_BLOCK IoStatus,
+ IN PDEVICE_OBJECT DeviceObject)
+{
+ /* Prevent all Fast I/O requests */
+ DPRINT("VfatFastIoCheckIfPossible(): returning FALSE.\n");
+ return FALSE;
+}
+
+BOOLEAN STDCALL
+VfatFastIoRead(IN PFILE_OBJECT FileObject,
+ IN PLARGE_INTEGER FileOffset,
+ IN ULONG Length,
+ IN BOOLEAN Wait,
+ IN ULONG LockKey,
+ OUT PVOID Buffer,
+ OUT PIO_STATUS_BLOCK IoStatus,
+ IN PDEVICE_OBJECT DeviceObject)
+{
+ DPRINT("VfatFastIoRead()\n");
+ return FALSE;
+}
+
+BOOLEAN STDCALL
+VfatFastIoWrite(IN PFILE_OBJECT FileObject,
+ IN PLARGE_INTEGER FileOffset,
+ IN ULONG Length,
+ IN BOOLEAN Wait,
+ IN ULONG LockKey,
+ OUT PVOID Buffer,
+ OUT PIO_STATUS_BLOCK IoStatus,
+ IN PDEVICE_OBJECT DeviceObject)
+{
+ DPRINT("VfatFastIoWrite()\n");
+ return FALSE;
+}
+
+BOOLEAN STDCALL
+VfatFastIoQueryBasicInfo(IN PFILE_OBJECT FileObject,
+ IN BOOLEAN Wait,
+ OUT PFILE_BASIC_INFORMATION Buffer,
+ OUT PIO_STATUS_BLOCK IoStatus,
+ IN PDEVICE_OBJECT DeviceObject)
+{
+ DPRINT("VfatFastIoQueryBasicInfo()\n");
+ return FALSE;
+}
+
+BOOLEAN STDCALL
+VfatFastIoQueryStandardInfo(IN PFILE_OBJECT FileObject,
+ IN BOOLEAN Wait,
+ OUT PFILE_STANDARD_INFORMATION Buffer,
+ OUT PIO_STATUS_BLOCK IoStatus,
+ IN PDEVICE_OBJECT DeviceObject)
+{
+ DPRINT("VfatFastIoQueryStandardInfo\n");
+ return FALSE;
+}
+
+BOOLEAN STDCALL
+VfatFastIoLock(IN PFILE_OBJECT FileObject,
+ IN PLARGE_INTEGER FileOffset,
+ IN PLARGE_INTEGER Length,
+ PEPROCESS ProcessId,
+ ULONG Key,
+ BOOLEAN FailImmediately,
+ BOOLEAN ExclusiveLock,
+ OUT PIO_STATUS_BLOCK IoStatus,
+ IN PDEVICE_OBJECT DeviceObject)
+{
+ DPRINT("VfatFastIoLock\n");
+ return FALSE;
+}
+
+BOOLEAN STDCALL
+VfatFastIoUnlockSingle(IN PFILE_OBJECT FileObject,
+ IN PLARGE_INTEGER FileOffset,
+ IN PLARGE_INTEGER Length,
+ PEPROCESS ProcessId,
+ ULONG Key,
+ OUT PIO_STATUS_BLOCK IoStatus,
+ IN PDEVICE_OBJECT DeviceObject)
+{
+ DPRINT("VfatFastIoUnlockSingle\n");
+ return FALSE;
+}
+
+BOOLEAN STDCALL
+VfatFastIoUnlockAll(IN PFILE_OBJECT FileObject,
+ PEPROCESS ProcessId,
+ OUT PIO_STATUS_BLOCK IoStatus,
+ IN PDEVICE_OBJECT DeviceObject)
+{
+ DPRINT("VfatFastIoUnlockAll\n");
+ return FALSE;
+}
+
+BOOLEAN STDCALL
+VfatFastIoUnlockAllByKey(IN PFILE_OBJECT FileObject,
+ PEPROCESS ProcessId,
+ ULONG Key,
+ OUT PIO_STATUS_BLOCK IoStatus,
+ IN PDEVICE_OBJECT DeviceObject)
+{
+ DPRINT("VfatFastIoUnlockAllByKey\n");
+ return FALSE;
+}
+
+BOOLEAN STDCALL
+VfatFastIoDeviceControl(IN PFILE_OBJECT FileObject,
+ IN BOOLEAN Wait,
+ IN PVOID InputBuffer OPTIONAL,
+ IN ULONG InputBufferLength,
+ OUT PVOID OutputBuffer OPTIONAL,
+ IN ULONG OutputBufferLength,
+ IN ULONG IoControlCode,
+ OUT PIO_STATUS_BLOCK IoStatus,
+ IN PDEVICE_OBJECT DeviceObject)
+{
+ DPRINT("VfatFastIoDeviceControl\n");
+ return FALSE;
+}
+
+VOID STDCALL
+VfatAcquireFileForNtCreateSection(IN PFILE_OBJECT FileObject)
+{
+ DPRINT("VfatAcquireFileForNtCreateSection\n");
+}
+
+VOID STDCALL
+VfatReleaseFileForNtCreateSection(IN PFILE_OBJECT FileObject)
+{
+ DPRINT("VfatReleaseFileForNtCreateSection\n");
+}
+
+VOID STDCALL
+VfatFastIoDetachDevice(IN PDEVICE_OBJECT SourceDevice,
+ IN PDEVICE_OBJECT TargetDevice)
+{
+ DPRINT("VfatFastIoDetachDevice\n");
+}
+
+BOOLEAN STDCALL
+VfatFastIoQueryNetworkOpenInfo(IN PFILE_OBJECT FileObject,
+ IN BOOLEAN Wait,
+ OUT PFILE_NETWORK_OPEN_INFORMATION Buffer,
+ OUT PIO_STATUS_BLOCK IoStatus,
+ IN PDEVICE_OBJECT DeviceObject)
+{
+ DPRINT("VfatFastIoQueryNetworkOpenInfo\n");
+ return FALSE;
+}
+
+NTSTATUS STDCALL
+VfatAcquireForModWrite(IN PFILE_OBJECT FileObject,
+ IN PLARGE_INTEGER EndingOffset,
+ OUT PERESOURCE* ResourceToRelease,
+ IN PDEVICE_OBJECT DeviceObject)
+{
+ DPRINT("VfatAcquireForModWrite\n");
+ return STATUS_UNSUCCESSFUL;
+}
+
+BOOLEAN STDCALL
+VfatMdlRead(IN PFILE_OBJECT FileObject,
+ IN PLARGE_INTEGER FileOffset,
+ IN ULONG Length,
+ IN ULONG LockKey,
+ OUT PMDL* MdlChain,
+ OUT PIO_STATUS_BLOCK IoStatus,
+ IN PDEVICE_OBJECT DeviceObject)
+{
+ DPRINT("VfatMdlRead\n");
+ return FALSE;
+}
+
+BOOLEAN STDCALL
+VfatMdlReadComplete(IN PFILE_OBJECT FileObject,
+ IN PMDL MdlChain,
+ IN PDEVICE_OBJECT DeviceObject)
+{
+ DPRINT("VfatMdlReadComplete\n");
+ return FALSE;
+}
+
+BOOLEAN STDCALL
+VfatPrepareMdlWrite(IN PFILE_OBJECT FileObject,
+ IN PLARGE_INTEGER FileOffset,
+ IN ULONG Length,
+ IN ULONG LockKey,
+ OUT PMDL* MdlChain,
+ OUT PIO_STATUS_BLOCK IoStatus,
+ IN PDEVICE_OBJECT DeviceObject)
+{
+ DPRINT("VfatPrepareMdlWrite\n");
+ return FALSE;
+}
+
+BOOLEAN STDCALL
+VfatMdlWriteComplete(IN PFILE_OBJECT FileObject,
+ IN PLARGE_INTEGER FileOffset,
+ IN PMDL MdlChain,
+ IN PDEVICE_OBJECT DeviceObject)
+{
+ DPRINT("VfatMdlWriteComplete\n");
+ return FALSE;
+}
+
+BOOLEAN STDCALL
+VfatFastIoReadCompressed(IN PFILE_OBJECT FileObject,
+ IN PLARGE_INTEGER FileOffset,
+ IN ULONG Length,
+ IN ULONG LockKey,
+ OUT PVOID Buffer,
+ OUT PMDL* MdlChain,
+ OUT PIO_STATUS_BLOCK IoStatus,
+ OUT PCOMPRESSED_DATA_INFO CompressedDataInfo,
+ IN ULONG CompressedDataInfoLength,
+ IN PDEVICE_OBJECT DeviceObject)
+{
+ DPRINT("VfatFastIoReadCompressed\n");
+ return FALSE;
+}
+
+BOOLEAN STDCALL
+VfatFastIoWriteCompressed(IN PFILE_OBJECT FileObject,
+ IN PLARGE_INTEGER FileOffset,
+ IN ULONG Length,
+ IN ULONG LockKey,
+ IN PVOID Buffer,
+ OUT PMDL* MdlChain,
+ OUT PIO_STATUS_BLOCK IoStatus,
+ IN PCOMPRESSED_DATA_INFO CompressedDataInfo,
+ IN ULONG CompressedDataInfoLength,
+ IN PDEVICE_OBJECT DeviceObject)
+{
+ DPRINT("VfatFastIoWriteCompressed\n");
+ return FALSE;
+}
+
+BOOLEAN STDCALL
+VfatMdlReadCompleteCompressed(IN PFILE_OBJECT FileObject,
+ IN PMDL MdlChain,
+ IN PDEVICE_OBJECT DeviceObject)
+{
+ DPRINT("VfatMdlReadCompleteCompressed\n");
+ return FALSE;
+}
+
+BOOLEAN STDCALL
+VfatMdlWriteCompleteCompressed(IN PFILE_OBJECT FileObject,
+ IN PLARGE_INTEGER FileOffset,
+ IN PMDL MdlChain,
+ IN PDEVICE_OBJECT DeviceObject)
+{
+ DPRINT("VfatMdlWriteCompleteCompressed\n");
+ return FALSE;
+}
+
+BOOLEAN STDCALL
+VfatFastIoQueryOpen(IN PIRP Irp,
+ OUT PFILE_NETWORK_OPEN_INFORMATION NetworkInformation,
+ IN PDEVICE_OBJECT DeviceObject)
+{
+ DPRINT("VfatFastIoQueryOpen\n");
+ return FALSE;
+}
+
+NTSTATUS STDCALL
+VfatReleaseForModWrite(IN PFILE_OBJECT FileObject,
+ IN PERESOURCE ResourceToRelease,
+ IN PDEVICE_OBJECT DeviceObject)
+{
+ DPRINT("VfatReleaseForModWrite\n");
+ return STATUS_UNSUCCESSFUL;
+}
+
+NTSTATUS STDCALL
+VfatAcquireForCcFlush(IN PFILE_OBJECT FileObject,
+ IN PDEVICE_OBJECT DeviceObject)
+{
+ DPRINT("VfatAcquireForCcFlush\n");
+ return STATUS_UNSUCCESSFUL;
+}
+
+NTSTATUS STDCALL
+VfatReleaseForCcFlush(IN PFILE_OBJECT FileObject,
+ IN PDEVICE_OBJECT DeviceObject)
+{
+ DPRINT("VfatReleaseForCcFlush\n");
+ return STATUS_UNSUCCESSFUL;
+}
+
+BOOLEAN STDCALL
+VfatAcquireForLazyWrite(IN PVOID Context,
+ IN BOOLEAN Wait)
+{
+ PVFATFCB Fcb = (PVFATFCB)Context;
+ ASSERT(Fcb);
+ DPRINT("VfatAcquireForLazyWrite(): Fcb %p\n", Fcb);
+
+ if (!ExAcquireResourceExclusiveLite(&(Fcb->MainResource), Wait))
+ {
+ DPRINT("VfatAcquireForLazyWrite(): ExReleaseResourceLite failed.\n");
+ return FALSE;
+ }
+ return TRUE;
+}
+
+VOID STDCALL
+VfatReleaseFromLazyWrite(IN PVOID Context)
+{
+ PVFATFCB Fcb = (PVFATFCB)Context;
+ ASSERT(Fcb);
+ DPRINT("VfatReleaseFromLazyWrite(): Fcb %p\n", Fcb);
+
+ ExReleaseResourceLite(&(Fcb->MainResource));
+}
+
+BOOLEAN STDCALL
+VfatAcquireForReadAhead(IN PVOID Context,
+ IN BOOLEAN Wait)
+{
+ PVFATFCB Fcb = (PVFATFCB)Context;
+ ASSERT(Fcb);
+ DPRINT("VfatAcquireForReadAhead(): Fcb %p\n", Fcb);
+
+ if (!ExAcquireResourceExclusiveLite(&(Fcb->MainResource), Wait))
+ {
+ DPRINT("VfatAcquireForReadAhead(): ExReleaseResourceLite failed.\n");
+ return FALSE;
+ }
+ return TRUE;
+}
+
+VOID STDCALL
+VfatReleaseFromReadAhead(IN PVOID Context)
+{
+ PVFATFCB Fcb = (PVFATFCB)Context;
+ ASSERT(Fcb);
+ DPRINT("VfatReleaseFromReadAhead(): Fcb %p\n", Fcb);
+
+ ExReleaseResourceLite(&(Fcb->MainResource));
+}
+
+VOID
+VfatInitFastIoRoutines(PFAST_IO_DISPATCH FastIoDispatch)
+{
+ FastIoDispatch->SizeOfFastIoDispatch = sizeof(FAST_IO_DISPATCH);
+ FastIoDispatch->FastIoCheckIfPossible = VfatFastIoCheckIfPossible;
+ FastIoDispatch->FastIoRead = VfatFastIoRead;
+ FastIoDispatch->FastIoWrite = VfatFastIoWrite;
+ FastIoDispatch->FastIoQueryBasicInfo = VfatFastIoQueryBasicInfo;
+ FastIoDispatch->FastIoQueryStandardInfo = VfatFastIoQueryStandardInfo;
+ FastIoDispatch->FastIoLock = VfatFastIoLock;
+ FastIoDispatch->FastIoUnlockSingle = VfatFastIoUnlockSingle;
+ FastIoDispatch->FastIoUnlockAll = VfatFastIoUnlockAll;
+ FastIoDispatch->FastIoUnlockAllByKey = VfatFastIoUnlockAllByKey;
+ FastIoDispatch->FastIoDeviceControl = VfatFastIoDeviceControl;
+ FastIoDispatch->AcquireFileForNtCreateSection = VfatAcquireFileForNtCreateSection;
+ FastIoDispatch->ReleaseFileForNtCreateSection = VfatReleaseFileForNtCreateSection;
+ FastIoDispatch->FastIoDetachDevice = VfatFastIoDetachDevice;
+ FastIoDispatch->FastIoQueryNetworkOpenInfo = VfatFastIoQueryNetworkOpenInfo;
+ FastIoDispatch->AcquireForModWrite = VfatAcquireForModWrite;
+ FastIoDispatch->MdlRead = VfatMdlRead;
+ FastIoDispatch->MdlReadComplete = VfatMdlReadComplete;
+ FastIoDispatch->PrepareMdlWrite = VfatPrepareMdlWrite;
+ FastIoDispatch->MdlWriteComplete = VfatMdlWriteComplete;
+ FastIoDispatch->FastIoReadCompressed = VfatFastIoReadCompressed;
+ FastIoDispatch->FastIoWriteCompressed = VfatFastIoWriteCompressed;
+ FastIoDispatch->MdlReadCompleteCompressed = VfatMdlReadCompleteCompressed;
+ FastIoDispatch->MdlWriteCompleteCompressed = VfatMdlWriteCompleteCompressed;
+ FastIoDispatch->FastIoQueryOpen = VfatFastIoQueryOpen;
+ FastIoDispatch->ReleaseForModWrite = VfatReleaseForModWrite;
+ FastIoDispatch->AcquireForCcFlush = VfatAcquireForCcFlush;
+ FastIoDispatch->ReleaseForCcFlush = VfatReleaseForCcFlush;
+}
+
+
diff --git a/reactos/drivers/fs/vfat/fat.c b/reactos/drivers/fs/vfat/fat.c
index 433f21324b4..27ebe3f1d3a 100644
--- a/reactos/drivers/fs/vfat/fat.c
+++ b/reactos/drivers/fs/vfat/fat.c
@@ -12,13 +12,7 @@
/* INCLUDES *****************************************************************/
-#include
-#include
-#include
-
#define NDEBUG
-#include
-
#include "vfat.h"
/* GLOBALS ******************************************************************/
@@ -157,7 +151,7 @@ FAT16FindAndMarkAvailableCluster(PDEVICE_EXTENSION DeviceExt,
for (i = StartCluster; i < FatLength; )
{
Offset.QuadPart = ROUND_DOWN(i * 2, ChunkSize);
- if(!CcMapData(DeviceExt->FATFileObject, &Offset, ChunkSize, 1, &Context, &BaseAddress))
+ if(!CcPinRead(DeviceExt->FATFileObject, &Offset, ChunkSize, 1, &Context, &BaseAddress))
{
DPRINT1("CcMapData(Offset %x, Length %d) failed\n", (ULONG)Offset.QuadPart, ChunkSize);
return STATUS_UNSUCCESSFUL;
@@ -209,7 +203,7 @@ FAT12FindAndMarkAvailableCluster(PDEVICE_EXTENSION DeviceExt, PULONG Cluster)
*Cluster = 0;
StartCluster = DeviceExt->LastAvailableCluster;
Offset.QuadPart = 0;
- if(!CcMapData(DeviceExt->FATFileObject, &Offset, DeviceExt->FatInfo.FATSectors * DeviceExt->FatInfo.BytesPerSector, 1, &Context, &BaseAddress))
+ if(!CcPinRead(DeviceExt->FATFileObject, &Offset, DeviceExt->FatInfo.FATSectors * DeviceExt->FatInfo.BytesPerSector, 1, &Context, &BaseAddress))
{
DPRINT1("CcMapData(Offset %x, Length %d) failed\n", (ULONG)Offset.QuadPart, DeviceExt->FatInfo.FATSectors * DeviceExt->FatInfo.BytesPerSector);
return STATUS_UNSUCCESSFUL;
@@ -274,7 +268,7 @@ FAT32FindAndMarkAvailableCluster (PDEVICE_EXTENSION DeviceExt, PULONG Cluster)
for (i = StartCluster; i < FatLength;)
{
Offset.QuadPart = ROUND_DOWN(i * 4, ChunkSize);
- if(!CcMapData(DeviceExt->FATFileObject, &Offset, ChunkSize, 1, &Context, &BaseAddress))
+ if(!CcPinRead(DeviceExt->FATFileObject, &Offset, ChunkSize, 1, &Context, &BaseAddress))
{
DPRINT1("CcMapData(Offset %x, Length %d) failed\n", (ULONG)Offset.QuadPart, ChunkSize);
return STATUS_UNSUCCESSFUL;
@@ -491,7 +485,7 @@ FAT12WriteCluster(PDEVICE_EXTENSION DeviceExt,
LARGE_INTEGER Offset;
Offset.QuadPart = 0;
- if(!CcMapData(DeviceExt->FATFileObject, &Offset, DeviceExt->FatInfo.FATSectors * DeviceExt->FatInfo.BytesPerSector, 1, &Context, &BaseAddress))
+ if(!CcPinRead(DeviceExt->FATFileObject, &Offset, DeviceExt->FatInfo.FATSectors * DeviceExt->FatInfo.BytesPerSector, 1, &Context, &BaseAddress))
{
return STATUS_UNSUCCESSFUL;
}
@@ -540,7 +534,7 @@ FAT16WriteCluster(PDEVICE_EXTENSION DeviceExt,
ChunkSize = CACHEPAGESIZE(DeviceExt);
FATOffset = ClusterToWrite * 2;
Offset.QuadPart = ROUND_DOWN(FATOffset, ChunkSize);
- if(!CcMapData(DeviceExt->FATFileObject, &Offset, ChunkSize, 1, &Context, &BaseAddress))
+ if(!CcPinRead(DeviceExt->FATFileObject, &Offset, ChunkSize, 1, &Context, &BaseAddress))
{
return STATUS_UNSUCCESSFUL;
}
@@ -574,7 +568,7 @@ FAT32WriteCluster(PDEVICE_EXTENSION DeviceExt,
FATOffset = (ClusterToWrite * 4);
Offset.QuadPart = ROUND_DOWN(FATOffset, ChunkSize);
- if(!CcMapData(DeviceExt->FATFileObject, &Offset, ChunkSize, 1, &Context, &BaseAddress))
+ if(!CcPinRead(DeviceExt->FATFileObject, &Offset, ChunkSize, 1, &Context, &BaseAddress))
{
return STATUS_UNSUCCESSFUL;
}
diff --git a/reactos/drivers/fs/vfat/fcb.c b/reactos/drivers/fs/vfat/fcb.c
index a3687d48c9b..ecffdcbb68e 100644
--- a/reactos/drivers/fs/vfat/fcb.c
+++ b/reactos/drivers/fs/vfat/fcb.c
@@ -13,20 +13,13 @@
/* ------------------------------------------------------- INCLUDES */
-#include
-#include
-#include
-#include
-#include
+#include /* towlower prototype */
#define NDEBUG
-#include
-
#include "vfat.h"
/* -------------------------------------------------------- DEFINES */
-#define TAG(A, B, C, D) (ULONG)(((A)<<0) + ((B)<<8) + ((C)<<16) + ((D)<<24))
#define TAG_FCB TAG('V', 'F', 'C', 'B')
#define ROUND_UP(N, S) ((((N) + (S) - 1) / (S)) * (S))
@@ -55,7 +48,7 @@ VOID
vfatSplitPathName(PUNICODE_STRING PathNameU, PUNICODE_STRING DirNameU, PUNICODE_STRING FileNameU)
{
PWCHAR pName;
- ULONG Length = 0;
+ USHORT Length = 0;
pName = PathNameU->Buffer + PathNameU->Length / sizeof(WCHAR) - 1;
while (*pName != L'\\' && pName >= PathNameU->Buffer)
{
@@ -79,9 +72,24 @@ vfatSplitPathName(PUNICODE_STRING PathNameU, PUNICODE_STRING DirNameU, PUNICODE_
VOID
vfatInitFcb(PVFATFCB Fcb, PUNICODE_STRING NameU)
{
+ ULONG PathNameBufferLength;
+
+ if (NameU)
+ PathNameBufferLength = NameU->Length + sizeof(WCHAR);
+ else
+ PathNameBufferLength = 0;
+
+ Fcb->PathNameBuffer = ExAllocatePool(NonPagedPool, PathNameBufferLength);
+ if (!Fcb->PathNameBuffer)
+ {
+ /* FIXME: what to do if no more memory? */
+ DPRINT1("Unable to initialize FCB for filename '%wZ'\n", NameU);
+ KEBUGCHECKEX(0, (ULONG_PTR)Fcb, (ULONG_PTR)NameU, 0, 0);
+ }
+
Fcb->PathNameU.Length = 0;
Fcb->PathNameU.Buffer = Fcb->PathNameBuffer;
- Fcb->PathNameU.MaximumLength = sizeof(Fcb->PathNameBuffer);
+ Fcb->PathNameU.MaximumLength = PathNameBufferLength;
Fcb->ShortNameU.Length = 0;
Fcb->ShortNameU.Buffer = Fcb->ShortNameBuffer;
Fcb->ShortNameU.MaximumLength = sizeof(Fcb->ShortNameBuffer);
@@ -129,6 +137,10 @@ vfatNewFCB(PDEVICE_EXTENSION pVCB, PUNICODE_STRING pFileNameU)
ExInitializeResourceLite(&rcFCB->MainResource);
FsRtlInitializeFileLock(&rcFCB->FileLock, NULL, NULL);
ExInitializeFastMutex(&rcFCB->LastMutex);
+ rcFCB->RFCB.PagingIoResource = &rcFCB->PagingIoResource;
+ rcFCB->RFCB.Resource = &rcFCB->MainResource;
+ rcFCB->RFCB.IsFastIoPossible = FastIoIsNotPossible;
+
return rcFCB;
}
@@ -146,18 +158,19 @@ VOID
vfatDestroyFCB(PVFATFCB pFCB)
{
FsRtlUninitializeFileLock(&pFCB->FileLock);
+ ExFreePool(pFCB->PathNameBuffer);
ExDeleteResourceLite(&pFCB->PagingIoResource);
ExDeleteResourceLite(&pFCB->MainResource);
ExFreeToNPagedLookasideList(&VfatGlobalData->FcbLookasideList, pFCB);
}
-BOOL
+BOOLEAN
vfatFCBIsDirectory(PVFATFCB FCB)
{
return *FCB->Attributes & FILE_ATTRIBUTE_DIRECTORY;
}
-BOOL
+BOOLEAN
vfatFCBIsRoot(PVFATFCB FCB)
{
return FCB->PathNameU.Length == sizeof(WCHAR) && FCB->PathNameU.Buffer[0] == L'\\' ? TRUE : FALSE;
@@ -219,7 +232,11 @@ vfatReleaseFCB(PDEVICE_EXTENSION pVCB, PVFATFCB pFCB)
/* Uninitialize file cache if initialized for this file object. */
if (pFCB->FileObject->SectionObjectPointer->SharedCacheMap)
{
+#ifdef USE_ROS_CC_AND_FS
CcRosReleaseFileCache(pFCB->FileObject);
+#else
+ CcUninitializeCacheMap(pFCB->FileObject, NULL, NULL);
+#endif
}
vfatDestroyCCB(pFCB->FileObject->FsContext2);
pFCB->FileObject->FsContext2 = NULL;
@@ -316,9 +333,11 @@ vfatGrabFCBFromTable(PDEVICE_EXTENSION pVCB, PUNICODE_STRING PathNameU)
NTSTATUS
vfatFCBInitializeCacheFromVolume (PVCB vcb, PVFATFCB fcb)
{
+#ifdef USE_ROS_CC_AND_FS
NTSTATUS status;
- PFILE_OBJECT fileObject;
ULONG fileCacheQuantum;
+#endif
+ PFILE_OBJECT fileObject;
PVFATCCB newCCB;
fileObject = IoCreateStreamFileObject (NULL, vcb->StorageDevice);
@@ -330,13 +349,12 @@ vfatFCBInitializeCacheFromVolume (PVCB vcb, PVFATFCB fcb)
}
RtlZeroMemory(newCCB, sizeof (VFATCCB));
- fileObject->Flags |= FO_FCB_IS_VALID | FO_DIRECT_CACHE_PAGING_READ;
fileObject->SectionObjectPointer = &fcb->SectionObjectPointers;
fileObject->FsContext = fcb;
fileObject->FsContext2 = newCCB;
fcb->FileObject = fileObject;
-
+#ifdef USE_ROS_CC_AND_FS
fileCacheQuantum = (vcb->FatInfo.BytesPerCluster >= PAGE_SIZE) ?
vcb->FatInfo.BytesPerCluster : PAGE_SIZE;
@@ -347,10 +365,22 @@ vfatFCBInitializeCacheFromVolume (PVCB vcb, PVFATFCB fcb)
DbgPrint ("CcRosInitializeFileCache failed\n");
KEBUGCHECK (0);
}
+#else
+ /* FIXME: Guard by SEH. */
+ CcInitializeCacheMap(fileObject,
+ (PCC_FILE_SIZES)(&fcb->RFCB.AllocationSize),
+ FALSE,
+ &VfatGlobalData->CacheMgrCallbacks,
+ fcb);
+#endif
fcb->Flags |= FCB_CACHE_INITIALIZED;
+#ifdef USE_ROS_CC_AND_FS
return status;
+#else
+ return STATUS_SUCCESS;
+#endif
}
PVFATFCB
@@ -359,9 +389,7 @@ vfatMakeRootFCB(PDEVICE_EXTENSION pVCB)
PVFATFCB FCB;
ULONG FirstCluster, CurrentCluster, Size = 0;
NTSTATUS Status = STATUS_SUCCESS;
- UNICODE_STRING NameU;
-
- RtlRosInitUnicodeStringFromLiteral(&NameU, L"\\");
+ UNICODE_STRING NameU = RTL_CONSTANT_STRING(L"\\");
FCB = vfatNewFCB(pVCB, &NameU);
if (FCB->Flags & FCB_IS_FATX_ENTRY)
@@ -401,6 +429,7 @@ vfatMakeRootFCB(PDEVICE_EXTENSION pVCB)
FCB->RFCB.FileSize.QuadPart = Size;
FCB->RFCB.ValidDataLength.QuadPart = Size;
FCB->RFCB.AllocationSize.QuadPart = Size;
+ FCB->RFCB.IsFastIoPossible = FastIoIsNotPossible;
vfatFCBInitializeCacheFromVolume(pVCB, FCB);
vfatAddFCBToTable(pVCB, FCB);
@@ -412,9 +441,7 @@ PVFATFCB
vfatOpenRootFCB(PDEVICE_EXTENSION pVCB)
{
PVFATFCB FCB;
- UNICODE_STRING NameU;
-
- RtlRosInitUnicodeStringFromLiteral(&NameU, L"\\");
+ UNICODE_STRING NameU = RTL_CONSTANT_STRING(L"\\");
FCB = vfatGrabFCBFromTable (pVCB, &NameU);
if (FCB == NULL)
@@ -432,20 +459,31 @@ vfatMakeFCBFromDirEntry(PVCB vcb,
PVFATFCB* fileFCB)
{
PVFATFCB rcFCB;
- WCHAR pathName [MAX_PATH];
+ PWCHAR PathNameBuffer;
+ ULONG PathNameLength;
ULONG Size;
ULONG hash;
UNICODE_STRING NameU;
- if (directoryFCB->PathNameU.Length + 2 * sizeof(WCHAR) +
- + DirContext->LongNameU.Length > MAX_PATH * sizeof(WCHAR))
+ PathNameLength = directoryFCB->PathNameU.Length + max(DirContext->LongNameU.Length, DirContext->ShortNameU.Length);
+ if (!vfatFCBIsRoot (directoryFCB))
+ {
+ PathNameLength += sizeof(WCHAR);
+ }
+
+ if (PathNameLength > LONGNAME_MAX_LENGTH * sizeof(WCHAR))
{
return STATUS_OBJECT_NAME_INVALID;
}
- NameU.Buffer = pathName;
+ PathNameBuffer = ExAllocatePool(NonPagedPool, PathNameLength + sizeof(WCHAR));
+ if (!PathNameBuffer)
+ {
+ return STATUS_INSUFFICIENT_RESOURCES;
+ }
+ NameU.Buffer = PathNameBuffer;
NameU.Length = 0;
- NameU.MaximumLength = sizeof(pathName);
+ NameU.MaximumLength = PathNameLength;
RtlCopyUnicodeString(&NameU, &directoryFCB->PathNameU);
if (!vfatFCBIsRoot (directoryFCB))
@@ -505,6 +543,12 @@ vfatMakeFCBFromDirEntry(PVCB vcb,
}
rcFCB->dirIndex = DirContext->DirIndex;
rcFCB->startIndex = DirContext->StartIndex;
+ if ((rcFCB->Flags & FCB_IS_FATX_ENTRY) && !vfatFCBIsRoot (directoryFCB))
+ {
+ ASSERT(DirContext->DirIndex >= 2 && DirContext->StartIndex >= 2);
+ rcFCB->dirIndex = DirContext->DirIndex-2;
+ rcFCB->startIndex = DirContext->StartIndex-2;
+ }
rcFCB->RFCB.FileSize.QuadPart = Size;
rcFCB->RFCB.ValidDataLength.QuadPart = Size;
rcFCB->RFCB.AllocationSize.QuadPart = ROUND_UP(Size, vcb->FatInfo.BytesPerCluster);
@@ -517,6 +561,7 @@ vfatMakeFCBFromDirEntry(PVCB vcb,
vfatAddFCBToTable (vcb, rcFCB);
*fileFCB = rcFCB;
+ ExFreePool(PathNameBuffer);
return STATUS_SUCCESS;
}
@@ -535,8 +580,6 @@ vfatAttachFCBToFileObject (PDEVICE_EXTENSION vcb,
}
RtlZeroMemory (newCCB, sizeof (VFATCCB));
- fileObject->Flags = fileObject->Flags | FO_FCB_IS_VALID |
- FO_DIRECT_CACHE_PAGING_READ;
fileObject->SectionObjectPointer = &fcb->SectionObjectPointers;
fileObject->FsContext = fcb;
fileObject->FsContext2 = newCCB;
@@ -556,7 +599,9 @@ vfatDirFindFile (PDEVICE_EXTENSION pDeviceExt,
PVOID Page = NULL;
BOOLEAN First = TRUE;
VFAT_DIRENTRY_CONTEXT DirContext;
- WCHAR LongNameBuffer[MAX_PATH];
+ /* This buffer must have a size of 260 characters, because
+ vfatMakeFCBFromDirEntry can copy 20 name entries with 13 characters. */
+ WCHAR LongNameBuffer[260];
WCHAR ShortNameBuffer[13];
BOOLEAN FoundLong = FALSE;
BOOLEAN FoundShort = FALSE;
@@ -634,7 +679,7 @@ vfatGetFCBForFile (PDEVICE_EXTENSION pVCB,
PVFATFCB FCB = NULL;
PVFATFCB parentFCB;
UNICODE_STRING NameU;
- UNICODE_STRING RootNameU;
+ UNICODE_STRING RootNameU = RTL_CONSTANT_STRING(L"\\");
PWCHAR curr, prev, last;
ULONG Length;
@@ -648,8 +693,6 @@ vfatGetFCBForFile (PDEVICE_EXTENSION pVCB,
if (parentFCB == NULL)
{
- RtlRosInitUnicodeStringFromLiteral(&RootNameU, L"\\");
-
// Trivial case, open of the root directory on volume
if (RtlEqualUnicodeString(pFileNameU, &RootNameU, FALSE))
{
@@ -693,9 +736,9 @@ vfatGetFCBForFile (PDEVICE_EXTENSION pVCB,
vfatReleaseFCB (pVCB, FCB);
return STATUS_OBJECT_NAME_INVALID;
}
- memmove(pFileNameU->Buffer + FCB->PathNameU.Length / sizeof(WCHAR),
+ RtlMoveMemory(pFileNameU->Buffer + FCB->PathNameU.Length / sizeof(WCHAR),
curr, pFileNameU->Length - Length);
- pFileNameU->Length += FCB->PathNameU.Length - Length;
+ pFileNameU->Length += (USHORT)(FCB->PathNameU.Length - Length);
curr = pFileNameU->Buffer + FCB->PathNameU.Length / sizeof(WCHAR);
last = pFileNameU->Buffer + pFileNameU->Length / sizeof(WCHAR) - 1;
}
@@ -754,9 +797,9 @@ vfatGetFCBForFile (PDEVICE_EXTENSION pVCB,
vfatReleaseFCB (pVCB, parentFCB);
return STATUS_OBJECT_NAME_INVALID;
}
- memmove(prev + parentFCB->LongNameU.Length / sizeof(WCHAR), curr,
+ RtlMoveMemory(prev + parentFCB->LongNameU.Length / sizeof(WCHAR), curr,
pFileNameU->Length - (curr - pFileNameU->Buffer) * sizeof(WCHAR));
- pFileNameU->Length += parentFCB->LongNameU.Length - Length;
+ pFileNameU->Length += (USHORT)(parentFCB->LongNameU.Length - Length);
curr = prev + parentFCB->LongNameU.Length / sizeof(WCHAR);
last = pFileNameU->Buffer + pFileNameU->Length / sizeof(WCHAR) - 1;
}
diff --git a/reactos/drivers/fs/vfat/finfo.c b/reactos/drivers/fs/vfat/finfo.c
index 3c4b2baa2f3..1f8015fe8c9 100644
--- a/reactos/drivers/fs/vfat/finfo.c
+++ b/reactos/drivers/fs/vfat/finfo.c
@@ -12,14 +12,57 @@
/* INCLUDES *****************************************************************/
-#include
-#include
-
#define NDEBUG
-#include
-
#include "vfat.h"
+/* GLOBALS ******************************************************************/
+
+const char* FileInformationClassNames[] =
+{
+ "??????",
+ "FileDirectoryInformation",
+ "FileFullDirectoryInformation",
+ "FileBothDirectoryInformation",
+ "FileBasicInformation",
+ "FileStandardInformation",
+ "FileInternalInformation",
+ "FileEaInformation",
+ "FileAccessInformation",
+ "FileNameInformation",
+ "FileRenameInformation",
+ "FileLinkInformation",
+ "FileNamesInformation",
+ "FileDispositionInformation",
+ "FilePositionInformation",
+ "FileFullEaInformation",
+ "FileModeInformation",
+ "FileAlignmentInformation",
+ "FileAllInformation",
+ "FileAllocationInformation",
+ "FileEndOfFileInformation",
+ "FileAlternateNameInformation",
+ "FileStreamInformation",
+ "FilePipeInformation",
+ "FilePipeLocalInformation",
+ "FilePipeRemoteInformation",
+ "FileMailslotQueryInformation",
+ "FileMailslotSetInformation",
+ "FileCompressionInformation",
+ "FileObjectIdInformation",
+ "FileCompletionInformation",
+ "FileMoveClusterInformation",
+ "FileQuotaInformation",
+ "FileReparsePointInformation",
+ "FileNetworkOpenInformation",
+ "FileAttributeTagInformation",
+ "FileTrackingInformation",
+ "FileIdBothDirectoryInformation",
+ "FileIdFullDirectoryInformation",
+ "FileValidDataLengthInformation",
+ "FileShortNameInformation",
+ "FileMaximumInformation"
+};
+
/* FUNCTIONS ****************************************************************/
static NTSTATUS
@@ -226,8 +269,9 @@ VfatSetDispositionInformation(PFILE_OBJECT FileObject,
PFILE_DISPOSITION_INFORMATION DispositionInfo)
{
NTSTATUS Status = STATUS_SUCCESS;
-
+#ifdef DBG
PDEVICE_EXTENSION DeviceExt = DeviceObject->DeviceExtension;
+#endif
DPRINT ("FsdSetDispositionInformation()\n");
@@ -248,13 +292,13 @@ VfatSetDispositionInformation(PFILE_OBJECT FileObject,
return STATUS_ACCESS_DENIED;
}
- if (DispositionInfo->DoDeleteFile)
+ if (DispositionInfo->DeleteFile)
{
if (MmFlushImageSection (FileObject->SectionObjectPointer, MmFlushForDelete))
{
- if (FCB->RefCount > 1)
+ if (FCB->OpenHandleCount > 1)
{
- DPRINT1("%d %x\n", FCB->RefCount, CcGetFileObjectFromSectionPtrs(FileObject->SectionObjectPointer));
+ DPRINT1("%d %x\n", FCB->OpenHandleCount, CcGetFileObjectFromSectionPtrs(FileObject->SectionObjectPointer));
Status = STATUS_ACCESS_DENIED;
}
else
@@ -479,7 +523,7 @@ VfatSetAllocationSizeInformation(PFILE_OBJECT FileObject,
ULONG ClusterSize = DeviceExt->FatInfo.BytesPerCluster;
ULONG NewSize = AllocationSize->u.LowPart;
ULONG NCluster;
- BOOL AllocSizeChanged = FALSE;
+ BOOLEAN AllocSizeChanged = FALSE;
DPRINT("VfatSetAllocationSizeInformation()\n");
@@ -654,6 +698,10 @@ NTSTATUS VfatQueryInformation(PVFAT_IRP_CONTEXT IrpContext)
FileInformationClass = IrpContext->Stack->Parameters.QueryFile.FileInformationClass;
FCB = (PVFATFCB) IrpContext->FileObject->FsContext;
+ DPRINT("VfatQueryInformation is called for '%s'\n",
+ FileInformationClass >= FileMaximumInformation - 1 ? "????" : FileInformationClassNames[FileInformationClass]);
+
+
SystemBuffer = IrpContext->Irp->AssociatedIrp.SystemBuffer;
BufferLength = IrpContext->Stack->Parameters.QueryFile.Length;
@@ -746,7 +794,7 @@ NTSTATUS VfatSetInformation(PVFAT_IRP_CONTEXT IrpContext)
PVFATFCB FCB = NULL;
NTSTATUS RC = STATUS_SUCCESS;
PVOID SystemBuffer;
- BOOL CanWait = IrpContext->Flags & IRPCONTEXT_CANWAIT;
+ BOOLEAN CanWait = (IrpContext->Flags & IRPCONTEXT_CANWAIT) != 0;
/* PRECONDITION */
ASSERT(IrpContext);
@@ -758,6 +806,9 @@ NTSTATUS VfatSetInformation(PVFAT_IRP_CONTEXT IrpContext)
IrpContext->Stack->Parameters.SetFile.FileInformationClass;
FCB = (PVFATFCB) IrpContext->FileObject->FsContext;
SystemBuffer = IrpContext->Irp->AssociatedIrp.SystemBuffer;
+
+ DPRINT("VfatSetInformation is called for '%s'\n",
+ FileInformationClass >= FileMaximumInformation - 1 ? "????" : FileInformationClassNames[ FileInformationClass]);
DPRINT("FileInformationClass %d\n", FileInformationClass);
DPRINT("SystemBuffer %x\n", SystemBuffer);
diff --git a/reactos/drivers/fs/vfat/flush.c b/reactos/drivers/fs/vfat/flush.c
index f128dfdcf21..9326a224c6e 100644
--- a/reactos/drivers/fs/vfat/flush.c
+++ b/reactos/drivers/fs/vfat/flush.c
@@ -9,11 +9,8 @@
/* INCLUDES *****************************************************************/
-#include
-#include "vfat.h"
-
#define NDEBUG
-#include
+#include "vfat.h"
/* FUNCTIONS ****************************************************************/
diff --git a/reactos/drivers/fs/vfat/fsctl.c b/reactos/drivers/fs/vfat/fsctl.c
index efdda7ca630..0a797c76075 100644
--- a/reactos/drivers/fs/vfat/fsctl.c
+++ b/reactos/drivers/fs/vfat/fsctl.c
@@ -26,14 +26,7 @@
/* INCLUDES *****************************************************************/
-#include
-#include
-#include
-#include
-
#define NDEBUG
-#include
-
#include "vfat.h"
/* FUNCTIONS ****************************************************************/
@@ -56,7 +49,7 @@ VfatHasFileSystem(PDEVICE_OBJECT DeviceToMount,
LARGE_INTEGER Offset;
struct _BootSector* Boot;
struct _BootSectorFatX* BootFatX;
- BOOL PartitionInfoIsValid = FALSE;
+ BOOLEAN PartitionInfoIsValid = FALSE;
DPRINT("VfatHasFileSystem\n");
@@ -123,153 +116,143 @@ VfatHasFileSystem(PDEVICE_OBJECT DeviceToMount,
*RecognizedFS = TRUE;
}
}
- /*
- * Floppy disk driver can return Unknown as media type if it
- * doesn't know yet what floppy in the drive really is. This is
- * perfectly correct to do under Windows.
- */
- if (DiskGeometry.MediaType == Unknown)
+ else if (DiskGeometry.MediaType == Unknown)
{
+ /*
+ * Floppy disk driver can return Unknown as media type if it
+ * doesn't know yet what floppy in the drive really is. This is
+ * perfectly correct to do under Windows.
+ */
*RecognizedFS = TRUE;
DiskGeometry.BytesPerSector = 512;
}
- if (DiskGeometry.MediaType > Unknown && DiskGeometry.MediaType < RemovableMedia )
+ else
{
*RecognizedFS = TRUE;
- }
- if (*RecognizedFS == FALSE)
+ }
+ if (*RecognizedFS)
{
- return STATUS_SUCCESS;
- }
- Boot = ExAllocatePool(NonPagedPool, DiskGeometry.BytesPerSector);
- if (Boot == NULL)
- {
- *RecognizedFS=FALSE;
- return STATUS_INSUFFICIENT_RESOURCES;
- }
+ Boot = ExAllocatePool(NonPagedPool, DiskGeometry.BytesPerSector);
+ if (Boot == NULL)
+ {
+ return STATUS_INSUFFICIENT_RESOURCES;
+ }
- Offset.QuadPart = 0;
+ Offset.QuadPart = 0;
- /* Try to recognize FAT12/FAT16/FAT32 partitions */
- Status = VfatReadDisk(DeviceToMount, &Offset, DiskGeometry.BytesPerSector, (PUCHAR) Boot, FALSE);
- if (NT_SUCCESS(Status))
- {
- if (Boot->Signatur1 != 0xaa55)
+ /* Try to recognize FAT12/FAT16/FAT32 partitions */
+ Status = VfatReadDisk(DeviceToMount, &Offset, DiskGeometry.BytesPerSector, (PUCHAR) Boot, FALSE);
+ if (NT_SUCCESS(Status))
{
- BootFatX = (struct _BootSectorFatX *) Boot;
- if (BootFatX->SysType[0] != 'F' ||
- BootFatX->SysType[1] != 'A' ||
- BootFatX->SysType[2] != 'T' ||
- BootFatX->SysType[3] != 'X')
+ if (Boot->Signatur1 != 0xaa55)
{
- DPRINT1("Signature %04x\n", Boot->Signatur1);
- }
- *RecognizedFS=FALSE;
- }
- if (*RecognizedFS &&
- Boot->BytesPerSector != 512 &&
- Boot->BytesPerSector != 1024 &&
- Boot->BytesPerSector != 2048 &&
- Boot->BytesPerSector != 4096)
- {
- DPRINT1("BytesPerSector %d\n", Boot->BytesPerSector);
- *RecognizedFS=FALSE;
- }
-
- if (*RecognizedFS &&
- Boot->FATCount != 1 &&
- Boot->FATCount != 2)
- {
- DPRINT1("FATCount %d\n", Boot->FATCount);
- *RecognizedFS=FALSE;
- }
-
- if (*RecognizedFS &&
- Boot->Media != 0xf0 &&
- Boot->Media != 0xf8 &&
- Boot->Media != 0xf9 &&
- Boot->Media != 0xfa &&
- Boot->Media != 0xfb &&
- Boot->Media != 0xfc &&
- Boot->Media != 0xfd &&
- Boot->Media != 0xfe &&
- Boot->Media != 0xff)
- {
- DPRINT1("Media %02x\n", Boot->Media);
- *RecognizedFS=FALSE;
- }
-
- if (*RecognizedFS &&
- Boot->SectorsPerCluster != 1 &&
- Boot->SectorsPerCluster != 2 &&
- Boot->SectorsPerCluster != 4 &&
- Boot->SectorsPerCluster != 8 &&
- Boot->SectorsPerCluster != 16 &&
- Boot->SectorsPerCluster != 32 &&
- Boot->SectorsPerCluster != 64 &&
- Boot->SectorsPerCluster != 128)
- {
- DPRINT1("SectorsPerCluster %02x\n", Boot->SectorsPerCluster);
- *RecognizedFS=FALSE;
- }
-
- if (*RecognizedFS &&
- Boot->BytesPerSector * Boot->SectorsPerCluster > 32 * 1024)
- {
- DPRINT1("ClusterSize %dx\n", Boot->BytesPerSector * Boot->SectorsPerCluster);
- *RecognizedFS=FALSE;
- }
-
- if (*RecognizedFS)
- {
- FatInfo.VolumeID = Boot->VolumeID;
- FatInfo.FATStart = Boot->ReservedSectors;
- FatInfo.FATCount = Boot->FATCount;
- FatInfo.FATSectors = Boot->FATSectors ? Boot->FATSectors : ((struct _BootSector32*) Boot)->FATSectors32;
- FatInfo.BytesPerSector = Boot->BytesPerSector;
- FatInfo.SectorsPerCluster = Boot->SectorsPerCluster;
- FatInfo.BytesPerCluster = FatInfo.BytesPerSector * FatInfo.SectorsPerCluster;
- FatInfo.rootDirectorySectors = ((Boot->RootEntries * 32) + Boot->BytesPerSector - 1) / Boot->BytesPerSector;
- FatInfo.rootStart = FatInfo.FATStart + FatInfo.FATCount * FatInfo.FATSectors;
- FatInfo.dataStart = FatInfo.rootStart + FatInfo.rootDirectorySectors;
- FatInfo.Sectors = Sectors = Boot->Sectors ? Boot->Sectors : Boot->SectorsHuge;
- Sectors -= Boot->ReservedSectors + FatInfo.FATCount * FatInfo.FATSectors + FatInfo.rootDirectorySectors;
- FatInfo.NumberOfClusters = Sectors / Boot->SectorsPerCluster;
- if (FatInfo.NumberOfClusters < 4085)
- {
- DPRINT("FAT12\n");
- FatInfo.FatType = FAT12;
- }
- else if (FatInfo.NumberOfClusters >= 65525)
- {
- DPRINT("FAT32\n");
- FatInfo.FatType = FAT32;
- FatInfo.RootCluster = ((struct _BootSector32*) Boot)->RootCluster;
- FatInfo.rootStart = FatInfo.dataStart + ((FatInfo.RootCluster - 2) * FatInfo.SectorsPerCluster);
- FatInfo.VolumeID = ((struct _BootSector32*) Boot)->VolumeID;
- }
- else
- {
- DPRINT("FAT16\n");
- FatInfo.FatType = FAT16;
- }
- if (PartitionInfoIsValid &&
- FatInfo.Sectors > PartitionInfo.PartitionLength.QuadPart / FatInfo.BytesPerSector)
- {
- CHECKPOINT1;
*RecognizedFS = FALSE;
}
-
- if (pFatInfo && *RecognizedFS)
+ if (*RecognizedFS &&
+ Boot->BytesPerSector != 512 &&
+ Boot->BytesPerSector != 1024 &&
+ Boot->BytesPerSector != 2048 &&
+ Boot->BytesPerSector != 4096)
{
- *pFatInfo = FatInfo;
+ DPRINT1("BytesPerSector %d\n", Boot->BytesPerSector);
+ *RecognizedFS = FALSE;
+ }
+
+ if (*RecognizedFS &&
+ Boot->FATCount != 1 &&
+ Boot->FATCount != 2)
+ {
+ DPRINT1("FATCount %d\n", Boot->FATCount);
+ *RecognizedFS = FALSE;
+ }
+
+ if (*RecognizedFS &&
+ Boot->Media != 0xf0 &&
+ Boot->Media != 0xf8 &&
+ Boot->Media != 0xf9 &&
+ Boot->Media != 0xfa &&
+ Boot->Media != 0xfb &&
+ Boot->Media != 0xfc &&
+ Boot->Media != 0xfd &&
+ Boot->Media != 0xfe &&
+ Boot->Media != 0xff)
+ {
+ DPRINT1("Media %02x\n", Boot->Media);
+ *RecognizedFS = FALSE;
+ }
+
+ if (*RecognizedFS &&
+ Boot->SectorsPerCluster != 1 &&
+ Boot->SectorsPerCluster != 2 &&
+ Boot->SectorsPerCluster != 4 &&
+ Boot->SectorsPerCluster != 8 &&
+ Boot->SectorsPerCluster != 16 &&
+ Boot->SectorsPerCluster != 32 &&
+ Boot->SectorsPerCluster != 64 &&
+ Boot->SectorsPerCluster != 128)
+ {
+ DPRINT1("SectorsPerCluster %02x\n", Boot->SectorsPerCluster);
+ *RecognizedFS = FALSE;
+ }
+
+ if (*RecognizedFS &&
+ Boot->BytesPerSector * Boot->SectorsPerCluster > 32 * 1024)
+ {
+ DPRINT1("ClusterSize %dx\n", Boot->BytesPerSector * Boot->SectorsPerCluster);
+ *RecognizedFS = FALSE;
+ }
+
+ if (*RecognizedFS)
+ {
+ FatInfo.VolumeID = Boot->VolumeID;
+ FatInfo.FATStart = Boot->ReservedSectors;
+ FatInfo.FATCount = Boot->FATCount;
+ FatInfo.FATSectors = Boot->FATSectors ? Boot->FATSectors : ((struct _BootSector32*) Boot)->FATSectors32;
+ FatInfo.BytesPerSector = Boot->BytesPerSector;
+ FatInfo.SectorsPerCluster = Boot->SectorsPerCluster;
+ FatInfo.BytesPerCluster = FatInfo.BytesPerSector * FatInfo.SectorsPerCluster;
+ FatInfo.rootDirectorySectors = ((Boot->RootEntries * 32) + Boot->BytesPerSector - 1) / Boot->BytesPerSector;
+ FatInfo.rootStart = FatInfo.FATStart + FatInfo.FATCount * FatInfo.FATSectors;
+ FatInfo.dataStart = FatInfo.rootStart + FatInfo.rootDirectorySectors;
+ FatInfo.Sectors = Sectors = Boot->Sectors ? Boot->Sectors : Boot->SectorsHuge;
+ Sectors -= Boot->ReservedSectors + FatInfo.FATCount * FatInfo.FATSectors + FatInfo.rootDirectorySectors;
+ FatInfo.NumberOfClusters = Sectors / Boot->SectorsPerCluster;
+ if (FatInfo.NumberOfClusters < 4085)
+ {
+ DPRINT("FAT12\n");
+ FatInfo.FatType = FAT12;
+ }
+ else if (FatInfo.NumberOfClusters >= 65525)
+ {
+ DPRINT("FAT32\n");
+ FatInfo.FatType = FAT32;
+ FatInfo.RootCluster = ((struct _BootSector32*) Boot)->RootCluster;
+ FatInfo.rootStart = FatInfo.dataStart + ((FatInfo.RootCluster - 2) * FatInfo.SectorsPerCluster);
+ FatInfo.VolumeID = ((struct _BootSector32*) Boot)->VolumeID;
+ }
+ else
+ {
+ DPRINT("FAT16\n");
+ FatInfo.FatType = FAT16;
+ }
+ if (PartitionInfoIsValid &&
+ FatInfo.Sectors > PartitionInfo.PartitionLength.QuadPart / FatInfo.BytesPerSector)
+ {
+ CHECKPOINT1;
+ *RecognizedFS = FALSE;
+ }
+
+ if (pFatInfo && *RecognizedFS)
+ {
+ *pFatInfo = FatInfo;
+ }
}
}
+
+ ExFreePool(Boot);
}
- ExFreePool(Boot);
-
if (!*RecognizedFS && PartitionInfoIsValid)
{
BootFatX = ExAllocatePool(NonPagedPool, sizeof(struct _BootSectorFatX));
@@ -315,8 +298,8 @@ VfatHasFileSystem(PDEVICE_OBJECT DeviceToMount,
FatInfo.SectorsPerCluster = BootFatX->SectorsPerCluster;
FatInfo.rootDirectorySectors = BootFatX->SectorsPerCluster;
FatInfo.BytesPerCluster = BootFatX->SectorsPerCluster * DiskGeometry.BytesPerSector;
- FatInfo.NumberOfClusters = PartitionInfo.PartitionLength.QuadPart / FatInfo.BytesPerCluster;
- if (FatInfo.NumberOfClusters < 65525)
+ FatInfo.Sectors = PartitionInfo.PartitionLength.QuadPart / DiskGeometry.BytesPerSector;
+ if (FatInfo.Sectors / FatInfo.SectorsPerCluster < 65525)
{
DPRINT("FATX16\n");
FatInfo.FatType = FATX16;
@@ -329,13 +312,14 @@ VfatHasFileSystem(PDEVICE_OBJECT DeviceToMount,
FatInfo.VolumeID = BootFatX->VolumeID;
FatInfo.FATStart = sizeof(struct _BootSectorFatX) / DiskGeometry.BytesPerSector;
FatInfo.FATCount = BootFatX->FATCount;
- FatInfo.FATSectors =
- ROUND_UP(FatInfo.NumberOfClusters * (FatInfo.FatType == FATX16 ? 2 : 4), 4096) /
+ FatInfo.FATSectors =
+ ROUND_UP(FatInfo.Sectors / FatInfo.SectorsPerCluster * (FatInfo.FatType == FATX16 ? 2 : 4), 4096) /
FatInfo.BytesPerSector;
FatInfo.rootStart = FatInfo.FATStart + FatInfo.FATCount * FatInfo.FATSectors;
FatInfo.dataStart = FatInfo.rootStart + FatInfo.rootDirectorySectors;
- FatInfo.Sectors = PartitionInfo.PartitionLength.QuadPart / FatInfo.BytesPerSector;
- if (pFatInfo && *RecognizedFS)
+ FatInfo.NumberOfClusters = (FatInfo.Sectors - FatInfo.dataStart) / FatInfo.SectorsPerCluster;
+
+ if (pFatInfo && *RecognizedFS)
{
*pFatInfo = FatInfo;
}
@@ -386,7 +370,8 @@ VfatMount (PVFAT_IRP_CONTEXT IrpContext)
PVFATFCB VolumeFcb = NULL;
PVFATCCB Ccb = NULL;
PDEVICE_OBJECT DeviceToMount;
- UNICODE_STRING NameU;
+ UNICODE_STRING NameU = RTL_CONSTANT_STRING(L"\\$$Fat$$");
+ UNICODE_STRING VolumeNameU = RTL_CONSTANT_STRING(L"\\$$Volume$$");
DPRINT("VfatMount(IrpContext %x)\n", IrpContext);
@@ -496,7 +481,6 @@ VfatMount (PVFAT_IRP_CONTEXT IrpContext)
DPRINT("FsDeviceObject %lx\n", DeviceObject);
DeviceExt->FATFileObject = IoCreateStreamFileObject(NULL, DeviceExt->StorageDevice);
- RtlRosInitUnicodeStringFromLiteral(&NameU, L"\\$$Fat$$");
Fcb = vfatNewFCB(DeviceExt, &NameU);
if (Fcb == NULL)
{
@@ -511,7 +495,6 @@ VfatMount (PVFAT_IRP_CONTEXT IrpContext)
}
RtlZeroMemory(Ccb, sizeof (VFATCCB));
- DeviceExt->FATFileObject->Flags = DeviceExt->FATFileObject->Flags | FO_FCB_IS_VALID | FO_DIRECT_CACHE_PAGING_READ;
DeviceExt->FATFileObject->FsContext = Fcb;
DeviceExt->FATFileObject->FsContext2 = Ccb;
DeviceExt->FATFileObject->SectionObjectPointer = &Fcb->SectionObjectPointers;
@@ -525,6 +508,7 @@ VfatMount (PVFAT_IRP_CONTEXT IrpContext)
Fcb->RFCB.ValidDataLength = Fcb->RFCB.FileSize;
Fcb->RFCB.AllocationSize = Fcb->RFCB.FileSize;
+#ifdef USE_ROS_CC_AND_FS
if (DeviceExt->FatInfo.FatType != FAT12)
{
Status = CcRosInitializeFileCache(DeviceExt->FATFileObject, CACHEPAGESIZE(DeviceExt));
@@ -538,14 +522,21 @@ VfatMount (PVFAT_IRP_CONTEXT IrpContext)
DPRINT1 ("CcRosInitializeFileCache failed\n");
goto ByeBye;
}
+#else
+ /* FIXME: Guard by SEH. */
+ CcInitializeCacheMap(DeviceExt->FATFileObject,
+ (PCC_FILE_SIZES)(&Fcb->RFCB.AllocationSize),
+ FALSE,
+ &VfatGlobalData->CacheMgrCallbacks,
+ Fcb);
+#endif
DeviceExt->LastAvailableCluster = 2;
ExInitializeResourceLite(&DeviceExt->DirResource);
ExInitializeResourceLite(&DeviceExt->FatResource);
InitializeListHead(&DeviceExt->FcbListHead);
- RtlRosInitUnicodeStringFromLiteral(&NameU, L"\\$$Volume$$");
- VolumeFcb = vfatNewFCB(DeviceExt, &NameU);
+ VolumeFcb = vfatNewFCB(DeviceExt, &VolumeNameU);
if (VolumeFcb == NULL)
{
Status = STATUS_INSUFFICIENT_RESOURCES;
@@ -655,9 +646,9 @@ VfatGetVolumeBitmap(PVFAT_IRP_CONTEXT IrpContext)
static NTSTATUS
VfatGetRetrievalPointers(PVFAT_IRP_CONTEXT IrpContext)
{
- PIO_STACK_LOCATION Stack;
+ PIO_STACK_LOCATION Stack;
LARGE_INTEGER Vcn;
- PGET_RETRIEVAL_DESCRIPTOR RetrievalPointers;
+ PRETRIEVAL_POINTERS_BUFFER RetrievalPointers;
PFILE_OBJECT FileObject;
ULONG MaxExtentCount;
PVFATFCB Fcb;
@@ -678,7 +669,7 @@ VfatGetRetrievalPointers(PVFAT_IRP_CONTEXT IrpContext)
return STATUS_INVALID_PARAMETER;
}
if (IrpContext->Irp->UserBuffer == NULL ||
- Stack->Parameters.DeviceIoControl.OutputBufferLength < sizeof(GET_RETRIEVAL_DESCRIPTOR) + sizeof(MAPPING_PAIR))
+ Stack->Parameters.DeviceIoControl.OutputBufferLength < sizeof(RETRIEVAL_POINTERS_BUFFER))
{
return STATUS_BUFFER_TOO_SMALL;
}
@@ -690,7 +681,7 @@ VfatGetRetrievalPointers(PVFAT_IRP_CONTEXT IrpContext)
Vcn = *(PLARGE_INTEGER)Stack->Parameters.DeviceIoControl.Type3InputBuffer;
RetrievalPointers = IrpContext->Irp->UserBuffer;
- MaxExtentCount = ((Stack->Parameters.DeviceIoControl.OutputBufferLength - sizeof(GET_RETRIEVAL_DESCRIPTOR)) / sizeof(MAPPING_PAIR));
+ MaxExtentCount = ((Stack->Parameters.DeviceIoControl.OutputBufferLength - sizeof(RetrievalPointers->ExtentCount) - sizeof(RetrievalPointers->StartingVcn)) / sizeof(RetrievalPointers->Extents[0]));
if (Vcn.QuadPart >= Fcb->RFCB.AllocationSize.QuadPart / DeviceExt->FatInfo.BytesPerCluster)
@@ -708,11 +699,12 @@ VfatGetRetrievalPointers(PVFAT_IRP_CONTEXT IrpContext)
goto ByeBye;
}
- RetrievalPointers->StartVcn = Vcn.QuadPart;
- RetrievalPointers->NumberOfPairs = 0;
- RetrievalPointers->Pair[0].Lcn = CurrentCluster - 2;
+ RetrievalPointers->StartingVcn = Vcn;
+ RetrievalPointers->ExtentCount = 0;
+ RetrievalPointers->Extents[0].Lcn.u.HighPart = 0;
+ RetrievalPointers->Extents[0].Lcn.u.LowPart = CurrentCluster - 2;
LastCluster = 0;
- while (CurrentCluster != 0xffffffff && RetrievalPointers->NumberOfPairs < MaxExtentCount)
+ while (CurrentCluster != 0xffffffff && RetrievalPointers->ExtentCount < MaxExtentCount)
{
LastCluster = CurrentCluster;
@@ -725,16 +717,17 @@ VfatGetRetrievalPointers(PVFAT_IRP_CONTEXT IrpContext)
if (LastCluster + 1 != CurrentCluster)
{
- RetrievalPointers->Pair[RetrievalPointers->NumberOfPairs].Vcn = Vcn.QuadPart;
- RetrievalPointers->NumberOfPairs++;
- if (RetrievalPointers->NumberOfPairs < MaxExtentCount)
+ RetrievalPointers->Extents[RetrievalPointers->ExtentCount].NextVcn = Vcn;
+ RetrievalPointers->ExtentCount++;
+ if (RetrievalPointers->ExtentCount < MaxExtentCount)
{
- RetrievalPointers->Pair[RetrievalPointers->NumberOfPairs].Lcn = CurrentCluster - 2;
+ RetrievalPointers->Extents[RetrievalPointers->ExtentCount].Lcn.u.HighPart = 0;
+ RetrievalPointers->Extents[RetrievalPointers->ExtentCount].Lcn.u.LowPart = CurrentCluster - 2;
}
}
}
- IrpContext->Irp->IoStatus.Information = sizeof(GET_RETRIEVAL_DESCRIPTOR) + sizeof(MAPPING_PAIR) * RetrievalPointers->NumberOfPairs;
+ IrpContext->Irp->IoStatus.Information = sizeof(RETRIEVAL_POINTERS_BUFFER) + (sizeof(RetrievalPointers->Extents[0]) * (RetrievalPointers->ExtentCount - 1));
Status = STATUS_SUCCESS;
ByeBye:
@@ -751,6 +744,7 @@ VfatMoveFile(PVFAT_IRP_CONTEXT IrpContext)
return STATUS_INVALID_DEVICE_REQUEST;
}
+#ifdef USE_ROS_CC_AND_FS
static NTSTATUS
VfatRosQueryLcnMapping(PVFAT_IRP_CONTEXT IrpContext)
{
@@ -758,7 +752,7 @@ VfatRosQueryLcnMapping(PVFAT_IRP_CONTEXT IrpContext)
PROS_QUERY_LCN_MAPPING LcnQuery;
PIO_STACK_LOCATION Stack;
- DPRINT("VfatGetRetrievalPointers(IrpContext %x)\n", IrpContext);
+ DPRINT("VfatRosQueryLcnMapping(IrpContext %x)\n", IrpContext);
DeviceExt = IrpContext->DeviceExt;
Stack = IrpContext->Stack;
@@ -772,6 +766,7 @@ VfatRosQueryLcnMapping(PVFAT_IRP_CONTEXT IrpContext)
IrpContext->Irp->IoStatus.Information = sizeof(ROS_QUERY_LCN_MAPPING);
return(STATUS_SUCCESS);
}
+#endif
NTSTATUS VfatFileSystemControl(PVFAT_IRP_CONTEXT IrpContext)
/*
@@ -803,9 +798,11 @@ NTSTATUS VfatFileSystemControl(PVFAT_IRP_CONTEXT IrpContext)
case FSCTL_MOVE_FILE:
Status = VfatMoveFile(IrpContext);
break;
+#ifdef USE_ROS_CC_AND_FS
case FSCTL_ROS_QUERY_LCN_MAPPING:
Status = VfatRosQueryLcnMapping(IrpContext);
break;
+#endif
default:
Status = STATUS_INVALID_DEVICE_REQUEST;
}
diff --git a/reactos/drivers/fs/vfat/iface.c b/reactos/drivers/fs/vfat/iface.c
index 0a3928bad9c..311d7b7076b 100644
--- a/reactos/drivers/fs/vfat/iface.c
+++ b/reactos/drivers/fs/vfat/iface.c
@@ -27,12 +27,7 @@
/* INCLUDES *****************************************************************/
-#include
-#include
-
#define NDEBUG
-#include
-
#include "vfat.h"
/* GLOBALS *****************************************************************/
@@ -45,7 +40,7 @@ NTSTATUS STDCALL
DriverEntry(PDRIVER_OBJECT DriverObject,
PUNICODE_STRING RegistryPath)
/*
- * FUNCTION: Called by the system to initalize the driver
+ * FUNCTION: Called by the system to initialize the driver
* ARGUMENTS:
* DriverObject = object describing this driver
* RegistryPath = path to our configuration entries
@@ -53,7 +48,7 @@ DriverEntry(PDRIVER_OBJECT DriverObject,
*/
{
PDEVICE_OBJECT DeviceObject;
- UNICODE_STRING DeviceName = ROS_STRING_INITIALIZER(L"\\Fat");
+ UNICODE_STRING DeviceName = RTL_CONSTANT_STRING(L"\\Fat");
NTSTATUS Status;
Status = IoCreateDevice(DriverObject,
@@ -65,7 +60,23 @@ DriverEntry(PDRIVER_OBJECT DriverObject,
&DeviceObject);
if (!NT_SUCCESS(Status))
{
- return (Status);
+ if (Status == STATUS_OBJECT_NAME_EXISTS ||
+ Status == STATUS_OBJECT_NAME_COLLISION)
+ {
+ /* Try an other name, if 'Fat' is already in use. 'Fat' is also used by fastfat.sys on W2K */
+ RtlInitUnicodeString(&DeviceName, L"\\RosFat");
+ Status = IoCreateDevice(DriverObject,
+ sizeof(VFAT_GLOBAL_DATA),
+ &DeviceName,
+ FILE_DEVICE_DISK_FILE_SYSTEM,
+ 0,
+ FALSE,
+ &DeviceObject);
+ if (!NT_SUCCESS(Status))
+ {
+ return (Status);
+ }
+ }
}
VfatGlobalData = DeviceObject->DeviceExtension;
RtlZeroMemory (VfatGlobalData, sizeof(VFAT_GLOBAL_DATA));
@@ -91,7 +102,18 @@ DriverEntry(PDRIVER_OBJECT DriverObject,
DriverObject->MajorFunction[IRP_MJ_FLUSH_BUFFERS] = VfatBuildRequest;
DriverObject->DriverUnload = NULL;
+
+ /* Cache manager */
+ VfatGlobalData->CacheMgrCallbacks.AcquireForLazyWrite = VfatAcquireForLazyWrite;
+ VfatGlobalData->CacheMgrCallbacks.ReleaseFromLazyWrite = VfatReleaseFromLazyWrite;
+ VfatGlobalData->CacheMgrCallbacks.AcquireForReadAhead = VfatAcquireForReadAhead;
+ VfatGlobalData->CacheMgrCallbacks.ReleaseFromReadAhead = VfatReleaseFromReadAhead;
+
+ /* Fast I/O */
+ VfatInitFastIoRoutines(&VfatGlobalData->FastIoDispatch);
+ DriverObject->FastIoDispatch = &VfatGlobalData->FastIoDispatch;
+ /* Private lists */
ExInitializeNPagedLookasideList(&VfatGlobalData->FcbLookasideList,
NULL, NULL, 0, sizeof(VFATFCB), TAG_FCB, 0);
ExInitializeNPagedLookasideList(&VfatGlobalData->CcbLookasideList,
diff --git a/reactos/drivers/fs/vfat/makefile b/reactos/drivers/fs/vfat/makefile
index bedba47eaf4..7ae216e9e62 100644
--- a/reactos/drivers/fs/vfat/makefile
+++ b/reactos/drivers/fs/vfat/makefile
@@ -19,6 +19,7 @@ TARGET_OBJECTS = \
direntry.o \
dirwr.o \
fat.o \
+ fastio.o \
fcb.o \
finfo.o \
iface.o \
@@ -38,9 +39,9 @@ TARGET_CLEAN = $(DEP_FILES) *.o *.sys *.sym
include $(PATH_TO_TOP)/config
ifeq ($(DBG), 1)
-TARGET_CFLAGS = -Wall -Werror -g
+TARGET_CFLAGS = -D__USE_W32API -Wall -Werror -g
else
-TARGET_CFLAGS = -Wall -Werror -O3 -fno-strict-aliasing
+TARGET_CFLAGS = -D__USE_W32API -Wall -Werror -O3 -fno-strict-aliasing
endif
include $(PATH_TO_TOP)/rules.mak
diff --git a/reactos/drivers/fs/vfat/misc.c b/reactos/drivers/fs/vfat/misc.c
index 7d464465f95..c3cc379f510 100644
--- a/reactos/drivers/fs/vfat/misc.c
+++ b/reactos/drivers/fs/vfat/misc.c
@@ -10,14 +10,44 @@
/* INCLUDES *****************************************************************/
-#include
-#include
-
#define NDEBUG
-#include
-
#include "vfat.h"
+/* GLOBALS ******************************************************************/
+
+const char* MajorFunctionNames[] =
+{
+ "IRP_MJ_CREATE",
+ "IRP_MJ_CREATE_NAMED_PIPE",
+ "IRP_MJ_CLOSE",
+ "IRP_MJ_READ",
+ "IRP_MJ_WRITE",
+ "IRP_MJ_QUERY_INFORMATION",
+ "IRP_MJ_SET_INFORMATION",
+ "IRP_MJ_QUERY_EA",
+ "IRP_MJ_SET_EA",
+ "IRP_MJ_FLUSH_BUFFERS",
+ "IRP_MJ_QUERY_VOLUME_INFORMATION",
+ "IRP_MJ_SET_VOLUME_INFORMATION",
+ "IRP_MJ_DIRECTORY_CONTROL",
+ "IRP_MJ_FILE_SYSTEM_CONTROL",
+ "IRP_MJ_DEVICE_CONTROL",
+ "IRP_MJ_INTERNAL_DEVICE_CONTROL",
+ "IRP_MJ_SHUTDOWN",
+ "IRP_MJ_LOCK_CONTROL",
+ "IRP_MJ_CLEANUP",
+ "IRP_MJ_CREATE_MAILSLOT",
+ "IRP_MJ_QUERY_SECURITY",
+ "IRP_MJ_SET_SECURITY",
+ "IRP_MJ_POWER",
+ "IRP_MJ_SYSTEM_CONTROL",
+ "IRP_MJ_DEVICE_CHANGE",
+ "IRP_MJ_QUERY_QUOTA",
+ "IRP_MJ_SET_QUOTA",
+ "IRP_MJ_PNP",
+ "IRP_MJ_MAXIMUM_FUNCTION"
+};
+
/* FUNCTIONS ****************************************************************/
static LONG QueueCount = 0;
@@ -62,10 +92,11 @@ Fail:;
return Status;
}
-NTSTATUS VfatDispatchRequest (
- IN PVFAT_IRP_CONTEXT IrpContext)
+NTSTATUS
+VfatDispatchRequest (IN PVFAT_IRP_CONTEXT IrpContext)
{
- DPRINT ("VfatDispatchRequest (IrpContext %x), MajorFunction %x\n", IrpContext, IrpContext->MajorFunction);
+ DPRINT ("VfatDispatchRequest (IrpContext %x), is called for %s\n", IrpContext,
+ IrpContext->MajorFunction >= IRP_MJ_MAXIMUM_FUNCTION ? "????" : MajorFunctionNames[IrpContext->MajorFunction]);
ASSERT(IrpContext);
@@ -223,7 +254,9 @@ PVOID VfatGetUserBuffer(IN PIRP Irp)
if (Irp->MdlAddress)
{
- return MmGetSystemAddressForMdl(Irp->MdlAddress);
+ /* This call may be in the paging path, so use maximum priority */
+ /* FIXME: call with normal priority in the non-paging path */
+ return MmGetSystemAddressForMdlSafe(Irp->MdlAddress, HighPagePriority);
}
else
{
diff --git a/reactos/drivers/fs/vfat/rw.c b/reactos/drivers/fs/vfat/rw.c
index bb86e51f576..6851681dbde 100644
--- a/reactos/drivers/fs/vfat/rw.c
+++ b/reactos/drivers/fs/vfat/rw.c
@@ -13,7 +13,6 @@
/* INCLUDES *****************************************************************/
#include
-#include
#include
#include
@@ -375,7 +374,7 @@ VfatWriteFileData(PVFAT_IRP_CONTEXT IrpContext,
ASSERT(WriteOffset.QuadPart + Length <= Fcb->RFCB.AllocationSize.QuadPart);
ASSERT(WriteOffset.u.LowPart % BytesPerSector == 0);
- ASSERT(Length % BytesPerSector == 0)
+ ASSERT(Length % BytesPerSector == 0);
// Is this a write of the volume ?
if (Fcb->Flags & FCB_IS_VOLUME)
@@ -681,10 +680,19 @@ VfatRead(PVFAT_IRP_CONTEXT IrpContext)
CHECKPOINT;
if (IrpContext->FileObject->PrivateCacheMap == NULL)
{
- ULONG CacheSize;
- CacheSize = max(IrpContext->DeviceExt->FatInfo.BytesPerCluster,
- 8 * PAGE_SIZE);
- CcRosInitializeFileCache(IrpContext->FileObject, CacheSize);
+#ifdef USE_ROS_CC_AND_FS
+ ULONG CacheSize;
+ CacheSize = max(IrpContext->DeviceExt->FatInfo.BytesPerCluster,
+ 8 * PAGE_SIZE);
+ CcRosInitializeFileCache(IrpContext->FileObject, CacheSize);
+#else
+ /* FIXME: Guard by SEH. */
+ CcInitializeCacheMap(IrpContext->FileObject,
+ (PCC_FILE_SIZES)(&Fcb->RFCB.AllocationSize),
+ FALSE,
+ &(VfatGlobalData->CacheMgrCallbacks),
+ Fcb);
+#endif
}
if (!CcCopyRead(IrpContext->FileObject, &ByteOffset, Length,
(BOOLEAN)(IrpContext->Flags & IRPCONTEXT_CANWAIT), Buffer,
@@ -705,7 +713,7 @@ VfatRead(PVFAT_IRP_CONTEXT IrpContext)
CHECKPOINT;
if (ByteOffset.QuadPart + Length > ROUND_UP(Fcb->RFCB.FileSize.QuadPart, BytesPerSector))
{
- Length = ROUND_UP(Fcb->RFCB.FileSize.QuadPart, BytesPerSector) - ByteOffset.QuadPart;
+ Length = (ULONG)(ROUND_UP(Fcb->RFCB.FileSize.QuadPart, BytesPerSector) - ByteOffset.QuadPart);
}
Status = VfatLockUserBuffer(IrpContext->Irp, Length, IoWriteAccess);
@@ -719,8 +727,8 @@ VfatRead(PVFAT_IRP_CONTEXT IrpContext)
if (Status == STATUS_VERIFY_REQUIRED)
{
DPRINT("VfatReadFile returned STATUS_VERIFY_REQUIRED\n");
- DeviceToVerify = IoGetDeviceToVerify((struct _ETHREAD*)KeGetCurrentThread());
- IoSetDeviceToVerify((struct _ETHREAD*)KeGetCurrentThread(), NULL);
+ DeviceToVerify = IoGetDeviceToVerify(PsGetCurrentThread());
+ IoSetDeviceToVerify(PsGetCurrentThread(), NULL);
Status = IoVerifyVolume (DeviceToVerify, FALSE);
if (NT_SUCCESS(Status))
@@ -973,14 +981,23 @@ NTSTATUS VfatWrite (PVFAT_IRP_CONTEXT IrpContext)
if (IrpContext->FileObject->PrivateCacheMap == NULL)
{
- ULONG CacheSize;
- CacheSize = max(IrpContext->DeviceExt->FatInfo.BytesPerCluster,
- 8 * PAGE_SIZE);
- CcRosInitializeFileCache(IrpContext->FileObject, CacheSize);
+#ifdef USE_ROS_CC_AND_FS
+ ULONG CacheSize;
+ CacheSize = max(IrpContext->DeviceExt->FatInfo.BytesPerCluster,
+ 8 * PAGE_SIZE);
+ CcRosInitializeFileCache(IrpContext->FileObject, CacheSize);
+#else
+ /* FIXME: Guard by SEH. */
+ CcInitializeCacheMap(IrpContext->FileObject,
+ (PCC_FILE_SIZES)(&Fcb->RFCB.AllocationSize),
+ FALSE,
+ &VfatGlobalData->CacheMgrCallbacks,
+ Fcb);
+#endif
}
if (ByteOffset.QuadPart > OldFileSize.QuadPart)
{
- CcZeroData(IrpContext->FileObject, &OldFileSize, &ByteOffset, TRUE);
+ CcZeroData(IrpContext->FileObject, &OldFileSize, &ByteOffset, TRUE);
}
if (CcCopyWrite(IrpContext->FileObject, &ByteOffset, Length,
1 /*IrpContext->Flags & IRPCONTEXT_CANWAIT*/, Buffer))
diff --git a/reactos/drivers/fs/vfat/shutdown.c b/reactos/drivers/fs/vfat/shutdown.c
index 28330e4547c..37e95be3da4 100644
--- a/reactos/drivers/fs/vfat/shutdown.c
+++ b/reactos/drivers/fs/vfat/shutdown.c
@@ -9,11 +9,7 @@
/* INCLUDES *****************************************************************/
-#include
-
#define NDEBUG
-#include
-
#include "vfat.h"
/* FUNCTIONS ****************************************************************/
diff --git a/reactos/drivers/fs/vfat/string.c b/reactos/drivers/fs/vfat/string.c
index 4df78172c9d..2d5e485c42c 100644
--- a/reactos/drivers/fs/vfat/string.c
+++ b/reactos/drivers/fs/vfat/string.c
@@ -11,12 +11,7 @@
/* INCLUDES *****************************************************************/
-#include
-#include
-
#define NDEBUG
-#include
-
#include "vfat.h"
/* FUNCTIONS ****************************************************************/
diff --git a/reactos/drivers/fs/vfat/vfat.h b/reactos/drivers/fs/vfat/vfat.h
index bfa0b22adf6..7f14a207daa 100644
--- a/reactos/drivers/fs/vfat/vfat.h
+++ b/reactos/drivers/fs/vfat/vfat.h
@@ -1,6 +1,29 @@
/* $Id$ */
#include
+#include
+#include
+#include
+
+#define USE_ROS_CC_AND_FS
+
+/* FIXME */
+#ifdef __USE_W32API
+NTSTATUS NTAPI RtlOemStringToUnicodeString(PUNICODE_STRING, CONST STRING *, BOOLEAN);
+NTSTATUS NTAPI RtlDowncaseUnicodeString(PUNICODE_STRING, PCUNICODE_STRING, BOOLEAN);
+NTSTATUS NTAPI RtlUnicodeStringToOemString(POEM_STRING, PCUNICODE_STRING, BOOLEAN);
+#undef DeleteFile /* FIXME */
+#endif
+
+#ifdef USE_ROS_CC_AND_FS
+NTSTATUS STDCALL CcRosInitializeFileCache(PFILE_OBJECT, ULONG);
+NTSTATUS STDCALL CcRosReleaseFileCache(PFILE_OBJECT);
+#define FSCTL_ROS_QUERY_LCN_MAPPING CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 63, METHOD_BUFFERED, FILE_ANY_ACCESS)
+typedef struct _ROS_QUERY_LCN_MAPPING { LARGE_INTEGER LcnDiskOffset; } ROS_QUERY_LCN_MAPPING, *PROS_QUERY_LCN_MAPPING;
+#endif
+
+#define KEBUGCHECK(a) DbgPrint("KeBugCheck at %s:%i\n",__FILE__,__LINE__), KeBugCheck(a)
+#define KEBUGCHECKEX(a,b,c,d,e) DbgPrint("KeBugCheckEx at %s:%i\n",__FILE__,__LINE__), KeBugCheckEx(a,b,c,d,e)
#define ROUND_UP(N, S) ((((N) + (S) - 1) / (S)) * (S))
#define ROUND_DOWN(N, S) ((N) - ((N) % (S)))
@@ -75,8 +98,10 @@ struct _FsInfoSector
typedef struct _BootSector BootSector;
-#define VFAT_CASE_LOWER_BASE 8 // base is lower case
-#define VFAT_CASE_LOWER_EXT 16 // extension is lower case
+#define VFAT_CASE_LOWER_BASE 8 // base is lower case
+#define VFAT_CASE_LOWER_EXT 16 // extension is lower case
+
+#define LONGNAME_MAX_LENGTH 256 // max length for a long filename
#define ENTRY_DELETED(DeviceExt, DirEntry) ((DeviceExt)->Flags & VCB_IS_FATX ? FATX_ENTRY_DELETED(&((DirEntry)->FatX)) : FAT_ENTRY_DELETED(&((DirEntry)->Fat)))
#define ENTRY_VOLUME(DeviceExt, DirEntry) ((DeviceExt)->Flags & VCB_IS_FATX ? FATX_ENTRY_VOLUME(&((DirEntry)->FatX)) : FAT_ENTRY_VOLUME(&((DirEntry)->Fat)))
@@ -179,7 +204,7 @@ typedef struct
ULONG NumberOfClusters;
ULONG FatType;
ULONG Sectors;
- BOOL FixedMedia;
+ BOOLEAN FixedMedia;
} FATINFO, *PFATINFO;
struct _VFATFCB;
@@ -244,6 +269,8 @@ typedef struct
NPAGED_LOOKASIDE_LIST FcbLookasideList;
NPAGED_LOOKASIDE_LIST CcbLookasideList;
NPAGED_LOOKASIDE_LIST IrpContextLookasideList;
+ FAST_IO_DISPATCH FastIoDispatch;
+ CACHE_MANAGER_CALLBACKS CacheMgrCallbacks;
} VFAT_GLOBAL_DATA, *PVFAT_GLOBAL_DATA;
extern PVFAT_GLOBAL_DATA VfatGlobalData;
@@ -284,7 +311,7 @@ typedef struct _VFATFCB
UNICODE_STRING PathNameU;
/* buffer for PathNameU */
- WCHAR PathNameBuffer[MAX_PATH];
+ PWCHAR PathNameBuffer;
/* buffer for ShortNameU */
WCHAR ShortNameBuffer[13];
@@ -356,17 +383,17 @@ typedef struct _VFATCCB
typedef struct __DOSTIME
{
- WORD Second:5;
- WORD Minute:6;
- WORD Hour:5;
+ USHORT Second:5;
+ USHORT Minute:6;
+ USHORT Hour:5;
}
DOSTIME, *PDOSTIME;
typedef struct __DOSDATE
{
- WORD Day:5;
- WORD Month:4;
- WORD Year:5;
+ USHORT Day:5;
+ USHORT Month:4;
+ USHORT Year:5;
}
DOSDATE, *PDOSDATE;
@@ -441,15 +468,15 @@ NTSTATUS VfatBlockDeviceIoControl (IN PDEVICE_OBJECT DeviceObject,
NTSTATUS VfatDirectoryControl (PVFAT_IRP_CONTEXT);
-BOOL FsdDosDateTimeToSystemTime (PDEVICE_EXTENSION DeviceExt,
- WORD wDosDate,
- WORD wDosTime,
- PLARGE_INTEGER SystemTime);
+BOOLEAN FsdDosDateTimeToSystemTime (PDEVICE_EXTENSION DeviceExt,
+ USHORT DosDate,
+ USHORT DosTime,
+ PLARGE_INTEGER SystemTime);
-BOOL FsdSystemTimeToDosDateTime (PDEVICE_EXTENSION DeviceExt,
- PLARGE_INTEGER SystemTime,
- WORD *pwDosDate,
- WORD *pwDosTime);
+BOOLEAN FsdSystemTimeToDosDateTime (PDEVICE_EXTENSION DeviceExt,
+ PLARGE_INTEGER SystemTime,
+ USHORT *pDosDate,
+ USHORT *pDosTime);
/* -------------------------------------------------------- create.c */
@@ -482,6 +509,25 @@ NTSTATUS VfatCloseFile(PDEVICE_EXTENSION DeviceExt,
NTSTATUS VfatCleanup (PVFAT_IRP_CONTEXT IrpContext);
+/* --------------------------------------------------------- fastio.c */
+
+VOID
+VfatInitFastIoRoutines(PFAST_IO_DISPATCH FastIoDispatch);
+
+BOOLEAN NTAPI
+VfatAcquireForLazyWrite(IN PVOID Context,
+ IN BOOLEAN Wait);
+
+VOID NTAPI
+VfatReleaseFromLazyWrite(IN PVOID Context);
+
+BOOLEAN NTAPI
+VfatAcquireForReadAhead(IN PVOID Context,
+ IN BOOLEAN Wait);
+
+VOID NTAPI
+VfatReleaseFromReadAhead(IN PVOID Context);
+
/* --------------------------------------------------------- fsctl.c */
NTSTATUS VfatFileSystemControl (PVFAT_IRP_CONTEXT IrpContext);
@@ -602,7 +648,7 @@ WriteCluster(PDEVICE_EXTENSION DeviceExt,
ULONG vfatDirEntryGetFirstCluster (PDEVICE_EXTENSION pDeviceExt,
PDIR_ENTRY pDirEntry);
-BOOL VfatIsDirectoryEmpty(PVFATFCB Fcb);
+BOOLEAN VfatIsDirectoryEmpty(PVFATFCB Fcb);
NTSTATUS FATGetNextDirEntry(PVOID * pContext,
PVOID * pPage,
@@ -641,9 +687,9 @@ PVFATFCB vfatMakeRootFCB (PDEVICE_EXTENSION pVCB);
PVFATFCB vfatOpenRootFCB (PDEVICE_EXTENSION pVCB);
-BOOL vfatFCBIsDirectory (PVFATFCB FCB);
+BOOLEAN vfatFCBIsDirectory (PVFATFCB FCB);
-BOOL vfatFCBIsRoot(PVFATFCB FCB);
+BOOLEAN vfatFCBIsRoot(PVFATFCB FCB);
NTSTATUS vfatAttachFCBToFileObject (PDEVICE_EXTENSION vcb,
PVFATFCB fcb,
diff --git a/reactos/drivers/fs/vfat/vfatfs.xml b/reactos/drivers/fs/vfat/vfatfs.xml
index 7d7549e78f3..3d1ce7ce470 100644
--- a/reactos/drivers/fs/vfat/vfatfs.xml
+++ b/reactos/drivers/fs/vfat/vfatfs.xml
@@ -1,5 +1,6 @@
.
+
ntoskrnl
hal
blockdev.c
@@ -11,6 +12,7 @@
dirwr.c
ea.c
fat.c
+ fastio.c
fcb.c
finfo.c
flush.c
diff --git a/reactos/drivers/fs/vfat/volume.c b/reactos/drivers/fs/vfat/volume.c
index 5f0b422abc8..3ed1ad22c63 100644
--- a/reactos/drivers/fs/vfat/volume.c
+++ b/reactos/drivers/fs/vfat/volume.c
@@ -11,12 +11,7 @@
/* INCLUDES *****************************************************************/
-#include
-#include
-
#define NDEBUG
-#include
-
#include "vfat.h"
/* FUNCTIONS ****************************************************************/
@@ -169,7 +164,7 @@ FsdSetFsLabelInformation(PDEVICE_OBJECT DeviceObject,
PDIR_ENTRY Entry;
PVFATFCB pRootFcb;
LARGE_INTEGER FileOffset;
- BOOL LabelFound = FALSE;
+ BOOLEAN LabelFound = FALSE;
DIR_ENTRY VolumeLabelDirEntry;
ULONG VolumeLabelDirIndex;
ULONG LabelLen;
@@ -233,7 +228,7 @@ FsdSetFsLabelInformation(PDEVICE_OBJECT DeviceObject,
/* Search existing volume entry on disk */
FileOffset.QuadPart = 0;
- if (CcMapData(pRootFcb->FileObject, &FileOffset, PAGE_SIZE, TRUE, &Context, (PVOID*)&Entry))
+ if (CcPinRead(pRootFcb->FileObject, &FileOffset, PAGE_SIZE, TRUE, &Context, (PVOID*)&Entry))
{
while (TRUE)
{
@@ -256,7 +251,7 @@ FsdSetFsLabelInformation(PDEVICE_OBJECT DeviceObject,
{
CcUnpinData(Context);
FileOffset.u.LowPart += PAGE_SIZE;
- if (!CcMapData(pRootFcb->FileObject, &FileOffset, PAGE_SIZE, TRUE, &Context, (PVOID*)&Entry))
+ if (!CcPinRead(pRootFcb->FileObject, &FileOffset, PAGE_SIZE, TRUE, &Context, (PVOID*)&Entry))
{
Context = NULL;
break;
@@ -277,7 +272,7 @@ FsdSetFsLabelInformation(PDEVICE_OBJECT DeviceObject,
{
FileOffset.u.HighPart = 0;
FileOffset.u.LowPart = VolumeLabelDirIndex * SizeDirEntry;
- CcMapData(pRootFcb->FileObject, &FileOffset, SizeDirEntry,
+ CcPinRead(pRootFcb->FileObject, &FileOffset, SizeDirEntry,
TRUE, &Context, (PVOID*)&Entry);
RtlCopyMemory(Entry, &VolumeLabelDirEntry, SizeDirEntry);
CcSetDirtyPinnedData(Context, NULL);
diff --git a/reactos/drivers/input/psaux/psaux.c b/reactos/drivers/input/psaux/psaux.c
index 4cb6369d797..44a4c319525 100644
--- a/reactos/drivers/input/psaux/psaux.c
+++ b/reactos/drivers/input/psaux/psaux.c
@@ -177,7 +177,6 @@ AllocatePointerDevice(PDRIVER_OBJECT DriverObject)
PDEVICE_OBJECT DeviceObject;
UNICODE_STRING DeviceName;
UNICODE_STRING SuffixString;
- UNICODE_STRING SymlinkName;
PDEVICE_EXTENSION DeviceExtension;
ULONG Suffix;
NTSTATUS Status;
@@ -213,25 +212,16 @@ AllocatePointerDevice(PDRIVER_OBJECT DriverObject)
}
ExFreePool(DeviceName.Buffer);
+ ExFreePool(SuffixString.Buffer);
/* Couldn't create device */
if (!NT_SUCCESS(Status))
{
- ExFreePool(SuffixString.Buffer);
return NULL;
}
DeviceObject->Flags = DeviceObject->Flags | DO_BUFFERED_IO;
- /* Create symlink */
- RtlInitUnicodeString(&SymlinkName, NULL);
- SymlinkName.MaximumLength = sizeof(L"\\??\\Mouse") + SUFFIX_MAXIMUM_SIZE + sizeof(UNICODE_NULL);
- SymlinkName.Buffer = ExAllocatePool(PagedPool, SymlinkName.MaximumLength);
- RtlAppendUnicodeToString(&SymlinkName, L"\\??\\Mouse");
- RtlAppendUnicodeToString(&DeviceName, SuffixString.Buffer);
- IoCreateSymbolicLink(&SymlinkName, &DeviceName);
- ExFreePool(SuffixString.Buffer);
-
DeviceExtension = DeviceObject->DeviceExtension;
KeInitializeDpc(&DeviceExtension->IsrDpc, (PKDEFERRED_ROUTINE)PS2MouseIsrDpc, DeviceObject);
diff --git a/reactos/drivers/input/sermouse/sermouse.c b/reactos/drivers/input/sermouse/sermouse.c
index 23ed60e7cf4..b2ad310a84d 100644
--- a/reactos/drivers/input/sermouse/sermouse.c
+++ b/reactos/drivers/input/sermouse/sermouse.c
@@ -26,8 +26,6 @@
#define SERMOUSE_COM1_SUPPORT
/* Check for mouse on COM2? */
/* #define SERMOUSE_COM2_SUPPORT */
-/* Create \??\Mouse* symlink for device? */
-#define SERMOUSE_MOUSESYMLINK_SUPPORT
/*
* Definitions
@@ -511,7 +509,6 @@ AllocatePointerDevice(PDRIVER_OBJECT DriverObject)
PDEVICE_OBJECT DeviceObject;
UNICODE_STRING DeviceName;
UNICODE_STRING SuffixString;
- UNICODE_STRING SymlinkName;
PDEVICE_EXTENSION DeviceExtension;
ULONG Suffix;
NTSTATUS Status;
@@ -541,28 +538,16 @@ AllocatePointerDevice(PDRIVER_OBJECT DriverObject)
}
ExFreePool(DeviceName.Buffer);
+ ExFreePool(SuffixString.Buffer);
/* Couldn't create device */
if (!NT_SUCCESS(Status))
{
- ExFreePool(SuffixString.Buffer);
return NULL;
}
DeviceObject->Flags = DeviceObject->Flags | DO_BUFFERED_IO;
-#ifdef SERMOUSE_MOUSESYMLINK_SUPPORT
- /* Create symlink */
- /* FIXME: Why? FiN 20/08/2003 */
- RtlInitUnicodeString(&SymlinkName, NULL);
- SymlinkName.MaximumLength = sizeof(L"\\??\\Mouse") + SUFFIX_MAXIMUM_SIZE + sizeof(UNICODE_NULL);
- SymlinkName.Buffer = ExAllocatePool(PagedPool, SymlinkName.MaximumLength);
- RtlAppendUnicodeToString(&SymlinkName, L"\\??\\Mouse");
- RtlAppendUnicodeToString(&DeviceName, SuffixString.Buffer);
- IoCreateSymbolicLink(&SymlinkName, &DeviceName);
-#endif
- ExFreePool(SuffixString.Buffer);
-
DeviceExtension = DeviceObject->DeviceExtension;
KeInitializeDpc(&DeviceExtension->IsrDpc, (PKDEFERRED_ROUTINE)SerialMouseIsrDpc, DeviceObject);
diff --git a/reactos/drivers/lib/ip/network/address.c b/reactos/drivers/lib/ip/network/address.c
index 38194a34c0b..1631efdda81 100644
--- a/reactos/drivers/lib/ip/network/address.c
+++ b/reactos/drivers/lib/ip/network/address.c
@@ -86,6 +86,7 @@ UINT AddrCountPrefixBits( PIP_ADDRESS Netmask ) {
VOID AddrWidenAddress( PIP_ADDRESS Network, PIP_ADDRESS Source,
PIP_ADDRESS Netmask ) {
if( Netmask->Type == IP_ADDRESS_V4 ) {
+ Network->Type = Netmask->Type;
Network->Address.IPv4Address =
Source->Address.IPv4Address & Netmask->Address.IPv4Address;
} else {
@@ -220,8 +221,10 @@ BOOLEAN AddrIsEqual(
PIP_ADDRESS Address1,
PIP_ADDRESS Address2)
{
- if (Address1->Type != Address2->Type)
+ if (Address1->Type != Address2->Type) {
+ DbgPrint("AddrIsEqual: Unequal Address Types\n");
return FALSE;
+ }
switch (Address1->Type) {
case IP_ADDRESS_V4:
@@ -231,6 +234,10 @@ BOOLEAN AddrIsEqual(
return (RtlCompareMemory(&Address1->Address, &Address2->Address,
sizeof(IPv6_RAW_ADDRESS)) == sizeof(IPv6_RAW_ADDRESS));
break;
+
+ default:
+ DbgPrint("AddrIsEqual: Bad address type\n");
+ break;
}
return FALSE;
diff --git a/reactos/drivers/lib/ip/network/interface.c b/reactos/drivers/lib/ip/network/interface.c
index 664d86f0e4d..8094c43050f 100644
--- a/reactos/drivers/lib/ip/network/interface.c
+++ b/reactos/drivers/lib/ip/network/interface.c
@@ -24,9 +24,7 @@ NTSTATUS GetInterfaceIPv4Address( PIP_INTERFACE Interface,
break;
case ADE_BROADCAST:
- *Address =
- Interface->Unicast.Address.IPv4Address |
- ~Interface->Netmask.Address.IPv4Address;
+ *Address = Interface->Broadcast.Address.IPv4Address;
break;
case ADE_POINTOPOINT:
diff --git a/reactos/drivers/lib/ip/network/ip.c b/reactos/drivers/lib/ip/network/ip.c
index d2ccd11da3a..4b6871efc0c 100644
--- a/reactos/drivers/lib/ip/network/ip.c
+++ b/reactos/drivers/lib/ip/network/ip.c
@@ -152,6 +152,10 @@ VOID IPDispatchProtocol(
/* Call the appropriate protocol handler */
(*ProtocolTable[Protocol])(Interface, IPPacket);
+ /* Special case for ICMP -- ICMP can be caught by a SOCK_RAW but also
+ * must be handled here. */
+ if( Protocol == IPPROTO_ICMP )
+ ICMPReceive( Interface, IPPacket );
}
@@ -401,9 +405,6 @@ NTSTATUS IPStartup(PUNICODE_STRING RegistryPath)
for (i = 0; i < IP_PROTOCOL_TABLE_SIZE; i++)
IPRegisterProtocol(i, DefaultProtocolHandler);
- /* Register network level protocol receive handlers */
- IPRegisterProtocol(IPPROTO_ICMP, ICMPReceive);
-
/* Initialize NTE list and protecting lock */
InitializeListHead(&NetTableListHead);
TcpipInitializeSpinLock(&NetTableListLock);
diff --git a/reactos/drivers/lib/ip/network/loopback.c b/reactos/drivers/lib/ip/network/loopback.c
index 6584cf9c2b9..e2be1fa4383 100644
--- a/reactos/drivers/lib/ip/network/loopback.c
+++ b/reactos/drivers/lib/ip/network/loopback.c
@@ -11,6 +11,107 @@
#include "precomp.h"
PIP_INTERFACE Loopback = NULL;
+typedef struct _LAN_WQ_ITEM {
+ LIST_ENTRY ListEntry;
+ PNDIS_PACKET Packet;
+ PLAN_ADAPTER Adapter;
+ UINT BytesTransferred;
+} LAN_WQ_ITEM, *PLAN_WQ_ITEM;
+
+/* Work around being called back into afd at Dpc level */
+KSPIN_LOCK LoopWorkLock;
+LIST_ENTRY LoopWorkList;
+WORK_QUEUE_ITEM LoopWorkItem;
+BOOLEAN LoopReceiveWorkerBusy = FALSE;
+
+VOID STDCALL LoopReceiveWorker( PVOID Context ) {
+ PLIST_ENTRY ListEntry;
+ PLAN_WQ_ITEM WorkItem;
+ PNDIS_PACKET Packet;
+ PLAN_ADAPTER Adapter;
+ UINT BytesTransferred;
+ PNDIS_BUFFER NdisBuffer;
+ IP_PACKET IPPacket;
+
+ TI_DbgPrint(DEBUG_DATALINK, ("Called.\n"));
+
+ while( (ListEntry =
+ ExInterlockedRemoveHeadList( &LoopWorkList, &LoopWorkLock )) ) {
+ WorkItem = CONTAINING_RECORD(ListEntry, LAN_WQ_ITEM, ListEntry);
+
+ TI_DbgPrint(DEBUG_DATALINK, ("WorkItem: %x\n", WorkItem));
+
+ Packet = WorkItem->Packet;
+ Adapter = WorkItem->Adapter;
+ BytesTransferred = WorkItem->BytesTransferred;
+
+ ExFreePool( WorkItem );
+
+ IPPacket.NdisPacket = Packet;
+
+ TI_DbgPrint(DEBUG_DATALINK, ("Packet %x Adapter %x Trans %x\n",
+ Packet, Adapter, BytesTransferred));
+
+ NdisGetFirstBufferFromPacket(Packet,
+ &NdisBuffer,
+ &IPPacket.Header,
+ &IPPacket.ContigSize,
+ &IPPacket.TotalSize);
+
+ IPPacket.ContigSize = IPPacket.TotalSize = BytesTransferred;
+ /* Determine which upper layer protocol that should receive
+ this packet and pass it to the correct receive handler */
+
+ TI_DbgPrint(MID_TRACE,
+ ("ContigSize: %d, TotalSize: %d, BytesTransferred: %d\n",
+ IPPacket.ContigSize, IPPacket.TotalSize,
+ BytesTransferred));
+
+ IPPacket.Position = 0;
+
+ IPReceive(Loopback, &IPPacket);
+
+ FreeNdisPacket( Packet );
+ }
+ TI_DbgPrint(DEBUG_DATALINK, ("Leaving\n"));
+ LoopReceiveWorkerBusy = FALSE;
+}
+
+VOID LoopSubmitReceiveWork(
+ NDIS_HANDLE BindingContext,
+ PNDIS_PACKET Packet,
+ NDIS_STATUS Status,
+ UINT BytesTransferred) {
+ PLAN_WQ_ITEM WQItem;
+ PLAN_ADAPTER Adapter = (PLAN_ADAPTER)BindingContext;
+ KIRQL OldIrql;
+
+ TcpipAcquireSpinLock( &LoopWorkLock, &OldIrql );
+
+ WQItem = ExAllocatePool( NonPagedPool, sizeof(LAN_WQ_ITEM) );
+ if( !WQItem ) {
+ TcpipReleaseSpinLock( &LoopWorkLock, OldIrql );
+ return;
+ }
+
+ WQItem->Packet = Packet;
+ WQItem->Adapter = Adapter;
+ WQItem->BytesTransferred = BytesTransferred;
+ InsertTailList( &LoopWorkList, &WQItem->ListEntry );
+
+ TI_DbgPrint(DEBUG_DATALINK, ("Packet %x Adapter %x BytesTrans %x\n",
+ Packet, Adapter, BytesTransferred));
+
+ if( !LoopReceiveWorkerBusy ) {
+ LoopReceiveWorkerBusy = TRUE;
+ ExQueueWorkItem( &LoopWorkItem, CriticalWorkQueue );
+ TI_DbgPrint(DEBUG_DATALINK,
+ ("Work item inserted %x %x\n", &LoopWorkItem, WQItem));
+ } else {
+ DbgPrint("LOOP WORKER BUSY %x %x\n", &LoopWorkItem, WQItem);
+ }
+ TcpipReleaseSpinLock( &LoopWorkLock, OldIrql );
+}
VOID LoopTransmit(
PVOID Context,
@@ -28,30 +129,31 @@ VOID LoopTransmit(
* Type = LAN protocol type (unused)
*/
{
- IP_PACKET IPPacket;
+ PCHAR PacketBuffer;
+ UINT PacketLength;
+ PNDIS_PACKET XmitPacket;
+ NDIS_STATUS NdisStatus;
- ASSERT_KM_POINTER(NdisPacket);
- ASSERT_KM_POINTER(PC(NdisPacket));
- ASSERT_KM_POINTER(PC(NdisPacket)->DLComplete);
+ ASSERT_KM_POINTER(NdisPacket);
+ ASSERT_KM_POINTER(PC(NdisPacket));
+ ASSERT_KM_POINTER(PC(NdisPacket)->DLComplete);
+
+ TI_DbgPrint(MAX_TRACE, ("Called (NdisPacket = %x)\n", NdisPacket));
- TI_DbgPrint(MAX_TRACE, ("Called (NdisPacket = %x)\n", NdisPacket));
+ GetDataPtr( NdisPacket, MaxLLHeaderSize, &PacketBuffer, &PacketLength );
- IPPacket.NdisPacket = NdisPacket;
- IPPacket.HeaderSize = 0;
- GetDataPtr( NdisPacket, 0, (PCHAR *)&IPPacket.Header, &IPPacket.TotalSize );
- IPPacket.Header += Offset;
- IPPacket.ContigSize = IPPacket.TotalSize;
- IPPacket.Position = Offset;
+ NdisStatus = AllocatePacketWithBuffer
+ ( &XmitPacket, PacketBuffer, PacketLength );
- TI_DbgPrint(MAX_TRACE,
- ("Doing receive (complete: %x, context %x, packet %x)\n",
- PC(NdisPacket)->DLComplete, Context, NdisPacket));
- IPReceive(Context, &IPPacket);
- TI_DbgPrint(MAX_TRACE,
- ("Finished receive (complete: %x, context %x, packet %x)\n",
- PC(NdisPacket)->DLComplete, Context, NdisPacket));
- PC(NdisPacket)->DLComplete(PC(NdisPacket)->Context, NdisPacket, NDIS_STATUS_SUCCESS);
- TI_DbgPrint(MAX_TRACE, ("Done\n"));
+ if( NT_SUCCESS(NdisStatus) ) {
+ LoopSubmitReceiveWork
+ ( NULL, XmitPacket, STATUS_SUCCESS, PacketLength );
+ }
+
+ (PC(NdisPacket)->DLComplete)
+ ( PC(NdisPacket)->Context, NdisPacket, STATUS_SUCCESS );
+
+ TI_DbgPrint(MAX_TRACE, ("Done\n"));
}
NDIS_STATUS LoopRegisterAdapter(
@@ -73,6 +175,9 @@ NDIS_STATUS LoopRegisterAdapter(
TI_DbgPrint(MID_TRACE, ("Called.\n"));
+ InitializeListHead( &LoopWorkList );
+ ExInitializeWorkItem( &LoopWorkItem, LoopReceiveWorker, NULL );
+
/* Bind the adapter to network (IP) layer */
BindInfo.Context = NULL;
BindInfo.HeaderSize = 0;
diff --git a/reactos/drivers/lib/ip/network/neighbor.c b/reactos/drivers/lib/ip/network/neighbor.c
index 49f650ff276..99e9bbf6e55 100644
--- a/reactos/drivers/lib/ip/network/neighbor.c
+++ b/reactos/drivers/lib/ip/network/neighbor.c
@@ -52,19 +52,19 @@ VOID NBSendPackets( PNEIGHBOR_CACHE_ENTRY NCE ) {
}
}
+/* Must be called with table lock acquired */
VOID NBFlushPacketQueue( PNEIGHBOR_CACHE_ENTRY NCE,
BOOL CallComplete,
NTSTATUS ErrorCode ) {
PLIST_ENTRY PacketEntry;
PNEIGHBOR_PACKET Packet;
- PacketEntry = ExInterlockedRemoveHeadList(&NCE->PacketQueue,
- &NCE->Table->Lock);
- while( PacketEntry != NULL ) {
+ while( !IsListEmpty(&NCE->PacketQueue) ) {
+ PacketEntry = RemoveHeadList(&NCE->PacketQueue);
Packet = CONTAINING_RECORD
( PacketEntry, NEIGHBOR_PACKET, Next );
- ASSERT_KM_POINTER(Packet);
+ ASSERT_KM_POINTER(Packet);
TI_DbgPrint
(MID_TRACE,
@@ -72,16 +72,14 @@ VOID NBFlushPacketQueue( PNEIGHBOR_CACHE_ENTRY NCE,
PacketEntry, Packet->Packet));
if( CallComplete )
- {
- ASSERT_KM_POINTER(Packet->Complete);
+ {
+ ASSERT_KM_POINTER(Packet->Complete);
Packet->Complete( Packet->Context,
Packet->Packet,
NDIS_STATUS_REQUEST_ABORTED );
- }
+ }
PoolFreeBuffer( Packet );
- PacketEntry = ExInterlockedRemoveHeadList(&NCE->PacketQueue,
- &NCE->Table->Lock);
}
}
@@ -407,10 +405,19 @@ PNEIGHBOR_CACHE_ENTRY NBFindOrCreateNeighbor(
NCE = NBLocateNeighbor(Address);
if (NCE == NULL)
{
- NCE = NBAddNeighbor(Interface, Address, NULL,
- Interface->AddressLength, NUD_INCOMPLETE);
- NCE->EventTimer = 1;
- NCE->EventCount = 0;
+ TI_DbgPrint(MID_TRACE,("BCAST: %s\n", A2S(&Interface->Broadcast)));
+ if( AddrIsEqual(Address, &Interface->Broadcast) ) {
+ TI_DbgPrint(MID_TRACE,("Packet targeted at broadcast addr\n"));
+ NCE = NBAddNeighbor(Interface, Address, NULL,
+ Interface->AddressLength, NUD_CONNECTED);
+ NCE->EventTimer = 0;
+ NCE->EventCount = 0;
+ } else {
+ NCE = NBAddNeighbor(Interface, Address, NULL,
+ Interface->AddressLength, NUD_INCOMPLETE);
+ NCE->EventTimer = 1;
+ NCE->EventCount = 0;
+ }
}
return NCE;
diff --git a/reactos/drivers/lib/ip/network/ports.c b/reactos/drivers/lib/ip/network/ports.c
index 6f0ab37468d..62be2ef11a3 100644
--- a/reactos/drivers/lib/ip/network/ports.c
+++ b/reactos/drivers/lib/ip/network/ports.c
@@ -20,6 +20,8 @@ VOID PortsStartup( PPORT_SET PortSet,
RtlInitializeBitMap( &PortSet->ProtoBitmap,
PortSet->ProtoBitBuffer,
PortSet->PortsToOversee );
+ RtlClearBits( &PortSet->ProtoBitmap,
+ PortSet->StartingPort, PortsToManage );
ExInitializeFastMutex( &PortSet->Mutex );
}
diff --git a/reactos/drivers/lib/ip/transport/datagram/datagram.c b/reactos/drivers/lib/ip/transport/datagram/datagram.c
index 9d50ab38a30..a10c20816ee 100644
--- a/reactos/drivers/lib/ip/transport/datagram/datagram.c
+++ b/reactos/drivers/lib/ip/transport/datagram/datagram.c
@@ -59,7 +59,7 @@ VOID DGDeliverData(
if (!IsListEmpty(&AddrFile->ReceiveQueue))
{
PLIST_ENTRY CurrentEntry;
- PDATAGRAM_RECEIVE_REQUEST Current;
+ PDATAGRAM_RECEIVE_REQUEST Current = NULL;
BOOLEAN Found;
PTA_IP_ADDRESS RTAIPAddress;
@@ -86,6 +86,10 @@ VOID DGDeliverData(
if (Found)
{
TI_DbgPrint(MAX_TRACE, ("Suitable receive request found.\n"));
+
+ TI_DbgPrint(MAX_TRACE,
+ ("Target Buffer: %x, Source Buffer: %x, Size %d\n",
+ Current->Buffer, DataBuffer, DataSize));
/* Copy the data into buffer provided by the user */
RtlCopyMemory( Current->Buffer,
diff --git a/reactos/drivers/lib/ip/transport/rawip/rawip.c b/reactos/drivers/lib/ip/transport/rawip/rawip.c
index e75d78a8325..181cc04e550 100644
--- a/reactos/drivers/lib/ip/transport/rawip/rawip.c
+++ b/reactos/drivers/lib/ip/transport/rawip/rawip.c
@@ -2,7 +2,7 @@
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS TCP/IP protocol driver
* FILE: transport/rawip/rawip.c
- * PURPOSE: Raw IP routines
+ * PURPOSE: User Datagram Protocol routines
* PROGRAMMERS: Casper S. Hornstrup (chorns@users.sourceforge.net)
* REVISIONS:
* CSH 01/08-2000 Created
@@ -10,71 +10,155 @@
#include "precomp.h"
-
-BOOLEAN RawIPInitialized = FALSE;
-
-
-NTSTATUS BuildRawIPPacket(
- PIP_PACKET Packet,
- UINT DataLength,
+NTSTATUS AddGenericHeaderIPv4(
+ PIP_ADDRESS RemoteAddress,
+ USHORT RemotePort,
PIP_ADDRESS LocalAddress,
- USHORT LocalPort )
+ USHORT LocalPort,
+ PIP_PACKET IPPacket,
+ UINT DataLength,
+ UINT Protocol,
+ UINT ExtraLength,
+ PVOID *NextHeader )
/*
- * FUNCTION: Builds an UDP packet
+ * FUNCTION: Adds an IPv4 and RawIp header to an IP packet
+ * ARGUMENTS:
+ * SendRequest = Pointer to send request
+ * LocalAddress = Pointer to our local address
+ * LocalPort = The port we send this datagram from
+ * IPPacket = Pointer to IP packet
+ * RETURNS:
+ * Status of operation
+ */
+{
+ PIPv4_HEADER IPHeader;
+ ULONG BufferSize;
+
+ TI_DbgPrint(MID_TRACE, ("Packet: %x NdisPacket %x\n",
+ IPPacket, IPPacket->NdisPacket));
+
+ BufferSize = MaxLLHeaderSize + sizeof(IPv4_HEADER) + ExtraLength;
+
+ GetDataPtr( IPPacket->NdisPacket,
+ MaxLLHeaderSize,
+ (PCHAR *)&IPPacket->Header,
+ &IPPacket->ContigSize );
+
+ IPPacket->HeaderSize = 20;
+
+ TI_DbgPrint(MAX_TRACE, ("Allocated %d bytes for headers at 0x%X.\n",
+ BufferSize, IPPacket->Header));
+ TI_DbgPrint(MAX_TRACE, ("Packet total length %d\n", IPPacket->TotalSize));
+
+ /* Build IPv4 header */
+ IPHeader = (PIPv4_HEADER)IPPacket->Header;
+ /* Version = 4, Length = 5 DWORDs */
+ IPHeader->VerIHL = 0x45;
+ /* Normal Type-of-Service */
+ IPHeader->Tos = 0;
+ /* Length of header and data */
+ IPHeader->TotalLength = WH2N((USHORT)IPPacket->TotalSize);
+ /* Identification */
+ IPHeader->Id = 0;
+ /* One fragment at offset 0 */
+ IPHeader->FlagsFragOfs = 0;
+ /* Time-to-Live is 128 */
+ IPHeader->Ttl = 128;
+ /* User Datagram Protocol */
+ IPHeader->Protocol = Protocol;
+ /* Checksum is 0 (for later calculation of this) */
+ IPHeader->Checksum = 0;
+ /* Source address */
+ IPHeader->SrcAddr = LocalAddress->Address.IPv4Address;
+ /* Destination address. FIXME: IPv4 only */
+ IPHeader->DstAddr = RemoteAddress->Address.IPv4Address;
+
+ /* Build RawIp header */
+ *NextHeader = (((PCHAR)IPHeader) + sizeof(IPv4_HEADER));
+ IPPacket->Data = ((PCHAR)*NextHeader) + ExtraLength;
+
+ return STATUS_SUCCESS;
+}
+
+
+NTSTATUS BuildRawIpPacket(
+ PIP_PACKET Packet,
+ PIP_ADDRESS RemoteAddress,
+ USHORT RemotePort,
+ PIP_ADDRESS LocalAddress,
+ USHORT LocalPort,
+ PCHAR DataBuffer,
+ UINT DataLen )
+/*
+ * FUNCTION: Builds an RawIp packet
* ARGUMENTS:
* Context = Pointer to context information (DATAGRAM_SEND_REQUEST)
- * LocalAddress = Pointer to our local address (NULL)
- * LocalPort = The port we send this datagram from (0)
+ * LocalAddress = Pointer to our local address
+ * LocalPort = The port we send this datagram from
* IPPacket = Address of pointer to IP packet
* RETURNS:
* Status of operation
*/
{
- PVOID Header;
- NDIS_STATUS NdisStatus;
- PNDIS_BUFFER HeaderBuffer;
- PNDIS_PACKET NdisPacket = Packet->NdisPacket;
- /* Will be zeroed in packet by IPInitializePacket */
-
+ NTSTATUS Status;
+ PCHAR Payload;
+
+ TI_DbgPrint(MAX_TRACE, ("Called.\n"));
+
+ /* FIXME: Assumes IPv4 */
+ IPInitializePacket(Packet, IP_ADDRESS_V4);
+ if (!Packet)
+ return STATUS_INSUFFICIENT_RESOURCES;
+
+ Packet->TotalSize = sizeof(IPv4_HEADER) + DataLen;
+
/* Prepare packet */
- IPInitializePacket(Packet,IP_ADDRESS_V4);
- Packet->Flags = IP_PACKET_FLAG_RAW; /* Don't touch IP header */
- Packet->TotalSize = DataLength;
- Packet->NdisPacket = NdisPacket;
+ Status = AllocatePacketWithBuffer( &Packet->NdisPacket,
+ NULL,
+ Packet->TotalSize + MaxLLHeaderSize );
+
+ if( !NT_SUCCESS(Status) ) return Status;
- if (MaxLLHeaderSize != 0) {
- Header = ExAllocatePool(NonPagedPool, MaxLLHeaderSize);
- if (!Header) {
- TI_DbgPrint(MIN_TRACE, ("Cannot allocate memory for packet headers.\n"));
- return STATUS_INSUFFICIENT_RESOURCES;
- }
+ TI_DbgPrint(MID_TRACE, ("Allocated packet: %x\n", Packet->NdisPacket));
+ TI_DbgPrint(MID_TRACE, ("Local Addr : %s\n", A2S(LocalAddress)));
+ TI_DbgPrint(MID_TRACE, ("Remote Addr: %s\n", A2S(RemoteAddress)));
+
+ switch (RemoteAddress->Type) {
+ case IP_ADDRESS_V4:
+ Status = AddGenericHeaderIPv4
+ (RemoteAddress, RemotePort,
+ LocalAddress, LocalPort, Packet, DataLen,
+ IPPROTO_ICMP, /* XXX Figure out a better way to do this */
+ 0, (PVOID *)&Payload );
+ break;
+ case IP_ADDRESS_V6:
+ /* FIXME: Support IPv6 */
+ Status = STATUS_UNSUCCESSFUL;
+ TI_DbgPrint(MIN_TRACE, ("IPv6 RawIp datagrams are not supported.\n"));
+ break;
- TI_DbgPrint(MAX_TRACE, ("Allocated %d bytes for headers at 0x%X.\n",
- MaxLLHeaderSize, Header));
-
- /* Allocate NDIS buffer for maximum link level header */
- NdisAllocateBuffer(&NdisStatus,
- &HeaderBuffer,
- GlobalBufferPool,
- Header,
- MaxLLHeaderSize);
-
- if (NdisStatus != NDIS_STATUS_SUCCESS) {
- TI_DbgPrint(MIN_TRACE, ("Cannot allocate NDIS buffer for packet headers. NdisStatus = (0x%X)\n", NdisStatus));
- ExFreePool(Header);
- return STATUS_INSUFFICIENT_RESOURCES;
- }
-
- /* Chain header at front of packet */
- NdisChainBufferAtFront(Packet->NdisPacket, HeaderBuffer);
+ default:
+ Status = STATUS_UNSUCCESSFUL;
+ TI_DbgPrint(MIN_TRACE, ("Bad Address Type %d\n", RemoteAddress->Type));
+ break;
}
-
+
+ TI_DbgPrint(MID_TRACE, ("Copying data (hdr %x data %x (%d))\n",
+ Packet->Header, Packet->Data,
+ (PCHAR)Packet->Data - (PCHAR)Packet->Header));
+
+ RtlCopyMemory( Packet->Data, DataBuffer, DataLen );
+
+ TI_DbgPrint(MID_TRACE, ("Displaying packet\n"));
+
DISPLAY_IP_PACKET(Packet);
-
+
+ TI_DbgPrint(MID_TRACE, ("Leaving\n"));
+
return STATUS_SUCCESS;
}
-VOID RawIPSendComplete
+VOID RawIpSendPacketComplete
( PVOID Context, PNDIS_PACKET Packet, NDIS_STATUS Status ) {
FreeNdisPacket( Packet );
}
@@ -83,10 +167,10 @@ NTSTATUS RawIPSendDatagram(
PADDRESS_FILE AddrFile,
PTDI_CONNECTION_INFORMATION ConnInfo,
PCHAR BufferData,
- ULONG BufferLen,
- PULONG DataUsed )
+ ULONG DataSize,
+ PULONG DataUsed )
/*
- * FUNCTION: Sends a raw IP datagram to a remote address
+ * FUNCTION: Sends an RawIp datagram to a remote address
* ARGUMENTS:
* Request = Pointer to TDI request
* ConnInfo = Pointer to connection information
@@ -96,134 +180,258 @@ NTSTATUS RawIPSendDatagram(
* Status of operation
*/
{
- NDIS_STATUS Status;
IP_PACKET Packet;
- PNEIGHBOR_CACHE_ENTRY NCE;
+ PTA_IP_ADDRESS RemoteAddressTa = (PTA_IP_ADDRESS)ConnInfo->RemoteAddress;
IP_ADDRESS RemoteAddress;
+ USHORT RemotePort;
+ NTSTATUS Status;
+ PNEIGHBOR_CACHE_ENTRY NCE;
- Status = AllocatePacketWithBuffer( &Packet.NdisPacket,
- BufferData,
- BufferLen );
-
- TI_DbgPrint(MID_TRACE,("Packet.NdisPacket %x\n", Packet.NdisPacket));
+ TI_DbgPrint(MID_TRACE,("Sending Datagram(%x %x %x %d)\n",
+ AddrFile, ConnInfo, BufferData, DataSize));
+ TI_DbgPrint(MID_TRACE,("RemoteAddressTa: %x\n", RemoteAddressTa));
- *DataUsed = BufferLen;
-
- if( Status == NDIS_STATUS_SUCCESS )
- Status = BuildRawIPPacket( &Packet,
- BufferLen,
- &AddrFile->Address,
- AddrFile->Port );
-
- if( Status == NDIS_STATUS_SUCCESS ) {
+ switch( RemoteAddressTa->Address[0].AddressType ) {
+ case TDI_ADDRESS_TYPE_IP:
RemoteAddress.Type = IP_ADDRESS_V4;
- RtlCopyMemory( &RemoteAddress.Address.IPv4Address,
- BufferData + FIELD_OFFSET(IPv4_HEADER, DstAddr),
- sizeof(IPv4_RAW_ADDRESS) );
+ RemoteAddress.Address.IPv4Address =
+ RemoteAddressTa->Address[0].Address[0].in_addr;
+ RemotePort = RemoteAddressTa->Address[0].Address[0].sin_port;
+ break;
- if(!(NCE = RouteGetRouteToDestination( &RemoteAddress ))) {
- FreeNdisPacket( Packet.NdisPacket );
- return STATUS_NO_SUCH_DEVICE;
- }
-
- IPSendDatagram( &Packet, NCE, RawIPSendComplete, NULL );
- } else
- FreeNdisPacket( Packet.NdisPacket );
+ default:
+ return STATUS_UNSUCCESSFUL;
+ }
+
+ Status = BuildRawIpPacket( &Packet,
+ &RemoteAddress,
+ RemotePort,
+ &AddrFile->Address,
+ AddrFile->Port,
+ BufferData,
+ DataSize );
+
+ if( !NT_SUCCESS(Status) )
+ return Status;
+ TI_DbgPrint(MID_TRACE,("About to get route to destination\n"));
+
+ if(!(NCE = RouteGetRouteToDestination( &RemoteAddress )))
+ return STATUS_UNSUCCESSFUL;
+
+ TI_DbgPrint(MID_TRACE,("About to send datagram\n"));
+
+ IPSendDatagram( &Packet, NCE, RawIpSendPacketComplete, NULL );
+
+ TI_DbgPrint(MID_TRACE,("Leaving\n"));
+
+ return STATUS_SUCCESS;
+}
+
+VOID RawIpReceiveComplete(PVOID Context, NTSTATUS Status, ULONG Count) {
+ PDATAGRAM_RECEIVE_REQUEST ReceiveRequest =
+ (PDATAGRAM_RECEIVE_REQUEST)Context;
+ TI_DbgPrint(MAX_TRACE,("Called\n"));
+ ReceiveRequest->UserComplete( ReceiveRequest->UserContext, Status, Count );
+ exFreePool( ReceiveRequest );
+ TI_DbgPrint(MAX_TRACE,("Done\n"));
+}
+
+NTSTATUS RawIPReceiveDatagram(
+ PADDRESS_FILE AddrFile,
+ PTDI_CONNECTION_INFORMATION ConnInfo,
+ PCHAR BufferData,
+ ULONG ReceiveLength,
+ ULONG ReceiveFlags,
+ PTDI_CONNECTION_INFORMATION ReturnInfo,
+ PULONG BytesReceived,
+ PDATAGRAM_COMPLETION_ROUTINE Complete,
+ PVOID Context)
+/*
+ * FUNCTION: Attempts to receive an RawIp datagram from a remote address
+ * ARGUMENTS:
+ * Request = Pointer to TDI request
+ * ConnInfo = Pointer to connection information
+ * Buffer = Pointer to NDIS buffer chain to store received data
+ * ReceiveLength = Maximum size to use of buffer, 0 if all can be used
+ * ReceiveFlags = Receive flags (None, Normal, Peek)
+ * ReturnInfo = Pointer to structure for return information
+ * BytesReceive = Pointer to structure for number of bytes received
+ * RETURNS:
+ * Status of operation
+ * NOTES:
+ * This is the high level interface for receiving RawIp datagrams
+ */
+{
+ KIRQL OldIrql;
+ NTSTATUS Status;
+ PDATAGRAM_RECEIVE_REQUEST ReceiveRequest;
+
+ TI_DbgPrint(MAX_TRACE, ("Called.\n"));
+
+ TcpipAcquireSpinLock(&AddrFile->Lock, &OldIrql);
+
+ if (AF_IS_VALID(AddrFile))
+ {
+ ReceiveRequest = exAllocatePool(NonPagedPool, sizeof(DATAGRAM_RECEIVE_REQUEST));
+ if (ReceiveRequest)
+ {
+ /* Initialize a receive request */
+
+ /* Extract the remote address filter from the request (if any) */
+ if ((ConnInfo->RemoteAddressLength != 0) &&
+ (ConnInfo->RemoteAddress))
+ {
+ Status = AddrGetAddress(ConnInfo->RemoteAddress,
+ &ReceiveRequest->RemoteAddress,
+ &ReceiveRequest->RemotePort);
+ if (!NT_SUCCESS(Status))
+ {
+ TcpipReleaseSpinLock(&AddrFile->Lock, OldIrql);
+ exFreePool(ReceiveRequest);
+ return Status;
+ }
+ }
+ else
+ {
+ ReceiveRequest->RemotePort = 0;
+ }
+ ReceiveRequest->ReturnInfo = ReturnInfo;
+ ReceiveRequest->Buffer = BufferData;
+ ReceiveRequest->BufferSize = ReceiveLength;
+ ReceiveRequest->UserComplete = Complete;
+ ReceiveRequest->UserContext = Context;
+ ReceiveRequest->Complete =
+ (PDATAGRAM_COMPLETION_ROUTINE)RawIpReceiveComplete;
+ ReceiveRequest->Context = ReceiveRequest;
+
+ /* Queue receive request */
+ InsertTailList(&AddrFile->ReceiveQueue, &ReceiveRequest->ListEntry);
+ AF_SET_PENDING(AddrFile, AFF_RECEIVE);
+
+ TcpipReleaseSpinLock(&AddrFile->Lock, OldIrql);
+
+ TI_DbgPrint(MAX_TRACE, ("Leaving (pending).\n"));
+
+ return STATUS_PENDING;
+ }
+ else
+ {
+ Status = STATUS_INSUFFICIENT_RESOURCES;
+ }
+ }
+ else
+ {
+ Status = STATUS_INVALID_ADDRESS;
+ }
+
+ TcpipReleaseSpinLock(&AddrFile->Lock, OldIrql);
+
+ TI_DbgPrint(MAX_TRACE, ("Leaving with errors (0x%X).\n", Status));
+
return Status;
}
-VOID RawIPReceive(
- PIP_INTERFACE Interface,
- PIP_PACKET IPPacket)
+VOID RawIpReceive(PIP_INTERFACE Interface, PIP_PACKET IPPacket)
/*
- * FUNCTION: Receives and queues a raw IP datagram
+ * FUNCTION: Receives and queues a RawIp datagram
* ARGUMENTS:
* NTE = Pointer to net table entry which the packet was received on
- * IPPacket = Pointer to an IP packet that was received
- * NOTES:
- * This is the low level interface for receiving ICMP datagrams.
- * It delivers the packet header and data to anyone that wants it
- * When we get here the datagram has already passed sanity checks
+* IPPacket = Pointer to an IP packet that was received
+* NOTES:
+* This is the low level interface for receiving RawIp datagrams. It strips
+* the RawIp header from a packet and delivers the data to anyone that wants it
+*/
+{
+ AF_SEARCH SearchContext;
+ PIPv4_HEADER IPv4Header;
+ PADDRESS_FILE AddrFile;
+ PIP_ADDRESS DstAddress, SrcAddress;
+ UINT DataSize;
+
+ TI_DbgPrint(MAX_TRACE, ("Called.\n"));
+
+ switch (IPPacket->Type) {
+ /* IPv4 packet */
+ case IP_ADDRESS_V4:
+ IPv4Header = IPPacket->Header;
+ DstAddress = &IPPacket->DstAddr;
+ SrcAddress = &IPPacket->SrcAddr;
+ DataSize = IPPacket->TotalSize;
+ break;
+
+ /* IPv6 packet */
+ case IP_ADDRESS_V6:
+ TI_DbgPrint(MIN_TRACE, ("Discarded IPv6 datagram (%i bytes).\n", IPPacket->TotalSize));
+
+ /* FIXME: IPv6 is not supported */
+ return;
+
+ default:
+ return;
+ }
+
+ /* Locate a receive request on destination address file object
+ and deliver the packet if one is found. If there is no receive
+ request on the address file object, call the associated receive
+ handler. If no receive handler is registered, drop the packet */
+
+ AddrFile = AddrSearchFirst(DstAddress,
+ 0,
+ IPv4Header->Protocol,
+ &SearchContext);
+ if (AddrFile) {
+ do {
+ DGDeliverData(AddrFile,
+ SrcAddress,
+ DstAddress,
+ 0,
+ 0,
+ IPPacket,
+ DataSize);
+ } while ((AddrFile = AddrSearchNext(&SearchContext)) != NULL);
+ } else {
+ /* There are no open address files that will take this datagram */
+ /* FIXME: IPv4 only */
+ TI_DbgPrint(MID_TRACE, ("Cannot deliver IPv4 raw datagram to address (0x%X).\n",
+ DN2H(DstAddress->Address.IPv4Address)));
+
+ /* FIXME: Send ICMP reply */
+ }
+ TI_DbgPrint(MAX_TRACE, ("Leaving.\n"));
+}
+
+
+NTSTATUS RawIPStartup(VOID)
+/*
+ * FUNCTION: Initializes the UDP subsystem
+ * RETURNS:
+ * Status of operation
*/
{
- PIP_ADDRESS DstAddress;
-
- TI_DbgPrint(MAX_TRACE, ("Called.\n"));
-
- switch (IPPacket->Type) {
- /* IPv4 packet */
- case IP_ADDRESS_V4:
- DstAddress = &IPPacket->DstAddr;
- break;
-
- /* IPv6 packet */
- case IP_ADDRESS_V6:
- TI_DbgPrint(MIN_TRACE, ("Discarded IPv6 raw IP datagram (%i bytes).\n",
- IPPacket->TotalSize));
-
- /* FIXME: IPv6 is not supported */
- return;
-
- default:
- return;
- }
-
- /* Locate a receive request on destination address file object
- and deliver the packet if one is found. If there is no receive
- request on the address file object, call the associated receive
- handler. If no receive handler is registered, drop the packet */
-
-#if 0 /* Decide what to do here */
- AddrFile = AddrSearchFirst(DstAddress,
- 0,
- IPPROTO_ICMP,
- &SearchContext);
- if (AddrFile) {
- do {
- DGDeliverData(AddrFile,
- DstAddress,
- IPPacket,
- IPPacket->TotalSize);
- } while ((AddrFile = AddrSearchNext(&SearchContext)) != NULL);
- } else {
- /* There are no open address files that will take this datagram */
- /* FIXME: IPv4 only */
- TI_DbgPrint(MID_TRACE, ("Cannot deliver IPv4 ICMP datagram to address (0x%X).\n",
- DN2H(DstAddress->Address.IPv4Address)));
- }
+#ifdef __NTDRIVER__
+ RtlZeroMemory(&UDPStats, sizeof(UDP_STATISTICS));
#endif
- TI_DbgPrint(MAX_TRACE, ("Leaving.\n"));
+
+ /* Register this protocol with IP layer */
+ IPRegisterProtocol(IPPROTO_ICMP, RawIpReceive);
+
+ return STATUS_SUCCESS;
}
-NTSTATUS RawIPStartup(
- VOID)
+NTSTATUS RawIPShutdown(VOID)
/*
- * FUNCTION: Initializes the Raw IP subsystem
+ * FUNCTION: Shuts down the UDP subsystem
* RETURNS:
* Status of operation
*/
{
- RawIPInitialized = TRUE;
+ /* Deregister this protocol with IP layer */
+ IPRegisterProtocol(IPPROTO_ICMP, NULL);
- return STATUS_SUCCESS;
-}
-
-
-NTSTATUS RawIPShutdown(
- VOID)
-/*
- * FUNCTION: Shuts down the Raw IP subsystem
- * RETURNS:
- * Status of operation
- */
-{
- if (!RawIPInitialized)
- return STATUS_SUCCESS;
-
- return STATUS_SUCCESS;
+ return STATUS_SUCCESS;
}
/* EOF */
diff --git a/reactos/drivers/lib/ip/transport/tcp/accept.c b/reactos/drivers/lib/ip/transport/tcp/accept.c
index 1b79bed5aa3..40287184187 100644
--- a/reactos/drivers/lib/ip/transport/tcp/accept.c
+++ b/reactos/drivers/lib/ip/transport/tcp/accept.c
@@ -1,7 +1,7 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS TCP/IP protocol driver
- * FILE: transport/tcp/tcp.c
+ * FILE: transport/tcp/accept.c
* PURPOSE: Transmission Control Protocol Listen/Accept code
* PROGRAMMERS: Art Yerkes (arty@users.sf.net)
* REVISIONS:
@@ -16,8 +16,7 @@ NTSTATUS TCPServiceListeningSocket( PCONNECTION_ENDPOINT Listener,
NTSTATUS Status;
SOCKADDR_IN OutAddr;
OSK_UINT OutAddrLen;
- PTA_ADDRESS RequestAddressReturn;
- SOCKADDR_IN AddressConnecting;
+ PTA_IP_ADDRESS RequestAddressReturn;
PTDI_CONNECTION_INFORMATION WhoIsConnecting;
/* Unpack TDI info -- We need the return connection information
@@ -38,22 +37,23 @@ NTSTATUS TCPServiceListeningSocket( PCONNECTION_ENDPOINT Listener,
TI_DbgPrint(DEBUG_TCP,("Status %x\n", Status));
if( NT_SUCCESS(Status) && Status != STATUS_PENDING ) {
+ RequestAddressReturn = WhoIsConnecting->RemoteAddress;
+
TI_DbgPrint(DEBUG_TCP,("Copying address to %x (Who %x)\n",
RequestAddressReturn, WhoIsConnecting));
- RequestAddressReturn = (PTA_ADDRESS)WhoIsConnecting->RemoteAddress;
- RequestAddressReturn->AddressLength = OutAddrLen;
- RequestAddressReturn->AddressType =
- AddressConnecting.sin_family;
- TI_DbgPrint(DEBUG_TCP,("Copying address proper: from %x to %x,%x\n",
- ((PCHAR)&AddressConnecting) +
- sizeof(AddressConnecting.sin_family),
- RequestAddressReturn->Address,
- RequestAddressReturn->AddressLength));
- RtlCopyMemory( RequestAddressReturn->Address,
- ((PCHAR)&AddressConnecting) +
- sizeof(AddressConnecting.sin_family),
- RequestAddressReturn->AddressLength );
+ RequestAddressReturn->TAAddressCount = 1;
+ RequestAddressReturn->Address[0].AddressLength = OutAddrLen;
+
+ /* BSD uses the first byte of the sockaddr struct as a length.
+ * Since windows doesn't do that we strip it */
+ RequestAddressReturn->Address[0].AddressType =
+ (OutAddr.sin_family >> 8) & 0xff;
+
+ RtlCopyMemory( &RequestAddressReturn->Address[0].Address,
+ ((PCHAR)&OutAddr) + sizeof(USHORT),
+ sizeof(RequestAddressReturn->Address[0].Address[0]) );
+
TI_DbgPrint(DEBUG_TCP,("Done copying\n"));
}
@@ -151,7 +151,7 @@ NTSTATUS TCPAccept
}
TcpipRecursiveMutexLeave( &TCPLock );
-
+
TI_DbgPrint(DEBUG_TCP,("TCPAccept finished %x\n", Status));
return Status;
}
diff --git a/reactos/drivers/lib/ip/transport/tcp/event.c b/reactos/drivers/lib/ip/transport/tcp/event.c
index 401d4444b9c..d22ed771af8 100644
--- a/reactos/drivers/lib/ip/transport/tcp/event.c
+++ b/reactos/drivers/lib/ip/transport/tcp/event.c
@@ -41,9 +41,10 @@ int TCPSocketState(void *ClientData,
TI_DbgPrint(MID_TRACE,("Connection signalled: %d\n",
Connection->Signalled));
+
+ Connection->SignalState |= NewState;
if( !Connection->Signalled ) {
Connection->Signalled = TRUE;
- Connection->SignalState = NewState;
InsertTailList( &SignalledConnections, &Connection->SignalList );
}
diff --git a/reactos/drivers/lib/ip/transport/tcp/tcp.c b/reactos/drivers/lib/ip/transport/tcp/tcp.c
index c46b8ce7fa5..167add772ee 100644
--- a/reactos/drivers/lib/ip/transport/tcp/tcp.c
+++ b/reactos/drivers/lib/ip/transport/tcp/tcp.c
@@ -30,24 +30,35 @@ static VOID HandleSignalledConnection( PCONNECTION_ENDPOINT Connection,
PIRP Irp;
PMDL Mdl;
+ TI_DbgPrint(MID_TRACE,("Handling signalled state on %x (%x)\n",
+ Connection, Connection->SocketContext));
+
/* Things that can happen when we try the initial connection */
- if( ((NewState & SEL_CONNECT) || (NewState & SEL_FIN)) &&
- !(Connection->State & (SEL_CONNECT | SEL_FIN)) ) {
+ if( NewState & SEL_CONNECT ) {
while( !IsListEmpty( &Connection->ConnectRequest ) ) {
- Connection->State |= NewState & (SEL_CONNECT | SEL_FIN);
- Entry = RemoveHeadList( &Connection->ConnectRequest );
- Bucket = CONTAINING_RECORD( Entry, TDI_BUCKET, Entry );
- Complete = Bucket->Request.RequestNotifyObject;
- TI_DbgPrint(DEBUG_TCP,
- ("Completing Connect Request %x\n", Bucket->Request));
- if( NewState & SEL_FIN ) Status = STATUS_CONNECTION_REFUSED;
- Complete( Bucket->Request.RequestContext, Status, 0 );
- /* Frees the bucket allocated in TCPConnect */
- PoolFreeBuffer( Bucket );
- }
+ Connection->State |= NewState;
+ Entry = RemoveHeadList( &Connection->ConnectRequest );
+ TI_DbgPrint(DEBUG_TCP, ("Connect Event\n"));
+
+ Bucket = CONTAINING_RECORD( Entry, TDI_BUCKET, Entry );
+ Complete = Bucket->Request.RequestNotifyObject;
+ TI_DbgPrint(DEBUG_TCP,
+ ("Completing Request %x\n", Bucket->Request));
+
+ if( (NewState & (SEL_CONNECT | SEL_FIN)) ==
+ (SEL_CONNECT | SEL_FIN) )
+ Status = STATUS_CONNECTION_REFUSED;
+ else
+ Status = STATUS_SUCCESS;
+
+ Complete( Bucket->Request.RequestContext, Status, 0 );
+
+ /* Frees the bucket allocated in TCPConnect */
+ PoolFreeBuffer( Bucket );
+ }
}
- if( (NewState & SEL_ACCEPT) ) {
+ if( NewState & SEL_ACCEPT ) {
/* Handle readable on a listening socket --
* TODO: Implement filtering
*/
@@ -84,7 +95,7 @@ static VOID HandleSignalledConnection( PCONNECTION_ENDPOINT Connection,
}
/* Things that happen after we're connected */
- if( (NewState & SEL_READ) ) {
+ if( NewState & SEL_READ ) {
TI_DbgPrint(DEBUG_TCP,("Readable: irp list %s\n",
IsListEmpty(&Connection->ReceiveRequest) ?
"empty" : "nonempty"));
@@ -142,6 +153,7 @@ static VOID HandleSignalledConnection( PCONNECTION_ENDPOINT Connection,
}
}
}
+
if( NewState & SEL_FIN ) {
TI_DbgPrint(DEBUG_TCP, ("EOF From socket\n"));
@@ -529,7 +541,8 @@ NTSTATUS TCPReceiveData
NTSTATUS Status;
PTDI_BUCKET Bucket;
- TI_DbgPrint(DEBUG_TCP,("Called for %d bytes\n", ReceiveLength));
+ TI_DbgPrint(DEBUG_TCP,("Called for %d bytes (on socket %x)\n",
+ ReceiveLength, Connection->SocketContext));
ASSERT_KM_POINTER(Connection->SocketContext);
@@ -616,7 +629,11 @@ VOID TCPTimeout(VOID) {
UINT TCPAllocatePort( UINT HintPort ) {
if( HintPort ) {
if( AllocatePort( &TCPPorts, HintPort ) ) return HintPort;
- else return (UINT)-1;
+ else {
+ TI_DbgPrint
+ (MID_TRACE,("We got a hint port but couldn't allocate it\n"));
+ return (UINT)-1;
+ }
} else return AllocatePortFromRange( &TCPPorts, 1024, 5000 );
}
@@ -624,4 +641,25 @@ VOID TCPFreePort( UINT Port ) {
DeallocatePort( &TCPPorts, Port );
}
+NTSTATUS TCPGetPeerAddress
+( PCONNECTION_ENDPOINT Connection,
+ PTRANSPORT_ADDRESS Address ) {
+ OSK_UINT LocalAddress, RemoteAddress;
+ OSK_UI16 LocalPort, RemotePort;
+ PTA_IP_ADDRESS AddressIP = (PTA_IP_ADDRESS)Address;
+
+ OskitTCPGetAddress
+ ( Connection->SocketContext,
+ &LocalAddress, &LocalPort,
+ &RemoteAddress, &RemotePort );
+
+ AddressIP->TAAddressCount = 1;
+ AddressIP->Address[0].AddressLength = TDI_ADDRESS_LENGTH_IP;
+ AddressIP->Address[0].AddressType = TDI_ADDRESS_TYPE_IP;
+ AddressIP->Address[0].Address[0].sin_port = RemotePort;
+ AddressIP->Address[0].Address[0].in_addr = RemoteAddress;
+
+ return STATUS_SUCCESS;
+}
+
/* EOF */
diff --git a/reactos/drivers/lib/ip/transport/udp/udp.c b/reactos/drivers/lib/ip/transport/udp/udp.c
index 3cff36b752f..0fbb5d61545 100644
--- a/reactos/drivers/lib/ip/transport/udp/udp.c
+++ b/reactos/drivers/lib/ip/transport/udp/udp.c
@@ -14,7 +14,6 @@
BOOLEAN UDPInitialized = FALSE;
PORT_SET UDPPorts;
-
NTSTATUS AddUDPHeaderIPv4(
PIP_ADDRESS RemoteAddress,
USHORT RemotePort,
@@ -33,51 +32,19 @@ NTSTATUS AddUDPHeaderIPv4(
* Status of operation
*/
{
- PIPv4_HEADER IPHeader;
PUDP_HEADER UDPHeader;
- ULONG BufferSize;
TI_DbgPrint(MID_TRACE, ("Packet: %x NdisPacket %x\n",
IPPacket, IPPacket->NdisPacket));
-
- BufferSize = MaxLLHeaderSize + sizeof(IPv4_HEADER) + sizeof(UDP_HEADER);
-
- GetDataPtr( IPPacket->NdisPacket,
- MaxLLHeaderSize,
- (PCHAR *)&IPPacket->Header,
- &IPPacket->ContigSize );
-
- IPPacket->HeaderSize = 20;
-
- TI_DbgPrint(MAX_TRACE, ("Allocated %d bytes for headers at 0x%X.\n",
- BufferSize, IPPacket->Header));
- TI_DbgPrint(MAX_TRACE, ("Packet total length %d\n", IPPacket->TotalSize));
-
- /* Build IPv4 header */
- IPHeader = (PIPv4_HEADER)IPPacket->Header;
- /* Version = 4, Length = 5 DWORDs */
- IPHeader->VerIHL = 0x45;
- /* Normal Type-of-Service */
- IPHeader->Tos = 0;
- /* Length of header and data */
- IPHeader->TotalLength = WH2N((USHORT)IPPacket->TotalSize);
- /* Identification */
- IPHeader->Id = 0;
- /* One fragment at offset 0 */
- IPHeader->FlagsFragOfs = 0;
- /* Time-to-Live is 128 */
- IPHeader->Ttl = 128;
- /* User Datagram Protocol */
- IPHeader->Protocol = IPPROTO_UDP;
- /* Checksum is 0 (for later calculation of this) */
- IPHeader->Checksum = 0;
- /* Source address */
- IPHeader->SrcAddr = LocalAddress->Address.IPv4Address;
- /* Destination address. FIXME: IPv4 only */
- IPHeader->DstAddr = RemoteAddress->Address.IPv4Address;
+
+ AddGenericHeaderIPv4
+ ( RemoteAddress, RemotePort,
+ LocalAddress, LocalPort,
+ IPPacket, DataLength, IPPROTO_UDP,
+ sizeof(UDP_HEADER), (PVOID *)&UDPHeader );
/* Build UDP header */
- UDPHeader = (PUDP_HEADER)(((PCHAR)IPHeader) + sizeof(IPv4_HEADER));
+ UDPHeader = (PUDP_HEADER)(IPPacket->Data - sizeof(UDP_HEADER));
/* Port values are already big-endian values */
UDPHeader->SourcePort = LocalPort;
UDPHeader->DestPort = RemotePort;
@@ -89,7 +56,7 @@ NTSTATUS AddUDPHeaderIPv4(
IPPacket->Data = ((PCHAR)UDPHeader) + sizeof(UDP_HEADER);
TI_DbgPrint(MID_TRACE, ("Packet: %d ip %d udp %d payload\n",
- (PCHAR)UDPHeader - (PCHAR)IPHeader,
+ (PCHAR)UDPHeader - (PCHAR)IPPacket->Header,
(PCHAR)IPPacket->Data - (PCHAR)UDPHeader,
DataLength));
@@ -440,7 +407,7 @@ NTSTATUS UDPStartup(
RtlZeroMemory(&UDPStats, sizeof(UDP_STATISTICS));
#endif
- PortsStartup( &UDPPorts, UDP_STARTING_PORT, UDP_DYNAMIC_PORTS );
+ PortsStartup( &UDPPorts, 1, 0xfffe );
/* Register this protocol with IP layer */
IPRegisterProtocol(IPPROTO_UDP, UDPReceive);
@@ -472,9 +439,11 @@ NTSTATUS UDPShutdown(
UINT UDPAllocatePort( UINT HintPort ) {
if( HintPort ) {
- if( AllocatePort( &UDPPorts, HintPort ) ) return HintPort;
- else return (UINT)-1;
- } else return AllocateAnyPort( &UDPPorts );
+ if( AllocatePort( &UDPPorts, HintPort ) ) return HintPort;
+ else return (UINT)-1;
+ } else return AllocatePortFromRange
+ ( &UDPPorts, UDP_STARTING_PORT,
+ UDP_STARTING_PORT + UDP_DYNAMIC_PORTS );
}
VOID UDPFreePort( UINT Port ) {
diff --git a/reactos/drivers/lib/oskittcp/oskittcp/interface.c b/reactos/drivers/lib/oskittcp/oskittcp/interface.c
index bb60fd5255a..5d9bb3bf70c 100644
--- a/reactos/drivers/lib/oskittcp/oskittcp/interface.c
+++ b/reactos/drivers/lib/oskittcp/oskittcp/interface.c
@@ -22,8 +22,8 @@ struct linker_set domain_set;
OSKITTCP_EVENT_HANDLERS OtcpEvent = { 0 };
-OSK_UINT OskitDebugTraceLevel = OSK_DEBUG_ULTRA;
-//OSK_UINT OskitDebugTraceLevel = 0;
+//OSK_UINT OskitDebugTraceLevel = OSK_DEBUG_ULTRA;
+OSK_UINT OskitDebugTraceLevel = 0;
/* SPL */
unsigned cpl;
@@ -295,6 +295,7 @@ int OskitTCPAccept( void *socket,
struct socket *so = socket;
struct sockaddr_in sa;
struct mbuf mnam;
+ struct inpcb *inp;
int namelen = 0, error = 0, s;
OS_DbgPrint(OSK_MID_TRACE,("OSKITTCP: Doing accept (Finish %d)\n",
@@ -308,8 +309,6 @@ int OskitTCPAccept( void *socket,
s = splnet();
- OskitDumpBuffer( so, sizeof(*so) );
-
#if 0
if ((head->so_options & SO_ACCEPTCONN) == 0) {
splx(s);
@@ -363,6 +362,13 @@ int OskitTCPAccept( void *socket,
*/
so = head->so_q;
+ inp = so ? so->so_pcb : 0;
+ if( inp ) {
+ ((struct sockaddr_in *)AddrOut)->sin_addr.s_addr =
+ inp->inp_faddr.s_addr;
+ ((struct sockaddr_in *)AddrOut)->sin_port = inp->inp_fport;
+ }
+
OS_DbgPrint(OSK_MID_TRACE,("error = %d\n", error));
if( FinishAccepting ) {
head->so_q = so->so_q;
@@ -380,8 +386,6 @@ int OskitTCPAccept( void *socket,
so->so_state = SS_NBIO | SS_ISCONNECTED;
- OskitDumpBuffer( so, sizeof(*so) );
-
OS_DbgPrint(OSK_MID_TRACE,("error = %d\n", error));
if (name) {
/* check sa_len before it is destroyed */
diff --git a/reactos/drivers/lib/oskittcp/oskittcp/uipc_domain.c b/reactos/drivers/lib/oskittcp/oskittcp/uipc_domain.c
index 08a1800eb41..7ab1555b6f3 100644
--- a/reactos/drivers/lib/oskittcp/oskittcp/uipc_domain.c
+++ b/reactos/drivers/lib/oskittcp/oskittcp/uipc_domain.c
@@ -64,7 +64,7 @@ domaininit()
register struct domain *dp, **dpp;
register struct protosw *pr;
- printf("domaininit starting\n");
+ //printf("domaininit starting\n");
/*
* NB - local domain is always present.
@@ -73,7 +73,7 @@ domaininit()
ADDDOMAIN(inet);
for (dpp = (struct domain **)domain_set.ls_items; *dpp; dpp++) {
- printf("(1) Domain %s counting\n", (**dpp).dom_name);
+ //printf("(1) Domain %s counting\n", (**dpp).dom_name);
(**dpp).dom_next = domains;
domains = *dpp;
}
@@ -84,11 +84,11 @@ domaininit()
#endif
*/
for (dp = domains; dp; dp = dp->dom_next) {
- printf("(1) Domain %s initializing\n", dp->dom_name);
+ //printf("(1) Domain %s initializing\n", dp->dom_name);
if (dp->dom_init)
(*dp->dom_init)();
for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++) {
- printf("Registering protocols for %s\n", dp->dom_name);
+ //printf("Registering protocols for %s\n", dp->dom_name);
if (pr->pr_init)
(*pr->pr_init)();
}
@@ -103,7 +103,7 @@ domaininit()
timeout(pffasttimo, (void *)0, 1);
timeout(pfslowtimo, (void *)0, 1);
- printf("Domaininit done\n");
+ //printf("Domaininit done\n");
}
struct protosw *
diff --git a/reactos/drivers/lib/oskittcp/oskittcp/uipc_mbuf.c b/reactos/drivers/lib/oskittcp/oskittcp/uipc_mbuf.c
index fa031f8ce7f..b9b4a41fee6 100644
--- a/reactos/drivers/lib/oskittcp/oskittcp/uipc_mbuf.c
+++ b/reactos/drivers/lib/oskittcp/oskittcp/uipc_mbuf.c
@@ -79,11 +79,11 @@ mbinit()
#else
#define NCL_INIT 1
#endif
- printf("Here1\n");
+ //printf("Here1\n");
s = splimp();
if (m_clalloc(NCL_INIT, M_DONTWAIT) == 0)
goto bad;
- printf("Here2\n");
+ //printf("Here2\n");
splx(s);
return;
bad:
@@ -116,12 +116,12 @@ m_clalloc(ncl, nowait)
npg = ncl * CLSIZE;
- printf("kmem_malloc(%d)\n", npg);
+ //printf("kmem_malloc(%d)\n", npg);
p = (caddr_t)kmem_malloc(mb_map, ctob(npg),
nowait ? M_NOWAIT : M_WAITOK);
- printf("kmem_malloc done\n");
+ //printf("kmem_malloc done\n");
/*
* Either the map is now full, or this is nowait and there
@@ -133,13 +133,13 @@ m_clalloc(ncl, nowait)
ncl = ncl * CLBYTES / MCLBYTES;
for (i = 0; i < ncl; i++) {
((union mcluster *)p)->mcl_next = mclfree;
- printf( "Freeing %x onto the free list\n", p);
+ //printf( "Freeing %x onto the free list\n", p);
mclfree = (union mcluster *)p;
p += MCLBYTES;
mbstat.m_clfree++;
}
mbstat.m_clusters += ncl;
- printf( "done with m_clalloc\n");
+ //printf( "done with m_clalloc\n");
return (1);
}
#endif /* !OSKIT */
@@ -363,9 +363,7 @@ m_copym(m, off0, len, wait)
#ifdef OSKIT
oskit_bufio_addref(m->m_ext.ext_bufio);
#else
-#ifdef __REACTOS__
- m->m_data = malloc(m->m_len);
-#else
+#ifndef __REACTOS__
mclrefcnt[mtocl(m->m_ext.ext_buf)]++;
#endif
#endif /* OSKIT */
@@ -416,6 +414,7 @@ m_copydata(m, off, len, cp)
if (m == 0)
panic("m_copydata");
count = min(m->m_len - off, len);
+ OS_DbgPrint(OSK_MID_TRACE,("count %d len %d\n", count, len));
bcopy(mtod(m, caddr_t) + off, cp, count);
len -= count;
cp += count;
diff --git a/reactos/drivers/net/afd/afd/bind.c b/reactos/drivers/net/afd/afd/bind.c
index 7312c9fc6f6..68235244ff6 100644
--- a/reactos/drivers/net/afd/afd/bind.c
+++ b/reactos/drivers/net/afd/afd/bind.c
@@ -74,10 +74,6 @@ AfdBindSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp,
/* This will be the from address for subsequent recvfrom calls */
TdiBuildConnectionInfo( &FCB->AddressFrom,
FCB->LocalAddress );
- /* Allocate our backup buffer */
- FCB->Recv.Window = ExAllocatePool( NonPagedPool, FCB->Recv.Size );
- FCB->PollState |= AFD_EVENT_SEND;
- /* A datagram socket is always sendable */
AFD_DbgPrint(MID_TRACE,("Calling TdiReceiveDatagram\n"));
diff --git a/reactos/drivers/net/afd/afd/connect.c b/reactos/drivers/net/afd/afd/connect.c
index b653fa0af5b..c453940de03 100644
--- a/reactos/drivers/net/afd/afd/connect.c
+++ b/reactos/drivers/net/afd/afd/connect.c
@@ -41,7 +41,7 @@ NTSTATUS WarmSocketForConnection( PAFD_FCB FCB ) {
}
NTSTATUS MakeSocketIntoConnection( PAFD_FCB FCB ) {
- NTSTATUS Status;
+ NTSTATUS Status = STATUS_NO_MEMORY;
/* Allocate the receive area and start receiving */
FCB->Recv.Window =
@@ -61,7 +61,7 @@ NTSTATUS MakeSocketIntoConnection( PAFD_FCB FCB ) {
ReceiveComplete,
FCB );
}
-
+
return Status;
}
diff --git a/reactos/drivers/net/afd/afd/info.c b/reactos/drivers/net/afd/afd/info.c
index 560a970e3fc..f521fade070 100644
--- a/reactos/drivers/net/afd/afd/info.c
+++ b/reactos/drivers/net/afd/afd/info.c
@@ -62,12 +62,14 @@ AfdGetInfo( PDEVICE_OBJECT DeviceObject, PIRP Irp,
}
NTSTATUS STDCALL
-AfdGetSockName( PDEVICE_OBJECT DeviceObject, PIRP Irp,
- PIO_STACK_LOCATION IrpSp ) {
+AfdGetSockOrPeerName( PDEVICE_OBJECT DeviceObject, PIRP Irp,
+ PIO_STACK_LOCATION IrpSp, BOOLEAN Local ) {
NTSTATUS Status = STATUS_SUCCESS;
PFILE_OBJECT FileObject = IrpSp->FileObject;
PAFD_FCB FCB = FileObject->FsContext;
- PMDL Mdl;
+ PMDL Mdl = NULL, SysMdl = NULL;
+ PTDI_CONNECTION_INFORMATION ConnInfo = NULL;
+ PTRANSPORT_ADDRESS TransAddr = NULL;
AFD_DbgPrint(MID_TRACE,("Called on %x\n", FCB));
@@ -94,12 +96,50 @@ AfdGetSockName( PDEVICE_OBJECT DeviceObject, PIRP Irp,
} _SEH_END;
if( NT_SUCCESS(Status) ) {
- Status = TdiQueryInformation
- ( FCB->AddressFile.Object,
- TDI_QUERY_ADDRESS_INFO,
- Mdl );
- }
+ if( Local ) {
+ Status = TdiQueryInformation
+ ( FCB->AddressFile.Object,
+ TDI_QUERY_ADDRESS_INFO,
+ Mdl );
+ } else {
+ if( !NT_SUCCESS
+ ( Status = TdiBuildNullConnectionInfo
+ ( &ConnInfo,
+ FCB->LocalAddress->Address[0].AddressType ) ) ) {
+ SysMdl = IoAllocateMdl
+ ( ConnInfo,
+ sizeof( TDI_CONNECTION_INFORMATION ) +
+ TaLengthOfTransportAddress
+ ( ConnInfo->RemoteAddress ),
+ FALSE,
+ FALSE,
+ NULL );
+ }
+ if( SysMdl ) {
+ MmBuildMdlForNonPagedPool( SysMdl );
+ Status = TdiQueryInformation
+ ( FCB->AddressFile.Object,
+ TDI_QUERY_CONNECTION_INFO,
+ SysMdl );
+ } else Status = STATUS_NO_MEMORY;
+
+ if( NT_SUCCESS(Status) ) {
+ TransAddr =
+ (PTRANSPORT_ADDRESS)MmMapLockedPages
+ ( Mdl, IoModifyAccess );
+ }
+
+ if( TransAddr )
+ RtlCopyMemory( TransAddr, ConnInfo->RemoteAddress,
+ TaLengthOfTransportAddress
+ ( ConnInfo->RemoteAddress ) );
+
+ if( ConnInfo ) ExFreePool( ConnInfo );
+ if( SysMdl ) IoFreeMdl( SysMdl );
+ }
+ }
+
/* MmUnlockPages( Mdl ); */
IoFreeMdl( Mdl );
} else {
diff --git a/reactos/drivers/net/afd/afd/listen.c b/reactos/drivers/net/afd/afd/listen.c
index b38d4514d26..26ef02e0fe7 100644
--- a/reactos/drivers/net/afd/afd/listen.c
+++ b/reactos/drivers/net/afd/afd/listen.c
@@ -12,7 +12,9 @@
#include "tdiconn.h"
#include "debug.h"
-VOID SatisfyAccept( PIRP Irp, PFILE_OBJECT NewFileObject,
+VOID SatisfyAccept( PAFD_DEVICE_EXTENSION DeviceExt,
+ PIRP Irp,
+ PFILE_OBJECT NewFileObject,
PAFD_TDI_OBJECT_QELT Qelt ) {
PAFD_FCB FCB = NewFileObject->FsContext;
@@ -23,32 +25,49 @@ VOID SatisfyAccept( PIRP Irp, PFILE_OBJECT NewFileObject,
FCB->State = SOCKET_STATE_CONNECTED;
FCB->Connection = Qelt->Object;
-#if 0
FCB->RemoteAddress =
TaCopyTransportAddress( Qelt->ConnInfo->RemoteAddress );
-#endif
Irp->IoStatus.Information = 0;
Irp->IoStatus.Status = STATUS_SUCCESS;
IoCompleteRequest( Irp, IO_NETWORK_INCREMENT );
MakeSocketIntoConnection( FCB );
-
+ FCB->PollState |= AFD_EVENT_SEND;
+ PollReeval( DeviceExt, NewFileObject );
+
SocketStateUnlock( FCB );
}
VOID SatisfyPreAccept( PIRP Irp, PAFD_TDI_OBJECT_QELT Qelt ) {
PAFD_RECEIVED_ACCEPT_DATA ListenReceive =
(PAFD_RECEIVED_ACCEPT_DATA)Irp->AssociatedIrp.SystemBuffer;
+ PTA_IP_ADDRESS IPAddr;
ListenReceive->SequenceNumber = Qelt->Seq;
+
AFD_DbgPrint(MID_TRACE,("Giving SEQ %d to userland\n", Qelt->Seq));
-#if 0
+ AFD_DbgPrint(MID_TRACE,("Socket Address (K) %x (U) %x\n",
+ &ListenReceive->Address,
+ Qelt->ConnInfo->RemoteAddress));
+
TaCopyTransportAddressInPlace( &ListenReceive->Address,
Qelt->ConnInfo->RemoteAddress );
-#endif
- Irp->IoStatus.Information = sizeof(*ListenReceive);
+ IPAddr = (PTA_IP_ADDRESS)&ListenReceive->Address;
+
+ AFD_DbgPrint(MID_TRACE,("IPAddr->TAAddressCount %d\n",
+ IPAddr->TAAddressCount));
+ AFD_DbgPrint(MID_TRACE,("IPAddr->Address[0].AddressType %d\n",
+ IPAddr->Address[0].AddressType));
+ AFD_DbgPrint(MID_TRACE,("IPAddr->Address[0].AddressLength %d\n",
+ IPAddr->Address[0].AddressLength));
+ AFD_DbgPrint(MID_TRACE,("IPAddr->Address[0].Address[0].sin_port %x\n",
+ IPAddr->Address[0].Address[0].sin_port));
+ AFD_DbgPrint(MID_TRACE,("IPAddr->Address[0].Address[0].sin_addr %x\n",
+ IPAddr->Address[0].Address[0].in_addr));
+
+ Irp->IoStatus.Information = ((PCHAR)&IPAddr[1]) - ((PCHAR)ListenReceive);
Irp->IoStatus.Status = STATUS_SUCCESS;
IoCompleteRequest( Irp, IO_NETWORK_INCREMENT );
}
@@ -79,8 +98,21 @@ NTSTATUS DDKAPI ListenComplete
TdiCloseDevice( FCB->Connection.Handle,
FCB->Connection.Object );
} else {
+ UINT AddressType =
+ FCB->LocalAddress->Address[0].AddressType;
+
Qelt->Object = FCB->Connection;
Qelt->Seq = FCB->ConnSeq++;
+ AFD_DbgPrint(MID_TRACE,("Address Type: %d (RA %x)\n",
+ AddressType,
+ FCB->ListenIrp.
+ ConnectionReturnInfo->RemoteAddress));
+
+ TdiBuildNullConnectionInfo( &Qelt->ConnInfo, AddressType );
+ TaCopyTransportAddressInPlace
+ ( Qelt->ConnInfo->RemoteAddress,
+ FCB->ListenIrp.ConnectionReturnInfo->RemoteAddress );
+
InsertTailList( &FCB->PendingConnections, &Qelt->ListEntry );
}
@@ -103,8 +135,6 @@ NTSTATUS DDKAPI ListenComplete
if( !IsListEmpty( &FCB->PendingConnections ) ) {
FCB->PollState |= AFD_EVENT_ACCEPT;
PollReeval( FCB->DeviceExt, FCB->FileObject );
- } else {
- FCB->PollState &= ~AFD_EVENT_ACCEPT;
}
SocketStateUnlock( FCB );
@@ -119,7 +149,7 @@ NTSTATUS AfdListenSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp,
PAFD_FCB FCB = FileObject->FsContext;
PAFD_LISTEN_DATA ListenReq;
- AFD_DbgPrint(MID_TRACE,("Called\n"));
+ AFD_DbgPrint(MID_TRACE,("Called on %x\n", FCB));
if( !SocketAcquireStateLock( FCB ) ) return LostSocket( Irp, TRUE );
@@ -186,6 +216,9 @@ NTSTATUS AfdWaitForListen( PDEVICE_OBJECT DeviceObject, PIRP Irp,
AFD_DbgPrint(MID_TRACE,("Completed a wait for accept\n"));
+ FCB->PollState &= ~AFD_EVENT_ACCEPT;
+ PollReeval( FCB->DeviceExt, FCB->FileObject );
+
SocketStateUnlock( FCB );
return Status;
} else {
@@ -199,6 +232,8 @@ NTSTATUS AfdAccept( PDEVICE_OBJECT DeviceObject, PIRP Irp,
PIO_STACK_LOCATION IrpSp ) {
NTSTATUS Status = STATUS_SUCCESS;
PFILE_OBJECT FileObject = IrpSp->FileObject;
+ PAFD_DEVICE_EXTENSION DeviceExt =
+ (PAFD_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
PAFD_FCB FCB = FileObject->FsContext;
PAFD_ACCEPT_DATA AcceptData = Irp->AssociatedIrp.SystemBuffer;
PLIST_ENTRY PendingConn;
@@ -207,6 +242,8 @@ NTSTATUS AfdAccept( PDEVICE_OBJECT DeviceObject, PIRP Irp,
if( !SocketAcquireStateLock( FCB ) ) return LostSocket( Irp, TRUE );
+ FCB->EventsFired &= ~AFD_EVENT_ACCEPT;
+
if( FCB->NeedsNewListen ) {
AFD_DbgPrint(MID_TRACE,("ADDRESSFILE: %x\n", FCB->AddressFile.Handle));
@@ -240,7 +277,7 @@ NTSTATUS AfdAccept( PDEVICE_OBJECT DeviceObject, PIRP Irp,
PendingConnObj->Seq));
if( PendingConnObj->Seq == AcceptData->SequenceNumber ) {
- PFILE_OBJECT NewFileObject;
+ PFILE_OBJECT NewFileObject = NULL;
RemoveEntryList( PendingConn );
@@ -252,8 +289,11 @@ NTSTATUS AfdAccept( PDEVICE_OBJECT DeviceObject, PIRP Irp,
(PVOID *)&NewFileObject,
NULL );
+ ASSERT(NewFileObject != FileObject);
+ ASSERT(NewFileObject->FsContext != FCB);
+
/* We have a pending connection ... complete this irp right away */
- SatisfyAccept( Irp, NewFileObject, PendingConnObj );
+ SatisfyAccept( DeviceExt, Irp, NewFileObject, PendingConnObj );
ObDereferenceObject( NewFileObject );
diff --git a/reactos/drivers/net/afd/afd/main.c b/reactos/drivers/net/afd/afd/main.c
index e70d4a4f178..1b9ab1d032d 100644
--- a/reactos/drivers/net/afd/afd/main.c
+++ b/reactos/drivers/net/afd/afd/main.c
@@ -19,8 +19,6 @@
#ifdef DBG
-extern NTSTATUS DDKAPI MmCopyFromCaller( PVOID Dst, PVOID Src, UINT Size );
-
/* See debug.h for debug/trace constants */
//DWORD DebugTraceLevel = DEBUG_ULTRA;
DWORD DebugTraceLevel = 0;
@@ -132,6 +130,18 @@ AfdCreateSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp,
}
FileObject->FsContext = FCB;
+
+ /* It seems that UDP sockets are writable from inception */
+ if( FCB->Flags & SGID_CONNECTIONLESS ) {
+ AFD_DbgPrint(MID_TRACE,("Packet oriented socket\n"));
+ /* Allocate our backup buffer */
+ FCB->Recv.Window = ExAllocatePool( NonPagedPool, FCB->Recv.Size );
+ FCB->Send.Window = ExAllocatePool( NonPagedPool, FCB->Send.Size );
+ /* A datagram socket is always sendable */
+ FCB->PollState |= AFD_EVENT_SEND;
+ PollReeval( FCB->DeviceExt, FCB->FileObject );
+ }
+
Irp->IoStatus.Status = STATUS_SUCCESS;
IoCompleteRequest( Irp, IO_NETWORK_INCREMENT );
@@ -140,6 +150,7 @@ AfdCreateSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp,
VOID DestroySocket( PAFD_FCB FCB ) {
UINT i;
+ BOOLEAN ReturnEarly = FALSE;
PAFD_IN_FLIGHT_REQUEST InFlightRequest[IN_FLIGHT_REQUESTS];
AFD_DbgPrint(MIN_TRACE,("Called (%x)\n", FCB));
@@ -161,8 +172,7 @@ VOID DestroySocket( PAFD_FCB FCB ) {
FCB->ListenIrp.InFlightRequest,
FCB->ReceiveIrp.InFlightRequest,
FCB->SendIrp.InFlightRequest));
- SocketStateUnlock( FCB );
- return;
+ ReturnEarly = TRUE;
}
/* After PoolReeval, this FCB should not be involved in any outstanding
@@ -181,6 +191,8 @@ VOID DestroySocket( PAFD_FCB FCB ) {
}
SocketStateUnlock( FCB );
+
+ if( ReturnEarly ) return;
if( FCB->Recv.Window )
ExFreePool( FCB->Recv.Window );
@@ -213,6 +225,8 @@ AfdCloseSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp,
FCB->PollState |= AFD_EVENT_CLOSE;
PollReeval( FCB->DeviceExt, FileObject );
+ KillSelectsForFCB( FCB->DeviceExt, FileObject, FALSE );
+
if( FCB->EventSelect ) ObDereferenceObject( FCB->EventSelect );
FileObject->FsContext = NULL;
@@ -367,7 +381,10 @@ AfdDispatch(PDEVICE_OBJECT DeviceObject, PIRP Irp)
return AfdDisconnect( DeviceObject, Irp, IrpSp );
case IOCTL_AFD_GET_SOCK_NAME:
- return AfdGetSockName( DeviceObject, Irp, IrpSp );
+ return AfdGetSockOrPeerName( DeviceObject, Irp, IrpSp, TRUE );
+
+ case IOCTL_AFD_GET_PEER_NAME:
+ return AfdGetSockOrPeerName( DeviceObject, Irp, IrpSp, FALSE );
case IOCTL_AFD_GET_TDI_HANDLES:
AFD_DbgPrint(MIN_TRACE, ("IOCTL_AFD_GET_TDI_HANDLES\n"));
diff --git a/reactos/drivers/net/afd/afd/read.c b/reactos/drivers/net/afd/afd/read.c
index cf83360977e..125615a0794 100644
--- a/reactos/drivers/net/afd/afd/read.c
+++ b/reactos/drivers/net/afd/afd/read.c
@@ -28,6 +28,13 @@
static VOID ProcessClose( PAFD_FCB FCB );
+BOOLEAN CantReadMore( PAFD_FCB FCB ) {
+ UINT BytesAvailable = FCB->Recv.Content - FCB->Recv.BytesUsed;
+
+ return !BytesAvailable &&
+ (FCB->PollState & (AFD_EVENT_CLOSE | AFD_EVENT_DISCONNECT));
+}
+
NTSTATUS TryToSatisfyRecvRequestFromBuffer( PAFD_FCB FCB,
PAFD_RECV_INFO RecvReq,
PUINT TotalBytesCopied ) {
@@ -41,7 +48,7 @@ NTSTATUS TryToSatisfyRecvRequestFromBuffer( PAFD_FCB FCB,
AFD_DbgPrint(MID_TRACE,("Called, BytesAvailable = %d\n",
BytesAvailable));
- if( FCB->PollState & AFD_EVENT_CLOSE ) return STATUS_SUCCESS;
+ if( CantReadMore(FCB) ) return STATUS_SUCCESS;
if( !BytesAvailable ) return STATUS_PENDING;
Map = (PAFD_MAPBUF)(RecvReq->BufferArray + RecvReq->BufferCount);
@@ -131,7 +138,7 @@ static VOID ProcessClose( PAFD_FCB FCB ) {
}
/* Handle closing signal */
- FCB->PollState |= AFD_EVENT_CLOSE;
+ FCB->PollState |= AFD_EVENT_DISCONNECT;
PollReeval( FCB->DeviceExt, FCB->FileObject );
}
@@ -159,9 +166,14 @@ NTSTATUS DDKAPI ReceiveComplete
FCB->Recv.BytesUsed = 0;
if( FCB->State == SOCKET_STATE_CLOSED ) {
+ AFD_DbgPrint(MIN_TRACE,("!!! CLOSED SOCK GOT A RECEIVE COMPLETE !!!\n"));
SocketStateUnlock( FCB );
DestroySocket( FCB );
return STATUS_SUCCESS;
+ } else if( FCB->State == SOCKET_STATE_LISTENING ) {
+ AFD_DbgPrint(MIN_TRACE,("!!! LISTENER GOT A RECEIVE COMPLETE !!!\n"));
+ SocketStateUnlock( FCB );
+ return STATUS_UNSUCCESSFUL;
}
if( NT_SUCCESS(Irp->IoStatus.Status) &&
@@ -208,6 +220,24 @@ NTSTATUS DDKAPI ReceiveComplete
Status = STATUS_SUCCESS;
} else {
+ /* Success here means that we got an EOF. Close all pending reads
+ * with EOF. Data won't have been available before. */
+ while( !IsListEmpty( &FCB->PendingIrpList[FUNCTION_RECV] ) ) {
+ NextIrpEntry =
+ RemoveHeadList(&FCB->PendingIrpList[FUNCTION_RECV]);
+ NextIrp =
+ CONTAINING_RECORD(NextIrpEntry, IRP, Tail.Overlay.ListEntry);
+ NextIrpSp = IoGetCurrentIrpStackLocation( NextIrp );
+ RecvReq = NextIrpSp->Parameters.DeviceIoControl.Type3InputBuffer;
+
+ AFD_DbgPrint(MID_TRACE,("Completing recv %x (%d)\n", NextIrp,
+ TotalBytesCopied));
+ UnlockBuffers( RecvReq->BufferArray,
+ RecvReq->BufferCount, FALSE );
+ NextIrp->IoStatus.Status = Status;
+ NextIrp->IoStatus.Information = 0;
+ IoCompleteRequest( NextIrp, IO_NETWORK_INCREMENT );
+ }
ProcessClose( FCB );
}
@@ -240,6 +270,12 @@ AfdConnectedSocketReadData(PDEVICE_OBJECT DeviceObject, PIRP Irp,
if( !SocketAcquireStateLock( FCB ) ) return LostSocket( Irp, FALSE );
+ if( FCB->State != SOCKET_STATE_CONNECTED ) {
+ AFD_DbgPrint(MID_TRACE,("Called recv on wrong kind of socket (s%x)\n",
+ FCB->State));
+ return STATUS_UNSUCCESSFUL;
+ }
+
if( FCB->Flags & AFD_ENDPOINT_CONNECTIONLESS )
{
AFD_DbgPrint(MID_TRACE,("Receive on connection-less sockets not implemented\n"));
@@ -261,7 +297,7 @@ AfdConnectedSocketReadData(PDEVICE_OBJECT DeviceObject, PIRP Irp,
/* Check if we're not closed down yet */
- if( !(FCB->PollState & AFD_EVENT_CLOSE ) ) {
+ if( !CantReadMore(FCB) ) {
AFD_DbgPrint(MID_TRACE,("Not EOF yet\n"));
if( FCB->ReceiveIrp.InFlightRequest ) {
AFD_DbgPrint(MID_TRACE,("We're waiting on a previous irp\n"));
@@ -277,6 +313,9 @@ AfdConnectedSocketReadData(PDEVICE_OBJECT DeviceObject, PIRP Irp,
Status = STATUS_END_OF_FILE;
ProcessClose( FCB );
+
+ return UnlockAndMaybeComplete
+ ( FCB, STATUS_SUCCESS, Irp, 0, NULL, FALSE);
}
if( NT_SUCCESS(Status) ) {
@@ -295,6 +334,7 @@ AfdConnectedSocketReadData(PDEVICE_OBJECT DeviceObject, PIRP Irp,
return UnlockAndMaybeComplete( FCB, Status, Irp,
TotalBytesCopied, NULL, TRUE );
} else {
+ AFD_DbgPrint(MID_TRACE,("Leaving read irp\n"));
return LeaveIrpUntilLater( FCB, Irp, FUNCTION_RECV );
}
}
diff --git a/reactos/drivers/net/afd/afd/select.c b/reactos/drivers/net/afd/afd/select.c
index e5507b8b32b..aae2412693a 100644
--- a/reactos/drivers/net/afd/afd/select.c
+++ b/reactos/drivers/net/afd/afd/select.c
@@ -12,6 +12,25 @@
#include "tdiconn.h"
#include "debug.h"
+VOID PrintEvents( ULONG Events ) {
+ char *events_list[] = { "AFD_EVENT_RECEIVE",
+ "AFD_EVENT_OOB_RECEIVE",
+ "AFD_EVENT_SEND",
+ "AFD_EVENT_DISCONNECT",
+ "AFD_EVENT_ABORT",
+ "AFD_EVENT_CLOSE",
+ "AFD_EVENT_CONNECT",
+ "AFD_EVENT_ACCEPT",
+ "AFD_EVENT_CONNECT_FAIL",
+ "AFD_EVENT_QOS",
+ "AFD_EVENT_GROUP_QOS",
+ NULL };
+ int i;
+
+ for( i = 0; events_list[i]; i++ )
+ if( Events & (1 << i) ) DbgPrint("%s ", events_list[i] );
+}
+
VOID CopyBackStatus( PAFD_HANDLE HandleArray,
UINT HandleCount ) {
UINT i;
@@ -43,13 +62,23 @@ VOID RemoveSelect( PAFD_ACTIVE_POLL Poll ) {
VOID SignalSocket( PAFD_ACTIVE_POLL Poll, PAFD_POLL_INFO PollReq,
NTSTATUS Status ) {
+ int i;
PIRP Irp = Poll->Irp;
AFD_DbgPrint(MID_TRACE,("Called (Status %x)\n", Status));
+ KeCancelTimer( &Poll->Timer );
Poll->Irp->IoStatus.Status = Status;
Poll->Irp->IoStatus.Information =
FIELD_OFFSET(AFD_POLL_INFO, Handles) + sizeof(AFD_HANDLE) * PollReq->HandleCount;
CopyBackStatus( PollReq->Handles,
PollReq->HandleCount );
+ for( i = 0; i < PollReq->HandleCount; i++ ) {
+ AFD_DbgPrint
+ (MAX_TRACE,
+ ("Handle(%x): Got %x,%x\n",
+ PollReq->Handles[i].Handle,
+ PollReq->Handles[i].Events,
+ PollReq->Handles[i].Status));
+ }
UnlockHandles( AFD_HANDLES(PollReq), PollReq->HandleCount );
AFD_DbgPrint(MID_TRACE,("Completing\n"));
IoCompleteRequest( Irp, IO_NETWORK_INCREMENT );
@@ -83,12 +112,17 @@ VOID SelectTimeout( PKDPC Dpc,
AFD_DbgPrint(MID_TRACE,("Timeout\n"));
}
-VOID KillExclusiveSelects( PAFD_DEVICE_EXTENSION DeviceExt ) {
+VOID KillSelectsForFCB( PAFD_DEVICE_EXTENSION DeviceExt,
+ PFILE_OBJECT FileObject,
+ BOOLEAN OnlyExclusive ) {
KIRQL OldIrql;
PLIST_ENTRY ListEntry;
PAFD_ACTIVE_POLL Poll;
PIRP Irp;
PAFD_POLL_INFO PollReq;
+ int i;
+
+ AFD_DbgPrint(MID_TRACE,("Killing selects that refer to %x\n", FileObject));
KeAcquireSpinLock( &DeviceExt->Lock, &OldIrql );
@@ -96,15 +130,23 @@ VOID KillExclusiveSelects( PAFD_DEVICE_EXTENSION DeviceExt ) {
while ( ListEntry != &DeviceExt->Polls ) {
Poll = CONTAINING_RECORD(ListEntry, AFD_ACTIVE_POLL, ListEntry);
ListEntry = ListEntry->Flink;
- if( Poll->Exclusive ) {
- Irp = Poll->Irp;
- PollReq = Irp->AssociatedIrp.SystemBuffer;
- ZeroEvents( PollReq->Handles, PollReq->HandleCount );
- SignalSocket( Poll, PollReq, STATUS_CANCELLED );
+ Irp = Poll->Irp;
+ PollReq = Irp->AssociatedIrp.SystemBuffer;
+
+ for( i = 0; i < PollReq->HandleCount; i++ ) {
+ AFD_DbgPrint(MAX_TRACE,("Req: %x, This %x\n",
+ PollReq->Handles[i].Handle, FileObject));
+ if( (PVOID)PollReq->Handles[i].Handle == FileObject &&
+ (!OnlyExclusive || (OnlyExclusive && Poll->Exclusive)) ) {
+ ZeroEvents( PollReq->Handles, PollReq->HandleCount );
+ SignalSocket( Poll, PollReq, STATUS_SUCCESS );
+ }
}
}
-
+
KeReleaseSpinLock( &DeviceExt->Lock, OldIrql );
+
+ AFD_DbgPrint(MID_TRACE,("Done\n"));
}
NTSTATUS STDCALL
@@ -130,9 +172,6 @@ AfdSelect( PDEVICE_OBJECT DeviceObject, PIRP Irp,
SET_AFD_HANDLES(PollReq,
LockHandles( PollReq->Handles, PollReq->HandleCount ));
- if( Exclusive ) KillExclusiveSelects( DeviceExt );
-
-
if( !AFD_HANDLES(PollReq) ) {
Irp->IoStatus.Status = STATUS_NO_MEMORY;
Irp->IoStatus.Information = 0;
@@ -140,6 +179,16 @@ AfdSelect( PDEVICE_OBJECT DeviceObject, PIRP Irp,
return Irp->IoStatus.Status;
}
+ if( Exclusive ) {
+ for( i = 0; i < PollReq->HandleCount; i++ ) {
+ if( !AFD_HANDLES(PollReq)[i].Handle ) continue;
+
+ KillSelectsForFCB( DeviceExt,
+ (PFILE_OBJECT)AFD_HANDLES(PollReq)[i].Handle,
+ TRUE );
+ }
+ }
+
ZeroEvents( PollReq->Handles,
PollReq->HandleCount );
@@ -173,6 +222,12 @@ AfdSelect( PDEVICE_OBJECT DeviceObject, PIRP Irp,
PollReq->Handles[i].Status = AFD_EVENT_CLOSE;
Signalled++;
} else {
+#ifdef DBG
+ DbgPrint("AFD: Select Events: ");
+ PrintEvents( PollReq->Handles[i].Events );
+ DbgPrint("\n");
+#endif
+
PollReq->Handles[i].Status =
PollReq->Handles[i].Events & FCB->PollState;
if( PollReq->Handles[i].Status ) {
diff --git a/reactos/drivers/net/afd/afd/tdiconn.c b/reactos/drivers/net/afd/afd/tdiconn.c
index 2528a55aa58..45a3792356e 100644
--- a/reactos/drivers/net/afd/afd/tdiconn.c
+++ b/reactos/drivers/net/afd/afd/tdiconn.c
@@ -80,7 +80,8 @@ NTSTATUS TdiBuildNullConnectionInfoInPlace
*/
{
ULONG TdiAddressSize;
-
+ PTRANSPORT_ADDRESS TransportAddress;
+
TdiAddressSize = TdiAddressSizeFromType(Type);
RtlZeroMemory(ConnInfo,
@@ -88,8 +89,11 @@ NTSTATUS TdiBuildNullConnectionInfoInPlace
TdiAddressSize);
ConnInfo->OptionsLength = sizeof(ULONG);
- ConnInfo->RemoteAddressLength = 0;
- ConnInfo->RemoteAddress = NULL;
+ ConnInfo->RemoteAddressLength = TdiAddressSize;
+ ConnInfo->RemoteAddress = TransportAddress =
+ (PTRANSPORT_ADDRESS)&ConnInfo[1];
+ TransportAddress->TAAddressCount = 1;
+ TransportAddress->Address[0].AddressType = Type;
return STATUS_SUCCESS;
}
diff --git a/reactos/drivers/net/afd/afd/write.c b/reactos/drivers/net/afd/afd/write.c
index bf0f7d007b3..69d09ed1311 100644
--- a/reactos/drivers/net/afd/afd/write.c
+++ b/reactos/drivers/net/afd/afd/write.c
@@ -22,7 +22,7 @@ NTSTATUS DDKAPI SendComplete
PLIST_ENTRY NextIrpEntry;
PIRP NextIrp = NULL;
PIO_STACK_LOCATION NextIrpSp;
- PAFD_SEND_INFO SendReq;
+ PAFD_SEND_INFO SendReq = NULL;
PAFD_MAPBUF Map;
UINT TotalBytesCopied = 0, SpaceAvail, i, CopySize = 0;
@@ -165,6 +165,9 @@ NTSTATUS DDKAPI PacketSocketSendComplete
/* It's ok if the FCB already died */
if( !SocketAcquireStateLock( FCB ) ) return STATUS_SUCCESS;
+ FCB->PollState |= AFD_EVENT_SEND;
+ PollReeval( FCB->DeviceExt, FCB->FileObject );
+
FCB->SendIrp.InFlightRequest = NULL;
/* Request is not in flight any longer */
@@ -208,6 +211,12 @@ AfdConnectedSocketWriteData(PDEVICE_OBJECT DeviceObject, PIRP Irp,
if( !(SendReq = LockRequest( Irp, IrpSp )) )
return UnlockAndMaybeComplete( FCB, STATUS_NO_MEMORY, Irp, 0,
NULL, FALSE );
+
+ /* Must lock buffers before handing off user data */
+ SendReq->BufferArray = LockBuffers( SendReq->BufferArray,
+ SendReq->BufferCount,
+ NULL, NULL,
+ FALSE, FALSE );
TdiBuildConnectionInfo( &TargetAddress, FCB->RemoteAddress );
@@ -260,7 +269,7 @@ AfdConnectedSocketWriteData(PDEVICE_OBJECT DeviceObject, PIRP Irp,
SendReq->BufferCount,
NULL, NULL,
FALSE, FALSE );
-
+
AFD_DbgPrint(MID_TRACE,("FCB->Send.BytesUsed = %d\n",
FCB->Send.BytesUsed));
@@ -355,6 +364,7 @@ AfdPacketSocketWriteData(PDEVICE_OBJECT DeviceObject, PIRP Irp,
if( !SocketAcquireStateLock( FCB ) ) return LostSocket( Irp, FALSE );
FCB->EventsFired &= ~AFD_EVENT_SEND;
+ FCB->PollState &= ~AFD_EVENT_SEND;
/* Check that the socket is bound */
if( FCB->State != SOCKET_STATE_BOUND )
diff --git a/reactos/drivers/net/afd/include/afd.h b/reactos/drivers/net/afd/include/afd.h
index 22bceceed26..b58f1d1f49d 100644
--- a/reactos/drivers/net/afd/include/afd.h
+++ b/reactos/drivers/net/afd/include/afd.h
@@ -191,8 +191,8 @@ AfdGetInfo( PDEVICE_OBJECT DeviceObject, PIRP Irp,
PIO_STACK_LOCATION IrpSp );
NTSTATUS STDCALL
-AfdGetSockName( PDEVICE_OBJECT DeviceObject, PIRP Irp,
- PIO_STACK_LOCATION IrpSp );
+AfdGetSockOrPeerName( PDEVICE_OBJECT DeviceObject, PIRP Irp,
+ PIO_STACK_LOCATION IrpSp, BOOLEAN Local );
/* listen.c */
NTSTATUS AfdWaitForListen( PDEVICE_OBJECT DeviceObject, PIRP Irp,
@@ -262,6 +262,8 @@ NTSTATUS STDCALL
AfdEnumEvents( PDEVICE_OBJECT DeviceObject, PIRP Irp,
PIO_STACK_LOCATION IrpSp );
VOID PollReeval( PAFD_DEVICE_EXTENSION DeviceObject, PFILE_OBJECT FileObject );
+VOID KillSelectsForFCB( PAFD_DEVICE_EXTENSION DeviceExt,
+ PFILE_OBJECT FileObject, BOOLEAN ExclusiveOnly );
/* tdi.c */
diff --git a/reactos/drivers/net/ndis/ndis/miniport.c b/reactos/drivers/net/ndis/ndis/miniport.c
index aaaf07c667d..0a792aaf10b 100644
--- a/reactos/drivers/net/ndis/ndis/miniport.c
+++ b/reactos/drivers/net/ndis/ndis/miniport.c
@@ -1933,7 +1933,7 @@ NdisMSetAttributes(
*/
{
NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
- NdisMSetAttributesEx(MiniportAdapterContext, MiniportAdapterContext, 0,
+ NdisMSetAttributesEx(MiniportAdapterHandle, MiniportAdapterContext, 0,
BusMaster ? NDIS_ATTRIBUTE_BUS_MASTER : 0,
AdapterType);
}
diff --git a/reactos/drivers/net/ndis/ndis/protocol.c b/reactos/drivers/net/ndis/ndis/protocol.c
index f83ff42aea6..f0d61d0efd1 100644
--- a/reactos/drivers/net/ndis/ndis/protocol.c
+++ b/reactos/drivers/net/ndis/ndis/protocol.c
@@ -855,7 +855,7 @@ NdisRegisterProtocol(
}
wcscpy(RegistryPathStr, SERVICES_KEY);
- wcscat(RegistryPathStr, (((WCHAR *)(KeyInformation->Data)) +8 ));
+ wcscat(RegistryPathStr, DataPtr + 8 );
wcscat(RegistryPathStr, PARAMETERS_KEY);
wcsncat(RegistryPathStr, ProtocolCharacteristics->Name.Buffer, ProtocolCharacteristics->Name.Length / sizeof(WCHAR) );
diff --git a/reactos/drivers/net/tcpip/datalink/lan.c b/reactos/drivers/net/tcpip/datalink/lan.c
index 731706ed0c9..4633b63c543 100644
--- a/reactos/drivers/net/tcpip/datalink/lan.c
+++ b/reactos/drivers/net/tcpip/datalink/lan.c
@@ -907,6 +907,14 @@ VOID BindAdapter(
if(NT_SUCCESS(Status))
Status = ReadIPAddressFromRegistry( RegHandle, L"SubnetMask",
&IF->Netmask );
+
+ IF->Broadcast.Type = IP_ADDRESS_V4;
+ IF->Broadcast.Address.IPv4Address =
+ IF->Unicast.Address.IPv4Address |
+ ~IF->Netmask.Address.IPv4Address;
+
+ TI_DbgPrint(MID_TRACE,("BCAST(IF) %s\n", A2S(&IF->Broadcast)));
+
if(NT_SUCCESS(Status)) {
Status = ReadStringFromRegistry( RegHandle, L"DeviceDesc",
&IF->Name );
diff --git a/reactos/drivers/net/tcpip/datalink/loopback.c b/reactos/drivers/net/tcpip/datalink/loopback.c
deleted file mode 100644
index 5213cd2d3e9..00000000000
--- a/reactos/drivers/net/tcpip/datalink/loopback.c
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS TCP/IP protocol driver
- * FILE: datalink/loopback.c
- * PURPOSE: Loopback adapter
- * PROGRAMMERS: Casper S. Hornstrup (chorns@users.sourceforge.net)
- * REVISIONS:
- * CSH 01/08-2000 Created
- */
-
-#include "precomp.h"
-
-VOID LoopTransmit(
- PVOID Context,
- PNDIS_PACKET NdisPacket,
- UINT Offset,
- PVOID LinkAddress,
- USHORT Type)
-/*
- * FUNCTION: Transmits a packet
- * ARGUMENTS:
- * Context = Pointer to context information (NULL)
- * NdisPacket = Pointer to NDIS packet to send
- * Offset = Offset in packet where packet data starts
- * LinkAddress = Pointer to link address
- * Type = LAN protocol type (unused)
- */
-{
- IP_PACKET IPPacket;
-
- TI_DbgPrint(MAX_TRACE, ("Called (NdisPacket = %x)\n", NdisPacket));
-
- IPPacket.NdisPacket = NdisPacket;
-
- IPReceive(Context, &IPPacket);
- TI_DbgPrint(MAX_TRACE, ("Finished receive\n"));
- ASSERT_KM_POINTER(Packet);
- ASSERT_KM_POINTER(PC(Packet));
- ASSERT_KM_POINTER(PC(Packet)->DLComplete);
- PC(NdisPacket)->DLComplete(Context, NdisPacket, NDIS_STATUS_SUCCESS);
- TI_DbgPrint(MAX_TRACE, ("Done\n"));
-}
-
-NDIS_STATUS LoopRegisterAdapter(
- PNDIS_STRING AdapterName,
- PLAN_ADAPTER *Adapter)
-/*
- * FUNCTION: Registers loopback adapter with the network layer
- * ARGUMENTS:
- * AdapterName = Unused
- * Adapter = Unused
- * RETURNS:
- * Status of operation
- */
-{
- PIP_ADDRESS Address;
- NDIS_STATUS Status;
-
- Status = NDIS_STATUS_SUCCESS;
-
- TI_DbgPrint(MID_TRACE, ("Called.\n"));
-
- Address = AddrBuildIPv4(LOOPBACK_ADDRESS_IPv4);
- if (Address != NULL)
- {
- LLIP_BIND_INFO BindInfo;
-
- /* Bind the adapter to network (IP) layer */
- BindInfo.Context = NULL;
- BindInfo.HeaderSize = 0;
- BindInfo.MinFrameSize = 0;
- BindInfo.MTU = 16384;
- BindInfo.Address = NULL;
- BindInfo.AddressLength = 0;
- BindInfo.Transmit = LoopTransmit;
-
- Loopback = IPCreateInterface(&BindInfo);
-
- if ((Loopback != NULL) && (IPCreateNTE(Loopback, Address, 8)))
- {
- /* Reference the interface for the NTE. The reference for
- the address is just passed on to the NTE */
- ReferenceObject(Loopback);
-
- IPRegisterInterface(Loopback);
- }
- else
- {
- Status = NDIS_STATUS_RESOURCES;
- }
- }
- else
- {
- Status = NDIS_STATUS_RESOURCES;
- }
-
- if (!NT_SUCCESS(Status))
- {
- LoopUnregisterAdapter(NULL);
- }
-
- TI_DbgPrint(MAX_TRACE, ("Leaving.\n"));
-
- return Status;
-}
-
-
-NDIS_STATUS LoopUnregisterAdapter(
- PLAN_ADAPTER Adapter)
-/*
- * FUNCTION: Unregisters loopback adapter with the network layer
- * ARGUMENTS:
- * Adapter = Unused
- * RETURNS:
- * Status of operation
- * NOTES:
- * Does not care wether we have registered loopback adapter
- */
-{
- TI_DbgPrint(MID_TRACE, ("Called.\n"));
-
- if (Loopback != NULL)
- {
- IPUnregisterInterface(Loopback);
- IPDestroyInterface(Loopback);
- Loopback = NULL;
- }
-
- TI_DbgPrint(MAX_TRACE, ("Leaving.\n"));
-
- return NDIS_STATUS_SUCCESS;
-}
diff --git a/reactos/drivers/net/tcpip/include/rawip.h b/reactos/drivers/net/tcpip/include/rawip.h
index 26efd3d8b50..26b7a35398a 100644
--- a/reactos/drivers/net/tcpip/include/rawip.h
+++ b/reactos/drivers/net/tcpip/include/rawip.h
@@ -7,6 +7,8 @@
#ifndef __RAWIP_H
#define __RAWIP_H
+
+
NTSTATUS RawIPSendDatagram(
PADDRESS_FILE AddrFile,
PTDI_CONNECTION_INFORMATION ConnInfo,
@@ -24,6 +26,17 @@ NTSTATUS RawIPStartup(
NTSTATUS RawIPShutdown(
VOID);
+NTSTATUS AddGenericHeaderIPv4(
+ PIP_ADDRESS RemoteAddress,
+ USHORT RemotePort,
+ PIP_ADDRESS LocalAddress,
+ USHORT LocalPort,
+ PIP_PACKET IPPacket,
+ UINT DataLength,
+ UINT Protocol,
+ UINT ExtraLength,
+ PVOID *NextHeader );
+
#endif /* __RAWIP_H */
/* EOF */
diff --git a/reactos/drivers/net/tcpip/include/tcp.h b/reactos/drivers/net/tcpip/include/tcp.h
index 08a0e4cdba1..8279db48685 100644
--- a/reactos/drivers/net/tcpip/include/tcp.h
+++ b/reactos/drivers/net/tcpip/include/tcp.h
@@ -164,6 +164,10 @@ UINT TCPAllocatePort( UINT HintPort );
VOID TCPFreePort( UINT Port );
+NTSTATUS TCPGetPeerAddress
+( PCONNECTION_ENDPOINT Connection,
+ PTRANSPORT_ADDRESS TransportAddress );
+
NTSTATUS TCPStartup(
VOID);
diff --git a/reactos/drivers/net/tcpip/tcpip/dispatch.c b/reactos/drivers/net/tcpip/tcpip/dispatch.c
index c4450d66b17..378f2665c38 100644
--- a/reactos/drivers/net/tcpip/tcpip/dispatch.c
+++ b/reactos/drivers/net/tcpip/tcpip/dispatch.c
@@ -63,7 +63,7 @@ VOID DispCancelComplete(
* Context = Pointer to context information (FILE_OBJECT)
*/
{
- KIRQL OldIrql;
+ /*KIRQL OldIrql;*/
PFILE_OBJECT FileObject;
PTRANSPORT_CONTEXT TranContext;
@@ -76,80 +76,12 @@ VOID DispCancelComplete(
KeSetEvent(&TranContext->CleanupEvent, 0, FALSE);
/* We are expected to release the cancel spin lock */
- IoReleaseCancelSpinLock(OldIrql);
+ /*IoReleaseCancelSpinLock(OldIrql);*/
TI_DbgPrint(DEBUG_IRP, ("Leaving.\n"));
}
-VOID DDKAPI DispCancelRequest(
- PDEVICE_OBJECT Device,
- PIRP Irp)
-/*
- * FUNCTION: Cancels an IRP
- * ARGUMENTS:
- * Device = Pointer to device object
- * Irp = Pointer to an I/O request packet
- */
-{
- PIO_STACK_LOCATION IrpSp;
- PTRANSPORT_CONTEXT TranContext;
- PFILE_OBJECT FileObject;
- UCHAR MinorFunction;
- NTSTATUS Status = STATUS_SUCCESS;
-
- TI_DbgPrint(DEBUG_IRP, ("Called.\n"));
-
- IrpSp = IoGetCurrentIrpStackLocation(Irp);
- FileObject = IrpSp->FileObject;
- TranContext = (PTRANSPORT_CONTEXT)FileObject->FsContext;
- MinorFunction = IrpSp->MinorFunction;
-
- TI_DbgPrint(DEBUG_IRP, ("IRP at (0x%X) MinorFunction (0x%X) IrpSp (0x%X).\n", Irp, MinorFunction, IrpSp));
-
-#ifdef DBG
- if (!Irp->Cancel)
- TI_DbgPrint(MIN_TRACE, ("Irp->Cancel is FALSE, should be TRUE.\n"));
-#endif
-
- IoReleaseCancelSpinLock(Irp->CancelIrql);
-
- /* Try canceling the request */
- switch(MinorFunction) {
- case TDI_SEND:
- case TDI_RECEIVE:
- /* FIXME: Close connection */
- break;
-
- case TDI_SEND_DATAGRAM:
- if (FileObject->FsContext2 != (PVOID)TDI_TRANSPORT_ADDRESS_FILE) {
- TI_DbgPrint(MIN_TRACE, ("TDI_SEND_DATAGRAM, but no address file.\n"));
- break;
- }
-
- /*DGCancelSendRequest(TranContext->Handle.AddressHandle, Irp);*/
- break;
-
- case TDI_RECEIVE_DATAGRAM:
- if (FileObject->FsContext2 != (PVOID)TDI_TRANSPORT_ADDRESS_FILE) {
- TI_DbgPrint(MIN_TRACE, ("TDI_RECEIVE_DATAGRAM, but no address file.\n"));
- break;
- }
-
- /*DGCancelReceiveRequest(TranContext->Handle.AddressHandle, Irp);*/
- break;
-
- default:
- TI_DbgPrint(MIN_TRACE, ("Unknown IRP. MinorFunction (0x%X).\n", MinorFunction));
- break;
- }
-
- if (Status != STATUS_PENDING)
- DispCancelComplete(FileObject);
-
- TI_DbgPrint(MAX_TRACE, ("Leaving.\n"));
-}
-
VOID DispDataRequestComplete(
PVOID Context,
NTSTATUS Status,
@@ -204,6 +136,89 @@ VOID DispDataRequestComplete(
}
+VOID DDKAPI DispCancelRequest(
+ PDEVICE_OBJECT Device,
+ PIRP Irp)
+/*
+ * FUNCTION: Cancels an IRP
+ * ARGUMENTS:
+ * Device = Pointer to device object
+ * Irp = Pointer to an I/O request packet
+ */
+{
+ PIO_STACK_LOCATION IrpSp;
+ PTRANSPORT_CONTEXT TranContext;
+ PFILE_OBJECT FileObject;
+ UCHAR MinorFunction;
+ /*NTSTATUS Status = STATUS_SUCCESS;*/
+
+ TI_DbgPrint(DEBUG_IRP, ("Called.\n"));
+
+ IrpSp = IoGetCurrentIrpStackLocation(Irp);
+ FileObject = IrpSp->FileObject;
+ TranContext = (PTRANSPORT_CONTEXT)FileObject->FsContext;
+ MinorFunction = IrpSp->MinorFunction;
+
+ TI_DbgPrint(DEBUG_IRP, ("IRP at (0x%X) MinorFunction (0x%X) IrpSp (0x%X).\n", Irp, MinorFunction, IrpSp));
+
+#ifdef DBG
+ if (!Irp->Cancel)
+ TI_DbgPrint(MIN_TRACE, ("Irp->Cancel is FALSE, should be TRUE.\n"));
+#endif
+
+ /* Try canceling the request */
+ switch(MinorFunction) {
+ case TDI_SEND:
+ TCPDisconnect
+ ( TranContext->Handle.ConnectionContext,
+ TDI_DISCONNECT_RELEASE,
+ NULL,
+ NULL,
+ DispDataRequestComplete,
+ Irp );
+ break;
+
+ case TDI_RECEIVE:
+ TCPDisconnect
+ ( TranContext->Handle.ConnectionContext,
+ TDI_DISCONNECT_ABORT | TDI_DISCONNECT_RELEASE,
+ NULL,
+ NULL,
+ DispDataRequestComplete,
+ Irp );
+ break;
+
+ case TDI_SEND_DATAGRAM:
+ if (FileObject->FsContext2 != (PVOID)TDI_TRANSPORT_ADDRESS_FILE) {
+ TI_DbgPrint(MIN_TRACE, ("TDI_SEND_DATAGRAM, but no address file.\n"));
+ break;
+ }
+
+ /*DGCancelSendRequest(TranContext->Handle.AddressHandle, Irp);*/
+ break;
+
+ case TDI_RECEIVE_DATAGRAM:
+ if (FileObject->FsContext2 != (PVOID)TDI_TRANSPORT_ADDRESS_FILE) {
+ TI_DbgPrint(MIN_TRACE, ("TDI_RECEIVE_DATAGRAM, but no address file.\n"));
+ break;
+ }
+
+ /*DGCancelReceiveRequest(TranContext->Handle.AddressHandle, Irp);*/
+ break;
+
+ default:
+ TI_DbgPrint(MIN_TRACE, ("Unknown IRP. MinorFunction (0x%X).\n", MinorFunction));
+ break;
+ }
+
+ IoReleaseCancelSpinLock(Irp->CancelIrql);
+
+ DispCancelComplete(FileObject);
+
+ TI_DbgPrint(MAX_TRACE, ("Leaving.\n"));
+}
+
+
NTSTATUS DispTdiAccept(
PIRP Irp)
/*
@@ -580,7 +595,9 @@ NTSTATUS DispTdiQueryInformation(
break;
case TDI_CONNECTION_FILE:
- AddrFile = ((PCONNECTION_ENDPOINT)TranContext->Handle.ConnectionContext)->AddressFile;
+ AddrFile =
+ ((PCONNECTION_ENDPOINT)TranContext->Handle.ConnectionContext)->
+ AddressFile;
break;
default:
@@ -605,13 +622,53 @@ NTSTATUS DispTdiQueryInformation(
Address->Address[0].AddressLength = TDI_ADDRESS_LENGTH_IP;
Address->Address[0].AddressType = TDI_ADDRESS_TYPE_IP;
Address->Address[0].Address[0].sin_port = AddrFile->Port;
- Address->Address[0].Address[0].in_addr = AddrFile->Address.Address.IPv4Address;
+ Address->Address[0].Address[0].in_addr =
+ AddrFile->Address.Address.IPv4Address;
RtlZeroMemory(
&Address->Address[0].Address[0].sin_zero,
sizeof(Address->Address[0].Address[0].sin_zero));
return STATUS_SUCCESS;
}
+
+ case TDI_QUERY_CONNECTION_INFO:
+ {
+ PTDI_CONNECTION_INFORMATION AddressInfo;
+ PADDRESS_FILE AddrFile;
+ PCONNECTION_ENDPOINT Endpoint = NULL;
+
+ AddressInfo = (PTDI_CONNECTION_INFORMATION)
+ MmGetSystemAddressForMdl(Irp->MdlAddress);
+
+ switch ((ULONG)IrpSp->FileObject->FsContext2) {
+ case TDI_TRANSPORT_ADDRESS_FILE:
+ AddrFile = (PADDRESS_FILE)TranContext->Handle.AddressHandle;
+ break;
+
+ case TDI_CONNECTION_FILE:
+ Endpoint =
+ (PCONNECTION_ENDPOINT)TranContext->Handle.ConnectionContext;
+ break;
+
+ default:
+ TI_DbgPrint(MIN_TRACE, ("Invalid transport context\n"));
+ return STATUS_INVALID_PARAMETER;
+ }
+
+ if (!Endpoint) {
+ TI_DbgPrint(MID_TRACE, ("No connection object.\n"));
+ return STATUS_INVALID_PARAMETER;
+ }
+
+ if (MmGetMdlByteCount(Irp->MdlAddress) <
+ (FIELD_OFFSET(TDI_CONNECTION_INFORMATION, RemoteAddress) +
+ sizeof(PVOID))) {
+ TI_DbgPrint(MID_TRACE, ("MDL buffer too small (ptr).\n"));
+ return STATUS_BUFFER_OVERFLOW;
+ }
+
+ return TCPGetPeerAddress( Endpoint, AddressInfo->RemoteAddress );
+ }
}
return STATUS_NOT_IMPLEMENTED;
@@ -867,12 +924,15 @@ NTSTATUS DispTdiSendDatagram(
("About to call send routine %x\n",
(*((PADDRESS_FILE)Request.Handle.AddressHandle)->Send)));
- Status = (*((PADDRESS_FILE)Request.Handle.AddressHandle)->Send)(
- Request.Handle.AddressHandle,
- DgramInfo->SendDatagramInformation,
- DataBuffer,
- BufferSize,
- &Irp->IoStatus.Information);
+ if( (*((PADDRESS_FILE)Request.Handle.AddressHandle)->Send) )
+ Status = (*((PADDRESS_FILE)Request.Handle.AddressHandle)->Send)(
+ Request.Handle.AddressHandle,
+ DgramInfo->SendDatagramInformation,
+ DataBuffer,
+ BufferSize,
+ &Irp->IoStatus.Information);
+ else
+ Status = STATUS_UNSUCCESSFUL;
if (Status != STATUS_PENDING) {
DispDataRequestComplete(Irp, Status, Irp->IoStatus.Information);
diff --git a/reactos/drivers/net/tcpip/tcpip/fileobjs.c b/reactos/drivers/net/tcpip/tcpip/fileobjs.c
index f219bf3631b..77a623ff00b 100644
--- a/reactos/drivers/net/tcpip/tcpip/fileobjs.c
+++ b/reactos/drivers/net/tcpip/tcpip/fileobjs.c
@@ -43,6 +43,20 @@ PADDRESS_FILE AddrSearchFirst(
return AddrSearchNext(SearchContext);
}
+BOOLEAN AddrIsBroadcast(
+ PIP_ADDRESS PossibleMatch,
+ PIP_ADDRESS TargetAddress ) {
+ IF_LIST_ITER(IF);
+
+ ForEachInterface(IF) {
+ if( AddrIsEqual( &IF->Unicast, PossibleMatch ) &&
+ AddrIsEqual( &IF->Broadcast, TargetAddress ) )
+ return TRUE;
+ } EndFor(IF);
+
+ return FALSE;
+}
+
/*
* FUNCTION: Searches through address file entries to find next match
* ARGUMENTS:
@@ -80,10 +94,11 @@ PADDRESS_FILE AddrSearchNext(
A2S(SearchContext->Address)));
/* See if this address matches the search criteria */
- if (((Current->Port == SearchContext->Port) &&
+ if ((Current->Port == SearchContext->Port) &&
(Current->Protocol == SearchContext->Protocol) &&
- (AddrIsEqual(IPAddress, SearchContext->Address))) ||
- (AddrIsUnspecified(IPAddress))) {
+ (AddrIsEqual(IPAddress, SearchContext->Address) ||
+ AddrIsBroadcast(IPAddress, SearchContext->Address) ||
+ AddrIsUnspecified(IPAddress))) {
/* We've found a match */
Found = TRUE;
break;
@@ -268,16 +283,18 @@ NTSTATUS FileOpenAddress(
/* Protocol specific handling */
switch (Protocol) {
case IPPROTO_TCP:
- /* FIXME: If specified port is 0, a port is chosen dynamically */
- AddrFile->Port = TCPAllocatePort(Address->Address[0].Address[0].sin_port);
- AddrFile->Send = NULL; /* TCPSendData */
- break;
+ AddrFile->Port =
+ TCPAllocatePort(Address->Address[0].Address[0].sin_port);
+ AddrFile->Send = NULL; /* TCPSendData */
+ break;
case IPPROTO_UDP:
TI_DbgPrint(MID_TRACE,("Allocating udp port\n"));
AddrFile->Port =
UDPAllocatePort(Address->Address[0].Address[0].sin_port);
- TI_DbgPrint(MID_TRACE,("Setting port %d\n", AddrFile->Port));
+ TI_DbgPrint(MID_TRACE,("Setting port %d (wanted %d)\n",
+ AddrFile->Port,
+ Address->Address[0].Address[0].sin_port));
AddrFile->Send = UDPSendDatagram;
break;
diff --git a/reactos/drivers/net/tcpip/tcpip/info.c b/reactos/drivers/net/tcpip/tcpip/info.c
index fa009f61ba7..42f042ee292 100644
--- a/reactos/drivers/net/tcpip/tcpip/info.c
+++ b/reactos/drivers/net/tcpip/tcpip/info.c
@@ -129,10 +129,10 @@ TDI_STATUS InfoTdiQueryInformationEx(
{
KIRQL OldIrql;
UINT i;
- PVOID context;
+ PVOID context = NULL;
NTSTATUS Status = STATUS_SUCCESS;
BOOL FoundEntity = FALSE;
- InfoRequest_f InfoRequest;
+ InfoRequest_f InfoRequest = NULL;
TI_DbgPrint(MAX_TRACE,
("InfoEx Req: %x %x %x!%04x:%d\n",
diff --git a/reactos/drivers/net/tcpip/tcpip/main.c b/reactos/drivers/net/tcpip/tcpip/main.c
index 9853b02ccfa..21aa80e9894 100644
--- a/reactos/drivers/net/tcpip/tcpip/main.c
+++ b/reactos/drivers/net/tcpip/tcpip/main.c
@@ -9,10 +9,10 @@
*/
#include "precomp.h"
-//#define NDEBUG
+#define NDEBUG
#ifndef NDEBUG
-DWORD DebugTraceLevel = MAX_TRACE | DEBUG_TCP;
+DWORD DebugTraceLevel = DEBUG_ULTRA & ~(DEBUG_LOCK | DEBUG_PBUFFER);
#else
DWORD DebugTraceLevel = 0;
#endif /* NDEBUG */
diff --git a/reactos/drivers/net/tcpip/tcpip/ninfo.c b/reactos/drivers/net/tcpip/tcpip/ninfo.c
index 7fab2c17bc7..85409b37694 100644
--- a/reactos/drivers/net/tcpip/tcpip/ninfo.c
+++ b/reactos/drivers/net/tcpip/tcpip/ninfo.c
@@ -121,7 +121,7 @@ TDI_STATUS InfoTdiQueryGetRouteTable( PNDIS_BUFFER Buffer, PUINT BufferSize ) {
EntityList[RtCurrent->Index - 1].context;
RtCurrent->Index-- );
- RtCurrent->Index = EntityList[RtCurrent->Index].tei_instance;
+ RtCurrent->Index = EntityList[RtCurrent->Index - 1].tei_instance;
TcpipReleaseSpinLock(&EntityListLock, OldIrql);
RtCurrent++; RCacheCur++;
diff --git a/reactos/drivers/storage/cdrom/cdrom.c b/reactos/drivers/storage/cdrom/cdrom.c
index e849a749a08..2a41355a2b0 100644
--- a/reactos/drivers/storage/cdrom/cdrom.c
+++ b/reactos/drivers/storage/cdrom/cdrom.c
@@ -134,6 +134,10 @@ VOID STDCALL
CdromTimerRoutine(IN PDEVICE_OBJECT DeviceObject,
IN PVOID Context);
+VOID
+CdromWorkItem(IN PDEVICE_OBJECT DeviceObject,
+ IN PVOID Context);
+
/* FUNCTIONS ****************************************************************/
@@ -1203,7 +1207,10 @@ CdromClassStartIo (IN PDEVICE_OBJECT DeviceObject,
Irp->IoStatus.Status = STATUS_VERIFY_REQUIRED;
/* FIXME: Update drive capacity */
-
+ IoCompleteRequest (Irp,
+ IO_DISK_INCREMENT);
+ IoStartNextPacket (DeviceObject,
+ FALSE);
return;
}
}
@@ -1614,11 +1621,68 @@ CdromDeviceControlCompletion (IN PDEVICE_OBJECT DeviceObject,
VOID STDCALL
-CdromTimerRoutine(PDEVICE_OBJECT DeviceObject,
- PVOID Context)
+CdromTimerRoutine(IN PDEVICE_OBJECT DeviceObject,
+ IN PVOID Context)
{
- DPRINT ("CdromTimerRoutine() called\n");
+ PIO_WORKITEM WorkItem;
+ DPRINT ("CdromTimerRoutine() called\n");
+ WorkItem = IoAllocateWorkItem(DeviceObject);
+ if (!WorkItem)
+ {
+ return;
+ }
+
+ IoQueueWorkItem(WorkItem,
+ CdromWorkItem,
+ DelayedWorkQueue,
+ WorkItem);
+}
+
+
+VOID
+CdromWorkItem(IN PDEVICE_OBJECT DeviceObject,
+ IN PVOID Context)
+{
+ PIRP Irp;
+ KEVENT Event;
+ IO_STATUS_BLOCK IoStatus;
+ NTSTATUS Status;
+
+ DPRINT("CdromWorkItem() called\n");
+
+ IoFreeWorkItem((PIO_WORKITEM) Context);
+
+ KeInitializeEvent(&Event,
+ NotificationEvent,
+ FALSE);
+
+ Irp = IoBuildDeviceIoControlRequest(IOCTL_CDROM_CHECK_VERIFY,
+ DeviceObject,
+ NULL,
+ 0,
+ NULL,
+ 0,
+ FALSE,
+ &Event,
+ &IoStatus);
+ if (Irp == NULL)
+ {
+ DPRINT("IoBuildDeviceIoControlRequest failed\n");
+ return;
+ }
+
+ Status = IoCallDriver(DeviceObject, Irp);
+ DPRINT("Status: %x\n", Status);
+
+ if (Status == STATUS_PENDING)
+ {
+ KeWaitForSingleObject(&Event,
+ Suspended,
+ KernelMode,
+ FALSE,
+ NULL);
+ }
}
/* EOF */
diff --git a/reactos/drivers/storage/class2/class2.c b/reactos/drivers/storage/class2/class2.c
index 81561dbc908..a76ce6532eb 100644
--- a/reactos/drivers/storage/class2/class2.c
+++ b/reactos/drivers/storage/class2/class2.c
@@ -1026,6 +1026,46 @@ ScsiClassInternalIoControl(IN PDEVICE_OBJECT DeviceObject,
}
+/*
+ * Implements part of the directives on:
+ * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/kmarch/hh/kmarch/other_c694d732-fa95-4841-8d61-2a55ee787905.xml.asp
+ */
+static VOID
+ScsiClassInvalidateMedia(IN PDEVICE_OBJECT DeviceObject,
+ OUT NTSTATUS *Status)
+{
+ PDEVICE_EXTENSION DeviceExtension;
+ PDEVICE_EXTENSION PhysicalExtension;
+
+ DeviceExtension = (PDEVICE_EXTENSION)DeviceObject->DeviceExtension;
+ PhysicalExtension = (PDEVICE_EXTENSION)DeviceExtension->PhysicalDevice->DeviceExtension;
+
+ if (DeviceObject->Characteristics & FILE_REMOVABLE_MEDIA)
+ {
+ DPRINT("Invalidate: test char yields TRUE\n");
+ }
+ else
+ {
+ DPRINT("Invalidate: test char yields FALSE\n");
+ }
+
+ if ((DeviceObject->Characteristics & FILE_REMOVABLE_MEDIA) &&
+ (DeviceObject->Vpb->Flags & VPB_MOUNTED))
+ {
+ DPRINT("Set DO_VERIFY_VOLUME\n");
+ DeviceObject->Flags |= DO_VERIFY_VOLUME;
+ *Status = STATUS_VERIFY_REQUIRED;
+ }
+ else
+ {
+ *Status = STATUS_IO_DEVICE_ERROR;
+ }
+
+ /* Increment the media change count */
+ PhysicalExtension->MediaChangeCount++;
+}
+
+
/*
* @implemented
*/
@@ -1106,9 +1146,12 @@ ScsiClassInterpretSenseInfo(IN PDEVICE_OBJECT DeviceObject,
case SCSI_ADSENSE_NO_MEDIA_IN_DEVICE:
DPRINT("SCSI_ADSENSE_NO_MEDIA_IN_DEVICE\n");
- *Status = STATUS_NO_MEDIA_IN_DEVICE;
+ ScsiClassInvalidateMedia(DeviceObject,
+ Status);
+
+ *Status = STATUS_NO_MEDIA_IN_DEVICE;
Retry = FALSE;
-
+
if((DeviceExtension->MediaChangeEvent != NULL) &&
(!DeviceExtension->MediaChangeEvent))
{
@@ -1200,22 +1243,9 @@ ScsiClassInterpretSenseInfo(IN PDEVICE_OBJECT DeviceObject,
break;
}
- if ((DeviceObject->Characteristics & FILE_REMOVABLE_MEDIA) &&
- (DeviceObject->Vpb->Flags & VPB_MOUNTED))
- {
- DPRINT("SCSI_SENSE_UNIT_ATTENTION set DoVerifyVol\n");
-
- DeviceObject->Flags |= DO_VERIFY_VOLUME;
- *Status = STATUS_VERIFY_REQUIRED;
- Retry = FALSE;
- }
- else
- {
- *Status = STATUS_IO_DEVICE_ERROR;
- }
-
- /* Increment the media change count */
- PhysicalExtension->MediaChangeCount++;
+ ScsiClassInvalidateMedia(DeviceObject,
+ Status);
+ Retry = FALSE;
break;
case SCSI_SENSE_DATA_PROTECT:
diff --git a/reactos/drivers/storage/disk/disk.c b/reactos/drivers/storage/disk/disk.c
index e2910de8862..2d68cf862a0 100644
--- a/reactos/drivers/storage/disk/disk.c
+++ b/reactos/drivers/storage/disk/disk.c
@@ -390,6 +390,8 @@ DiskClassCheckReadWrite(IN PDEVICE_OBJECT DeviceObject,
{
PDEVICE_EXTENSION DeviceExtension;
PDISK_DATA DiskData;
+ PIO_STACK_LOCATION IrpStack;
+ ULARGE_INTEGER EndingOffset;
DPRINT("DiskClassCheckReadWrite() called\n");
@@ -404,6 +406,16 @@ DiskClassCheckReadWrite(IN PDEVICE_OBJECT DeviceObject,
return(STATUS_INVALID_PARAMETER);
}
+ IrpStack = IoGetCurrentIrpStackLocation(Irp);
+ EndingOffset.QuadPart = IrpStack->Parameters.Read.ByteOffset.QuadPart +
+ IrpStack->Parameters.Read.Length;
+
+ if (EndingOffset.QuadPart > DeviceExtension->PartitionLength.QuadPart)
+ {
+ Irp->IoStatus.Status = STATUS_INVALID_PARAMETER;
+ return(STATUS_INVALID_PARAMETER);
+ }
+
return(STATUS_SUCCESS);
}
diff --git a/reactos/drivers/usb/Makefile b/reactos/drivers/usb/Makefile
new file mode 100644
index 00000000000..d389c4503d3
--- /dev/null
+++ b/reactos/drivers/usb/Makefile
@@ -0,0 +1,50 @@
+#
+# ReactOS USB Drivers
+#
+
+PATH_TO_TOP = ../..
+
+include $(PATH_TO_TOP)/rules.mak
+
+DRIVERS = usbport miniport/usbuhci miniport/usbehci miniport/usbohci usbhub usbd
+
+all: $(DRIVERS)
+
+depends:
+
+implib: $(DRIVERS:%=%_implib)
+
+clean: $(DRIVERS:%=%_clean)
+
+install: $(DRIVERS:%=%_install)
+
+bootcd: $(DRIVERS:%=%_bootcd)
+
+.PHONY: all depends implib clean install bootcd
+
+
+#
+# USB DRIVERS
+#
+$(DRIVERS): %:
+ $(MAKE) -C $*
+
+$(DRIVERS:%=%_implib): %_implib:
+ $(MAKE) -C $* implib
+
+$(DRIVERS:%=%_clean): %_clean:
+ $(MAKE) -C $* clean
+
+$(DRIVERS:%=%_install): %_install:
+ $(MAKE) -C $* install
+
+$(DRIVERS:%=%_bootcd): %_bootcd:
+ $(MAKE) -C $* bootcd
+
+.PHONY: $(DRIVERS) $(DRIVERS:%=%_implib) $(DRIVERS:%=%_clean) $(DRIVERS:%=%_install) $(DRIVERS:%=%_bootcd)
+
+
+etags:
+ find . -name "*.[ch]" -print | etags --language=c -
+
+# EOF
diff --git a/reactos/drivers/usb/cromwell/Makefile b/reactos/drivers/usb/cromwell/Makefile
new file mode 100644
index 00000000000..b38e31bc053
--- /dev/null
+++ b/reactos/drivers/usb/cromwell/Makefile
@@ -0,0 +1,50 @@
+#
+# ReactOS USB-Cromwell Drivers
+#
+
+PATH_TO_TOP = ../../..
+
+include $(PATH_TO_TOP)/rules.mak
+
+DRIVERS = core host
+
+all: $(DRIVERS)
+
+depends:
+
+implib: $(DRIVERS:%=%_implib)
+
+clean: $(DRIVERS:%=%_clean)
+
+install: $(DRIVERS:%=%_install)
+
+bootcd: $(DRIVERS:%=%_bootcd)
+
+.PHONY: all depends implib clean install bootcd
+
+
+#
+# USB DRIVERS
+#
+$(DRIVERS): %:
+ $(MAKE) -C $*
+
+$(DRIVERS:%=%_implib): %_implib:
+ $(MAKE) -C $* implib
+
+$(DRIVERS:%=%_clean): %_clean:
+ $(MAKE) -C $* clean
+
+$(DRIVERS:%=%_install): %_install:
+ $(MAKE) -C $* install
+
+$(DRIVERS:%=%_bootcd): %_bootcd:
+ $(MAKE) -C $* bootcd
+
+.PHONY: $(DRIVERS) $(DRIVERS:%=%_implib) $(DRIVERS:%=%_clean) $(DRIVERS:%=%_install) $(DRIVERS:%=%_bootcd)
+
+
+etags:
+ find . -name "*.[ch]" -print | etags --language=c -
+
+# EOF
diff --git a/reactos/drivers/usb/cromwell/core/buffer_simple.c b/reactos/drivers/usb/cromwell/core/buffer_simple.c
new file mode 100644
index 00000000000..7ac70ce30cb
--- /dev/null
+++ b/reactos/drivers/usb/cromwell/core/buffer_simple.c
@@ -0,0 +1,42 @@
+/*
+ * buffer_simple.c -- replacement for usb/core/buffer.c
+ *
+ * (c) Georg Acher, georg@acher.org
+ *
+ */
+
+#include "../usb_wrapper.h"
+#define __KERNEL__
+#define CONFIG_PCI
+#include "hcd.h"
+
+/*------------------------------------------------------------------------*/
+int hcd_buffer_create (struct usb_hcd *hcd)
+{
+ return 0;
+}
+/*------------------------------------------------------------------------*/
+void hcd_buffer_destroy (struct usb_hcd *hcd)
+{
+}
+/*------------------------------------------------------------------------*/
+void *hcd_buffer_alloc (
+ struct usb_bus *bus,
+ size_t size,
+ int mem_flags,
+ dma_addr_t *dma
+)
+{
+ return kmalloc(size,0);
+}
+/*------------------------------------------------------------------------*/
+void hcd_buffer_free (
+ struct usb_bus *bus,
+ size_t size,
+ void *addr,
+ dma_addr_t dma
+)
+{
+ kfree(addr);
+}
+
diff --git a/reactos/drivers/usb/cromwell/core/config.c b/reactos/drivers/usb/cromwell/core/config.c
new file mode 100644
index 00000000000..7d400e982d8
--- /dev/null
+++ b/reactos/drivers/usb/cromwell/core/config.c
@@ -0,0 +1,508 @@
+#if 0
+#include
+#include
+#include
+#include
+#include
+#else
+#include "../usb_wrapper.h"
+#endif
+
+#define USB_MAXALTSETTING 128 /* Hard limit */
+#define USB_MAXENDPOINTS 30 /* Hard limit */
+
+/* these maximums are arbitrary */
+#define USB_MAXCONFIG 8
+#define USB_ALTSETTINGALLOC 4
+#define USB_MAXINTERFACES 32
+
+static int usb_parse_endpoint(struct usb_host_endpoint *endpoint, unsigned char *buffer, int size)
+{
+ struct usb_descriptor_header *header;
+ unsigned char *begin;
+ int parsed = 0, len, numskipped;
+
+ header = (struct usb_descriptor_header *)buffer;
+
+ /* Everything should be fine being passed into here, but we sanity */
+ /* check JIC */
+ if (header->bLength > size) {
+ err("ran out of descriptors parsing");
+ return -1;
+ }
+
+ if (header->bDescriptorType != USB_DT_ENDPOINT) {
+ warn("unexpected descriptor 0x%X, expecting endpoint, 0x%X",
+ header->bDescriptorType, USB_DT_ENDPOINT);
+ return parsed;
+ }
+
+ if (header->bLength == USB_DT_ENDPOINT_AUDIO_SIZE)
+ memcpy(&endpoint->desc, buffer, USB_DT_ENDPOINT_AUDIO_SIZE);
+ else
+ memcpy(&endpoint->desc, buffer, USB_DT_ENDPOINT_SIZE);
+
+ le16_to_cpus(&endpoint->desc.wMaxPacketSize);
+
+ buffer += header->bLength;
+ size -= header->bLength;
+ parsed += header->bLength;
+
+ /* Skip over the rest of the Class Specific or Vendor Specific */
+ /* descriptors */
+ begin = buffer;
+ numskipped = 0;
+ while (size >= sizeof(struct usb_descriptor_header)) {
+ header = (struct usb_descriptor_header *)buffer;
+
+ if (header->bLength < 2) {
+ err("invalid descriptor length of %d", header->bLength);
+ return -1;
+ }
+
+ /* If we find another "proper" descriptor then we're done */
+ if ((header->bDescriptorType == USB_DT_ENDPOINT) ||
+ (header->bDescriptorType == USB_DT_INTERFACE) ||
+ (header->bDescriptorType == USB_DT_CONFIG) ||
+ (header->bDescriptorType == USB_DT_DEVICE))
+ break;
+
+ dbg("skipping descriptor 0x%X",
+ header->bDescriptorType);
+ numskipped++;
+
+ buffer += header->bLength;
+ size -= header->bLength;
+ parsed += header->bLength;
+ }
+ if (numskipped)
+ dbg("skipped %d class/vendor specific endpoint descriptors", numskipped);
+
+ /* Copy any unknown descriptors into a storage area for drivers */
+ /* to later parse */
+ len = (int)(buffer - begin);
+ if (!len) {
+ endpoint->extra = NULL;
+ endpoint->extralen = 0;
+ return parsed;
+ }
+
+ endpoint->extra = kmalloc(len, GFP_KERNEL);
+
+ if (!endpoint->extra) {
+ err("couldn't allocate memory for endpoint extra descriptors");
+ endpoint->extralen = 0;
+ return parsed;
+ }
+
+ memcpy(endpoint->extra, begin, len);
+ endpoint->extralen = len;
+
+ return parsed;
+}
+
+static int usb_parse_interface(struct usb_interface *interface, unsigned char *buffer, int size)
+{
+ int i, len, numskipped, retval, parsed = 0;
+ struct usb_descriptor_header *header;
+ struct usb_host_interface *ifp;
+ unsigned char *begin;
+
+ interface->act_altsetting = 0;
+ interface->num_altsetting = 0;
+ interface->max_altsetting = USB_ALTSETTINGALLOC;
+ device_initialize(&interface->dev);
+
+ interface->altsetting = kmalloc(sizeof(*interface->altsetting) * interface->max_altsetting,
+ GFP_KERNEL);
+
+ if (!interface->altsetting) {
+ err("couldn't kmalloc interface->altsetting");
+ return -1;
+ }
+
+ while (size > 0) {
+ struct usb_interface_descriptor *d;
+
+ if (interface->num_altsetting >= interface->max_altsetting) {
+ struct usb_host_interface *ptr;
+ int oldmas;
+
+ oldmas = interface->max_altsetting;
+ interface->max_altsetting += USB_ALTSETTINGALLOC;
+ if (interface->max_altsetting > USB_MAXALTSETTING) {
+ warn("too many alternate settings (incr %d max %d)\n",
+ USB_ALTSETTINGALLOC, USB_MAXALTSETTING);
+ return -1;
+ }
+
+ ptr = kmalloc(sizeof(*ptr) * interface->max_altsetting, GFP_KERNEL);
+ if (ptr == NULL) {
+ err("couldn't kmalloc interface->altsetting");
+ return -1;
+ }
+ memcpy(ptr, interface->altsetting, sizeof(*interface->altsetting) * oldmas);
+ kfree(interface->altsetting);
+ interface->altsetting = ptr;
+ }
+
+ ifp = interface->altsetting + interface->num_altsetting;
+ ifp->endpoint = NULL;
+ ifp->extra = NULL;
+ ifp->extralen = 0;
+ interface->num_altsetting++;
+
+ memcpy(ifp, buffer, USB_DT_INTERFACE_SIZE);
+
+ /* Skip over the interface */
+ buffer += ifp->desc.bLength;
+ parsed += ifp->desc.bLength;
+ size -= ifp->desc.bLength;
+
+ begin = buffer;
+ numskipped = 0;
+
+ /* Skip over any interface, class or vendor descriptors */
+ while (size >= sizeof(struct usb_descriptor_header)) {
+ header = (struct usb_descriptor_header *)buffer;
+
+ if (header->bLength < 2) {
+ err("invalid descriptor length of %d", header->bLength);
+ return -1;
+ }
+
+ /* If we find another "proper" descriptor then we're done */
+ if ((header->bDescriptorType == USB_DT_INTERFACE) ||
+ (header->bDescriptorType == USB_DT_ENDPOINT) ||
+ (header->bDescriptorType == USB_DT_CONFIG) ||
+ (header->bDescriptorType == USB_DT_DEVICE))
+ break;
+
+ numskipped++;
+
+ buffer += header->bLength;
+ parsed += header->bLength;
+ size -= header->bLength;
+ }
+
+ if (numskipped)
+ dbg("skipped %d class/vendor specific interface descriptors", numskipped);
+
+ /* Copy any unknown descriptors into a storage area for */
+ /* drivers to later parse */
+ len = (int)(buffer - begin);
+ if (len) {
+ ifp->extra = kmalloc(len, GFP_KERNEL);
+
+ if (!ifp->extra) {
+ err("couldn't allocate memory for interface extra descriptors");
+ ifp->extralen = 0;
+ return -1;
+ }
+ memcpy(ifp->extra, begin, len);
+ ifp->extralen = len;
+ }
+
+ /* Did we hit an unexpected descriptor? */
+ header = (struct usb_descriptor_header *)buffer;
+ if ((size >= sizeof(struct usb_descriptor_header)) &&
+ ((header->bDescriptorType == USB_DT_CONFIG) ||
+ (header->bDescriptorType == USB_DT_DEVICE)))
+ return parsed;
+
+ if (ifp->desc.bNumEndpoints > USB_MAXENDPOINTS) {
+ warn("too many endpoints");
+ return -1;
+ }
+
+ ifp->endpoint = (struct usb_host_endpoint *)
+ kmalloc(ifp->desc.bNumEndpoints *
+ sizeof(struct usb_host_endpoint), GFP_KERNEL);
+ if (!ifp->endpoint) {
+ err("out of memory");
+ return -1;
+ }
+
+ memset(ifp->endpoint, 0, ifp->desc.bNumEndpoints *
+ sizeof(struct usb_host_endpoint));
+
+ for (i = 0; i < ifp->desc.bNumEndpoints; i++) {
+ header = (struct usb_descriptor_header *)buffer;
+
+ if (header->bLength > size) {
+ err("ran out of descriptors parsing");
+ return -1;
+ }
+
+ retval = usb_parse_endpoint(ifp->endpoint + i, buffer, size);
+ if (retval < 0)
+ return retval;
+
+ buffer += retval;
+ parsed += retval;
+ size -= retval;
+ }
+
+ /* We check to see if it's an alternate to this one */
+ d = (struct usb_interface_descriptor *)buffer;
+ if (size < USB_DT_INTERFACE_SIZE
+ || d->bDescriptorType != USB_DT_INTERFACE
+ || !d->bAlternateSetting)
+ return parsed;
+ }
+
+ return parsed;
+}
+
+int usb_parse_configuration(struct usb_host_config *config, char *buffer)
+{
+ int i, retval, size;
+ struct usb_descriptor_header *header;
+
+ memcpy(&config->desc, buffer, USB_DT_CONFIG_SIZE);
+ le16_to_cpus(&config->desc.wTotalLength);
+ size = config->desc.wTotalLength;
+
+ if (config->desc.bNumInterfaces > USB_MAXINTERFACES) {
+ warn("too many interfaces");
+ return -1;
+ }
+
+ config->interface = (struct usb_interface *)
+ kmalloc(config->desc.bNumInterfaces *
+ sizeof(struct usb_interface), GFP_KERNEL);
+ dbg("kmalloc IF %p, numif %i", config->interface, config->desc.bNumInterfaces);
+ if (!config->interface) {
+ err("out of memory");
+ return -1;
+ }
+
+ memset(config->interface, 0,
+ config->desc.bNumInterfaces * sizeof(struct usb_interface));
+
+ buffer += config->desc.bLength;
+ size -= config->desc.bLength;
+
+ config->extra = NULL;
+ config->extralen = 0;
+
+ for (i = 0; i < config->desc.bNumInterfaces; i++) {
+ int numskipped, len;
+ char *begin;
+
+ /* Skip over the rest of the Class Specific or Vendor */
+ /* Specific descriptors */
+ begin = buffer;
+ numskipped = 0;
+ while (size >= sizeof(struct usb_descriptor_header)) {
+ header = (struct usb_descriptor_header *)buffer;
+
+ if ((header->bLength > size) || (header->bLength < 2)) {
+ err("invalid descriptor length of %d", header->bLength);
+ return -1;
+ }
+
+ /* If we find another "proper" descriptor then we're done */
+ if ((header->bDescriptorType == USB_DT_ENDPOINT) ||
+ (header->bDescriptorType == USB_DT_INTERFACE) ||
+ (header->bDescriptorType == USB_DT_CONFIG) ||
+ (header->bDescriptorType == USB_DT_DEVICE))
+ break;
+
+ dbg("skipping descriptor 0x%X", header->bDescriptorType);
+ numskipped++;
+
+ buffer += header->bLength;
+ size -= header->bLength;
+ }
+ if (numskipped)
+ dbg("skipped %d class/vendor specific endpoint descriptors", numskipped);
+
+ /* Copy any unknown descriptors into a storage area for */
+ /* drivers to later parse */
+ len = (int)(buffer - begin);
+ if (len) {
+ if (config->extralen) {
+ warn("extra config descriptor");
+ } else {
+ config->extra = kmalloc(len, GFP_KERNEL);
+ if (!config->extra) {
+ err("couldn't allocate memory for config extra descriptors");
+ config->extralen = 0;
+ return -1;
+ }
+
+ memcpy(config->extra, begin, len);
+ config->extralen = len;
+ }
+ }
+
+ retval = usb_parse_interface(config->interface + i, buffer, size);
+ if (retval < 0)
+ return retval;
+
+ buffer += retval;
+ size -= retval;
+ }
+
+ return size;
+}
+
+// hub-only!! ... and only exported for reset/reinit path.
+// otherwise used internally on disconnect/destroy path
+void usb_destroy_configuration(struct usb_device *dev)
+{
+ int c, i, j, k;
+
+ if (!dev->config)
+ return;
+
+ if (dev->rawdescriptors) {
+ for (i = 0; i < dev->descriptor.bNumConfigurations; i++)
+ kfree(dev->rawdescriptors[i]);
+
+ kfree(dev->rawdescriptors);
+ }
+
+ for (c = 0; c < dev->descriptor.bNumConfigurations; c++) {
+ struct usb_host_config *cf = &dev->config[c];
+
+ if (!cf->interface)
+ break;
+
+ for (i = 0; i < cf->desc.bNumInterfaces; i++) {
+ struct usb_interface *ifp =
+ &cf->interface[i];
+
+ if (!ifp->altsetting)
+ break;
+
+ for (j = 0; j < ifp->num_altsetting; j++) {
+ struct usb_host_interface *as =
+ &ifp->altsetting[j];
+
+ if(as->extra) {
+ kfree(as->extra);
+ }
+
+ if (!as->endpoint)
+ break;
+
+ for(k = 0; k < as->desc.bNumEndpoints; k++) {
+ if(as->endpoint[k].extra) {
+ kfree(as->endpoint[k].extra);
+ }
+ }
+ kfree(as->endpoint);
+ }
+
+ kfree(ifp->altsetting);
+ }
+ kfree(cf->interface);
+ }
+ kfree(dev->config);
+}
+
+
+// hub-only!! ... and only in reset path, or usb_new_device()
+// (used by real hubs and virtual root hubs)
+int usb_get_configuration(struct usb_device *dev)
+{
+ int result;
+ unsigned int cfgno, length;
+ unsigned char *buffer;
+ unsigned char *bigbuffer;
+ struct usb_config_descriptor *desc;
+
+ if (dev->descriptor.bNumConfigurations > USB_MAXCONFIG) {
+ warn("too many configurations");
+ return -EINVAL;
+ }
+
+ if (dev->descriptor.bNumConfigurations < 1) {
+ warn("not enough configurations");
+ return -EINVAL;
+ }
+
+ dev->config = (struct usb_host_config *)
+ kmalloc(dev->descriptor.bNumConfigurations *
+ sizeof(struct usb_host_config), GFP_KERNEL);
+ if (!dev->config) {
+ err("out of memory");
+ return -ENOMEM;
+ }
+ memset(dev->config, 0, dev->descriptor.bNumConfigurations *
+ sizeof(struct usb_host_config));
+
+ dev->rawdescriptors = (char **)kmalloc(sizeof(char *) *
+ dev->descriptor.bNumConfigurations, GFP_KERNEL);
+ if (!dev->rawdescriptors) {
+ err("out of memory");
+ return -ENOMEM;
+ }
+
+ buffer = kmalloc(8, GFP_KERNEL);
+ if (!buffer) {
+ err("unable to allocate memory for configuration descriptors");
+ return -ENOMEM;
+ }
+ desc = (struct usb_config_descriptor *)buffer;
+
+ for (cfgno = 0; cfgno < dev->descriptor.bNumConfigurations; cfgno++) {
+ /* We grab the first 8 bytes so we know how long the whole */
+ /* configuration is */
+ result = usb_get_descriptor(dev, USB_DT_CONFIG, cfgno, buffer, 8);
+ if (result < 8) {
+ if (result < 0)
+ err("unable to get descriptor");
+ else {
+ err("config descriptor too short (expected %i, got %i)", 8, result);
+ result = -EINVAL;
+ }
+ goto err;
+ }
+
+ /* Get the full buffer */
+ length = le16_to_cpu(desc->wTotalLength);
+
+ bigbuffer = kmalloc(length, GFP_KERNEL);
+ if (!bigbuffer) {
+ err("unable to allocate memory for configuration descriptors");
+ result = -ENOMEM;
+ goto err;
+ }
+
+ /* Now that we know the length, get the whole thing */
+ result = usb_get_descriptor(dev, USB_DT_CONFIG, cfgno, bigbuffer, length);
+ if (result < 0) {
+ err("couldn't get all of config descriptors");
+ kfree(bigbuffer);
+ goto err;
+ }
+
+ if (result < length) {
+ err("config descriptor too short (expected %i, got %i)", length, result);
+ result = -EINVAL;
+ kfree(bigbuffer);
+ goto err;
+ }
+
+ dev->rawdescriptors[cfgno] = bigbuffer;
+
+ result = usb_parse_configuration(&dev->config[cfgno], bigbuffer);
+ if (result > 0)
+ dbg("descriptor data left");
+ else if (result < 0) {
+ result = -EINVAL;
+ goto err;
+ }
+ }
+
+ kfree(buffer);
+ return 0;
+err:
+ kfree(buffer);
+ dev->descriptor.bNumConfigurations = cfgno;
+ return result;
+}
+
diff --git a/reactos/drivers/usb/cromwell/core/hcd-pci.c b/reactos/drivers/usb/cromwell/core/hcd-pci.c
new file mode 100644
index 00000000000..ca7182c0b2a
--- /dev/null
+++ b/reactos/drivers/usb/cromwell/core/hcd-pci.c
@@ -0,0 +1,365 @@
+/*
+ * (C) Copyright David Brownell 2000-2002
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#if 0
+#include
+
+#ifdef CONFIG_USB_DEBUG
+ #define DEBUG
+#else
+ #undef DEBUG
+#endif
+
+#include
+#include
+#include
+#include
+#include
+#include