Compare commits

..

7 Commits

Author SHA1 Message Date
The ReactOS Team
0b545b592e This commit was manufactured by cvs2svn to create tag 'krnl0010'.
svn path=/tags/krnl0010/; revision=32
1998-09-05 17:34:23 +00:00
Rex Jolliff
935b7c2953 upgrade to krnl0010
svn path=/branches/ros/; revision=30
1998-09-05 17:34:23 +00:00
The ReactOS Team
1b7327da76 This commit was manufactured by cvs2svn to create branch 'ros'.
svn path=/branches/ros/; revision=29
1998-09-05 17:34:23 +00:00
Rex Jolliff
f77c44657c Import of KRNL0009
svn path=/branches/ros/; revision=21
1998-08-28 23:24:42 +00:00
The ReactOS Team
df0328b7cc This commit was manufactured by cvs2svn to create branch 'ros'.
svn path=/branches/ros/; revision=20
1998-08-28 23:24:42 +00:00
Rex Jolliff
94c8483b04 A much Needed Update
svn path=/branches/ros/; revision=10
1998-08-25 04:27:41 +00:00
The ReactOS Team
fc7e59ce74 This commit was manufactured by cvs2svn to create branch 'ros'.
svn path=/branches/ros/; revision=9
1998-08-25 04:27:41 +00:00
283 changed files with 69229 additions and 10044 deletions

View File

@@ -1,46 +0,0 @@
<?xml version="1.0"?>
<!--
Copyright (C) 2005 Casper S. Hornstrup
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.
-->
<project name="ReactOS.ApiStatus" default="publish">
<property name="reactos.dir" value="reactos" />
<property name="apistatus.xsl" value="rapistatus.xsl" />
<property name="apistatus.xml" value="rapistatus.xml" />
<property name="apistatus.html" value="index2.html" />
<include buildfile="config.include" />
<target name="publish">
<delete dir="${reactos.dir}" if="${directory::exists(reactos.dir)}" />
<exec program="svn" commandline="export -r HEAD ${source.url} ${reactos.dir}" />
<exec program="rgenstat" commandline="reactos\apistatus.lst ${apistatus.xml}" />
<style style="${apistatus.xsl}" destdir="${reactos.dir}" in="${apistatus.xml}" out="${apistatus.html}" />
<copy todir="${publish.dir}" overwrite="true">
<fileset basedir=".">
<include name="${apistatus.xml}" />
<include name="${apistatus.html}" />
</fileset>
</copy>
<delete>
<fileset basedir=".">
<include name="${apistatus.xml}" />
<include name="${apistatus.html}" />
</fileset>
</delete>
<delete dir="${reactos.dir}" if="${directory::exists(reactos.dir)}" />
</target>
</project>

View File

@@ -1,22 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2005 Casper S. Hornstrup
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.
-->
<project>
<property name="source.url" value="svn://svn.reactos.com/trunk/reactos" />
<property name="publish.dir" value="C:\api" />
</project>

View File

@@ -1,199 +0,0 @@
<?xml version="1.0" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html" indent="no"/>
<!-- <xsl:output method="xml"/>-->
<!-- Will not work: <xsl:strip-space elements="*"/> -->
<xsl:template match="/">
<HTML>
<HEAD>
<TITLE>
ReactOS API Status
</TITLE>
<SCRIPT src="rapistatus.js"></SCRIPT>
<LINK rel="stylesheet" type="text/css" href="rapistatus.css"></LINK>
</HEAD>
<BODY onLoad="onLoad();">
<P>
<H1>ReactOS API Status</H1>
</P>
<P>
<TABLE>
<TR>
<TD> <INPUT type="checkbox" ID="implemented" onClick="selectImplemented();" checked="1"/> </TD>
<TD> <IMG src="i.gif"/> </TD>
<TD> Implemented </TD>
<TD width="20"/>
</TR>
<TR>
<TD> <INPUT type="checkbox" ID="unimplemented" onClick="selectUnimplemented();" checked="1"/> </TD>
<TD> <IMG src="u.gif"/> </TD>
<TD> Unimplemented </TD>
<TD width="20"/>
</TR>
</TABLE>
</P>
<DIV ID="ROOT">
<xsl:apply-templates/>
</DIV>
<P>
Legend :<BR/>
<TABLE>
<TR>
<TD> <IMG src="c.gif"/> </TD>
<TD> Component </TD>
<TD> <IMG src="i.gif"/> </TD>
<TD> Implemented </TD>
<TD> <IMG src="sc.gif"/> </TD>
<TD> Complete </TD>
<TR>
</TR>
<TD> <IMG src="f.gif"/> </TD>
<TD> Function </TD>
<TD> <IMG src="u.gif"/> </TD>
<TD> Unimplemented </TD>
<TD></TD>
<TD></TD>
</TR>
</TABLE>
</P>
</BODY>
</HTML>
</xsl:template>
<!-- component -->
<xsl:template match="/components">
<xsl:apply-templates select="component">
<xsl:sort select="@name"/>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="components/component[@implemented_total or @unimplemented_total]">
<DIV>
<xsl:call-template name="ELEMENT">
<xsl:with-param name="class">c</xsl:with-param>
</xsl:call-template>
<xsl:apply-templates>
<xsl:with-param name="base"><xsl:value-of select="@base"/></xsl:with-param>
</xsl:apply-templates>
</DIV>
</xsl:template>
<!-- function -->
<xsl:template match="functions">
<xsl:param name="base"/>
<xsl:apply-templates select="f">
<xsl:sort select="@n"/>
<xsl:with-param name="base"><xsl:value-of select="$base"/></xsl:with-param>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="functions/f">
<xsl:param name="base"/>
<DIV>
<xsl:call-template name="ELEMENT">
<xsl:with-param name="class">f</xsl:with-param>
<xsl:with-param name="base"><xsl:value-of select="$base"/></xsl:with-param>
</xsl:call-template>
<xsl:apply-templates/>
</DIV>
</xsl:template>
<!-- support templates -->
<xsl:template name="ELEMENT">
<xsl:param name="class"/>
<xsl:param name="base"/>
<xsl:param name="image"/>
<xsl:attribute name="class">
<xsl:value-of select="$class"/>
<xsl:text>_</xsl:text>
</xsl:attribute>
<xsl:call-template name="toggle"/>
<xsl:choose>
<xsl:when test="local-name() != 'component' and @i = 'true'">
<img src="i.gif" class="i"/>
</xsl:when>
<xsl:when test="local-name() != 'component' and @i = 'false'">
<img src="u.gif" class="u"/>
</xsl:when>
<xsl:when test="local-name() = 'component' and @complete >= 100">
<img src="sc.gif"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@i"/><img src="tb.gif" with="12" height="12"/>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="$image">
<img src="{$image}.gif" class="t"/>
</xsl:when>
<xsl:otherwise>
<img src="{$class}.gif" class="t"/>
</xsl:otherwise>
</xsl:choose>
<xsl:call-template name="name"/>
<xsl:call-template name="n"/>
<xsl:call-template name="file">
<xsl:with-param name="base"><xsl:value-of select="$base"/></xsl:with-param>
</xsl:call-template>
<xsl:call-template name="status"/>
</xsl:template>
<xsl:template name="status">
<xsl:if test="@complete and @complete != 0">
<SPAN class="st">
<img src="sc.gif"/>
<xsl:text>: </xsl:text>
<xsl:value-of select="@complete"/>
<xsl:text>%</xsl:text>
</SPAN>
</xsl:if>
<xsl:if test="@implemented_total">
<SPAN class="st">
<img src="i.gif"/>: <xsl:value-of select="@implemented_total"/>
</SPAN>
</xsl:if>
<xsl:if test="@unimplemented_total">
<SPAN class="st">
<img src="u.gif"/>: <xsl:value-of select="@unimplemented_total"/>
</SPAN>
</xsl:if>
</xsl:template>
<xsl:template name="toggle">
<xsl:choose>
<xsl:when test="local-name() = 'component'">
<IMG src="tp.gif" class="t"/>
</xsl:when>
<xsl:otherwise>
<IMG src="tb.gif"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="name">
<xsl:if test="@name">
<SPAN class="l"><xsl:value-of select="@name"/></SPAN>
</xsl:if>
</xsl:template>
<xsl:template name="n">
<xsl:if test="@n">
<SPAN class="l"><xsl:value-of select="@n"/></SPAN>
</xsl:if>
</xsl:template>
<xsl:template name="file">
<xsl:param name="base"/>
<xsl:if test="@f">
<SPAN class="h"><xsl:value-of select="$base"/><xsl:value-of select="@f"/></SPAN>
</xsl:if>
</xsl:template>
</xsl:stylesheet>

View File

@@ -1,10 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="publishPath" value="c:\iso" /> <!-- c:\iso or ftp://ftp.server.com/iso -->
<add key="smtpServer" value="localhost" />
<add key="errorEmail" value="mailbox@somewhere-on-the-net" />
<add key="makeParameters" value="" />
<add key="fastDisk" value="" />
</appSettings>
</configuration>

View File

@@ -1,14 +0,0 @@
using System.Reflection;
using System.Runtime.CompilerServices;
[assembly: AssemblyTitle("ReactOS Sin Custom Revision Action")]
[assembly: AssemblyDescription("ReactOS Sin Custom Revision Action")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("ReactOS Project")]
[assembly: AssemblyProduct("React Operating System")]
[assembly: AssemblyCopyright("Copyright 2005 ReactOS Project")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyDelaySign(false)]
[assembly: AssemblyKeyFile("")]

View File

@@ -1,20 +0,0 @@
<?xml version="1.0"?>
<project name="ReactOS.CustomRevisionAction" default="build">
<property name="output.dir" value="bin" />
<target name="build" description="Build component">
<mkdir dir="${output.dir}" />
<csc target="exe"
output="${output.dir}\ReactOS.CustomRevisionAction.exe"
optimize="true"
debug="true"
doc="${output.dir}\ReactOS.CustomRevisionAction.xml"
warninglevel="0">
<sources>
<include name="*.cs" />
</sources>
</csc>
</target>
</project>

File diff suppressed because it is too large Load Diff

View File

@@ -1,340 +0,0 @@
using System;
using System.IO;
using System.Diagnostics;
using System.Configuration;
using System.Web.Mail;
namespace ReactOS.CustomRevisionAction
{
public class MainClass
{
/// <summary>
/// Path to store published binaries at.
/// </summary>
private static string publishPath;
/// <summary>
/// Whether or not to publish ISOs to a remote destination via FTP.
/// </summary>
private static bool PublishToRemoteFtpLocation
{
get
{
return publishPath.StartsWith("ftp://");
}
}
/// <summary>
/// Run the application.
/// </summary>
/// <param name="script">Script to run.</param>
/// <param name="args">Arguments to pass to script.</param>
/// <param name="workingDirectory">Working directory.</param>
/// <param name="standardOutput">Receives standard output.</param>
/// <param name="standardError">Receives standard error.</param>
/// <returns>
/// Exit code.
/// </returns>
private static int RunScript(string script,
string args,
string workingDirectory,
out string standardOutput,
out string standardError)
{
ProcessStartInfo scriptProcessStartInfo = new ProcessStartInfo(script,
args);
scriptProcessStartInfo.CreateNoWindow = true;
/*
* All standard streams must be redirected.
* Otherwise DuplicateHandle() will fail.
*/
scriptProcessStartInfo.RedirectStandardInput = true;
scriptProcessStartInfo.RedirectStandardError = true;
scriptProcessStartInfo.RedirectStandardOutput = true;
scriptProcessStartInfo.UseShellExecute = false;
scriptProcessStartInfo.WorkingDirectory = workingDirectory;
RedirectableProcess redirectableProcess = new RedirectableProcess(scriptProcessStartInfo);
standardOutput = redirectableProcess.ProcessOutput;
standardError = redirectableProcess.ProcessError;
return redirectableProcess.ExitCode;
}
/// <summary>
/// Retrieve value of configuration from configuration file.
/// </summary>
/// <param name="name">Name of configuration option.</param>
/// <param name="defaultValue">
/// Default value to be returned if the option does not exist.
/// </param>
/// <returns>
/// Value of configuration option or null if the option does not
/// exist and no default value is provided.
/// </returns>
private static string GetConfigurationOption(string name,
string defaultValue)
{
if (ConfigurationSettings.AppSettings[name] != null)
return ConfigurationSettings.AppSettings[name];
else
return defaultValue;
}
/// <summary>
/// Send an email.
/// </summary>
/// <param name="subject">Subject of the email.</param>
/// <param name="body">Content of the email.</param>
private static void SendErrorMail(string subject, string body)
{
try
{
string smtpServer = GetConfigurationOption("smtpServer", "localhost");
string toEmail = GetConfigurationOption("errorEmail", null);
if (toEmail == null)
return;
string fromEmail = GetConfigurationOption("fromEmail", null);
if (fromEmail == null)
fromEmail = toEmail;
MailMessage mm = new MailMessage();
mm.Priority = MailPriority.Normal;
mm.From = toEmail;
mm.To = toEmail;
mm.Subject = subject;
mm.Body += body;
mm.Body += "<br>";
mm.BodyFormat = MailFormat.Html;
SmtpMail.SmtpServer = smtpServer;
SmtpMail.Send(mm);
}
catch (Exception ex)
{
Console.Error.WriteLine(ex.Message);
}
}
/// <summary>
/// Fail with an error message.
/// </summary>
/// <param name="revision">Repository revision.</param>
/// <param name="text">Error message.</param>
private static void Fail(int revision,
string text)
{
Console.WriteLine(text);
Console.Error.WriteLine(text);
SendErrorMail(String.Format("[{0}] ReactOS Publish Error", revision), text);
}
/// <summary>
/// Fail with an error message.
/// </summary>
/// <param name="text">Error message.</param>
private static void Fail(string text)
{
Console.WriteLine(text);
Console.Error.WriteLine(text);
SendErrorMail("ReactOS Publish Error", text);
}
/// <summary>
/// Generate filename of distribution.
/// </summary>
/// <param name="branch">Branch.</param>
/// <param name="revision">Revision.</param>
private static string GetDistributionFilename(string branch,
int revision)
{
return String.Format("ReactOS-{0}-r{1}.iso",
branch,
revision);
}
private static void SplitRemotePublishPath(string publishPath,
out string server,
out string directory)
{
string searchString = "://";
int index = publishPath.IndexOf(searchString);
if (index == -1)
throw new InvalidOperationException();
int endOfProtocolIndex = index + searchString.Length;
string withoutProtocol = publishPath.Remove(0, endOfProtocolIndex);
index = withoutProtocol.IndexOf("/");
if (index == -1)
{
server = withoutProtocol;
directory = "";
}
else
{
server = withoutProtocol.Substring(0, index);
directory = withoutProtocol.Remove(0, index + 1);
}
}
/// <summary>
/// Copy ISO to the (remote) destination.
/// </summary>
/// <param name="sourceFilename">Name of source ISO file to copy.</param>
/// <param name="branch">Branch.</param>
/// <param name="revision">Revision.</param>
/// <remarks>
/// Structure is ftp://ftp.server.com/whereever/<branch>/ReactOS-<branch>-r<revision>.iso.
/// </remarks>
private static void CopyISOToRemoteFtpDestination(string sourceFilename,
string branch,
int revision)
{
string distributionFilename = GetDistributionFilename(branch,
revision);
string destinationFilename = Path.Combine(Path.GetDirectoryName(sourceFilename),
distributionFilename);
File.Move(sourceFilename, destinationFilename);
string server;
string directory;
SplitRemotePublishPath(publishPath, out server, out directory);
FtpClient ftpClient = new FtpClient(server, "anonymous", "sin@svn.reactos.com");
ftpClient.Login();
if (directory != "")
ftpClient.ChangeDir(directory);
/* Create destination directory if it does not already exist */
if (!ftpClient.DirectoryExists(branch))
ftpClient.MakeDir(branch);
ftpClient.ChangeDir(branch);
ftpClient.Upload(destinationFilename);
ftpClient.Close();
}
/// <summary>
/// Copy ISO to the (local) destination.
/// </summary>
/// <param name="sourceFilename">Name of source ISO file to copy.</param>
/// <param name="branch">Branch.</param>
/// <param name="revision">Revision.</param>
/// <remarks>
/// Structure is <branch>\ReactOS-<branch>-r<revision>.iso.
/// </remarks>
private static void CopyISOToLocalDestination(string sourceFilename,
string branch,
int revision)
{
string distributionFilename = GetDistributionFilename(branch,
revision);
string destinationDirectory = Path.Combine(publishPath,
branch);
string destinationFilename = Path.Combine(destinationDirectory,
distributionFilename);
if (!Directory.Exists(destinationDirectory))
Directory.CreateDirectory(destinationDirectory);
File.Copy(sourceFilename,
destinationFilename);
}
/// <summary>
/// Copy ISO to the destination.
/// </summary>
/// <param name="sourceFilename">Name of source ISO file to copy.</param>
/// <param name="branch">Branch.</param>
/// <param name="revision">Revision.</param>
/// <remarks>
/// Structure is <branch>\ReactOS-<branch>-r<revision>.iso.
/// </remarks>
private static void CopyISOToDestination(string sourceFilename,
string branch,
int revision)
{
if (PublishToRemoteFtpLocation)
CopyISOToRemoteFtpDestination(sourceFilename, branch, revision);
else
CopyISOToLocalDestination(sourceFilename, branch, revision);
}
/// <summary>
/// Publish a revision of ReactOS.
/// </summary>
/// <param name="text">Error message.</param>
private static int Publish(string branch,
int revision,
string workingDirectory)
{
string make = "mingw32-make";
string makeParameters = GetConfigurationOption("makeParameters", "");
string reactosDirectory = Path.Combine(workingDirectory,
"reactos");
Console.WriteLine(String.Format("ReactOS directory is {0}",
reactosDirectory));
string standardOutput;
string standardError;
int exitCode = RunScript(make,
makeParameters + " bootcd",
reactosDirectory,
out standardOutput,
out standardError);
if (exitCode != 0)
{
Fail(revision,
String.Format("make bootcd failed: (error: {0}) {1}",
standardError,
standardOutput));
return exitCode;
}
string sourceFilename = Path.Combine(reactosDirectory,
"ReactOS.iso");
if (File.Exists(sourceFilename))
CopyISOToDestination(sourceFilename,
branch,
revision);
else
{
Fail(revision,
"make bootcd produced no ReactOS.iso");
return exitCode;
}
return exitCode;
}
/// <summary>
/// Program entry point.
/// </summary>
/// <param name="args">Arguments from command line.</param>
/// <remarks>
/// If exit code is 0, then the commit was processed successfully.
/// If exit code is 1, then the commit was not processed successfully.
/// </remarks>
public static void Main(string[] args)
{
try
{
System.Environment.ExitCode = 1;
publishPath = ConfigurationSettings.AppSettings["publishPath"];
if (publishPath == null)
{
Fail("PublishPath option not set.");
return;
}
if (args.Length < 3)
{
Fail("Usage: ReactOS.CustomRevisionAction action branch revision");
return;
}
string action = args[0]; /* bootcd */
string branch = args[1];
int revision = Int32.Parse(args[2]);
System.Environment.ExitCode = Publish(branch,
revision,
System.Environment.CurrentDirectory);
}
catch (Exception ex)
{
Fail(String.Format("Exception: {0}", ex));
System.Environment.ExitCode = 1;
}
}
}
}

View File

@@ -1,145 +0,0 @@
/*
* When using the ProcessStartInfo.RedirectStandardXxx properties there is a chance of
* the parent and child process blocking due to a race condition. This class handles the
* problem.
* http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdiagnosticsprocessstartinfoclassredirectstandardoutputtopic.asp
*/
using System;
using System.IO;
using System.Threading;
using System.Diagnostics;
namespace ReactOS.CustomRevisionAction
{
/// <summary>
/// Process that redirects standard output and standard error streams.
/// </summary>
public class RedirectableProcess
{
/// <summary>
/// Process.
/// </summary>
private Process process;
/// <summary>
/// Redirected standard error stream.
/// </summary>
private string processError;
/// <summary>
/// Redirected standard output stream.
/// </summary>
private string processOutput;
/// <summary>
/// Exit code.
/// </summary>
private int exitCode;
/// <summary>
/// Redirected standard error stream.
/// </summary>
public string ProcessError
{
get
{
return processError;
}
}
/// <summary>
/// Redirected standard output stream.
/// </summary>
public string ProcessOutput
{
get
{
return processOutput;
}
}
/// <summary>
/// Exit code.
/// </summary>
public int ExitCode
{
get
{
return exitCode;
}
}
/// <summary>
/// Run an excutable and redirect standard error and/or standard output safely.
/// </summary>
public RedirectableProcess(ProcessStartInfo processStartInfo)
{
Run(processStartInfo, null);
}
/// <summary>
/// Run an excutable and redirect standard error and/or standard output safely.
/// </summary>
public RedirectableProcess(ProcessStartInfo processStartInfo, string input)
{
Run(processStartInfo, input);
}
private void Run(ProcessStartInfo processStartInfo, string input)
{
process = new Process();
process.StartInfo = processStartInfo;
process.Start();
if (processStartInfo.RedirectStandardInput && input != null)
{
process.StandardInput.AutoFlush = true;
process.StandardInput.WriteLine(input);
}
Thread readStandardError = null;
if (processStartInfo.RedirectStandardError)
{
readStandardError = new Thread(new ThreadStart(ReadStandardError));
readStandardError.Start();
}
Thread readStandardOutput = null;
if (processStartInfo.RedirectStandardOutput)
{
readStandardOutput = new Thread(new ThreadStart(ReadStandardOutput));
readStandardOutput.Start();
}
if (processStartInfo.RedirectStandardError)
{
readStandardError.Join();
}
if (processStartInfo.RedirectStandardOutput)
{
readStandardOutput.Join();
}
process.WaitForExit();
exitCode = process.ExitCode;
process = null;
}
/// <summary>
/// Read standard error thread entry-point.
/// </summary>
private void ReadStandardError()
{
if (process != null)
{
processError = process.StandardError.ReadToEnd();
}
}
/// <summary>
/// Read standard output thread entry-point.
/// </summary>
private void ReadStandardOutput()
{
if (process != null)
{
processOutput = process.StandardOutput.ReadToEnd();
}
}
}
}

View File

@@ -1,8 +0,0 @@
<?php
/* Rename to config.php */
define(ISO_BASE_URL, "http://www.server.com/iso/");
define(ISO_PATH, "C:\\iso\\");
?>

View File

@@ -1,230 +0,0 @@
<?php
include ('config.php');
function dm_usort_cmp ($a, $b) {
if ($a == $b) return 0;
return ($a > $b) ? -1 : 1;
}
function dm_usort_cmp_desc ($a, $b) {
if ($a == $b) return 0;
return ($a > $b) ? 1 : -1;
}
function printHeader()
{
?>
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>ReactOS Revison ISOs</title>
<meta name="generator" content="Editpad">
<meta name="keywords" content="OS, ReactOS, operating system">
<meta name="author" content="ReactOS Project (ros-dev@reactos.com)">
<style>
.box
{
padding: 0px;
background-color: #88aadd;
border-left: 1px solid #f0f0f0;
border-right: 1px solid #000000;
border-top: 1px solid #f0f0f0;
border-bottom: 1px solid #000000;
}
</style>
</head>
<body bgcolor="#88aadd">
<form method="post" action="">
<?php
}
function printMenu($revision)
{
?>
<table border="0" class="box" cellpadding="5">
<tr>
<td height="2px">
</td>
</tr>
<tr>
<td>
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
<b>Branch:</b>
</td>
<td>
<select name="branch" tabindex="1">
<?php
$d = dir(ISO_PATH);
$i = 0;
$dirlist = array();
while (false !== ($entry = $d->read())) {
if ((strcasecmp($entry, ".") != 0) && (strcasecmp($entry, "..") != 0) && is_dir(ISO_PATH . "\\" . $entry) == "dir") {
$dirlist[$i++] = $entry;
}
}
$d->close();
if (is_array($dirlist)) {
usort($dirlist, "dm_usort_cmp");
reset($dirlist);
while (list($key, $val) = each($dirlist)) {
$branch = $val;
if ($branch == $_POST["branch"] || (!isset($_POST["branch"]) && $branch == "trunk"))
$selected = " selected";
else
$selected = "";
echo "<option$selected>$branch</option>";
}
}
?>
</select>
</td>
<td>
&nbsp;
</td>
<td>
<b>Revision:</b>
</td>
<td>
<?php
echo "<input type=\"text\" name=\"revision\" size=\"10\" maxlength=\"10\" tabindex=\"2\" value=\"" . $revision . "\"></input>";
?>
</td>
<td>
&nbsp;
</td>
<td>
<input type="submit" name="getiso" value="Download" tabindex="3" style="border: 1px solid #000000"></input>
</td>
</tr>
<tr>
<td colspan="7">
<hr size="2" width="100%" />
</td>
</tr>
<tr>
<td colspan="4">
<input type="submit" name="getnextiso" value="Next ISO" tabindex="4" style="border: 1px solid #000000"></input>
</td>
<td colspan="3" align="right">
<input type="submit" name="getlatestiso" value="Latest ISO" tabindex="5" style="border: 1px solid #000000"></input>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="2px">
</td>
</tr>
</table>
<?php
}
function printFooter()
{
?>
</form>
<script>
var revision = document.getElementById('revision');
if (revision) revision.focus();
</script>
</body>
</html>
<?php
}
function locateRevisionISO($branch, $revision, $latest)
{
$revision = intval($revision);
$path = ISO_PATH . "\\" . $branch;
$d = dir($path);
$i = 0;
$filelist = array();
while (false !== ($entry = $d->read())) {
if (is_dir($path . "\\" . $entry) != "dir")
$filelist[$i++] = $entry;
}
$d->close();
if (is_array($filelist)) {
$sortFunction = $latest ? "dm_usort_cmp" : "dm_usort_cmp_desc";
usort($filelist, $sortFunction);
reset($filelist);
while (list($key, $filename) = each($filelist)) {
if (ereg('ReactOS-' . $branch . '-r([0-9]*).iso', $filename, $regs))
{
$thisRevision = intval($regs[1]);
if (($latest) && ($thisRevision < $revision))
return $regs[1];
else if ($thisRevision > $revision)
return $regs[1];
$lastRevision = $thisRevision;
}
}
}
return "";
}
function getNextRevisionISO($branch, $revision)
{
return locateRevisionISO($branch, $revision, false);
}
function getLatestRevisionISO($branch)
{
return locateRevisionISO($branch, 999999, true);
}
function main()
{
$branch = $_POST["branch"];
$revision = $_POST["revision"];
$filename = "ReactOS-" . $branch . "-r" . $revision . ".iso";
if (file_exists(ISO_PATH . $branch . "\\" . $filename))
{
$location = ISO_BASE_URL . $branch . "/" . $filename;
header("Location: $location");
return;
}
else
{
printHeader();
printMenu($_POST["revision"]);
echo "<br><b>No ISO exist for branch '" . $branch . "' and revision " . $revision . ".</b><br><br>";
printFooter();
}
}
if (!empty($_POST["getiso"]) && !empty($_POST["branch"]) && !empty($_POST["revision"]) && is_numeric($_POST["revision"]))
main();
else if (!empty($_POST["getnextiso"]) && !empty($_POST["branch"]) && !empty($_POST["revision"]) && is_numeric($_POST["revision"]))
{
printHeader();
printMenu(getNextRevisionISO($_POST["branch"], $_POST["revision"]));
printFooter();
}
else if (!empty($_POST["getlatestiso"]) && !empty($_POST["branch"]))
{
printHeader();
printMenu(getLatestRevisionISO($_POST["branch"]));
printFooter();
}
else
{
printHeader();
printMenu($_POST["revision"]);
printFooter();
}
?>

View File

@@ -1,9 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="smtpServer" value="localhost" />
<add key="errorEmail" value="mailbox@somewhere-on-the-net" />
<add key="makeParameters" value="" />
<add key="fastDisk" value="" />
</appSettings>
</configuration>

View File

@@ -1,14 +0,0 @@
using System.Reflection;
using System.Runtime.CompilerServices;
[assembly: AssemblyTitle("ReactOS Sin Verifier")]
[assembly: AssemblyDescription("ReactOS Sin Verifier")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("ReactOS Project")]
[assembly: AssemblyProduct("React Operating System")]
[assembly: AssemblyCopyright("Copyright 2005 ReactOS Project")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyDelaySign(false)]
[assembly: AssemblyKeyFile("")]

View File

@@ -1,20 +0,0 @@
<?xml version="1.0"?>
<project name="ReactOS.Verify" default="build">
<property name="output.dir" value="bin" />
<target name="build" description="Build component">
<mkdir dir="${output.dir}" />
<csc target="exe"
output="${output.dir}\ReactOS.Verify.exe"
optimize="true"
debug="true"
doc="${output.dir}\ReactOS.Verify.xml"
warninglevel="0">
<sources>
<include name="*.cs" />
</sources>
</csc>
</target>
</project>

View File

@@ -1,279 +0,0 @@
using System;
using System.IO;
using System.Diagnostics;
using System.Configuration;
using System.Web.Mail;
using System.Collections;
using System.Collections.Specialized;
namespace ReactOS.Verify
{
public class MainClass
{
/// <summary>
/// Run the application.
/// </summary>
/// <param name="script">Script to run.</param>
/// <param name="args">Arguments to pass to script.</param>
/// <param name="workingDirectory">Working directory.</param>
/// <param name="standardOutput">Receives standard output.</param>
/// <param name="standardError">Receives standard error.</param>
/// <returns>
/// Exit code.
/// </returns>
private static int RunScript(string script,
string args,
string workingDirectory,
StringDictionary environmentVarables,
out string standardOutput,
out string standardError)
{
ProcessStartInfo scriptProcessStartInfo = new ProcessStartInfo(script,
args);
scriptProcessStartInfo.CreateNoWindow = true;
/*
* All standard streams must be redirected.
* Otherwise DuplicateHandle() will fail.
*/
scriptProcessStartInfo.RedirectStandardInput = true;
scriptProcessStartInfo.RedirectStandardError = true;
scriptProcessStartInfo.RedirectStandardOutput = true;
scriptProcessStartInfo.UseShellExecute = false;
scriptProcessStartInfo.WorkingDirectory = workingDirectory;
if (environmentVarables != null)
{
foreach (DictionaryEntry de in environmentVarables)
scriptProcessStartInfo.EnvironmentVariables.Add(de.Key as string, de.Value as string);
}
RedirectableProcess redirectableProcess = new RedirectableProcess(scriptProcessStartInfo);
standardOutput = redirectableProcess.ProcessOutput;
standardError = redirectableProcess.ProcessError;
return redirectableProcess.ExitCode;
}
/// <summary>
/// Retrieve value of configuration from configuration file.
/// </summary>
/// <param name="name">Name of configuration option.</param>
/// <param name="defaultValue">
/// Default value to be returned if the option does not exist.
/// </param>
/// <returns>
/// Value of configuration option or null if the option does not
/// exist and no default value is provided.
/// </returns>
private static string GetConfigurationOption(string name,
string defaultValue)
{
if (ConfigurationSettings.AppSettings[name] != null)
{
string s = ConfigurationSettings.AppSettings[name].Trim();
return s.Equals(String.Empty) ? defaultValue : s;
}
else
return defaultValue;
}
/// <summary>
/// Send an email.
/// </summary>
/// <param name="subject">Subject of the email.</param>
/// <param name="body">Content of the email.</param>
private static void SendErrorMail(string subject, string body)
{
try
{
string smtpServer = GetConfigurationOption("smtpServer", "localhost");
string email = GetConfigurationOption("errorEmail", null);
if (email == null)
return;
MailMessage mm = new MailMessage();
mm.Priority = MailPriority.Normal;
mm.From = email;
mm.To = email;
mm.Subject = subject;
mm.Body += body;
mm.Body += "<br>";
mm.BodyFormat = MailFormat.Html;
SmtpMail.SmtpServer = smtpServer;
SmtpMail.Send(mm);
}
catch (Exception ex)
{
Console.Error.WriteLine(ex.Message);
}
}
/// <summary>
/// Fail with an error message.
/// </summary>
/// <param name="text">Error message.</param>
private static void Fail(string text)
{
Console.WriteLine(text);
}
/// <summary>
/// Paths to fast disk for temporary files.
/// </summary>
private static string TemporaryFastDisk
{
get
{
string temporaryFastDisk = GetConfigurationOption("temporaryFastDisk", null);
if (temporaryFastDisk == null || temporaryFastDisk.Trim().Equals(String.Empty))
return null;
return temporaryFastDisk.Trim();
}
}
/// <summary>
/// Paths to fast disk for intermediate files.
/// </summary>
private static string IntermediateFastDisk
{
get
{
string intermediateFastDisk = GetConfigurationOption("intermediateFastDisk", null);
if (intermediateFastDisk == null || intermediateFastDisk.Trim().Equals(String.Empty))
return null;
return intermediateFastDisk.Trim();
}
}
/// <summary>
/// Paths to fast disk for output files.
/// </summary>
private static string OutputFastDisk
{
get
{
string outputFastDisk = GetConfigurationOption("outputFastDisk", null);
if (outputFastDisk == null || outputFastDisk.Trim().Equals(String.Empty))
return null;
return outputFastDisk.Trim();
}
}
/// <summary>
/// Return collection of environment variables.
/// </summary>
/// <returns>Collection of environment variables or null if there is none.</returns>
private static StringDictionary GetEnvironmentVarables()
{
StringDictionary environmentVarables = new StringDictionary();
if (TemporaryFastDisk != null)
environmentVarables.Add("ROS_TEMPORARY", TemporaryFastDisk);
if (IntermediateFastDisk != null)
environmentVarables.Add("ROS_INTERMEDIATE", IntermediateFastDisk);
if (OutputFastDisk != null)
environmentVarables.Add("ROS_OUTPUT", OutputFastDisk);
return environmentVarables;
}
/// <summary>
/// Run make.
/// </summary>
/// <param name="arguments">Arguments.</param>
/// <param name="standardOutput">Receives standard output.</param>
/// <param name="standardError">Receives standard error.</param>
/// <returns>Make exit code.</returns>
private static int RunMake(string arguments,
out string standardOutput,
out string standardError)
{
string make = "mingw32-make";
string makeParameters = GetConfigurationOption("makeParameters", "");
string reactosDirectory = Path.Combine(System.Environment.CurrentDirectory,
"reactos");
return RunScript(make,
makeParameters + " " + arguments,
reactosDirectory,
GetEnvironmentVarables(),
out standardOutput,
out standardError);
}
/// <summary>
/// Verify a revision of ReactOS by building it all.
/// </summary>
private static int VerifyFull()
{
string standardOutput;
string standardError;
int exitCode = RunMake("bootcd",
out standardOutput,
out standardError);
if (exitCode != 0)
{
Fail(String.Format("make bootcd failed: (error: {0}) {1}",
standardError,
standardOutput));
return exitCode;
}
string reactosDirectory = Path.Combine(System.Environment.CurrentDirectory,
"reactos");
string isoFilename = Path.Combine(reactosDirectory,
"ReactOS.iso");
if (!File.Exists(isoFilename))
Fail("make bootcd produced no ReactOS.iso");
return exitCode;
}
/// <summary>
/// Verify a revision of ReactOS by building parts.
/// </summary>
/// <param name="components">Comma separated list of components to build.</param>
private static int VerifyPartial(string components)
{
string standardOutput;
string standardError;
string componentParameters = "\"" + components.Replace(",", "\" \"") + "\"";
int exitCode = RunMake(componentParameters,
out standardOutput,
out standardError);
if (exitCode != 0)
Fail(String.Format("make failed for targets {0}: (error: {1}) {2}",
componentParameters,
standardError,
standardOutput));
return exitCode;
}
/// <summary>
/// Verify a revision of ReactOS.
/// </summary>
/// <param name="args">Arguments from command line.</param>
private static int Verify(string[] args)
{
if (args.Length > 0)
return VerifyPartial(args[0]);
else
return VerifyFull();
}
/// <summary>
/// Program entry point.
/// </summary>
/// <param name="args">Arguments from command line.</param>
/// <remarks>
/// If exit code is 0, then the commit was processed successfully.
/// If exit code is 1, then the commit was not processed successfully.
/// </remarks>
public static void Main(string[] args)
{
try
{
System.Environment.ExitCode = Verify(args);
}
catch (Exception ex)
{
string text = String.Format("Exception: {0}", ex);
SendErrorMail("ReactOS Verify Error", text);
System.Environment.ExitCode = 1;
}
}
}
}

View File

@@ -1,145 +0,0 @@
/*
* When using the ProcessStartInfo.RedirectStandardXxx properties there is a chance of
* the parent and child process blocking due to a race condition. This class handles the
* problem.
* http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdiagnosticsprocessstartinfoclassredirectstandardoutputtopic.asp
*/
using System;
using System.IO;
using System.Threading;
using System.Diagnostics;
namespace ReactOS.Verify
{
/// <summary>
/// Process that redirects standard output and standard error streams.
/// </summary>
public class RedirectableProcess
{
/// <summary>
/// Process.
/// </summary>
private Process process;
/// <summary>
/// Redirected standard error stream.
/// </summary>
private string processError;
/// <summary>
/// Redirected standard output stream.
/// </summary>
private string processOutput;
/// <summary>
/// Exit code.
/// </summary>
private int exitCode;
/// <summary>
/// Redirected standard error stream.
/// </summary>
public string ProcessError
{
get
{
return processError;
}
}
/// <summary>
/// Redirected standard output stream.
/// </summary>
public string ProcessOutput
{
get
{
return processOutput;
}
}
/// <summary>
/// Exit code.
/// </summary>
public int ExitCode
{
get
{
return exitCode;
}
}
/// <summary>
/// Run an excutable and redirect standard error and/or standard output safely.
/// </summary>
public RedirectableProcess(ProcessStartInfo processStartInfo)
{
Run(processStartInfo, null);
}
/// <summary>
/// Run an excutable and redirect standard error and/or standard output safely.
/// </summary>
public RedirectableProcess(ProcessStartInfo processStartInfo, string input)
{
Run(processStartInfo, input);
}
private void Run(ProcessStartInfo processStartInfo, string input)
{
process = new Process();
process.StartInfo = processStartInfo;
process.Start();
if (processStartInfo.RedirectStandardInput && input != null)
{
process.StandardInput.AutoFlush = true;
process.StandardInput.WriteLine(input);
}
Thread readStandardError = null;
if (processStartInfo.RedirectStandardError)
{
readStandardError = new Thread(new ThreadStart(ReadStandardError));
readStandardError.Start();
}
Thread readStandardOutput = null;
if (processStartInfo.RedirectStandardOutput)
{
readStandardOutput = new Thread(new ThreadStart(ReadStandardOutput));
readStandardOutput.Start();
}
if (processStartInfo.RedirectStandardError)
{
readStandardError.Join();
}
if (processStartInfo.RedirectStandardOutput)
{
readStandardOutput.Join();
}
process.WaitForExit();
exitCode = process.ExitCode;
process = null;
}
/// <summary>
/// Read standard error thread entry-point.
/// </summary>
private void ReadStandardError()
{
if (process != null)
{
processError = process.StandardError.ReadToEnd();
}
}
/// <summary>
/// Read standard output thread entry-point.
/// </summary>
private void ReadStandardOutput()
{
if (process != null)
{
processOutput = process.StandardOutput.ReadToEnd();
}
}
}
}

View File

@@ -1,2 +0,0 @@
*.ncb
*.opt

View File

@@ -1,102 +0,0 @@
ReactOS Microsoft Visual C/C++ 6.0 IDE files
This is the Microsoft Visual C/C++ 6.0 project workspace and project
files for a few of the ReactOS binaries. They are ONLY included as a
convenience, and is NOT to be considered supported, or even correct.
If you build a binary that misbehaves using these files, you _might_
be able to get in touch with someone to fix the problem
BUT DO NOT COUNT ON IT!
The only supported build system for ReactOS is the one documented at
www.reactos.com.
------------------------------------------------------------------
Please, before you start playing with this, read the whole of
this document.
Before you can use these project files, you _need_ to make a successful
build using the normal ReactOS build system. There are some vital files
that needs to be created, and currently only the normal build creates these.
Once that is done, you need to generate the kernel-mode service "table"
file by running nmake (from this point on you can use the "native"
MSVC tools) from the directory MSVC6\iface\native.
This will generate MSVC6\ntoskrnl\nt_zw_msvc.c, an MSVC compatible inline-
assembler version of the file otherwise known as reactos\ntoskrnl\nt\zw.c.
Next, go to def_converter and run nmake. This builds the tool to convert
the .def files for HAL and the kernel from the MinGW format to something
more suitable for the MSVC linker, and also generates these .def files
to their target location [1].
Now you should be set to fire up the IDE and load the project workspace.
When building HAL or the kernel for the first time using these
project files, just doing it the "normal" way _will not work_.
The linker will complain about missing library, and it will fail.
The reason for this is a circular dependency between these two binaries.
Currently you need to follow these procedures [2]:
- Select hal as your active project.
- Select Project/Settings.
- Select the Link tab.
- Select "General" from the Category drop-list.
- Temporary remove the explicit linker library
(e.g. "..\ntoskrnl\Debug\ntoskrnl.lib")
- Select "Customize" from the Category drop-list.
- Check the "Force file output" checkbox.
- Build hal.
- Uncheck "Force file output".
- Put back the removed import library.
- Now build the ntoskrnl. Do NOT try to build hal again until
you have sucessfully built the kernel, and the linker has
generated its import library!
- Now you can "Clean" hal, and build it as usual.
If everything worked as expected, you should now have both ntoskrnl.exe
and hal.dll freshly built.
LIMITATIONS/DEVIATIONS (from the MinGW build):
- Since there can only be one resource file/project, the kernel had
to choose between either its version resource, or its message table.
The messages won.
- Do NOT open the .rc files in the IDE's resource editor. Chances are
it will assume ownership over them and fill them up with at least
conditional compilation macros.
NOTES:
[1] This is needed due to differences in handling of decorated names
in .def files. While both MinGW GCC and MSVC generates decorated names
in the same way for at least plain cdecl and stdcall C functions, the
MSVC linker expects names in the .def file to be either
- an exact match of the decorated name, in case it exports the
decorated name from the linked binary, or
- just the name without any decoration, in case it exports just the
name of the symbol from the linked binary (to allow for e.g.
GetProcAddress using the undecorated name) - but keeps the decorated
names in the import library to handle and "redirect" linker requests
for those decorated symbols, and point them to the undercorated names
in the binary exporting them - so that a binary A, at link time,
importing symbols from binary B of the form "_name@0" will resolve
that symbol from the import library, but the linked binary A will
reference it as just "name".
The ROS .def files contains a mix, "half-decorated", where the leading
undescores are missing, but the trailing "@n" (for stdcall functions)
are present.
[2] Theoretically it could be possible to use a hal.lib generated by the
following procedure, removing the need for the manual steps above.
cd MSVC6\hal\Debug
lib \def:..\..\..\reactos\hal\hal\hal.def
but I have not tested it, and take no responsibility for its effectiveness.

View File

@@ -1,41 +0,0 @@
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "hal"=.\hal\hal.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "ntoskrnl"=.\ntoskrnl\ntoskrnl.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################

View File

@@ -1,64 +0,0 @@
// Uses hard-coded filenames to require a minimum of input.
// You think this file should be licensed? OK then,
// Copyright (C) 2004, Mike Nordell. Use as you whish.
#include <fstream>
#include <string>
#include <algorithm>
const char szSrc1[] = "..\\..\\reactos\\ntoskrnl\\ntoskrnl.def";
const char szDst1[] = "..\\ntoskrnl\\ntoskrnl.def";
const char szSrc2[] = "..\\..\\reactos\\hal\\hal\\hal.def";
const char szDst2[] = "..\\hal\\hal.def";
enum File
{
Kernel,
HAL
};
std::string do_kernel_replacements(std::string& s)
{
std::string s2 = s.c_str(); // to fixup size after replacements
if (s2 == "ExAllocateFromPagedLookasideList") {
s2 += "=ExiAllocateFromPagedLookasideList";
} else
if (s2 == "ExFreeToPagedLookasideList") {
s2 += "=ExiFreeToPagedLookasideList";
} else
if (s2 == "MmLockPagableImageSection") {
s2 += "=MmLockPagableDataSection";
}
return s2;
}
void convert_def(const char* szSrc, const char* szDst, File file)
{
using namespace std;
ifstream in(szSrc);
ofstream out(szDst);
string s;
while (getline(in, s).good()) {
if (!s.size()) {
continue;
}
if (s[0] != ';') { // only replace non-comment lines
if (s[0] == '@') {
s.erase(0, 1);
}
replace(s.begin(), s.end(), '@', '\0');
if (file == Kernel) {
s = do_kernel_replacements(s);
}
}
out << s << endl;
}
}
int main()
{
convert_def(szSrc1, szDst1, Kernel);
convert_def(szSrc2, szDst2, HAL);
return 0;
}

View File

@@ -1,19 +0,0 @@
# $Id$
#
# ReactOS Operating System - .def converter for HAL and the kernel
#
DEF_HAL = ..\hal\hal.def
DEF_KRNL = ..\ntoskrnl\ntoskrnl.def
CPPFLAGS = /GX
all: def_converter.exe $(DEF_HAL) $(DEF_KRNL)
$(DEF_HAL) : ..\..\reactos\hal\hal\hal.def
def_converter.exe
$(DEF_KRNL) : ..\..\reactos\ntoskrnl\ntoskrnl.def
def_converter.exe
def_converter.exe : def_converter.cpp

View File

@@ -1,3 +0,0 @@
Debug
Release
hal.def

View File

@@ -1,243 +0,0 @@
# Microsoft Developer Studio Project File - Name="hal" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=hal - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "hal.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "hal.mak" CFG="hal - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "hal - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "hal - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "hal - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "HAL_EXPORTS" /YX /FD /c
# ADD CPP /nologo /MT /W3 /Ot /Og /Os /Ob1 /I "..\..\reactos\include" /I "..\..\reactos\hal\halx86\include" /I "..\..\reactos\ntoskrnl\include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "i386" /D "__NTHAL__" /FD /c
# SUBTRACT CPP /YX
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x41d /d "NDEBUG"
# ADD RSC /l 0x417 /i "..\..\reactos\include" /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 /nologo /dll /machine:I386
# ADD LINK32 ..\ntoskrnl\Release\ntoskrnl.lib /nologo /dll /machine:I386 /fixed:no
# SUBTRACT LINK32 /pdb:none /force
!ELSEIF "$(CFG)" == "hal - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "HAL_EXPORTS" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Z7 /Od /I "..\..\reactos\include" /I "..\..\reactos\hal\halx86\include" /I "..\..\reactos\ntoskrnl\include" /D "_WINDOWS" /D "__NTHAL__" /D "_DEBUG" /D "WIN32" /D "_MBCS" /D "i386" /FD /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x41d /d "_DEBUG"
# ADD RSC /l 0x417 /i "..\..\reactos\include" /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 /nologo /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 ..\ntoskrnl\Debug\ntoskrnl.lib /nologo /dll /incremental:no /debug /machine:I386 /pdbtype:sept /fixed:no
# SUBTRACT LINK32 /pdb:none
!ENDIF
# Begin Target
# Name "hal - Win32 Release"
# Name "hal - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=..\..\reactos\hal\halx86\adapter.c
# End Source File
# Begin Source File
SOURCE=..\..\reactos\hal\halx86\beep.c
# End Source File
# Begin Source File
SOURCE=..\..\reactos\hal\halx86\bus.c
# End Source File
# Begin Source File
SOURCE=..\..\reactos\hal\halx86\display.c
# End Source File
# Begin Source File
SOURCE=..\..\reactos\hal\halx86\dma.c
# End Source File
# Begin Source File
SOURCE=..\..\reactos\hal\halx86\drive.c
# End Source File
# Begin Source File
SOURCE=..\..\reactos\hal\halx86\enum.c
# End Source File
# Begin Source File
SOURCE=..\..\reactos\hal\halx86\fmutex.c
# End Source File
# Begin Source File
SOURCE=..\..\reactos\hal\halx86\fmutex_tmn.c
# PROP Exclude_From_Build 1
# End Source File
# Begin Source File
SOURCE=..\..\reactos\hal\halx86\halinit.c
# End Source File
# Begin Source File
SOURCE=..\..\reactos\hal\halx86\halx86mp.rc
# PROP Exclude_From_Build 1
# End Source File
# Begin Source File
SOURCE=..\..\reactos\hal\halx86\halx86up.rc
# End Source File
# Begin Source File
SOURCE=..\..\reactos\hal\halx86\irql.c
# End Source File
# Begin Source File
SOURCE=..\..\reactos\hal\halx86\isa.c
# End Source File
# Begin Source File
SOURCE=..\..\reactos\hal\halx86\kdbg.c
# End Source File
# Begin Source File
SOURCE=..\..\reactos\hal\halx86\mca.c
# End Source File
# Begin Source File
SOURCE=..\..\reactos\hal\halx86\misc.c
# End Source File
# Begin Source File
SOURCE=..\..\reactos\hal\halx86\mp.c
# End Source File
# Begin Source File
SOURCE=..\..\reactos\hal\halx86\mpsirql.c
# PROP Exclude_From_Build 1
# End Source File
# Begin Source File
SOURCE=..\..\reactos\hal\halx86\pci.c
# End Source File
# Begin Source File
SOURCE=..\..\reactos\hal\halx86\portio.c
# End Source File
# Begin Source File
SOURCE=..\..\reactos\hal\halx86\pwroff.c
# PROP Exclude_From_Build 1
# End Source File
# Begin Source File
SOURCE=..\..\reactos\hal\halx86\reboot.c
# End Source File
# Begin Source File
SOURCE=..\..\reactos\hal\halx86\spinlock.c
# End Source File
# Begin Source File
SOURCE=..\..\reactos\hal\halx86\spinlock_tmn.c
# PROP Exclude_From_Build 1
# End Source File
# Begin Source File
SOURCE=..\..\reactos\hal\halx86\sysbus.c
# End Source File
# Begin Source File
SOURCE=..\..\reactos\hal\halx86\sysinfo.c
# End Source File
# Begin Source File
SOURCE=..\..\reactos\hal\halx86\time.c
# End Source File
# Begin Source File
SOURCE=..\..\reactos\hal\halx86\timer.c
# End Source File
# End Group
# Begin Group "include"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=..\..\reactos\hal\halx86\include\bus.h
# End Source File
# Begin Source File
SOURCE=..\..\reactos\hal\halx86\include\hal.h
# End Source File
# Begin Source File
SOURCE=..\..\reactos\hal\halx86\include\mps.h
# End Source File
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# Begin Source File
SOURCE=.\hal.def
# End Source File
# End Target
# End Project

View File

@@ -1,392 +0,0 @@
/* $Id$
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS version of ntdll
* FILE: iface/native/genntdll.c
* PURPOSE: Generates the system call stubs in ntdll
* CHANGE HISTORY: Added a '@xx' to deal with stdcall [ Ariadne ]
* 19990616 (ea)
* Four arguments now required; 4th is the file
* for ntoskrnl ZwXXX functions (which are merely calls
* to twin NtXXX calls, via int 0x2e (x86).
* 19990617 (ea)
* Fixed a bug in function numbers in kernel ZwXXX stubs.
*
*/
/* INCLUDE ******************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define PARAMETERIZED_LIBS
/* #define VERBOSE */
#define INPUT_BUFFER_SIZE 255
/* FUNCTIONS ****************************************************************/
void write_syscall_stub(FILE* out, FILE* out3, char* name, char* name2,
char* nr_args, unsigned int sys_call_idx)
{
int i;
int nArgBytes = atoi(nr_args);
#ifdef PARAMETERIZED_LIBS
fprintf(out,"__asm__(\"\\n\\t.global _%s@%s\\n\\t\"\n",name,nr_args);
fprintf(out,"\".global _%s@%s\\n\\t\"\n",name2,nr_args);
fprintf(out,"\"_%s@%s:\\n\\t\"\n",name,nr_args);
fprintf(out,"\"_%s@%s:\\n\\t\"\n",name2,nr_args);
#else
fprintf(out,"__asm__(\"\\n\\t.global _%s\\n\\t\"\n",name);
fprintf(out,"\".global _%s\\n\\t\"\n",name2);
fprintf(out,"\"_%s:\\n\\t\"\n",name);
fprintf(out,"\"_%s:\\n\\t\"\n",name2);
#endif
fprintf(out,"\t\"pushl\t%%ebp\\n\\t\"\n");
fprintf(out,"\t\"movl\t%%esp, %%ebp\\n\\t\"\n");
fprintf(out,"\t\"mov\t$%d,%%eax\\n\\t\"\n",sys_call_idx);
fprintf(out,"\t\"lea\t8(%%ebp),%%edx\\n\\t\"\n");
fprintf(out,"\t\"int\t$0x2E\\n\\t\"\n");
fprintf(out,"\t\"popl\t%%ebp\\n\\t\"\n");
fprintf(out,"\t\"ret\t$%s\\n\\t\");\n\n",nr_args);
/*
* Now write the NTOSKRNL stub for the
* current system call. ZwXXX does NOT
* alias the corresponding NtXXX call.
*/
#if 0
fprintf(out3,"__asm__(\n");
fprintf(out3,"\".global _%s@%s\\n\\t\"\n",name2,nr_args);
fprintf(out3,"\"_%s@%s:\\n\\t\"\n",name2,nr_args);
fprintf(out3,"\t\"pushl\t%%ebp\\n\\t\"\n");
fprintf(out3,"\t\"movl\t%%esp, %%ebp\\n\\t\"\n");
fprintf(out3,"\t\"mov\t$%d,%%eax\\n\\t\"\n",sys_call_idx);
fprintf(out3,"\t\"lea\t8(%%ebp),%%edx\\n\\t\"\n");
fprintf(out3,"\t\"int\t$0x2E\\n\\t\"\n");
fprintf(out3,"\t\"popl\t%%ebp\\n\\t\"\n");
fprintf(out3,"\t\"ret\t$%s\\n\\t\");\n\n",nr_args);
#else
fprintf(out3,"__declspec(naked) __stdcall\n");
fprintf(out3,"%s(", name2); // make it emit callconv, reval and full signature too
for (i=0; i*4 < nArgBytes; ++i) {
fprintf(out3,"int dummy%d", i);
if (((i+1)*4) < nArgBytes) fprintf(out3,",");
}
fprintf(out3,")\n{\n");
fprintf(out3,"\t__asm {\n");
fprintf(out3,"\t\tpush\tebp\n");
fprintf(out3,"\t\tmov\tebp, esp\n");
fprintf(out3,"\t\tmov\teax,%d\n",sys_call_idx);
fprintf(out3,"\t\tlea\tedx, 8[ebp]\n");
fprintf(out3,"\t\tint\t0x2E\n");
fprintf(out3,"\t\tpop\tebp\n");
fprintf(out3,"\t\tret\t%s\n",nr_args);
fprintf(out3,"\t}\n");
fprintf(out3,"}\n\n");
#endif
}
int makeSystemServiceTable(FILE *in, FILE *out)
{
char line [INPUT_BUFFER_SIZE];
char *s;
char *name;
char *name2;
int sys_call_idx;
char *nr_args;
char *stmp;
/*
* Main SSDT Header
*/
fprintf(out,"// Machine generated, don't edit\n");
fprintf(out,"\n\n");
/*
* First we build the Main SSDT
*/
fprintf(out,"\n\n\n");
fprintf(out,"SSDT MainSSDT[] = {\n");
for ( /* First system call has index zero */
sys_call_idx = 0;
/* Go on until EOF or read zero bytes */
( (!feof(in))
&& (fgets(line, sizeof line, in) != NULL)
);
/* Next system call index */
sys_call_idx++
)
{
if ((s = (char *) strchr(line,'\r')) != NULL)
{
*s = '\0';
}
/*
* Skip comments (#) and empty lines.
*/
s = & line[0];
if ((*s) != '#' && (*s) != '\0')
{
/* Extract the NtXXX name */
name = (char *)strtok(s," \t");
/* Extract the ZwXXX name */
name2 = (char *)strtok(NULL," \t");
//value = strtok(NULL," \t");
/* Extract the stack size */
nr_args = (char *)strtok(NULL," \t");
/*
* Remove, if present, the trailing LF.
*/
if ((stmp = strchr(nr_args, '\n')) != NULL)
{
*stmp = '\0';
}
#ifdef VERBOSE
printf("%3d \"%s\"\n",sys_call_idx,name);
#endif
if (sys_call_idx > 0)
{
fprintf(out,",\n");
}
/*
* Now write the current system call's name
* in the service table.
*/
fprintf(out,"\t\t{ (ULONG)%s }",name);
}
}
/* Close the service table (C syntax) */
fprintf(out,"\n};\n");
/*
* Now we build the Main SSPT
*/
rewind(in);
fprintf(out,"\n\n\n");
fprintf(out,"SSPT MainSSPT[] = {\n");
for ( /* First system call has index zero */
sys_call_idx = 0;
/* Go on until EOF or read zero bytes */
( (!feof(in))
&& (fgets(line, sizeof line, in) != NULL)
);
/* Next system call index */
sys_call_idx++
)
{
if ((s = (char *) strchr(line,'\r')) != NULL)
{
*s = '\0';
}
/*
* Skip comments (#) and empty lines.
*/
s = & line[0];
if ((*s) != '#' && (*s) != '\0')
{
/* Extract the NtXXX name */
name = (char *)strtok(s," \t");
/* Extract the ZwXXX name */
name2 = (char *)strtok(NULL," \t");
//value = strtok(NULL," \t");
/* Extract the stack size */
nr_args = (char *)strtok(NULL," \t");
/*
* Remove, if present, the trailing LF.
*/
if ((stmp = strchr(nr_args, '\n')) != NULL)
{
*stmp = '\0';
}
#ifdef VERBOSE
printf("%3d \"%s\"\n",sys_call_idx,name);
#endif
if (sys_call_idx > 0)
{
fprintf(out,",\n");
}
/*
* Now write the current system call's ID
* in the service table along with its Parameters Size.
*/
fprintf(out,"\t\t{ %s }",nr_args);
}
}
/*
* Close the service table (C syntax)
*/
fprintf(out,"\n};\n");
/*
* We write some useful defines
*/
fprintf(out, "\n\n#define MIN_SYSCALL_NUMBER 0\n");
fprintf(out, "#define MAX_SYSCALL_NUMBER %d\n", sys_call_idx-1);
fprintf(out, "#define NUMBER_OF_SYSCALLS %d\n", sys_call_idx);
return(0);
}
int
process(
FILE * in,
FILE * out,
FILE * out2,
FILE * out3
)
{
char line [INPUT_BUFFER_SIZE];
char * s;
char * name; /* NtXXX name */
char * name2; /* ZwXXX name */
int sys_call_idx; /* NtXXX index number in the service table */
char * nr_args; /* stack_size / machine_word_size */
char * stmp;
/*
* NTDLL stubs file header
*/
fprintf(out,"// Machine generated, don't edit\n");
fprintf(out,"\n\n");
/*
* NTOSKRNL Zw functions stubs header
*/
fprintf(out3,"// Machine generated by genntdll, don't edit\n");
fprintf(out3,"\n\n");
/*
* Scan the database. DB is a text file; each line
* is a record, which contains data for one system
* function. Each record has three columns:
*
* NT_NAME (e.g. NtCreateProcess)
* ZW_NAME (e.g. ZwCreateProcess)
* STACK_SIZE (in machine words: for x[3456]86
* processors a machine word is 4 bytes)
*/
for ( /* First system call has index zero */
sys_call_idx = 0;
/* Go on until EOF or read zero bytes */
( (!feof(in))
&& (fgets(line, sizeof line, in) != NULL)
);
/* Next system call index */
sys_call_idx++
)
{
/*
* Remove, if present, the trailing CR.
* (os specific?)
*/
if ((s = (char *) strchr(line,'\r')) != NULL)
{
*s = '\0';
}
/*
* Skip comments (#) and empty lines.
*/
s = & line[0];
if ((*s) != '#' && (*s) != '\0')
{
/* Extract the NtXXX name */
name = (char *)strtok(s," \t");
/* Extract the ZwXXX name */
name2 = (char *)strtok(NULL," \t");
//value = strtok(NULL," \t");
/* Extract the stack size */
nr_args = (char *)strtok(NULL," \t");
/*
* Remove, if present, the trailing LF.
*/
if ((stmp = strchr(nr_args, '\n')) != NULL)
{
*stmp = '\0';
}
#ifdef VERBOSE
printf("%3d \"%s\"\n",sys_call_idx,name);
#endif
/*
* Write the NTDLL stub for the current
* system call: NtXXX and ZwXXX symbols
* are aliases.
*/
write_syscall_stub(out, out3, name, name2,
nr_args, sys_call_idx);
}
}
return(0);
}
void usage(char * argv0)
{
printf("Usage: %s sysfuncs.lst napi.c napi.h zw.c\n"
" sysfuncs.lst system functions database\n"
" napi.c NTDLL stubs\n"
" napi.h NTOSKRNL service table\n"
" zw.c NTOSKRNL Zw stubs\n",
argv0
);
}
int main(int argc, char* argv[])
{
FILE * in; /* System calls database */
FILE * out1; /* NTDLL stubs */
FILE * out2; /* SERVICE_TABLE */
FILE * out3; /* NTOSKRNL Zw stubs */
int ret;
if (argc != 5)
{
usage(argv[0]);
return(1);
}
in = fopen(argv[1],"rb");
if (in == NULL)
{
perror("Failed to open input file (system calls database)");
return(1);
}
out1 = fopen(argv[2],"wb");
if (out1 == NULL)
{
perror("Failed to open output file (NTDLL stubs)");
return(1);
}
out2 = fopen(argv[3],"wb");
if (out2 == NULL)
{
perror("Failed to open output file (NTOSKRNL service table)");
return(1);
}
out3 = fopen(argv[4],"wb");
if (out3 == NULL)
{
perror("Failed to open output file (NTOSKRNL Zw stubs)");
return(1);
}
ret = process(in,out1,out2,out3);
rewind(in);
ret = makeSystemServiceTable(in, out2);
fclose(in);
fclose(out1);
fclose(out2);
fclose(out3);
return(ret);
}

View File

@@ -1,22 +0,0 @@
# $Id$
#
# ReactOS Operating System - MSVC6 Zw functions stubs to call generator
#
SYSTEM_CALLS_DB = ..\..\..\reactos\iface\native\sysfuncs.lst
KERNEL_ZW_CALLS =..\..\ntoskrnl\nt_zw_msvc.c
all: genntdll.exe $(KERNEL_ZW_CALLS)
$(KERNEL_ZW_CALLS) : $(SYSTEM_CALLS_DB)
genntdll.exe $(SYSTEM_CALLS_DB) foo1 foo2 $(KERNEL_ZW_CALLS)
-@del foo1
-@del foo2
genntdll.exe : genntdll.c
clean:
-@del *.exe
-@del *.obj
-@del $(KERNEL_ZW_CALLS)

View File

@@ -1,4 +0,0 @@
Debug
Release
nt_zw_msvc.c
ntoskrnl.def

View File

@@ -1,167 +0,0 @@
/*
* ReactOS kernel
* Copyright (C) 2000 David Welch <welch@cwcom.net>
*
* Moved to MSVC-compatible inline assembler by Mike Nordell, 2003-12-25
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id$
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/ke/i386/bthread.S
* PURPOSE: Trap handlers
* PROGRAMMER: David Welch (david.welch@seh.ox.ac.uk)
*/
/* INCLUDES ******************************************************************/
#include <ddk/ntddk.h>
#include <ddk/status.h>
#include <internal/i386/segment.h>
#include <internal/i386/fpu.h>
#include <internal/ps.h>
#include <ddk/defines.h>
/* Values for contextflags */
#define CONTEXT_i386 0x10000
#ifndef CONTEXT_CONTROL
#define CONTEXT_CONTROL (CONTEXT_i386 | 1)
#endif
#ifndef CONTEXT_INTEGER
#define CONTEXT_INTEGER (CONTEXT_i386 | 2)
#endif
#ifndef CONTEXT_SEGMENTS
#define CONTEXT_SEGMENTS (CONTEXT_i386 | 4)
#endif
#ifndef CONTEXT_FLOATING_POINT
#define CONTEXT_FLOATING_POINT (CONTEXT_i386 | 8)
#endif
#ifndef CONTEXT_DEBUG_REGISTERS
#define CONTEXT_DEBUG_REGISTERS (CONTEXT_i386 | 0x10)
#endif
#ifndef CONTEXT_FULL
#define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS)
#endif
/* FUNCTIONS *****************************************************************/
void KeReturnFromSystemCallWithHook();
VOID PiBeforeBeginThread(CONTEXT c);
/*
*
*/
__declspec(naked)
VOID PsBeginThread(PKSTART_ROUTINE StartRoutine, PVOID StartContext)
{
/*
* This isn't really a function, we are called as the return address
* of the context switch function
*/
/*
* Do the necessary prolog after a context switch
*/
__asm
{
call PiBeforeBeginThread
/*
* Call the actual start of the thread
*/
// We must NOT use the arguments by name. VC then uses EBP-relative
// addressing, and with an EBP of 0 you can imagine what happens.
mov ebx, 4[esp] // StartRoutine
mov eax, 8[esp] // StartContext
push eax
call ebx /* Call the start routine */
add esp, 4
/*
* Terminate the thread
*/
push eax
call PsTerminateSystemThread
add esp, 4
}
/* If that fails then bug check */
KeBugCheck(0);
/* And if that fails then loop */
for (;;)
; // forever
}
__declspec(naked)
VOID PsBeginThreadWithContextInternal(VOID)
{
/*
* This isn't really a function, we are called as the return
* address of a context switch
*/
/*
* Do the necessary prolog before the context switch
*/
__asm
{
call PiBeforeBeginThread
/*
* Load the context flags.
*/
pop ebx
/*
* Load the debugging registers
*/
test ebx, (CONTEXT_DEBUG_REGISTERS & ~CONTEXT_i386)
jz L1
pop eax __asm mov dr0, eax
pop eax __asm mov dr1, eax
pop eax __asm mov dr2, eax
pop eax __asm mov dr3, eax
pop eax __asm mov dr6, eax
pop eax __asm mov dr7, eax
jmp L3
L1:
add esp, 24
L3:
/*
* Load the floating point registers
*/
mov eax, HardwareMathSupport
test eax,eax
jz L2
test ebx, (CONTEXT_FLOATING_POINT & ~CONTEXT_i386)
jz L2
frstor [esp]
L2:
add esp, 112
/* Load the rest of the thread's user mode context. */
mov eax, 0
jmp KeReturnFromSystemCallWithHook
}
}

View File

@@ -1,114 +0,0 @@
/*
* ReactOS kernel
* Copyright (C) 2000 David Welch <welch@cwcom.net>
*
* Moved to MSVC-compatible inline assembler by Mike Nordell, 2003-12-26
*
* 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.
*/
/*
* FILE: ntoskrnl/ke/i386/vm86_sup.S
* PURPOSE: V86 mode support
* PROGRAMMER: David Welch (welch@cwcom.net)
* UPDATE HISTORY:
* Created 09/10/00
*/
/* INCLUDES ******************************************************************/
#pragma hdrstop
#include <ddk/ntddk.h>
#include <ddk/status.h>
#include <internal/i386/segment.h>
#include <internal/i386/fpu.h>
#include <internal/ps.h>
#include <ddk/defines.h>
#include <internal/v86m.h>
#include <ntos/tss.h>
#include <internal/trap.h>
#include <internal/ps.h>
#include <roscfg.h>
#include <internal/ntoskrnl.h>
#include <internal/i386/segment.h>
// no arg-list, but asm doesn't care anyway
void KiInterruptDispatch();
#define DEFINE_INT_HANDLER(N) \
__declspec(naked) \
void irq_handler_##N() \
{ \
__asm pushad \
__asm push ds \
__asm push es \
__asm push fs \
__asm mov eax, 0xceafbeef \
__asm push eax \
__asm mov ax, KERNEL_DS \
__asm mov ds, ax \
__asm mov es, ax \
__asm mov ax, PCR_SELECTOR \
__asm mov fs, ax \
__asm push esp \
__asm push N \
__asm call KiInterruptDispatch \
__asm pop eax \
__asm pop eax \
__asm pop eax \
__asm pop fs \
__asm pop es \
__asm pop ds \
__asm popad \
__asm iretd
// NOTE: The inline assembler can't deal with having the final brace,
// ending the function, on the same line as an __asm, why there is
// none here and it MUST be added when using the macro!
DEFINE_INT_HANDLER(0)
}
DEFINE_INT_HANDLER(1)
}
DEFINE_INT_HANDLER(2)
}
DEFINE_INT_HANDLER(3)
}
DEFINE_INT_HANDLER(4)
}
DEFINE_INT_HANDLER(5)
}
DEFINE_INT_HANDLER(6)
}
DEFINE_INT_HANDLER(7)
}
DEFINE_INT_HANDLER(8)
}
DEFINE_INT_HANDLER(9)
}
DEFINE_INT_HANDLER(10)
}
DEFINE_INT_HANDLER(11)
}
DEFINE_INT_HANDLER(12)
}
DEFINE_INT_HANDLER(13)
}
DEFINE_INT_HANDLER(14)
}
DEFINE_INT_HANDLER(15)
}

View File

@@ -1,655 +0,0 @@
/*
* ReactOS kernel
* Copyright (C) 2003 Mike Nordell
* Based on multiboot.S (no copyright note present), but so heavily
* modified that it bears close to no resemblance to the original work.
*
* MSVC compatible combination of plain C and inline assembler to:
* 1 Relocated all the sections in the kernel - something I feel the
* bootloader should have done, but multiboot being just a "raw image"
* loader, it unfortunately had to be done here - in-place.
* 2 Set up page directories and stuff.
* 3 Load IDT, GDT and turn on paging, making us execute at the intended
* target address (as if the image was PE-loaded and parsed into that addr.)
* 4 Call _main, and let the rest of the startup run...
*
* 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.
*/
//
// TODO: Fix the MP parts
//
/* INCLUDES ******************************************************************/
#pragma hdrstop
#include <ddk/ntddk.h>
#include <ddk/status.h>
#include <internal/i386/segment.h>
#include <internal/i386/fpu.h>
#include <internal/ps.h>
#include <ddk/defines.h>
#include <pe.h>
#include <roscfg.h>
#include <internal/ntoskrnl.h>
#include <internal/i386/segment.h>
#include <internal/ps.h>
#include <internal/ldr.h>
// some notes:
// The MSVC linker (by defult) emits no special .bss section, but uses the data
// section with a rawsize smaller than virtualsize. The "slack" is BSS.
//////////////////////////////////////////////////////////////////
// Some macros we need
// some stuff straight from freeloaders multiboot.h
#define MULTIBOOT_HEADER_MAGIC (0x1BADB002)
#define MULTIBOOT_HEADER_FLAGS (0x00010003)
#define TARGET_LOAD_ADDR 0x00200000
#define BASE_TO_PHYS_DIST (KERNEL_BASE - TARGET_LOAD_ADDR)
#define V2P(x) (x - BASE_TO_PHYS_DIST)
#ifdef MP
#define AP_MAGIC (0x12481020)
#endif /* MP */
void initialize_page_directory(void);
void* relocate_pointer_log_to_phys(const void* p)
{
// DON'T CALL this function until relocation of .data and/or .rdata,
// is completed - but still be sure that we have not yet enabled paging!
return (void*)((DWORD)p - BASE_TO_PHYS_DIST);
}
#ifdef _DEBUG
// Macro to emit one character to Bochs debug-port (0x9e).
// We need to do it this way, since at this point of the startup, obviously
// we have neither HAL nor DbgPrint support.
#define BOCHS_OUT_CHAR(c1) __asm push eax __asm push edx __asm mov dx, 0xe9 __asm mov al, c1 __asm out dx, al __asm pop edx __asm pop eax
void boch_out_hex_digit(unsigned char ch1)
{
if (ch1 <= 9) { ch1 += '0'; } else { ch1 += 'a' - 10; }
BOCHS_OUT_CHAR(ch1)
}
void bochs_dump_hex(DWORD p)
{
unsigned char ch3 = (unsigned char)((p >> 28) & 0x0f);
unsigned char cl3 = (unsigned char)((p >> 24) & 0x0f);
unsigned char ch2 = (unsigned char)((p >> 20) & 0x0f);
unsigned char cl2 = (unsigned char)((p >> 16) & 0x0f);
unsigned char ch1 = (unsigned char)((p >> 12) & 0x0f);
unsigned char cl1 = (unsigned char)((p >> 8) & 0x0f);
unsigned char ch0 = (unsigned char)((p >> 4) & 0x0f);
unsigned char cl0 = (unsigned char)((p >> 0) & 0x0f);
BOCHS_OUT_CHAR('0') BOCHS_OUT_CHAR('x')
boch_out_hex_digit(ch3);
boch_out_hex_digit(cl3);
boch_out_hex_digit(ch2);
boch_out_hex_digit(cl2);
boch_out_hex_digit(ch1);
boch_out_hex_digit(cl1);
boch_out_hex_digit(ch0);
boch_out_hex_digit(cl0);
BOCHS_OUT_CHAR('\n')
}
static void bochs_out_string(const char* s /* logical address! */)
{
s = relocate_pointer_log_to_phys(s);
__asm
{
pushad
mov dx, 0xe9
mov ebx, s
L1:
cmp byte ptr[ebx], 0
je end
mov al, [ebx]
out dx, al
inc ebx
jmp L1
end:
popad
}
}
#else
#define BOCHS_OUT_CHAR(c1)
#define bochs_dump_hex(VAL)
#define bochs_out_string(STR)
#endif // _DEBUG
//////////////////////////////////////////////////////////////////
typedef char kernel_page_t[4096];
// Use 4096 (pagesize) more bytes that actually needed for each *_holder,
// to be able to make sure that the other stuff is page aligned.
// No other way to do this portably... :-(
//
// TODO: Consider allocating just one large block of BSS memory here, align
// just the first pointer, and then get the other ones just as offsets from
// this (now-aligned) pointer. That way we could get away with wasting just
// one page of memory, instead of 4 (like 16KB would matter... but still)
static kernel_page_t* startup_pagedirectory_holder[1024 * 2];
static kernel_page_t* lowmem_pagetable_holder[1024 * 2];
static kernel_page_t* kernel_pagetable_holder[32*1024 + 1];
static __int32 kpcr_pagetable_holder[4096/4 * 2];
#ifdef MP
char apic_pagetable[4096];
#endif /* MP */
__int32 unmap_me[4096/4];
__int32 unmap_me2[4096/4];
__int32 unmap_me3[4096/4];
__int32 init_stack[3*4096/4];
int init_stack_top;
__int32 trap_stack[3*4096/4];
int trap_stack_top;
void _main();
// lie a bit about types - since C is basically typeless anyway, it
// doesn't really matter what type we say it is here...
extern int KiGdtDescriptor;
extern int KiIdtDescriptor;
/*
* This is called by the realmode loader, with protected mode
* enabled, paging disabled and the segment registers pointing
* a 4Gb, 32-bit segment starting at zero.
*
* EAX = Multiboot magic or application processor magic
*
* EBX = Points to a structure in lowmem with data from the
* loader
*/
#pragma intrinsic(memset)
// We need to implement this ourself, to be able to get to it by short call's
void our_memmove(void* pDest, const void* pSrc, DWORD size)
{
char* pD = (char*)pDest;
const char* pS = (char*)pSrc;
if (pDest < pSrc)
{
while (size--)
{
*pD++ = *pS++;
}
}
else if (pSrc < pDest)
{
while (size--)
{
pD[size] = pS[size];
}
}
}
void dummy_placeholder(void)
{
// NOTE: This function MUST be placed JUST AFTER MultibootStub in memory.
// Yes, it's BEFORE it in this file, but linkorder.txt fixes this for us.
}
// This one is needed, since the boot loader hasn't relocated us
__declspec(naked)
void MultibootStub()
{
__asm
{
jmp _multiboot_entry
// This sucks, I know...
#define EMIT_DWORD(x) __asm __emit ((x) >> 0) & 0xff __asm _emit ((x) >> 8) & 0xff __asm _emit ((x) >> 16) & 0xff __asm _emit ((x) >> 24) & 0xff
ALIGN 4
EMIT_DWORD(MULTIBOOT_HEADER_MAGIC)
EMIT_DWORD(MULTIBOOT_HEADER_FLAGS)
EMIT_DWORD(-(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS))
EMIT_DWORD(TARGET_LOAD_ADDR + 0x0400 + 0x04)
// Now just make something up, since there is no way we can know, beforehand,
// where any BSS data is...
EMIT_DWORD((TARGET_LOAD_ADDR))
EMIT_DWORD((TARGET_LOAD_ADDR + 1*1024*1024)) /* assume ntoskrnel.exe is < 1MB! */
EMIT_DWORD((TARGET_LOAD_ADDR + 2*1024*1024)) /* just to have something, let's say BSS is 1MB too */
/* This is *REALLY* ugly! If MultibootStub is *EVER* at */
/* any other offset, this will crash like crazy! */
/* 0x0400 is the file alignment of the binary (ntoskrnl.exe) */
EMIT_DWORD((TARGET_LOAD_ADDR + 0x0400)) // entry_addr
_multiboot_entry:
cld // just for good measure
}
{
/* Save the multiboot or application processor magic */
DWORD saved_eax;
DWORD saved_ebx;
__asm mov saved_eax, eax
__asm mov saved_ebx, ebx
// bochs_out_string("MultibootStub()\n");
// OK, time to relocate the brute-loaded image in-place...
// If we don't watch it, we will overwrite ourselves here - imagine
// the fireworks! :-) That's why the function dummy_placeholder()
// MUST be placed JUST JUST AFTER this function.
{
PIMAGE_NT_HEADERS NtHeader = RtlImageNtHeader((PVOID)TARGET_LOAD_ADDR);
PIMAGE_SECTION_HEADER Section = IMAGE_FIRST_SECTION(NtHeader);
const int count = NtHeader->FileHeader.NumberOfSections;
int i;
Section += count - 1; // make it point to the last section
// NOTE: We MUST walk the sections "backwards".
for (i = count-1; i >= 0; --i, --Section)
{
DWORD dwSrc = TARGET_LOAD_ADDR + Section->PointerToRawData;
DWORD dwDst = TARGET_LOAD_ADDR + Section->VirtualAddress;
DWORD dwSiz = Section->SizeOfRawData;
const char* pEndThisFunc;
if (dwSrc == dwDst)
{
continue;
}
//bochs_out_string("MultibootStub: relocating section\n");
if (Section->Characteristics & IMAGE_SCN_MEM_EXECUTE)
{
// can't get a pointer to a label from plain C :-(
__asm mov pEndThisFunc, offset dummy_placeholder
pEndThisFunc -= BASE_TO_PHYS_DIST;
if (dwDst < (DWORD)pEndThisFunc)
{
// We must not move the code from under our feet!
// This can only happen in the code segment - the first segment
DWORD diff = (DWORD)pEndThisFunc - dwDst;
dwDst += diff;
dwSrc += diff;
dwSiz -= diff;
}
}
// obviously we must use memmove, since memory can overlap
our_memmove((void*)dwDst, (void*)dwSrc, dwSiz);
// While at it, we might as well zero any uninitialized data in the section...
if (Section->SizeOfRawData < Section->Misc.VirtualSize)
{
memset((char*)(Section->VirtualAddress + Section->SizeOfRawData + TARGET_LOAD_ADDR),
0,
Section->Misc.VirtualSize - Section->SizeOfRawData);
}
}
// Now all sections are relocated to their intended in-memory layout,
// but we are still running int the low TARGET_LOAD_ADDR memory.
{
// Time to jump to the real startup, the entry-point function.
// We must do this using assembler, since both eax and ebx are assumed
// to hold some magic values.
typedef VOID (STDCALL* pfn_t)(PPEB);
pfn_t pfn = (pfn_t)(NtHeader->OptionalHeader.AddressOfEntryPoint + TARGET_LOAD_ADDR);
#if 1
__asm mov eax, saved_eax
__asm mov ebx, saved_ebx
__asm mov ecx, pfn
__asm jmp ecx
#else
__asm mov ebx, saved_ebx
(*pfn)((PPEB)saved_eax);
#endif
}
}
}
}
// TMN: TODO: Convert this to the extent possible to plain C code
// Due to the "magic" above, we enter this function with all kernel sections
// properly relocated wrt. offsets from start-of-mem. But, we are still running
// without paging, meaning that the address that is to be KERNEL_BASE+xyz is
// currently still TARGET_LOAD_ADDR+xyz.
// We get aways with a few of the functions call here since they are near calls
// (PC-relative), but don't even _think_ about calling any other functions
// until we have turned on paging!
VOID STDCALL
NtProcessStartup(
IN PPEB Peb
)
{
DWORD saved_ebx;
DWORD saved_eax;
__asm mov saved_ebx, ebx
__asm mov saved_eax, eax
bochs_out_string("NtProcessStartup: Just entered\n");
#ifdef MP
if (saved_eax != AP_MAGIC)
{
#endif /* MP */
bochs_out_string("NtProcessStartup: Calling initialize_page_directory()\n");
initialize_page_directory(); // Initialize the page directory
bochs_out_string("NtProcessStartup: Page directory initialized\n");
#ifdef MP
__asm
{
/*
* Initialize the page table that maps the APIC register address space
*/
/*
* FIXME: APIC register address space can be non-standard so do the
* mapping later
*/
mov esi, V2P(apic_pagetable)
mov edi, 0
mov eax, 0xFEC0001B
mov [esi+edi], eax
mov edi, 0x800
mov eax, 0xFEE0001B
mov [esi+edi], eax
}
}
#endif /* MP */
{
bochs_out_string("NtProcessStartup: Enabling paging...\n");
/*
* Enable paging and set write protect
* bit 31: PG, bit 16: WP
*/
__asm mov eax, cr0
__asm or eax, 0x80010000
__asm mov cr0, eax
bochs_out_string("NtProcessStartup: Paging enabled!\n");
bochs_out_string("NtProcessStartup: But we're still at the \"low\" address\n");
/*
* Do an absolute jump because we now want to execute above KERNEL_BASE
*/
__asm mov eax, offset l2_
__asm jmp eax
}
l2_:
bochs_out_string("We have now left \"low\" memory, and is flying at an altitude of...\n");
bochs_out_string("OK, we're not flying, we're just executing above KERNEL_BASE\n");
/*
* Load the GDTR and IDTR with new tables located above
* KERNEL_BASE
*/
#ifdef _DEBUG
{
DWORD val = (DWORD)&KiGdtDescriptor;
bochs_out_string("&KiGdtDescriptor: ");
bochs_dump_hex(val);
val = (DWORD)&KiIdtDescriptor;
bochs_out_string("&KiIdtDescriptor: ");
bochs_dump_hex(val);
}
#endif
bochs_out_string("Loading GDT and IDT...\n");
/* FIXME: Application processors should have their own GDT/IDT */
__asm lgdt KiGdtDescriptor
__asm lidt KiIdtDescriptor
bochs_out_string("GDT and IDT loaded\n");
__asm
{
/*
* Reload the data segment registers
*/
mov eax, KERNEL_DS
mov ds, ax
mov es, ax
mov gs, ax
mov ss, ax
mov eax, 0
mov fs, ax
}
bochs_out_string("NtProcessStartup: segment registers loaded\n");
#ifdef MP
if (saved_eax == AP_MAGIC)
{
__asm
{
/*
* This is an application processor executing
*/
/*
* Initialize EFLAGS
*/
push 0
popfd
/*
* Call the application processor initialization code
*/
push 0
push offset l7_
push KERNEL_CS
push KiSystemStartup
retf
/*
* Catch illegal returns from KiSystemStartup
*/
l7_:
pop eax
}
KeBugCheck(0);
for (;;)
; /*forever */
}
#endif /* MP */
bochs_out_string("Loading fs with PCR_SELECTOR\n");
/* Load the PCR selector */
__asm mov eax, PCR_SELECTOR
__asm mov fs, ax
bochs_out_string("Loading esp with init_stack_top : "); bochs_dump_hex((DWORD)&init_stack_top);
bochs_out_string("Just for interest, init_stack is at: "); bochs_dump_hex((DWORD)init_stack);
bochs_out_string("Meaing the init_stack in bytes is : "); bochs_dump_hex((DWORD)&init_stack_top - (DWORD)init_stack);
/* Load the initial kernel stack */
__asm mov esp, offset init_stack_top
bochs_out_string("Loaded esp with init_stack_top\n");
/*
* Initialize EFLAGS
*/
__asm push 0
__asm popfd
bochs_out_string("Loaded eflags\n");
/*
* Call the main kernel initialization
*/
bochs_out_string("TMN: Calling _main...\n");
__asm
{
xor ebp,ebp
push ebx
push edx
push offset l5_
push KERNEL_CS
push offset _main
retf
/*
* Catch illegal returns from main, try bug checking the system,
* if that fails then loop forever.
*/
l5_:
pop eax
pop eax
} // end of __asm block
bochs_out_string("TMN: Back from _main ?! Let's crash!\n");
KeBugCheck(0);
for (;;)
; /*forever */
}
void initialize_page_directory(void)
{
/*
* Initialize the page directory
*/
// First convert the pointers from the virtual address the compiler generated
// code thinks we are at, to the currently active physical address we actually
// got loaded into by the loader. At this point we have been relocated, so
// that there is a 1:1 mapping between KERNEL_BASE+n and TARGET_LOAD_ADDR+n.
kernel_page_t** startup_pagedirectory = startup_pagedirectory_holder;
kernel_page_t** lowmem_pagetable = lowmem_pagetable_holder;
kernel_page_t** kernel_pagetable = kernel_pagetable_holder;
__int32* kpcr_pagetable = kpcr_pagetable_holder;
bochs_out_string("startup_pagedirectory before reloc: ");
bochs_dump_hex((DWORD)startup_pagedirectory);
startup_pagedirectory = (kernel_page_t**)relocate_pointer_log_to_phys(startup_pagedirectory);
lowmem_pagetable = (kernel_page_t**)relocate_pointer_log_to_phys(lowmem_pagetable);
kernel_pagetable = (kernel_page_t**)relocate_pointer_log_to_phys(kernel_pagetable);
kpcr_pagetable = (__int32*) relocate_pointer_log_to_phys(kpcr_pagetable);
bochs_out_string("startup_pagedirectory after reloc : ");
bochs_dump_hex((DWORD)startup_pagedirectory);
// Now align the pointers to PAGE_SIZE...
startup_pagedirectory = (kernel_page_t**)(((ULONG_PTR)startup_pagedirectory + 4095) & ~4095);
lowmem_pagetable = (kernel_page_t**)(((ULONG_PTR)lowmem_pagetable + 4095) & ~4095);
kernel_pagetable = (kernel_page_t**)(((ULONG_PTR)kernel_pagetable + 4095) & ~4095);
kpcr_pagetable = (__int32* ) (((ULONG_PTR)kpcr_pagetable + 4095) & ~4095);
#ifdef _DEBUG
bochs_out_string("startup_pagedirectory aligned : ");
bochs_dump_hex((DWORD)startup_pagedirectory);
#endif
// Ugly macros, I know...
#define DEST(PAGE) startup_pagedirectory[(PAGE) + 0xc00 / 4]
#define SRC(PAGE) (kernel_page_t*)((char*)kernel_pagetable + (PAGE)*4096 + 0x7)
startup_pagedirectory[0] = (kernel_page_t*)((char*)lowmem_pagetable + 0x7);
{
unsigned int i;
for (i=0; i<32; ++i)
{
DEST(i) = SRC(i);
}
}
DEST( 64) = (kernel_page_t*)((char*)lowmem_pagetable + 0x7);
DEST(192) = (kernel_page_t*)((char*)startup_pagedirectory + 0x7);
#ifdef MP
DEST(251) = (kernel_page_t*)((char*)apic_pagetable + 0x7);
#endif /* MP */
DEST(252) = (kernel_page_t*)((char*)kpcr_pagetable + 0x7);
{
unsigned int i;
/* Initialize the page table that maps low memory */
for (i=0; i<1024; ++i) {
lowmem_pagetable[i] = (kernel_page_t*)(i*4096 + 7);
}
/* Initialize the page table that maps kernel memory */
for (i=0; i<6144/4 /* 1536 pages = 6MB */; ++i) {
kernel_pagetable[i] = (kernel_page_t*)(i*4096 + TARGET_LOAD_ADDR + 0x7);
}
/* Initialize the page table that maps the initial KPCR (at FF000000) */
kpcr_pagetable[0] = 0x1007;
}
/*
* Set up the PDBR
*/
__asm mov eax, startup_pagedirectory
__asm mov cr3, eax
}

View File

@@ -1,110 +0,0 @@
/*
* ReactOS kernel
* Copyright (C) 2000 David Welch <welch@cwcom.net>
*
* Moved to MSVC-compatible inline assembler by Mike Nordell, 2003-12-26
*
* 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.
*/
/*
* FILE: ntoskrnl/ke/i386/vm86_sup.S
* PURPOSE: V86 mode support
* PROGRAMMER: David Welch (welch@cwcom.net)
* UPDATE HISTORY:
* Created 09/10/00
*/
/* INCLUDES ******************************************************************/
#pragma hdrstop
#include <ddk/ntddk.h>
#include <ddk/status.h>
#include <internal/i386/segment.h>
#include <internal/i386/fpu.h>
#include <internal/ps.h>
#include <ddk/defines.h>
#include <internal/v86m.h>
#include <ntos/tss.h>
//#include <ntos/service.h>
#include <internal/trap.h>
#include <internal/ps.h>
#include <roscfg.h>
#include <internal/ntoskrnl.h>
#include <internal/i386/segment.h>
void KeReturnFromSystemCall();
/*
* FUNCTION: KeStackSwitchAndRet
* PURPOSE: Switch to a new stack and return from the first frame on
* the new stack which was assumed to a stdcall function with
* 8 bytes of arguments and which saved edi, esi and ebx.
*/
__declspec(naked)
VOID STDCALL
KeStackSwitchAndRet(PVOID NewStack)
{
__asm
{
push ebp
mov ebp, esp
cli
mov esp, NewStack
sti
pop edi
pop esi
pop ebx
pop ebp
ret 8
}
}
__declspec(naked)
VOID STDCALL
KePushAndStackSwitchAndSysRet(ULONG Push, PVOID NewStack)
{
__asm
{
push ebp
mov ebp, esp
push ebx
push esi
push edi
cli
push 8[ebp]
mov ebx, fs:KPCR_CURRENT_THREAD
mov KTHREAD_CALLBACK_STACK[ebx], esp
mov esp, 12[ebp]
sti
push 0
call KeLowerIrql
jmp KeReturnFromSystemCall
}
}

View File

@@ -1,325 +0,0 @@
/*
* ReactOS kernel
* Copyright (C) 2000 David Welch <welch@cwcom.net>
*
* Converted to MSVC-compatible inline assembler by Mike Nordell, 2003.
*
* 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.
*/
/*
* FILE: MSVC6/ntoskrnl/ke_i386_syscall.c
* based on ntoskrnl/ke/i386/syscall.s
* PURPOSE: syscall dispatching and support
* PROGRAMMER: David Welch (welch@cwcom.net)
* UPDATE HISTORY:
* Created 09/10/00
*/
/* INCLUDES ******************************************************************/
#pragma hdrstop
#include <ddk/ntddk.h>
#include <ddk/status.h>
#include <internal/i386/segment.h>
#include <internal/i386/fpu.h>
#include <internal/ps.h>
#include <ddk/defines.h>
#include <internal/v86m.h>
#include <ntos/tss.h>
//#include <ntos/service.h>
#include <internal/trap.h>
#include <internal/ps.h>
#include <roscfg.h>
#include <internal/ntoskrnl.h>
#include <internal/i386/segment.h>
#define KernelMode (0)
#define UserMode (1)
// TMN: Replicated here to reduce mess-time
#ifdef STATUS_INVALID_SYSTEM_SERVICE
#undef STATUS_INVALID_SYSTEM_SERVICE
#endif
#define STATUS_INVALID_SYSTEM_SERVICE 0xc000001c
/*
*
*/
void KiServiceCheck (ULONG Nr);
ULONG KiAfterSystemCallHook(ULONG NtStatus, PKTRAP_FRAME TrapFrame);
VOID KiSystemCallHook(ULONG Nr, ...);
void KeReturnFromSystemCallWithHook();
void KeReturnFromSystemCall();
__declspec(naked)
void interrupt_handler2e(void)
{
__asm
{
/* Construct a trap frame on the stack */
/* Error code */
push 0
push ebp
push ebx
push esi
push edi
push fs
/* Load PCR selector into fs */
mov ebx, PCR_SELECTOR
mov fs, bx
/* Save the old exception list */
mov ebx, fs:KPCR_EXCEPTION_LIST
push ebx
/* Set the exception handler chain terminator */
mov dword ptr fs:KPCR_EXCEPTION_LIST, 0xffffffff
/* Get a pointer to the current thread */
mov esi, fs:KPCR_CURRENT_THREAD
/* Save the old previous mode */
xor ebx,ebx
mov bl, ss:KTHREAD_PREVIOUS_MODE[esi]
push ebx
/* Set the new previous mode based on the saved CS selector */
mov ebx, 0x24[esp]
and ebx, 0x0000FFFF
cmp ebx, KERNEL_CS
#if 0
// TODO: Verify implementation change and use this code path
// to remove two conditional jumps.
setnz bl
mov ss:KTHREAD_PREVIOUS_MODE[esi], bl
#else
jne L1
mov ss:KTHREAD_PREVIOUS_MODE[esi], KernelMode
jmp L3
L1:
mov ss:KTHREAD_PREVIOUS_MODE[esi], UserMode
L3:
#endif
/* Save other registers */
push eax
push ecx
push edx
push ds
push es
push gs
push 0 /* DR7 */
push 0 /* DR6 */
push 0 /* DR3 */
push 0 /* DR2 */
push 0 /* DR1 */
push 0 /* DR0 */
push 0 /* XXX: TempESP */
push 0 /* XXX: TempCS */
push 0 /* XXX: DebugPointer */
push 0 /* XXX: DebugArgMark */
mov ebx, 0x60[esp]
push ebx /* DebugEIP */
push ebp /* DebugEBP */
/* Load the segment registers */
mov bx, KERNEL_DS
mov ds, bx
mov es, bx
mov gs, bx
/*
* Save the old trap frame pointer over where we would save the EDX
* register.
*/
mov ebx, KTHREAD_TRAP_FRAME[esi]
mov 0x3C[esp], ebx
/* Save a pointer to the trap frame in the TCB */
mov KTHREAD_TRAP_FRAME[esi], esp
/* Set ES to kernel segment */
mov bx, KERNEL_DS
mov es, bx
/* Allocate new Kernel stack frame */
mov ebp, esp
/* Users's current stack frame pointer is source */
mov esi, edx
/* Determine system service table to use */
cmp eax, 0x0fff
ja new_useShadowTable
/* Check to see if EAX is valid/inrange */
cmp eax, es:KeServiceDescriptorTable + 8
jbe new_serviceInRange
mov eax, STATUS_INVALID_SYSTEM_SERVICE
jmp KeReturnFromSystemCall
new_serviceInRange:
/* Allocate room for argument list from kernel stack */
mov ecx, es:KeServiceDescriptorTable + 12
mov ecx, es:[ecx + eax * 4]
sub esp, ecx
/* Copy the arguments from the user stack to the kernel stack */
mov edi, esp
cld
repe movsb
/* DS is now also kernel segment */
mov ds, bx
/* Call system call hook */
push eax
call KiSystemCallHook
pop eax
/* Make the system service call */
mov ecx, es:KeServiceDescriptorTable
mov eax, es:[ecx + eax * 4]
call eax
#if CHECKED
/* Bump Service Counter */
#endif
/* Deallocate the kernel stack frame */
mov esp, ebp
/* Call the post system call hook and deliver any pending APCs */
push ebp
push eax
call KiAfterSystemCallHook
add esp, 8
jmp KeReturnFromSystemCall
new_useShadowTable:
sub eax, 0x1000
/* Check to see if EAX is valid/inrange */
cmp eax, es:KeServiceDescriptorTableShadow + 24
jbe new_shadowServiceInRange
mov eax, STATUS_INVALID_SYSTEM_SERVICE
jmp KeReturnFromSystemCall
new_shadowServiceInRange:
/* Allocate room for argument list from kernel stack */
mov ecx, es:KeServiceDescriptorTableShadow + 28
mov ecx, es:[ecx + eax * 4]
sub esp, ecx
/* Copy the arguments from the user stack to the kernel stack */
mov edi, esp
cld
repe movsb
/* DS is now also kernel segment */
mov ds, bx
/* Call system call hook */
// pushl %eax
// call _KiSystemCallHook
// popl %eax
/* Call service check routine */
push eax
call KiServiceCheck
pop eax
/* Make the system service call */
mov ecx, es:KeServiceDescriptorTableShadow + 16
mov eax, es:[ecx + eax * 4]
call eax
#if CHECKED
/* Bump Service Counter */
#endif
/* Deallocate the kernel stack frame */
mov esp, ebp
// TMN: Added, to be able to separate this into different functions
jmp KeReturnFromSystemCallWithHook
}
}
__declspec(naked)
void KeReturnFromSystemCallWithHook()
{
__asm
{
/* Call the post system call hook and deliver any pending APCs */
push esp
push eax
call KiAfterSystemCallHook
add esp, 8
// TMN: Added, to be able to separate this into different functions
jmp KeReturnFromSystemCall
}
}
__declspec(naked)
void KeReturnFromSystemCall()
{
__asm
{
/* Restore the user context */
/* Get a pointer to the current thread */
mov esi, fs:0x124
/* Restore the old trap frame pointer */
mov ebx, 0x3c[esp]
mov KTHREAD_TRAP_FRAME[esi], ebx
/* Skip debug information and unsaved registers */
add esp, 0x30
pop gs
pop es
pop ds
pop edx
pop ecx
add esp, 4 /* Don't restore eax */
/* Restore the old previous mode */
pop ebx
mov ss:KTHREAD_PREVIOUS_MODE[esi], bl
/* Restore the old exception handler list */
pop ebx
mov fs:KPCR_EXCEPTION_LIST, ebx
pop fs
pop edi
pop esi
pop ebx
pop ebp
add esp, 4 /* Ignore error code */
iretd
}
}

View File

@@ -1,468 +0,0 @@
/*
* ReactOS kernel
* Copyright (C) 2000 David Welch <welch@cwcom.net>
*
* Moved to MSVC-compatible inline assembler by Mike Nordell, 2003-12-26
*
* 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.
*/
/*
* FILE: ntoskrnl/ke/i386/vm86_sup.S
* PURPOSE: V86 mode support
* PROGRAMMER: David Welch (welch@cwcom.net)
* UPDATE HISTORY:
* Created 09/10/00
*/
/* INCLUDES ******************************************************************/
#pragma hdrstop
#include <ddk/ntddk.h>
#include <ddk/status.h>
#include <internal/i386/segment.h>
#include <internal/i386/fpu.h>
#include <internal/ps.h>
#include <ddk/defines.h>
#include <internal/v86m.h>
#include <ntos/tss.h>
#include <internal/trap.h>
#include <internal/ps.h>
#include <roscfg.h>
#include <internal/ntoskrnl.h>
#include <internal/i386/segment.h>
void KiV86Complete(void);
void KiTrapHandler(void);
void KiDoubleFaultHandler(void);
extern int KiPcrInitDone;
/*
* Epilog for exception handlers
*/
__declspec(naked)
void KiTrapEpilog()
{
__asm
{
cmp eax, 1 /* Check for v86 recovery */
jne _KiTrapRet
jmp KiV86Complete
_KiTrapRet:
/* Skip debug information and unsaved registers */
add esp, 0x30
pop gs
pop es
pop ds
pop edx
pop ecx
pop eax
/* Restore the old previous mode */
pop ebx
mov ss:KTHREAD_PREVIOUS_MODE[esi], bl
/* Restore the old exception handler list */
pop ebx
mov fs:KPCR_EXCEPTION_LIST, ebx
pop fs
pop edi
pop esi
pop ebx
pop ebp
add esp, 4 /* Ignore error code */
iretd
}
}
__declspec(naked)
void KiTrapProlog()
{
__asm
{
push edi
push fs
/*
* Check that the PCR exists, very early in the boot process it may
* not
*/
cmp ss:KiPcrInitDone, 0
je L5_
/* Load the PCR selector into fs */
mov ebx, PCR_SELECTOR
mov fs, bx
/* Save the old exception list */
mov ebx, fs:KPCR_EXCEPTION_LIST
push ebx
/* Put the exception handler chain terminator */
mov dword ptr fs:KPCR_EXCEPTION_LIST, 0xffffffff
/* Get a pointer to the current thread */
mov edi, fs:KPCR_CURRENT_THREAD
/* The current thread may be NULL early in the boot process */
cmp edi, 0
je L4_
/* Save the old previous mode */
xor ebx, ebx
mov bl, ss:KTHREAD_PREVIOUS_MODE[edi]
push ebx
/* Set the new previous mode based on the saved CS selector */
mov ebx, 0x24[esp]
and ebx, 0x0000FFFF
cmp ebx, KERNEL_CS
jne L1_
mov ss:KTHREAD_PREVIOUS_MODE[edi], KernelMode
jmp L3_
L1_:
mov ss:KTHREAD_PREVIOUS_MODE[edi], UserMode
L3_:
/* Save other registers */
push eax
push ecx
push edx
push ds
push es
push gs
push 0 /* DR7 */
push 0 /* DR6 */
push 0 /* DR3 */
push 0 /* DR2 */
push 0 /* DR1 */
push 0 /* DR0 */
push 0 /* XXX: TempESP */
push 0 /* XXX: TempCS */
push 0 /* XXX: DebugPointer */
push 0 /* XXX: DebugArgMark */
mov ebx, 0x60[esp]
push ebx /* XXX: DebugEIP */
push ebp /* XXX: DebugEBP */
/* Load the segment registers */
mov ebx, KERNEL_DS
mov ds, bx
mov es, bx
mov gs, bx
/* Set ES to kernel segment */
mov bx, KERNEL_DS
mov es, bx
mov ebx, esp
mov ebp, esp
/* Save the old trap frame. */
cmp edi, 0
je L7_
mov edx, ss:KTHREAD_TRAP_FRAME[edi]
push edx
jmp L8_
L7_:
push 0
L8_:
/* Save a pointer to the trap frame in the current KTHREAD */
cmp edi, 0
je L6_
mov ss:KTHREAD_TRAP_FRAME[edi], ebx
L6_:
/* Call the C exception handler */
push esi
push ebx
call KiTrapHandler
add esp, 8
/* Get a pointer to the current thread */
mov esi, fs:KPCR_CURRENT_THREAD
/* Restore the old trap frame pointer */
pop ebx
mov KTHREAD_TRAP_FRAME[esi], ebx
/* Return to the caller */
jmp KiTrapEpilog
/* Handle the no-pcr case out of line */
L5_:
push 0
/* Handle the no-thread case out of line */
L4_:
push 0
jmp L3_
} // end of __asm block
}
__declspec(naked)
void KiTrap0()
{
__asm
{
/* No error code */
push 0
push ebp
push ebx
push esi
mov esi, 0
jmp KiTrapProlog
}
}
__declspec(naked)
void KiTrap1()
{
__asm
{
/* No error code */
push 0
push ebp
push ebx
push esi
mov esi, 1
jmp KiTrapProlog
}
}
__declspec(naked)
void KiTrap2()
{
__asm
{
push 0
push ebp
push ebx
push esi
mov esi, 2
jmp KiTrapProlog
}
}
__declspec(naked)
void KiTrap3()
{
__asm
{
push 0
push ebp
push ebx
push esi
mov esi, 3
jmp KiTrapProlog
}
}
__declspec(naked)
void KiTrap4()
{
__asm
{
push 0
push ebp
push ebx
push esi
mov esi, 4
jmp KiTrapProlog
}
}
__declspec(naked)
void KiTrap5()
{
__asm
{
push 0
push ebp
push ebx
push esi
mov esi, 5
jmp KiTrapProlog
}
}
__declspec(naked)
void KiTrap6()
{
__asm
{
push 0
push ebp
push ebx
push esi
mov esi, 6
jmp KiTrapProlog
}
}
__declspec(naked)
void KiTrap7()
{
__asm
{
push 0
push ebp
push ebx
push esi
mov esi, 7
jmp KiTrapProlog
}
}
__declspec(naked)
void KiTrap8()
{
__asm
{
call KiDoubleFaultHandler
iretd
}
}
__declspec(naked)
void KiTrap9()
{
__asm
{
push 0
push ebp
push ebx
push esi
mov esi, 9
jmp KiTrapProlog
}
}
__declspec(naked)
void KiTrap10()
{
__asm
{
push ebp
push ebx
push esi
mov esi, 10
jmp KiTrapProlog
}
}
__declspec(naked)
void KiTrap11()
{
__asm
{
push ebp
push ebx
push esi
mov esi, 11
jmp KiTrapProlog
}
}
__declspec(naked)
void KiTrap12()
{
__asm
{
push ebp
push ebx
push esi
mov esi, 12
jmp KiTrapProlog
}
}
__declspec(naked)
void KiTrap13()
{
__asm
{
push ebp
push ebx
push esi
mov esi, 13
jmp KiTrapProlog
}
}
__declspec(naked)
void KiTrap14()
{
__asm
{
push ebp
push ebx
push esi
mov esi, 14
jmp KiTrapProlog
}
}
__declspec(naked)
void KiTrap15()
{
__asm
{
push 0
push ebp
push ebx
push esi
mov esi, 15
jmp KiTrapProlog
}
}
__declspec(naked)
void KiTrap16()
{
__asm
{
push 0
push ebp
push ebx
push esi
mov esi, 16
jmp KiTrapProlog
}
}
__declspec(naked)
void KiTrapUnknown()
{
__asm
{
push 0
push ebp
push ebx
push esi
mov esi, 255
jmp KiTrapProlog
}
}
/* EOF */

View File

@@ -1,217 +0,0 @@
/*
* ReactOS kernel
* Copyright (C) 2000 David Welch <welch@cwcom.net>
*
* Moved to MSVC-compatible inline assembler by Mike Nordell, 2003-12-26
*
* 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.
*/
/*
* FILE: ntoskrnl/ke/i386/vm86_sup.S
* PURPOSE: V86 mode support
* PROGRAMMER: David Welch (welch@cwcom.net)
* UPDATE HISTORY:
* Created 09/10/00
*/
/* INCLUDES ******************************************************************/
#pragma hdrstop
#include <ddk/ntddk.h>
#include <ddk/status.h>
#include <internal/i386/segment.h>
#include <internal/i386/fpu.h>
#include <internal/ps.h>
#include <ddk/defines.h>
#include <internal/v86m.h>
#include <ntos/tss.h>
//#include <ntos/service.h>
#include <internal/trap.h>
#include <internal/ps.h>
#include <roscfg.h>
#include <internal/ntoskrnl.h>
#include <internal/i386/segment.h>
extern KSPIN_LOCK PiThreadListLock;
extern ULONG PiNrThreadsAwaitingReaping;
extern ULONG MmGlobalKernelPageDirectory[1024];
VOID STDCALL PiWakeupReaperThread(VOID);
VOID KeSetBaseGdtSelector(ULONG Entry, PVOID Base);
/*
* FUNCTIONS: Switches to another thread's context
* ARGUMENTS:
* Thread = Thread to switch to
* OldThread = Thread to switch from
*/
__declspec(naked)
VOID
Ki386ContextSwitch(struct _KTHREAD* NewThread, struct _KTHREAD* OldThread)
{
__asm
{
push ebp
mov ebp, esp
/* Save callee save registers. */
push ebx
push esi
push edi
cli /* This is a critical section for this processor. */
/* Get the pointer to the new thread. */
mov ebx, NewThread
/*
* Set the base of the TEB selector to the base of the TEB for
* this thread.
*/
push ebx
push KTHREAD_TEB[ebx]
push TEB_SELECTOR
call KeSetBaseGdtSelector
add esp, 8
pop ebx
/*
* Load the PCR selector.
*/
mov eax, PCR_SELECTOR
mov fs, ax
/*
* Set the current thread information in the PCR.
*/
mov fs:KPCR_CURRENT_THREAD, ebx
/*
* Set the current LDT
*/
xor eax, eax
mov edi, ETHREAD_THREADS_PROCESS[ebx]
test word ptr KPROCESS_LDT_DESCRIPTOR0[edi], 0xFFFF
jz L4
push KPROCESS_LDT_DESCRIPTOR1[edi]
push KPROCESS_LDT_DESCRIPTOR0[edi]
push LDT_SELECTOR
call KeSetGdtSelector
add esp, 12
mov eax, LDT_SELECTOR
L4:
lldt ax
/*
* Load up the iomap offset for this thread in
* preparation for setting it below.
*/
mov eax, KPROCESS_IOPM_OFFSET[edi]
/*
* FIXME: Save debugging state.
*/
/*
* FIXME: Save floating point state.
*/
/*
* Switch stacks
*/
mov ebx, 12[ebp]
mov KTHREAD_KERNEL_STACK[ebx], esp
mov ebx, 8[ebp]
mov esp, KTHREAD_KERNEL_STACK[ebx]
mov edi, KTHREAD_STACK_LIMIT[ebx]
/*
* Set the stack pointer in this processors TSS
*/
mov esi, fs:KPCR_TSS
/*
* Set current IOPM offset in the TSS
*/
mov KTSS_IOMAPBASE[esi], ax
mov eax, KTHREAD_INITIAL_STACK[ebx]
mov KTSS_ESP0[esi], eax
/*
* Change the address space
*/
mov ebx, ETHREAD_THREADS_PROCESS[ebx]
mov eax, KPROCESS_DIRECTORY_TABLE_BASE[ebx]
mov cr3, eax
/*
* Set up the PDE for the top of the new stack.
*/
mov ebx, 0
L2:
mov esi, edi
shr esi, 22
mov eax, 0xF03C0000[esi*4]
cmp eax, 0
jne L1
mov eax, MmGlobalKernelPageDirectory[esi*4]
mov 0xF03C0000[esi*4], eax
L1:
add edi, 4096
inc ebx
cmp ebx, (MM_STACK_SIZE / 4096)
jl L2
/*
* FIXME: Restore floating point state
*/
/*
* FIXME: Restore debugging state
*/
/*
* Exit the critical section
*/
sti
}
KeReleaseSpinLockFromDpcLevel(&PiThreadListLock);
if (PiNrThreadsAwaitingReaping) {
PiWakeupReaperThread();
}
__asm
{
/*
* Restore the saved register and exit
*/
pop edi
pop esi
pop ebx
pop ebp
ret
}
}

View File

@@ -1,256 +0,0 @@
/*
* ReactOS kernel
* Copyright (C) 2000 David Welch <welch@cwcom.net>
*
* Moved to MSVC-compatible inline assembler by Mike Nordell, 2003-12-25
*
* 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.
*/
/*
* FILE: ntoskrnl/ke/i386/vm86_sup.S
* PURPOSE: V86 mode support
* PROGRAMMER: David Welch (welch@cwcom.net)
* UPDATE HISTORY:
* Created 09/10/00
*/
/* INCLUDES ******************************************************************/
#pragma hdrstop
#include <ddk/ntddk.h>
#include <ddk/status.h>
#include <internal/i386/segment.h>
#include <internal/i386/fpu.h>
#include <internal/ps.h>
#include <ddk/defines.h>
#include <internal/v86m.h>
#include <ntos/tss.h>
#include <internal/trap.h>
#include <internal/ps.h>
#include <roscfg.h>
#include <internal/ntoskrnl.h>
#include <internal/i386/segment.h>
#include <internal/ps.h>
// Taken from ntoskrnl/include/internal/v86m.h, since that one must be fixed
// a bit before it could be used from here.
#define KV86M_REGISTERS_EBP (0x0)
#define KV86M_REGISTERS_EDI (0x4)
#define KV86M_REGISTERS_ESI (0x8)
#define KV86M_REGISTERS_EDX (0xC)
#define KV86M_REGISTERS_ECX (0x10)
#define KV86M_REGISTERS_EBX (0x14)
#define KV86M_REGISTERS_EAX (0x18)
#define KV86M_REGISTERS_DS (0x1C)
#define KV86M_REGISTERS_ES (0x20)
#define KV86M_REGISTERS_FS (0x24)
#define KV86M_REGISTERS_GS (0x28)
#define KV86M_REGISTERS_EIP (0x2C)
#define KV86M_REGISTERS_CS (0x30)
#define KV86M_REGISTERS_EFLAGS (0x34)
#define KV86M_REGISTERS_ESP (0x38)
#define KV86M_REGISTERS_SS (0x3C)
void KiV86Complete();
/*
* Starts in v86 mode with the registers set to the
* specified values.
*/
__declspec(naked)
VOID Ki386RetToV86Mode(KV86M_REGISTERS* InRegs,
KV86M_REGISTERS* OutRegs)
{
__asm
{
/*
* Setup a stack frame
*/
push ebp
mov ebp, esp
pushad /* Save registers */
mov ebx, InRegs
/*
* Save ebp
*/
push ebp
/*
* Save a pointer to IN_REGS which the v86m exception handler will
* use to handle exceptions
*/
push ebx
/*
* Since we are going to fiddle with the stack pointer this must be
* a critical section for this processor
*/
/*
* Save the old initial stack
*/
mov esi, fs:KPCR_CURRENT_THREAD
mov edi, KTHREAD_INITIAL_STACK[esi]
push edi
/*
* We also need to set the stack in the kthread structure
*/
mov KTHREAD_INITIAL_STACK[esi], esp
/*
* The stack used for handling exceptions from v86 mode in this thread
* will be the current stack adjusted so we don't overwrite the
* existing stack frames
*/
mov esi, fs:KPCR_TSS
mov KTSS_ESP0[esi], esp
/*
* Create the stack frame for an iret to v86 mode
*/
push KV86M_REGISTERS_GS[ebx]
push KV86M_REGISTERS_FS[ebx]
push KV86M_REGISTERS_DS[ebx]
push KV86M_REGISTERS_ES[ebx]
push KV86M_REGISTERS_SS[ebx]
push KV86M_REGISTERS_ESP[ebx]
push KV86M_REGISTERS_EFLAGS[ebx]
push KV86M_REGISTERS_CS[ebx]
push KV86M_REGISTERS_EIP[ebx]
/*
* Setup the CPU registers
*/
mov eax, KV86M_REGISTERS_EAX[ebx]
mov ecx, KV86M_REGISTERS_ECX[ebx]
mov edx, KV86M_REGISTERS_EDX[ebx]
mov esi, KV86M_REGISTERS_ESI[ebx]
mov edi, KV86M_REGISTERS_EDI[ebx]
mov ebp, KV86M_REGISTERS_EBP[ebx]
mov ebx, KV86M_REGISTERS_EBX[ebx]
/*
* Go to v86 mode
*/
iretd
/*
* Handle the completion of a vm86 routine. We are called from
* an exception handler with the registers at the point of the
* exception on the stack.
*/
jmp KiV86Complete // TMN: Function-splitting
}
}
__declspec(naked)
void KiV86Complete()
{
__asm
{
/* Restore the original ebp */
mov ebp, TF_ORIG_EBP[esp]
/* Get a pointer to the OUT_REGS structure */
mov ebx, 12[ebp] // OutRegs
/* Skip debug information and unsaved registers */
add esp, 0x30
/* Ignore 32-bit segment registers */
add esp, 12
/* Save the vm86 registers into the OUT_REGS structure */
pop dword ptr KV86M_REGISTERS_EDX[ebx]
pop dword ptr KV86M_REGISTERS_ECX[ebx]
pop dword ptr KV86M_REGISTERS_EAX[ebx]
/* Restore the old previous mode */
pop eax
mov ss:KTHREAD_PREVIOUS_MODE[esi], al
/* Restore the old exception handler list */
pop eax
mov fs:KPCR_EXCEPTION_LIST, eax
/* Ignore the 32-bit fs register */
add esp, 4
pop dword ptr KV86M_REGISTERS_EDI[ebx]
pop dword ptr KV86M_REGISTERS_ESI[ebx]
pop dword ptr KV86M_REGISTERS_EBX[ebx]
pop dword ptr KV86M_REGISTERS_EBP[ebx]
/* Ignore error code */
add esp, 4
pop dword ptr KV86M_REGISTERS_EIP[ebx]
pop dword ptr KV86M_REGISTERS_CS[ebx]
pop dword ptr KV86M_REGISTERS_EFLAGS[ebx]
pop dword ptr KV86M_REGISTERS_ESP[ebx]
pop dword ptr KV86M_REGISTERS_SS[ebx]
pop dword ptr KV86M_REGISTERS_ES[ebx]
pop dword ptr KV86M_REGISTERS_DS[ebx]
pop dword ptr KV86M_REGISTERS_FS[ebx]
pop dword ptr KV86M_REGISTERS_GS[ebx]
/*
* We are going to fiddle with the stack so this must be a critical
* section for this process
*/
cli
/*
* Restore the initial stack
*/
pop eax
mov esi, fs:KPCR_TSS
mov KTSS_ESP0[esi], eax
/*
* We also need to set the stack in the kthread structure
*/
mov esi, fs:KPCR_CURRENT_THREAD
mov edi, KTHREAD_INITIAL_STACK[esi]
mov KTHREAD_INITIAL_STACK[esi], eax
/* Exit the critical section */
sti
/* Ignore IN_REGS pointer */
add esp, 4
/* Ignore ebp restored above */
add esp, 4
/* Return to caller */
popad
mov esp, ebp
pop ebp
ret
} // end of __asm block
}

View File

@@ -1,15 +0,0 @@
; This file is vital. It tells the linker how to order some functions
; and some data, that unfortunately is assumed to be at low location
; and in known order to eachother respectively?
MultibootStub
our_memmove
dummy_placeholder
NtProcessStartup@4
initialize_page_directory
relocate_pointer_log_to_phys
; Order some data that there is some assumptions about...
init_stack
init_stack_top
trap_stack
trap_stack_top

View File

@@ -1,126 +0,0 @@
#include <ddk/ntddk.h>
void MmSafeCopyToUserRestart();
void MmSafeCopyToUserUnsafeStart();
void MmSafeCopyFromUserUnsafeStart();
void MmSafeCopyFromUserRestart();
/*
* NTSTATUS MmSafeCopyFromUser(PVOID Dest, PVOID Src,
* ULONG NumberOfBytes)
*/
__declspec(naked)
NTSTATUS MmSafeCopyFromUser(PVOID Dest, const VOID *Src, ULONG Count)
{
__asm
{
push ebp
mov ebp,esp
push esi
push edi
push ecx
mov edi, 8[ebp]
mov esi, 12[ebp]
mov ecx, 16[ebp]
/*
* Default return code
*/
xor eax,eax
jmp MmSafeCopyFromUserUnsafeStart
}
}
__declspec(naked)
void MmSafeCopyFromUserUnsafeStart()
{
__asm
{
/*
* This is really a synthetic instruction since if we incur a
* pagefault then eax will be set to an appropiate STATUS code
*/
cld
rep movsb
jmp MmSafeCopyFromUserRestart
}
}
__declspec(naked)
void MmSafeCopyFromUserRestart()
{
__asm
{
pop ecx
pop edi
pop esi
pop ebp
ret
}
}
/*****************************************************************************/
/*
* NTSTATUS MmSafeCopyToUser(PVOID Dest, PVOID Src,
* ULONG NumberOfBytes)
*/
NTSTATUS MmSafeCopyToUser(PVOID Dest, const VOID *Src, ULONG Count)
{
__asm
{
push ebp
mov esp,ebp
push esi
push edi
push ecx
mov edi, 8[ebp]
mov esi, 12[ebp]
mov ecx, 16[ebp]
/*
* Default return code
*/
xor eax,eax
jmp MmSafeCopyToUserUnsafeStart
}
}
__declspec(naked)
void MmSafeCopyToUserUnsafeStart()
{
__asm
{
/*
* This is really a synthetic instruction since if we incur a
* pagefault then eax will be set to an appropiate STATUS code
*/
cld
rep movsb
jmp MmSafeCopyToUserRestart
}
}
__declspec(naked)
void MmSafeCopyToUserRestart()
{
__asm
{
pop ecx
pop edi
pop esi
pop ebp
ret
}
}

View File

@@ -1,574 +0,0 @@
/* $Id$
*
* COPYRIGHT: See COPYING in the top directory
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/mm/mminit.c
* PURPOSE: kernel memory managment initialization functions
* PROGRAMMER: David Welch (welch@cwcom.net)
* UPDATE HISTORY:
* Created 9/4/98
*/
/* INCLUDES *****************************************************************/
#include <ddk/ntddk.h>
#include <roscfg.h>
#include <internal/i386/segment.h>
#include <internal/mm.h>
#include <internal/ntoskrnl.h>
#include <internal/io.h>
#include <internal/ps.h>
#include <internal/pool.h>
#define NDEBUG
#include <internal/debug.h>
/* GLOBALS *****************************************************************/
/*
* Size of extended memory (kb) (fixed for now)
*/
#define EXTENDED_MEMORY_SIZE (3*1024*1024)
/*
* Compiler defined symbols
*/
#if defined(_MSC_VER)
#pragma intrinsic(strcmp)
static PIMAGE_SECTION_HEADER FindSection(const char* szSeg)
{
PIMAGE_NT_HEADERS NtHeader = RtlImageNtHeader((PVOID)KERNEL_BASE);
PIMAGE_SECTION_HEADER Section = IMAGE_FIRST_SECTION(NtHeader);
const int count = NtHeader->FileHeader.NumberOfSections;
int i;
for (i = 0; i < count; ++i, ++Section)
{
if (!strcmp(szSeg, Section->Name))
{
return Section;
}
}
return NULL;
}
static void* FindSegmentStart(const char* szSeg)
{
PIMAGE_SECTION_HEADER Section = FindSection(szSeg);
if (Section)
{
return (void*)(KERNEL_BASE + Section->VirtualAddress);
}
return NULL;
}
static void* FindSegmentEnd(const char* szSeg)
{
PIMAGE_SECTION_HEADER Section = FindSection(szSeg);
if (Section)
{
return (void*)(KERNEL_BASE + Section->VirtualAddress + Section->Misc.VirtualSize);
}
return NULL;
}
#endif // defined(_MSC_VER)
static BOOLEAN IsThisAnNtAsSystem = FALSE;
static MM_SYSTEM_SIZE MmSystemSize = MmSmallSystem;
static MEMORY_AREA* kernel_text_desc = NULL;
static MEMORY_AREA* kernel_init_desc = NULL;
static MEMORY_AREA* kernel_map_desc = NULL;
static MEMORY_AREA* kernel_kpcr_desc = NULL;
static MEMORY_AREA* kernel_data_desc = NULL;
static MEMORY_AREA* kernel_param_desc = NULL;
static MEMORY_AREA* kernel_pool_desc = NULL;
static MEMORY_AREA* kernel_shared_data_desc = NULL;
static MEMORY_AREA* kernel_mapped_low_mem_desc = NULL;
static MEMORY_AREA* MiKernelMapDescriptor = NULL;
static MEMORY_AREA* MiPagedPoolDescriptor = NULL;
PHYSICAL_ADDRESS MmSharedDataPagePhysicalAddress;
PVOID MiNonPagedPoolStart;
ULONG MiNonPagedPoolLength;
PVOID MiKernelMapStart;
ULONG MiKernelMapLength;
/* FUNCTIONS ****************************************************************/
/*
* @implemented
*/
BOOLEAN STDCALL MmIsThisAnNtAsSystem(VOID)
{
return(IsThisAnNtAsSystem);
}
/*
* @implemented
*/
MM_SYSTEM_SIZE STDCALL MmQuerySystemSize(VOID)
{
return(MmSystemSize);
}
VOID MiShutdownMemoryManager(VOID)
{
}
VOID INIT_FUNCTION
MmInitVirtualMemory(ULONG LastKernelAddress,
ULONG KernelLength)
/*
* FUNCTION: Intialize the memory areas list
* ARGUMENTS:
* bp = Pointer to the boot parameters
* kernel_len = Length of the kernel
*/
{
PVOID BaseAddress;
ULONG Length;
ULONG ParamLength = KernelLength;
NTSTATUS Status;
PHYSICAL_ADDRESS BoundaryAddressMultiple;
//ULONG i;
DPRINT("MmInitVirtualMemory(%x, %x)\n",LastKernelAddress, KernelLength);
BoundaryAddressMultiple.QuadPart = 0;
LastKernelAddress = PAGE_ROUND_UP(LastKernelAddress);
MmInitMemoryAreas();
/* Don't change the start of kernel map. Pte's must always exist for this region. */
MiKernelMapStart = (char*)LastKernelAddress + PAGE_SIZE;
MiKernelMapLength = MM_KERNEL_MAP_SIZE;
MiNonPagedPoolStart = (char*)MiKernelMapStart + MiKernelMapLength + PAGE_SIZE;
MiNonPagedPoolLength = MM_NONPAGED_POOL_SIZE;
MmPagedPoolBase = (char*)MiNonPagedPoolStart + MiNonPagedPoolLength + PAGE_SIZE;
MmPagedPoolSize = MM_PAGED_POOL_SIZE;
MiInitKernelMap();
MiInitializeNonPagedPool();
/*
* Setup the system area descriptor list
*/
BaseAddress = (PVOID)0xf0000000;
MmCreateMemoryArea(NULL,
MmGetKernelAddressSpace(),
MEMORY_AREA_SYSTEM,
&BaseAddress,
0x400000,
0,
&kernel_map_desc,
FALSE,
FALSE,
BoundaryAddressMultiple);
BaseAddress = (PVOID)KPCR_BASE;
MmCreateMemoryArea(NULL,
MmGetKernelAddressSpace(),
MEMORY_AREA_SYSTEM,
&BaseAddress,
PAGE_SIZE * MAXIMUM_PROCESSORS,
0,
&kernel_kpcr_desc,
FALSE,
FALSE,
BoundaryAddressMultiple);
BaseAddress = (PVOID)0xd0000000;
MmCreateMemoryArea(NULL,
MmGetKernelAddressSpace(),
MEMORY_AREA_SYSTEM,
&BaseAddress,
0x100000,
0,
&kernel_mapped_low_mem_desc,
FALSE,
FALSE,
BoundaryAddressMultiple);
BaseAddress = (PVOID)KERNEL_BASE;
Length = PAGE_ROUND_UP(((ULONG)FindSegmentEnd(".text"))) - KERNEL_BASE;
ParamLength = ParamLength - Length;
/*
* No need to lock the address space at this point since no
* other threads are running.
*/
MmCreateMemoryArea(NULL,
MmGetKernelAddressSpace(),
MEMORY_AREA_SYSTEM,
&BaseAddress,
Length,
0,
&kernel_text_desc,
FALSE,
FALSE,
BoundaryAddressMultiple);
// TODO: Here we REALLY should iterate the PE's sections and set protection
// accordingly for each and every one of them.
// NOTE This code ONLY works because of the assumption that the .text
// segment is the first in the PE, and the .reloc segment is the last.
// Link in a way to make this assumtion false, and the kernel won't work.
BaseAddress = (PVOID)PAGE_ROUND_UP(((ULONG)FindSegmentEnd(".text")));
Length = PAGE_ROUND_UP(((ULONG)FindSegmentStart(".reloc"))) - (ULONG_PTR)BaseAddress;
ParamLength = ParamLength - Length;
DPRINT1("Data Length %x\n",Length);
DPRINT1("Data BaseAddress %x\n",BaseAddress);
/*
* No need to lock the address space at this point since we are
* the only thread running.
*/
// For GCC-compiled, kernel_data_desc contains:
// .data, .edata, .idata, .bss and .rsrc. E.i. all but .text and .reloc
MmCreateMemoryArea(NULL,
MmGetKernelAddressSpace(),
MEMORY_AREA_SYSTEM,
&BaseAddress,
Length,
0,
&kernel_data_desc,
FALSE,
FALSE,
BoundaryAddressMultiple);
// BaseAddress = (PVOID)PAGE_ROUND_UP(((ULONG)FindSegmentEnd(".edata")));
BaseAddress = (PVOID)PAGE_ROUND_UP(((ULONG)FindSegmentStart(".reloc")));
Length = LastKernelAddress - (ULONG)BaseAddress;
// For GCC-compiled, kernel_param_desc contains .reloc
MmCreateMemoryArea(NULL,
MmGetKernelAddressSpace(),
MEMORY_AREA_SYSTEM,
&BaseAddress,
Length,
0,
&kernel_param_desc,
FALSE,
FALSE,
BoundaryAddressMultiple);
BaseAddress = MiNonPagedPoolStart;
MmCreateMemoryArea(NULL,
MmGetKernelAddressSpace(),
MEMORY_AREA_SYSTEM,
&BaseAddress,
MiNonPagedPoolLength,
0,
&kernel_pool_desc,
FALSE,
FALSE,
BoundaryAddressMultiple);
BaseAddress = MiKernelMapStart;
Status = MmCreateMemoryArea(NULL,
MmGetKernelAddressSpace(),
MEMORY_AREA_SYSTEM,
&BaseAddress,
MiKernelMapLength,
0,
&MiKernelMapDescriptor,
FALSE,
FALSE,
BoundaryAddressMultiple);
BaseAddress = MmPagedPoolBase;
Status = MmCreateMemoryArea(NULL,
MmGetKernelAddressSpace(),
MEMORY_AREA_PAGED_POOL,
&BaseAddress,
MmPagedPoolSize,
0,
&MiPagedPoolDescriptor,
FALSE,
FALSE,
BoundaryAddressMultiple);
MmInitializePagedPool();
/*
* Create the kernel mapping of the user/kernel shared memory.
*/
BaseAddress = (PVOID)KI_USER_SHARED_DATA;
Length = PAGE_SIZE;
MmCreateMemoryArea(NULL,
MmGetKernelAddressSpace(),
MEMORY_AREA_SYSTEM,
&BaseAddress,
Length,
0,
&kernel_shared_data_desc,
FALSE,
FALSE,
BoundaryAddressMultiple);
Status = MmRequestPageMemoryConsumer(MC_NPPOOL, TRUE,
&MmSharedDataPagePhysicalAddress);
Status = MmCreateVirtualMapping(NULL,
(PVOID)KI_USER_SHARED_DATA,
PAGE_READWRITE,
MmSharedDataPagePhysicalAddress,
TRUE);
if (!NT_SUCCESS(Status))
{
DbgPrint("Unable to create virtual mapping\n");
KEBUGCHECK(0);
}
RtlZeroMemory(BaseAddress, Length);
/*
*
*/
MmInitializeMemoryConsumer(MC_USER, MmTrimUserMemory);
}
VOID INIT_FUNCTION
MmInit1(ULONG FirstKrnlPhysAddr,
ULONG LastKrnlPhysAddr,
ULONG LastKernelAddress,
PADDRESS_RANGE BIOSMemoryMap,
ULONG AddressRangeCount,
ULONG MaxMem)
/*
* FUNCTION: Initalize memory managment
*/
{
ULONG i;
ULONG kernel_len;
#ifndef MP
extern unsigned int unmap_me, unmap_me2, unmap_me3;
#endif
DPRINT("MmInit1(FirstKrnlPhysAddr, %x, LastKrnlPhysAddr %x, LastKernelAddress %x)\n",
FirstKrnlPhysAddr,
LastKrnlPhysAddr,
LastKernelAddress);
if ((BIOSMemoryMap != NULL) && (AddressRangeCount > 0))
{
// If we have a bios memory map, recalulate the memory size
ULONG last = 0;
for (i = 0; i < AddressRangeCount; i++)
{
if (BIOSMemoryMap[i].Type == 1
&& (BIOSMemoryMap[i].BaseAddrLow + BIOSMemoryMap[i].LengthLow + PAGE_SIZE -1) / PAGE_SIZE > last)
{
last = (BIOSMemoryMap[i].BaseAddrLow + BIOSMemoryMap[i].LengthLow + PAGE_SIZE -1) / PAGE_SIZE;
}
}
if ((last - 256) * 4 > KeLoaderBlock.MemHigher)
{
KeLoaderBlock.MemHigher = (last - 256) * 4;
}
}
if (KeLoaderBlock.MemHigher >= (MaxMem - 1) * 1024)
{
KeLoaderBlock.MemHigher = (MaxMem - 1) * 1024;
}
/*
* FIXME: Set this based on the system command line
*/
MmSystemRangeStart = (PVOID)KERNEL_BASE; // 0xC0000000
MmUserProbeAddress = (PVOID)0x7fff0000;
MmHighestUserAddress = (PVOID)0x7ffeffff;
MmInitGlobalKernelPageDirectory();
/*
* Initialize memory managment statistics
*/
MmStats.NrTotalPages = 0;
MmStats.NrSystemPages = 0;
MmStats.NrUserPages = 0;
MmStats.NrReservedPages = 0;
MmStats.NrUserPages = 0;
MmStats.NrFreePages = 0;
MmStats.NrLockedPages = 0;
MmStats.PagingRequestsInLastMinute = 0;
MmStats.PagingRequestsInLastFiveMinutes = 0;
MmStats.PagingRequestsInLastFifteenMinutes = 0;
/*
* Initialize the kernel address space
*/
MmInitializeKernelAddressSpace();
/*
* Unmap low memory
*/
#ifndef MP
/* In SMP mode we unmap the low memory in MmInit3.
The APIC needs the mapping of the first pages
while the processors are starting up. */
MmDeletePageTable(NULL, 0);
#endif
/*
* Free all pages not used for kernel memory
* (we assume the kernel occupies a continuous range of physical
* memory)
*/
DPRINT("first krnl %x\nlast krnl %x\n",FirstKrnlPhysAddr,
LastKrnlPhysAddr);
/*
* Free physical memory not used by the kernel
*/
MmStats.NrTotalPages = KeLoaderBlock.MemHigher/4;
if (!MmStats.NrTotalPages)
{
DbgPrint("Memory not detected, default to 8 MB\n");
MmStats.NrTotalPages = 2048;
}
else
{
/* add 1MB for standard memory (not extended) */
MmStats.NrTotalPages += 256;
}
#ifdef BIOS_MEM_FIX
MmStats.NrTotalPages += 16;
#endif
DbgPrint("Used memory %dKb\n", (MmStats.NrTotalPages * PAGE_SIZE) / 1024);
LastKernelAddress = (ULONG)MmInitializePageList((PVOID)FirstKrnlPhysAddr,
(PVOID)LastKrnlPhysAddr,
MmStats.NrTotalPages,
PAGE_ROUND_UP(LastKernelAddress),
BIOSMemoryMap,
AddressRangeCount);
kernel_len = LastKrnlPhysAddr - FirstKrnlPhysAddr;
/*
* Create a trap for null pointer references and protect text
* segment
*/
CHECKPOINT;
#if defined(_MSC_VER)
DPRINT(".text start: %x, .data start: %x\n",
(int)FindSegmentStart(".text"),
(int)FindSegmentStart(".data"));
{
const char* pCode = FindSegmentStart(".text");
const char* pData = FindSegmentEnd(".text");
while (pCode < pData)
{
MmSetPageProtect(NULL, (PVOID)pCode, PAGE_EXECUTE_READ);
pCode += PAGE_SIZE;
}
}
#else
DPRINT("_text_start__ %x _init_end__ %x\n",(int)&_text_start__,(int)&_init_end__);
for (i=PAGE_ROUND_DOWN(((int)&_text_start__));
i<PAGE_ROUND_UP(((int)&_init_end__));i=i+PAGE_SIZE)
{
MmSetPageProtect(NULL,
(PVOID)i,
PAGE_EXECUTE_READ);
}
#endif
DPRINT("Invalidating between %x and %x\n",
LastKernelAddress, 0xc0600000);
for (i=(LastKernelAddress); i<0xc0600000; i+=PAGE_SIZE)
{
MmRawDeleteVirtualMapping((PVOID)(i));
}
DPRINT("Invalidating between %x and %x\n",
0xd0100000, 0xd0400000);
for (i=0xd0100000; i<0xd0400000; i+=PAGE_SIZE)
{
MmRawDeleteVirtualMapping((PVOID)(i));
}
DPRINT("Almost done MmInit()\n");
#ifndef MP
/* FIXME: This is broken in SMP mode */
#if !defined(_MSC_VER) // FIXME: I don't trust using this from MSVC yet!
MmDeleteVirtualMapping(NULL, (PVOID)&unmap_me, TRUE, NULL, NULL);
MmDeleteVirtualMapping(NULL, (PVOID)&unmap_me2, TRUE, NULL, NULL);
MmDeleteVirtualMapping(NULL, (PVOID)&unmap_me3, TRUE, NULL, NULL);
#endif // _MSC_VER
#endif
/*
* Intialize memory areas
*/
MmInitVirtualMemory(LastKernelAddress, kernel_len);
MmInitializeMdlImplementation();
}
VOID INIT_FUNCTION
MmInit2(VOID)
{
MmInitializeRmapList();
MmInitializePageOp();
MmInitSectionImplementation();
MmInitPagingFile();
}
VOID INIT_FUNCTION
MmInit3(VOID)
{
/*
* Unmap low memory
*/
#ifdef MP
/* In SMP mode we can unmap the low memory
if all processors are started. */
MmDeletePageTable(NULL, 0);
#endif
MmInitZeroPageThread();
MmCreatePhysicalMemorySection();
MiInitBalancerThread();
/*
* Initialise the modified page writer.
*/
MmInitMpwThread();
/* FIXME: Read parameters from memory */
}
VOID STATIC
MiFreeInitMemoryPage(PVOID Context, MEMORY_AREA* MemoryArea, PVOID Address,
PHYSICAL_ADDRESS PhysAddr, SWAPENTRY SwapEntry,
BOOLEAN Dirty)
{
assert(SwapEntry == 0);
if (PhysAddr.QuadPart != 0)
{
MmReleasePageMemoryConsumer(MC_NPPOOL, PhysAddr);
}
}
VOID
MiFreeInitMemory(VOID)
{
#if defined(_MSC_VER)
DPRINT1("Can not yet free .init memory for MSVC compiled kernel\n");
#else
MmLockAddressSpace(MmGetKernelAddressSpace());
MmFreeMemoryArea(MmGetKernelAddressSpace(),
(PVOID)&_init_start__,
PAGE_ROUND_UP((ULONG)&_init_end__) - (ULONG)_init_start__,
MiFreeInitMemoryPage,
NULL);
MmUnlockAddressSpace(MmGetKernelAddressSpace());
#endif
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,299 +0,0 @@
/*
* ReactOS kernel
* Copyright (C) 2000 David Welch <welch@cwcom.net>
*
* Moved to MSVC-compatible inline assembler by Mike Nordell, 2003-12-26
*
* 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.
*/
/*
* FILE: ntoskrnl/ke/i386/vm86_sup.S
* PURPOSE: V86 mode support
* PROGRAMMER: David Welch (welch@cwcom.net)
* UPDATE HISTORY:
* Created 09/10/00
*/
/* INCLUDES ******************************************************************/
#pragma hdrstop
#include <ddk/ntddk.h>
#include <ddk/status.h>
#include <internal/i386/segment.h>
#include <internal/i386/fpu.h>
#include <internal/ps.h>
#include <ddk/defines.h>
#include <internal/v86m.h>
#include <ntos/tss.h>
//#include <ntos/service.h>
#include <internal/trap.h>
#include <internal/ps.h>
#include <roscfg.h>
#include <internal/ntoskrnl.h>
#include <internal/i386/segment.h>
#define EXCEPTION_UNWINDING 0x02
#define EREC_FLAGS 0x04
#define ExceptionContinueExecution 0
#define ExceptionContinueSearch 1
#define ExceptionNestedException 2
#define ExceptionCollidedUnwind 3
//.globl _RtlpExecuteHandlerForException
//.globl _RtlpExecuteHandlerForUnwind
#define CONTEXT_FLAGS 0x00
#define CONTEXT_SEGGS 0x8C
#define CONTEXT_SEGFS 0x90
#define CONTEXT_SEGES 0x94
#define CONTEXT_SEGDS 0x98
#define CONTEXT_EDI 0x9C
#define CONTEXT_ESI 0xA0
#define CONTEXT_EBX 0xA4
#define CONTEXT_EDX 0xA8
#define CONTEXT_ECX 0xAC
#define CONTEXT_EAX 0xB0
#define CONTEXT_EBP 0xB4
#define CONTEXT_EIP 0xB8
#define CONTEXT_SEGCS 0xBC
#define CONTEXT_EFLAGS 0xC0
#define CONTEXT_ESP 0xC4
#define CONTEXT_SEGSS 0xC8
#define RCC_CONTEXT 0x08
VOID STDCALL
AsmDebug(ULONG Value);
// EAX = value to print
__declspec(naked)
void do_debug()
{
__asm
{
pusha
push eax
call AsmDebug
popa
ret
}
}
#define REH_ERECORD 0x08
#define REH_RFRAME 0x0C
#define REH_CONTEXT 0x10
#define REH_DCONTEXT 0x14
#define REH_EROUTINE 0x18
// Parameters:
// None
// Registers:
// [EBP+08h] - PEXCEPTION_RECORD ExceptionRecord
// [EBP+0Ch] - PEXCEPTION_REGISTRATION RegistrationFrame
// [EBP+10h] - PVOID Context
// [EBP+14h] - PVOID DispatcherContext
// [EBP+18h] - PEXCEPTION_HANDLER ExceptionRoutine
// EDX - Address of protecting exception handler
// Returns:
// EXCEPTION_DISPOSITION
// Notes:
// Setup the protecting exception handler and call the exception
// handler in the right context.
__declspec(naked)
void RtlpExecuteHandler()
{
__asm
{
push ebp
mov ebp, esp
push REH_RFRAME[ebp]
push edx
push fs:0x0
mov fs:0x0, esp
// Prepare to call the exception handler
push REH_DCONTEXT[ebp]
push REH_CONTEXT[ebp]
push REH_RFRAME[ebp]
push REH_ERECORD[ebp]
// Now call the exception handler
mov eax, REH_EROUTINE[ebp]
call eax
cmp fs:0x0, -1
jne reh_stack_looks_ok
// This should not happen
push 0
push 0
push 0
push 0
call RtlAssert
reh_loop:
jmp reh_loop
reh_stack_looks_ok:
mov esp, fs:0x0
// Return to the 'front-end' for this function
pop dword ptr fs:0x0
mov esp, ebp
pop ebp
ret
}
}
#if 0
#endif // 0
#define REP_ERECORD 0x04
#define REP_RFRAME 0x08
#define REP_CONTEXT 0x0C
#define REP_DCONTEXT 0x10
// Parameters:
// [ESP+04h] - PEXCEPTION_RECORD ExceptionRecord
// [ESP+08h] - PEXCEPTION_REGISTRATION RegistrationFrame
// [ESP+0Ch] - PCONTEXT Context
// [ESP+10h] - PVOID DispatcherContext
// Registers:
// None
// Returns:
// EXCEPTION_DISPOSITION
// Notes:
// This exception handler protects the exception handling
// mechanism by detecting nested exceptions.
__declspec(naked)
void RtlpExceptionProtector()
{
__asm
{
mov eax, ExceptionContinueSearch
mov ecx, REP_ERECORD[esp]
test EREC_FLAGS[ecx], EXCEPTION_UNWINDING
jnz rep_end
// Unwinding is not taking place, so return ExceptionNestedException
// Set DispatcherContext field to the exception registration for the
// exception handler that executed when a nested exception occurred
mov ecx, REP_DCONTEXT[esp]
mov eax, REP_RFRAME[esp]
mov [ecx], eax
mov eax, ExceptionNestedException
rep_end:
ret
}
}
// Parameters:
// [ESP+04h] - PEXCEPTION_RECORD ExceptionRecord
// [ESP+08h] - PEXCEPTION_REGISTRATION RegistrationFrame
// [ESP+0Ch] - PCONTEXT Context
// [ESP+10h] - PVOID DispatcherContext
// [ESP+14h] - PEXCEPTION_HANDLER ExceptionHandler
// Registers:
// None
// Returns:
// EXCEPTION_DISPOSITION
// Notes:
// Front-end
__declspec(naked)
void RtlpExecuteHandlerForException()
{
__asm
{
mov edx, RtlpExceptionProtector
jmp RtlpExecuteHandler
}
}
#define RUP_ERECORD 0x04
#define RUP_RFRAME 0x08
#define RUP_CONTEXT 0x0C
#define RUP_DCONTEXT 0x10
// Parameters:
// [ESP+04h] - PEXCEPTION_RECORD ExceptionRecord
// [ESP+08h] - PEXCEPTION_REGISTRATION RegistrationFrame
// [ESP+0Ch] - PCONTEXT Context
// [ESP+10h] - PVOID DispatcherContext
// Registers:
// None
// Returns:
// EXCEPTION_DISPOSITION
// Notes:
// This exception handler protects the exception handling
// mechanism by detecting collided unwinds.
__declspec(naked)
void RtlpUnwindProtector()
{
__asm
{
mov eax, ExceptionContinueSearch
mov RUP_ERECORD[esp], ecx
test EREC_FLAGS[ecx], EXCEPTION_UNWINDING
jz rup_end
// Unwinding is taking place, so return ExceptionCollidedUnwind
mov ecx, RUP_RFRAME[esp]
mov edx, RUP_DCONTEXT[esp]
// Set DispatcherContext field to the exception registration for the
// exception handler that executed when a collision occurred
mov eax, RUP_RFRAME[ecx]
mov [edx], eax
mov eax, ExceptionCollidedUnwind
rup_end:
ret
}
}
// Parameters:
// [ESP+04h] - PEXCEPTION_RECORD ExceptionRecord
// [ESP+08h] - PEXCEPTION_REGISTRATION RegistrationFrame
// [ESP+0Ch] - PCONTEXT Context
// [ESP+10h] - PVOID DispatcherContext
// [ESP+14h] - PEXCEPTION_HANDLER ExceptionHandler
// Registers:
// None
// Returns:
// EXCEPTION_DISPOSITION
__declspec(naked)
void RtlpExecuteHandlerForUnwind()
{
__asm mov edx, RtlpUnwindProtector
__asm jmp RtlpExecuteHandler
}

1
reactos/boot.bat Normal file
View File

@@ -0,0 +1 @@
loaders\dos\loadros ntoskrnl\kimage.bin %1 %2 %3 %4

340
reactos/copying_rex Normal file
View File

@@ -0,0 +1,340 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
675 Mass Ave, Cambridge, MA 02139, USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
Appendix: How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) 19yy <name of author>
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.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) 19yy name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.

140
reactos/doc/api.txt Normal file
View File

@@ -0,0 +1,140 @@
This file attempts to document the functions made publically available by
the various subsystems.
* Formatted I/O operations *
NAME: int vsprintf(char *buf, const char *fmt, va_list args)
NAME: int sprintf(char* buf, const char* fmt, ...)
WHERE: internal/kernel.h
FUNCTION: The same as the standard c library versions
* PIO operations *
NAME: in[b/w/l](port)
WHERE: internal/io.h
FUNCTION: Read an IO port of the specified size (byte/word or long)
RETURNS: The value read
NAME: out[b/w/l](port,val)
WHERE: internal/io.h
FUNCTION: Write an IO port of the specified size (byte/word or long)
NAME: in_p[b/w/l](port)
WHERE: internal/io.h
FUNCTION: Read an IO port of the specified size (byte/word or long) with
a pause
RETURNS: The value read
NAME: out_p[b/w/l](port,val)
WHERE: internal/io.h
FUNCTION: Write an IO port of the specified size (byte/word or long) with
a pause
* Bit operations *
NAME: int set_bit(int nr, void* addr)
NAME: int clear_bit(int nr, void* addr)
NAME: int change_bit(int nr, void* addr)
WHERE: internal/bitops.h>
FUNCTION: Operate on a bit in the word pointed to by addr
RETURN: 0 if the bit was cleared before the operations
non-zero otherwise
* Debugging functions *
NAME: DPRINT(fmt,....)
WHERE: internal/debug.h
FUNCTION: Outputs a string to the console if NDEBUG isn't defined before
including internal/debug.h, a NOP otherwise
ARGUMENTS: The same as printf
NAME: printk
WHERE: internal/kernel.h
FUNCTION: Outputs a string to the console
ARGUMENTS: The same as printf
* Memory managment functions *
NAME: unsigned int physical_to_linear(unsigned int paddr)
WHERE: hal/page.h
FUNCTION: Converts a physical address to a linear one
RECEIVES:
paddr = the physical address to convert
RETURNS: A virtual address where the memory at that physical address can be
accessed
NAME: void* ExAllocatePool(unsigned int size, unsigned int type = 0);
WHERE: internal/pool.h
FUNCTION: Allocates a block of memory
RECEIVES:
size = the size of the block to allocate
type = will be whether to allocate pagable memory
RETURNS: The address of the block
NOTE: This isn't interrupt safe
NAME: void ExFreePool(void* block)
WHERE: internal/pool.h
FUNCTION: Frees a block of memory
NAME: void free_page(unsigned int physical_base, unsigned int nr = 1)
WHERE: internal/mm.h
FUNCTION: Adds a continuous range of physical memory to the free list
NAME: unsigned int get_free_page(void)
WHERE: internal/mm.h
FUNCTION: Gets a free page
RETURNS: Its physical address
NAME: unsigned int get_page_physical_address(unsigned int vaddr)
WHERE: internal/mm.h
FUNCTION: Gets the physical address of a page
NAME: void mark_page_not_writable(unsigned int vaddr)
WHERE: internal/mm.h
FUNCTION: Prevent writing the page
* DMA functions *
NAME: unsigned int get_dma_page(unsigned int max_address)
WHERE: internal/mm.h
FUNCTION: Gets a page with a restricted physical address i.e. suitable for
dma
RETURNS: The physical address of the page
NAME: void disable_dma(unsigned int dmanr)
WHERE: internal/dma.h
FUNCTION: Disables the specified dma channel
NAME: void enable_dma(unsigned int dmanr)
WHERE: internal/dma.h
FUNCTION: Enables the specified dma channel
NAME: void clear_dma_ff(unsigned int dmanr)
WHERE: internal/dma.h
FUNCTION: Clear the dma flip-flop
NAME: void set_dma_mode(unsigned int dmanr, char mode)
WHERE: internal/dma.h
FUNCTION: Sets the type of dma transfer
NAME: void set_dma_page(unsigned int dmanr, char pagenr)
WHERE: internal/dma.h
FUNCTION: Set only the page register bits of the transfer address
NAME: void set_dma_addr(unsigned int dmanr, unsigned int a)
WHERE: internal/dma.h
FUNCTION: Set the transfer address for dma
NOTE: Assumes flip-flop is clear
NAME: void set_dma_count(unsigned int dmanr, unsigned int count)
WHERE: internal/dma.h
FUNCTION: Sets the size of the transfer
ARGUMENTS:
count = the number of bytes to transfer
NOTE: Count must be even for channels 5-7
NAME: int get_dma_residue(unsigned int dmanr)
WHERE: internal/dma.h
FUNCTION: Gets the residue remaining after a dma transfer on the channel

2
reactos/doc/buglist Normal file
View File

@@ -0,0 +1,2 @@
* Kernel bugs not fixed

27
reactos/doc/ddkfuncs.txt Normal file
View File

@@ -0,0 +1,27 @@
This is a list of the functions documented in the ddk that have been
implemented
IoAllocateController
IoFreeController
IoCreateController
IoDeleteController
IoStartNextPacket
IoStartNextPacketByKey
IoStartPacket
IoSizeOfIrp
IoMarkIrpPending
IoFreeIrp
IoConnectInterrupt
IoDisconnectInterrupt
IoGetCurrentIrpStackLocation
IoGetNextIrpStackLocation
IoRequestDpc
IoInitializeDpc
IoInitializeTimer
IoStartTimer
IoStopTimer
Partially implemented
IoCreateDevice
IoCallDriver

19
reactos/doc/debug.txt Normal file
View File

@@ -0,0 +1,19 @@
Some notes on debugging the ReactOS kernel
------------------------------------------
* Interpreting crashes
If the kernel causes a fatal cpu fault then it will print out a message and
halt. This message contains important information for debugging the problem,
look for these lines
Exception: xx(yy)
CS:EIP 20:zzzzzzzzzzzz
Here xx is the type of error, usually either 14 or 13 and yy is the error
code. Generally error codes 13 and 14 both mean the kernel tried to access
some memory in an invalid way. zzzzzzzzz is the address of the erronous
instruction.
* Debugging with bochs

114
reactos/doc/faq.txt Normal file
View File

@@ -0,0 +1,114 @@
Kernel Development FAQ (for v0.0.7)
This attempts to answer some of the common questions people developing for
the kernel might want to ask (or at least what I think they should ask).
Obviously I can only detail those parts which I have written so other
developers please fill in the gaps.
Q: What is this, what are you people, what's going on
A: This is the ReactOS, an operating system intended as a clone of windows
NT. See the project website (http://www.sid-dis.com/reactos/) for more details.
Q: Why ReactOS
A: To condemn Bill Gates to penury.
Q: What do I need to compile the kernel
A: DJGPP, get it from http://www.delorie.com/djgpp
Q: How do I compile the kernel
A: Unpack the zip. It is important not to install the kernel in the same
directory as a previous version, this has caused a bit of confusion in the
past. Edit the makefile in the top level directory, in particular select the
correct host to build from. Then run make in the top directory
Q: What files are created when I make the kernel
A: The following files are created in the kernel directory
kimage = the kernel as a coff executable
kimage.bin = the kernel as a raw binary image
kernel.sym = a list of the kernel symbols
Q: How do I load the kernel
A: Run the boot.bat batch file.
Q: Does it boot from disk
A: Not at the moment.
Q: When I run the kernel it crashes
A: The kernel (at the moment) can only be loaded from a clean system. That
is one without EMM386 or any version of windows loaded. A quick way to
ensure this (if you have windows 95) is to set the program to run in msdos
mode and specify an empty config.sys and autoexec.bat. See the windows help
for more information.
If you do that and the problem persists then contact the kernel team
(ros-kernel@sid-dis.com) as it is probably a bug in the kernel
Q6: How do I load a module with the kernel
A: Add the names of any modules to be loaded to the command line of boot.bat.
Q7: I want to add code to the kernel, how do I get it to be compiled
A: You will need to edit the Makefile in kernel directory. There should be
a statement like this
OBJECTS = hal/head.o hal/exp.o kernel/vsprintf.o \
....
kernel/irqhand.o hal/page.o mm/virtual.o kernel/error.o \
kernel/exports.o kernel/module.o
Add the name of the object file (the file produced when your code is
compiled) to the end of the statement (in this case after kernel/module.o).
If you need to go onto a new line then add a slash to the end of the
previous line. It is also very important to use an editor which preserves
tabs.
Q8: I want to add code to the kernel, how do I make it official
A: Contact the kernel mailing list ros-kernel@sid-dis.com or our coordinator
dwinkley@whitworth.edu. If it is for a specific section then the kernel
website (http://www.geocities.com/SiliconValley/Peaks/1957) has a list of
those working on individual areas, you might what to contact one of them
instead.
Q9: What header files should I use
A: Don't include the usual DJGPP headers like stdio.h unless you are using
something compiler based like stdargs.h. To use the DJGPP headers requires
linking with libc which is useless in kernel mode.
All the header files are in the top-level include directory which is laid
out like this
include = general win32 api declarations
include/internal = private kernel headers
include/internal/hal = HAL headers
include/ddk = header files with declarations for modules
There should be a file called api.txt which documents all of the functions
(and which header files they need).
Q11: I want to export my function for modules to use, how do I do that
A: Add the function to the list in kernel/exports.lst, then remake the
kernel. Note the function must be declared as extern "C".
Q12: I want to make my functions part of the kernel interface to user mode,
A: That section isn't finished yet, though it will probably mean adding a
pointer to the function and the size of its parameters to a internal table
somewhere.
Q14: I want to write a module, what are the guidelines
A: See modules.txt in this directory
Q15: I want to write an ISR (interrupt service routine)
A: See irq.txt in this directory
Q16: I want to use DMA
A: Firstly this answer covers only DMA via the dma chips *not*
busmaster DMA.
To program the dma chip use the functions in internal/dma.h (look in api.txt
for details). PC DMA can only go to memory with a physical address below
1mb (or 16mb on some systems), use the get_dma_page to allocate this kind
of memory.
Q17: You haven't answered my question
A: Send your questions to ros-kernel@sid-dis.com
- David Welch (welch@mcmail.com)

View File

@@ -0,0 +1,10 @@
This document describes the implementation of the memory managment
* ReactOS memory map
0x00000000 - 0xc0000000 = User memory
0xc0000000 - 0xd0000000 = Kernel memory
0xd0000000 - 0xffffffff = Identify map of physical memory
*

1253
reactos/doc/internal/pe.txt Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,2 @@
This contains documentation describing the internals of the various kernel
subsystems and a few other useful bits of information.

135
reactos/doc/irq.txt Normal file
View File

@@ -0,0 +1,135 @@
** Introduction
This attempts to document the ReactOS irq handling. As of v0.0.8 this has
changed to be more nt like, I will attempt to summarize the new
implementation for those unavailable with nt device driver writing. Note,
ReactOS doesn't have an exact implementation but the omissions are, except
where noted, not user visible.
** Steps in grabbing an irq vector
* Call HalConnectInterrupt
PROTOTYPE:
ULONG HalGetInterruptVector(INTERFACE_TYPE InterfaceType,
ULONG BusNumber,
ULONG BusInterruptLevel,
ULONG BusInterruptVector,
OUT PKIRQL Irql,
OUT PKAFFINITY Affinity)
PURPOSE:
Translates a bus dependant interrupt vector to a system vector
ARGUMENTS:
InterfaceType = Type of bus to which the device to receive interrupts
from is connected to. Currently only 'Internal' is
recognized
BusNumber = Number of the bus the device is connected to
(currently ignored)
BusInterruptLevel = Bus specific interrupt level (currently ignored)
BusInterruptVector = Bus specific vector. Currently this is the same
as the normal vector (09 is the keyboard vector
for example)
Irql = On return contains the DIRQL for the vector
Affinity = On return contains the affinity mask for the vector
(currently unimplemented)
RETURNS:
The system mapped vector
* Call IoConnectInterrupt
PROTOTYPE:
NTSTATUS IoConnectInterrupt(OUT PKINTERRUPT* InterruptObject,
PKSERVICE_ROUTINE ServiceRoutine,
PVOID ServiceContext,
PKSPIN_LOCK SpinLock,
ULONG Vector,
KIRQL Irql,
KIRQL SynchronizeIrql,
KINTERRUPT_MODE InterruptMode,
BOOLEAN ShareVector,
KAFFINITY ProcessorEnableMask,
BOOLEAN FloatingSave)
PURPOSE:
Connect a service routine to an interrupt vector
ARGUMENTS:
InterruptObject = Points to an object describes the interrupt on
return
ServiceRoutine = Function to be called when the device interrupts
ServiceContext = Parameters to be passed to the service routine
SpinLock = Should be NULL
Vector = System mapped vector returned from HalGetInterruptVector
Irql = DIRQL returned from HalGetInterruptVector
SynchronizeIrql = Should be the same as Irql
InterruptMode = Device interrupt type (currently ignored)
ShareVector = True if the interrupt vector can shared
ProcessorEnableMask = Currently ignored
FloatingSave = Should be false
RETURNS: Status
* Sample code for snarfing an interrupt vector
void grab_my_irq()
{
ULONG MappedIrq;
KIRQL Dirql;
KAFFINITY Affinity;
PKINTERRUPT IrqObject;
MappedIrq = HalGetInterruptVector(Internal,
0,
0,
MY_VECTOR,
&Dirql,
&Affinity);
IoConnectInterrupt(&IrqObject,
my_irq_service_routine,
my_context,
NULL,
MappedIrq,
Dirql,
Dirql,
0,
FALSE, // Not sharable
Affinity,
FALSE);
}
** Designing an interrupt service routine
An interrupt service routine should have the following prototype
BOOLEAN my_irq_service_routine(PKINTERRUPT Interrupt,
PVOID ServiceContext);
ARGUMENTS:
Interrupt = The same as the object returned from the
IoConnectInterrupt
ServiceContext = A user defined parameters
(passed to IoConnectInterrupt)
RETURNS:
True if it handled the interrupt, false if it should be passed onto
other devices sharing the same vector
NOTES:
While an isr is executing all devices of a lower or equal priority
can't interrupt. For this reason it is important that an isr
should complete in a short an interval as possible. The set of
routines an isr can call is also restricted.

21
reactos/doc/irql.txt Normal file
View File

@@ -0,0 +1,21 @@
This document describes the state of a uniprocessor PC at each of the IRQ
levels supported by the ReactOS kernel
PASSIVE_LEVEL: IF bit clear in the processor flags
All irqs umasked at the PIC
APC_LEVEL: Unknown
WAKE_LEVEL: Unknown
DISPATCH_LEVEL: IF bit clear in the processor flags
All irqs umasked at the PIC
Thread dispatching disabled
DIRQL (Device specific IRQ level):
IF bit clear in the processor flags
Device's irq and all lower priority irqs masked at the PIC
Thread dispatching disabled
HIGH_LEVEL: IF bit set in the processor flags
All irqs masked at the PIC
Thread dispatching disabled

33
reactos/doc/modules.txt Normal file
View File

@@ -0,0 +1,33 @@
** Introduction
This is (an incomplete) guide to writing device drivers (and other kernel
extensions) for ReactOS.
** Setting up the build environment
Create a new subdirectory in the modules directory and copy one of the
existing module makefiles into it. Customize the makefile to compile the
source files for the module. Note: generally it is not necessary to specify
the compiler or compiler flags to use.
** Initializing a module
On loading the kernel will call the module function
PROTOTYPE:
NTSTATUS ModuleEntry(PDRIVER_OBJECT DriverObject,
PUNICODE_STRING RegistryPath)
PURPOSE:
Initializing the module
ARGUMENTS:
DriverObject = Pointer to an object describing the driver
RegistryPath = Currently NULL
RETURNS:
STATUS_SUCCESS = If the module initialized successfully

31
reactos/doc/todo Normal file
View File

@@ -0,0 +1,31 @@
* Kernel things implemented [exceptions in brackets]
Spinlocks [Uniprocessor only]
IRQ levels [Not APC_LEVEL or WAKE_LEVEL, uniprocessor only]
ISRs [Partial, uniprocessor only]
Timers [Untested]
DPCs [Untested]
Objects [Partial]
Namespace [Partial]
Handle tables [One process only]
Threads [Some initial work]
RTL list functions [All except sequenced lists]
Zones [Untested]
Memory pool [Working but semantics partially incompatiable]
Device objects [Some but no support for layering]
IRP [Partial]
Memory sections [Partial, no file mappings]
PCI interface [Probes but no support]
CreateFile API [Device only]
ReadFile/WriteFile API [Device only]
MDL functions [Untested]
* Kernel things unimplemented (partial)
Add support for source level debugging to Bochs
Support for remote debugging
Process managment
Dispatcher objects (Mutex, Semaphore etc)
Investigate user and kernel mode APCs
Asynchronous I/O
Optimization

16
reactos/doc/wstring.txt Normal file
View File

@@ -0,0 +1,16 @@
subject wstring.zip
author Boudewijn Dekker
date 06-06-98
I wrote some inline wide character string functions. It are modified version
of the ones in string.h. I added four more function nl stricmp, strnicmp,
wcsicmp, and wcsnicmp. These are the case insensitive variants of
strcmp, strncmp and wcscmp, wcsncmp. I tested all the functions but I
would urge anyone to tested again. I removed an extern specifier
__wcstok and strtok cause I it caused an compilation error when
using strtok or wcstok. Please could someone see if this correct.
I also used these string functions in lstring api functions.
Boudewijn Dekker

11
reactos/drivers/readme Normal file
View File

@@ -0,0 +1,11 @@
These are a selection of services for the ReactOS kernel. They include
parallel = parallel port driver
serial = serial port driver
mouse = mouse driver
null = null device driver
ide = IDE (hard disk) driver
keyboard = keyboard driver
loop = Allows accessing a file as a block device
scramdisk = Filesystem encryption driver
event = Sample driver demonstrating notifying a user thread using an event

2979
reactos/include/ascii.h Normal file

File diff suppressed because it is too large Load Diff

572
reactos/include/base.h Normal file
View File

@@ -0,0 +1,572 @@
/*
Base.h
Base definitions
Copyright (C) 1996, 1997 Free Software Foundation, Inc.
Author: Scott Christley <scottc@net-community.com>
This file is part of the Windows32 API Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
If you are interested in a warranty or support for this source code,
contact Scott Christley <scottc@net-community.com> for more information.
You should have received a copy of the GNU Library General Public
License along with this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _GNU_H_WINDOWS32_BASE
#define _GNU_H_WINDOWS32_BASE
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#ifndef NULL
#ifdef __cplusplus
#define NULL (0)
#else
#define NULL ((void *)0)
#endif
#endif /* !NULL */
#define FALSE 0
#define TRUE 1
#ifndef RC_INVOKED
/* typedef ACMDRIVERENUMCB;
typedef ACMDRIVERPROC;
typedef ACMFILERCHOOSEHOOKPROC;
typedef ACMFILTERENUMCB;
typedef ACMFILTERTAGENUMCB;
typedef ACMFORMATCHOOSEHOOKPROC;
typedef ACMFORMATENUMCB;
typedef ACMFORMATTAGENUMCB;
typedef APPLET_PROC;
*/
typedef unsigned short ATOM;
/* Changed from BOOL to WINBOOL to avoid Objective-C conflict */
typedef int WINBOOL;
typedef unsigned char BOOLEAN;
typedef unsigned char BYTE;
typedef unsigned long CALTYPE;
typedef unsigned long CALID;
typedef char CCHAR;
typedef unsigned long COLORREF;
#define CONST const
/* Check VOID before defining CHAR, SHORT, and LONG */
#ifndef VOID
#define VOID void
typedef char CHAR;
typedef short SHORT;
typedef long LONG;
#endif
/*
typedef CTRYID;
typedef DLGPROC;
*/
typedef unsigned int DWORD; /* was unsigned long */
typedef double DWORDLONG, *PDWORDLONG;
/*
typedef EDITWORDBREAKPROC;
typedef ENHMFENUMPROC;
typedef ENUMRESLANGPROC;
typedef ENUMRESNAMEPROC;
typedef ENUMRESTYPEPROC;
*/
typedef float FLOAT;
/* typedef GLOBALHANDLE; */
typedef void *HANDLE;
typedef HANDLE HACCEL;
typedef HANDLE HBITMAP;
typedef HANDLE HBRUSH;
typedef HANDLE HCOLORSPACE;
typedef HANDLE HCONV;
typedef HANDLE HCONVLIST;
typedef HANDLE HCURSOR;
typedef HANDLE HDBC;
typedef HANDLE HDC;
typedef HANDLE HDDEDATA;
typedef HANDLE HDESK;
typedef HANDLE HDROP;
typedef HANDLE HDWP;
typedef HANDLE HENHMETAFILE;
typedef HANDLE HENV;
typedef int HFILE;
typedef HANDLE HFONT;
typedef HANDLE HGDIOBJ;
typedef HANDLE HGLOBAL;
typedef HANDLE HGLRC;
typedef HANDLE HHOOK;
typedef HANDLE HICON;
typedef HANDLE HIMAGELIST;
typedef HANDLE HINSTANCE;
typedef HANDLE HKEY, *PHKEY;
typedef HANDLE HKL;
typedef HANDLE HLOCAL;
typedef HANDLE HMENU;
typedef HANDLE HMETAFILE;
typedef HANDLE HMODULE;
typedef HANDLE HPALETTE;
typedef HANDLE HPEN;
typedef HANDLE HRASCONN;
typedef long HRESULT;
typedef HANDLE HRGN;
typedef HANDLE HRSRC;
typedef HANDLE HSTMT;
typedef HANDLE HSZ;
typedef HANDLE HWINSTA;
typedef HANDLE HWND;
typedef int INT;
typedef unsigned short LANGID;
typedef DWORD LCID;
typedef DWORD LCTYPE;
/* typedef LOCALHANDLE */
typedef double LONGLONG, *PLONGLONG;
typedef unsigned short *LP;
typedef long LPARAM;
typedef WINBOOL *LPBOOL;
typedef BYTE *LPBYTE;
typedef CONST CHAR *LPCCH;
typedef CHAR *LPCH;
typedef COLORREF *LPCOLORREF;
typedef const char *LPCSTR;
typedef char* PCSZ;
#ifdef UNICODE
typedef const unsigned short *LPCTSTR;
#else
typedef const char *LPCTSTR;
#endif /* UNICODE */
typedef const unsigned short *LPCWCH;
typedef const unsigned short *LPCWSTR;
typedef DWORD *LPDWORD;
/* typedef LPFRHOOKPROC; */
typedef HANDLE *LPHANDLE;
/* typedef LPHANDLER_FUNCTION; */
typedef int *LPINT;
typedef long *LPLONG;
typedef char *LPSTR;
#ifdef UNICODE
typedef unsigned short *LPTCH;
typedef unsigned short *LPTSTR;
#else
typedef char *LPTCH;
typedef char *LPTSTR;
#endif /* UNICODE */
typedef long LRESULT;
typedef void *LPVOID;
typedef const void *LPCVOID;
typedef unsigned short *LPWCH;
typedef unsigned short *LPWORD;
typedef unsigned short *LPWSTR;
typedef unsigned short *PWSTR;
/* typedef NPSTR; */
typedef unsigned short *NWPSTR;
typedef WINBOOL *PWINBOOL;
typedef BYTE *PBOOLEAN;
typedef BYTE *PBYTE;
typedef const CHAR *PCCH;
typedef CHAR *PCH;
typedef CHAR *PCHAR;
typedef const char *PCSTR;
typedef const unsigned short *PCWCH;
typedef const unsigned short *PCWSTR;
typedef DWORD *PDWORD;
typedef float *PFLOAT;
typedef HANDLE *PHANDLE;
/* typedef PHKEY; */
typedef int *PINT;
/* typedef LCID *PLCID; */
typedef long *PLONG;
typedef short *PSHORT;
/* typedef PSID; */
typedef char *PSTR;
typedef char *PSZ;
#ifdef UNICODE
typedef unsigned short *PTBYTE;
typedef unsigned short *PTCH;
typedef unsigned short *PTCHAR;
typedef unsigned short *PTSTR;
#else
typedef unsigned char *PTBYTE;
typedef char *PTCH;
typedef char *PTCHAR;
typedef char *PTSTR;
#endif /* UNICODE */
typedef unsigned char *PUCHAR;
typedef unsigned int *PUINT;
typedef unsigned long *PULONG;
typedef unsigned short *PUSHORT;
typedef void *PVOID;
typedef unsigned short *PWCH;
typedef unsigned short *PWCHAR;
typedef unsigned short *PWORD;
/*
typedef PWSTR;
typedef REGSAM;
*/
typedef short RETCODE;
typedef HANDLE SC_HANDLE;
typedef LPVOID SC_LOCK;
typedef SC_HANDLE *LPSC_HANDLE;
typedef DWORD SERVICE_STATUS_HANDLE;
/* typedef SPHANDLE; */
#ifdef UNICODE
typedef unsigned short TBYTE;
typedef unsigned short TCHAR;
typedef unsigned short BCHAR;
#else
typedef unsigned char TBYTE;
typedef char TCHAR;
typedef BYTE BCHAR;
#endif /* UNICODE */
typedef unsigned char UCHAR;
typedef unsigned int UINT;
typedef unsigned long ULONG;
typedef unsigned short USHORT;
typedef unsigned short WCHAR;
typedef unsigned short WORD;
typedef unsigned int WPARAM;
/* typedef YIELDPROC; */
/* Only use __stdcall under WIN32 compiler */
#ifdef i386
#define STDCALL __attribute__ ((stdcall))
#define CDECL __attribute((cdecl))
#define CALLBACK WINAPI
#define PASCAL WINAPI
#else
#define STDCALL
#define CDECL
#define CALLBACK
#define PASCAL
#endif
#define WINAPI STDCALL
#define APIENTRY STDCALL
#define WINGDIAPI
#define _export
/*
Enumerations
*/
typedef enum _ACL_INFORMATION_CLASS {
AclRevisionInformation = 1,
AclSizeInformation
} ACL_INFORMATION_CLASS;
typedef enum _MEDIA_TYPE {
Unknown,
F5_1Pt2_512,
F3_1Pt44_512,
F3_2Pt88_512,
F3_20Pt8_512,
F3_720_512,
F5_360_512,
F5_320_512,
F5_320_1024,
F5_180_512,
F5_160_512,
RemovableMedia,
FixedMedia
} MEDIA_TYPE;
#define RASCS_DONE 0x2000
#define RASCS_PAUSED 0x1000
typedef enum _RASCONNSTATE {
RASCS_OpenPort = 0,
RASCS_PortOpened,
RASCS_ConnectDevice,
RASCS_DeviceConnected,
RASCS_AllDevicesConnected,
RASCS_Authenticate,
RASCS_AuthNotify,
RASCS_AuthRetry,
RASCS_AuthCallback,
RASCS_AuthChangePassword,
RASCS_AuthProject,
RASCS_AuthLinkSpeed,
RASCS_AuthAck,
RASCS_ReAuthenticate,
RASCS_Authenticated,
RASCS_PrepareForCallback,
RASCS_WaitForModemReset,
RASCS_WaitForCallback,
RASCS_Projected,
RASCS_StartAuthentication,
RASCS_CallbackComplete,
RASCS_LogonNetwork,
RASCS_Interactive = RASCS_PAUSED,
RASCS_RetryAuthentication,
RASCS_CallbackSetByCaller,
RASCS_PasswordExpired,
RASCS_Connected = RASCS_DONE,
RASCS_Disconnected
} RASCONNSTATE ;
typedef enum _RASPROJECTION {
RASP_Amb = 0x10000,
RASP_PppNbf = 0x803F,
RASP_PppIpx = 0x802B,
RASP_PppIp = 0x8021
} RASPROJECTION ;
typedef enum _SECURITY_IMPERSONATION_LEVEL {
SecurityAnonymous,
SecurityIdentification,
SecurityImpersonation,
SecurityDelegation
} SECURITY_IMPERSONATION_LEVEL;
typedef enum _SID_NAME_USE {
SidTypeUser = 1,
SidTypeGroup,
SidTypeDomain,
SidTypeAlias,
SidTypeWellKnownGroup,
SidTypeDeletedAccount,
SidTypeInvalid,
SidTypeUnknown
} SID_NAME_USE, *PSID_NAME_USE;
typedef enum _TOKEN_INFORMATION_CLASS {
TokenUser = 1,
TokenGroups,
TokenPrivileges,
TokenOwner,
TokenPrimaryGroup,
TokenDefaultDacl,
TokenSource,
TokenType,
TokenImpersonationLevel,
TokenStatistics
} TOKEN_INFORMATION_CLASS;
typedef enum tagTOKEN_TYPE {
TokenPrimary = 1,
TokenImpersonation
} TOKEN_TYPE;
#endif /* ! defined (RC_INVOKED) */
/*
Macros
*/
#define FORWARD_WM_NOTIFY(hwnd, idFrom, pnmhdr, fn) (void)(fn)((hwnd), WM_NOTIFY, (WPARAM)(int)(id), (LPARAM)(NMHDR FAR*)(pnmhdr))
#define GetBValue(rgb) ((BYTE) ((rgb) >> 16))
#define GetGValue(rgb) ((BYTE) (((WORD) (rgb)) >> 8))
#define GetRValue(rgb) ((BYTE) (rgb))
#define RGB(r, g ,b) ((DWORD) (((BYTE) (r) | ((WORD) (g) << 8)) | (((DWORD) (BYTE) (b)) << 16)))
#define HANDLE_WM_NOTIFY(hwnd, wParam, lParam, fn) (fn)((hwnd), (int)(wParam), (NMHDR FAR*)(lParam))
#define HIBYTE(w) ((BYTE) (((WORD) (w) >> 8) & 0xFF))
#define HIWORD(l) ((WORD) (((DWORD) (l) >> 16) & 0xFFFF))
#define LOBYTE(w) ((BYTE) (w))
#define LOWORD(l) ((WORD) (l))
#define MAKELONG(a, b) ((LONG) (((WORD) (a)) | ((DWORD) ((WORD) (b))) << 16))
#define MAKEWORD(a, b) ((WORD) (((BYTE) (a)) | ((WORD) ((BYTE) (b))) << 8))
/* original Cygnus headers also had the following defined: */
#define SEXT_HIWORD(l) ((((int)l) >> 16))
#define ZEXT_HIWORD(l) ((((unsigned int)l) >> 16))
#define SEXT_LOWORD(l) ((int)(short)l)
#define INDEXTOOVERLAYMASK(i) ((i) << 8)
#define INDEXTOSTATEIMAGEMASK(i) ((i) << 12)
#define MAKEINTATOM(i) (LPTSTR) ((DWORD) ((WORD) (i)))
#define MAKEINTRESOURCE(i) (LPTSTR) ((DWORD) ((WORD) (i)))
#define MAKELANGID(p, s) ((((WORD) (s)) << 10) | (WORD) (p))
#define PRIMARYLANGID(lgid) ((WORD )(lgid) & 0x3ff)
#define SUBLANGID(lgid) ((WORD )(lgid) >> 10)
#define LANGIDFROMLCID(lcid) ((WORD) (lcid))
#define SORTIDFROMLCID(lcid) ((WORD )((((DWORD)(lcid)) & 0x000FFFFF) >> 16))
#define MAKELCID(lgid, srtid) ((DWORD)((((DWORD)((WORD)(srtid))) << 16) | ((DWORD)((WORD)(lgid)))))
#define MAKELPARAM(l, h) ((LPARAM) MAKELONG(l, h))
#define MAKELRESULT(l, h) ((LRESULT) MAKELONG(l, h))
#define MAKEPOINTS(l) (*((POINTS FAR *) & (l)))
#define MAKEROP4(fore,back) (DWORD)((((back) << 8) & 0xFF000000) | (fore))
#define MAKEWPARAM(l, h) ((WPARAM) MAKELONG(l, h))
#ifndef max
#define max(a, b) (((a) > (b)) ? (a) : (b))
#endif
#ifndef min
#define min(a, b) (((a) < (b)) ? (a) : (b))
#endif
#define PALETTEINDEX(i) ((COLORREF) (0x01000000 | (DWORD) (WORD) (i)))
#define PALETTERGB(r, g, b) (0x02000000 | RGB(r, g, b))
#define POINTSTOPOINT(pt, pts) {(pt).x = (SHORT) LOWORD(pts); (pt).y = (SHORT) HIWORD(pts);}
#define POINTTOPOINTS(pt) (MAKELONG((short) ((pt).x), (short) ((pt).y)))
#define INDEXTOOVERLAYMASK(i) ((i) << 8)
#define INDEXTOSTATEIMAGEMASK(i) ((i) << 12)
#ifdef UNICODE
#define TEXT(quote) L##quote
#else
#define TEXT(quote) quote
#endif
#ifndef RC_INVOKED
/*
Definitions for callback procedures
*/
typedef int CALLBACK (*BFFCALLBACK) (HWND, UINT, LPARAM, LPARAM);
typedef UINT CALLBACK (*LPCCHOOKPROC) (HWND, UINT, WPARAM, LPARAM);
typedef UINT CALLBACK (*LPCFHOOKPROC) (HWND, UINT, WPARAM, LPARAM);
typedef DWORD CALLBACK (*PTHREAD_START_ROUTINE) (LPVOID);
typedef PTHREAD_START_ROUTINE LPTHREAD_START_ROUTINE;
typedef DWORD CALLBACK (*EDITSTREAMCALLBACK) (DWORD, LPBYTE, LONG, LONG);
typedef UINT CALLBACK (*LPFRHOOKPROC) (HWND, UINT, WPARAM, LPARAM);
typedef UINT CALLBACK (*LPOFNHOOKPROC) (HWND, UINT, WPARAM, LPARAM);
typedef UINT CALLBACK (*LPPRINTHOOKPROC) (HWND, UINT, WPARAM, LPARAM);
typedef UINT CALLBACK (*LPSETUPHOOKPROC) (HWND, UINT, WPARAM, LPARAM);
typedef WINBOOL CALLBACK (*DLGPROC) (HWND, UINT, WPARAM, LPARAM);
typedef int CALLBACK (*PFNPROPSHEETCALLBACK) (HWND, UINT, LPARAM);
typedef VOID CALLBACK (*LPSERVICE_MAIN_FUNCTION) (DWORD, LPTSTR);
typedef int CALLBACK (*PFNTVCOMPARE) (LPARAM, LPARAM, LPARAM);
typedef LRESULT CALLBACK (*WNDPROC) (HWND, UINT, WPARAM, LPARAM);
typedef int CALLBACK (*FARPROC)(void);
typedef FARPROC PROC;
typedef WINBOOL CALLBACK (*ENUMRESTYPEPROC) (HANDLE, LPTSTR, LONG);
typedef WINBOOL CALLBACK (*ENUMRESNAMEPROC) (HANDLE, LPCTSTR, LPTSTR, LONG);
typedef WINBOOL CALLBACK (*ENUMRESLANGPROC) (HANDLE, LPCTSTR, LPCTSTR, WORD, LONG);
typedef FARPROC DESKTOPENUMPROC;
typedef WINBOOL CALLBACK (*ENUMWINDOWSPROC) (HWND, LPARAM);
typedef WINBOOL CALLBACK (*ENUMWINDOWSTATIONPROC) (LPTSTR, LPARAM);
typedef VOID CALLBACK (*SENDASYNCPROC) (HWND, UINT, DWORD, LRESULT);
typedef VOID CALLBACK (*TIMERPROC) (HWND, UINT, UINT, DWORD);
typedef FARPROC GRAYSTRINGPROC;
typedef WINBOOL CALLBACK (*DRAWSTATEPROC) (HDC, LPARAM, WPARAM, int, int);
typedef WINBOOL CALLBACK (*PROPENUMPROCEX) (HWND, LPCTSTR, HANDLE, DWORD);
typedef WINBOOL CALLBACK (*PROPENUMPROC) (HWND, LPCTSTR, HANDLE);
typedef LRESULT CALLBACK (*HOOKPROC) (int, WPARAM, LPARAM);
typedef VOID CALLBACK (*ENUMOBJECTSPROC) (LPVOID, LPARAM);
typedef VOID CALLBACK (*LINEDDAPROC) (int, int, LPARAM);
typedef WINBOOL CALLBACK (*ABORTPROC) (HDC, int);
typedef UINT CALLBACK (*LPPAGEPAINTHOOK) (HWND, UINT, WPARAM, LPARAM );
typedef UINT CALLBACK (*LPPAGESETUPHOOK) (HWND, UINT, WPARAM, LPARAM );
typedef int CALLBACK (*ICMENUMPROC) (LPTSTR, LPARAM);
typedef LONG (*EDITWORDBREAKPROCEX) (char *, LONG, BYTE, INT);
typedef int CALLBACK (*PFNLVCOMPARE) (LPARAM, LPARAM, LPARAM);
typedef WINBOOL CALLBACK (*LOCALE_ENUMPROC) (LPTSTR);
typedef WINBOOL CALLBACK (*CODEPAGE_ENUMPROC) (LPTSTR);
typedef WINBOOL CALLBACK (*DATEFMT_ENUMPROC) (LPTSTR);
typedef WINBOOL CALLBACK (*TIMEFMT_ENUMPROC) (LPTSTR);
typedef WINBOOL CALLBACK (*CALINFO_ENUMPROC) (LPTSTR);
typedef WINBOOL CALLBACK (*PHANDLER_ROUTINE) (DWORD);
typedef WINBOOL CALLBACK (*LPHANDLER_FUNCTION) (DWORD);
typedef UINT CALLBACK (*PFNGETPROFILEPATH) (LPCTSTR, LPSTR, UINT);
typedef UINT CALLBACK (*PFNRECONCILEPROFILE) (LPCTSTR, LPCTSTR, DWORD);
typedef WINBOOL CALLBACK (*PFNPROCESSPOLICIES) (HWND, LPCTSTR, LPCTSTR, LPCTSTR, DWORD);
#define SECURITY_NULL_SID_AUTHORITY {0,0,0,0,0,0}
#define SECURITY_WORLD_SID_AUTHORITY {0,0,0,0,0,1}
#define SECURITY_LOCAL_SID_AUTHORITY {0,0,0,0,0,2}
#define SECURITY_CREATOR_SID_AUTHORITY {0,0,0,0,0,3}
#define SECURITY_NON_UNIQUE_AUTHORITY {0,0,0,0,0,4}
#define SECURITY_NT_AUTHORITY {0,0,0,0,0,5}
#define SE_CREATE_TOKEN_NAME TEXT("SeCreateTokenPrivilege")
#define SE_ASSIGNPRIMARYTOKEN_NAME TEXT("SeAssignPrimaryTokenPrivilege")
#define SE_LOCK_MEMORY_NAME TEXT("SeLockMemoryPrivilege")
#define SE_INCREASE_QUOTA_NAME TEXT("SeIncreaseQuotaPrivilege")
#define SE_UNSOLICITED_INPUT_NAME TEXT("SeUnsolicitedInputPrivilege")
#define SE_MACHINE_ACCOUNT_NAME TEXT("SeMachineAccountPrivilege")
#define SE_TCB_NAME TEXT("SeTcbPrivilege")
#define SE_SECURITY_NAME TEXT("SeSecurityPrivilege")
#define SE_TAKE_OWNERSHIP_NAME TEXT("SeTakeOwnershipPrivilege")
#define SE_LOAD_DRIVER_NAME TEXT("SeLoadDriverPrivilege")
#define SE_SYSTEM_PROFILE_NAME TEXT("SeSystemProfilePrivilege")
#define SE_SYSTEMTIME_NAME TEXT("SeSystemtimePrivilege")
#define SE_PROF_SINGLE_PROCESS_NAME TEXT("SeProfileSingleProcessPrivilege")
#define SE_INC_BASE_PRIORITY_NAME TEXT("SeIncreaseBasePriorityPrivilege")
#define SE_CREATE_PAGEFILE_NAME TEXT("SeCreatePagefilePrivilege")
#define SE_CREATE_PERMANENT_NAME TEXT("SeCreatePermanentPrivilege")
#define SE_BACKUP_NAME TEXT("SeBackupPrivilege")
#define SE_RESTORE_NAME TEXT("SeRestorePrivilege")
#define SE_SHUTDOWN_NAME TEXT("SeShutdownPrivilege")
#define SE_DEBUG_NAME TEXT("SeDebugPrivilege")
#define SE_AUDIT_NAME TEXT("SeAuditPrivilege")
#define SE_SYSTEM_ENVIRONMENT_NAME TEXT("SeSystemEnvironmentPrivilege")
#define SE_CHANGE_NOTIFY_NAME TEXT("SeChangeNotifyPrivilege")
#define SE_REMOTE_SHUTDOWN_NAME TEXT("SeRemoteShutdownPrivilege")
#define SERVICES_ACTIVE_DATABASEW L"ServicesActive"
#define SERVICES_FAILED_DATABASEW L"ServicesFailed"
#define SERVICES_ACTIVE_DATABASEA "ServicesActive"
#define SERVICES_FAILED_DATABASEA "ServicesFailed"
#define SC_GROUP_IDENTIFIERW L'+'
#define SC_GROUP_IDENTIFIERA '+'
#ifdef UNICODE
#define SERVICES_ACTIVE_DATABASE SERVICES_ACTIVE_DATABASEW
#define SERVICES_FAILED_DATABASE SERVICES_FAILED_DATABASEW
#define SC_GROUP_IDENTIFIER SC_GROUP_IDENTIFIERW
#else
#define SERVICES_ACTIVE_DATABASE SERVICES_ACTIVE_DATABASEA
#define SERVICES_FAILED_DATABASE SERVICES_FAILED_DATABASEA
#define SC_GROUP_IDENTIFIER SC_GROUP_IDENTIFIERA
#endif /* UNICODE */
/* ---------------------------------- */
/* From ddeml.h in old Cygnus headers */
typedef void (*CALLB) (void);
typedef CALLB PFNCALLBACK;
typedef WINBOOL SECURITY_CONTEXT_TRACKING_MODE;
/* End of stuff from ddeml.h in old Cygnus headers */
/* ----------------------------------------------- */
typedef FARPROC WNDENUMPROC;
typedef FARPROC ENHMFENUMPROC;
typedef DWORD CCSTYLE, *PCCSTYLE, *LPCCSTYLE;
typedef DWORD CCSTYLEFLAGA, *PCCSTYLEFLAGA, *LPCCSTYLEFLAGA;
#define DECLARE_HANDLE(s) typedef HANDLE s
#endif /* ! defined (RC_INVOKED) */
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* _GNU_H_WINDOWS32_BASE */

339
reactos/include/coff.h Normal file
View File

@@ -0,0 +1,339 @@
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
#ifndef __dj_include_coff_h_
#define __dj_include_coff_h_
#ifdef __cplusplus
extern "C" {
#endif
//#ifndef __dj_ENFORCE_ANSI_FREESTANDING
//#ifndef __STRICT_ANSI__
//#ifndef _POSIX_SOURCE
/*** coff information for Intel 386/486. */
/********************** FILE HEADER **********************/
struct external_filehdr {
unsigned short f_magic; /* magic number */
unsigned short f_nscns; /* number of sections */
unsigned long f_timdat; /* time & date stamp */
unsigned long f_symptr; /* file pointer to symtab */
unsigned long f_nsyms; /* number of symtab entries */
unsigned short f_opthdr; /* sizeof(optional hdr) */
unsigned short f_flags; /* flags */
};
/* Bits for f_flags:
* F_RELFLG relocation info stripped from file
* F_EXEC file is executable (no unresolved external references)
* F_LNNO line numbers stripped from file
* F_LSYMS local symbols stripped from file
* F_AR32WR file has byte ordering of an AR32WR machine (e.g. vax)
*/
#define F_RELFLG (0x0001)
#define F_EXEC (0x0002)
#define F_LNNO (0x0004)
#define F_LSYMS (0x0008)
#define I386MAGIC 0x14c
#define I386AIXMAGIC 0x175
#define I386BADMAG(x) (((x).f_magic!=I386MAGIC) && (x).f_magic!=I386AIXMAGIC)
#define FILHDR struct external_filehdr
#define FILHSZ sizeof(FILHDR)
/********************** AOUT "OPTIONAL HEADER" **********************/
typedef struct
{
unsigned short magic; /* type of file */
unsigned short vstamp; /* version stamp */
unsigned long tsize; /* text size in bytes, padded to FW bdry*/
unsigned long dsize; /* initialized data " " */
unsigned long bsize; /* uninitialized data " " */
unsigned long entry; /* entry pt. */
unsigned long text_start; /* base of text used for this file */
unsigned long data_start; /* base of data used for this file */
}
AOUTHDR;
typedef struct gnu_aout {
unsigned long info;
unsigned long tsize;
unsigned long dsize;
unsigned long bsize;
unsigned long symsize;
unsigned long entry;
unsigned long txrel;
unsigned long dtrel;
} GNU_AOUT;
#define AOUTSZ (sizeof(AOUTHDR))
#define OMAGIC 0404 /* object files, eg as output */
#define ZMAGIC 0413 /* demand load format, eg normal ld output */
#define STMAGIC 0401 /* target shlib */
#define SHMAGIC 0443 /* host shlib */
/********************** SECTION HEADER **********************/
struct external_scnhdr {
char s_name[8]; /* section name */
unsigned long s_paddr; /* physical address, aliased s_nlib */
unsigned long s_vaddr; /* virtual address */
unsigned long s_size; /* section size */
unsigned long s_scnptr; /* file ptr to raw data for section */
unsigned long s_relptr; /* file ptr to relocation */
unsigned long s_lnnoptr; /* file ptr to line numbers */
unsigned short s_nreloc; /* number of relocation entries */
unsigned short s_nlnno; /* number of line number entries*/
unsigned long s_flags; /* flags */
};
#define SCNHDR struct external_scnhdr
#define SCNHSZ sizeof(SCNHDR)
/*
* names of "special" sections
*/
#define _TEXT ".text"
#define _DATA ".data"
#define _BSS ".bss"
#define _COMMENT ".comment"
#define _LIB ".lib"
/*
* s_flags "type"
*/
#define STYP_TEXT (0x0020) /* section contains text only */
#define STYP_DATA (0x0040) /* section contains data only */
#define STYP_BSS (0x0080) /* section contains bss only */
/********************** LINE NUMBERS **********************/
/* 1 line number entry for every "breakpointable" source line in a section.
* Line numbers are grouped on a per function basis; first entry in a function
* grouping will have l_lnno = 0 and in place of physical address will be the
* symbol table index of the function name.
*/
struct external_lineno {
union {
unsigned long l_symndx __attribute__((packed)); /* function name symbol index, iff l_lnno == 0 */
unsigned long l_paddr __attribute__((packed)); /* (physical) address of line number */
} l_addr;
unsigned short l_lnno; /* line number */
};
#define LINENO struct external_lineno
#define LINESZ sizeof(LINENO)
/********************** SYMBOLS **********************/
#define E_SYMNMLEN 8 /* # characters in a symbol name */
#define E_FILNMLEN 14 /* # characters in a file name */
#define E_DIMNUM 4 /* # array dimensions in auxiliary entry */
struct external_syment
{
union {
char e_name[E_SYMNMLEN];
struct {
unsigned long e_zeroes __attribute__((packed));
unsigned long e_offset __attribute__((packed));
} e;
} e;
unsigned long e_value __attribute__((packed));
short e_scnum;
unsigned short e_type;
unsigned char e_sclass;
unsigned char e_numaux;
};
#define N_BTMASK (0xf)
#define N_TMASK (0x30)
#define N_BTSHFT (4)
#define N_TSHIFT (2)
union external_auxent {
struct {
unsigned long x_tagndx __attribute__((packed)); /* str, un, or enum tag indx */
union {
struct {
unsigned short x_lnno; /* declaration line number */
unsigned short x_size; /* str/union/array size */
} x_lnsz;
unsigned long x_fsize __attribute__((packed)); /* size of function */
} x_misc;
union {
struct { /* if ISFCN, tag, or .bb */
unsigned long x_lnnoptr __attribute__((packed)); /* ptr to fcn line # */
unsigned long x_endndx __attribute__((packed)); /* entry ndx past block end */
} x_fcn;
struct { /* if ISARY, up to 4 dimen. */
unsigned short x_dimen[E_DIMNUM];
} x_ary;
} x_fcnary;
unsigned short x_tvndx; /* tv index */
} x_sym;
union {
char x_fname[E_FILNMLEN];
struct {
unsigned long x_zeroes __attribute__((packed));
unsigned long x_offset __attribute__((packed));
} x_n;
} x_file;
struct {
unsigned long x_scnlen __attribute__((packed)); /* section length */
unsigned short x_nreloc; /* # relocation entries */
unsigned short x_nlinno; /* # line numbers */
} x_scn;
struct {
unsigned long x_tvfill __attribute__((packed)); /* tv fill value */
unsigned short x_tvlen; /* length of .tv */
unsigned short x_tvran[2]; /* tv range */
} x_tv; /* info about .tv section (in auxent of symbol .tv)) */
};
#define SYMENT struct external_syment
#define SYMESZ sizeof(SYMENT)
#define AUXENT union external_auxent
#define AUXESZ sizeof(AUXENT)
# define _ETEXT "etext"
/* Relocatable symbols have number of the section in which they are defined,
or one of the following: */
#define N_UNDEF ((short)0) /* undefined symbol */
#define N_ABS ((short)-1) /* value of symbol is absolute */
#define N_DEBUG ((short)-2) /* debugging symbol -- value is meaningless */
#define N_TV ((short)-3) /* indicates symbol needs preload transfer vector */
#define P_TV ((short)-4) /* indicates symbol needs postload transfer vector*/
/*
* Type of a symbol, in low N bits of the word
*/
#define T_NULL 0
#define T_VOID 1 /* function argument (only used by compiler) */
#define T_CHAR 2 /* character */
#define T_SHORT 3 /* short integer */
#define T_INT 4 /* integer */
#define T_LONG 5 /* long integer */
#define T_FLOAT 6 /* floating point */
#define T_DOUBLE 7 /* double word */
#define T_STRUCT 8 /* structure */
#define T_UNION 9 /* union */
#define T_ENUM 10 /* enumeration */
#define T_MOE 11 /* member of enumeration*/
#define T_UCHAR 12 /* unsigned character */
#define T_USHORT 13 /* unsigned short */
#define T_UINT 14 /* unsigned integer */
#define T_ULONG 15 /* unsigned long */
#define T_LNGDBL 16 /* long double */
/*
* derived types, in n_type
*/
#define DT_NON (0) /* no derived type */
#define DT_PTR (1) /* pointer */
#define DT_FCN (2) /* function */
#define DT_ARY (3) /* array */
#define BTYPE(x) ((x) & N_BTMASK)
#define ISPTR(x) (((x) & N_TMASK) == (DT_PTR << N_BTSHFT))
#define ISFCN(x) (((x) & N_TMASK) == (DT_FCN << N_BTSHFT))
#define ISARY(x) (((x) & N_TMASK) == (DT_ARY << N_BTSHFT))
#define ISTAG(x) ((x)==C_STRTAG||(x)==C_UNTAG||(x)==C_ENTAG)
#define DECREF(x) ((((x)>>N_TSHIFT)&~N_BTMASK)|((x)&N_BTMASK))
/********************** STORAGE CLASSES **********************/
/* This used to be defined as -1, but now n_sclass is unsigned. */
#define C_EFCN 0xff /* physical end of function */
#define C_NULL 0
#define C_AUTO 1 /* automatic variable */
#define C_EXT 2 /* external symbol */
#define C_STAT 3 /* static */
#define C_REG 4 /* register variable */
#define C_EXTDEF 5 /* external definition */
#define C_LABEL 6 /* label */
#define C_ULABEL 7 /* undefined label */
#define C_MOS 8 /* member of structure */
#define C_ARG 9 /* function argument */
#define C_STRTAG 10 /* structure tag */
#define C_MOU 11 /* member of union */
#define C_UNTAG 12 /* union tag */
#define C_TPDEF 13 /* type definition */
#define C_USTATIC 14 /* undefined static */
#define C_ENTAG 15 /* enumeration tag */
#define C_MOE 16 /* member of enumeration */
#define C_REGPARM 17 /* register parameter */
#define C_FIELD 18 /* bit field */
#define C_AUTOARG 19 /* auto argument */
#define C_LASTENT 20 /* dummy entry (end of block) */
#define C_BLOCK 100 /* ".bb" or ".eb" */
#define C_FCN 101 /* ".bf" or ".ef" */
#define C_EOS 102 /* end of structure */
#define C_FILE 103 /* file name */
#define C_LINE 104 /* line # reformatted as symbol table entry */
#define C_ALIAS 105 /* duplicate tag */
#define C_HIDDEN 106 /* ext symbol in dmert public lib */
/********************** RELOCATION DIRECTIVES **********************/
struct external_reloc {
unsigned long r_vaddr __attribute__((packed));
unsigned long r_symndx __attribute__((packed));
unsigned short r_type;
};
#define RELOC struct external_reloc
#define RELSZ sizeof(RELOC)
#define RELOC_REL32 20 /* 32-bit PC-relative address */
#define RELOC_ADDR32 6 /* 32-bit absolute address */
#define DEFAULT_DATA_SECTION_ALIGNMENT 4
#define DEFAULT_BSS_SECTION_ALIGNMENT 4
#define DEFAULT_TEXT_SECTION_ALIGNMENT 4
/* For new sections we havn't heard of before */
#define DEFAULT_SECTION_ALIGNMENT 4
//#endif /* !_POSIX_SOURCE */
//#endif /* !__STRICT_ANSI__ */
//#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */
#ifndef __dj_ENFORCE_FUNCTION_CALLS
#endif /* !__dj_ENFORCE_FUNCTION_CALLS */
#ifdef __cplusplus
}
#endif
#endif /* !__dj_include_coff_h_ */

View File

@@ -0,0 +1,72 @@
// registry key structures
typedef struct _KEY_BASIC_INFORMATION {
LARGE_INTEGER LastWriteTime;
ULONG TitleIndex;
ULONG NameLength;
WCHAR Name[1]; // variable size
} KEY_BASIC_INFORMATION, *PKEY_BASIC_INFORMATION;
typedef struct _KEY_NODE_INFORMATION {
LARGE_INTEGER LastWriteTime;
ULONG TitleIndex;
ULONG ClassOffset;
ULONG ClassLength;
ULONG NameLength;
WCHAR Name[1]; // variable size
} KEY_NODE_INFORMATION, *PKEY_NODE_INFORMATION;
typedef struct _KEY_FULL_INFORMATION {
LARGE_INTEGER LastWriteTime;
ULONG TitleIndex;
ULONG ClassOffset;
ULONG ClassLength;
ULONG SubKeys;
ULONG MaxNameLen;
ULONG MaxClassLen;
ULONG Values;
ULONG MaxValueNameLen;
ULONG MaxValueDataLen;
WCHAR Class[1]; // variable size
} KEY_FULL_INFORMATION, *PKEY_FULL_INFORMATION;
typedef struct _KEY_WRITE_TIME_INFORMATION {
LARGE_INTEGER LastWriteTime;
} KEY_WRITE_TIME_INFORMATION, *PKEY_WRITE_TIME_INFORMATION;
// key query value structures
typedef struct _KEY_VALUE_BASIC_INFORMATION {
ULONG TitleIndex;
ULONG Type;
ULONG NameLength;
WCHAR Name[1]; // variable size
} KEY_VALUE_BASIC_INFORMATION, *PKEY_VALUE_BASIC_INFORMATION;
typedef struct _KEY_VALUE_FULL_INFORMATION {
ULONG TitleIndex;
ULONG Type;
ULONG DataOffset;
ULONG DataLength;
ULONG NameLength;
WCHAR Name[1]; // variable size
} KEY_VALUE_FULL_INFORMATION, *PKEY_VALUE_FULL_INFORMATION;
typedef struct _KEY_VALUE_PARTIAL_INFORMATION {
ULONG TitleIndex;
ULONG Type;
ULONG DataLength;
UCHAR Data[1]; // variable size
} KEY_VALUE_PARTIAL_INFORMATION, *PKEY_VALUE_PARTIAL_INFORMATION;
typedef struct _KEY_VALUE_ENTRY {
PUNICODE_STRING ValueName;
ULONG DataLength;
ULONG DataOffset;
ULONG Type;
} KEY_VALUE_ENTRY, *PKEY_VALUE_ENTRY;

View File

@@ -0,0 +1,3 @@
VOID DbgBreakPoint(VOID);
ULONG DbgPrint(PCH Format,...);

View File

@@ -0,0 +1,250 @@
/* GENERAL DEFINITIONS ****************************************************/
#include <internal/hal/irq.h>
#include <ddk/kedef.h>
#include <ddk/iodef.h>
/*
* PURPOSE: Number of a thread priority levels
*/
#define NR_PRIORITY_LEVELS (32)
/*
* PURPOSE: Type of queue to insert a work item in
*/
enum
{
CriticalWorkQueue,
DelayedWorkQueue,
HyperCriticalWorkQueue,
};
/*
* Types of memory to allocate
*/
enum
{
NonPagedPool,
NonPagedPoolMustSucceed,
NonPagedPoolCacheAligned,
NonPagedPoolCacheAlignedMustS,
PagedPool,
PagedPoolCacheAligned,
};
/*
* This is a list of bug check types (not MS's)
*/
enum
{
APC_INDEX_MISMATCH = 1,
DEVICE_QUEUE_NOT_BUSY,
INVALID_AFFINITY_SET,
INVALID_DATA_ACCESS_TRAP,
INVALID_PROCESS_ATTACH_ATTEMPT,
INVALID_PROCESS_DEATTACH_ATTEMPT,
INVALID_SOFTWARE_INTERRUPT,
IRQL_NOT_DISPATCH_LEVEL,
IRQL_NOT_GREATER_OR_EQUAL,
NO_EXCEPTION_HANDLING_SUPPORT,
MAXIMUM_WAIT_OBJECTS_EXCEEDED,
MUTEX_LEVEL_NUMBER_VIOLATION,
NO_USER_MODE_CONTEXT,
SPIN_LOCK_ALREADY_OWNED,
SPIN_LOCK_NOT_OWNED,
THREAD_NOT_MUTEX_OWNER,
TRAP_CAUSE_UNKNOWN,
EMPTY_THREAD_REAPER_LIST,
CREATE_DELETE_LOCK_NOT_LOCKED,
LAST_CHANCE_CALLED_FROM_KMODE,
CID_HANDLE_CREATION,
CID_HANDLE_DELETION,
REFERENCE_BY_POINTER,
BAD_POOL_HEADER,
MEMORY_MANAGMENT,
PFN_SHARE_COUNT,
PFN_REFERENCE_COUNT,
NO_SPIN_LOCK_AVAILABLE,
KMODE_EXCEPTION_NOT_HANDLED,
SHARED_RESOURCE_CONV_ERROR,
KERNEL_APC_PENDING_DURING_EXIT,
QUOTA_UNDERFLOW,
FILE_SYSTEM,
FAT_FILE_SYSTEM,
NTFS_FILE_SYSTEM,
NPFS_FILE_SYSTEM,
CDFS_FILE_SYSTEM,
RDR_FILE_SYSTEM,
CORRUPT_ACCESS_TOKEN,
SECURITY_SYSTEM,
INCONSISTENT_IRP,
PANIC_STACK_SWITCH,
PORT_DRIVER_INTERNAL,
SCSI_DISK_DRIVER_INTERNAL,
INSTRUCTION_BUS_ERROR,
SET_OF_INVALID_CONTEXT,
PHASE0_INITIALIZATION_FAILED,
PHASE1_INITIALIZATION_FAILED,
UNEXPECTED_INITIALIZATION_CALL,
CACHE_MANAGER,
NO_MORE_IRP_STACK_LOCATIONS,
DEVICE_REFERENCE_COUNT_NOT_ZERO,
FLOPPY_INTERNAL_ERROR,
SERIAL_DRIVER_INTERNAL,
SYSTEM_EXIT_OWNED_MUTEX,
SYSTEM_UNWIND_PREVIOUS_USER,
SYSTEN_SERVICE_EXCEPTION,
INTERRUPT_UNWIND_ATTEMPTED,
INTERRUPT_EXCEPTION_NOT_HANDLED,
MULTIPROCESSOR_CONFIGURATION_NOT_SUPPORTED,
NO_MORE_SYSTEM_PTES,
TARGET_MDL_TOO_SMALL,
MUST_SUCCEED_POOL_EMPTY,
ATDISK_DRIVER_INTERNAL,
NO_SUCH_PARTITION,
MULTIPLE_IRP_COMPLETE_REQUESTS,
INSUFFICENT_SYSTEM_MAP_PAGES,
DEREF_UNKNOWN_LOGON_SERVICE,
REF_UNKNOWN_LOGON_SERVICE,
CANCEL_STATE_IN_COMPLETED_IRP,
PAGE_FAULT_WITH_INTERRUPTS_OFF,
IRQL_GT_ZERO_AT_SYSTEM_SERVICE,
STREAMS_INTERNAL_ERROR,
FATAL_UNHANDLED_HARD_ERROR,
NO_PAGES_AVAILABLE,
PFN_LIST_CORRUPT,
NDIS_INTERNAL_ERROR,
PAGE_FAULT_IN_NONPAGED_AREA,
REGISTRY_ERROR,
MAILSLOT_FILE_SYSTEM,
NO_BOOT_DEVICE,
LM_SERVER_INTERNAL_ERROR,
DATA_COHERENCY_EXCEPTION,
INSTRUCTION_COHERENCY_EXCEPTION,
XNS_INTERNAL_ERROR,
FTDISK_INTERNAL_ERROR,
PINBALL_FILE_SYSTEM,
CRITICAL_SERVICE_FAILED,
SET_ENV_VAR_FAILED,
HAL_INITIALIZED_FAILED,
UNSUPPORTED_PROCESSOR,
OBJECT_INITIALIZATION_FAILED,
SECURITY_INITIALIZATION_FAILED,
PROCESS_INITIALIZATION_FAILED,
HAL1_INITIALIZATION_FAILED,
};
enum
{
KBUG_NONE,
KBUG_ORPHANED_IRP,
KBUG_IO_STACK_OVERFLOW,
KBUG_OUT_OF_MEMORY,
KBUG_POOL_FREE_LIST_CORRUPT,
/*
* These are well known but the actual value is unknown
*/
// NO_PAGES_AVAILABLE,
/*
* These are well known (MS) bug types
* (Reference: NT Insider 1997 - http://www.osr.com)
*/
IRQL_NOT_LESS_OR_EQUAL = 0xa,
// KMODE_EXCEPTION_NOT_HANDLED = 0x1e,
UNEXPECTED_KERNEL_MODE_TRAP = 0x7f,
PAGE_FAULT_IN_NON_PAGED_AREA = 0x50,
};
/*
* PURPOSE: Object attributes
*/
enum
{
OBJ_INHERIT = 0x1,
OBJ_PERMANENT = 0x2,
OBJ_EXCLUSIVE = 0x4,
OBJ_CASE_INSENSITIVE = 0x8,
OBJ_OPENIF = 0x10,
};
/*
* PURPOSE: DPC priorities
*/
enum
{
High,
Medium,
Low,
};
/*
* PURPOSE: Timer types
*/
enum
{
NotificationTimer,
SynchronizationTimer,
};
/*
* PURPOSE: Some drivers use these
*/
#define IN
#define OUT
#define OPTIONAL
/*
* PURPOSE: Power IRP minor function numbers
*/
enum
{
IRP_MN_QUERY_POWER,
IRP_MN_SET_POWER,
IRP_MN_WAIT_WAKE,
IRP_MN_QUERY_CAPABILITIES,
IRP_MN_POWER_SEQUENCE,
};
/*
* PURPOSE: Used all over
*/
enum
{
KernelMode,
UserMode,
};
/*
* PURPOSE: Arguments to MmProbeAndLockPages
*/
enum
{
IoReadAccess,
IoWriteAccess,
IoModifyAccess,
};
#define MAXIMUM_VOLUME_LABEL_LENGTH (32)
/*
* IRQ levels
*/
enum
{
PASSIVE_LEVEL,
/*
* Which order for these (only DISPATCH_LEVEL is important for now)
*/
APC_LEVEL,
DISPATCH_LEVEL,
/*
* Above here are device specific IRQ levels
*/
FIRST_DEVICE_SPECIFIC_LEVEL,
HIGH_LEVEL = FIRST_DEVICE_SPECIFIC_LEVEL + NR_DEVICE_SPECIFIC_LEVELS,
};

View File

@@ -0,0 +1,96 @@
/* EXECUTIVE ROUTINES ******************************************************/
VOID ExAcquireFastMutex(PFAST_MUTEX FastMutex);
VOID ExAcquireFastMutexUnsafe(PFAST_MUTEX FastMutex);
BOOLEAN ExAcquireResourceExclusive(PERESOURCE Resource, BOOLEAN Wait);
BOOLEAN ExAcquireResourceExclusiveLite(PERESOURCE Resource, BOOLEAN Wait);
BOOLEAN ExAcquireResourceSharedLite(PERESOURCE Resource, BOOLEAN Wait);
BOOLEAN ExAcquireSharedStarveExclusive(PERESOURCE Resource, BOOLEAN Wait);
BOOLEAN ExAcquireSharedWaitForExclusive(PERESOURCE Resource, BOOLEAN Wait);
PVOID ExAllocateFromNPagedLookasideList(PNPAGED_LOOKASIDE_LIST LookSide);
PVOID ExAllocateFromPagedLookasideList(PPAGED_LOOKASIDE_LIST LookSide);
PVOID ExAllocateFromZone(PZONE_HEADER Zone);
/*
* FUNCTION: Allocates memory from the nonpaged pool
* ARGUMENTS:
* size = minimum size of the block to be allocated
* PoolType = the type of memory to use for the block (ignored)
* RETURNS:
* the address of the block if it succeeds
*/
PVOID ExAllocatePool(POOL_TYPE PoolType, ULONG size);
PVOID ExAllocatePoolWithQuota(POOL_TYPE PoolType, ULONG NumberOfBytes);
PVOID ExAllocatePoolWithQuotaTag(POOL_TYPE PoolType, ULONG NumberOfBytes,
ULONG Tag);
PVOID ExAllocatePoolWithTag(POOL_TYPE PoolType, ULONG NumberOfBytes,
ULONG Tag);
VOID ExConvertExclusiveToSharedLite(PERESOURCE Resource);
VOID ExDeleteNPagedLookasideList(PNPAGED_LOOKASIDE_LIST Lookaside);
VOID ExDeletePagedLookasideList(PPAGED_LOOKASIDE_LIST Lookaside);
NTSTATUS ExDeleteResource(PERESOURCE Resource);
NTSTATUS ExDeleteResourceLite(PERESOURCE Resource);
NTSTATUS ExExtendZone(PZONE_HEADER Zone, PVOID Segment, ULONG SegmentSize);
/*
* FUNCTION: Releases previously allocated memory
* ARGUMENTS:
* block = block to free
*/
VOID ExFreePool(PVOID block);
VOID ExFreeToNPagedLookasideList(PNPAGED_LOOKASIDE_LIST Lookaside,
PVOID Entry);
VOID ExFreeToPagedLookasideList(PPAGED_LOOKASIDE_LIST Lookaside,
PVOID Entry);
PVOID ExFreeToZone(PZONE_HEADER Zone, PVOID Block);
ERESOURCE_THREAD ExGetCurrentResourceThread(VOID);
ULONG ExGetExclusiveWaiterCount(PERESOURCE Resource);
ULONG ExGetSharedWaiterCount(PERESOURCE Resource);
VOID ExInitializeFastMutex(PFAST_MUTEX FastMutex);
VOID ExInitializeNPagedLookasideList(PNPAGED_LOOKASIDE_LIST Lookaside,
PALLOCATE_FUNCTION Allocate,
PFREE_FUNCTION Free,
ULONG Flags,
ULONG Size,
ULONG Tag,
USHORT Depth);
VOID ExInitializePagedLookasideList(PPAGED_LOOKASIDE_LIST Lookaside,
PALLOCATE_FUNCTION Allocate,
PFREE_FUNCTION Free,
ULONG Flags,
ULONG Size,
ULONG Tag,
USHORT Depth);
NTSTATUS ExInitializeResource(PERESOURCE Resource);
NTSTATUS ExInitializeResourceLite(PERESOURCE Resource);
VOID ExInitializeSListHead(PSLIST_HEADER SListHead);
VOID ExInitializeWorkItem(PWORK_QUEUE_ITEM Item,
PWORKER_THREAD_ROUTINE Routine,
PVOID Context);
NTSTATUS ExInitializeZone(PZONE_HEADER Zone,
ULONG BlockSize,
PVOID InitialSegment,
ULONG InitialSegmentSize);
LARGE_INTEGER ExInterlockedAddLargeInteger(PLARGE_INTEGER Addend,
LARGE_INTEGER Increment,
PKSPIN_LOCK Lock);
ULONG ExInterlockedAddUlong(PULONG Addend, ULONG Increment, PKSPIN_LOCK Lock);
VOID ExInterlockedRemoveEntryList(PLIST_ENTRY ListHead, PLIST_ENTRY Entry,
PKSPIN_LOCK Lock);
VOID RemoveEntryFromList(PLIST_ENTRY ListHead, PLIST_ENTRY Entry);
PLIST_ENTRY ExInterlockedRemoveHeadList(PLIST_ENTRY Head, PKSPIN_LOCK Lock);
PLIST_ENTRY ExInterlockedInsertTailList(PLIST_ENTRY ListHead,
PLIST_ENTRY ListEntry,
PKSPIN_LOCK Lock);
PLIST_ENTRY ExInterlockedInsertHeadList(PLIST_ENTRY ListHead,
PLIST_ENTRY ListEntry,
PKSPIN_LOCK Lock);
VOID ExQueueWorkItem(PWORK_QUEUE_ITEM WorkItem,
WORK_QUEUE_TYPE QueueType);

View File

@@ -0,0 +1,127 @@
typedef ULONG INTERLOCKED_RESULT;
typedef ULONG WORK_QUEUE_TYPE;
typedef ULONG ERESOURCE_THREAD, *PERESOURCE_THREAD;
typedef struct _OWNER_ENTRY
{
ERESOURCE_THREAD OwnerThread;
union
{
LONG OwnerCount;
ULONG TableSize;
} a;
} OWNER_ENTRY, *POWNER_ENTRY;
typedef struct _ERESOURCE
{
LIST_ENTRY SystemResourcesList;
POWNER_ENTRY OwnerTable;
SHORT ActiveCount;
USHORT Flag;
PKSEMAPHORE SharedWaiters;
PKEVENT ExclusiveWaiters;
OWNER_ENTRY OwnerThreads[2];
ULONG ContentionCount;
USHORT NumberOfSharedWaiters;
USHORT NumberOfExclusiveWaiters;
union
{
PVOID Address;
ULONG CreatorBackTraceIndex;
} a;
KSPIN_LOCK SpinLock;
} ERESOURCE, *PERESOURCE;
typedef struct
{
LONG Count;
struct _KTHREAD* Owner;
ULONG Contention;
KEVENT Event;
ULONG OldIrql;
} FAST_MUTEX, *PFAST_MUTEX;
typedef struct _ZONE_HEADER
{
SINGLE_LIST_ENTRY FreeList;
SINGLE_LIST_ENTRY SegmentList;
ULONG BlockSize;
ULONG TotalSegmentSize;
} ZONE_HEADER, *PZONE_HEADER;
typedef struct _ZONE_SEGMENT
{
SINGLE_LIST_ENTRY Entry;
ULONG size;
} ZONE_SEGMENT, *PZONE_SEGMENT;
typedef struct _ZONE_ENTRY
{
SINGLE_LIST_ENTRY Entry;
} ZONE_ENTRY, *PZONE_ENTRY;
typedef VOID (*PWORKER_THREAD_ROUTINE)(PVOID Parameter);
typedef struct _WORK_QUEUE_ITEM
{
LIST_ENTRY Entry;
PWORKER_THREAD_ROUTINE Routine;
PVOID Context;
} WORK_QUEUE_ITEM, *PWORK_QUEUE_ITEM;
typedef PVOID (*PALLOCATE_FUNCTION)(POOL_TYPE PoolType,
ULONG NumberOfBytes,
ULONG Tag);
typedef VOID (*PFREE_FUNCTION)(PVOID Buffer);
typedef union _SLIST_HEADER
{
ULONGLONG Alignment;
struct
{
SINGLE_LIST_ENTRY Next;
USHORT Depth;
USHORT Sequence;
} s;
} SLIST_HEADER, *PSLIST_HEADER;
typedef struct
{
SLIST_HEADER ListHead;
USHORT Depth;
USHORT Pad;
ULONG TotalAllocates;
ULONG AllocateMisses;
ULONG TotalFrees;
ULONG TotalMisses;
POOL_TYPE Type;
ULONG Tag;
ULONG Size;
PALLOCATE_FUNCTION Allocate;
PFREE_FUNCTION Free;
LIST_ENTRY ListEntry;
KSPIN_LOCK Lock;
} NPAGED_LOOKASIDE_LIST, *PNPAGED_LOOKASIDE_LIST;
typedef struct
{
SLIST_HEADER ListHead;
USHORT Depth;
USHORT Pad;
ULONG TotalAllocates;
ULONG AllocateMisses;
ULONG TotalFrees;
ULONG TotalMisses;
POOL_TYPE Type;
ULONG Tag;
ULONG Size;
PALLOCATE_FUNCTION Allocate;
PFREE_FUNCTION Free;
LIST_ENTRY ListEntry;
FAST_MUTEX Lock;
} PAGED_LOOKASIDE_LIST, *PPAGED_LOOKASIDE_LIST;

View File

@@ -0,0 +1,18 @@
#ifndef __INCLUDE_DDK_IOCTRL_H
#define __INCLUDE_DDK_IOCTRL_H
#define CTL_CODE(Dev, Func, Meth, Acc) ( ((Dev)<<16) | ((Acc)<<14) | ((Func)<<2) | (Meth))
// IOCTL Parameter buffering methods
#define METHOD_BUFFERED 0
#define METHOD_IN_DIRECT 1
#define METHOD_OUT_DIRECT 2
#define METHOD_NEITHER 3
// IOCTL File access type
#define FILE_ANY_ACCESS 0
#define FILE_READ_ACCESS 1
#define FILE_WRITE_ACCESS 2
#endif /* __INCLUDE_DDK_IOCTRL_H */

301
reactos/include/ddk/iodef.h Normal file
View File

@@ -0,0 +1,301 @@
#ifndef __INCLUDE_DDK_IODEF_H
#define __INCLUDE_DDK_IODEF_H
typedef enum _IO_QUERY_DEVICE_DESCRIPTION
{
IoQueryDeviceIdentifier = 0,
IoQueryDeviceConfigurationData,
IoQueryDeviceComponentInformation,
IoQueryDeviceDataFormatMaximum,
} IO_QUERY_DEVICE_DESCRIPTION, *PIO_QUERY_DEVICE_DESCRIPTION;
typedef enum _CONFIGURATION_TYPE
{
DiskController,
ParallelController,
MaximumType,
} CONFIGURATION_TYPE, *PCONFIGURATION_TYPE;
typedef enum _CM_RESOURCE_TYPE
{
CmResourceTypePort = 1,
CmResourceTypeInterrupt,
CmResourceTypeMemory,
CmResourceTypeDma,
CmResourceTypeDeviceSpecific,
CmResourceTypeMaximum,
} CM_RESOURCE_TYPE;
typedef enum _CM_SHARE_DISPOSITION
{
CmResourceShareDeviceExclusive = 1,
CmResourceShareDriverExclusive,
CmResourceShareShared,
CmResourceShareMaximum,
} CM_SHARE_DISPOSITION;
enum
{
CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE,
CM_RESOURCE_INTERRUPT_LATCHED,
};
enum
{
CM_RESOURCE_PORT_MEMORY,
CM_RESOURCE_PORT_IO,
};
/*
* PURPOSE: Irp flags
*/
enum
{
/*
* Read any data from the actual backing media
*/
IRP_NOCACHE,
/*
* The I/O operation is performing paging
*/
IRP_PAGING_IO,
/*
* The IRP is for a mount operation
*/
IRP_MOUNT_COMPLETION,
/*
* The API expects synchronous behaviour
*/
IRP_SYNCHRONOUS_API,
/*
* The IRP is associated with a larger operation
*/
IRP_ASSOCIATED_IRP,
/*
* The AssociatedIrp.SystemBuffer field is valid
*/
IRP_BUFFERED_IO,
/*
* The system buffer was allocated from pool and should be deallocated
* by the I/O manager
*/
IRP_DEALLOCATE_BUFFER,
/*
* The IRP is for an input operation
*/
IRP_INPUT_OPERATION,
/*
* The paging operation should complete synchronously
*/
IRP_SYNCHRONOUS_PAGING_IO,
/*
* The IRP represents a filesystem create operation
*/
IRP_CREATE_OPERATION,
/*
* The IRP represents a filesystem read operation
*/
IRP_READ_OPERATION,
/*
* The IRP represents a filesystem write operation
*/
IRP_WRITE_OPERATION,
/*
* The IRP represents a filesystem close operation
*/
IRP_CLOSE_OPERATION,
/*
* Asynchronous behavior is advised but not required
*/
IRP_DEFER_IO_COMPLETION,
};
/*
* I/O operation flags
*/
enum
{
/*
* Force an access check even if opened in kernel mode
*/
SL_FORCE_ACCESS_CHECK,
/*
* The file being opened is a paging file
*/
SL_OPEN_PAGING_FILE,
SL_OPEN_TARGET_DIRECTORY,
SL_CASE_SENSITIVE,
SL_KEY_SPECIFIED,
SL_OVERRIDE_VERIFY_VOLUME,
SL_WRITE_THROUGH,
SL_FT_SEQUENTIAL_WRITE,
SL_FAIL_IMMEDIATELY,
SL_EXCLUSIVE_LOCK,
SL_RESTART_SCAN,
SL_RETURN_SINGLE_ENTRY,
SL_INDEX_SPECIFIED,
SL_WATCH_TREE,
SL_ALLOW_RAW_MOUNT,
SL_PENDING_RETURNED,
};
enum
{
SL_INVOKE_ON_SUCCESS = 1,
SL_INVOKE_ON_ERROR = 2,
SL_INVOKE_ON_CANCEL = 4,
};
/*
* Possible flags for the device object flags
*/
enum
{
DO_BUFFERED_IO = 0x1,
DO_DIRECT_IO = 0x2,
};
/*
* Possible device types
*/
enum
{
/*
* Standard define types
*/
FILE_DEVICE_BEEP,
FILE_DEVICE_CDROM,
FILE_DEVICE_CONTROLLER,
FILE_DEVICE_DISK,
FILE_DEVICE_INPORT_PORT,
FILE_DEVICE_KEYBOARD,
FILE_DEVICE_MIDI_IN,
FILE_DEVICE_MIDI_OUT,
FILE_DEVICE_MOUSE,
FILE_DEVICE_NULL,
FILE_DEVICE_PARALLEL_PORT,
FILE_DEVICE_PRINTER,
FILE_DEVICE_SCANNER,
FILE_DEVICE_SERIAL_MOUSE_PORT,
FILE_DEVICE_SERIAL_PORT,
FILE_DEVICE_SCREEN,
FILE_DEVICE_TAPE,
FILE_DEVICE_UNKNOWN,
FILE_DEVICE_VIDEO,
FILE_DEVICE_VIRTUAL_DISK,
FILE_DEVICE_WAVE_IN,
FILE_DEVICE_WAVE_OUT,
FILE_DEVICE_8042_PORT,
/*
* Values beyond this are reserved for ISVs
*/
FILE_DEVICE_FIRST_FREE = 32768
};
/*
* Possible device characteristics
*/
enum
{
FILE_REMOVABLE_MEDIA = 0x1,
FILE_READ_ONLY_DEVICE = 0x2,
FILE_FLOPPY_DISKETTE = 0x4,
FILE_WRITE_ONCE_MEDIA = 0x8,
FILE_REMOTE_DEVICE = 0x10,
};
/*
* PURPOSE: Bus types
*/
enum
{
Internal,
Isa,
MicroChannel,
TurboChannel,
PCIBus,
MaximumInterfaceType,
};
/*
* FIXME: These are not in the correct order
*/
enum
{
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_QUERY_POWER,
IRP_MJ_SET_POWER,
IRP_MJ_DEVICE_CHANGE,
IRP_MJ_QUERY_QUOTA,
IRP_MJ_SET_QUOTA,
IRP_MJ_PNP_POWER,
IRP_MJ_MAXIMUM_FUNCTION,
};
enum
/*
* PURPOSE: Details about the result of a file open or create
*/
{
FILE_CREATED,
// FILE_OPENED,
FILE_OVERWRITTEN,
FILE_SUPERSEDED,
FILE_EXISTS,
FILE_DOES_NOT_EXIST,
};
#endif

View File

@@ -0,0 +1,523 @@
/* IO MANAGER ***************************************************************/
/*
* FUNCTION: Registers the driver with WMI
* ARGUMENTS:
* DeviceObject = Device to register
* Action = Action to take
* RETURNS: Status (?)
*/
//NTSTATUS IoWMIRegistrationControl(DeviceObject, WMIREGACTION Action);
/*
* FUNCTION: Synchronizes cancelable-state transistions for IRPs in a
* multiprocessor-safe way
* ARGUMENTS:
* Irpl = Variable to store the current IRQ level
*/
VOID IoAcquireCancelSpinLock(PKIRQL Irpl);
typedef IO_ALLOCATION_ACTION (*PDRIVER_CONTROL)(PDEVICE_OBJECT DeviceObject,
PIRP irp,
PVOID MapRegisterBase,
PVOID Context);
/*
* FUNCTION: Allocates an adaptor object for a DMA operation on the target
* device
* ARGUMENTS:
* Adaptor = Adapter channel or busmaster adapter to be allocated
* DeviceObject = Target device for DMA
* NumberOfMapRegisters = Number of map registers
* ExecutionRoutine = Routine to be called when the adaptor is
* available
* Context = driver defined contex that will be passed to the
* execution routine
* RETURNS: Success or failure code
*/
NTSTATUS IoAllocateAdapterChannel(PADAPTER_OBJECT AdaperObject,
PDEVICE_OBJECT DeviceObject,
ULONG NumberOfMapRegisters,
PDRIVER_CONTROL ExecutionRoutine,
PVOID Context);
/*
* FUNCTION: Sets up a call to a driver supplied controller object as
* soon as it is available
* ARGUMENTS:
* ControllerObject = Driver created controller object
* DeviceObject = target device
* ExecutionObject = Routine to be called
* Context = Driver determined context to be based to the routine
*/
VOID IoAllocateController(PCONTROLLER_OBJECT ControllerObject,
PDEVICE_OBJECT DeviceObject,
PDRIVER_CONTROL ExecutionRoutine,
PVOID Context);
/*
* FUNCTION: Allocates an error log packet
* ARGUMENTS:
* IoObject = Object which found the error
* EntrySize = Size in bytes of the packet to be allocated
* RETURNS: On success a pointer to the allocated packet
* On failure returns NULL
*/
PVOID IoAllocateErrorLogEntry(PVOID IoObject, UCHAR EntrySize);
/*
* FUNCTION: Allocates an IRP
* ARGUMENTS:
* StackSize = number of stack locations to allocate
* ChargeQuota = Who knows
* RETURNS: On success the allocated IRP
* On failure NULL
*/
PIRP IoAllocateIrp(CCHAR StackSize, BOOLEAN ChargeQuota);
/*
* FUNCTION: Allocates an MDL large enough to map the supplied buffer
* ARGUMENTS:
* VirtualAddress = base virtual address of the buffer to be mapped
* Length = length of the buffer to be mapped
* SecondaryBuffer = Whether the buffer is primary or secondary
* ChargeQuota = Charge non-paged pool quota to current thread
* Irp = Optional irp to be associated with the MDL
* RETURNS: On the success the allocated MDL
* On failure NULL
*/
PMDL IoAllocateMdl(PVOID VirtualAddress, ULONG Length,
BOOLEAN SecondaryBuffer, BOOLEAN ChargeQuota,
PIRP Irp);
/*
* FUNCTION: Creates a symbolic link between the ARC name of a physical
* device and the name of the corresponding device object
* ARGUMENTS:
* ArcName = ARC name of the device
* DeviceName = Name of the device object
*/
VOID IoAssignArcName(PUNICODE_STRING ArcName, PUNICODE_STRING DeviceName);
enum
{
IO_NO_INCREMENT,
};
/*
* FUNCTION: Takes a list of requested hardware resources and allocates them
* ARGUMENTS:
* RegisterPath =
* DriverClassName =
* DriverObject = Driver object passed to the DriverEntry routine
* DeviceObject =
* RequestedResources = List of resources
* RETURNS:
*/
NTSTATUS IoAssignResources(PUNICODE_STRING RegistryPath,
PUNICODE_STRING DriverClassName,
PDRIVER_OBJECT DriverObject,
PDEVICE_OBJECT DeviceObject,
PIO_RESOURCE_REQUIREMENTS_LIST RequestedResources,
PCM_RESOURCE_LIST* AllocatedResources);
/*
* FUNCTION: Attaches the callers device object to a named target device
* ARGUMENTS:
* SourceDevice = caller's device
* TargetDevice = Name of the target device
* AttachedDevice = Caller allocated storage. On return contains
* a pointer to the target device
* RETURNS: Success or failure code
*/
NTSTATUS IoAttachDevice(PDEVICE_OBJECT SourceDevice,
PUNICODE_STRING TargetDevice,
PDEVICE_OBJECT* AttachedDevice);
/*
* FUNCTION: Obsolete
* ARGUMENTS:
* SourceDevice = device to attach
* TargetDevice = device to be attached to
* RETURNS: Success or failure code
*/
NTSTATUS IoAttachDeviceByPointer(PDEVICE_OBJECT SourceDevice,
PDEVICE_OBJECT TargetDevice);
/*
* FUNCTION: Attaches the callers device to the highest device in the chain
* ARGUMENTS:
* SourceDevice = caller's device
* TargetDevice = Device to attach
* RETURNS: On success the previously highest device
* On failure NULL
*/
PDEVICE_OBJECT IoAttachDeviceToDeviceStack(PDEVICE_OBJECT SourceDevice,
PDEVICE_OBJECT TargetDevice);
/*
* FUNCTION: Builds a irp to be sent to lower level drivers
* ARGUMENTS:
* MajorFunction = Major function code to be set in the IRP
* DeviceObject = Next lower device object
* Buffer = Buffer (only required for some major function codes)
* Length = Length in bytes of the buffer
* StartingOffset = Starting offset on the target device
* IoStatusBlock = Storage for status about the operation (optional)
* RETURNS: On success the IRP allocated
* On failure NULL
*/
PIRP IoBuildAsynchronousFsdRequest(ULONG MajorFunction,
PDEVICE_OBJECT DeviceObject,
PVOID Buffer,
ULONG Length,
PLARGE_INTEGER StartingOffset,
PIO_STATUS_BLOCK IoStatusBlock);
/*
* FUNCTION: Allocates and sets up an IRP for a device control request
* ARGUMENTS:
* IoControlCode = Type of request
* DeviceObject = Target device
* InputBuffer = Optional input buffer to the driver
* InputBufferLength = Length of the input buffer
* OutputBuffer = Optional output buffer
* OutputBufferLength = Length of the output buffer
* InternalDeviceIoControl = TRUE if the request is internal
* Event = Initialized event for the caller to wait for the request
* to be completed
* IoStatusBlock = I/O status block to be set when the request is
* completed
* RETURNS: Returns the IRP created
*/
PIRP IoBuildDeviceIoControlRequest(ULONG IoControlCode,
PDEVICE_OBJECT DeviceObject,
PVOID InputBuffer,
ULONG InputBufferLength,
PVOID OutputBuffer,
ULONG OutputBufferLength,
BOOLEAN InternalDeviceIoControl,
PKEVENT Event,
PIO_STATUS_BLOCK IoStatusBlock);
VOID IoBuildPartialMdl(PMDL SourceMdl,
PMDL TargetMdl,
PVOID VirtualAddress,
ULONG Length);
PIRP IoBuildSynchronousFsdRequest(ULONG MajorFunction,
PDEVICE_OBJECT DeviceObject,
PVOID Buffer,
ULONG Length,
PLARGE_INTEGER StartingOffset,
PKEVENT Event,
PIO_STATUS_BLOCK IoStatusBlock);
/*
* FUNCTION: Sends an irp to the next lower driver
*/
NTSTATUS IoCallDriver(PDEVICE_OBJECT DeviceObject, PIRP irp);
BOOLEAN IoCancelIrp(PIRP Irp);
NTSTATUS IoCheckShareAccess(ACCESS_MASK DesiredAccess,
ULONG DesiredShareAccess,
PFILE_OBJECT FileObject,
PSHARE_ACCESS ShareAccess,
BOOLEAN Update);
/*
* FUNCTION: Indicates the caller has finished all processing for a given
* I/O request and is returning the given IRP to the I/O manager
* ARGUMENTS:
* Irp = Irp to be cancelled
* PriorityBoost = Increment by which to boost the priority of the
* thread making the request
*/
VOID IoCompleteRequest(PIRP Irp, CCHAR PriorityBoost);
NTSTATUS IoConnectInterrupt(PKINTERRUPT* InterruptObject,
PKSERVICE_ROUTINE ServiceRoutine,
PVOID ServiceContext,
PKSPIN_LOCK SpinLock,
ULONG Vector,
KIRQL Irql,
KIRQL SynchronizeIrql,
KINTERRUPT_MODE InterruptMode,
BOOLEAN ShareVector,
KAFFINITY ProcessorEnableMask,
BOOLEAN FloatingSave);
PCONTROLLER_OBJECT IoCreateController(ULONG Size);
/*
* FUNCTION: Allocates memory for and intializes a device object for use for
* a driver
* ARGUMENTS:
* DriverObject : Driver object passed by iomgr when the driver was
* loaded
* DeviceExtensionSize : Number of bytes for the device extension
* DeviceName : Unicode name of device
* DeviceType : Device type
* DeviceCharacteristics : Bit mask of device characteristics
* Exclusive : True if only one thread can access the device at a
* time
* RETURNS:
* Success or failure
* DeviceObject : Contains a pointer to allocated device object
* if the call succeeded
* NOTES: See the DDK documentation for more information
*/
NTSTATUS IoCreateDevice(PDRIVER_OBJECT DriverObject,
ULONG DeviceExtensionSize,
PUNICODE_STRING DeviceName,
DEVICE_TYPE DeviceType,
ULONG DeviceCharacteristics,
BOOLEAN Exclusive,
PDEVICE_OBJECT* DeviceObject);
PKEVENT IoCreateNotificationEvent(PUNICODE_STRING EventName,
PHANDLE EventHandle);
NTSTATUS IoCreateSymbolicLink(PUNICODE_STRING SymbolicLinkName,
PUNICODE_STRING DeviceName);
PKEVENT IoCreateSynchronizationEvent(PUNICODE_STRING EventName,
PHANDLE EventHandle);
NTSTATUS IoCreateUnprotectedSymbolicLink(PUNICODE_STRING SymbolicLinkName,
PUNICODE_STRING DeviceName);
VOID IoDeassignArcName(PUNICODE_STRING ArcName);
VOID IoDeleteController(PCONTROLLER_OBJECT ControllerObject);
VOID IoDeleteDevice(PDEVICE_OBJECT DeviceObject);
NTSTATUS IoDeleteSymbolicLink(PUNICODE_STRING SymbolicLinkName);
VOID IoDetachDevice(PDEVICE_OBJECT TargetDevice);
VOID IoDisconnectInterrupt(PKINTERRUPT InterruptObject);
BOOLEAN IoFlushAdapterBuffers(PADAPTER_OBJECT AdapterObject,
PMDL Mdl,
PVOID MapRegisterBase,
PVOID CurrentVa,
ULONG Length,
BOOLEAN WriteToDevice);
VOID IoFreeAdapterChannel(PADAPTER_OBJECT AdapterObject);
VOID IoFreeController(PCONTROLLER_OBJECT ControllerObject);
VOID IoFreeIrp(PIRP Irp);
VOID IoFreeMapRegisters(PADAPTER_OBJECT AdapterObject,
PVOID MapRegisterBase,
ULONG NumberOfMapRegisters);
VOID IoFreeMdl(PMDL Mdl);
PCONFIGURATION_INFORMATION IoGetConfigurationInformation(VOID);
/*
* FUNCTION: Returns a pointer to the callers stack location in the irp
*/
PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(IRP* irp);
struct _EPROCESS* IoGetCurrentProcess(VOID);
NTSTATUS IoGetDeviceObjectPointer(PUNICODE_STRING ObjectName,
ACCESS_MASK DesiredAccess,
PFILE_OBJECT* FileObject,
PDEVICE_OBJECT* DeviceObject);
PDEVICE_OBJECT IoGetDeviceToVerify(PETHREAD Thread);
PGENERIC_MAPPING IoGetFileObjectGenericMapping(VOID);
ULONG IoGetFunctionCodeFromCtlCode(ULONG ControlCode);
PVOID IoGetInitialStack(VOID);
/*
* FUNCTION:
*/
PIO_STACK_LOCATION IoGetNextIrpStackLocation(IRP* irp);
PDEVICE_OBJECT IoGetRelatedDeviceObject(PFILE_OBJECT FileObject);
VOID IoInitializeDpcRequest(PDEVICE_OBJECT DeviceObject,
PIO_DPC_ROUTINE DpcRoutine);
/*
* FUNCTION: Initalizes an irp allocated by the caller
* ARGUMENTS:
* Irp = IRP to initalize
* PacketSize = Size in bytes of the IRP
* StackSize = Number of stack locations in the IRP
*/
VOID IoInitializeIrp(PIRP Irp, USHORT PacketSize, CCHAR StackSize);
NTSTATUS IoInitializeTimer(PDEVICE_OBJECT DeviceObject,
PIO_TIMER_ROUTINE TimerRoutine,
PVOID Context);
BOOLEAN IoIsErrorUserInduced(NTSTATUS Status);
BOOLEAN IoIsTotalDeviceFailure(NTSTATUS Status);
PIRP IoMakeAssociatedIrp(PIRP Irp, CCHAR StackSize);
PHYSICAL_ADDRESS IoMapTransfer(PADAPTER_OBJECT AdapterObject,
PMDL Mdl,
PVOID MapRegisterBase,
PVOID CurrentVa,
PULONG Length,
BOOLEAN WriteToDevice);
/*
* FUNCTION: Marks an IRP as pending
* ARGUMENTS:
* Irp = Irp to mark
* NOTE: If a driver doesn't complete the irp in its dispatch routine it
* must mark it pending otherwise the I/O manager will complete it on
* return from the dispatch routine.
*/
VOID IoMarkIrpPending(PIRP Irp);
NTSTATUS IoQueryDeviceDescription(PINTERFACE_TYPE BusType,
PULONG BusNumber,
PCONFIGURATION_TYPE ControllerType,
PULONG ControllerNumber,
PCONFIGURATION_TYPE PeripheralType,
PULONG PeripheralNumber,
PIO_QUERY_DEVICE_ROUTINE CalloutRoutine,
PVOID Context);
VOID IoRaiseHardError(PIRP Irp, PVPB Vpb, PDEVICE_OBJECT RealDeviceObject);
BOOLEAN IoRaiseHardInformationalError(NTSTATUS ErrorStatus,
PUNICODE_STRING String,
PKTHREAD Thread);
NTSTATUS IoReadPartitionTable(PDEVICE_OBJECT DeviceObject,
ULONG SectorSize,
BOOLEAN ReturnedRecognizedPartitions,
struct _DRIVE_LAYOUT_INFORMATION** PBuffer);
VOID IoRegisterDriverReinitialization(PDRIVER_OBJECT DriverObject,
PDRIVER_REINITIALIZE ReinitRoutine,
PVOID Context);
NTSTATUS IoRegisterShutdownNotification(PDEVICE_OBJECT DeviceObject);
VOID IoReleaseCancelSpinLock(KIRQL Irql);
VOID IoRemoveShareAccess(PFILE_OBJECT FileObject,
PSHARE_ACCESS ShareAccess);
NTSTATUS IoReportResourceUsage(PUNICODE_STRING DriverClassName,
PDRIVER_OBJECT DriverObject,
PCM_RESOURCE_LIST DriverList,
ULONG DriverListSize,
PDEVICE_OBJECT DeviceObject,
PCM_RESOURCE_LIST DeviceList,
ULONG DeviceListSize,
BOOLEAN OverrideConflict,
PBOOLEAN ConflictDetected);
VOID IoRequestDpc(PDEVICE_OBJECT DeviceObject,
PIRP Irp,
PVOID Context);
PDRIVER_CANCEL IoSetCancelRoutine(PIRP Irp, PDRIVER_CANCEL CancelRoutine);
VOID IoSetCompletionRoutine(PIRP Irp,
PIO_COMPLETION_ROUTINE CompletionRoutine,
PVOID Context,
BOOLEAN InvokeOnSuccess,
BOOLEAN InvokeOnError,
BOOLEAN InvokeOnCancel);
VOID IoSetHardErrorOrVerifyDevice(PIRP Irp, PDEVICE_OBJECT DeviceObject);
VOID IoSetNextIrpStackLocation(PIRP Irp);
NTSTATUS IoSetPartitionInformation(PDEVICE_OBJECT DeviceObject,
ULONG SectorSize,
ULONG PartitionNumber,
ULONG PartitionType);
VOID IoSetShareAccess(ACCESS_MASK DesiredAccess,
ULONG DesiredShareAccess,
PFILE_OBJECT FileObject,
PSHARE_ACCESS ShareAccess);
/*
* FUNCTION: Determines the size of an IRP
* ARGUMENTS:
* StackSize = number of stack locations in the IRP
* RETURNS: The size of the IRP in bytes
*/
USHORT IoSizeOfIrp(CCHAR StackSize);
/*
* FUNCTION: Dequeues the next IRP from the device's associated queue and
* calls its StartIo routine
* ARGUMENTS:
* DeviceObject = Device object
* Cancelable = True if IRPs in the queue can be cancelled
*/
VOID IoStartNextPacket(PDEVICE_OBJECT DeviceObject, BOOLEAN Cancelable);
VOID IoStartNextPacketByKey(PDEVICE_OBJECT DeviceObject,
BOOLEAN Cancelable,
ULONG Key);
/*
* FUNCTION: Calls the drivers StartIO routine with the IRP or queues it if
* the device is busy
* ARGUMENTS:
* DeviceObject = Device to pass the IRP to
* Irp = Irp to be processed
* Key = Optional value for where to insert the IRP
* CancelFunction = Entry point for a driver supplied cancel function
*/
VOID IoStartPacket(PDEVICE_OBJECT DeviceObject, PIRP Irp, PULONG Key,
PDRIVER_CANCEL CancelFunction);
VOID IoStartTimer(PDEVICE_OBJECT DeviceObject);
VOID IoStopTimer(PDEVICE_OBJECT DeviceObject);
VOID IoUnregisterShutdownNotification(PDEVICE_OBJECT DeviceObject);
VOID IoUpdateShareAccess(PFILE_OBJECT FileObject, PSHARE_ACCESS ShareAccess);
VOID IoWriteErrorLogEntry(PVOID ElEntry);
NTSTATUS IoWritePartitionTable(PDEVICE_OBJECT DeviceObject,
ULONG SectorSize,
ULONG SectorsPerTrack,
ULONG NumberOfHeads,
struct _DRIVE_LAYOUT_INFORMATION* PBuffer);
typedef ULONG FS_INFORMATION_CLASS;
// Preliminary guess
NTKERNELAPI NTSTATUS IoQueryFileVolumeInformation(IN PFILE_OBJECT FileObject,
IN FS_INFORMATION_CLASS FsInformationClass,
IN ULONG Length,
OUT PVOID FsInformation,
OUT PULONG ReturnedLength);
NTKERNELAPI // confirmed - Undocumented because it does not require a valid file handle
NTSTATUS
IoQueryFileInformation(
IN PFILE_OBJECT FileObject,
IN FILE_INFORMATION_CLASS FileInformationClass,
IN ULONG Length,
OUT PVOID FileInformation,
OUT PULONG ReturnedLength
);

View File

@@ -0,0 +1,581 @@
/*
*
*/
#ifndef __INCLUDE_DDK_IOTYPES_H
#define __INCLUDE_DDK_IOTYPES_H
/*
* These are referenced before they can be fully defined
*/
struct _DRIVER_OBJECT;
struct _FILE_OBJECT;
struct _DEVICE_OBJECT;
struct _IRP;
struct _IO_STATUS_BLOCK;
/* SIMPLE TYPES *************************************************************/
enum
{
DeallocateObject,
KeepObject,
};
typedef ULONG INTERFACE_TYPE;
typedef INTERFACE_TYPE* PINTERFACE_TYPE;
/*
* FIXME: Definition needed
*/
typedef struct _SHARE_ACCESS
{
} SHARE_ACCESS, *PSHARE_ACCESS;
/* FUNCTION TYPES ************************************************************/
typedef VOID (*PDRIVER_REINITIALIZE)(struct _DRIVER_OBJECT* DriverObject,
PVOID Context,
ULONG Count);
typedef NTSTATUS (*PIO_QUERY_DEVICE_ROUTINE)(PVOID Context,
PUNICODE_STRING Pathname,
INTERFACE_TYPE BusType,
ULONG BusNumber,
PKEY_VALUE_FULL_INFORMATION* BI,
CONFIGURATION_TYPE ControllerType,
ULONG ControllerNumber,
PKEY_VALUE_FULL_INFORMATION* CI,
CONFIGURATION_TYPE PeripheralType,
ULONG PeripheralNumber,
PKEY_VALUE_FULL_INFORMATION* PI);
typedef NTSTATUS (*PIO_COMPLETION_ROUTINE)(struct _DEVICE_OBJECT* DeviceObject,
struct _IRP* Irp,
PVOID Context);
typedef VOID (*PIO_APC_ROUTINE) (PVOID ApcContext,
struct _IO_STATUS_BLOCK* IoStatusBlock,
ULONG Reserved);
/* STRUCTURE TYPES ***********************************************************/
typedef struct _ADAPTER_OBJECT
{
} ADAPTER_OBJECT, *PADAPTER_OBJECT;
/*
* PURPOSE: Special timer associated with each device
* NOTES: This is a guess
*/
typedef struct _IO_TIMER
{
KTIMER timer;
KDPC dpc;
} IO_TIMER, *PIO_TIMER;
/*
* PURPOSE: IRP stack location
*/
typedef struct _IO_STACK_LOCATION
{
/*
* Type of request
*/
UCHAR MajorFunction;
/*
* Further information about request type
*/
UCHAR MinorFunction;
/*
*
*/
UCHAR Flags;
/*
* FUNCTION: Various flags including for the io completion routine
*/
UCHAR Control;
/*
* Parameters for request
*/
union
{
struct
{
/*
* Number of bytes to be transferrred
*/
ULONG Length;
/*
* Possibly used to sort incoming request (to be documented)
*/
ULONG Key;
/*
* Optional starting offset for read
*/
LARGE_INTEGER ByteOffset;
} Read;
struct
{
ULONG Length;
ULONG Key;
LARGE_INTEGER ByteOffset;
} Write;
struct
{
ULONG OutputBufferLength;
ULONG InputBufferLength;
ULONG IoControlCode;
PVOID Type3InputBuffer;
} DeviceIoControl;
} Parameters;
/*
* PURPOSE: Completion routine
* NOTE: If this is the nth stack location (where the 1st is passed to the
* highest level driver) then this is the completion routine set by
* the (n-1)th driver
*/
PIO_COMPLETION_ROUTINE CompletionRoutine;
PVOID CompletionContext;
/*
* Driver created device object representing the target device
*/
struct _DEVICE_OBJECT* DeviceObject;
/*
* File object (if any) associated with DeviceObject
*/
struct _FILE_OBJECT* FileObject;
} IO_STACK_LOCATION, *PIO_STACK_LOCATION;
typedef struct _IO_STATUS_BLOCK
{
/*
* Is the completion status
*/
NTSTATUS Status;
/*
* Is a request dependant value
*/
ULONG Information;
} IO_STATUS_BLOCK, *PIO_STATUS_BLOCK;
/*
* Driver entry point declaration
*/
typedef NTSTATUS (*PDRIVER_INITIALIZE)(struct _DRIVER_OBJECT* DriverObject,
PUNICODE_STRING RegistryPath);
/*
* Driver cancel declaration
*/
typedef NTSTATUS (*PDRIVER_CANCEL)(struct _DRIVER_OBJECT* DriverObject,
PUNICODE_STRING RegistryPath);
typedef struct _SECTION_OBJECT_POINTERS
{
PVOID DataSectionObject;
PVOID SharedCacheMap;
PVOID ImageSectionObject;
} SECTION_OBJECT_POINTERS, *PSECTION_OBJECT_POINTERS;
typedef struct _IO_COMPLETION_CONTEXT
{
PVOID Port;
ULONG Key;
} IO_COMPLETION_CONTEXT, *PIO_COMPLETION_CONTEXT;
#define FO_FILE_OPEN 0x00000001
#define FO_SYNCHRONOUS_IO 0x00000002
#define FO_ALERTABLE_IO 0x00000004
#define FO_NO_INTERMEDIATE_BUFFERING 0x00000008
#define FO_WRITE_THROUGH 0x00000010
#define FO_SEQUENTIAL_ONLY 0x00000020
#define FO_CACHE_SUPPORTED 0x00000040
#define FO_NAMED_PIPE 0x00000080
#define FO_STREAM_FILE 0x00000100
#define FO_MAILSLOT 0x00000200
#define FO_GENERATE_AUDIT_ON_CLOSE 0x00000400
#define FO_DIRECT_DEVICE_OPEN 0x00000800
#define FO_FILE_MODIFIED 0x00001000
#define FO_FILE_SIZE_CHANGED 0x00002000
#define FO_CLEANUP_COMPLETE 0x00004000
#define FO_TEMPORARY_FILE 0x00008000
#define FO_DELETE_ON_CLOSE 0x00010000
#define FO_OPENED_CASE_SENSITIVE 0x00020000
#define FO_HANDLE_CREATED 0x00040000
#define FO_FILE_FAST_IO_READ 0x00080000
typedef struct _FILE_OBJECT
{
CSHORT Type;
CSHORT Size;
struct _DEVICE_OBJECT* DeviceObject;
struct _VPB* Vpb;
PVOID FsContext;
PVOID FsContext2;
PSECTION_OBJECT_POINTERS SectionObjectPointers;
PVOID PrivateCacheMap;
NTSTATUS FinalStatus;
struct _FILE_OBJECT* RelatedFileObject;
BOOLEAN LockOperation;
BOOLEAN DeletePending;
BOOLEAN ReadAccess;
BOOLEAN WriteAccess;
BOOLEAN DeleteAccess;
BOOLEAN SharedRead;
BOOLEAN SharedWrite;
BOOLEAN SharedDelete;
ULONG Flags;
UNICODE_STRING FileName;
LARGE_INTEGER CurrentByteOffset;
ULONG Waiters;
ULONG Busy;
PVOID LastLock;
KEVENT Lock;
KEVENT Event;
PIO_COMPLETION_CONTEXT CompletionContext;
} FILE_OBJECT, *PFILE_OBJECT;
typedef struct _IRP
{
PMDL MdlAddress;
ULONG Flags;
union
{
struct _IRP* MasterIrp;
LONG IrpCount;
PVOID SystemBuffer;
} AssociatedIrp;
LIST_ENTRY ThreadListEntry;
IO_STATUS_BLOCK IoStatus;
KPROCESSOR_MODE RequestorMode;
BOOLEAN PendingReturned;
BOOLEAN Cancel;
KIRQL CancelIrql;
PDRIVER_CANCEL CancelRoutine;
PVOID UserBuffer;
PVOID ApcEnvironment;
ULONG AllocationFlags;
PIO_STATUS_BLOCK UserIosb;
PKEVENT UserEvent;
union
{
struct
{
PIO_APC_ROUTINE UserApcRoutine;
PVOID UserApcContext;
} AsynchronousParameters;
LARGE_INTEGER AllocationSize;
} Overlay;
union
{
struct
{
KDEVICE_QUEUE_ENTRY DeviceQueueEntry;
struct _ETHREAD* Thread;
PCHAR AuxiliaryBuffer;
LIST_ENTRY ListEntry;
struct _IO_STACK_LOCATION* CurrentStackLocation;
PFILE_OBJECT OriginalFileObject;
} Overlay;
KAPC Apc;
ULONG CompletionKey;
} Tail;
ULONG CurrentLocation;
IO_STACK_LOCATION Stack[1];
} IRP, *PIRP;
typedef struct _VPB
{
CSHORT Type;
CSHORT Size;
USHORT Flags;
USHORT VolumeLabelLength;
struct _DEVICE_OBJECT* DeviceObject;
struct _DEVICE_OBJECT* RealDevice;
ULONG SerialNumber;
ULONG ReferenceCount;
WCHAR VolumeLabel[MAXIMUM_VOLUME_LABEL_LENGTH / sizeof(WCHAR)];
} VPB, *PVPB;
typedef struct _DEVICE_OBJECT
{
CSHORT Type;
CSHORT Size;
LONG ReferenceCount;
struct _DRIVER_OBJECT* DriverObject;
struct _DEVICE_OBJECT* NextDevice;
struct _DEVICE_OBJECT* AttachedDevice;
struct _IRP* CurrentIrp;
PIO_TIMER Timer;
ULONG Flags;
ULONG Characteristics;
PVPB Vpb;
PVOID DeviceExtension;
DEVICE_TYPE DeviceType;
CCHAR StackSize;
union
{
LIST_ENTRY ListHead;
WAIT_CONTEXT_BLOCK Wcb;
} Queue;
ULONG AlignmentRequirement;
KDEVICE_QUEUE DeviceQueue;
KDPC Dpc;
ULONG ActiveThreadCount;
PSECURITY_DESCRIPTOR SecurityDescriptor;
KEVENT DeviceLock;
USHORT SectorSize;
USHORT Spare1;
struct _DEVOBJ_EXTENSION* DeviceObjectExtension;
PVOID Reserved;
} DEVICE_OBJECT, *PDEVICE_OBJECT;
/*
* Dispatch routine type declaration
*/
typedef NTSTATUS (*PDRIVER_DISPATCH)(struct _DEVICE_OBJECT*, IRP*);
/*
* Fast i/o routine type declaration
*/
typedef NTSTATUS (*PFAST_IO_DISPATCH)(struct _DEVICE_OBJECT*, IRP*);
/*
* Dispatch routine type declaration
*/
typedef VOID (*PDRIVER_STARTIO)(struct _DEVICE_OBJECT*, IRP*);
/*
* Dispatch routine type declaration
*/
typedef NTSTATUS (*PDRIVER_UNLOAD)(struct _DRIVER_OBJECT*);
typedef struct _DRIVER_EXTENSION
{
struct _DRIVER_OBJECT* DriverObject;
PDRIVER_ADD_DEVICE AddDevice;
ULONG Count;
UNICODE_STRING ServiceKeyName;
} DRIVER_EXTENSION, *PDRIVER_EXTENSION;
typedef struct _DRIVER_OBJECT
{
/*
* PURPOSE: Magic values for debugging
*/
CSHORT Type;
CSHORT Size;
PDEVICE_OBJECT DeviceObject;
ULONG Flags;
PVOID DriverStart;
ULONG DriverSize;
PVOID DriverSection;
PDRIVER_EXTENSION DriverExtension;
UNICODE_STRING DriverName;
PUNICODE_STRING HardwareDatabase;
PFAST_IO_DISPATCH FastIoDispatch;
PDRIVER_INITIALIZE DriverInit;
PDRIVER_STARTIO DriverStartIo;
PDRIVER_UNLOAD DriverUnload;
PDRIVER_DISPATCH MajorFunction[IRP_MJ_MAXIMUM_FUNCTION + 1];
} DRIVER_OBJECT, *PDRIVER_OBJECT;
typedef struct _CONFIGURATION_INFORMATION
{
ULONG DiskCount;
ULONG FloppyCount;
ULONG CDRomCount;
ULONG TapeCount;
ULONG ScsiPortCount;
ULONG SerialCount;
ULONG ParallelCount;
BOOLEAN AtDiskPrimaryAddressClaimed;
BOOLEAN AtDiskSecondaryAddressClaimed;
} CONFIGURATION_INFORMATION, *PCONFIGURATION_INFORMATION;
typedef VOID (*PIO_DPC_ROUTINE)(PKDPC Dpc,
PDEVICE_OBJECT DeviceObject,
PIRP Irp,
PVOID Context);
typedef VOID (*PIO_TIMER_ROUTINE)(PDEVICE_OBJECT DeviceObject,
PVOID Context);
#if WINDOWS_STRUCTS_DOESNT_ALREADY_DEFINE_THIS
typedef struct _PARTITION_INFORMATION
{
LARGE_INTEGER StartingOffset;
LARGE_INTEGER PartitionLength;
ULONG HiddenSectors;
ULONG PartitionNumber;
UCHAR PartitionType;
BOOLEAN BootIndicator;
BOOLEAN RecognizedPartition;
BOOLEAN RewritePartition;
} PARTITION_INFORMATION, *PPARTITION_INFORMATION;
#endif
typedef struct _DRIVER_LAYOUT_INFORMATION
{
ULONG PartitionCount;
ULONG Signature;
PARTITION_INFORMATION PartitionEntry[1];
} DRIVER_LAYOUT_INFORMATION, *PDRIVER_LAYOUT_INFORMATION;
typedef struct _IO_RESOURCE_DESCRIPTOR
{
UCHAR Option;
UCHAR Type;
UCHAR SharedDisposition;
/*
* Reserved for system use
*/
UCHAR Spare1;
USHORT Flags;
/*
* Reserved for system use
*/
UCHAR Spare2;
union
{
struct
{
ULONG Length;
ULONG Alignment;
PHYSICAL_ADDRESS MinimumAddress;
PHYSICAL_ADDRESS MaximumAddress;
} Port;
struct
{
ULONG Length;
ULONG Alignment;
PHYSICAL_ADDRESS MinimumAddress;
PHYSICAL_ADDRESS MaximumAddress;
} Memory;
struct
{
ULONG MinimumVector;
ULONG MaximumVector;
} Interrupt;
struct
{
ULONG MinimumChannel;
ULONG MaximumChannel;
} Dma;
} u;
} IO_RESOURCE_DESCRIPTOR, *PIO_RESOURCE_DESCRIPTOR;
typedef struct _IO_RESOURCE_LIST
{
USHORT Version;
USHORT Revision;
ULONG Count;
IO_RESOURCE_DESCRIPTOR Descriptors[1];
} IO_RESOURCE_LIST, *PIO_RESOURCE_LIST;
typedef struct _IO_RESOURCES_REQUIREMENTS_LIST
{
/*
* List size in bytes
*/
ULONG ListSize;
/*
* System defined enum for the bus
*/
INTERFACE_TYPE InterfaceType;
ULONG BusNumber;
ULONG SlotNumber;
ULONG Reserved[3];
ULONG AlternativeLists;
IO_RESOURCE_LIST List[1];
} IO_RESOURCES_REQUIREMENTS_LIST, *PIO_RESOURCE_REQUIREMENTS_LIST;
typedef struct
{
UCHAR Type;
UCHAR ShareDisposition;
USHORT Flags;
union
{
struct
{
PHYSICAL_ADDRESS Start;
ULONG Length;
} Port;
struct
{
ULONG Level;
ULONG Vector;
ULONG Affinity;
} Interrupt;
struct
{
PHYSICAL_ADDRESS Start;
ULONG Length;
} Memory;
struct
{
ULONG Channel;
ULONG Port;
ULONG Reserved1;
} Dma;
struct
{
ULONG DataSize;
ULONG Reserved1;
ULONG Reserved2;
} DeviceSpecificData;
} u;
} CM_PARTIAL_RESOURCE_DESCRIPTOR, *PCM_PARTIAL_RESOURCE_DESCRIPTOR;
typedef struct
{
USHORT Version;
USHORT Revision;
ULONG Count;
CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1];
} CM_PARTIAL_RESOURCE_LIST;
typedef struct
{
INTERFACE_TYPE InterfaceType;
ULONG BusNumber;
CM_PARTIAL_RESOURCE_LIST PartialResourceList;
} CM_FULL_RESOURCE_DESCRIPTOR;
typedef struct
{
ULONG Count;
CM_FULL_RESOURCE_DESCRIPTOR List[1];
} CM_RESOURCE_LIST, *PCM_RESOURCE_LIST;
#endif __INCLUDE_DDK_IOTYPES_H

View File

@@ -0,0 +1,42 @@
typedef enum _KINTERRUPT_MODE
{
LevelSensitive,
Latched,
} KINTERRUPT_MODE;
typedef enum _EVENT_TYPE
{
NotificationEvent,
SynchronizationEvent,
SemaphoreType,
} EVENT_TYPE;
typedef enum _KWAIT_REASON
{
Executive,
FreePage,
PageIn,
PoolAllocation,
DelayExecution,
Suspended,
UserRequest,
WrExecutive,
WrFreePage,
WrPageIn,
WrDelayExecution,
WrSuspended,
WrUserRequest,
WrQueue,
WrLpcReceive,
WrLpcReply,
WrVirtualMemory,
WrPageOut,
WrRendezvous,
Spare2,
Spare3,
Spare4,
Spare5,
Spare6,
WrKernel,
MaximumWaitReason,
} KWAIT_REASON;

View File

@@ -0,0 +1,158 @@
#ifndef __INCLUDE_DDK_KEFUNCS_H
#define __INCLUDE_DDK_KEFUNCS_H
/* KERNEL FUNCTIONS ********************************************************/
struct _KAPC;
void KeInitializeApc(
struct _KAPC *Apc,
PKTHREAD Thread,
UCHAR StateIndex,
PKKERNEL_ROUTINE KernelRoutine,
PKRUNDOWN_ROUTINE RundownRoutine,
PKNORMAL_ROUTINE NormalRoutine,
UCHAR Mode,
PVOID Context
);
void KeInsertQueueApc(struct _KAPC *Apc, PVOID SystemArgument1,
PVOID SystemArgument2, UCHAR Mode);
void KeAttachProcess(struct _EPROCESS* Process);
void KeDetachProcess(VOID);
VOID KeDrainApcQueue(VOID);
PKPROCESS KeGetCurrentProcess(VOID);
/*
* FUNCTION: Acquires a spinlock so the caller can synchronize access to
* data
* ARGUMENTS:
* SpinLock = Initialized spinlock
* OldIrql (OUT) = Set the previous irql on return
*/
VOID KeAcquireSpinLock(PKSPIN_LOCK SpinLock, PKIRQL OldIrql);
VOID KeAcquireSpinLockAtDpcLevel(PKSPIN_LOCK SpinLock);
BOOLEAN KeCancelTimer(PKTIMER Timer);
VOID KeClearEvent(PKEVENT Event);
NTSTATUS KeDelayExecutionThread(KPROCESSOR_MODE WaitMode,
BOOLEAN Alertable,
PLARGE_INTEGER Internal);
BOOLEAN KeDeregisterBugCheckCallback(PKBUGCHECK_CALLBACK_RECORD
CallbackRecord);
VOID KeEnterCriticalRegion(VOID);
VOID KeFlushIoBuffers(PMDL Mdl, BOOLEAN ReadOperation, BOOLEAN DmaOperation);
KIRQL KeGetCurrentIrql(VOID);
ULONG KeGetCurrentProcessorNumber(VOID);
ULONG KeGetDcacheFillSize(VOID);
PKTHREAD KeGetCurrentThread(VOID);
VOID KeInitializeCallbackRecord(PKBUGCHECK_CALLBACK_RECORD CallbackRecord);
VOID KeInitializeDeviceQueue(PKDEVICE_QUEUE DeviceQueue);
VOID KeInitializeDpc(PKDPC Dpc, PKDEFERRED_ROUTINE DeferredRoutine,
PVOID DeferredContext);
VOID KeInitializeEvent(PKEVENT Event, EVENT_TYPE Type, BOOLEAN State);
VOID KeInitializeMutex(PKMUTEX Mutex, ULONG Level);
VOID KeInitializeSemaphore(PKSEMAPHORE Semaphore, LONG Count, LONG Limit);
VOID KeInitializeTimer(PKTIMER Timer);
VOID KeInitializeTimerEx(PKTIMER Timer, TIMER_TYPE Type);
BOOLEAN KeInsertByKeyDeviceQueue(PKDEVICE_QUEUE DeviceQueue,
PKDEVICE_QUEUE_ENTRY DeviceQueueEntry,
ULONG SortKey);
BOOLEAN KeInsertDeviceQueue(PKDEVICE_QUEUE DeviceQueue,
PKDEVICE_QUEUE_ENTRY DeviceQueueEntry);
BOOLEAN KeInsertQueueDpc(PKDPC Dpc, PVOID SystemArgument1,
PVOID SystemArgument2);
VOID KeLeaveCriticalRegion(VOID);
VOID KeLowerIrql(KIRQL NewIrql);
LARGE_INTEGER KeQueryPerformanceCounter(PLARGE_INTEGER PerformanceFrequency);
VOID KeQuerySystemTime(PLARGE_INTEGER CurrentTime);
VOID KeQueryTickCount(PLARGE_INTEGER TickCount);
ULONG KeQueryTimeIncrement(VOID);
VOID KeRaiseIrql(KIRQL NewIrql, PKIRQL OldIrql);
LONG KeReadStateEvent(PKEVENT Event);
LONG KeReadStateMutex(PKMUTEX Mutex);
LONG KeReadStateSemaphore(PKSEMAPHORE Semaphore);
BOOLEAN KeReadStateTimer(PKTIMER Timer);
BOOLEAN KeRegisterBugCheckCallback(PKBUGCHECK_CALLBACK_RECORD CallbackRecord,
PKBUGCHECK_CALLBACK_ROUTINE CallbackRoutine,
PVOID Buffer,
ULONG Length,
PUCHAR Component);
LONG KeReleaseMutex(PKMUTEX Mutex, BOOLEAN Wait);
LONG KeReleaseSemaphore(PKSEMAPHORE Semaphore, KPRIORITY Increment,
LONG Adjustment, BOOLEAN Wait);
VOID KeReleaseSpinLock(PKSPIN_LOCK Spinlock, KIRQL NewIrql);
VOID KeReleaseSpinLockFromDpcLevel(PKSPIN_LOCK Spinlock);
PKDEVICE_QUEUE_ENTRY KeRemoveByKeyDeviceQueue(PKDEVICE_QUEUE DeviceQueue,
ULONG SortKey);
PKDEVICE_QUEUE_ENTRY KeRemoveDeviceQueue(PKDEVICE_QUEUE DeviceQueue);
BOOLEAN KeRemoveEntryDeviceQueue(PKDEVICE_QUEUE DeviceQueue,
PKDEVICE_QUEUE_ENTRY DeviceQueueEntry);
BOOLEAN KeRemoveQueueDpc(PKDPC Dpc);
LONG KeResetEvent(PKEVENT Event);
LONG KeSetBasePriorityThread(PKTHREAD Thread, LONG Increment);
LONG KeSetEvent(PKEVENT Event, KPRIORITY Increment, BOOLEAN Wait);
KPRIORITY KeSetPriorityThread(PKTHREAD Thread, KPRIORITY Priority);
BOOLEAN KeSetTimer(PKTIMER Timer, LARGE_INTEGER DueTime, PKDPC Dpc);
BOOLEAN KeSetTimerEx(PKTIMER Timer, LARGE_INTEGER DueTime, LONG Period,
PKDPC Dpc);
VOID KeStallExecutionProcessor(ULONG MicroSeconds);
BOOLEAN KeSynchronizeExecution(PKINTERRUPT Interrupt,
PKSYNCHRONIZE_ROUTINE SynchronizeRoutine,
PVOID SynchronizeContext);
NTSTATUS KeWaitForMultipleObjects(ULONG Count,
PVOID Object[],
WAIT_TYPE WaitType,
KWAIT_REASON WaitReason,
KPROCESSOR_MODE WaitMode,
BOOLEAN Alertable,
PLARGE_INTEGER Timeout,
PKWAIT_BLOCK WaitBlockArray);
NTSTATUS KeWaitForMutexObject(PKMUTEX Mutex, KWAIT_REASON WaitReason,
KPROCESSOR_MODE WaitMode, BOOLEAN Alertable,
PLARGE_INTEGER Timeout);
NTSTATUS KeWaitForSingleObject(PVOID Object, KWAIT_REASON WaitReason,
KPROCESSOR_MODE WaitMode,
BOOLEAN Alertable, PLARGE_INTEGER Timeout);
/*
* FUNCTION: Initializes a spinlock
* ARGUMENTS:
* SpinLock = Spinlock to initialize
*/
VOID KeInitializeSpinLock(PKSPIN_LOCK SpinLock);
/*
* FUNCTION: Sets the current irql without altering the current processor
* state
* ARGUMENTS:
* newlvl = IRQ level to set
* NOTE: This is for internal use only
*/
VOID KeSetCurrentIrql(KIRQL newlvl);
/*
* FUNCTION: Brings the system down in a controlled manner when an
* inconsistency that might otherwise cause corruption has been detected
* ARGUMENTS:
* BugCheckCode = Specifies the reason for the bug check
* BugCheckParameter[1-4] = Additional information about bug
* RETURNS: Doesn't
*/
VOID KeBugCheckEx(ULONG BugCheckCode,
ULONG BugCheckParameter1,
ULONG BugCheckParameter2,
ULONG BugCheckParameter3,
ULONG BugCheckParameter4);
/*
* FUNCTION: Brings the system down in a controlled manner when an
* inconsistency that might otherwise cause corruption has been detected
* ARGUMENTS:
* BugCheckCode = Specifies the reason for the bug check
* RETURNS: Doesn't
*/
VOID KeBugCheck(ULONG BugCheckCode);
#endif /* __INCLUDE_DDK_KEFUNCS_H */

View File

@@ -0,0 +1,299 @@
/* KERNEL TYPES **************************************************************/
#ifndef __INCLUDE_DDK_KETYPES_H
#define __INCLUDE_DDK_KETYPES_H
struct _KMUTANT;
typedef LONG KPRIORITY;
typedef VOID (*PKBUGCHECK_CALLBACK_ROUTINE)(PVOID Buffer, ULONG Length);
typedef BOOLEAN (*PKSYNCHRONIZE_ROUTINE)(PVOID SynchronizeContext);
struct _KAPC;
typedef VOID (*PKNORMAL_ROUTINE)(PVOID NormalContext,
PVOID SystemArgument1,
PVOID SystemArgument2);
typedef VOID (*PKKERNEL_ROUTINE)(struct _KAPC* Apc,
PKNORMAL_ROUTINE* NormalRoutine,
PVOID* NormalContext,
PVOID* SystemArgument1,
PVOID* SystemArgument2);
typedef VOID (*PKRUNDOWN_ROUTINE)(struct _KAPC* Apc);
typedef struct
/*
* PURPOSE: Object describing the wait a thread is currently performing
*/
{
LIST_ENTRY WaitListEntry;
struct _KTHREAD* Thread;
PVOID Object;
struct _KWAIT_BLOCK* NextWaitBlock;
USHORT WaitKey;
USHORT WaitType;
} KWAIT_BLOCK, *PKWAIT_BLOCK;
typedef struct _DISPATCHER_HEADER
{
UCHAR Type;
UCHAR Absolute;
UCHAR Size;
UCHAR Inserted;
LONG SignalState;
LIST_ENTRY WaitListHead;
} DISPATCHER_HEADER;
struct _KDPC;
typedef struct _KTIMER
{
/*
* Pointers to maintain the linked list of activated timers
*/
LIST_ENTRY entry;
/*
* Absolute expiration time in system time units
*/
signed long long expire_time;
/*
* Optional dpc associated with the timer
*/
struct _KDPC* dpc;
/*
* True if the timer is signaled
*/
BOOLEAN signaled;
/*
* True if the timer is in the system timer queue
*/
BOOLEAN running;
/*
* Type of the timer either Notification or Synchronization
*/
TIMER_TYPE type;
/*
* Period of the timer in milliseconds (zero if once-only)
*/
ULONG period;
} KTIMER, *PKTIMER;
struct _KSPIN_LOCK;
typedef struct _KSPIN_LOCK
{
KIRQL irql;
} KSPIN_LOCK, *PKSPIN_LOCK;
typedef struct _KDEVICE_QUEUE
{
LIST_ENTRY ListHead;
BOOLEAN Busy;
KSPIN_LOCK Lock;
} KDEVICE_QUEUE, *PKDEVICE_QUEUE;
#if RIGHT_DEFINITION_PROVIDED_ABOVE
#define _KTHREAD _ETHREAD
typedef struct _KTHREAD
/*
* PURPOSE: Describes a thread of execution
*/
{
CSHORT Type;
CSHORT Size;
/*
* PURPOSE: Head of the queue of apcs
*/
LIST_ENTRY ApcQueueHead;
/*
* PURPOSE: Entry in the linked list of threads
*/
LIST_ENTRY Entry;
/*
* PURPOSE: Current state of the thread
*/
ULONG State;
/*
* PURPOSE: Priority modifier of the thread
*/
ULONG Priority;
/*
* PURPOSE: Pointer to our process
*/
struct _EPROCESS* Process;
/*
* PURPOSE: Handle of our process
*/
HANDLE ProcessHandle;
/*
* PURPOSE: Thread affinity mask
*/
ULONG AffinityMask;
/*
* PURPOSE: Saved thread context
*/
hal_thread_state context;
/*
* PURPOSE: Timeout for the thread to be woken up
*/
signed long long int wake_time;
} KTHREAD, *PKTHREAD, *PETHREAD;
#endif
typedef struct _KAPC
{
CSHORT Type;
CSHORT Size;
ULONG Spare0;
struct _KTHREAD* Thread;
LIST_ENTRY ApcListEntry;
PKKERNEL_ROUTINE KernelRoutine;
PKRUNDOWN_ROUTINE RundownRoutine;
PKNORMAL_ROUTINE NormalRoutine;
PVOID NormalContext;
PVOID SystemArgument1;
PVOID SystemArgument2;
CCHAR ApcStateIndex;
KPROCESSOR_MODE ApcMode;
BOOLEAN Inserted;
} KAPC, *PKAPC;
typedef struct
{
LIST_ENTRY Entry;
PKBUGCHECK_CALLBACK_ROUTINE CallbackRoutine;
PVOID Buffer;
ULONG Length;
PUCHAR Component;
ULONG Checksum;
UCHAR State;
} KBUGCHECK_CALLBACK_RECORD, *PKBUGCHECK_CALLBACK_RECORD;
typedef struct
{
DISPATCHER_HEADER Header;
LIST_ENTRY MutantListEntry;
struct _KTHREAD* OwnerThread;
BOOLEAN Abandoned;
UCHAR ApcDisable;
} KMUTEX, *PKMUTEX;
typedef struct
{
DISPATCHER_HEADER Header;
LONG Limit;
} KSEMAPHORE, *PKSEMAPHORE;
typedef struct _KEVENT
/*
* PURPOSE: Describes an event
*/
{
/*
* PURPOSE: So we can use the general wait routine
*/
DISPATCHER_HEADER Header;
} KEVENT, *PKEVENT;
typedef VOID (*PDRIVER_ADD_DEVICE)(VOID);
struct _KDPC;
/*
* PURPOSE: Defines a delayed procedure call routine
* NOTE:
* Dpc = The associated DPC object
* DeferredContext = Driver defined context for the DPC
* SystemArgument[1-2] = Undocumented.
*
*/
typedef VOID (*PKDEFERRED_ROUTINE)(struct _KDPC* Dpc, PVOID DeferredContext,
PVOID SystemArgument1, PVOID SystemArgument2);
typedef struct _KDPC
/*
* PURPOSE: Defines a delayed procedure call object
*/
{
/*
* PURPOSE: Magic value to check this is the current object type
*/
SHORT Type;
/*
* PURPOSE: Target processor or zero if untargetted
*/
UCHAR Number;
/*
* PURPOSE: Indication of desired latency before exection
*/
UCHAR Importance;
LIST_ENTRY DpcListEntry;
PKDEFERRED_ROUTINE DeferredRoutine;
PVOID DeferredContext;
PVOID SystemArgument1;
PVOID SystemArgument2;
/*
* PURPOSE: If non-zero then already in queue
*/
PULONG Lock;
} KDPC, *PKDPC;
typedef struct _KDEVICE_QUEUE_ENTRY
{
LIST_ENTRY Entry;
ULONG Key;
} KDEVICE_QUEUE_ENTRY, *PKDEVICE_QUEUE_ENTRY;
typedef struct _WAIT_CONTEXT_BLOCK
{
} WAIT_CONTEXT_BLOCK, *PWAIT_CONTEXT_BLOCK;
struct _KINTERRUPT;
typedef BOOLEAN (*PKSERVICE_ROUTINE)(struct _KINTERRUPT* Interrupt,
PVOID ServiceContext);
typedef struct _KINTERRUPT
{
ULONG Vector;
KAFFINITY ProcessorEnableMask;
PKSPIN_LOCK IrqLock;
BOOLEAN Shareable;
BOOLEAN FloatingSave;
PKSERVICE_ROUTINE ServiceRoutine;
PVOID ServiceContext;
LIST_ENTRY Entry;
KIRQL SynchLevel;
} KINTERRUPT, *PKINTERRUPT;
#endif /* __INCLUDE_DDK_KETYPES_H */

View File

@@ -0,0 +1,297 @@
/* MEMORY MANAGMENT ******************************************************/
#include <internal/hal/page.h>
/*
* FUNCTION: Determines if the given virtual address is page aligned
*/
#define IS_PAGE_ALIGNED(Va) (((ULONG)Va)&0xfff)
/*
* PURPOSE: Returns the byte offset of a field within a structure
*/
#define FIELD_OFFSET(Type,Field) (LONG)(&(((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 *)(((LONG)Address) - FIELD_OFFSET(Type,Field))
/*
* FUNCTION: Returns the number of pages spanned by an address range
* ARGUMENTS:
* Va = start of range
* Size = Size of range
* RETURNS: The number of pages
*/
extern inline unsigned int ADDRESS_AND_SIZE_TO_SPAN_PAGES(PVOID Va,
ULONG Size)
{
ULONG HighestAddr;
ULONG LowestAddr;
HighestAddr = PAGE_ROUND_UP(Size + ((ULONG)Va));
LowestAddr = PAGE_ROUND_DOWN((ULONG)Va);
return((HighestAddr - LowestAddr) / PAGESIZE);
}
/*
* FUNCTION: Returns FALSE is the pointer is NULL, TRUE otherwise
*/
#define ARGUMENT_PRESENT(arg) ((arg)!=NULL)
/*
* FUNCTION: Returns the byte offset of the address within its page
*/
#define BYTE_OFFSET(va) (((ULONG)va)%PAGESIZE)
/*
* FUNCTION: Takes a count in bytes and returns the number of pages
* required to hold it
*/
#define BYTES_TO_PAGES(size) (?)
/*
* FUNCTION: Allocates a range of physically contiguous cache aligned
* memory from the non-paged pool
* ARGUMENTS:
* NumberOfBytes = Size of the memory block to allocate
* HighestAcceptableAddress = Highest address valid for the caller
* RETURNS: The virtual address of the memory block on success
* NULL on error
*/
PVOID MmAllocateContiguousMemory(ULONG NumberOfBytes,
PHYSICAL_ADDRESS HighestAcceptableAddress);
/*
* FUNCTION: Allocates a virtual address range of noncached and cache
* aligned memory
* ARGUMENTS:
* NumberOfBytes = Size of region to allocate
* RETURNS: The base address of the range on success
* NULL on failure
*/
PVOID MmAllocateNonCachedMemory(ULONG NumberOfBytes);
/*
* FUNCTION: Fills in the corresponding physical page array for a given MDL
* for a buffer in nonpaged system space
* ARGUMENTS:
* MemoryDescriptorList = MDL to fill
*/
VOID MmBuildMdlForNonPagedPool(PMDL MemoryDescriptorList);
/*
* FUNCTION: Allocates and initializes an MDL
* ARGUMENTS:
* MemoryDescriptorList = Optional caller allocated MDL to initalize
* Base = Base virtual address for buffer
* Length = Length in bytes of the buffer
* RETURNS: A pointer to the initalized MDL
*/
PMDL MmCreateMdl(PMDL MemoryDescriptorList, PVOID Base, ULONG Length);
/*
* FUNCTION: Releases a range of physically contiguous memory allocated
* with MmAllocateContiguousMemory
* ARGUMENTS:
* BaseAddress = Vritual address of the memory to be freed
*/
VOID MmFreeContiguousMemory(PVOID BaseAddress);
/*
* FUNCTION: Releases a range of noncached memory allocated with
* MmAllocateNonCachedMemory
* ARGUMENTS:
* BaseAddress = Virtual address to be freed
* NumberOfBytes = size of the region to be freed
*/
VOID MmFreeNonCachedMemory(PVOID BaseAddress, ULONG NumberOfBytes);
/*
* FUNCTION: Returns the length in bytes of a buffer described by an MDL
* ARGUMENTS:
* Mdl = the mdl
* RETURNS: Size of the buffer
*/
ULONG MmGetMdlByteCount(PMDL Mdl);
/*
* FUNCTION: Returns the byte offset within a page of the buffer described
* by an MDL
* ARGUMENTS:
* Mdl = the mdl
* RETURNS: The offset in bytes
*/
ULONG MmGetMdlByteOffset(PMDL Mdl);
/*
* FUNCTION: Returns the initial virtual address for a buffer described
* by an MDL
* ARGUMENTS:
* Mdl = the mdl
* RETURNS: The initial virtual address
*/
PVOID MmGetMdlVirtualAddress(PMDL Mdl);
/*
* FUNCTION: Returns the physical address corresponding to a given valid
* virtual address
* ARGUMENTS:
* BaseAddress = the virtual address
* RETURNS: The physical address
*/
PHYSICAL_ADDRESS MmGetPhysicalAddress(PVOID BaseAddress);
/*
* FUNCTION: Maps the physical pages described by an MDL into system space
* ARGUMENTS:
* Mdl = mdl
* RETURNS: The base system address for the mapped buffer
*/
PVOID MmGetSystemAddressForMdl(PMDL Mdl);
/*
* FUNCTION: Initalizes an mdl
* ARGUMENTS:
* MemoryDescriptorList = MDL to be initalized
* BaseVa = Base virtual address of the buffer
* Length = Length in bytes of the buffer
*/
VOID MmInitializeMdl(PMDL MemoryDescriptorList, PVOID BaseVa, ULONG Length);
/*
* FUNCTION: Checks whether an address is valid for read/write
* ARGUMENTS:
* VirtualAddress = address to be check
* RETURNS: TRUE if an access would be valid
*/
BOOLEAN MmIsAddressValid(PVOID VirtualAddress);
/*
* FUNCTION: Checks if the current platform is a workstation or a server
* RETURNS: If the system is a server returns true
* NOTE: Drivers can use this as an estimate of the likely resources
* available
*/
BOOLEAN MmIsThisAnAsSystem(VOID);
/*
* FUNCTION: Locks a section of the driver's code into memory
* ARGUMENTS:
* AddressWithinSection = Any address in the region
* RETURNS: A handle to the region
*/
PVOID MmLockPagableCodeSection(PVOID AddressWithinSection);
/*
* FUNCTION: Locks a section of the driver's data into memory
* ARGUMENTS:
* AddressWithinSection = Any address in the region
* RETURNS: A handle to the region
*/
PVOID MmLockPagableDataSection(PVOID AddressWithinSection);
/*
* FUNCTION: Locks a section of memory
* ARGUMENTS:
* ImageSectionHandle = handle returned from MmLockPagableCodeSection
* or MmLockPagableDataSection
*/
VOID MmLockPagableSectionByHandle(PVOID ImageSectionHandle);
/*
* FUNCTION: Maps a physical memory range into system space
* ARGUMENTS:
* PhysicalAddress = First physical address to map
* NumberOfBytes = Number of bytes to map
* CacheEnable = TRUE if the range can be cached
* RETURNS: The base virtual address which maps the region
*/
PVOID MmMapIoSpace(PHYSICAL_ADDRESS PhysicalAddress, ULONG NumberOfBytes,
BOOLEAN CacheEnable);
/*
* FUNCTION: Maps the pages described by a given MDL
* ARGUMENTS:
* MemoryDescriptorList = MDL updated by MmProbeAndLockPages
* AccessMode = Access mode in which to map the MDL
* RETURNS: The base virtual address which maps the buffer
*/
PVOID MmMapLockedPages(PMDL MemoryDescriptorList, KPROCESSOR_MODE AccessMode);
/*
* FUNCTION: Makes the whole driver pageable
* ARGUMENTS:
* AddressWithinSection = Any address within the driver
*/
VOID MmPageEntireDriver(PVOID AddressWithinSection);
/*
* FUNCTION: Resets the pageable status of a driver's sections to their
* compile time settings
* ARGUMENTS:
* AddressWithinSection = Any address within the driver
*/
VOID MmResetDriverPaging(PVOID AddressWithinSection);
/*
* FUNCTION: Reinitializes a caller-allocated MDL
* ARGUMENTS:
* Mdl = Points to the MDL that will be reused
*/
VOID MmPrepareMdlForReuse(PMDL Mdl);
/*
* FUNCTION: Probes the specified pages, makes them resident and locks
* the physical pages mapped by the virtual address range
* ARGUMENTS:
* MemoryDescriptorList = MDL which supplies the virtual address,
* byte offset and length
* AccessMode = Access mode with which to probe the arguments
* Operation = Types of operation for which the pages should be
* probed
*/
VOID MmProbeAndLockPages(PMDL MemoryDescriptorList,
KPROCESSOR_MODE AccessMode,
LOCK_OPERATION Operation);
/*
* FUNCTION: Returns an estimate of the amount of memory in the system
* RETURNS: Either MmSmallSystem, MmMediumSystem or MmLargeSystem
*/
MM_SYSTEM_SIZE MmQuerySystemSize(VOID);
/*
* FUNCTION: Returns the number of bytes to allocate for an MDL
* describing a given address range
* ARGUMENTS:
* Base = Base virtual address for the region
* Length = size in bytes of the region
* RETURNS: The number of bytes required for the MDL
*/
ULONG MmSizeOfMdl(PVOID Base, ULONG Length);
/*
* FUNCTION: Unlocks the physical pages described by a given MDL
* ARGUMENTS:
* Mdl = Mdl to unlock
*/
VOID MmUnlockPages(PMDL Mdl);
/*
* FUNCTION: Releases a section of driver code or data previously locked into
* memory
* ARGUMENTS:
* ImageSectionHandle = Handle for the locked section
*/
VOID MmUnlockPagableImageSection(PVOID ImageSectionHandle);
VOID MmUnmapIoSpace(PVOID BaseAddress, ULONG NumberOfBytes);
VOID MmUnmapLockedPages(PVOID BaseAddress, PMDL MemoryDescriptorList);
PVOID MmAllocateSection(ULONG Length);

View File

@@ -0,0 +1,35 @@
enum
{
MDL_MAPPED_TO_SYSTEM_VA = 0x1,
MDL_PAGES_LOCKED = 0x2,
MDL_SOURCE_IS_NONPAGED_POOL = 0x4,
MDL_ALLOCATED_FIXED_SIZE = 0x8,
MDL_PARTIAL = 0x10,
MDL_PARTIAL_HAS_BEEN_MAPPED = 0x20,
MDL_IO_PAGE_READ = 0x40,
MDL_WRITE_OPERATION = 0x80,
MDL_PARENT_MAPPED_SYSTEM_VA = 0x100,
MDL_LOCK_HELD = 0x200,
MDL_SCATTER_GATHER_VA = 0x400,
MDL_IO_SPACE = 0x800,
MDL_NETWORK_HEADER = 0x1000,
MDL_MAPPING_CAN_FAIL = 0x2000,
MDL_ALLOCATED_MUST_SUCCEED = 0x4000,
MDL_64_BIT_VA = 0x8000,
};
typedef struct _MDL
/*
* PURPOSE: Describes a user buffer passed to a system API
*/
{
struct _MDL* Next;
CSHORT Size;
CSHORT MdlFlags;
struct _EPROCESS* Process;
PVOID MappedSystemVa;
PVOID StartVa;
ULONG ByteCount;
ULONG ByteOffset;
} MDL, *PMDL;

View File

@@ -0,0 +1,62 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: include/ddk/ntddk.h
* PURPOSE: Interface definitions for drivers
* PROGRAMMER: David Welch (welch@mcmail.com)
* UPDATE HISTORY:
* 15/05/98: Created
*/
#ifndef __NTDDK_H
#define __NTDDK_H
#ifdef __cplusplus
extern "C"
{
#endif
/* INCLUDES ***************************************************************/
#include <windows.h>
#define QUAD_PART(LI) (*(LONGLONG *)(&LI))
#define IO_DISK_INCREMENT 4
#define FILE_WORD_ALIGNMENT 0x0001
#define FILE_OPENED 0x0001
#include <ddk/status.h>
#include <ddk/ntdef.h>
#include <ddk/defines.h>
#include <ddk/types.h>
#include <ddk/cfgtypes.h>
#include <ddk/ketypes.h>
#include <ddk/obtypes.h>
#include <ddk/mmtypes.h>
#include <ddk/iotypes.h>
#include <ddk/extypes.h>
#include <ddk/pstypes.h>
#include <ddk/setypes.h>
#include <ddk/ioctrl.h>
#include <internal/hal/ddk.h>
#include <ddk/rtl.h>
#include <ddk/zw.h>
#include <ddk/exfuncs.h>
#include <ddk/mmfuncs.h>
#include <ddk/kefuncs.h>
#include <ddk/iofuncs.h>
#include <ddk/psfuncs.h>
#include <ddk/obfuncs.h>
#include <ddk/dbgfuncs.h>
#ifdef __cplusplus
};
#endif
#endif /* __NTDDK_H */

View File

@@ -0,0 +1,10 @@
#ifndef __INCLUDE_DDK_NTDEF_H
#define __INCLUDE_DDK_NTDEF_H
struct _KTHREAD;
struct _ETHREAD;
struct _EPROCESS;
#define NTKERNELAPI
#endif

View File

@@ -0,0 +1,47 @@
/* OBJECT MANAGER ************************************************************/
/*
* FUNCTION: Decrements the object's reference count and performs retention
* checks
* ARGUMENTS:
* Object = Object's body
*/
VOID ObDeferenceObject(PVOID Object);
/*
* FUNCTION: Performs access validation on an object handle and if access
* is granted returns a pointer to the object's body
* ARGUMENTS:
* Handle = Handle to the object
* DesiredAccess = Desired access to the object
* ObjectType (OPTIONAL) = Pointer to the object's type definition
* AccessMode = Access mode to use for the check
* Object (OUT) = Caller supplied storage for a pointer to the object's
* body
* HandleInformation (OUT) = Points to a structure which receives
* information about the handle
* RETURNS: Status
*/
NTSTATUS ObReferenceObjectByHandle(HANDLE Handle,
ACCESS_MASK DesiredAccess,
POBJECT_TYPE ObjectType,
KPROCESSOR_MODE AccessMode,
PVOID* Object,
POBJECT_HANDLE_INFORMATION HandleInfo);
/*
* FUNCTION: Increments the reference count for a given object
* ARGUMENTS:
* Object = Points to the body of the object
* AccessMode = Requested access to the object
* ObjectType = Pointer to the object's type definition
* AccessMode = Access mode to use for the security check
* RETURNS: Status
*/
NTSTATUS ObReferenceObjectByPointer(PVOID Object,
ACCESS_MASK DesiredAccess,
POBJECT_TYPE ObjectType,
KPROCESSOR_MODE AccessMode);
NTSTATUS ObOpenObjectByName(POBJECT_ATTRIBUTES ObjectAttributes,
PVOID* Object);

View File

@@ -0,0 +1,146 @@
struct _DIRECTORY_OBJECT;
typedef ULONG ACCESS_STATE, *PACCESS_STATE;
typedef struct _OBJECT_HANDLE_INFORMATION {
ULONG HandleAttributes;
ACCESS_MASK GrantedAccess;
} OBJECT_HANDLE_INFORMATION, *POBJECT_HANDLE_INFORMATION;
struct _OBJECT;
typedef struct _OBJECT_TYPE
{
/*
* PURPOSE: Name of the type
*/
UNICODE_STRING TypeName;
/*
* PURPOSE: Total number of objects of this type
*/
ULONG TotalObjects;
/*
* PURPOSE: Total number of handles of this type
*/
ULONG TotalHandles;
/*
* PURPOSE: Maximum objects of this type
*/
ULONG MaxObjects;
/*
* PURPOSE: Maximum handles of this type
*/
ULONG MaxHandles;
/*
* PURPOSE: Paged pool charge
*/
ULONG PagedPoolCharge;
/*
* PURPOSE: Nonpaged pool charge
*/
ULONG NonpagedPoolCharge;
/*
* PURPOSE: Dumps the object
* NOTE: To be defined
*/
VOID (*Dump)(VOID);
/*
* PURPOSE: Opens the object
* NOTE: To be defined
*/
VOID (*Open)(VOID);
/*
* PURPOSE: Called to close an object if OkayToClose returns true
*/
VOID (*Close)(VOID);
/*
* PURPOSE: Called to close an object if OkayToClose returns true
*/
VOID (*Delete)(VOID);
/*
* PURPOSE: Called when an open attempts to open a file apparently
* residing within the object
*/
VOID (*Parse)(VOID);
/*
*/
VOID (*Security)(VOID);
/*
*/
VOID (*QueryName)(VOID);
/*
* PURPOSE: Called when a process asks to close the object
*/
VOID (*OkayToClose)(VOID);
} OBJECT_TYPE, *POBJECT_TYPE;
typedef struct _OBJECT
/*
* PURPOSE: Header for every object managed by the object manager
*/
{
/*
* PURPOSE: Name of this entry
*/
UNICODE_STRING name;
/*
* PURPOSE: Our entry in our parents list of subdirectory
*/
LIST_ENTRY entry;
/*
* PURPOSE: Number of non-handle references to this object
*/
ULONG RefCount;
/*
* PURPOSE: Number of handles opened to this object
*/
ULONG HandleCount;
struct _DIRECTORY_OBJECT* Parent;
/*
* PURPOSE: Object type
* NOTE: This overlaps the first member of the object body
*/
CSHORT Type;
/*
* PURPOSE: Object size
* NOTE: This overlaps the second member of the object body
*/
CSHORT Size;
} OBJECT_HEADER, *POBJECT_HEADER;
/*
* PURPOSE: Defines an object
*/
typedef struct _OBJECT_ATTRIBUTES
{
ULONG Length;
HANDLE RootDirectory;
PUNICODE_STRING ObjectName;
ULONG Attributes;
PVOID SecurityDescriptor;
PVOID SecurityQualityOfService;
} OBJECT_ATTRIBUTES, *POBJECT_ATTRIBUTES;

View File

@@ -0,0 +1,31 @@
/*
* FUNCTION: Creates a thread which executes in kernel mode
* ARGUMENTS:
* ThreadHandle (OUT) = Caller supplied storage for the returned thread
* handle
* DesiredAccess = Requested access to the thread
* ObjectAttributes = Object attributes (optional)
* ProcessHandle = Handle of process thread will run in
* NULL to use system process
* ClientId (OUT) = Caller supplied storage for the returned client id
* of the thread (optional)
* StartRoutine = Entry point for the thread
* StartContext = Argument supplied to the thread when it begins
* execution
* RETURNS: Success or failure status
*/
NTSTATUS PsCreateSystemThread(PHANDLE ThreadHandle,
ACCESS_MASK DesiredAccess,
POBJECT_ATTRIBUTES ObjectAttributes,
HANDLE ProcessHandle,
PCLIENT_ID ClientId,
PKSTART_ROUTINE StartRoutine,
PVOID StartContext);
NTSTATUS PsTerminateSystemThread(NTSTATUS ExitStatus);
NTSTATUS PsSuspendThread(VOID);
NTSTATUS PsWakeThread(PETHREAD Thread);
PETHREAD PsGetCurrentThread(VOID);
struct _EPROCESS* PsGetCurrentProcess(VOID);

View File

@@ -0,0 +1,285 @@
#ifndef __INCLUDE_DDK_PSTYPES_H
#define __INCLUDE_DDK_PSTYPES_H
#include <kernel32/heap.h>
#include <internal/hal.h>
typedef NTSTATUS (*PKSTART_ROUTINE)(PVOID StartContext);
typedef struct _STACK_INFORMATION
{
PVOID BaseAddress;
PVOID UpperAddress;
} STACK_INFORMATION, *PSTACK_INFORMATION;
typedef struct linux_sigcontext {
int sc_gs;
int sc_fs;
int sc_es;
int sc_ds;
int sc_edi;
int sc_esi;
int sc_ebp;
int sc_esp;
int sc_ebx;
int sc_edx;
int sc_ecx;
int sc_eax;
int sc_trapno;
int sc_err;
int sc_eip;
int sc_cs;
int sc_eflags;
int sc_esp_at_signal;
int sc_ss;
int sc_387;
int sc_mask;
int sc_cr2;
} TRAP_FRAME, *PTRAP_FRAME;
typedef ULONG THREADINFOCLASS;
typedef void* ATOMTABLE;
typedef struct _pPebInfo {
WCHAR* WindowTitle;
WCHAR* ImageFile;
WCHAR* CommandLine;
WCHAR* DllPath;
// STARTUPINFOW StartupInfo;
} PEBINFO;
typedef struct _LDR_ {
UCHAR Initialized;
UCHAR InInitializationOrderModuleList;
PVOID InLoadOrderModuleList;
PVOID InMemoryOrderModuleList;
} LDR, *PLDR;
typedef struct _NT_PEB
{
UCHAR InheritedAddressSpace;
UCHAR ReadImageFileExecOptions;
UCHAR BeingDebugged;
LONG ImageBaseAddress;
LDR Ldr;
DWORD dwTlsBits[2]; // tls in use bits
WORD NumberOfProcessors;
WORD NtGlobalFlag;
DWORD HeapReserve;
DWORD HeapCommit;
DWORD HeapDecommitFreeBlockThreshold;
DWORD NumberOfHeaps;
DWORD MaxiumNumberOfHeaps;
PEBINFO* PebInfo;
PHEAP ProcessHeap;
ATOMTABLE LocalAtomTable;
LPCRITICAL_SECTION CriticalSection;
DWORD CriticalSectionTimeout;
WORD MajorVersion;
WORD MinorVersion;
WORD BuildNumber;
WORD PlatformId;
} NT_PEB, *PNT_PEB;
typedef struct _CLIENT_ID
{
HANDLE UniqueProcess;
HANDLE UniqueThread;
} CLIENT_ID, *PCLIENT_ID;
typedef struct _NT_TIB {
struct _EXCEPTION_REGISTRATION_RECORD *ExceptionList;
PVOID StackBase;
PVOID StackLimit;
PVOID SubSystemTib;
union {
PVOID FiberData;
ULONG Version;
} Fib;
PVOID ArbitraryUserPointer;
struct _NT_TIB *Self;
} NT_TIB, *PNT_TIB;
typedef struct _NT_TEB
{
NT_TIB Tib;
CLIENT_ID Cid;
HANDLE RPCHandle;
PVOID TlsData;
NT_PEB *pPeb;
DWORD LastErrorCode;
NTSTATUS LastStatusValue;
DWORD LockCount;
UCHAR HardErrorMode;
} NT_TEB;
typedef struct _KTHREAD
{
DISPATCHER_HEADER DispatcherHeader;
TIME ElapsedTime;
TIME KernelTime;
TIME UserTime;
STACK_INFORMATION StackInformation;
PVOID ServiceDescriptorTable; // points to KeServiceDescriptorTable
KAFFINITY Affinity;
KPRIORITY CurrentPriority;
KPRIORITY BasePriority;
ULONG Quantum;
UCHAR ThreadState; //Thread state is a typeless enum, otherwise it should be const integer
ULONG FreezeCount;
ULONG SuspendCount;
PTRAP_FRAME TrapFrame;
PVOID *Tls;
KWAIT_BLOCK WaitBlock[4];
struct _KMUTANT* MutantList;
PLIST_ENTRY ApcList;
UCHAR KernelApcDisable;
KTIMER TimerBlock;
KDEVICE_QUEUE DeviceQueue;
NT_TEB* Teb;
/*
* PURPOSE: CPU state
* NOTE: I have temporarily added this to give somewhere to store
* cpu state when the thread isn't running
*/
hal_thread_state Context;
LIST_ENTRY Entry;
} KTHREAD, *PKTHREAD;
// According to documentation the stack should have a commited [ 1 page ] and
// a reserved part [ 1 M ].
typedef struct _INITIAL_TEB {
PVOID StackCommit;
PVOID StackReserved;
} INITIAL_TEB, *PINITIAL_TEB;
//ThreadState defines the current state of a thread
//FIXME I am allready defined in psmgr.h as a enum
/*
enum
{
THREAD_STATE_INITIALIZED = 0,
THREAD_STATE_READY,
THREAD_STATE_RUNNING,
THREAD_STATE_STANDBY,
THREAD_STATE_TERMINATED,
THREAD_STATE_WAIT,
THREAD_STATE_TRANSITION,
THREAD_STATE_RESERVED
};
*/
// wait reason only applies for threads in a wait state
// part of this enum is double ????
/*
typedef _KWAIT_REASON
{
WAIT_EXCECUTIVE1 = 0,
WAIT_FREE_PAGE1,
WAIT_PAGE_IN1,
WAIT_POOL_ALLOCATION1,
WAIT_EXECUTION_DELAY1,
WAIT_SUSPENDED_CONDITION1,
WAIT_USER_REQUEST1,
WAIT_EXCECUTIVE2,
WAIT_FREE_PAGE2,
WAIT_PAGE_IN2,
WAIT_POOL_ALLOCATION2,
WAIT_EXECUTION_DELAY2,
WAIT_SUSPENDED_CONDITION2,
WAIT_USER_REQUEST2,
WAIT_EVENT_PAIR_HIGH,
WAIT_EVENT_PAIR_LOW,
WAIT_LPC_RECEIVE,
WAIT_LPC_REPLY,
WAIT_VIRTUAL_MEMORY,
WAIT_PAGE_OUT
} KWAIT_REASON;
*/
// TopLevelIrp can be one of the following values:
// FIXME I belong somewhere else
#define FSRTL_FSP_TOP_LEVEL_IRP (0x01)
#define FSRTL_CACHE_TOP_LEVEL_IRP (0x02)
#define FSRTL_MOD_WRITE_TOP_LEVEL_IRP (0x03)
#define FSRTL_FAST_IO_TOP_LEVEL_IRP (0x04)
#define FSRTL_MAX_TOP_LEVEL_IRP_FLAG (0x04)
typedef struct _TOP_LEVEL_IRP
{
PIRP TopLevelIrp;
ULONG TopLevelIrpConst;
} TOP_LEVEL_IRP;
typedef struct _ETHREAD {
KTHREAD Tcb;
TIME CreateTime;
TIME ExitTime;
NTSTATUS ExitStatus;
LIST_ENTRY PostBlockList;
LIST_ENTRY TerminationPortList;
ULONG ActiveTimerListLock;
PVOID ActiveTimerListHead;
CLIENT_ID Cid;
PLARGE_INTEGER LpcReplySemaphore;
PVOID LpcReplyMessage;
PLARGE_INTEGER LpcReplyMessageId;
PVOID ImpersonationInfo;
LIST_ENTRY IrpList; //
TOP_LEVEL_IRP TopLevelIrp;
ULONG ReadClusterSize;
UCHAR ForwardClusterOnly;
UCHAR DisablePageFaultClustering;
UCHAR DeadThread;
UCHAR HasTerminated;
ACCESS_MASK GrantedAccess;
struct _EPROCESS* ThreadsProcess;
PKSTART_ROUTINE StartAddress;
LPTHREAD_START_ROUTINE Win32StartAddress; // Should Specify a win32 start func
UCHAR LpcExitThreadCalled;
UCHAR HardErrorsAreDisabled;
} ETHREAD, *PETHREAD;
typedef struct _KPROCESS {
DISPATCHER_HEADER DispatcherHeader;
PVOID PageTableDirectory; // FIXME: I shoud point to a PTD
TIME ElapsedTime;
TIME KernelTime;
TIME UserTime;
LIST_ENTRY InOutSwap; // ??
KSPIN_LOCK SpinLock;
KAFFINITY Affinity;
ULONG StackCount;
KPRIORITY BasePriority;
ULONG DefaultThreadQuantum;
UCHAR ProcessState;
ULONG ThreadSeed;
UCHAR DisableBoost;
/*
* Added by David Welch (welch@mcmail.com)
*/
LIST_ENTRY MemoryAreaList;
} KPROCESS, *PKPROCESS;
typedef struct _EPROCESS
{
KPROCESS Pcb;
} EPROCESS, *PEPROCESS;
#endif /* __INCLUDE_DDK_PSTYPES_H */

323
reactos/include/ddk/rtl.h Normal file
View File

@@ -0,0 +1,323 @@
/*
*
*/
#ifndef __DDK_RTL_H
#define __DDK_RTL_H
typedef struct _CONTROLLER_OBJECT
{
CSHORT Type;
CSHORT Size;
PVOID ControllerExtension;
KDEVICE_QUEUE DeviceWaitQueue;
ULONG Spare1;
LARGE_INTEGER Spare2;
} CONTROLLER_OBJECT, *PCONTROLLER_OBJECT;
typedef struct _STRING
{
/*
* Length in bytes of the string stored in buffer
*/
USHORT Length;
/*
* Maximum length of the string
*/
USHORT MaximumLength;
/*
* String
*/
PCHAR Buffer;
} STRING, *PSTRING;
typedef struct _ANSI_STRING
{
/*
* Length in bytes of the string stored in buffer
*/
USHORT Length;
/*
* Maximum length of the string
*/
USHORT MaximumLength;
/*
* String
*/
PCHAR Buffer;
} ANSI_STRING, *PANSI_STRING;
typedef struct _TIME_FIELDS
{
CSHORT Year;
CSHORT Month;
CSHORT Day;
CSHORT Hour;
CSHORT Minute;
CSHORT Second;
CSHORT Milliseconds;
CSHORT Weekday;
} TIME_FIELDS, *PTIME_FIELDS;
/*
* PURPOSE: Flags for RtlQueryRegistryValues
*/
enum
{
RTL_QUERY_REGISTRY_SUBKEY,
RTL_QUERY_REGISTRY_TOPKEY,
RTL_QUERY_REGISTRY_REQUIRED,
RTL_QUERY_REGISTRY_NOVALUE,
RTL_QUERY_REGISTRY_NOEXPAND,
RTL_QUERY_REGISTRY_DIRECT,
RTL_QUERY_REGISTRY_DELETE,
};
typedef NTSTATUS (*PRTL_QUERY_REGISTRY_ROUTINE)(PWSTR ValueName,
ULONG ValueType,
PVOID ValueData,
ULONG ValueLength,
PVOID Context,
PVOID EntryContext);
typedef struct _RTL_QUERY_REGISTRY_TABLE
{
PRTL_QUERY_REGISTRY_ROUTINE QueryRoutine;
ULONG Flags;
PWSTR Name;
PVOID EntryContext;
ULONG DefaultType;
PVOID DefaultData;
ULONG DefaultLength;
} RTL_QUERY_REGISTRY_TABLE, *PRTL_QUERY_REGISTRY_TABLE;
/*
* PURPOSE: Used with RtlCheckRegistryKey, RtlCreateRegistryKey,
* RtlDeleteRegistryKey
*/
enum
{
RTL_REGISTRY_ABSOLUTE,
RTL_REGISTRY_SERVICES,
RTL_REGISTRY_CONTROL,
RTL_REGISTRY_WINDOWS_NT,
RTL_REGISTRY_DEVICEMAP,
RTL_REGISTRY_USER,
RTL_REGISTRY_OPTIONAL,
RTL_REGISTRY_VALUE,
};
/*
* FUNCTION: Sets up a parameter of type OBJECT_ATTRIBUTES for a
* subsequent call to ZwCreateXXX or ZwOpenXXX
* ARGUMENTS:
* InitializedAttributes (OUT) = Caller supplied storage for the
* object attributes
* ObjectName = Full path name for object
* Attributes = Attributes for the object
* RootDirectory = Where the object should be placed or NULL
* SecurityDescriptor = Ignored
*/
VOID InitializeObjectAttributes(POBJECT_ATTRIBUTES InitializedAttributes,
PUNICODE_STRING ObjectName,
ULONG Attributes,
HANDLE RootDirectory,
PSECURITY_DESCRIPTOR SecurityDescriptor);
VOID InitializeListHead(PLIST_ENTRY ListHead);
VOID InsertHeadList(PLIST_ENTRY ListHead, PLIST_ENTRY Entry);
VOID InsertTailList(PLIST_ENTRY ListHead, PLIST_ENTRY Entry);
BOOLEAN IsListEmpty(PLIST_ENTRY ListHead);
PSINGLE_LIST_ENTRY PopEntryList(PSINGLE_LIST_ENTRY ListHead);
VOID PushEntryList(PSINGLE_LIST_ENTRY ListHead, PSINGLE_LIST_ENTRY Entry);
VOID RemoveEntryList(PLIST_ENTRY Entry);
PLIST_ENTRY RemoveHeadList(PLIST_ENTRY ListHead);
PLIST_ENTRY RemoveTailList(PLIST_ENTRY ListHead);
ULONG RtlAnsiStringToUnicodeSize(PANSI_STRING AnsiString);
NTSTATUS RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString,
PANSI_STRING SourceString,
BOOLEAN AllocateDestinationString);
NTSTATUS RtlAppendUnicodeStringToString(PUNICODE_STRING Destination,
PUNICODE_STRING Source);
NTSTATUS RtlAppendUnicodeToString(PUNICODE_STRING Destination,
PWSTR Source);
NTSTATUS RtlCharToInteger(PCSZ String, ULONG Base, PULONG Value);
NTSTATUS RtlCheckRegistryKey(ULONG RelativeTo, PWSTR Path);
ULONG RtlCompareMemory(PVOID Source1, PVOID Source2, ULONG Length);
LONG RtlCompareString(PSTRING String1, PSTRING String2,
BOOLEAN CaseInsensitive);
LONG RtlCompareUnicodeString(PUNICODE_STRING String1,
PUNICODE_STRING String2,
BOOLEAN BaseInsensitive);
LARGE_INTEGER RtlConvertLongToLargeInteger(LONG SignedInteger);
LARGE_INTEGER RtlConvertUlongToLargeInteger(ULONG UnsignedInteger);
VOID RtlCopyBytes(PVOID Destination, CONST VOID* Source, ULONG Length);
VOID RtlCopyMemory(VOID* Destination, VOID* Source, ULONG Length);
VOID RtlCopyString(PSTRING DestinationString, PSTRING SourceString);
VOID RtlCopyUnicodeString(PUNICODE_STRING DestinationString,
PUNICODE_STRING SourceString);
NTSTATUS RtlCreateRegistryKey(ULONG RelativeTo,
PWSTR Path);
NTSTATUS RtlCreateSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor,
ULONG Revision);
NTSTATUS RtlDeleteRegistryValue(ULONG RelativeTo,
PWSTR Path,
PWSTR ValueName);
LARGE_INTEGER RtlEnlargedIntegerMultiply(LONG Multiplicand,
LONG Multiplier);
ULONG RtlEnlargedUnsignedDivide(ULARGE_INTEGER Dividend,
ULONG Divisor,
PULONG Remainder);
LARGE_INTEGER RtlEnlargedUnsignedMultiply(ULONG Multiplicand,
ULONG Multiplier);
BOOLEAN RtlEqualString(PSTRING String1,
PSTRING String2,
BOOLEAN CaseInSensitive);
BOOLEAN RtlEqualUnicodeString(PUNICODE_STRING String1,
PUNICODE_STRING String2,
BOOLEAN CaseInSensitive);
LARGE_INTEGER RtlExtendedIntegerMultiply(LARGE_INTEGER Multiplicand,
LONG Multiplier);
LARGE_INTEGER RtlExtendedLargeIntegerDivide(LARGE_INTEGER Dividend,
ULONG Divisor,
PULONG Remainder);
LARGE_INTEGER RtlExtendedMagicDivide(LARGE_INTEGER Dividend,
LARGE_INTEGER MagicDivisor,
CCHAR ShiftCount);
VOID RtlFillMemory(PVOID Destination, ULONG Length, UCHAR Fill);
VOID RtlFreeAnsiString(PANSI_STRING AnsiString);
VOID RtlFreeUnicodeString(PUNICODE_STRING UnicodeString);
VOID RtlInitAnsiString(PANSI_STRING DestinationString,
PCSZ SourceString);
VOID RtlInitString(PSTRING DestinationString, PCSZ SourceString);
VOID RtlInitUnicodeString(PUNICODE_STRING DestinationString,
PCWSTR SourceString);
NTSTATUS RtlIntegerToUnicodeString(ULONG Value,
ULONG Base,
PUNICODE_STRING String);
LARGE_INTEGER RtlLargeIntegerAdd(LARGE_INTEGER Addend1,
LARGE_INTEGER Addend2);
VOID RtlLargeIntegerAnd(PLARGE_INTEGER Result,
LARGE_INTEGER Source,
LARGE_INTEGER Mask);
/* MISSING FUNCTIONS GO HERE */
LARGE_INTEGER RtlConvertLongToLargeInteger(LONG SignedInteger);
LARGE_INTEGER RtlConvertUlongToLargeInteger(ULONG UnsignedInteger);
LARGE_INTEGER RtlEnlargedIntegerMultiply(LONG Multiplicand,
LONG Multiplier);
ULONG RtlEnlargedUnsignedDivide(ULARGE_INTEGER Dividend,
ULONG Divisor,
PULONG Remainder);
LARGE_INTEGER RtlEnlargedUnsignedMultiply(ULONG Multiplicand,
ULONG Multipler);
LARGE_INTEGER RtlExtendedIntegerMultiply(LARGE_INTEGER Multiplicand,
LONG Multiplier);
LARGE_INTEGER RtlExtendedLargeIntegerDivide(LARGE_INTEGER Dividend,
ULONG Divisor,
PULONG Remainder);
LARGE_INTEGER RtlExtendedMagicDivide(LARGE_INTEGER Dividend,
LARGE_INTEGER MagicDivisor,
CCHAR ShiftCount);
LARGE_INTEGER ExInterlockedAddLargeInteger(PLARGE_INTEGER Addend,
LARGE_INTEGER Increment,
PKSPIN_LOCK Lock);
LARGE_INTEGER RtlLargeIntegerAdd(LARGE_INTEGER Addend1,
LARGE_INTEGER Addend2);
VOID RtlLargeIntegerAnd(PLARGE_INTEGER Result,
LARGE_INTEGER Source,
LARGE_INTEGER Mask);
LARGE_INTEGER RtlLargeIntegerArithmeticShift(LARGE_INTEGER LargeInteger,
CCHAR ShiftCount);
LARGE_INTEGER RtlLargeIntegerDivide(LARGE_INTEGER Dividend,
LARGE_INTEGER Divisor,
PLARGE_INTEGER Remainder);
BOOLEAN RtlLargeIntegerEqualTo(LARGE_INTEGER Operand1,
LARGE_INTEGER Operand2);
BOOLEAN RtlLargeIntegerEqualToZero(LARGE_INTEGER Operand);
BOOLEAN RtlLargeIntegerGreaterThan(LARGE_INTEGER Operand1,
LARGE_INTEGER Operand2);
BOOLEAN RtlLargeIntegerGreaterThanOrEqualTo(LARGE_INTEGER Operand1,
LARGE_INTEGER Operand2);
BOOLEAN RtlLargeIntegerGreaterThanOrEqualToZero(LARGE_INTEGER Operand1);
BOOLEAN RtlLargeIntegerGreaterThanZero(LARGE_INTEGER Operand1);
BOOLEAN RtlLargeIntegerLessThan(LARGE_INTEGER Operand1,
LARGE_INTEGER Operand2);
BOOLEAN RtlLargeIntegerLessThanOrEqualTo(LARGE_INTEGER Operand1,
LARGE_INTEGER Operand2);
BOOLEAN RtlLargeIntegerLessThanOrEqualToZero(LARGE_INTEGER Operand);
BOOLEAN RtlLargeIntegerLessThanZero(LARGE_INTEGER Operand);
LARGE_INTEGER RtlLargeIntegerNegate(LARGE_INTEGER Subtrahend);
BOOLEAN RtlLargeIntegerNotEqualTo(LARGE_INTEGER Operand1,
LARGE_INTEGER Operand2);
BOOLEAN RtlLargeIntegerNotEqualToZero(LARGE_INTEGER Operand);
LARGE_INTEGER RtlLargeIntegerShiftLeft(LARGE_INTEGER LargeInteger,
CCHAR ShiftCount);
LARGE_INTEGER RtlLargeIntegerShiftRight(LARGE_INTEGER LargeInteger,
CCHAR ShiftCount);
LARGE_INTEGER RtlLargeIntegerSubtract(LARGE_INTEGER Minuend,
LARGE_INTEGER Subtrahend);
ULONG RtlLengthSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor);
VOID RtlMoveMemory(PVOID Destination, CONST VOID* Source, ULONG Length);
NTSTATUS RtlQueryRegistryValues(ULONG RelativeTo,
PWSTR Path,
PRTL_QUERY_REGISTRY_TABLE QueryTable,
PVOID Context, PVOID Environment);
VOID RtlRetrieveUlong(PULONG DestinationAddress,
PULONG SourceAddress);
VOID RtlRetrieveUshort(PUSHORT DestinationAddress,
PUSHORT SourceAddress);
NTSTATUS RtlSetDaclSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor,
BOOLEAN DaclPresent,
PACL Dacl,
BOOLEAN DaclDefaulted);
VOID RtlStoreLong(PULONG Address, ULONG Value);
VOID RtlStoreUshort(PUSHORT Address, USHORT Value);
BOOLEAN RtlTimeFieldsToTime(PTIME_FIELDS TimeFields, PLARGE_INTEGER Time);
VOID RtlTimeToTimeFields(PLARGE_INTEGER Time, PTIME_FIELDS TimeFields);
PWSTR RtlStrtok(PUNICODE_STRING _string, PWSTR _sep, PWSTR* temp);
VOID RtlGetCallersAddress(PVOID* CallersAddress);
VOID RtlZeroMemory(PVOID Destination, ULONG Length);
typedef struct {
ULONG Length;
ULONG Unknown[11];
} RTL_HEAP_DEFINITION, *PRTL_HEAP_DEFINITION;
// Heap creation routine
HANDLE
STDCALL
RtlCreateHeap(
ULONG Flags,
PVOID BaseAddress,
ULONG SizeToReserve,
ULONG SizeToCommit,
PVOID Unknown,
PRTL_HEAP_DEFINITION Definition
);
PVOID
STDCALL
RtlAllocateHeap(
HANDLE Heap,
ULONG Flags,
ULONG Size
);
BOOLEAN
STDCALL
RtlFreeHeap(
HANDLE Heap,
ULONG Flags,
PVOID Address
);
#endif /* __DDK_RTL_H */

View File

@@ -0,0 +1,41 @@
/*
* COPYRIGHT: See COPYING in the top level directory for details
* PROJECT: ReactOS kernel
* FILE: include/ddk/setypes.h
* PURPOSE: Security manager types
* REVISION HISTORY:
* ??/??/??: Created with empty stubs by David Welch
* 29/08/98: ACCESS_TOKEN definition from Boudewijn Dekker
*/
typedef ULONG ACCESS_MODE, *PACCESS_MODE;
typedef struct _SECURITY_SUBJECT_CONTEXT
{
} SECURITY_SUBJECT_CONTEXT, *PSECURITY_SUBJECT_CONTEXT;
typedef struct _SECURITY_DESCRIPTOR_CONTEXT
{
} SECURITY_DESCRIPTOR_CONTEXT, *PSECURITY_DESCRIPTOR_CONTEXT;
typedef struct _ACCESS_TOKEN {
TOKEN_SOURCE TokenSource;
LUID AuthenticationId;
LARGE_INTEGER ExpirationTime;
LUID ModifiedId;
ULONG UserAndGroupCount;
ULONG PrivilegeCount;
ULONG VariableLength;
ULONG DynamicCharged;
ULONG DynamicAvailable;
ULONG DefaultOwnerIndex;
PACL DefaultDacl;
TOKEN_TYPE TokenType;
SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
UCHAR TokenFlags;
UCHAR TokenInUse;
UCHAR Unused[2];
PVOID ProxyData;
PVOID AuditData;
UCHAR VariablePart[0];
} ACCESS_TOKEN, *PACCESS_TOKEN;

View File

@@ -0,0 +1,159 @@
#ifndef __INCLUDE_DDK_STATUS_H
#define __INCLUDE_DDK_STATUS_H
#define NT_SUCCESS(StatCode) ((NTSTATUS)(StatCode) >= 0)
/*
* Possible status codes
* FIXME: These may not be the actual values used by NT
*/
enum
{
STATUS_SUCCESS = 0x0,
STATUS_INSUFFICIENT_RESOURCES = 0x80000000,
STATUS_OBJECT_NAME_EXISTS,
STATUS_OBJECT_NAME_COLLISION,
// STATUS_DATATYPE_MISALIGNMENT,
STATUS_CTL_FILE_NOT_SUPPORTED,
// STATUS_ACCESS_VIOLATION,
STATUS_PORT_ALREADY_SET,
STATUS_SECTION_NOT_IMAGE,
STATUS_BAD_WORKING_SET_LIMIT,
STATUS_INCOMPATIBLE_FILE_MAP,
STATUS_HANDLE_NOT_WAITABLE,
STATUS_PORT_DISCONNECTED,
STATUS_NOT_LOCKED,
STATUS_NOT_MAPPED_VIEW,
STATUS_UNABLE_TO_FREE_VM,
STATUS_UNABLE_TO_DELETE_SECTION,
STATUS_MORE_PROCESSING_REQUIRED,
STATUS_INVALID_CID,
STATUS_BAD_INITIAL_STACK,
STATUS_INVALID_VOLUME_LABEL,
STATUS_SECTION_NOT_EXTENDED,
STATUS_NOT_MAPPED_DATA,
STATUS_INFO_LENGTH_MISMATCH,
STATUS_INVALID_INFO_CLASS,
STATUS_SUSPEND_COUNT_EXCEEDED,
STATUS_NOTIFY_ENUM_DIR,
STATUS_REGISTRY_RECOVERED,
STATUS_REGISTRY_IO_FAILED,
STATUS_KEY_DELETED,
STATUS_NO_LOG_SPACE,
STATUS_KEY_HAS_CHILDREN,
STATUS_CHILD_MUST_BE_VOLATILE,
STATUS_REGISTRY_CORRUPT,
STATUS_DLL_NOT_FOUND,
STATUS_DLL_INIT_FAILED,
STATUS_ORDINAL_NOT_FOUND,
STATUS_ENTRYPOINT_NOT_FOUND,
// STATUS_PENDING,
STATUS_MORE_ENTRIES,
// STATUS_INTEGER_OVERFLOW,
STATUS_BUFFER_OVERFLOW,
STATUS_NO_MORE_FILES,
STATUS_NO_INHERITANCE,
STATUS_NO_MORE_EAS,
STATUS_NO_MORE_ENTRIES,
STATUS_GUIDS_EXHAUSTED,
STATUS_AGENTS_EXHAUSTED,
STATUS_UNSUCCESSFUL,
STATUS_NOT_IMPLEMENTED,
STATUS_ILLEGAL_FUNCTION,
// STATUS_IN_PAGE_ERROR,
STATUS_PAGEFILE_QUOTA,
STATUS_COMMITMENT_LIMIT,
STATUS_SECTION_TOO_BIG,
RPC_NT_SS_IN_NULL_CONTEXT,
RPC_NT_INVALID_BINDING,
// STATUS_INVALID_HANDLE,
STATUS_OBJECT_FILE_MISMATCH,
STATUS_FILE_CLOSED,
STATUS_INVALID_PORT_HANDLE,
STATUS_NOT_COMMITTED,
STATUS_INVALID_PARAMETER,
STATUS_INVALID_PARAMETER_1,
STATUS_INVALID_PARAMETER_2,
STATUS_INVALID_PARAMETER_3,
STATUS_INVALID_PARAMETER_4,
STATUS_INVALID_PARAMETER_5,
STATUS_INVALID_PARAMETER_6,
STATUS_INVALID_PARAMETER_7,
STATUS_INVALID_PARAMETER_8,
STATUS_INVALID_PARAMETER_9,
STATUS_INVALID_PARAMETER_10,
STATUS_INVALID_PARAMETER_11,
STATUS_INVALID_PARAMETER_12,
STATUS_INVALID_PARAMETER_MAX,
STATUS_INVALID_PAGE_PROTECTION,
STATUS_RESOURCE_DATA_NOT_FOUND,
STATUS_RESOURCE_TYPE_NOT_FOUND,
STATUS_RESOURCE_NAME_NOT_FOUND,
STATUS_RESOURCE_LANG_NOT_FOUND,
STATUS_NO_SUCH_DEVICE,
STATUS_NO_SUCH_FILE,
STATUS_INVALID_DEVICE_REQUEST,
STATUS_END_OF_FILE,
STATUS_FILE_FORCED_CLOSED,
STATUS_WRONG_VOLUME,
STATUS_NO_MEDIA,
STATUS_NO_MEDIA_IN_DEVICE,
STATUS_NONEXISTENT_SECTOR,
STATUS_WORKING_SET_QUOTA,
// STATUS_NO_MEMORY,
STATUS_CONFLICTING_ADDRESS,
STATUS_INVALID_SYSTEM_SERVICE,
STATUS_THREAD_IS_TERMINATING,
STATUS_PROCESS_IS_TERMINATING,
STATUS_INVALID_LOCK_SEQUENCE,
STATUS_INVALID_VIEW_SIZE,
STATUS_ALREADY_COMMITTED,
STATUS_ACCESS_DENIED,
STATUS_FILE_IS_A_DIRECTORY,
STATUS_CANNOT_DELETE,
STATUS_INVALID_COMPUTER_NAME,
STATUS_FILE_DELETED,
STATUS_DELETE_PENDING,
STATUS_PORT_CONNECTION_REFUSED,
STATUS_NO_SUCH_PRIVILEGE,
STATUS_PRIVILEGE_NOT_HELD,
STATUS_CANNOT_IMPERSONATE,
STATUS_LOGON_FAILURE,
STATUS_ACCOUNT_RESTRICTION,
STATUS_INVALID_LOGON_HOURS,
STATUS_INVALID_WORKSTATION,
STATUS_BUFFER_TOO_SMALL,
STATUS_UNABLE_TO_DECOMMIT_VM,
STATUS_DISK_CORRUPT_ERROR,
STATUS_OBJECT_NAME_INVALID,
STATUS_OBJECT_NAME_NOT_FOUND,
// STATUS_OBJECT_NAME_COLLISION,
STATUS_OBJECT_PATH_INVALID,
STATUS_OBJECT_PATH_NOT_FOUND,
STATUS_DFS_EXIT_PATH_FOUND,
STATUS_OBJECT_PATH_SYNTAX_BAD,
STATUS_DATA_OVERRUN,
STATUS_DATA_LATE_ERROR,
STATUS_DATA_ERROR,
STATUS_CRC_ERROR,
STATUS_SHARING_VIOLATION,
STATUS_QUOTA_EXCEEDED,
STATUS_MUTANT_NOT_OWNED,
STATUS_SEMAPHORE_LIMIT_EXCEEDED,
STATUS_DISK_FULL,
STATUS_LOCK_NOT_GRANTED,
STATUS_DEVICE_NOT_READY,
STATUS_IO_TIMEOUT,
STATUS_MEDIA_WRITE_PROTECTED,
STATUS_NO_MEDIA_IN_DRIVE,
STATUS_VERIFY_REQUIRED,
STATUS_UNRECOGNIZED_MEDIA,
STATUS_UNRECOGNIZED_VOLUME,
// STATUS_WRONG_VOLUME,
STATUS_FS_DRIVER_REQUIRED,
STATUS_NOT_SUPPORTED = 9999,
STATUS_DISK_OPERATION_FAILED
};
#endif /* __INCLUDE_DDK_STATUS_H */

View File

@@ -0,0 +1,73 @@
#ifndef __DDK_TYPES_H
#define __DDK_TYPES_H
// these should be moved to a file like ntdef.h
typedef const int CINT;
typedef ULONG KAFFINITY, *PKAFFINITY;
typedef LONG NTSTATUS, *PNTSTATUS;
typedef ULONG DEVICE_TYPE;
enum
{
DIRECTORY_QUERY,
DIRECTORY_TRAVERSE,
DIRECTORY_CREATE_OBJECT,
DIRECTORY_CREATE_SUBDIRECTORY,
DIRECTORY_ALL_ACCESS,
};
typedef unsigned long long ULONGLONG;
/*
* General type for status information
*/
//typedef LONG NTSTATUS;
typedef struct _UNICODE_STRING
{
USHORT Length;
USHORT MaximumLength;
PWSTR Buffer;
} UNICODE_STRING, *PUNICODE_STRING;
typedef enum _SECTION_INHERIT {
ViewShare = 1,
ViewUnmap = 2
} SECTION_INHERIT;
/*
* Various other types (all quite pointless)
*/
typedef ULONG KPROCESSOR_MODE;
typedef UCHAR KIRQL;
typedef KIRQL* PKIRQL;
typedef ULONG IO_ALLOCATION_ACTION;
typedef ULONG POOL_TYPE;
typedef ULONG TIMER_TYPE;
typedef ULONG MM_SYSTEM_SIZE;
typedef ULONG LOCK_OPERATION;
typedef ULONG KEY_INFORMATION_CLASS;
typedef ULONG FILE_INFORMATION_CLASS;
typedef ULONG KEY_VALUE_INFORMATION_CLASS;
typedef LARGE_INTEGER PHYSICAL_ADDRESS;
typedef PHYSICAL_ADDRESS* PPHYSICAL_ADDRESS;
typedef ULONG WAIT_TYPE;
//typedef ULONG KINTERRUPT_MODE;
typedef USHORT CSHORT;
typedef struct _TIME {
DWORD LowPart;
LONG HighPart;
} TIME;
#endif

3908
reactos/include/ddk/zw.h Normal file

File diff suppressed because it is too large Load Diff

5167
reactos/include/defines.h Normal file

File diff suppressed because it is too large Load Diff

16
reactos/include/devices.h Normal file
View File

@@ -0,0 +1,16 @@
typedef struct
{
LPSTR LeftVolumeName;
LPSTR RightVolumeName;
ULONG DefaultVolume;
ULONG Type;
ULONG DeviceType;
char Key[4];
LPSTR PrototypeName;
PVOID DeferredRoutine;
PVOID ExclusionRoutine;
PVOID DispatchRoutine;
PVOID DevCapsRoutine;
PVOID HwSetVolume;
ULONG IoMethod;
}SOUND_DEVICE_INIT;

713
reactos/include/errors.h Normal file
View File

@@ -0,0 +1,713 @@
/*
Errors.h
Windows32 API error codes
Copyright (C) 1996 Free Software Foundation, Inc.
Author: Scott Christley <scottc@net-community.com>
This file is part of the Windows32 API Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
If you are interested in a warranty or support for this source code,
contact Scott Christley <scottc@net-community.com> for more information.
You should have received a copy of the GNU Library General Public
License along with this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _GNU_H_WINDOWS32_ERROR
#define _GNU_H_WINDOWS32_ERROR
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/* Numerical order */
#define LZERROR_UNKNOWNALG (-8)
#define LZERROR_BADVALUE (-7)
#define LZERROR_GLOBLOCK (-6)
#define LZERROR_GLOBALLOC (-5)
#define LZERROR_WRITE (-4)
#define LZERROR_READ (-3)
#define LZERROR_BADOUTHANDLE (-2)
#define LZERROR_BADINHANDLE (-1)
#define NO_ERROR 0L
#define ERROR_SUCCESS 0L
#define ERROR_INVALID_FUNCTION 1L
#define ERROR_FILE_NOT_FOUND 2L
#define ERROR_PATH_NOT_FOUND 3L
#define ERROR_TOO_MANY_OPEN_FILES 4L
#define ERROR_ACCESS_DENIED 5L
#define ERROR_INVALID_HANDLE 6L
#define ERROR_ARENA_TRASHED 7L
#define ERROR_NOT_ENOUGH_MEMORY 8L
#define ERROR_INVALID_BLOCK 9L
#define ERROR_BAD_ENVIRONMENT 10L
#define ERROR_BAD_FORMAT 11L
#define ERROR_INVALID_ACCESS 12L
#define ERROR_INVALID_DATA 13L
#define ERROR_OUTOFMEMORY 14L
#define ERROR_INVALID_DRIVE 15L
#define ERROR_CURRENT_DIRECTORY 16L
#define ERROR_NOT_SAME_DEVICE 17L
#define ERROR_NO_MORE_FILES 18L
#define ERROR_WRITE_PROTECT 19L
#define ERROR_BAD_UNIT 20L
#define ERROR_NOT_READY 21L
#define ERROR_BAD_COMMAND 22L
#define ERROR_CRC 23L
#define ERROR_BAD_LENGTH 24L
#define ERROR_SEEK 25L
#define ERROR_NOT_DOS_DISK 26L
#define ERROR_SECTOR_NOT_FOUND 27L
#define ERROR_OUT_OF_PAPER 28L
#define ERROR_WRITE_FAULT 29L
#define ERROR_READ_FAULT 30L
#define ERROR_GEN_FAILURE 31L
#define ERROR_SHARING_VIOLATION 32L
#define ERROR_LOCK_VIOLATION 33L
#define ERROR_WRONG_DISK 34L
#define ERROR_SHARING_BUFFER_EXCEEDED 36L
#define ERROR_HANDLE_EOF 38L
#define ERROR_HANDLE_DISK_FULL 39L
#define ERROR_NOT_SUPPORTED 50L
#define ERROR_REM_NOT_LIST 51L
#define ERROR_DUP_NAME 52L
#define ERROR_BAD_NETPATH 53L
#define ERROR_NETWORK_BUSY 54L
#define ERROR_DEV_NOT_EXIST 55L
#define ERROR_TOO_MANY_CMDS 56L
#define ERROR_ADAP_HDW_ERR 57L
#define ERROR_BAD_NET_RESP 58L
#define ERROR_UNEXP_NET_ERR 59L
#define ERROR_BAD_REM_ADAP 60L
#define ERROR_PRINTQ_FULL 61L
#define ERROR_NO_SPOOL_SPACE 62L
#define ERROR_PRINT_CANCELLED 63L
#define ERROR_NETNAME_DELETED 64L
#define ERROR_NETWORK_ACCESS_DENIED 65L
#define ERROR_BAD_DEV_TYPE 66L
#define ERROR_BAD_NET_NAME 67L
#define ERROR_TOO_MANY_NAMES 68L
#define ERROR_TOO_MANY_SESS 69L
#define ERROR_SHARING_PAUSED 70L
#define ERROR_REQ_NOT_ACCEP 71L
#define ERROR_REDIR_PAUSED 72L
#define ERROR_FILE_EXISTS 80L
#define ERROR_CANNOT_MAKE 82L
#define ERROR_FAIL_I24 83L
#define ERROR_OUT_OF_STRUCTURES 84L
#define ERROR_ALREADY_ASSIGNED 85L
#define ERROR_INVALID_PASSWORD 86L
#define ERROR_INVALID_PARAMETER 87L
#define ERROR_NET_WRITE_FAULT 88L
#define ERROR_NO_PROC_SLOTS 89L
#define ERROR_TOO_MANY_SEMAPHORES 100L
#define ERROR_EXCL_SEM_ALREADY_OWNED 101L
#define ERROR_SEM_IS_SET 102L
#define ERROR_TOO_MANY_SEM_REQUESTS 103L
#define ERROR_INVALID_AT_INTERRUPT_TIME 104L
#define ERROR_SEM_OWNER_DIED 105L
#define ERROR_SEM_USER_LIMIT 106L
#define ERROR_DISK_CHANGE 107L
#define ERROR_DRIVE_LOCKED 108L
#define ERROR_BROKEN_PIPE 109L
#define ERROR_OPEN_FAILED 110L
#define ERROR_BUFFER_OVERFLOW 111L
#define ERROR_DISK_FULL 112L
#define ERROR_NO_MORE_SEARCH_HANDLES 113L
#define ERROR_INVALID_TARGET_HANDLE 114L
#define ERROR_INVALID_CATEGORY 117L
#define ERROR_INVALID_VERIFY_SWITCH 118L
#define ERROR_BAD_DRIVER_LEVEL 119L
#define ERROR_CALL_NOT_IMPLEMENTED 120L
#define ERROR_SEM_TIMEOUT 121L
#define ERROR_INSUFFICIENT_BUFFER 122L
#define ERROR_INVALID_NAME 123L
#define ERROR_INVALID_LEVEL 124L
#define ERROR_NO_VOLUME_LABEL 125L
#define ERROR_MOD_NOT_FOUND 126L
#define ERROR_PROC_NOT_FOUND 127L
#define ERROR_WAIT_NO_CHILDREN 128L
#define ERROR_CHILD_NOT_COMPLETE 129L
#define ERROR_DIRECT_ACCESS_HANDLE 130L
#define ERROR_NEGATIVE_SEEK 131L
#define ERROR_SEEK_ON_DEVICE 132L
#define ERROR_IS_JOIN_TARGET 133L
#define ERROR_IS_JOINED 134L
#define ERROR_IS_SUBSTED 135L
#define ERROR_NOT_JOINED 136L
#define ERROR_NOT_SUBSTED 137L
#define ERROR_JOIN_TO_JOIN 138L
#define ERROR_SUBST_TO_SUBST 139L
#define ERROR_JOIN_TO_SUBST 140L
#define ERROR_SUBST_TO_JOIN 141L
#define ERROR_BUSY_DRIVE 142L
#define ERROR_SAME_DRIVE 143L
#define ERROR_DIR_NOT_ROOT 144L
#define ERROR_DIR_NOT_EMPTY 145L
#define ERROR_IS_SUBST_PATH 146L
#define ERROR_IS_JOIN_PATH 147L
#define ERROR_PATH_BUSY 148L
#define ERROR_IS_SUBST_TARGET 149L
#define ERROR_SYSTEM_TRACE 150L
#define ERROR_INVALID_EVENT_COUNT 151L
#define ERROR_TOO_MANY_MUXWAITERS 152L
#define ERROR_INVALID_LIST_FORMAT 153L
#define ERROR_LABEL_TOO_LONG 154L
#define ERROR_TOO_MANY_TCBS 155L
#define ERROR_SIGNAL_REFUSED 156L
#define ERROR_DISCARDED 157L
#define ERROR_NOT_LOCKED 158L
#define ERROR_BAD_THREADID_ADDR 159L
#define ERROR_BAD_ARGUMENTS 160L
#define ERROR_BAD_PATHNAME 161L
#define ERROR_SIGNAL_PENDING 162L
#define ERROR_MAX_THRDS_REACHED 164L
#define ERROR_LOCK_FAILED 167L
#define ERROR_BUSY 170L
#define ERROR_CANCEL_VIOLATION 173L
#define ERROR_ATOMIC_LOCKS_NOT_SUPPORTED 174L
#define ERROR_INVALID_SEGMENT_NUMBER 180L
#define ERROR_INVALID_ORDINAL 182L
#define ERROR_ALREADY_EXISTS 183L
#define ERROR_INVALID_FLAG_NUMBER 186L
#define ERROR_SEM_NOT_FOUND 187L
#define ERROR_INVALID_STARTING_CODESEG 188L
#define ERROR_INVALID_STACKSEG 189L
#define ERROR_INVALID_MODULETYPE 190L
#define ERROR_INVALID_EXE_SIGNATURE 191L
#define ERROR_EXE_MARKED_INVALID 192L
#define ERROR_BAD_EXE_FORMAT 193L
#define ERROR_ITERATED_DATA_EXCEEDS_64k 194L
#define ERROR_INVALID_MINALLOCSIZE 195L
#define ERROR_DYNLINK_FROM_INVALID_RING 196L
#define ERROR_IOPL_NOT_ENABLED 197L
#define ERROR_INVALID_SEGDPL 198L
#define ERROR_AUTODATASEG_EXCEEDS_64k 199L
#define ERROR_RING2SEG_MUST_BE_MOVABLE 200L
#define ERROR_RELOC_CHAIN_XEEDS_SEGLIM 201L
#define ERROR_INFLOOP_IN_RELOC_CHAIN 202L
#define ERROR_ENVVAR_NOT_FOUND 203L
#define ERROR_NO_SIGNAL_SENT 205L
#define ERROR_FILENAME_EXCED_RANGE 206L
#define ERROR_RING2_STACK_IN_USE 207L
#define ERROR_META_EXPANSION_TOO_LONG 208L
#define ERROR_INVALID_SIGNAL_NUMBER 209L
#define ERROR_THREAD_1_INACTIVE 210L
#define ERROR_LOCKED 212L
#define ERROR_TOO_MANY_MODULES 214L
#define ERROR_NESTING_NOT_ALLOWED 215L
#define ERROR_BAD_PIPE 230L
#define ERROR_PIPE_BUSY 231L
#define ERROR_NO_DATA 232L
#define ERROR_PIPE_NOT_CONNECTED 233L
#define ERROR_MORE_DATA 234L
#define ERROR_VC_DISCONNECTED 240L
#define ERROR_INVALID_EA_NAME 254L
#define ERROR_EA_LIST_INCONSISTENT 255L
#define ERROR_NO_MORE_ITEMS 259L
#define ERROR_CANNOT_COPY 266L
#define ERROR_DIRECTORY 267L
#define ERROR_EAS_DIDNT_FIT 275L
#define ERROR_EA_FILE_CORRUPT 276L
#define ERROR_EA_TABLE_FULL 277L
#define ERROR_INVALID_EA_HANDLE 278L
#define ERROR_EAS_NOT_SUPPORTED 282L
#define ERROR_NOT_OWNER 288L
#define ERROR_TOO_MANY_POSTS 298L
#define ERROR_PARTIAL_COPY 299L
#define ERROR_MR_MID_NOT_FOUND 317L
#define ERROR_INVALID_ADDRESS 487L
#define ERROR_ARITHMETIC_OVERFLOW 534L
#define ERROR_PIPE_CONNECTED 535L
#define ERROR_PIPE_LISTENING 536L
#define ERROR_EA_ACCESS_DENIED 994L
#define ERROR_OPERATION_ABORTED 995L
#define ERROR_IO_INCOMPLETE 996L
#define ERROR_IO_PENDING 997L
#define ERROR_NOACCESS 998L
#define ERROR_SWAPERROR 999L
#define ERROR_STACK_OVERFLOW 1001L
#define ERROR_INVALID_MESSAGE 1002L
#define ERROR_CAN_NOT_COMPLETE 1003L
#define ERROR_INVALID_FLAGS 1004L
#define ERROR_UNRECOGNIZED_VOLUME 1005L
#define ERROR_FILE_INVALID 1006L
#define ERROR_FULLSCREEN_MODE 1007L
#define ERROR_NO_TOKEN 1008L
#define ERROR_BADDB 1009L
#define ERROR_BADKEY 1010L
#define ERROR_CANTOPEN 1011L
#define ERROR_CANTREAD 1012L
#define ERROR_CANTWRITE 1013L
#define ERROR_REGISTRY_RECOVERED 1014L
#define ERROR_REGISTRY_CORRUPT 1015L
#define ERROR_REGISTRY_IO_FAILED 1016L
#define ERROR_NOT_REGISTRY_FILE 1017L
#define ERROR_KEY_DELETED 1018L
#define ERROR_NO_LOG_SPACE 1019L
#define ERROR_KEY_HAS_CHILDREN 1020L
#define ERROR_CHILD_MUST_BE_VOLATILE 1021L
#define ERROR_NOTIFY_ENUM_DIR 1022L
#define ERROR_DEPENDENT_SERVICES_RUNNING 1051L
#define ERROR_INVALID_SERVICE_CONTROL 1052L
#define ERROR_SERVICE_REQUEST_TIMEOUT 1053L
#define ERROR_SERVICE_NO_THREAD 1054L
#define ERROR_SERVICE_DATABASE_LOCKED 1055L
#define ERROR_SERVICE_ALREADY_RUNNING 1056L
#define ERROR_INVALID_SERVICE_ACCOUNT 1057L
#define ERROR_SERVICE_DISABLED 1058L
#define ERROR_CIRCULAR_DEPENDENCY 1059L
#define ERROR_SERVICE_DOES_NOT_EXIST 1060L
#define ERROR_SERVICE_CANNOT_ACCEPT_CTRL 1061L
#define ERROR_SERVICE_NOT_ACTIVE 1062L
#define ERROR_FAILED_SERVICE_CONTROLLER_CONNECT 1063L
#define ERROR_EXCEPTION_IN_SERVICE 1064L
#define ERROR_DATABASE_DOES_NOT_EXIST 1065L
#define ERROR_SERVICE_SPECIFIC_ERROR 1066L
#define ERROR_PROCESS_ABORTED 1067L
#define ERROR_SERVICE_DEPENDENCY_FAIL 1068L
#define ERROR_SERVICE_LOGON_FAILED 1069L
#define ERROR_SERVICE_START_HANG 1070L
#define ERROR_INVALID_SERVICE_LOCK 1071L
#define ERROR_SERVICE_MARKED_FOR_DELETE 1072L
#define ERROR_SERVICE_EXISTS 1073L
#define ERROR_ALREADY_RUNNING_LKG 1074L
#define ERROR_SERVICE_DEPENDENCY_DELETED 1075L
#define ERROR_BOOT_ALREADY_ACCEPTED 1076L
#define ERROR_SERVICE_NEVER_STARTED 1077L
#define ERROR_DUPLICATE_SERVICE_NAME 1078L
#define ERROR_END_OF_MEDIA 1100L
#define ERROR_FILEMARK_DETECTED 1101L
#define ERROR_BEGINNING_OF_MEDIA 1102L
#define ERROR_SETMARK_DETECTED 1103L
#define ERROR_NO_DATA_DETECTED 1104L
#define ERROR_PARTITION_FAILURE 1105L
#define ERROR_INVALID_BLOCK_LENGTH 1106L
#define ERROR_DEVICE_NOT_PARTITIONED 1107L
#define ERROR_UNABLE_TO_LOCK_MEDIA 1108L
#define ERROR_UNABLE_TO_UNLOAD_MEDIA 1109L
#define ERROR_MEDIA_CHANGED 1110L
#define ERROR_BUS_RESET 1111L
#define ERROR_NO_MEDIA_IN_DRIVE 1112L
#define ERROR_NO_UNICODE_TRANSLATION 1113L
#define ERROR_DLL_INIT_FAILED 1114L
#define ERROR_SHUTDOWN_IN_PROGRESS 1115L
#define ERROR_NO_SHUTDOWN_IN_PROGRESS 1116L
#define ERROR_IO_DEVICE 1117L
#define ERROR_SERIAL_NO_DEVICE 1118L
#define ERROR_IRQ_BUSY 1119L
#define ERROR_MORE_WRITES 1120L
#define ERROR_COUNTER_TIMEOUT 1121L
#define ERROR_FLOPPY_ID_MARK_NOT_FOUND 1122L
#define ERROR_FLOPPY_WRONG_CYLINDER 1123L
#define ERROR_FLOPPY_UNKNOWN_ERROR 1124L
#define ERROR_FLOPPY_BAD_REGISTERS 1125L
#define ERROR_DISK_RECALIBRATE_FAILED 1126L
#define ERROR_DISK_OPERATION_FAILED 1127L
#define ERROR_DISK_RESET_FAILED 1128L
#define ERROR_EOM_OVERFLOW 1129L
#define ERROR_NOT_ENOUGH_SERVER_MEMORY 1130L
#define ERROR_POSSIBLE_DEADLOCK 1131L
#define ERROR_MAPPED_ALIGNMENT 1132L
#define ERROR_SET_POWER_STATE_VETOED 1140L
#define ERROR_SET_POWER_STATE_FAILED 1141L
#define ERROR_OLD_WIN_VERSION 1150L
#define ERROR_APP_WRONG_OS 1151L
#define ERROR_SINGLE_INSTANCE_APP 1152L
#define ERROR_RMODE_APP 1153L
#define ERROR_INVALID_DLL 1154L
#define ERROR_NO_ASSOCIATION 1155L
#define ERROR_DDE_FAIL 1156L
#define ERROR_DLL_NOT_FOUND 1157L
#define ERROR_BAD_USERNAME 2202L
#define ERROR_NOT_CONNECTED 2250L
#define ERROR_OPEN_FILES 2401L
#define ERROR_ACTIVE_CONNECTIONS 2402L
#define ERROR_DEVICE_IN_USE 2404L
#define ERROR_BAD_DEVICE 1200L
#define ERROR_CONNECTION_UNAVAIL 1201L
#define ERROR_DEVICE_ALREADY_REMEMBERED 1202L
#define ERROR_NO_NET_OR_BAD_PATH 1203L
#define ERROR_BAD_PROVIDER 1204L
#define ERROR_CANNOT_OPEN_PROFILE 1205L
#define ERROR_BAD_PROFILE 1206L
#define ERROR_NOT_CONTAINER 1207L
#define ERROR_EXTENDED_ERROR 1208L
#define ERROR_INVALID_GROUPNAME 1209L
#define ERROR_INVALID_COMPUTERNAME 1210L
#define ERROR_INVALID_EVENTNAME 1211L
#define ERROR_INVALID_DOMAINNAME 1212L
#define ERROR_INVALID_SERVICENAME 1213L
#define ERROR_INVALID_NETNAME 1214L
#define ERROR_INVALID_SHARENAME 1215L
#define ERROR_INVALID_PASSWORDNAME 1216L
#define ERROR_INVALID_MESSAGENAME 1217L
#define ERROR_INVALID_MESSAGEDEST 1218L
#define ERROR_SESSION_CREDENTIAL_CONFLICT 1219L
#define ERROR_REMOTE_SESSION_LIMIT_EXCEEDED 1220L
#define ERROR_DUP_DOMAINNAME 1221L
#define ERROR_NO_NETWORK 1222L
#define ERROR_CANCELLED 1223L
#define ERROR_USER_MAPPED_FILE 1224L
#define ERROR_CONNECTION_REFUSED 1225L
#define ERROR_GRACEFUL_DISCONNECT 1226L
#define ERROR_ADDRESS_ALREADY_ASSOCIATED 1227L
#define ERROR_ADDRESS_NOT_ASSOCIATED 1228L
#define ERROR_CONNECTION_INVALID 1229L
#define ERROR_CONNECTION_ACTIVE 1230L
#define ERROR_NETWORK_UNREACHABLE 1231L
#define ERROR_HOST_UNREACHABLE 1232L
#define ERROR_PROTOCOL_UNREACHABLE 1233L
#define ERROR_PORT_UNREACHABLE 1234L
#define ERROR_REQUEST_ABORTED 1235L
#define ERROR_CONNECTION_ABORTED 1236L
#define ERROR_RETRY 1237L
#define ERROR_CONNECTION_COUNT_LIMIT 1238L
#define ERROR_LOGIN_TIME_RESTRICTION 1239L
#define ERROR_LOGIN_WKSTA_RESTRICTION 1240L
#define ERROR_INCORRECT_ADDRESS 1241L
#define ERROR_ALREADY_REGISTERED 1242L
#define ERROR_SERVICE_NOT_FOUND 1243L
#define ERROR_NOT_AUTHENTICATED 1244L
#define ERROR_NOT_LOGGED_ON 1245L
#define ERROR_CONTINUE 1246L
#define ERROR_ALREADY_INITIALIZED 1247L
#define ERROR_NO_MORE_DEVICES 1248L
#define ERROR_NOT_ALL_ASSIGNED 1300L
#define ERROR_SOME_NOT_MAPPED 1301L
#define ERROR_NO_QUOTAS_FOR_ACCOUNT 1302L
#define ERROR_LOCAL_USER_SESSION_KEY 1303L
#define ERROR_NULL_LM_PASSWORD 1304L
#define ERROR_UNKNOWN_REVISION 1305L
#define ERROR_REVISION_MISMATCH 1306L
#define ERROR_INVALID_OWNER 1307L
#define ERROR_INVALID_PRIMARY_GROUP 1308L
#define ERROR_NO_IMPERSONATION_TOKEN 1309L
#define ERROR_CANT_DISABLE_MANDATORY 1310L
#define ERROR_NO_LOGON_SERVERS 1311L
#define ERROR_NO_SUCH_LOGON_SESSION 1312L
#define ERROR_NO_SUCH_PRIVILEGE 1313L
#define ERROR_PRIVILEGE_NOT_HELD 1314L
#define ERROR_INVALID_ACCOUNT_NAME 1315L
#define ERROR_USER_EXISTS 1316L
#define ERROR_NO_SUCH_USER 1317L
#define ERROR_GROUP_EXISTS 1318L
#define ERROR_NO_SUCH_GROUP 1319L
#define ERROR_MEMBER_IN_GROUP 1320L
#define ERROR_MEMBER_NOT_IN_GROUP 1321L
#define ERROR_LAST_ADMIN 1322L
#define ERROR_WRONG_PASSWORD 1323L
#define ERROR_ILL_FORMED_PASSWORD 1324L
#define ERROR_PASSWORD_RESTRICTION 1325L
#define ERROR_LOGON_FAILURE 1326L
#define ERROR_ACCOUNT_RESTRICTION 1327L
#define ERROR_INVALID_LOGON_HOURS 1328L
#define ERROR_INVALID_WORKSTATION 1329L
#define ERROR_PASSWORD_EXPIRED 1330L
#define ERROR_ACCOUNT_DISABLED 1331L
#define ERROR_NONE_MAPPED 1332L
#define ERROR_TOO_MANY_LUIDS_REQUESTED 1333L
#define ERROR_LUIDS_EXHAUSTED 1334L
#define ERROR_INVALID_SUB_AUTHORITY 1335L
#define ERROR_INVALID_ACL 1336L
#define ERROR_INVALID_SID 1337L
#define ERROR_INVALID_SECURITY_DESCR 1338L
#define ERROR_BAD_INHERITANCE_ACL 1340L
#define ERROR_SERVER_DISABLED 1341L
#define ERROR_SERVER_NOT_DISABLED 1342L
#define ERROR_INVALID_ID_AUTHORITY 1343L
#define ERROR_ALLOTTED_SPACE_EXCEEDED 1344L
#define ERROR_INVALID_GROUP_ATTRIBUTES 1345L
#define ERROR_BAD_IMPERSONATION_LEVEL 1346L
#define ERROR_CANT_OPEN_ANONYMOUS 1347L
#define ERROR_BAD_VALIDATION_CLASS 1348L
#define ERROR_BAD_TOKEN_TYPE 1349L
#define ERROR_NO_SECURITY_ON_OBJECT 1350L
#define ERROR_CANT_ACCESS_DOMAIN_INFO 1351L
#define ERROR_INVALID_SERVER_STATE 1352L
#define ERROR_INVALID_DOMAIN_STATE 1353L
#define ERROR_INVALID_DOMAIN_ROLE 1354L
#define ERROR_NO_SUCH_DOMAIN 1355L
#define ERROR_DOMAIN_EXISTS 1356L
#define ERROR_DOMAIN_LIMIT_EXCEEDED 1357L
#define ERROR_INTERNAL_DB_CORRUPTION 1358L
#define ERROR_INTERNAL_ERROR 1359L
#define ERROR_GENERIC_NOT_MAPPED 1360L
#define ERROR_BAD_DESCRIPTOR_FORMAT 1361L
#define ERROR_NOT_LOGON_PROCESS 1362L
#define ERROR_LOGON_SESSION_EXISTS 1363L
#define ERROR_NO_SUCH_PACKAGE 1364L
#define ERROR_BAD_LOGON_SESSION_STATE 1365L
#define ERROR_LOGON_SESSION_COLLISION 1366L
#define ERROR_INVALID_LOGON_TYPE 1367L
#define ERROR_CANNOT_IMPERSONATE 1368L
#define ERROR_RXACT_INVALID_STATE 1369L
#define ERROR_RXACT_COMMIT_FAILURE 1370L
#define ERROR_SPECIAL_ACCOUNT 1371L
#define ERROR_SPECIAL_GROUP 1372L
#define ERROR_SPECIAL_USER 1373L
#define ERROR_MEMBERS_PRIMARY_GROUP 1374L
#define ERROR_TOKEN_ALREADY_IN_USE 1375L
#define ERROR_NO_SUCH_ALIAS 1376L
#define ERROR_MEMBER_NOT_IN_ALIAS 1377L
#define ERROR_MEMBER_IN_ALIAS 1378L
#define ERROR_ALIAS_EXISTS 1379L
#define ERROR_LOGON_NOT_GRANTED 1380L
#define ERROR_TOO_MANY_SECRETS 1381L
#define ERROR_SECRET_TOO_LONG 1382L
#define ERROR_INTERNAL_DB_ERROR 1383L
#define ERROR_TOO_MANY_CONTEXT_IDS 1384L
#define ERROR_LOGON_TYPE_NOT_GRANTED 1385L
#define ERROR_NT_CROSS_ENCRYPTION_REQUIRED 1386L
#define ERROR_NO_SUCH_MEMBER 1387L
#define ERROR_INVALID_MEMBER 1388L
#define ERROR_TOO_MANY_SIDS 1389L
#define ERROR_LM_CROSS_ENCRYPTION_REQUIRED 1390L
#define ERROR_NO_INHERITANCE 1391L
#define ERROR_FILE_CORRUPT 1392L
#define ERROR_DISK_CORRUPT 1393L
#define ERROR_NO_USER_SESSION_KEY 1394L
#define ERROR_LICENSE_QUOTA_EXCEEDED 1395L
#define ERROR_INVALID_WINDOW_HANDLE 1400L
#define ERROR_INVALID_MENU_HANDLE 1401L
#define ERROR_INVALID_CURSOR_HANDLE 1402L
#define ERROR_INVALID_ACCEL_HANDLE 1403L
#define ERROR_INVALID_HOOK_HANDLE 1404L
#define ERROR_INVALID_DWP_HANDLE 1405L
#define ERROR_TLW_WITH_WSCHILD 1406L
#define ERROR_CANNOT_FIND_WND_CLASS 1407L
#define ERROR_WINDOW_OF_OTHER_THREAD 1408L
#define ERROR_HOTKEY_ALREADY_REGISTERED 1409L
#define ERROR_CLASS_ALREADY_EXISTS 1410L
#define ERROR_CLASS_DOES_NOT_EXIST 1411L
#define ERROR_CLASS_HAS_WINDOWS 1412L
#define ERROR_INVALID_INDEX 1413L
#define ERROR_INVALID_ICON_HANDLE 1414L
#define ERROR_PRIVATE_DIALOG_INDEX 1415L
#define ERROR_LISTBOX_ID_NOT_FOUND 1416L
#define ERROR_NO_WILDCARD_CHARACTERS 1417L
#define ERROR_CLIPBOARD_NOT_OPEN 1418L
#define ERROR_HOTKEY_NOT_REGISTERED 1419L
#define ERROR_WINDOW_NOT_DIALOG 1420L
#define ERROR_CONTROL_ID_NOT_FOUND 1421L
#define ERROR_INVALID_COMBOBOX_MESSAGE 1422L
#define ERROR_WINDOW_NOT_COMBOBOX 1423L
#define ERROR_INVALID_EDIT_HEIGHT 1424L
#define ERROR_DC_NOT_FOUND 1425L
#define ERROR_INVALID_HOOK_FILTER 1426L
#define ERROR_INVALID_FILTER_PROC 1427L
#define ERROR_HOOK_NEEDS_HMOD 1428L
#define ERROR_GLOBAL_ONLY_HOOK 1429L
#define ERROR_JOURNAL_HOOK_SET 1430L
#define ERROR_HOOK_NOT_INSTALLED 1431L
#define ERROR_INVALID_LB_MESSAGE 1432L
#define ERROR_SETCOUNT_ON_BAD_LB 1433L
#define ERROR_LB_WITHOUT_TABSTOPS 1434L
#define ERROR_DESTROY_OBJECT_OF_OTHER_THREAD 1435L
#define ERROR_CHILD_WINDOW_MENU 1436L
#define ERROR_NO_SYSTEM_MENU 1437L
#define ERROR_INVALID_MSGBOX_STYLE 1438L
#define ERROR_INVALID_SPI_VALUE 1439L
#define ERROR_SCREEN_ALREADY_LOCKED 1440L
#define ERROR_HWNDS_HAVE_DIFF_PARENT 1441L
#define ERROR_NOT_CHILD_WINDOW 1442L
#define ERROR_INVALID_GW_COMMAND 1443L
#define ERROR_INVALID_THREAD_ID 1444L
#define ERROR_NON_MDICHILD_WINDOW 1445L
#define ERROR_POPUP_ALREADY_ACTIVE 1446L
#define ERROR_NO_SCROLLBARS 1447L
#define ERROR_INVALID_SCROLLBAR_RANGE 1448L
#define ERROR_INVALID_SHOWWIN_COMMAND 1449L
#define ERROR_NO_SYSTEM_RESOURCES 1450L
#define ERROR_NONPAGED_SYSTEM_RESOURCES 1451L
#define ERROR_PAGED_SYSTEM_RESOURCES 1452L
#define ERROR_WORKING_SET_QUOTA 1453L
#define ERROR_PAGEFILE_QUOTA 1454L
#define ERROR_COMMITMENT_LIMIT 1455L
#define ERROR_MENU_ITEM_NOT_FOUND 1456L
#define ERROR_EVENTLOG_FILE_CORRUPT 1500L
#define ERROR_EVENTLOG_CANT_START 1501L
#define ERROR_LOG_FILE_FULL 1502L
#define ERROR_EVENTLOG_FILE_CHANGED 1503L
#define RPC_S_INVALID_STRING_BINDING 1700L
#define RPC_S_WRONG_KIND_OF_BINDING 1701L
#define RPC_S_INVALID_BINDING 1702L
#define RPC_S_PROTSEQ_NOT_SUPPORTED 1703L
#define RPC_S_INVALID_RPC_PROTSEQ 1704L
#define RPC_S_INVALID_STRING_UUID 1705L
#define RPC_S_INVALID_ENDPOINT_FORMAT 1706L
#define RPC_S_INVALID_NET_ADDR 1707L
#define RPC_S_NO_ENDPOINT_FOUND 1708L
#define RPC_S_INVALID_TIMEOUT 1709L
#define RPC_S_OBJECT_NOT_FOUND 1710L
#define RPC_S_ALREADY_REGISTERED 1711L
#define RPC_S_TYPE_ALREADY_REGISTERED 1712L
#define RPC_S_ALREADY_LISTENING 1713L
#define RPC_S_NO_PROTSEQS_REGISTERED 1714L
#define RPC_S_NOT_LISTENING 1715L
#define RPC_S_UNKNOWN_MGR_TYPE 1716L
#define RPC_S_UNKNOWN_IF 1717L
#define RPC_S_NO_BINDINGS 1718L
#define RPC_S_NO_PROTSEQS 1719L
#define RPC_S_CANT_CREATE_ENDPOINT 1720L
#define RPC_S_OUT_OF_RESOURCES 1721L
#define RPC_S_SERVER_UNAVAILABLE 1722L
#define RPC_S_SERVER_TOO_BUSY 1723L
#define RPC_S_INVALID_NETWORK_OPTIONS 1724L
#define RPC_S_NO_CALL_ACTIVE 1725L
#define RPC_S_CALL_FAILED 1726L
#define RPC_S_CALL_FAILED_DNE 1727L
#define RPC_S_PROTOCOL_ERROR 1728L
#define RPC_S_UNSUPPORTED_TRANS_SYN 1730L
#define RPC_S_UNSUPPORTED_TYPE 1732L
#define RPC_S_INVALID_TAG 1733L
#define RPC_S_INVALID_BOUND 1734L
#define RPC_S_NO_ENTRY_NAME 1735L
#define RPC_S_INVALID_NAME_SYNTAX 1736L
#define RPC_S_UNSUPPORTED_NAME_SYNTAX 1737L
#define RPC_S_UUID_NO_ADDRESS 1739L
#define RPC_S_DUPLICATE_ENDPOINT 1740L
#define RPC_S_UNKNOWN_AUTHN_TYPE 1741L
#define RPC_S_MAX_CALLS_TOO_SMALL 1742L
#define RPC_S_STRING_TOO_LONG 1743L
#define RPC_S_PROTSEQ_NOT_FOUND 1744L
#define RPC_S_PROCNUM_OUT_OF_RANGE 1745L
#define RPC_S_BINDING_HAS_NO_AUTH 1746L
#define RPC_S_UNKNOWN_AUTHN_SERVICE 1747L
#define RPC_S_UNKNOWN_AUTHN_LEVEL 1748L
#define RPC_S_INVALID_AUTH_IDENTITY 1749L
#define RPC_S_UNKNOWN_AUTHZ_SERVICE 1750L
#define EPT_S_INVALID_ENTRY 1751L
#define EPT_S_CANT_PERFORM_OP 1752L
#define EPT_S_NOT_REGISTERED 1753L
#define RPC_S_NOTHING_TO_EXPORT 1754L
#define RPC_S_INCOMPLETE_NAME 1755L
#define RPC_S_INVALID_VERS_OPTION 1756L
#define RPC_S_NO_MORE_MEMBERS 1757L
#define RPC_S_NOT_ALL_OBJS_UNEXPORTED 1758L
#define RPC_S_INTERFACE_NOT_FOUND 1759L
#define RPC_S_ENTRY_ALREADY_EXISTS 1760L
#define RPC_S_ENTRY_NOT_FOUND 1761L
#define RPC_S_NAME_SERVICE_UNAVAILABLE 1762L
#define RPC_S_INVALID_NAF_ID 1763L
#define RPC_S_CANNOT_SUPPORT 1764L
#define RPC_S_NO_CONTEXT_AVAILABLE 1765L
#define RPC_S_INTERNAL_ERROR 1766L
#define RPC_S_ZERO_DIVIDE 1767L
#define RPC_S_ADDRESS_ERROR 1768L
#define RPC_S_FP_DIV_ZERO 1769L
#define RPC_S_FP_UNDERFLOW 1770L
#define RPC_S_FP_OVERFLOW 1771L
#define RPC_X_NO_MORE_ENTRIES 1772L
#define RPC_X_SS_CHAR_TRANS_OPEN_FAIL 1773L
#define RPC_X_SS_CHAR_TRANS_SHORT_FILE 1774L
#define RPC_X_SS_IN_NULL_CONTEXT 1775L
#define RPC_X_SS_CONTEXT_DAMAGED 1777L
#define RPC_X_SS_HANDLES_MISMATCH 1778L
#define RPC_X_SS_CANNOT_GET_CALL_HANDLE 1779L
#define RPC_X_NULL_REF_POINTER 1780L
#define RPC_X_ENUM_VALUE_OUT_OF_RANGE 1781L
#define RPC_X_BYTE_COUNT_TOO_SMALL 1782L
#define RPC_X_BAD_STUB_DATA 1783L
#define ERROR_INVALID_USER_BUFFER 1784L
#define ERROR_UNRECOGNIZED_MEDIA 1785L
#define ERROR_NO_TRUST_LSA_SECRET 1786L
#define ERROR_NO_TRUST_SAM_ACCOUNT 1787L
#define ERROR_TRUSTED_DOMAIN_FAILURE 1788L
#define ERROR_TRUSTED_RELATIONSHIP_FAILURE 1789L
#define ERROR_TRUST_FAILURE 1790L
#define RPC_S_CALL_IN_PROGRESS 1791L
#define ERROR_NETLOGON_NOT_STARTED 1792L
#define ERROR_ACCOUNT_EXPIRED 1793L
#define ERROR_REDIRECTOR_HAS_OPEN_HANDLES 1794L
#define ERROR_PRINTER_DRIVER_ALREADY_INSTALLED 1795L
#define ERROR_UNKNOWN_PORT 1796L
#define ERROR_UNKNOWN_PRINTER_DRIVER 1797L
#define ERROR_UNKNOWN_PRINTPROCESSOR 1798L
#define ERROR_INVALID_SEPARATOR_FILE 1799L
#define ERROR_INVALID_PRIORITY 1800L
#define ERROR_INVALID_PRINTER_NAME 1801L
#define ERROR_PRINTER_ALREADY_EXISTS 1802L
#define ERROR_INVALID_PRINTER_COMMAND 1803L
#define ERROR_INVALID_DATATYPE 1804L
#define ERROR_INVALID_ENVIRONMENT 1805L
#define RPC_S_NO_MORE_BINDINGS 1806L
#define ERROR_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT 1807L
#define ERROR_NOLOGON_WORKSTATION_TRUST_ACCOUNT 1808L
#define ERROR_NOLOGON_SERVER_TRUST_ACCOUNT 1809L
#define ERROR_DOMAIN_TRUST_INCONSISTENT 1810L
#define ERROR_SERVER_HAS_OPEN_HANDLES 1811L
#define ERROR_RESOURCE_DATA_NOT_FOUND 1812L
#define ERROR_RESOURCE_TYPE_NOT_FOUND 1813L
#define ERROR_RESOURCE_NAME_NOT_FOUND 1814L
#define ERROR_RESOURCE_LANG_NOT_FOUND 1815L
#define ERROR_NOT_ENOUGH_QUOTA 1816L
#define RPC_S_NO_INTERFACES 1817L
#define RPC_S_CALL_CANCELLED 1818L
#define RPC_S_BINDING_INCOMPLETE 1819L
#define RPC_S_COMM_FAILURE 1820L
#define RPC_S_UNSUPPORTED_AUTHN_LEVEL 1821L
#define RPC_S_NO_PRINC_NAME 1822L
#define RPC_S_NOT_RPC_ERROR 1823L
#define RPC_S_UUID_LOCAL_ONLY 1824L
#define RPC_S_SEC_PKG_ERROR 1825L
#define RPC_S_NOT_CANCELLED 1826L
#define RPC_X_INVALID_ES_ACTION 1827L
#define RPC_X_WRONG_ES_VERSION 1828L
#define RPC_X_WRONG_STUB_VERSION 1829L
#define RPC_S_GROUP_MEMBER_NOT_FOUND 1898L
#define EPT_S_CANT_CREATE 1899L
#define RPC_S_INVALID_OBJECT 1900L
#define ERROR_INVALID_TIME 1901L
#define ERROR_INVALID_FORM_NAME 1902L
#define ERROR_INVALID_FORM_SIZE 1903L
#define ERROR_ALREADY_WAITING 1904L
#define ERROR_PRINTER_DELETED 1905L
#define ERROR_INVALID_PRINTER_STATE 1906L
#define ERROR_PASSWORD_MUST_CHANGE 1907L
#define ERROR_DOMAIN_CONTROLLER_NOT_FOUND 1908L
#define ERROR_ACCOUNT_LOCKED_OUT 1909L
#define ERROR_NO_BROWSER_SERVERS_FOUND 6118L
#define ERROR_INVALID_PIXEL_FORMAT 2000L
#define ERROR_BAD_DRIVER 2001L
#define ERROR_INVALID_WINDOW_STYLE 2002L
#define ERROR_METAFILE_NOT_SUPPORTED 2003L
#define ERROR_TRANSFORM_NOT_SUPPORTED 2004L
#define ERROR_CLIPPING_NOT_SUPPORTED 2005L
#define ERROR_UNKNOWN_PRINT_MONITOR 3000L
#define ERROR_PRINTER_DRIVER_IN_USE 3001L
#define ERROR_SPOOL_FILE_NOT_FOUND 3002L
#define ERROR_SPL_NO_STARTDOC 3003L
#define ERROR_SPL_NO_ADDJOB 3004L
#define ERROR_PRINT_PROCESSOR_ALREADY_INSTALLED 3005L
#define ERROR_PRINT_MONITOR_ALREADY_INSTALLED 3006L
#define ERROR_WINS_INTERNAL 4000L
#define ERROR_CAN_NOT_DEL_LOCAL_WINS 4001L
#define ERROR_STATIC_INIT 4002L
#define ERROR_INC_BACKUP 4003L
#define ERROR_FULL_BACKUP 4004L
#define ERROR_REC_NON_EXISTENT 4005L
#define ERROR_RPL_NOT_ALLOWED 4006L
#define ERROR_NO_BROWSER_SERVERS_FOUND 6118L
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* _GNU_H_WINDOWS32_ERROR */

7484
reactos/include/funcs.h Normal file

File diff suppressed because it is too large Load Diff

491
reactos/include/in.h Normal file
View File

@@ -0,0 +1,491 @@
unsigned int wavelength=3891;
unsigned char wave[]={
0x52,0x49,0x46,0x46,0x2b,0xf,0x0,0x0,
0x57,0x41,0x56,0x45,0x66,0x6d,0x74,0x20,
0x10,0x0,0x0,0x0,0x1,0x0,0x1,0x0,
0x22,0x56,0x0,0x0,0x22,0x56,0x0,0x0,
0x1,0x0,0x8,0x0,0x64,0x61,0x74,0x61,
0x7,0xf,0x0,0x0,0x80,0xce,0xb2,0x53,
0x2e,0x75,0xca,0xbb,0x5d,0x2c,0x6a,0xc4,
0xc2,0x68,0x2c,0x5f,0xbd,0xc8,0x74,0x2e,
0x51,0xad,0xd0,0x8a,0x36,0x3f,0x98,0xd2,
0xa2,0x46,0x33,0x81,0xcd,0xb5,0x58,0x2d,
0x67,0xbe,0xc8,0x78,0x30,0x49,0xa3,0xd2,
0x9b,0x43,0x34,0x80,0xcc,0xb9,0x60,0x2c,
0x5e,0xb6,0xce,0x89,0x39,0x3b,0x8b,0xce,
0xb4,0x5c,0x2d,0x5e,0xb6,0xce,0x89,0x39,
0x3a,0x8b,0xce,0xb7,0x62,0x2d,0x54,0xaa,
0xd1,0x9b,0x46,0x31,0x74,0xc2,0xc7,0x7b,
0x34,0x41,0x94,0xcf,0xb3,0x61,0x2e,0x53,
0xa6,0xd1,0xa3,0x4f,0x2e,0x65,0xb7,0xce,
0x90,0x41,0x33,0x78,0xc3,0xc8,0x83,0x3a,
0x38,0x80,0xc6,0xc4,0x7d,0x36,0x3c,0x86,
0xc9,0xc0,0x76,0x34,0x40,0x8d,0xcb,0xbe,
0x74,0x34,0x3e,0x87,0xc9,0xc1,0x78,0x36,
0x3b,0x83,0xc7,0xc4,0x7e,0x39,0x39,0x7d,
0xc2,0xc9,0x8a,0x42,0x32,0x6a,0xb6,0xce,
0x9c,0x4f,0x2e,0x5b,0xa8,0xd0,0xab,0x5d,
0x2f,0x49,0x94,0xcb,0xbe,0x78,0x39,0x38,
0x77,0xbd,0xcc,0x95,0x4a,0x2f,0x5c,0xa7,
0xcf,0xb0,0x68,0x33,0x40,0x83,0xc3,0xc9,
0x8e,0x47,0x30,0x5c,0xa6,0xcf,0xb2,0x6b,
0x34,0x3e,0x7e,0xbf,0xcc,0x99,0x51,0x2f,
0x4f,0x96,0xcb,0xc1,0x81,0x40,0x32,0x64,
0xab,0xcf,0xb0,0x6c,0x36,0x39,0x74,0xb7,
0xce,0xa7,0x61,0x32,0x40,0x80,0xbe,0xcc,
0x9d,0x56,0x30,0x48,0x88,0xc3,0xca,0x99,
0x54,0x30,0x47,0x88,0xc2,0xca,0x98,0x55,
0x30,0x47,0x87,0xc1,0xca,0x9a,0x58,0x31,
0x42,0x80,0xbb,0xcd,0xa5,0x63,0x34,0x3b,
0x73,0xb3,0xce,0xb1,0x6f,0x39,0x36,0x66,
0xa6,0xcc,0xbe,0x84,0x47,0x30,0x50,0x8f,
0xc4,0xc9,0x9b,0x5c,0x33,0x3f,0x77,0xb4,
0xce,0xb2,0x77,0x40,0x32,0x57,0x96,0xc6,
0xc7,0x99,0x5a,0x33,0x3e,0x73,0xb0,0xcd,
0xb7,0x7e,0x45,0x31,0x4e,0x88,0xbe,0xcc,
0xa9,0x6c,0x3b,0x34,0x5d,0x99,0xc7,0xc7,
0x99,0x5d,0x35,0x3a,0x69,0xa3,0xca,0xc3,
0x93,0x58,0x33,0x3c,0x6e,0xa8,0xcb,0xc0,
0x8f,0x54,0x33,0x3f,0x6f,0xa8,0xcb,0xc1,
0x91,0x58,0x34,0x3b,0x69,0xa3,0xc9,0xc5,
0x98,0x5f,0x37,0x38,0x61,0x99,0xc4,0xc9,
0xa5,0x6d,0x3e,0x33,0x52,0x88,0xba,0xcc,
0xb3,0x80,0x4b,0x32,0x44,0x76,0xac,0xca,
0xc2,0x96,0x5f,0x38,0x36,0x5b,0x91,0xbf,
0xcb,0xaf,0x7b,0x49,0x32,0x44,0x75,0xa9,
0xc9,0xc4,0x9d,0x68,0x3d,0x34,0x50,0x83,
0xb5,0xcb,0xbc,0x8f,0x59,0x37,0x38,0x5d,
0x91,0xbd,0xcb,0xb6,0x85,0x53,0x35,0x3a,
0x60,0x94,0xbe,0xcb,0xb3,0x83,0x51,0x34,
0x3c,0x62,0x95,0xbe,0xcb,0xb6,0x87,0x56,
0x37,0x39,0x5a,0x8c,0xb9,0xcb,0xbb,0x90,
0x5d,0x3a,0x35,0x52,0x80,0xb0,0xc9,0xc3,
0x9f,0x6e,0x44,0x33,0x43,0x6d,0x9f,0xc2,
0xc9,0xaf,0x81,0x53,0x37,0x39,0x57,0x85,
0xb2,0xc9,0xc2,0x9f,0x6e,0x45,0x34,0x41,
0x68,0x98,0xbe,0xca,0xb8,0x8e,0x61,0x3d,
0x34,0x49,0x72,0xa1,0xc2,0xc9,0xb2,0x88,
0x5a,0x3b,0x36,0x4e,0x7a,0xa6,0xc4,0xc8,
0xb0,0x85,0x59,0x3b,0x36,0x4d,0x76,0xa3,
0xc3,0xc9,0xb3,0x89,0x5d,0x3d,0x35,0x49,
0x70,0x9c,0xbe,0xc9,0xba,0x96,0x6a,0x44,
0x35,0x40,0x61,0x8d,0xb4,0xc8,0xc2,0xa4,
0x7a,0x51,0x38,0x38,0x4f,0x78,0xa2,0xc0,
0xc9,0xb8,0x93,0x68,0x45,0x35,0x3f,0x5f,
0x89,0xaf,0xc6,0xc6,0xad,0x86,0x5e,0x3f,
0x35,0x43,0x66,0x8f,0xb4,0xc7,0xc3,0xa9,
0x81,0x58,0x3d,0x36,0x46,0x67,0x8f,0xb4,
0xc7,0xc4,0xab,0x85,0x5d,0x3f,0x36,0x43,
0x63,0x8a,0xb0,0xc5,0xc6,0xb1,0x8e,0x66,
0x46,0x36,0x3c,0x56,0x7d,0xa2,0xbf,0xc8,
0xbc,0x9c,0x77,0x51,0x3a,0x37,0x48,0x69,
0x8f,0xb2,0xc5,0xc5,0xb2,0x8f,0x69,0x48,
0x37,0x3b,0x51,0x75,0x9b,0xba,0xc7,0xc1,
0xaa,0x86,0x62,0x44,0x37,0x3d,0x55,0x79,
0x9d,0xba,0xc7,0xc1,0xa8,0x85,0x61,0x44,
0x37,0x3c,0x54,0x75,0x99,0xb7,0xc6,0xc3,
0xae,0x8e,0x69,0x4a,0x39,0x3a,0x4c,0x6b,
0x8f,0xaf,0xc3,0xc6,0xb8,0x9c,0x79,0x57,
0x3f,0x37,0x41,0x59,0x7c,0x9e,0xb9,0xc6,
0xc2,0xad,0x8e,0x6c,0x4d,0x3b,0x38,0x46,
0x61,0x82,0xa4,0xbc,0xc7,0xc0,0xaa,0x8a,
0x68,0x4b,0x3a,0x39,0x48,0x62,0x84,0xa4,
0xbc,0xc6,0xc1,0xad,0x8d,0x6d,0x4f,0x3c,
0x38,0x44,0x5d,0x7d,0x9d,0xb6,0xc5,0xc4,
0xb5,0x99,0x79,0x5b,0x43,0x38,0x3d,0x50,
0x6c,0x8c,0xab,0xbf,0xc6,0xbf,0xaa,0x8d,
0x6e,0x52,0x3e,0x38,0x41,0x56,0x73,0x92,
0xae,0xc1,0xc6,0xbc,0xa5,0x87,0x6a,0x4f,
0x3d,0x39,0x41,0x57,0x73,0x92,0xad,0xbf,
0xc5,0xbe,0xa9,0x8d,0x70,0x53,0x40,0x39,
0x3f,0x50,0x6b,0x88,0xa5,0xba,0xc5,0xc2,
0xb3,0x9a,0x7e,0x61,0x49,0x3b,0x3a,0x46,
0x5b,0x78,0x94,0xae,0xbf,0xc5,0xbe,0xad,
0x93,0x77,0x5b,0x46,0x3b,0x3b,0x47,0x5b,
0x77,0x92,0xac,0xbe,0xc5,0xc0,0xb1,0x9a,
0x7e,0x63,0x4c,0x3e,0x3a,0x41,0x52,0x6a,
0x85,0x9f,0xb4,0xc1,0xc4,0xbc,0xab,0x93,
0x79,0x5f,0x4a,0x3d,0x3a,0x42,0x53,0x6a,
0x82,0x9c,0xb1,0xc0,0xc4,0xbf,0xb0,0x9a,
0x80,0x68,0x51,0x42,0x3a,0x3d,0x48,0x5c,
0x73,0x8d,0xa4,0xb7,0xc2,0xc3,0xbc,0xac,
0x96,0x7e,0x67,0x51,0x42,0x3b,0x3d,0x48,
0x5a,0x70,0x88,0x9f,0xb2,0xbf,0xc3,0xbf,
0xb3,0xa1,0x89,0x72,0x5c,0x4a,0x3e,0x3b,
0x3f,0x4c,0x5e,0x75,0x8a,0xa1,0xb3,0xbf,
0xc3,0xbf,0xb5,0xa3,0x8e,0x77,0x61,0x4e,
0x41,0x3b,0x3d,0x46,0x55,0x69,0x80,0x95,
0xa9,0xb8,0xc1,0xc3,0xbd,0xb0,0x9f,0x8a,
0x75,0x61,0x4e,0x42,0x3c,0x3d,0x44,0x52,
0x65,0x7a,0x8e,0xa2,0xb2,0xbd,0xc2,0xc0,
0xb8,0xaa,0x98,0x83,0x6f,0x5c,0x4c,0x41,
0x3c,0x3d,0x45,0x52,0x63,0x77,0x8b,0x9e,
0xaf,0xbb,0xc1,0xc1,0xbc,0xb1,0xa1,0x8f,
0x7b,0x67,0x56,0x48,0x3f,0x3c,0x3f,0x47,
0x54,0x65,0x77,0x8a,0x9d,0xad,0xb9,0xc0,
0xc2,0xbe,0xb5,0xa7,0x97,0x83,0x72,0x60,
0x50,0x45,0x3e,0x3d,0x40,0x49,0x56,0x66,
0x78,0x8a,0x9c,0xab,0xb7,0xbf,0xc1,0xbf,
0xb8,0xac,0x9d,0x8c,0x7b,0x6a,0x59,0x4c,
0x43,0x3d,0x3d,0x42,0x4b,0x57,0x67,0x79,
0x89,0x9a,0xa8,0xb5,0xbd,0xc1,0xc0,0xbb,
0xb1,0xa5,0x95,0x84,0x74,0x63,0x56,0x4a,
0x42,0x3e,0x3e,0x43,0x4b,0x57,0x66,0x75,
0x85,0x95,0xa4,0xb0,0xba,0xbf,0xc0,0xbe,
0xb7,0xad,0xa0,0x92,0x81,0x72,0x63,0x55,
0x4a,0x42,0x3e,0x3e,0x42,0x48,0x53,0x60,
0x6e,0x7e,0x8d,0x9b,0xa9,0xb4,0xbb,0xbf,
0xc0,0xbd,0xb7,0xad,0xa1,0x93,0x84,0x75,
0x67,0x5a,0x4f,0x46,0x40,0x3e,0x3f,0x44,
0x4b,0x56,0x63,0x71,0x80,0x8d,0x9a,0xa7,
0xb1,0xb9,0xbe,0xc0,0xbe,0xb9,0xb2,0xa7,
0x9c,0x8e,0x80,0x73,0x65,0x59,0x4f,0x47,
0x41,0x3f,0x3f,0x43,0x49,0x53,0x5d,0x69,
0x76,0x84,0x91,0x9e,0xa9,0xb3,0xba,0xbe,
0xbf,0xbe,0xba,0xb3,0xaa,0xa0,0x93,0x86,
0x7a,0x6d,0x60,0x55,0x4d,0x46,0x41,0x3f,
0x40,0x44,0x49,0x51,0x5c,0x66,0x72,0x80,
0x8b,0x97,0xa2,0xac,0xb4,0xba,0xbd,0xbe,
0xbd,0xb9,0xb4,0xab,0xa1,0x96,0x8b,0x80,
0x73,0x68,0x5d,0x52,0x4b,0x45,0x41,0x40,
0x41,0x44,0x49,0x50,0x58,0x63,0x6e,0x7a,
0x85,0x90,0x9b,0xa5,0xae,0xb5,0xba,0xbd,
0xbe,0xbd,0xba,0xb4,0xae,0xa5,0x9b,0x91,
0x85,0x7b,0x70,0x65,0x5b,0x53,0x4b,0x46,
0x42,0x41,0x41,0x43,0x47,0x4c,0x54,0x5d,
0x67,0x71,0x7c,0x86,0x90,0x9a,0xa3,0xac,
0xb3,0xb8,0xbb,0xbd,0xbd,0xbb,0xb7,0xb2,
0xac,0xa3,0x9b,0x91,0x87,0x7d,0x72,0x69,
0x5f,0x57,0x50,0x4a,0x45,0x42,0x41,0x42,
0x43,0x47,0x4c,0x53,0x5b,0x63,0x6c,0x76,
0x80,0x88,0x93,0x9c,0xa4,0xab,0xb1,0xb6,
0xba,0xbc,0xbd,0xbc,0xb9,0xb5,0xb0,0xaa,
0xa2,0x9a,0x91,0x87,0x80,0x76,0x6c,0x63,
0x5c,0x55,0x4e,0x49,0x45,0x43,0x42,0x42,
0x44,0x47,0x4b,0x50,0x57,0x5e,0x66,0x6f,
0x78,0x80,0x89,0x92,0x9a,0xa2,0xa8,0xae,
0xb4,0xb7,0xba,0xbc,0xbc,0xbb,0xb8,0xb5,
0xb0,0xab,0xa4,0x9d,0x95,0x8d,0x85,0x7c,
0x74,0x6c,0x64,0x5c,0x56,0x51,0x4c,0x48,
0x45,0x43,0x43,0x43,0x45,0x48,0x4b,0x50,
0x56,0x5d,0x63,0x6b,0x73,0x7b,0x82,0x8a,
0x92,0x99,0xa0,0xa7,0xac,0xb1,0xb5,0xb8,
0xba,0xbb,0xbb,0xba,0xb8,0xb4,0xb1,0xac,
0xa6,0xa0,0x9a,0x92,0x8b,0x83,0x7c,0x75,
0x6d,0x66,0x60,0x5a,0x54,0x4f,0x4b,0x48,
0x45,0x44,0x43,0x44,0x45,0x47,0x4a,0x4e,
0x53,0x58,0x5e,0x64,0x6b,0x72,0x79,0x80,
0x87,0x8d,0x94,0x9b,0xa1,0xa6,0xac,0xaf,
0xb3,0xb6,0xb8,0xba,0xba,0xba,0xb9,0xb7,
0xb4,0xb0,0xad,0xa8,0xa2,0x9d,0x97,0x90,
0x8a,0x83,0x7d,0x76,0x70,0x69,0x64,0x5d,
0x59,0x53,0x50,0x4c,0x49,0x47,0x45,0x44,
0x44,0x45,0x46,0x48,0x4b,0x4f,0x52,0x57,
0x5c,0x61,0x67,0x6c,0x72,0x79,0x80,0x85,
0x8b,0x91,0x96,0x9c,0xa2,0xa7,0xab,0xaf,
0xb2,0xb5,0xb7,0xb8,0xb9,0xb9,0xb9,0xb8,
0xb6,0xb4,0xb1,0xae,0xaa,0xa6,0xa1,0x9c,
0x96,0x91,0x8c,0x86,0x80,0x7a,0x75,0x6f,
0x6a,0x64,0x5f,0x5b,0x56,0x52,0x4f,0x4c,
0x4a,0x48,0x46,0x46,0x45,0x46,0x47,0x48,
0x4a,0x4c,0x4f,0x52,0x56,0x5a,0x5e,0x63,
0x68,0x6e,0x72,0x78,0x7d,0x82,0x88,0x8c,
0x92,0x97,0x9b,0xa0,0xa4,0xa8,0xac,0xaf,
0xb1,0xb3,0xb6,0xb7,0xb8,0xb8,0xb8,0xb7,
0xb6,0xb5,0xb3,0xb0,0xad,0xaa,0xa7,0xa3,
0x9f,0x9b,0x97,0x92,0x8c,0x87,0x82,0x7f,
0x7a,0x75,0x70,0x6b,0x66,0x62,0x5e,0x5a,
0x56,0x54,0x51,0x4e,0x4c,0x4a,0x49,0x47,
0x47,0x47,0x47,0x47,0x48,0x4a,0x4b,0x4d,
0x50,0x53,0x55,0x59,0x5d,0x61,0x64,0x68,
0x6d,0x71,0x76,0x7b,0x7f,0x82,0x87,0x8b,
0x90,0x95,0x98,0x9c,0xa0,0xa3,0xa7,0xaa,
0xad,0xaf,0xb1,0xb3,0xb4,0xb5,0xb6,0xb7,
0xb7,0xb6,0xb6,0xb5,0xb3,0xb2,0xb0,0xad,
0xab,0xa8,0xa5,0xa2,0x9e,0x9a,0x96,0x93,
0x8e,0x8a,0x86,0x81,0x7f,0x7a,0x76,0x72,
0x6d,0x6a,0x65,0x62,0x5e,0x5b,0x58,0x55,
0x53,0x50,0x4e,0x4c,0x4b,0x4a,0x49,0x48,
0x48,0x48,0x49,0x49,0x4a,0x4b,0x4d,0x4f,
0x51,0x54,0x56,0x59,0x5c,0x5f,0x63,0x66,
0x6a,0x6e,0x72,0x76,0x7a,0x7e,0x80,0x85,
0x89,0x8d,0x90,0x94,0x98,0x9c,0x9f,0xa2,
0xa5,0xa7,0xaa,0xac,0xae,0xb0,0xb2,0xb3,
0xb4,0xb5,0xb5,0xb5,0xb5,0xb5,0xb4,0xb3,
0xb2,0xb0,0xaf,0xad,0xab,0xa8,0xa6,0xa3,
0xa0,0x9d,0x9a,0x96,0x93,0x8f,0x8c,0x88,
0x84,0x80,0x7e,0x7a,0x76,0x72,0x6f,0x6b,
0x68,0x65,0x62,0x5f,0x5c,0x59,0x57,0x54,
0x52,0x50,0x4f,0x4d,0x4c,0x4b,0x4a,0x4a,
0x4a,0x4a,0x4a,0x4a,0x4b,0x4c,0x4d,0x4f,
0x50,0x52,0x54,0x56,0x59,0x5c,0x5e,0x61,
0x64,0x67,0x6a,0x6d,0x71,0x74,0x77,0x7b,
0x7f,0x81,0x84,0x88,0x8b,0x8e,0x92,0x95,
0x98,0x9b,0x9e,0xa1,0xa3,0xa5,0xa8,0xaa,
0xac,0xad,0xaf,0xb0,0xb1,0xb2,0xb3,0xb3,
0xb3,0xb3,0xb3,0xb3,0xb2,0xb2,0xb1,0xb0,
0xae,0xac,0xab,0xa9,0xa7,0xa4,0xa2,0xa0,
0x9d,0x9a,0x97,0x95,0x91,0x8f,0x8b,0x89,
0x85,0x82,0x80,0x7d,0x79,0x76,0x73,0x70,
0x6d,0x6a,0x68,0x65,0x62,0x5f,0x5d,0x5b,
0x59,0x56,0x55,0x53,0x51,0x50,0x4f,0x4e,
0x4d,0x4c,0x4c,0x4c,0x4b,0x4b,0x4c,0x4c,
0x4d,0x4e,0x4e,0x50,0x51,0x53,0x54,0x56,
0x58,0x5a,0x5b,0x5d,0x60,0x63,0x65,0x68,
0x6a,0x6d,0x70,0x73,0x76,0x78,0x7c,0x7f,
0x80,0x84,0x87,0x89,0x8c,0x8f,0x92,0x94,
0x97,0x99,0x9c,0x9e,0xa0,0xa2,0xa5,0xa6,
0xa8,0xaa,0xab,0xad,0xae,0xaf,0xaf,0xb0,
0xb1,0xb1,0xb2,0xb2,0xb2,0xb1,0xb1,0xb1,
0xb0,0xaf,0xae,0xad,0xac,0xab,0xa9,0xa8,
0xa5,0xa4,0xa2,0xa0,0x9e,0x9c,0x99,0x97,
0x95,0x92,0x90,0x8d,0x8b,0x88,0x86,0x82,
0x80,0x7e,0x7b,0x78,0x76,0x73,0x71,0x6e,
0x6c,0x69,0x67,0x65,0x63,0x60,0x5e,0x5d,
0x5b,0x59,0x57,0x56,0x54,0x53,0x52,0x51,
0x50,0x50,0x4f,0x4e,0x4e,0x4e,0x4d,0x4d,
0x4e,0x4e,0x4e,0x4f,0x4f,0x50,0x51,0x52,
0x53,0x54,0x56,0x57,0x58,0x5a,0x5c,0x5e,
0x60,0x62,0x63,0x65,0x67,0x6a,0x6c,0x6f,
0x71,0x73,0x75,0x78,0x7a,0x7d,0x7f,0x80,
0x83,0x85,0x88,0x8a,0x8c,0x8f,0x91,0x93,
0x95,0x97,0x99,0x9b,0x9d,0x9f,0xa1,0xa2,
0xa4,0xa5,0xa7,0xa8,0xa9,0xaa,0xab,0xac,
0xad,0xae,0xae,0xaf,0xaf,0xaf,0xaf,0xaf,
0xaf,0xaf,0xaf,0xae,0xae,0xad,0xad,0xac,
0xab,0xaa,0xa9,0xa8,0xa7,0xa5,0xa4,0xa3,
0xa1,0x9f,0x9e,0x9c,0x9a,0x98,0x96,0x95,
0x92,0x91,0x8e,0x8c,0x8a,0x88,0x86,0x84,
0x81,0x80,0x7e,0x7c,0x7a,0x78,0x75,0x73,
0x71,0x6f,0x6d,0x6b,0x6a,0x67,0x66,0x64,
0x63,0x61,0x5f,0x5e,0x5c,0x5b,0x5a,0x58,
0x57,0x56,0x55,0x54,0x53,0x53,0x52,0x51,
0x51,0x50,0x50,0x50,0x50,0x50,0x50,0x50,
0x50,0x50,0x51,0x51,0x52,0x53,0x53,0x54,
0x55,0x56,0x57,0x58,0x59,0x5a,0x5c,0x5d,
0x5f,0x60,0x61,0x63,0x64,0x66,0x68,0x69,
0x6c,0x6d,0x6f,0x71,0x73,0x74,0x77,0x78,
0x7a,0x7c,0x7e,0x80,0x81,0x83,0x84,0x87,
0x88,0x8a,0x8c,0x8e,0x8f,0x92,0x93,0x94,
0x96,0x98,0x99,0x9b,0x9d,0x9e,0x9f,0xa0,
0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,
0xa9,0xaa,0xaa,0xab,0xac,0xac,0xac,0xac,
0xad,0xad,0xad,0xad,0xad,0xac,0xac,0xac,
0xac,0xab,0xab,0xaa,0xaa,0xa9,0xa8,0xa7,
0xa6,0xa6,0xa5,0xa4,0xa2,0xa1,0xa0,0x9f,
0x9e,0x9d,0x9b,0x99,0x98,0x97,0x95,0x94,
0x93,0x90,0x8f,0x8d,0x8c,0x8a,0x89,0x87,
0x86,0x83,0x82,0x80,0x80,0x7e,0x7c,0x7b,
0x79,0x78,0x76,0x75,0x72,0x71,0x6f,0x6e,
0x6c,0x6b,0x6a,0x68,0x67,0x66,0x64,0x63,
0x62,0x61,0x60,0x5e,0x5d,0x5c,0x5b,0x5a,
0x59,0x59,0x58,0x57,0x56,0x56,0x55,0x55,
0x54,0x54,0x54,0x53,0x53,0x53,0x53,0x53,
0x53,0x53,0x53,0x53,0x53,0x54,0x54,0x54,
0x55,0x55,0x56,0x56,0x56,0x57,0x58,0x59,
0x59,0x5a,0x5b,0x5c,0x5d,0x5e,0x5f,0x60,
0x61,0x62,0x64,0x64,0x65,0x67,0x68,0x69,
0x6b,0x6c,0x6e,0x6f,0x70,0x71,0x73,0x74,
0x76,0x77,0x79,0x7a,0x7c,0x7d,0x7e,0x80,
0x80,0x82,0x83,0x85,0x86,0x88,0x89,0x8a,
0x8b,0x8d,0x8e,0x90,0x91,0x92,0x93,0x94,
0x96,0x97,0x98,0x99,0x9a,0x9b,0x9c,0x9d,
0x9e,0x9f,0xa0,0xa1,0xa2,0xa2,0xa3,0xa4,
0xa5,0xa5,0xa6,0xa6,0xa7,0xa7,0xa8,0xa8,
0xa8,0xa9,0xa9,0xa9,0xa9,0xa9,0xaa,0xaa,
0xaa,0xa9,0xa9,0xa9,0xa9,0xa9,0xa9,0xa8,
0xa8,0xa8,0xa7,0xa7,0xa6,0xa6,0xa5,0xa4,
0xa4,0xa3,0xa2,0xa1,0xa1,0xa0,0x9f,0x9e,
0x9d,0x9d,0x9c,0x9a,0x99,0x99,0x97,0x96,
0x95,0x94,0x93,0x92,0x90,0x8f,0x8e,0x8d,
0x8c,0x8a,0x89,0x88,0x87,0x85,0x84,0x83,
0x81,0x80,0x80,0x7f,0x7d,0x7d,0x7b,0x7a,
0x78,0x77,0x76,0x75,0x74,0x73,0x71,0x70,
0x6f,0x6e,0x6c,0x6c,0x6b,0x69,0x68,0x68,
0x66,0x65,0x65,0x64,0x63,0x62,0x61,0x60,
0x5f,0x5f,0x5e,0x5d,0x5d,0x5c,0x5b,0x5b,
0x5a,0x5a,0x59,0x59,0x58,0x58,0x58,0x57,
0x57,0x57,0x57,0x57,0x56,0x56,0x56,0x56,
0x56,0x56,0x56,0x57,0x57,0x57,0x57,0x57,
0x58,0x58,0x58,0x59,0x59,0x5a,0x5a,0x5a,
0x5b,0x5c,0x5c,0x5d,0x5d,0x5e,0x5f,0x5f,
0x60,0x61,0x62,0x63,0x64,0x64,0x65,0x66,
0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,
0x6f,0x70,0x71,0x72,0x73,0x74,0x75,0x76,
0x77,0x78,0x7a,0x7b,0x7c,0x7d,0x7e,0x80,
0x80,0x81,0x81,0x83,0x84,0x85,0x86,0x87,
0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,
0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x96,
0x98,0x98,0x99,0x9a,0x9b,0x9b,0x9c,0x9d,
0x9d,0x9e,0x9f,0x9f,0xa0,0xa0,0xa1,0xa1,
0xa2,0xa2,0xa3,0xa3,0xa3,0xa4,0xa4,0xa4,
0xa5,0xa5,0xa5,0xa5,0xa5,0xa5,0xa6,0xa6,
0xa6,0xa6,0xa6,0xa6,0xa6,0xa5,0xa5,0xa5,
0xa5,0xa5,0xa5,0xa4,0xa4,0xa4,0xa3,0xa3,
0xa3,0xa2,0xa2,0xa1,0xa1,0xa0,0xa0,0x9f,
0x9f,0x9e,0x9e,0x9d,0x9d,0x9c,0x9b,0x9a,
0x9a,0x99,0x98,0x97,0x97,0x96,0x95,0x95,
0x93,0x93,0x92,0x91,0x90,0x8f,0x8e,0x8d,
0x8d,0x8c,0x8b,0x8a,0x89,0x88,0x87,0x86,
0x85,0x84,0x83,0x82,0x81,0x80,0x80,0x80,
0x7e,0x7e,0x7d,0x7c,0x7b,0x7a,0x79,0x78,
0x77,0x76,0x75,0x74,0x74,0x73,0x72,0x71,
0x70,0x70,0x6e,0x6e,0x6d,0x6c,0x6b,0x6a,
0x6a,0x69,0x68,0x67,0x67,0x66,0x65,0x65,
0x64,0x64,0x63,0x62,0x62,0x62,0x61,0x61,
0x60,0x60,0x5f,0x5f,0x5e,0x5e,0x5d,0x5d,
0x5d,0x5d,0x5c,0x5c,0x5c,0x5c,0x5b,0x5b,
0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,
0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,
0x5b,0x5c,0x5c,0x5c,0x5c,0x5d,0x5d,0x5d,
0x5e,0x5e,0x5e,0x5f,0x5f,0x60,0x60,0x60,
0x61,0x61,0x62,0x62,0x63,0x63,0x64,0x64,
0x65,0x65,0x66,0x67,0x67,0x68,0x69,0x69,
0x6a,0x6b,0x6b,0x6c,0x6d,0x6d,0x6e,0x6f,
0x70,0x70,0x71,0x72,0x73,0x73,0x74,0x75,
0x76,0x77,0x77,0x78,0x79,0x7a,0x7b,0x7b,
0x7c,0x7d,0x7e,0x7e,0x80,0x80,0x80,0x81,
0x82,0x82,0x83,0x84,0x85,0x85,0x86,0x87,
0x88,0x88,0x89,0x8a,0x8b,0x8b,0x8c,0x8d,
0x8d,0x8e,0x8f,0x90,0x90,0x91,0x92,0x92,
0x93,0x93,0x94,0x95,0x95,0x96,0x96,0x97,
0x97,0x98,0x99,0x99,0x99,0x9a,0x9a,0x9b,
0x9b,0x9b,0x9c,0x9c,0x9d,0x9d,0x9d,0x9e,
0x9e,0x9e,0x9e,0x9f,0x9f,0x9f,0x9f,0xa0,
0xa0,0xa0,0xa0,0xa0,0xa0,0xa1,0xa1,0xa1,
0xa1,0xa1,0xa1,0xa1,0xa1,0xa1,0xa1,0xa1,
0xa1,0xa1,0xa1,0xa1,0xa0,0xa0,0xa0,0xa0,
0xa0,0xa0,0x9f,0x9f,0x9f,0x9f,0x9f,0x9e,
0x9e,0x9e,0x9d,0x9d,0x9d,0x9c,0x9c,0x9c,
0x9b,0x9b,0x9a,0x9a,0x9a,0x99,0x99,0x98,
0x98,0x97,0x97,0x96,0x96,0x95,0x95,0x94,
0x94,0x93,0x93,0x92,0x92,0x91,0x90,0x90,
0x8f,0x8f,0x8e,0x8d,0x8d,0x8c,0x8c,0x8b,
0x8a,0x8a,0x89,0x88,0x88,0x87,0x87,0x86,
0x85,0x85,0x84,0x83,0x83,0x82,0x81,0x81,
0x80,0x80,0x80,0x7f,0x7e,0x7e,0x7d,0x7d,
0x7c,0x7b,0x7a,0x7a,0x79,0x79,0x78,0x78,
0x77,0x76,0x75,0x75,0x74,0x74,0x73,0x73,
0x72,0x72,0x71,0x71,0x70,0x6f,0x6f,0x6e,
0x6e,0x6d,0x6d,0x6c,0x6c,0x6b,0x6b,0x6a,
0x6a,0x69,0x69,0x69,0x68,0x68,0x68,0x67,
0x67,0x66,0x66,0x65,0x65,0x65,0x65,0x64,
0x64,0x64,0x63,0x63,0x63,0x63,0x62,0x62,
0x62,0x62,0x62,0x61,0x61,0x61,0x61,0x61,
0x61,0x61,0x60,0x60,0x60,0x60,0x60,0x60,
0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,
0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x61,
0x61,0x61,0x61,0x61,0x61,0x62,0x62,0x62,
0x62,0x62,0x63,0x63,0x63,0x63,0x64,0x64,
0x64,0x64,0x65,0x65,0x65,0x66,0x66,0x66,
0x66,0x67,0x67,0x67,0x68,0x68,0x69,0x69,
0x69,0x6a,0x6a,0x6b,0x6b,0x6b,0x6c,0x6c,
0x6d,0x6d,0x6e,0x6e,0x6e,0x6f,0x6f,0x70,
0x70,0x71,0x71,0x72,0x72,0x73,0x73,0x74,
0x74,0x75,0x75,0x76,0x76,0x77,0x77,0x78,
0x78,0x79,0x79,0x7a,0x7a,0x7b,0x7b,0x7c,
0x7c,0x7d,0x7d,0x7e,0x7e,0x7f,0x80,0x80,
0x80,0x80,0x81,0x81,0x82,0x82,0x83,0x83,
0x84,0x84,0x84,0x85,0x85,0x86,0x86,0x87,
0x87,0x88,0x88,0x89,0x89,0x8a,0x8a,0x8b,
0x8b,0x8b,0x8c,0x8c,0x8d,0x8d,0x8e,0x8e,
0x8e,0x8e,0x8f,0x8f,0x90,0x90,0x91,0x91,
0x91,0x92,0x92,0x92,0x93,0x93,0x93,0x94,
0x94,0x94,0x94,0x95,0x95,0x95,0x96,0x96,
0x96,0x96,0x97,0x97,0x97,0x97,0x98,0x98,
0x98,0x98,0x98,0x99,0x99,0x99,0x99,0x99,
0x99,0x9a,0x9a,0x9a,0x9a,0x9a,0x9a,0x9a,
0x9a,0x9a,0x9a,0x9b,0x9b,0x9b,0x9b,0x9b,
0x9b,0x9b,0x9b,0x9b,0x9b,0x9b,0x9b,0x9b,
0x9b,0x9b,0x9b,0x9b,0x9b,0x9a,0x9a,0x9a,
0x9a,0x9a,0x9a,0x9a,0x9a,0x9a,0x9a,0x9a,
0x99,0x99,0x99,0x99,0x99,0x99,0x98,0x98,
0x98,0x98,0x98,0x98,0x97,0x97,0x97,0x97,
0x96,0x96,0x96,0x96,0x96,0x95,0x95,0x95,
0x94,0x94,0x94,0x94,0x94,0x93,0x93,0x93,
0x92,0x92,0x92,0x91,0x91,0x91,0x90,0x90,
0x90,0x90,0x8f,0x8f,0x8e,0x8e,0x8e,0x8e,
0x8d,0x8d,0x8c,0x8c,0x8c,0x8b,0x8b,0x8b,
0x8a,0x8a,0x89,0x89,0x89,0x89,0x88,0x88,
0x87,0x87,0x86,0x86,0x86,0x85,0x85,0x85,
0x84,0x84,0x84,0x83,0x83,0x82,0x82,0x82,
0x81,0x81,0x80,0x80,0x80,0x80,0x80,0x80,
0x7f,0x7f,0x7f,0x7e,0x7e,0x7d,0x7d,0x7d,
0x7c,0x7c,0x7b,0x7b,0x7b,0x7b,0x7a,0x7a,
0x79,0x79,0x79,0x78,0x78,0x77,0x77,0x77,
0x77,0x76,0x76,0x75,0x75,0x75,0x75,0x74,
0x74,0x74,0x73,0x73,0x73,0x72,0x72,0x72,
0x72,0x71,0x71,0x71,0x70,0x70,0x70,0x6f,
0x6f,0x6f,0x6f,0x6e,0x6e,0x6e,0x6e,0x6e,
0x6d,0x6d,0x6d,0x6d,0x6c,0x6c,0x6c,0x6c,
0x6c,0x6b,0x6b,0x6b,0x6b,0x6b,0x6a,0x6a,
0x6a,0x6a,0x6a,0x6a,0x6a,0x69,0x69,0x69,
0x69,0x69,0x69,0x69,0x69,0x68,0x68,0x68,
0x68,0x68,0x68,0x68,0x68,0x68,0x68,0x68,
0x68,0x67,0x67,0x67,0x67,0x67,0x67,0x67,
0x67,0x67,0x67,0x67,0x67,0x67,0x67,0x67,
0x67,0x67,0x67,0x67,0x67,0x67,0x67,0x67,
0x67,0x67,0x67,0x67,0x68,0x68,0x68,0x68,
0x68,0x68,0x68,0x68,0x68,0x68,0x68,0x68,
0x68,0x69,0x69,0x69,0x69,0x69,0x69,0x69,
0x69,0x6a,0x6a,0x6a,0x6a,0x6a,0x6a,0x6a,
0x6b,0x6b,0x6b,0x6b,0x6b,0x6b,0x6c,0x6c,
0x6c,0x6c,0x6c,0x6d,0x6d,0x6d,0x6d,0x6d,
0x6d,0x6e,0x6e,0x6e,0x6e,0x6e,0x6f,0x6f,
0x6f,0x6f,0x6f,0x70,0x70,0x70,0x70,0x71,
0x71,0x71,0x71,0x72,0x72,0x72,0x72,0x73,
0x73,0x73,0x73,0x73,0x74,0x74,0x74,0x74,
0x75,0x75,0x75,0x76,0x76,0x76,0x76,0x77,
0x77,0x77,0x77,0x77,0x78,0x78,0x79,0x79,
0x79,0x79,0x79,0x7a,0x7a,0x7a,0x7a,0x7b,
0x7b,0x7b,0x7c,0x7c,0x7c,0x7c,0x7c,0x7d,
0x7d,0x7d,0x7e,0x7e,0x7e,0x7e,0x7f,0x7f,
0x7f,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
0x80,0x80,0x81,0x81,0x81,0x82,0x82,0x82,
0x82,0x82,0x83,0x83,0x83,0x83,0x84,0x84,
0x84,0x84,0x84,0x85,0x85,0x85,0x86,0x86,
0x86,0x86,0x87,0x87,0x87,0x87,0x87,0x88,
0x88,0x88,0x88,0x88,0x89,0x89,0x89,0x89,
0x89,0x89,0x8a,0x8a,0x8a,0x8a,0x8b,0x8b,
0x8b,0x8b,0x8b,0x8b,0x8b,0x8c,0x8c,0x8c,
0x8c,0x8d,0x8d,0x8d,0x8d,0x8d,0x8d,0x8d,
0x8d,0x8e,0x8e,0x8e,0x8e,0x8e,0x8e,0x8e,
0x8f,0x8f,0x8f,0x8f,0x8f,0x8f,0x8f,0x8f,
0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,
0x90,0x90,0x90,0x91,0x91,0x91,0x91,0x91,
0x91,0x91,0x91,0x91,0x91,0x91,0x91,0x91,
0x92,0x91,0x92,0x92,0x92,0x92,0x92,0x92,
0x92,0x92,0x92,0x92,0x92,0x92,0x92,0x92,
0x92,0x92,0x92,0x92,0x92,0x92,0x92,0x92,
0x92,0x92,0x92,0x92,0x92,0x92,0x92,0x92,
0x92,0x92,0x92,0x92,0x92,0x92,0x92,0x92,
0x92,0x92,0x92,0x92,0x92,0x92,0x92,0x92,
0x91,0x91,0x91,0x91,0x91,0x91,0x91,0x91,
0x91,0x91,0x91,0x91,0x91,0x91,0x91,0x91,
0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,
0x90,0x90,0x90,0x90,0x8f,0x8f,0x8f,0x8f,
0x8f,0x8f,0x8f,0x8f,0x8f,0x8e,0x8e,0x8e,
0x8e,0x8e,0x8e,0x8e,0x8e,0x8e,0x8d,0x8d,
0x8d,0x8d,0x8d,0x8d,0x8d,0x8d,0x8d,0x8c,
0x8c,0x8c,0x8c,0x8c,0x8c,0x8c,0x8b,0x8b,
0x8b,0x8b,0x8b,0x8b,0x8b,0x8a,0x8a,0x8a,
0x8a,0x8a,0x8a,0x8a,0x89,0x89,0x89,0x89,
0x89,0x89,0x88,0x88,0x88,0x88,0x88,0x88,
0x88,0x87,0x87,0x87,0x87,0x87,0x86,0x86,
0x86,0x86,0x86,0x86,0x86,0x86,0x85,0x85,
0x85,0x85,0x85,0x84,0x84,0x84,0x84,0x84,
0x84,0x84,0x84,0x83,0x83,0x83,0x83,0x83,
0x83,0x82,0x82,0x82,0x82,0x82,0x81,0x81,
0x81,0x81,0x81,0x81,0x81,0x81,0x80,0x80,
0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
0x80,0x80,0x80,0x7f,0x7f,0x7f,0x7f,0x7f,
0x7f,0x7e,0x7e,0x7e,0x7e,0x7e,0x7e,0x7d,
0x7e,0x7d,0x7d,0x7d,0x7d,0x7d,0x7d,0x7d,
0x7d,0x7d,0x7d,0x7d,0x7d,0x7d,0x7d,0x7d,
0x7d,0x7d,0x7d,0x7d,0x7d,0x7d,0x7d,0x7d,
0x7d,0x7d,0x7d,0x7d,0x7d,0x7d,0x7e,0x7d,
0x7d,0x7e,0x7e,0x7e,0x7e,0x7e,0x7e,0x7e,
0x7e,0x7e,0x7e,0x7f,0x7f,0x7f,0x7f,0x7f,
0x7f,0x7f,0x80,0x80,0x80,0x80,0x80,0x80,
};

View File

@@ -0,0 +1,140 @@
#ifndef _I386_BITOPS_H
#define _I386_BITOPS_H
/*
* Copyright 1992, Linus Torvalds.
*/
/*
* Reused for the ReactOS kernel by David Welch (1998)
*/
/*
* These have to be done with inline assembly: that way the bit-setting
* is guaranteed to be atomic. All bit operations return 0 if the bit
* was cleared before the operation and != 0 if it was not.
*
* bit 0 is the LSB of addr; bit 32 is the LSB of (addr+1).
*/
#ifdef __SMP__
#define LOCK_PREFIX "lock ; "
#define SMPVOL volatile
#else
#define LOCK_PREFIX ""
#define SMPVOL
#endif
/*
* Some hacks to defeat gcc over-optimizations..
*/
struct __dummy { unsigned long a[100]; };
#define ADDR (*(struct __dummy *) addr)
#define CONST_ADDR (*(const struct __dummy *) addr)
extern __inline__ int set_bit(int nr, SMPVOL void * addr)
{
int oldbit;
__asm__ __volatile__(LOCK_PREFIX
"btsl %2,%1\n\tsbbl %0,%0"
:"=r" (oldbit),"=m" (ADDR)
:"ir" (nr));
return oldbit;
}
extern __inline__ int clear_bit(int nr, SMPVOL void * addr)
{
int oldbit;
__asm__ __volatile__(LOCK_PREFIX
"btrl %2,%1\n\tsbbl %0,%0"
:"=r" (oldbit),"=m" (ADDR)
:"ir" (nr));
return oldbit;
}
extern __inline__ int change_bit(int nr, SMPVOL void * addr)
{
int oldbit;
__asm__ __volatile__(LOCK_PREFIX
"btcl %2,%1\n\tsbbl %0,%0"
:"=r" (oldbit),"=m" (ADDR)
:"ir" (nr));
return oldbit;
}
/*
* This routine doesn't need to be atomic.
*/
extern __inline__ int test_bit(int nr, const SMPVOL void * addr)
{
return ((1UL << (nr & 31)) & (((const unsigned int *) addr)[nr >> 5])) != 0;
}
/*
* Find-bit routines..
*/
extern __inline__ int find_first_zero_bit(void * addr, unsigned size)
{
int res;
if (!size)
return 0;
__asm__("cld\n\t"
"movl $-1,%%eax\n\t"
"xorl %%edx,%%edx\n\t"
"repe; scasl\n\t"
"je 1f\n\t"
"xorl -4(%%edi),%%eax\n\t"
"subl $4,%%edi\n\t"
"bsfl %%eax,%%edx\n"
"1:\tsubl %%ebx,%%edi\n\t"
"shll $3,%%edi\n\t"
"addl %%edi,%%edx"
:"=d" (res)
:"c" ((size + 31) >> 5), "D" (addr), "b" (addr)
:"ax", "cx", "di");
return res;
}
extern __inline__ int find_next_zero_bit (void * addr, int size, int offset)
{
unsigned long * p = ((unsigned long *) addr) + (offset >> 5);
int set = 0, bit = offset & 31, res;
if (bit) {
/*
* Look for zero in first byte
*/
__asm__("bsfl %1,%0\n\t"
"jne 1f\n\t"
"movl $32, %0\n"
"1:"
: "=r" (set)
: "r" (~(*p >> bit)));
if (set < (32 - bit))
return set + offset;
set = 32 - bit;
p++;
}
/*
* No zero yet, search remaining full bytes for a zero
*/
res = find_first_zero_bit (p, size - 32 * (p - (unsigned long *) addr));
return (offset + set + res);
}
/*
* ffz = Find First Zero in word. Undefined if no zero exists,
* so code should check against ~0UL first..
*/
extern __inline__ unsigned long ffz(unsigned long word)
{
__asm__("bsfl %1,%0"
:"=r" (word)
:"r" (~word));
return word;
}
#endif /* _I386_BITOPS_H */

View File

@@ -0,0 +1,71 @@
#ifndef _LINUX_CTYPE_H
#define _LINUX_CTYPE_H
#ifdef USE_OLD_CTYPE_IMPLEMENTATION
#define _U 0x01 /* upper */
#define _L 0x02 /* lower */
#define _D 0x04 /* digit */
#define _C 0x08 /* cntrl */
#define _P 0x10 /* punct */
#define _S 0x20 /* white space (space/lf/tab) */
#define _X 0x40 /* hex digit */
#define _SP 0x80 /* hard space (0x20) */
extern unsigned char _ctype[];
extern char _ctmp;
#define isalnum(c) ((_ctype+1)[c]&(_U|_L|_D))
#define isalpha(c) ((_ctype+1)[c]&(_U|_L))
#define iscntrl(c) ((_ctype+1)[c]&(_C))
#define isdigit(c) ((_ctype+1)[c]&(_D))
#define isgraph(c) ((_ctype+1)[c]&(_P|_U|_L|_D))
#define islower(c) ((_ctype+1)[c]&(_L))
#define isprint(c) ((_ctype+1)[c]&(_P|_U|_L|_D|_SP))
#define ispunct(c) ((_ctype+1)[c]&(_P))
#define isspace(c) ((_ctype+1)[c]&(_S))
#define isupper(c) ((_ctype+1)[c]&(_U))
#define isxdigit(c) ((_ctype+1)[c]&(_D|_X))
#define isascii(c) (((unsigned) c)<=0x7f)
#define toascii(c) (((unsigned) c)&0x7f)
#define tolower(c) (_ctmp=c,isupper(_ctmp)?_ctmp-('A'-'a'):_ctmp)
#define toupper(c) (_ctmp=c,islower(_ctmp)?_ctmp-('a'-'A'):_ctmp)
#else
#define upalpha ('A' - 'a')
extern inline char toupper(char c)
{
if ((c>='a') && (c<='z')) return (c+upalpha);
return(c);
}
extern inline int islower(char c)
{
if ((c>='a') && (c<='z')) return 1;
return 0;
}
extern inline int isdigit(char c)
{
if ((c>='0') && (c<='9')) return 1;
return 0;
}
extern inline int isxdigit(char c)
{
if (((c>='0') && (c<='9')) || ((toupper(c)>='A') && (toupper(c)<='Z')))
{
return 1;
}
return 0;
}
#endif
#endif

View File

@@ -0,0 +1,72 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: include/internal/debug.h
* PURPOSE: Useful debugging macros
* PROGRAMMER: David Welch (welch@mcmail.com)
* UPDATE HISTORY:
* 28/05/98: Created
*/
/*
* NOTE: Define NDEBUG before including this header to disable debugging
* macros
*/
#ifndef __INTERNAL_DEBUG
#define __INTERNAL_DEBUG
#define UNIMPLEMENTED do {DbgPrint("%s at %s:%d is umimplemented, have a nice day\n",__FUNCTION__,__FILE__,__LINE__); for(;;); } while(0);
#ifndef NDEBUG
#define DPRINT(fmt,args...) do { DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint(fmt,args); } while(0);
//#define assert(x) if (!(x)) {DbgPrint("Assertion "#x" failed at %s:%d\n", __FILE__,__LINE__); (*((unsigned int *)0))=1; for (;;); }
#define assert(x) if (!(x)) {DbgPrint("Assertion "#x" failed at %s:%d\n", __FILE__,__LINE__); for (;;); }
#define CHECKPOINT DbgPrint("%s:%d\n",__FILE__,__LINE__)
#else
#define DPRINT(fmt,args...)
#define assert(x)
#define CHECKPOINT
#endif /* NDEBUG */
/*
* FUNCTION: Assert a maximum value for the current irql
* ARGUMENTS:
* x = Maximum irql
*/
#define ASSERT_IRQL(x) assert(KeGetCurrentIrql()<=(x))
#define assert_irql(x) assert(KeGetCurrentIrql()<=(x))
#define HBP_EXECUTE (0)
#define HBP_WRITE (1)
#define HBP_READWRITE (3)
#define HBP_BYTE (0)
#define HBP_WORD (1)
#define HBP_DWORD (3)
/*
* FUNCTION: Sets a hardware breakpoint
* ARGUMENTS:
* i = breakpoint to set (0 to 3)
* addr = linear address to break on
* type = Type of access to break on
* len = length of the variable to watch
* NOTES:
* The variable to watch must be aligned to its length (i.e. a dword
* breakpoint must be aligned to a dword boundary)
*
* A fatal exception will be generated on the access to the variable.
* It is (at the moment) only really useful for catching undefined
* pointers if you know the variable effected but not the buggy
* routine.
*
* FIXME: Extend to call out to kernel debugger on breakpoint
* Add support for I/O breakpoints
* REFERENCES: See the i386 programmer manual for more details
*/
void set_breakpoint(unsigned int i, unsigned int addr, unsigned int type,
unsigned int len);
#endif /* __INTERNAL_DEBUG */

View File

@@ -0,0 +1,267 @@
/* $Id: dma.h,v 1.1.1.2 1998/08/25 04:27:32 rex Exp $
* linux/include/asm/dma.h: Defines for using and allocating dma channels.
* Written by Hennus Bergman, 1992.
* High DMA channel support & info by Hannu Savolainen
* and John Boyd, Nov. 1992.
*/
#ifndef _ASM_DMA_H
#define _ASM_DMA_H
#include <internal/hal/io.h> /* need byte IO */
#ifdef HAVE_REALLY_SLOW_DMA_CONTROLLER
#define dma_outb outb_p
#else
#define dma_outb outb
#endif
#define dma_inb inb
/*
* NOTES about DMA transfers:
*
* controller 1: channels 0-3, byte operations, ports 00-1F
* controller 2: channels 4-7, word operations, ports C0-DF
*
* - ALL registers are 8 bits only, regardless of transfer size
* - channel 4 is not used - cascades 1 into 2.
* - channels 0-3 are byte - addresses/counts are for physical bytes
* - channels 5-7 are word - addresses/counts are for physical words
* - transfers must not cross physical 64K (0-3) or 128K (5-7) boundaries
* - transfer count loaded to registers is 1 less than actual count
* - controller 2 offsets are all even (2x offsets for controller 1)
* - page registers for 5-7 don't use data bit 0, represent 128K pages
* - page registers for 0-3 use bit 0, represent 64K pages
*
* DMA transfers are limited to the lower 16MB of _physical_ memory.
* Note that addresses loaded into registers must be _physical_ addresses,
* not logical addresses (which may differ if paging is active).
*
* Address mapping for channels 0-3:
*
* A23 ... A16 A15 ... A8 A7 ... A0 (Physical addresses)
* | ... | | ... | | ... |
* | ... | | ... | | ... |
* | ... | | ... | | ... |
* P7 ... P0 A7 ... A0 A7 ... A0
* | Page | Addr MSB | Addr LSB | (DMA registers)
*
* Address mapping for channels 5-7:
*
* A23 ... A17 A16 A15 ... A9 A8 A7 ... A1 A0 (Physical addresses)
* | ... | \ \ ... \ \ \ ... \ \
* | ... | \ \ ... \ \ \ ... \ (not used)
* | ... | \ \ ... \ \ \ ... \
* P7 ... P1 (0) A7 A6 ... A0 A7 A6 ... A0
* | Page | Addr MSB | Addr LSB | (DMA registers)
*
* Again, channels 5-7 transfer _physical_ words (16 bits), so addresses
* and counts _must_ be word-aligned (the lowest address bit is _ignored_ at
* the hardware level, so odd-byte transfers aren't possible).
*
* Transfer count (_not # bytes_) is limited to 64K, represented as actual
* count - 1 : 64K => 0xFFFF, 1 => 0x0000. Thus, count is always 1 or more,
* and up to 128K bytes may be transferred on channels 5-7 in one operation.
*
*/
#define MAX_DMA_CHANNELS 8
/* The maximum address that we can perform a DMA transfer to on this platform */
#define MAX_DMA_ADDRESS 0x1000000
/* 8237 DMA controllers */
#define IO_DMA1_BASE 0x00 /* 8 bit slave DMA, channels 0..3 */
#define IO_DMA2_BASE 0xC0 /* 16 bit master DMA, ch 4(=slave input)..7 */
/* DMA controller registers */
#define DMA1_CMD_REG 0x08 /* command register (w) */
#define DMA1_STAT_REG 0x08 /* status register (r) */
#define DMA1_REQ_REG 0x09 /* request register (w) */
#define DMA1_MASK_REG 0x0A /* single-channel mask (w) */
#define DMA1_MODE_REG 0x0B /* mode register (w) */
#define DMA1_CLEAR_FF_REG 0x0C /* clear pointer flip-flop (w) */
#define DMA1_TEMP_REG 0x0D /* Temporary Register (r) */
#define DMA1_RESET_REG 0x0D /* Master Clear (w) */
#define DMA1_CLR_MASK_REG 0x0E /* Clear Mask */
#define DMA1_MASK_ALL_REG 0x0F /* all-channels mask (w) */
#define DMA2_CMD_REG 0xD0 /* command register (w) */
#define DMA2_STAT_REG 0xD0 /* status register (r) */
#define DMA2_REQ_REG 0xD2 /* request register (w) */
#define DMA2_MASK_REG 0xD4 /* single-channel mask (w) */
#define DMA2_MODE_REG 0xD6 /* mode register (w) */
#define DMA2_CLEAR_FF_REG 0xD8 /* clear pointer flip-flop (w) */
#define DMA2_TEMP_REG 0xDA /* Temporary Register (r) */
#define DMA2_RESET_REG 0xDA /* Master Clear (w) */
#define DMA2_CLR_MASK_REG 0xDC /* Clear Mask */
#define DMA2_MASK_ALL_REG 0xDE /* all-channels mask (w) */
#define DMA_ADDR_0 0x00 /* DMA address registers */
#define DMA_ADDR_1 0x02
#define DMA_ADDR_2 0x04
#define DMA_ADDR_3 0x06
#define DMA_ADDR_4 0xC0
#define DMA_ADDR_5 0xC4
#define DMA_ADDR_6 0xC8
#define DMA_ADDR_7 0xCC
#define DMA_CNT_0 0x01 /* DMA count registers */
#define DMA_CNT_1 0x03
#define DMA_CNT_2 0x05
#define DMA_CNT_3 0x07
#define DMA_CNT_4 0xC2
#define DMA_CNT_5 0xC6
#define DMA_CNT_6 0xCA
#define DMA_CNT_7 0xCE
#define DMA_PAGE_0 0x87 /* DMA page registers */
#define DMA_PAGE_1 0x83
#define DMA_PAGE_2 0x81
#define DMA_PAGE_3 0x82
#define DMA_PAGE_5 0x8B
#define DMA_PAGE_6 0x89
#define DMA_PAGE_7 0x8A
#define DMA_MODE_READ 0x44 /* I/O to memory, no autoinit, increment, single mode */
#define DMA_MODE_WRITE 0x48 /* memory to I/O, no autoinit, increment, single mode */
#define DMA_MODE_CASCADE 0xC0 /* pass thru DREQ->HRQ, DACK<-HLDA only */
/* enable/disable a specific DMA channel */
static __inline__ void enable_dma(unsigned int dmanr)
{
if (dmanr<=3)
dma_outb(DMA1_MASK_REG, dmanr);
else
dma_outb(DMA2_MASK_REG, dmanr & 3);
}
static __inline__ void disable_dma(unsigned int dmanr)
{
if (dmanr<=3)
dma_outb(DMA1_MASK_REG, dmanr | 4);
else
dma_outb(DMA2_MASK_REG, (dmanr & 3) | 4);
}
/* Clear the 'DMA Pointer Flip Flop'.
* Write 0 for LSB/MSB, 1 for MSB/LSB access.
* Use this once to initialize the FF to a known state.
* After that, keep track of it. :-)
* --- In order to do that, the DMA routines below should ---
* --- only be used while interrupts are disabled! ---
*/
static __inline__ void clear_dma_ff(unsigned int dmanr)
{
if (dmanr<=3)
dma_outb(DMA1_CLEAR_FF_REG, 0);
else
dma_outb(DMA2_CLEAR_FF_REG, 0);
}
/* set mode (above) for a specific DMA channel */
static __inline__ void set_dma_mode(unsigned int dmanr, char mode)
{
if (dmanr<=3)
dma_outb(DMA1_MODE_REG, mode | dmanr);
else
dma_outb(DMA2_MODE_REG, mode | (dmanr&3));
}
/* Set only the page register bits of the transfer address.
* This is used for successive transfers when we know the contents of
* the lower 16 bits of the DMA current address register, but a 64k boundary
* may have been crossed.
*/
static __inline__ void set_dma_page(unsigned int dmanr, char pagenr)
{
switch(dmanr) {
case 0:
dma_outb(DMA_PAGE_0, pagenr);
break;
case 1:
dma_outb(DMA_PAGE_1, pagenr);
break;
case 2:
dma_outb(DMA_PAGE_2, pagenr);
break;
case 3:
dma_outb(DMA_PAGE_3, pagenr);
break;
case 5:
dma_outb(DMA_PAGE_5, pagenr & 0xfe);
break;
case 6:
dma_outb(DMA_PAGE_6, pagenr & 0xfe);
break;
case 7:
dma_outb(DMA_PAGE_7, pagenr & 0xfe);
break;
}
}
/* Set transfer address & page bits for specific DMA channel.
* Assumes dma flipflop is clear.
*/
static __inline__ void set_dma_addr(unsigned int dmanr, unsigned int a)
{
set_dma_page(dmanr, a>>16);
if (dmanr <= 3) {
dma_outb(((dmanr&3)<<1) + IO_DMA1_BASE, a & 0xff);
dma_outb(((dmanr&3)<<1) + IO_DMA1_BASE, (a>>8) & 0xff );
} else {
dma_outb( ((dmanr&3)<<2) + IO_DMA2_BASE ,(a>>1) & 0xff );
dma_outb( ((dmanr&3)<<2) + IO_DMA2_BASE,(a>>9) & 0xff );
}
}
/* Set transfer size (max 64k for DMA1..3, 128k for DMA5..7) for
* a specific DMA channel.
* You must ensure the parameters are valid.
* NOTE: from a manual: "the number of transfers is one more
* than the initial word count"! This is taken into account.
* Assumes dma flip-flop is clear.
* NOTE 2: "count" represents _bytes_ and must be even for channels 5-7.
*/
static __inline__ void set_dma_count(unsigned int dmanr, unsigned int count)
{
count--;
if (dmanr <= 3) {
dma_outb( count & 0xff, ((dmanr&3)<<1) + 1 + IO_DMA1_BASE );
dma_outb( (count>>8) & 0xff, ((dmanr&3)<<1) + 1 + IO_DMA1_BASE );
} else {
dma_outb( (count>>1) & 0xff, ((dmanr&3)<<2) + 2 + IO_DMA2_BASE );
dma_outb( (count>>9) & 0xff, ((dmanr&3)<<2) + 2 + IO_DMA2_BASE );
}
}
/* Get DMA residue count. After a DMA transfer, this
* should return zero. Reading this while a DMA transfer is
* still in progress will return unpredictable results.
* If called before the channel has been used, it may return 1.
* Otherwise, it returns the number of _bytes_ left to transfer.
*
* Assumes DMA flip-flop is clear.
*/
static __inline__ int get_dma_residue(unsigned int dmanr)
{
unsigned int io_port = (dmanr<=3)? ((dmanr&3)<<1) + 1 + IO_DMA1_BASE
: ((dmanr&3)<<2) + 2 + IO_DMA2_BASE;
/* using short to get 16-bit wrap around */
unsigned short count;
count = 1 + dma_inb(io_port);
count += dma_inb(io_port) << 8;
return (dmanr<=3)? count : (count<<1);
}
#endif /* _ASM_DMA_H */

View File

@@ -0,0 +1,10 @@
#ifndef __INCLUDE_INTERNAL_HAL_H
#define __INCLUDE_INTERNAL_HAL_H
#ifdef i386
#include <internal/i386/hal.h>
#else
#error "Unknown processor"
#endif
#endif

View File

@@ -0,0 +1,117 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: include/internal/hal/ddk.h
* PURPOSE: HAL provided defintions for device drivers
* PROGRAMMER: David Welch (welch@mcmail.com)
* REVISION HISTORY:
* 23/06/98: Taken from linux system.h
*/
#ifndef __INCLUDE_INTERNAL_HAL_DDK_H
#define __INCLUDE_INTERNAL_HAL_DDK_H
enum
{
DEVICE_DESCRIPTION_VERSION,
DEVICE_DESCRIPTION_VERSION1,
};
typedef ULONG DMA_WIDTH;
typedef ULONG DMA_SPEED;
typedef ULONG BUS_DATA_TYPE;
/*
* PURPOSE: Types for HalGetBusData
*/
enum
{
Cmos,
EisaConfiguration,
Pos,
PCIConfiguration,
MaximumBusDataType,
};
typedef struct _DEVICE_DESCRIPTION
{
ULONG Version;
BOOLEAN Master;
BOOLEAN ScatterGather;
BOOLEAN DemandMode;
BOOLEAN AutoInitialize;
BOOLEAN Dma32BitAddress;
BOOLEAN IgnoreCount;
BOOLEAN Reserved1;
BOOLEAN Reserved2;
ULONG BusNumber;
ULONG DmaChannel;
INTERFACE_TYPE InterfaceType;
DMA_WIDTH DmaWidth;
DMA_SPEED DmaSpeed;
ULONG MaximumLength;
ULONG DmaPort;
} DEVICE_DESCRIPTION, *PDEVICE_DESCRIPTION;
PVOID HalAllocateCommonBuffer(PADAPTER_OBJECT AdapterObject,
ULONG Length,
PPHYSICAL_ADDRESS LogicalAddress,
BOOLEAN CacheEnabled);
NTSTATUS HalAssignSlotResources(PUNICODE_STRING RegistryPath,
PUNICODE_STRING DriverClassName,
PDRIVER_OBJECT DriverObject,
PDEVICE_OBJECT DeviceObject,
INTERFACE_TYPE BusType,
ULONG BusNumber,
ULONG SlotNumber,
PCM_RESOURCE_LIST* AllocatedResources);
VOID HalExamineMBR(PDEVICE_OBJECT DeviceObject,
ULONG SectorSize,
ULONG MBRTypeIdentifier,
PVOID Buffer);
VOID HalFreeCommonBuffer(PADAPTER_OBJECT AdapterObject,
ULONG Length,
PHYSICAL_ADDRESS LogicalAddress,
PVOID VirtualAddress,
BOOLEAN CacheEnabled);
PADAPTER_OBJECT HalGetAdapter(PDEVICE_DESCRIPTION DeviceDescription,
PULONG NumberOfMapRegisters);
ULONG HalGetBusData(BUS_DATA_TYPE BusDataType,
ULONG BusNumber,
ULONG SlotNumber,
PVOID Buffer,
ULONG Length);
ULONG HalGetBusDataByOffset(BUS_DATA_TYPE BusDataType,
ULONG BusNumber,
ULONG SlotNumber,
PVOID Buffer,
ULONG Offset,
ULONG Length);
ULONG HalGetDmaAlignmentRequirement(VOID);
ULONG HalGetInterruptVector(INTERFACE_TYPE InterfaceType,
ULONG BusNumber,
ULONG BusInterruptLevel,
ULONG BusInterruptVector,
PKIRQL Irql,
PKAFFINITY Affinity);
VOID HalQuerySystemInformation(VOID);
ULONG HalReadDmaCounter(PADAPTER_OBJECT AdapterObject);
ULONG HalSetBusData(BUS_DATA_TYPE BusDataType,
ULONG BusNumber,
ULONG SlotNumber,
PVOID Buffer,
ULONG Length);
ULONG HalSetBusDataByOffset(BUS_DATA_TYPE BusDataType,
ULONG BusNumber,
ULONG SlotNumber,
PVOID Buffer,
ULONG Offset,
ULONG Length);
BOOLEAN HalTranslateBusAddress(INTERFACE_TYPE InterfaceType,
ULONG BusNumber,
PHYSICAL_ADDRESS BusAddress,
PULONG AddressSpace,
PPHYSICAL_ADDRESS TranslatedAddress);
#endif /* __INCLUDE_INTERNAL_HAL_DDK_H */

View File

@@ -0,0 +1,167 @@
#ifndef _ASM_IO_H
#define _ASM_IO_H
/*
* This file contains the definitions for the x86 IO instructions
* inb/inw/inl/outb/outw/outl and the "string versions" of the same
* (insb/insw/insl/outsb/outsw/outsl). You can also use "pausing"
* versions of the single-IO instructions (inb_p/inw_p/..).
*
* This file is not meant to be obfuscating: it's just complicated
* to (a) handle it all in a way that makes gcc able to optimize it
* as well as possible and (b) trying to avoid writing the same thing
* over and over again with slight variations and possibly making a
* mistake somewhere.
*/
/*
* Thanks to James van Artsdalen for a better timing-fix than
* the two short jumps: using outb's to a nonexistent port seems
* to guarantee better timings even on fast machines.
*
* On the other hand, I'd like to be sure of a non-existent port:
* I feel a bit unsafe about using 0x80 (should be safe, though)
*
* Linus
*/
#ifdef SLOW_IO_BY_JUMPING
#define __SLOW_DOWN_IO __asm__ __volatile__("jmp 1f\n1:\tjmp 1f\n1:")
#else
#define __SLOW_DOWN_IO __asm__ __volatile__("outb %al,$0x80")
#endif
#ifdef REALLY_SLOW_IO
#define SLOW_DOWN_IO { __SLOW_DOWN_IO; __SLOW_DOWN_IO; __SLOW_DOWN_IO; __SLOW_DOWN_IO; }
#else
#define SLOW_DOWN_IO __SLOW_DOWN_IO
#endif
/*
* Talk about misusing macros..
*/
#define __OUT1(s,x) \
extern inline void __out##s(unsigned x value, unsigned short port) {
#define __OUT2(s,s1,s2) \
__asm__ __volatile__ ("out" #s " %" s1 "0,%" s2 "1"
#define __OUT(s,s1,x) \
__OUT1(s,x) __OUT2(s,s1,"w") : : "a" (value), "d" (port)); } \
__OUT1(s##c,x) __OUT2(s,s1,"") : : "a" (value), "id" (port)); } \
__OUT1(s##_p,x) __OUT2(s,s1,"w") : : "a" (value), "d" (port)); SLOW_DOWN_IO; } \
__OUT1(s##c_p,x) __OUT2(s,s1,"") : : "a" (value), "id" (port)); SLOW_DOWN_IO; }
#define __IN1(s) \
extern inline RETURN_TYPE __in##s(unsigned short port) { RETURN_TYPE _v;
#define __IN2(s,s1,s2) \
__asm__ __volatile__ ("in" #s " %" s2 "1,%" s1 "0"
#define __IN(s,s1,i...) \
__IN1(s) __IN2(s,s1,"w") : "=a" (_v) : "d" (port) ,##i ); return _v; } \
__IN1(s##c) __IN2(s,s1,"") : "=a" (_v) : "id" (port) ,##i ); return _v; } \
__IN1(s##_p) __IN2(s,s1,"w") : "=a" (_v) : "d" (port) ,##i ); SLOW_DOWN_IO; return _v; } \
__IN1(s##c_p) __IN2(s,s1,"") : "=a" (_v) : "id" (port) ,##i ); SLOW_DOWN_IO; return _v; }
#define __INS(s) \
extern inline void ins##s(unsigned short port, void * addr, unsigned long count) \
{ __asm__ __volatile__ ("cld ; rep ; ins" #s \
: "=D" (addr), "=c" (count) : "d" (port),"0" (addr),"1" (count)); }
#define __OUTS(s) \
extern inline void outs##s(unsigned short port, const void * addr, unsigned long count) \
{ __asm__ __volatile__ ("cld ; rep ; outs" #s \
: "=S" (addr), "=c" (count) : "d" (port),"0" (addr),"1" (count)); }
#define RETURN_TYPE unsigned char
/* __IN(b,"b","0" (0)) */
__IN(b,"")
#undef RETURN_TYPE
#define RETURN_TYPE unsigned short
/* __IN(w,"w","0" (0)) */
__IN(w,"")
#undef RETURN_TYPE
#define RETURN_TYPE unsigned int
__IN(l,"")
#undef RETURN_TYPE
__OUT(b,"b",char)
__OUT(w,"w",short)
__OUT(l,,int)
__INS(b)
__INS(w)
__INS(l)
__OUTS(b)
__OUTS(w)
__OUTS(l)
/*
* Note that due to the way __builtin_constant_p() works, you
* - can't use it inside a inline function (it will never be true)
* - you don't have to worry about side effects within the __builtin..
*/
#define outb(port,val) \
((__builtin_constant_p((port)) && (port) < 256) ? \
__outbc((val),(port)) : \
__outb((val),(port)))
#define inb(port) \
((__builtin_constant_p((port)) && (port) < 256) ? \
__inbc(port) : \
__inb(port))
#define outb_p(port,val) \
((__builtin_constant_p((port)) && (port) < 256) ? \
__outbc_p((val),(port)) : \
__outb_p((val),(port)))
#define inb_p(port) \
((__builtin_constant_p((port)) && (port) < 256) ? \
__inbc_p(port) : \
__inb_p(port))
#define outw(port,val) \
((__builtin_constant_p((port)) && (port) < 256) ? \
__outwc((val),(port)) : \
__outw((val),(port)))
#define inw(port) \
((__builtin_constant_p((port)) && (port) < 256) ? \
__inwc(port) : \
__inw(port))
#define outw_p(port,val) \
((__builtin_constant_p((port)) && (port) < 256) ? \
__outwc_p((val),(port)) : \
__outw_p((val),(port)))
#define inw_p(port) \
((__builtin_constant_p((port)) && (port) < 256) ? \
__inwc_p(port) : \
__inw_p(port))
#define outl(port,val) \
((__builtin_constant_p((port)) && (port) < 256) ? \
__outlc((val),(port)) : \
__outl((val),(port)))
#define inl(port) \
((__builtin_constant_p((port)) && (port) < 256) ? \
__inlc(port) : \
__inl(port))
#define outl_p(port,val) \
((__builtin_constant_p((port)) && (port) < 256) ? \
__outlc_p((val),(port)) : \
__outl_p((val),(port)))
#define inl_p(port) \
((__builtin_constant_p((port)) && (port) < 256) ? \
__inlc_p(port) : \
__inl_p(port))
#endif

View File

@@ -0,0 +1,7 @@
/*
* PURPOSE: The number of device specific level levels
*/
#define NR_DEVICE_SPECIFIC_LEVELS (16)

View File

@@ -0,0 +1,82 @@
/*
* Lowlevel memory managment definitions
*/
#ifndef __INTERNAL_HAL_PAGE_H
#define __INTERNAL_HAL_PAGE_H
#include <ddk/ntddk.h>
#define PAGESIZE (4096)
/*
* Sets a page entry
* vaddr: The virtual address to set the page entry for
* attributes: The access attributes to give the page
* physaddr: The physical address the page should map to
*/
void set_page(unsigned int vaddr, unsigned int attributes,
unsigned int physaddr);
#define PAGE_ROUND_UP(x) ( (((ULONG)x)%PAGESIZE) ? ((((ULONG)x)&(~0xfff))+0x1000) : ((ULONG)x) )
#define PAGE_ROUND_DOWN(x) (((ULONG)x)&(~0xfff))
/*
* Page access attributes (or these together)
*/
#define PA_READ (1<<0)
#define PA_WRITE ((1<<0)+(1<<1))
#define PA_EXECUTE PA_READ
#define PA_PCD (1<<4)
#define PA_PWT (1<<3)
/*
* Page attributes
*/
#define PA_USER (1<<2)
#define PA_SYSTEM (0)
#define KERNEL_BASE (0xc0000000)
#define IDMAP_BASE (0xd0000000)
/*
* Return a linear address which can be used to access the physical memory
* starting at x
*/
extern inline unsigned int physical_to_linear(unsigned int x)
{
return(x+IDMAP_BASE);
}
extern inline unsigned int linear_to_physical(unsigned int x)
{
return(x-IDMAP_BASE);
}
#define FLUSH_TLB __asm__("movl %cr3,%eax\n\tmovl %eax,%cr3\n\t")
extern inline unsigned int* get_page_directory(void)
{
unsigned int page_dir=0;
__asm__("movl %%cr3,%0\n\t"
: "=r" (page_dir));
return((unsigned int *)physical_to_linear(page_dir));
}
/*
* Amount of memory that can be mapped by a page table
*/
#define PAGE_TABLE_SIZE (4*1024*1024)
#define PAGE_MASK(x) (x&(~0xfff))
#define VADDR_TO_PT_OFFSET(x) (((x/1024)%4096))
#define VADDR_TO_PD_OFFSET(x) ((x)/(4*1024*1024))
unsigned int* get_page_entry(unsigned int vaddr);
BOOL is_page_present(unsigned int vaddr);
#endif /* __INTERNAL_HAL_PAGE_H */

View File

@@ -0,0 +1,343 @@
#ifndef _ASM_SEGMENT_H
#define _ASM_SEGMENT_H
#define ZERO_DS 0x18
#define KERNEL_CS 0x20
#define KERNEL_DS 0x28
#ifndef __ASSEMBLY__
/*
* Uh, these should become the main single-value transfer routines..
* They automatically use the right size if we just have the right
* pointer type..
*/
#define put_user(x,ptr) __put_user((unsigned long)(x),(ptr),sizeof(*(ptr)))
#define get_user(ptr) ((__typeof__(*(ptr)))__get_user((ptr),sizeof(*(ptr))))
/*
* This is a silly but good way to make sure that
* the __put_user function is indeed always optimized,
* and that we use the correct sizes..
*/
extern int bad_user_access_length(void);
/*
* dummy pointer type structure.. gcc won't try to do something strange
* this way..
*/
struct __segment_dummy { unsigned long a[100]; };
#define __sd(x) ((struct __segment_dummy *) (x))
#define __const_sd(x) ((const struct __segment_dummy *) (x))
static inline void __put_user(unsigned long x, void * y, int size)
{
switch (size) {
case 1:
__asm__ ("movb %b1,%%fs:%0"
:"=m" (*__sd(y))
:"iq" ((unsigned char) x), "m" (*__sd(y)));
break;
case 2:
__asm__ ("movw %w1,%%fs:%0"
:"=m" (*__sd(y))
:"ir" ((unsigned short) x), "m" (*__sd(y)));
break;
case 4:
__asm__ ("movl %1,%%fs:%0"
:"=m" (*__sd(y))
:"ir" (x), "m" (*__sd(y)));
break;
default:
bad_user_access_length();
}
}
static inline unsigned long __get_user(const void * y, int size)
{
unsigned long result;
switch (size) {
case 1:
__asm__ ("movb %%fs:%1,%b0"
:"=q" (result)
:"m" (*__const_sd(y)));
return (unsigned char) result;
case 2:
__asm__ ("movw %%fs:%1,%w0"
:"=r" (result)
:"m" (*__const_sd(y)));
return (unsigned short) result;
case 4:
__asm__ ("movl %%fs:%1,%0"
:"=r" (result)
:"m" (*__const_sd(y)));
return result;
default:
return bad_user_access_length();
}
}
static inline void __generic_memcpy_tofs(void * to, const void * from, unsigned long n)
{
__asm__ volatile
(" cld
push %%es
push %%fs
cmpl $3,%0
pop %%es
jbe 1f
movl %%edi,%%ecx
negl %%ecx
andl $3,%%ecx
subl %%ecx,%0
rep; movsb
movl %0,%%ecx
shrl $2,%%ecx
rep; movsl
andl $3,%0
1: movl %0,%%ecx
rep; movsb
pop %%es"
:"=abd" (n)
:"0" (n),"D" ((long) to),"S" ((long) from)
:"cx","di","si");
}
static inline void __constant_memcpy_tofs(void * to, const void * from, unsigned long n)
{
switch (n) {
case 0:
return;
case 1:
__put_user(*(const char *) from, (char *) to, 1);
return;
case 2:
__put_user(*(const short *) from, (short *) to, 2);
return;
case 3:
__put_user(*(const short *) from, (short *) to, 2);
__put_user(*(2+(const char *) from), 2+(char *) to, 1);
return;
case 4:
__put_user(*(const int *) from, (int *) to, 4);
return;
case 8:
__put_user(*(const int *) from, (int *) to, 4);
__put_user(*(1+(const int *) from), 1+(int *) to, 4);
return;
case 12:
__put_user(*(const int *) from, (int *) to, 4);
__put_user(*(1+(const int *) from), 1+(int *) to, 4);
__put_user(*(2+(const int *) from), 2+(int *) to, 4);
return;
case 16:
__put_user(*(const int *) from, (int *) to, 4);
__put_user(*(1+(const int *) from), 1+(int *) to, 4);
__put_user(*(2+(const int *) from), 2+(int *) to, 4);
__put_user(*(3+(const int *) from), 3+(int *) to, 4);
return;
}
#define COMMON(x) \
__asm__("cld\n\t" \
"push %%es\n\t" \
"push %%fs\n\t" \
"pop %%es\n\t" \
"rep ; movsl\n\t" \
x \
"pop %%es" \
: /* no outputs */ \
:"c" (n/4),"D" ((long) to),"S" ((long) from) \
:"cx","di","si")
switch (n % 4) {
case 0:
COMMON("");
return;
case 1:
COMMON("movsb\n\t");
return;
case 2:
COMMON("movsw\n\t");
return;
case 3:
COMMON("movsw\n\tmovsb\n\t");
return;
}
#undef COMMON
}
static inline void __generic_memcpy_fromfs(void * to, const void * from, unsigned long n)
{
__asm__ volatile
(" cld
cmpl $3,%0
jbe 1f
movl %%edi,%%ecx
negl %%ecx
andl $3,%%ecx
subl %%ecx,%0
fs; rep; movsb
movl %0,%%ecx
shrl $2,%%ecx
fs; rep; movsl
andl $3,%0
1: movl %0,%%ecx
fs; rep; movsb"
:"=abd" (n)
:"0" (n),"D" ((long) to),"S" ((long) from)
:"cx","di","si", "memory");
}
static inline void __constant_memcpy_fromfs(void * to, const void * from, unsigned long n)
{
switch (n) {
case 0:
return;
case 1:
*(char *)to = __get_user((const char *) from, 1);
return;
case 2:
*(short *)to = __get_user((const short *) from, 2);
return;
case 3:
*(short *) to = __get_user((const short *) from, 2);
*((char *) to + 2) = __get_user(2+(const char *) from, 1);
return;
case 4:
*(int *) to = __get_user((const int *) from, 4);
return;
case 8:
*(int *) to = __get_user((const int *) from, 4);
*(1+(int *) to) = __get_user(1+(const int *) from, 4);
return;
case 12:
*(int *) to = __get_user((const int *) from, 4);
*(1+(int *) to) = __get_user(1+(const int *) from, 4);
*(2+(int *) to) = __get_user(2+(const int *) from, 4);
return;
case 16:
*(int *) to = __get_user((const int *) from, 4);
*(1+(int *) to) = __get_user(1+(const int *) from, 4);
*(2+(int *) to) = __get_user(2+(const int *) from, 4);
*(3+(int *) to) = __get_user(3+(const int *) from, 4);
return;
}
#define COMMON(x) \
__asm__("cld\n\t" \
"rep ; fs ; movsl\n\t" \
x \
: /* no outputs */ \
:"c" (n/4),"D" ((long) to),"S" ((long) from) \
:"cx","di","si","memory")
switch (n % 4) {
case 0:
COMMON("");
return;
case 1:
COMMON("fs ; movsb");
return;
case 2:
COMMON("fs ; movsw");
return;
case 3:
COMMON("fs ; movsw\n\tfs ; movsb");
return;
}
#undef COMMON
}
#define memcpy_fromfs(to, from, n) \
(__builtin_constant_p(n) ? \
__constant_memcpy_fromfs((to),(from),(n)) : \
__generic_memcpy_fromfs((to),(from),(n)))
#define memcpy_tofs(to, from, n) \
(__builtin_constant_p(n) ? \
__constant_memcpy_tofs((to),(from),(n)) : \
__generic_memcpy_tofs((to),(from),(n)))
/*
* These are deprecated..
*
* Use "put_user()" and "get_user()" with the proper pointer types instead.
*/
#define get_fs_byte(addr) __get_user((const unsigned char *)(addr),1)
#define get_fs_word(addr) __get_user((const unsigned short *)(addr),2)
#define get_fs_long(addr) __get_user((const unsigned int *)(addr),4)
#define put_fs_byte(x,addr) __put_user((x),(unsigned char *)(addr),1)
#define put_fs_word(x,addr) __put_user((x),(unsigned short *)(addr),2)
#define put_fs_long(x,addr) __put_user((x),(unsigned int *)(addr),4)
#ifdef WE_REALLY_WANT_TO_USE_A_BROKEN_INTERFACE
static inline unsigned short get_user_word(const short *addr)
{
return __get_user(addr, 2);
}
static inline unsigned char get_user_byte(const char * addr)
{
return __get_user(addr,1);
}
static inline unsigned long get_user_long(const int *addr)
{
return __get_user(addr, 4);
}
static inline void put_user_byte(char val,char *addr)
{
__put_user(val, addr, 1);
}
static inline void put_user_word(short val,short * addr)
{
__put_user(val, addr, 2);
}
static inline void put_user_long(unsigned long val,int * addr)
{
__put_user(val, addr, 4);
}
#endif
/*
* Someone who knows GNU asm better than I should double check the following.
* It seems to work, but I don't know if I'm doing something subtly wrong.
* --- TYT, 11/24/91
* [ nothing wrong here, Linus: I just changed the ax to be any reg ]
*/
static inline unsigned long get_fs(void)
{
unsigned long _v;
__asm__("mov %%fs,%w0":"=r" (_v):"0" (0));
return _v;
}
static inline unsigned long get_ds(void)
{
unsigned long _v;
__asm__("mov %%ds,%w0":"=r" (_v):"0" (0));
return _v;
}
static inline void set_fs(unsigned long val)
{
__asm__ __volatile__("mov %w0,%%fs": /* no output */ :"r" (val));
}
static inline void set_ds(unsigned long val)
{
__asm__ __volatile__("mov %w0,%%ds": /* no output */ :"r" (val));
}
#endif /* __ASSEMBLY__ */
#endif /* _ASM_SEGMENT_H */

View File

@@ -0,0 +1,6 @@
;
; Useful prototypes and definitions
;
%define KERNEL_DS 028h
%define KERNEL_CS 020h

View File

@@ -0,0 +1,71 @@
/*
*
*/
#ifndef __INTERNAL_HAL_HAL_H
#define __INTERNAL_HAL_HAL_H
typedef struct
{
unsigned short previous_task;
unsigned short reserved1;
unsigned long esp0;
unsigned short ss0;
unsigned short reserved2;
unsigned long esp1;
unsigned short ss1;
unsigned short reserved3;
unsigned long esp2;
unsigned short ss2;
unsigned short reserved4;
unsigned long cr3;
unsigned long eip;
unsigned long eflags;
unsigned long eax;
unsigned long ecx;
unsigned long edx;
unsigned long ebx;
unsigned long esp;
unsigned long ebp;
unsigned long esi;
unsigned long edi;
unsigned short es;
unsigned short reserved5;
unsigned short cs;
unsigned short reserved6;
unsigned short ss;
unsigned short reserved7;
unsigned short ds;
unsigned short reserved8;
unsigned short fs;
unsigned short reserved9;
unsigned short gs;
unsigned short reserved10;
unsigned short ldt;
unsigned short reserved11;
unsigned short trap;
unsigned short iomap_base;
unsigned short nr;
unsigned char io_bitmap[1];
} hal_thread_state;
/*
* FUNCTION: Probes for a PCI bus
* RETURNS: True if found
*/
BOOL HalPciProbe(void);
/*
* FUNCTION: Probes for a BIOS32 extension
*/
VOID Hal_bios32_probe(VOID);
/*
* FUNCTION: Determines if a a bios32 service is present
*/
BOOLEAN Hal_bios32_is_service_present(ULONG service);
#endif /* __INTERNAL_HAL_HAL_H */

Some files were not shown because too many files have changed in this diff Show More