diff --git a/reactos/iface/native/genntdll.c b/reactos/iface/native/genntdll.c
index 3abaee83303..c82860f08fe 100644
--- a/reactos/iface/native/genntdll.c
+++ b/reactos/iface/native/genntdll.c
@@ -359,34 +359,34 @@ int main(int argc, char* argv[])
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");
+ out1 = fopen(argv[1],"wb");
if (out1 == NULL)
{
perror("Failed to open output file (NTDLL stubs)");
return(1);
}
- out2 = fopen(argv[3],"wb");
+ out2 = fopen(argv[2],"wb");
if (out2 == NULL)
{
perror("Failed to open output file (NTOSKRNL service table)");
return(1);
}
- out3 = fopen(argv[4],"wb");
+ out3 = fopen(argv[3],"wb");
if (out3 == NULL)
{
perror("Failed to open output file (NTOSKRNL Zw stubs)");
return(1);
}
+ in = fopen(argv[4],"rb");
+ if (in == NULL)
+ {
+ perror("Failed to open input file (system calls database)");
+ return(1);
+ }
+
ret = process(in,out1,out2,out3);
rewind(in);
ret = makeSystemServiceTable(in, out2);
diff --git a/reactos/iface/native/module.xml b/reactos/iface/native/module.xml
index 263d8e50918..2b4aa5f6dbd 100644
--- a/reactos/iface/native/module.xml
+++ b/reactos/iface/native/module.xml
@@ -1,4 +1,14 @@
.
genntdll.c
+
+
+ sysfuncs.lst
+
+
+
diff --git a/reactos/ntoskrnl/ntoskrnl.xml b/reactos/ntoskrnl/ntoskrnl.xml
index 8a8fa4a895c..9e81e5f4a1b 100644
--- a/reactos/ntoskrnl/ntoskrnl.xml
+++ b/reactos/ntoskrnl/ntoskrnl.xml
@@ -1,11 +1,13 @@
buildno
+ genntdll
wmc
- ./include
+ 32
+ include
include
kjs
@@ -34,6 +36,7 @@
rtlfunc.c
+
+
+
dbgctrl.c
errinfo.c
@@ -75,11 +83,13 @@
user.c
+
btree.c
callback.c
fmutex.c
diff --git a/reactos/tools/rbuild/backend/mingw/modulehandler.cpp b/reactos/tools/rbuild/backend/mingw/modulehandler.cpp
index e3374174f5c..4c6e34abbfd 100644
--- a/reactos/tools/rbuild/backend/mingw/modulehandler.cpp
+++ b/reactos/tools/rbuild/backend/mingw/modulehandler.cpp
@@ -50,6 +50,15 @@ MingwModuleHandler::GetWorkingDirectory () const
return ".";
}
+string
+MingwModuleHandler::GetExtension ( const string& filename ) const
+{
+ size_t index = filename.find_last_of ( '.' );
+ if (index != string::npos)
+ return filename.substr ( index );
+ return "";
+}
+
string
MingwModuleHandler::ReplaceExtension ( const string& filename,
const string& newExtension ) const
@@ -245,6 +254,54 @@ MingwModuleHandler::GenerateGccParameters ( const Module& module ) const
return parameters;
}
+string
+MingwModuleHandler::GenerateGccCommand ( const Module& module,
+ const string& sourceFilename,
+ const string& cc ) const
+{
+ string objectFilename = GetObjectFilename ( sourceFilename );
+ return ssprintf ( "%s -c %s -o %s %s\n",
+ cc.c_str (),
+ sourceFilename.c_str (),
+ objectFilename.c_str (),
+ GenerateGccParameters ( module ).c_str () );
+}
+
+string
+MingwModuleHandler::GenerateGccAssemblerCommand ( const Module& module,
+ const string& sourceFilename,
+ const string& cc ) const
+{
+ string objectFilename = GetObjectFilename ( sourceFilename );
+ return ssprintf ( "%s -x assembler-with-cpp -c %s -o %s -D__ASM__ %s\n",
+ cc.c_str (),
+ sourceFilename.c_str (),
+ objectFilename.c_str (),
+ GenerateGccParameters ( module ).c_str () );
+}
+
+string
+MingwModuleHandler::GenerateCommand ( const Module& module,
+ const string& sourceFilename,
+ const string& cc ) const
+{
+ string extension = GetExtension ( sourceFilename );
+ if ( extension == ".c" || extension == ".C" )
+ return GenerateGccCommand ( module,
+ sourceFilename,
+ cc );
+ else if ( extension == ".s" || extension == ".S" )
+ return GenerateGccAssemblerCommand ( module,
+ sourceFilename,
+ cc );
+
+ throw InvalidOperationException ( __FILE__,
+ __LINE__,
+ "Unsupported filename extension '%s' in file '%s'",
+ extension.c_str (),
+ sourceFilename.c_str () );
+}
+
void
MingwModuleHandler::GenerateObjectFileTargets ( const Module& module,
const string& cc) const
@@ -263,11 +320,10 @@ MingwModuleHandler::GenerateObjectFileTargets ( const Module& module,
objectFilename.c_str (),
sourceFilename.c_str () );
fprintf ( fMakefile,
- "\t%s -c %s -o %s %s\n",
- cc.c_str (),
- sourceFilename.c_str (),
- objectFilename.c_str (),
- GenerateGccParameters ( module ).c_str () );
+ "\t%s\n",
+ GenerateCommand ( module,
+ sourceFilename,
+ cc ).c_str () );
}
fprintf ( fMakefile, "\n" );
@@ -502,7 +558,8 @@ MingwKernelModuleHandler::GenerateKernelModuleTarget ( const Module& module )
archiveFilename.c_str (),
importLibraryDependencies.c_str () );
fprintf ( fMakefile,
- "\t${gcc} -Wl,--base-file,%s -o %s %s %s\n",
+ "\t${gcc} -Wl,--entry,_NtProcessStartup -Wl,-T,%s" SSEP "ntoskrnl.lnk -Wl,--subsystem,native -Wl,--image-base,0xC0000000 -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -Wl,--base-file,%s -nostartfiles -o %s %s %s\n",
+ module.GetBasePath ().c_str (),
base_tmp.c_str (),
junk_tmp.c_str (),
archiveFilename.c_str (),
diff --git a/reactos/tools/rbuild/backend/mingw/modulehandler.h b/reactos/tools/rbuild/backend/mingw/modulehandler.h
index 36f5a552a72..c0173e71c38 100644
--- a/reactos/tools/rbuild/backend/mingw/modulehandler.h
+++ b/reactos/tools/rbuild/backend/mingw/modulehandler.h
@@ -17,7 +17,8 @@ public:
virtual void Process ( const Module& module ) = 0;
protected:
- std::string MingwModuleHandler::GetWorkingDirectory () const;
+ std::string GetWorkingDirectory () const;
+ std::string GetExtension ( const std::string& filename ) const;
std::string ReplaceExtension ( const std::string& filename,
const std::string& newExtension ) const;
std::string GetModuleArchiveFilename ( const Module& module ) const;
@@ -46,6 +47,15 @@ private:
void GenerateGccModuleIncludeVariable ( const Module& module ) const;
std::string GenerateGccIncludeParameters ( const Module& module ) const;
std::string GenerateGccParameters ( const Module& module ) const;
+ std::string GenerateGccCommand ( const Module& module,
+ const std::string& sourceFilename,
+ const std::string& cc ) const;
+ std::string GenerateGccAssemblerCommand ( const Module& module,
+ const std::string& sourceFilename,
+ const std::string& cc ) const;
+ std::string GenerateCommand ( const Module& module,
+ const std::string& sourceFilename,
+ const std::string& cc ) const;
void GenerateObjectFileTargets ( const Module& module,
const std::string& cc ) const;
void GenerateArchiveTarget ( const Module& module,
diff --git a/reactos/tools/rbuild/exception.cpp b/reactos/tools/rbuild/exception.cpp
index 99df90e15da..3927e2d81f1 100644
--- a/reactos/tools/rbuild/exception.cpp
+++ b/reactos/tools/rbuild/exception.cpp
@@ -34,13 +34,31 @@ void Exception::SetMessage ( const char* message,
InvalidOperationException::InvalidOperationException ( const char* filename,
- const int linenumber)
+ const int linenumber )
{
Message = ssprintf ( "%s:%d",
filename,
linenumber );
}
+InvalidOperationException::InvalidOperationException ( const char* filename,
+ const int linenumber,
+ const char* message,
+ ... )
+{
+ string errorMessage;
+ va_list args;
+ va_start ( args,
+ message );
+ errorMessage = ssvprintf ( message,
+ args );
+ va_end ( args );
+ Message = ssprintf ( "%s:%d %s",
+ filename,
+ linenumber,
+ errorMessage.c_str () );
+}
+
FileNotFoundException::FileNotFoundException ( const string& filename )
: Exception ( "File '%s' not found.",
diff --git a/reactos/tools/rbuild/exception.h b/reactos/tools/rbuild/exception.h
index 465d300b3df..5574d63f7a8 100644
--- a/reactos/tools/rbuild/exception.h
+++ b/reactos/tools/rbuild/exception.h
@@ -22,6 +22,10 @@ class InvalidOperationException : public Exception
public:
InvalidOperationException ( const char* filename,
const int linenumber);
+ InvalidOperationException ( const char* filename,
+ const int linenumber,
+ const char* message,
+ ... );
};