From 014ff8c89462f36d4067ba2ebc3e21c844c6e17c Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Wed, 9 Feb 2011 01:07:30 +0000 Subject: [PATCH] [NCI] Ue macros for the other nci generated files, too and delete nci-tool. svn path=/trunk/; revision=50625 --- reactos/dll/ntdll/ntdll.rbuild | 3 - reactos/lib/lib.rbuild | 3 - reactos/lib/ntdllsys/ntdllsys.rbuild | 7 - reactos/ntoskrnl/ex/zw.S | 2 +- reactos/ntoskrnl/include/internal/napi.h | 22 + reactos/ntoskrnl/{ex => include}/sysfuncs.h | 0 reactos/ntoskrnl/ntdll.S | 12 + reactos/ntoskrnl/ntoskrnl.rbuild | 4 + reactos/tools/nci/nci.mak | 91 --- reactos/tools/nci/ncitool.c | 762 -------------------- reactos/tools/tools.mak | 1 - 11 files changed, 39 insertions(+), 868 deletions(-) delete mode 100644 reactos/lib/ntdllsys/ntdllsys.rbuild create mode 100644 reactos/ntoskrnl/include/internal/napi.h rename reactos/ntoskrnl/{ex => include}/sysfuncs.h (100%) create mode 100644 reactos/ntoskrnl/ntdll.S delete mode 100644 reactos/tools/nci/nci.mak delete mode 100644 reactos/tools/nci/ncitool.c diff --git a/reactos/dll/ntdll/ntdll.rbuild b/reactos/dll/ntdll/ntdll.rbuild index 0a09528d93f..2a0b9101df3 100644 --- a/reactos/dll/ntdll/ntdll.rbuild +++ b/reactos/dll/ntdll/ntdll.rbuild @@ -1,9 +1,6 @@ - - - diff --git a/reactos/lib/lib.rbuild b/reactos/lib/lib.rbuild index 8a5e890d55a..90f4ba6050c 100644 --- a/reactos/lib/lib.rbuild +++ b/reactos/lib/lib.rbuild @@ -46,9 +46,6 @@ - - - diff --git a/reactos/lib/ntdllsys/ntdllsys.rbuild b/reactos/lib/ntdllsys/ntdllsys.rbuild deleted file mode 100644 index 920dc148e74..00000000000 --- a/reactos/lib/ntdllsys/ntdllsys.rbuild +++ /dev/null @@ -1,7 +0,0 @@ - - - - - ntdll.S - - diff --git a/reactos/ntoskrnl/ex/zw.S b/reactos/ntoskrnl/ex/zw.S index f4b26793d2a..c619b9e1c43 100644 --- a/reactos/ntoskrnl/ex/zw.S +++ b/reactos/ntoskrnl/ex/zw.S @@ -7,6 +7,6 @@ SyscallId = 0 #define SVC_(name, argcount) STUB_K name, argcount -#include "sysfuncs.h" +#include END diff --git a/reactos/ntoskrnl/include/internal/napi.h b/reactos/ntoskrnl/include/internal/napi.h new file mode 100644 index 00000000000..62205945094 --- /dev/null +++ b/reactos/ntoskrnl/include/internal/napi.h @@ -0,0 +1,22 @@ +/* + * FILE: ntoskrnl/include/internal/napi.h + * COPYRIGHT: GNU GPL, see COPYING in the top level directory + * PURPOSE: System Call Table for Native API + * PROGRAMMER: Timo Kreuzer + */ + +#define SVC_(name, argcount) (ULONG_PTR)Nt##name, +ULONG_PTR MainSSDT[] = { +#include "sysfuncs.h" +}; +#undef SVC_ + +#define SVC_(name, argcount) argcount * sizeof(void *), +UCHAR MainSSPT[] = { +#include "sysfuncs.h" +}; + +#define MIN_SYSCALL_NUMBER 0 +#define NUMBER_OF_SYSCALLS (sizeof(MainSSPT) / sizeof(MainSSPT[0])) +#define MAX_SYSCALL_NUMBER (NUMBER_OF_SYSCALLS - 1) +ULONG MainNumberOfSysCalls = NUMBER_OF_SYSCALLS; diff --git a/reactos/ntoskrnl/ex/sysfuncs.h b/reactos/ntoskrnl/include/sysfuncs.h similarity index 100% rename from reactos/ntoskrnl/ex/sysfuncs.h rename to reactos/ntoskrnl/include/sysfuncs.h diff --git a/reactos/ntoskrnl/ntdll.S b/reactos/ntoskrnl/ntdll.S new file mode 100644 index 00000000000..ec073ac4f8f --- /dev/null +++ b/reactos/ntoskrnl/ntdll.S @@ -0,0 +1,12 @@ + +#include +#include + +.code + +SyscallId = 0 +#define SVC_(name, argcount) STUB_U name, argcount + +#include + +END diff --git a/reactos/ntoskrnl/ntoskrnl.rbuild b/reactos/ntoskrnl/ntoskrnl.rbuild index b8d4defb8f4..6a541aca975 100644 --- a/reactos/ntoskrnl/ntoskrnl.rbuild +++ b/reactos/ntoskrnl/ntoskrnl.rbuild @@ -5,3 +5,7 @@ + + include + ntdll.S + diff --git a/reactos/tools/nci/nci.mak b/reactos/tools/nci/nci.mak deleted file mode 100644 index c168b7d0d9f..00000000000 --- a/reactos/tools/nci/nci.mak +++ /dev/null @@ -1,91 +0,0 @@ -NCI_BASE = $(TOOLS_BASE_)nci -NCI_BASE_ = $(NCI_BASE)$(SEP) -NCI_INT = $(INTERMEDIATE_)$(NCI_BASE) -NCI_INT_ = $(NCI_INT)$(SEP) -NCI_OUT = $(OUTPUT_)$(NCI_BASE) -NCI_OUT_ = $(NCI_OUT)$(SEP) - -$(NCI_INT): | $(TOOLS_INT) - $(ECHO_MKDIR) - ${mkdir} $@ - -ifneq ($(INTERMEDIATE),$(OUTPUT)) -$(NCI_OUT): | $(TOOLS_OUT) - $(ECHO_MKDIR) - ${mkdir} $@ -endif - -NCI_TARGET = \ - $(NCI_OUT_)nci$(EXEPOSTFIX) - -NCI_SOURCES = \ - $(NCI_BASE_)ncitool.c - -NCI_OBJECTS = \ - $(addprefix $(INTERMEDIATE_), $(NCI_SOURCES:.c=.o)) - -NCI_HOST_CFLAGS = -Iinclude $(TOOLS_CFLAGS) - -NCI_HOST_LFLAGS = $(TOOLS_LFLAGS) - -$(NCI_TARGET): $(NCI_OBJECTS) | $(NCI_OUT) - $(ECHO_HOSTLD) - ${host_gcc} $(NCI_OBJECTS) $(NCI_HOST_LFLAGS) -o $@ - -$(NCI_INT_)ncitool.o: $(NCI_BASE_)ncitool.c | $(NCI_INT) - $(ECHO_HOSTCC) - ${host_gcc} $(NCI_HOST_CFLAGS) -c $< -o $@ - -.PHONY: nci -nci: $(NCI_TARGET) - -.PHONY: nci_clean -nci_clean: - -@$(rm) $(NCI_TARGET) $(NCI_OBJECTS) 2>$(NUL) -clean: nci_clean - -# WIN32K.SYS -WIN32K_SVC_DB = subsystems$(SEP)win32$(SEP)win32k$(SEP)w32ksvc.db -WIN32K_SERVICE_TABLE = $(INTERMEDIATE_)subsystems$(SEP)win32$(SEP)win32k$(SEP)include$(SEP)napi.h -WIN32K_STUBS = $(INTERMEDIATE_)lib$(SEP)win32ksys$(SEP)win32k.S - - - -# NTOSKRNL.EXE -KERNEL_SVC_DB = ntoskrnl$(SEP)sysfuncs.lst -KERNEL_SERVICE_TABLE = $(INTERMEDIATE_)ntoskrnl$(SEP)include$(SEP)internal$(SEP)napi.h -NTDLL_STUBS = $(INTERMEDIATE_)lib$(SEP)ntdllsys$(SEP)ntdll.S -KERNEL_STUBS = $(INTERMEDIATE_)ntoskrnl$(SEP)ex$(SEP)zw.S -NT_SPEC = $(INTERMEDIATE_)dll$(SEP)ntdll$(SEP)def$(SEP)ntsys.pspec - -NCI_SERVICE_FILES = \ - $(KERNEL_SERVICE_TABLE) \ - $(WIN32K_SERVICE_TABLE) \ - $(NTDLL_STUBS) \ - $(KERNEL_STUBS) \ - $(WIN32K_STUBS) \ - $(NT_SPEC) - -$(NCI_SERVICE_FILES): $(NCI_TARGET) $(KERNEL_SVC_DB) $(WIN32K_SVC_DB) - $(ECHO_NCI) - ${mkdir} $(INTERMEDIATE_)ntoskrnl$(SEP)include$(SEP)internal 2>$(NUL) - ${mkdir} $(INTERMEDIATE_)lib$(SEP)ntdllsys$(SEP)ntdll 2>$(NUL) - ${mkdir} $(INTERMEDIATE_)ntoskrnl$(SEP)ex$(SEP) 2>$(NUL) - ${mkdir} $(INTERMEDIATE_)subsystems$(SEP)win32$(SEP)win32k$(SEP)include 2>$(NUL) - ${mkdir} $(INTERMEDIATE_)lib$(SEP)win32ksys 2>$(NUL) - ${mkdir} $(INTERMEDIATE_)dll$(SEP)ntdll$(SEP)def 2>$(NUL) - - $(Q)$(NCI_TARGET) -arch $(ARCH) \ - $(KERNEL_SVC_DB) \ - $(WIN32K_SVC_DB) \ - $(KERNEL_SERVICE_TABLE) \ - $(WIN32K_SERVICE_TABLE) \ - $(NTDLL_STUBS) \ - $(KERNEL_STUBS) \ - $(WIN32K_STUBS) \ - $(NT_SPEC) - -.PHONY: nci_service_files_clean -nci_service_files_clean: - -@$(rm) $(NCI_SERVICE_FILES) 2>$(NUL) -clean: nci_service_files_clean diff --git a/reactos/tools/nci/ncitool.c b/reactos/tools/nci/ncitool.c deleted file mode 100644 index ca10a815a5b..00000000000 --- a/reactos/tools/nci/ncitool.c +++ /dev/null @@ -1,762 +0,0 @@ -/* - * FILE: tools/nci/ncitool.c - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: Native Call Interface Support Tool - * PURPOSE: Generates NCI Tables and Stubs. - * PROGRAMMER; Alex Ionescu (alex@relsoft.net) - * CHANGE HISTORY: 14/01/05 - Created. Based on original code by - * KJK::Hyperion and Emanuelle Aliberti. - * - */ - -/* INCLUDE ******************************************************************/ - -#include -#include -#include -#if !defined(__FreeBSD__) && !defined(__APPLE__) -# include -#endif // __FreeBSD__ - -/* DEFINES ****************************************************************/ - -#define INPUT_BUFFER_SIZE 255 -#define Arguments 8 - -/******* Table Indexes ************/ -#define MAIN_INDEX 0x0 -#define WIN32K_INDEX 0x1000 - -/******* Argument List ************/ -/* Databases */ -#define NativeSystemDb 0 -#define NativeGuiDb 1 - -/* Service Tables */ -#define NtosServiceTable 2 -#define Win32kServiceTable 3 - -/* Stub Files */ -#define NtosUserStubs 4 -#define NtosKernelStubs 5 -#define Win32kStubs 6 - -/* Spec Files */ -#define NtSpec 7 - -/********** Stub Code ************/ - -/* - * This stubs calls into KUSER_SHARED_DATA where either a - * sysenter or interrupt is performed, depending on CPU support. - */ -#define UserModeStub_x86 " mov eax, %d\n" \ - " mov ecx, KUSER_SHARED_SYSCALL\n" \ - " call dword ptr [ecx]\n" \ - " ret %d\n\n" - -#define UserModeStub_amd64 " mov eax, %d\n" \ - " mov r10, rcx\n" \ - " syscall\n" \ - " ret %d\n\n" - -#define UserModeStub_ppc " stwu 1,-16(1)\n" \ - " mflr 0\n\t" \ - " stw 0,0(1)\n" \ - " li 0,0x%x\n" \ - " sc\n" \ - " lwz 0,0(1)\n" \ - " mtlr 0\n" \ - " addi 1,1,16\n" \ - " blr\n" - -#define UserModeStub_mips " li $8, KUSER_SHARED_SYSCALL\n" \ - " lw $8,0($8)\n" \ - " j $8\n" \ - " nop\n" - -#define UserModeStub_arm " swi #0x%x\n" \ - " bx lr\n\n" - - -/* - * This stub calls KiSystemService directly with a fake INT2E stack. - * Because EIP is pushed during the call, the handler will return here. - */ -#define KernelModeStub_x86 " mov eax, %d\n" \ - " lea edx, [esp + 4]\n" \ - " pushf\n" \ - " push KGDT_R0_CODE\n" \ - " call _KiSystemService\n" \ - " ret %d\n\n" - -#define KernelModeStub_amd64 " mov eax, %d\n" \ - " call KiSystemService\n" \ - " ret %d\n\n" - -/* For now, use the usermode stub. We'll optimize later */ -#define KernelModeStub_ppc UserModeStub_ppc - -#define KernelModeStub_mips " j KiSystemService\n" \ - " nop\n" - -#define KernelModeStub_arm " mov ip, lr\n" \ - " swi #0x%x\n" \ - " bx ip\n\n" - -/***** Arch Dependent Stuff ******/ -struct ncitool_data_t { - const char *arch; - int args_to_bytes; - const char *km_stub; - const char *um_stub; - const char *global_header; - const char *declaration; -}; - -struct ncitool_data_t ncitool_data[] = { - { "i386", 4, KernelModeStub_x86, UserModeStub_x86, - "PUBLIC _%s@%d\n", "_%s@%d:\n" }, - { "amd64", 4, KernelModeStub_amd64, UserModeStub_amd64, - "PUBLIC %s\n", "%s:\n" }, - { "powerpc", 4, KernelModeStub_ppc, UserModeStub_ppc, - "\t.globl %s\n", "%s:\n" }, - { "mips", 4, KernelModeStub_mips, UserModeStub_mips, - "\t.globl %s\n", "%s:\n" }, - { "arm", 4, KernelModeStub_arm, UserModeStub_arm, - "\t.globl %s\n", "%s:\n" }, - { 0, } -}; -int arch_sel = 0; -#define ARGS_TO_BYTES(x) (x)*(ncitool_data[arch_sel].args_to_bytes) -#define UserModeStub ncitool_data[arch_sel].um_stub -#define KernelModeStub ncitool_data[arch_sel].km_stub -#define GlobalHeader ncitool_data[arch_sel].global_header -#define Declaration ncitool_data[arch_sel].declaration - -/* FUNCTIONS ****************************************************************/ - -/*++ - * WriteFileHeader - * - * Prints out the File Header for a Stub File. - * - * Params: - * StubFile - Stub File to which to write the header. - * - * FileDescription - Description of the Stub file to which to write the header. - * - * FileLocation - Name of the Stub file to which to write the header. - * - * Returns: - * None. - * - * Remarks: - * FileLocation is only used for printing the header. - * - *--*/ -void -WriteFileHeader(FILE * StubFile, - char* FileDescription, - char* FileLocation) -{ - /* This prints out the file header */ - fprintf(StubFile, - "/* FILE: %s\n" - " * COPYRIGHT: See COPYING in the top level directory\n" - " * PURPOSE: %s\n" - " * PROGRAMMER: Computer Generated File. See tools/nci/ncitool.c\n" - " * REMARK: DO NOT EDIT OR COMMIT MODIFICATIONS TO THIS FILE\n" - " */\n\n\n", - - FileDescription, - FileLocation); -} - -/*++ - * WriteStubHeader - * - * Prints out the File Header for a Stub File. - * - * Params: - * StubFile - Stub File to which to write the header. - * - * FileDescription - Description of the Stub file to which to write the header. - * - * FileLocation - Name of the Stub file to which to write the header. - * - * Returns: - * None. - * - * Remarks: - * FileLocation is only used for printing the header. - * - *--*/ -void -WriteStubHeader(FILE* StubFile, - char* SyscallName, - unsigned StackBytes) -{ - /* Export the function */ - fprintf(StubFile, GlobalHeader, SyscallName, StackBytes); - - /* Define it */ - fprintf(StubFile, Declaration, SyscallName, StackBytes); -} - - -/*++ - * WriteKernelModeStub - * - * Prints out the Kernel Mode Stub for a System Call. - * - * Params: - * StubFile - Stub File to which to write the header. - * - * SyscallName - Name of System Call for which to add the stub. - * - * StackBytes - Number of bytes on the stack to return after doing the system call. - * - * SyscallId - Service Descriptor Table ID for this System Call. - * - * Returns: - * None. - * - * Remarks: - * On i386, StackBytes is the number of arguments x 4. - * - *--*/ -void -WriteKernelModeStub(FILE* StubFile, - char* SyscallName, - unsigned StackBytes, - unsigned int SyscallId) -{ - /* Write the Stub Header and export the Function */ - WriteStubHeader(StubFile, SyscallName, StackBytes); - - /* Write the Stub Code */ - fprintf(StubFile, KernelModeStub, SyscallId, StackBytes); -} - -/*++ - * WriteUserModeStub - * - * Prints out the User Mode Stub for a System Call. - * - * Params: - * StubFile - Stub File to which to write the header. - * - * SyscallName - Name of System Call for which to add the stub. - * - * StackBytes - Number of bytes on the stack to return after doing the system call. - * - * SyscallId - Service Descriptor Table ID for this System Call. - * - * Returns: - * None. - * - * Remarks: - * On i386, StackBytes is the number of arguments x 4. - * - *--*/ -void -WriteUserModeStub(FILE* StubFile, - char* SyscallName, - unsigned StackBytes, - unsigned int SyscallId) -{ - /* Write the Stub Header and export the Function */ - WriteStubHeader(StubFile, SyscallName, StackBytes); - - /* Write the Stub Code */ - fprintf(StubFile, UserModeStub, SyscallId, StackBytes); -} - -/*++ - * GetNameAndArgumentsFromDb - * - * Parses an entry from a System Call Database, extracting - * the function's name and arguments that it takes. - * - * Params: - * Line - Entry from the Database to parse. - * - * NtSyscallName - Output string to which to save the Function Name - * - * SyscallArguments - Output string to which to save the number of - * arguments that the function takes. - * - * Returns: - * None. - * - * Remarks: - * On i386, StackBytes is the number of arguments x 4. - * - *--*/ -void -GetNameAndArgumentsFromDb(char Line[], - char ** NtSyscallName, - char ** SyscallArguments) -{ - char *s; - char *stmp; - - /* Remove new line */ - 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 */ - *NtSyscallName = (char *)strtok(s," \t"); - - /* Extract the argument count */ - *SyscallArguments = (char *)strtok(NULL," \t"); - - /* Remove, if present, the trailing LF */ - if ((stmp = strchr(*SyscallArguments, '\n')) != NULL) { - *stmp = '\0'; - } - - } else { - - /* Skip this entry */ - *NtSyscallName = NULL; - *SyscallArguments = NULL; - } -} - -/*++ - * CreateStubs - * - * Parses a System Call Database and creates stubs for all the entries. - * - * Params: - * SyscallDb - System Call Database to parse. - * - * UserModeFiles - Array of Usermode Stub Files to which to write the stubs. - * - * KernelModeFile - Kernelmode Stub Files to which to write the stubs. - * - * Index - Number of first syscall - * - * UserFiles - Number of Usermode Stub Files to create - * - * NeedsZw - Write Zw prefix? - * - * Returns: - * None. - * - * Remarks: - * None. - * - *--*/ -void -CreateStubs(FILE * SyscallDb, - FILE * UserModeFiles[], - FILE * KernelModeFile, - unsigned Index, - unsigned UserFiles, - unsigned NeedsZw) -{ - char Line[INPUT_BUFFER_SIZE]; - char *NtSyscallName; - char *SyscallArguments; - int SyscallId; - unsigned StackBytes; - unsigned int i; - - /* We loop, incrementing the System Call Index, until the end of the file */ - for (SyscallId = 0; ((!feof(SyscallDb)) && (fgets(Line, sizeof(Line), SyscallDb) != NULL));) { - - /* Extract the Name and Arguments */ - GetNameAndArgumentsFromDb(Line, &NtSyscallName, &SyscallArguments); - if (SyscallArguments != NULL) - StackBytes = ARGS_TO_BYTES(strtoul(SyscallArguments, NULL, 0)); - else - StackBytes = 0; - - /* Make sure we really extracted something */ - if (NtSyscallName) { - - /* Create Usermode Stubs for Nt/Zw syscalls in each Usermode file */ - for (i= 0; i < UserFiles; i++) { - - /* Write the Stub Header and export the Function */ - WriteStubHeader(UserModeFiles[i], NtSyscallName, StackBytes); - - /* If a Zw Version is needed (was specified), write it too */ - if (NeedsZw) { - - NtSyscallName[0] = 'Z'; - NtSyscallName[1] = 'w'; - - /* Write the Stub Header and export the Function */ - WriteStubHeader(UserModeFiles[i], NtSyscallName, StackBytes); - } - - /* Write the Stub Code */ - fprintf(UserModeFiles[i], UserModeStub, SyscallId | Index, StackBytes); - } - - /* Create the Kernel coutnerparts (only Zw*, Nt* are the real functions!) */ - if (KernelModeFile) { - - NtSyscallName[0] = 'Z'; - NtSyscallName[1] = 'w'; - WriteKernelModeStub(KernelModeFile, - NtSyscallName, - StackBytes, - SyscallId | Index); - } - - /* Only increase if we actually added something */ - SyscallId++; - } - } - -#if defined(_MSC_VER) - for (i= 0; i < UserFiles; i++) fprintf(UserModeFiles[i], "END\n"); - fprintf(KernelModeFile, "END\n"); -#endif -} - -/*++ - * CreateSystemServiceTable - * - * Parses a System Call Database and creates a System Call Service Table for it. - * - * Params: - * SyscallDb - System Call Database to parse. - * - * SyscallTable - File in where to create System Call Service Table. - * - * Name - Name of the Service Table. - * - * FileLocation - Filename containing the Table. - * - * Returns: - * None. - * - * Remarks: - * FileLocation is only used for the header generation. - * - *--*/ -void -CreateSystemServiceTable(FILE *SyscallDb, - FILE *SyscallTable, - char * Name, - char * FileLocation) -{ - char Line[INPUT_BUFFER_SIZE]; - char *NtSyscallName; - char *SyscallArguments; - int SyscallId; - - /* Print the Header */ - WriteFileHeader(SyscallTable, "System Call Table for Native API", FileLocation); - - /* First we build the SSDT */ - fprintf(SyscallTable,"\n\n\n"); - fprintf(SyscallTable,"ULONG_PTR %sSSDT[] = {\n", Name); - - /* We loop, incrementing the System Call Index, until the end of the file */ - for (SyscallId = 0; ((!feof(SyscallDb)) && (fgets(Line, sizeof(Line), SyscallDb) != NULL));) { - - /* Extract the Name and Arguments */ - GetNameAndArgumentsFromDb(Line, &NtSyscallName, &SyscallArguments); - - /* Make sure we really extracted something */ - if (NtSyscallName) { - - /* Add a new line */ - if (SyscallId > 0) fprintf(SyscallTable,",\n"); - - /* Write the syscall name in the service table. */ - fprintf(SyscallTable,"\t\t(ULONG_PTR)%s", NtSyscallName); - - /* Only increase if we actually added something */ - SyscallId++; - } - } - - /* Close the service table (C syntax) */ - fprintf(SyscallTable,"\n};\n"); - - /* Now we build the SSPT */ - rewind(SyscallDb); - fprintf(SyscallTable,"\n\n\n"); - fprintf(SyscallTable,"UCHAR %sSSPT[] = {\n", Name); - - for (SyscallId = 0; ((!feof(SyscallDb)) && (fgets(Line, sizeof(Line), SyscallDb) != NULL));) { - - /* Extract the Name and Arguments */ - GetNameAndArgumentsFromDb(Line, &NtSyscallName, &SyscallArguments); - - /* Make sure we really extracted something */ - if (NtSyscallName) { - - /* Add a new line */ - if (SyscallId > 0) fprintf(SyscallTable,",\n"); - - /* Write the syscall arguments in the argument table. */ - if (SyscallArguments != NULL) - fprintf(SyscallTable,"\t\t%lu * sizeof(void *)",strtoul(SyscallArguments, NULL, 0)); - else - fprintf(SyscallTable,"\t\t0"); - - /* Only increase if we actually added something */ - SyscallId++; - } - } - - /* Close the service table (C syntax) */ - fprintf(SyscallTable,"\n};\n"); - - /* - * We write some useful defines - */ - fprintf(SyscallTable, "\n\n#define MIN_SYSCALL_NUMBER 0\n"); - fprintf(SyscallTable, "#define MAX_SYSCALL_NUMBER %d\n", SyscallId - 1); - fprintf(SyscallTable, "#define NUMBER_OF_SYSCALLS %d\n", SyscallId); - fprintf(SyscallTable, "ULONG %sNumberOfSysCalls = %d;\n", Name, SyscallId); -} - -/*++ - * WriteSpec - * - * Prints out the Spec Entry for a System Call. - * - * Params: - * SpecFile - Spec File to which to write the header. - * - * SyscallName - Name of System Call for which to add the stub. - * - * CountArguments - Number of arguments to the System Call. - * - * Returns: - * None. - * - * Remarks: - * None. - * - *--*/ -void -WriteSpec(FILE* StubFile, - char* SyscallName, - unsigned CountArguments) -{ - unsigned i; - - fprintf(StubFile, "@ stdcall %s", SyscallName); - - fputc ('(', StubFile); - - for (i = 0; i < CountArguments; ++ i) - fputs ("ptr ", StubFile); - - fputc (')', StubFile); - fputc ('\n', StubFile); -} - -/*++ - * CreateSpec - * - * Parses a System Call Database and creates a spec file for all the entries. - * - * Params: - * SyscallDb - System Call Database to parse. - * - * Files - Array of Spec Files to which to write. - * - * CountFiles - Number of Spec Files to create - * - * UseZw - Use Zw prefix? - * - * Returns: - * None. - * - * Remarks: - * None. - * - *--*/ -void -CreateSpec(FILE * SyscallDb, - FILE * Files[], - unsigned CountFiles, - unsigned UseZw) -{ - char Line[INPUT_BUFFER_SIZE]; - char *NtSyscallName; - char *SyscallArguments; - unsigned CountArguments; - - /* We loop until the end of the file */ - while ((!feof(SyscallDb)) && (fgets(Line, sizeof(Line), SyscallDb) != NULL)) { - - /* Extract the Name and Arguments */ - GetNameAndArgumentsFromDb(Line, &NtSyscallName, &SyscallArguments); - CountArguments = strtoul(SyscallArguments, NULL, 0); - - /* Make sure we really extracted something */ - if (NtSyscallName) { - - unsigned int i; - for (i= 0; i < CountFiles; i++) { - - if (!UseZw) { - WriteSpec(Files[i], - NtSyscallName, - CountArguments); - } - - if (UseZw && NtSyscallName[0] == 'N' && NtSyscallName[1] == 't') { - - NtSyscallName[0] = 'Z'; - NtSyscallName[1] = 'w'; - WriteSpec(Files[i], - NtSyscallName, - CountArguments); - } - - } - } - } -} - -void usage(char * argv0) -{ - printf("Usage: %s [-arch ] sysfuncs.lst w32ksvc.db napi.h ssdt.h napi.S zw.S win32k.S win32k.S\n" - " sysfuncs.lst native system functions database\n" - " w32ksvc.db native graphic functions database\n" - " napi.h NTOSKRNL service table\n" - " ssdt.h WIN32K service table\n" - " napi.S NTDLL stubs\n" - " zw.S NTOSKRNL Zw stubs\n" - " win32k.S GDI32 stubs\n" - " win32k.S USER32 stubs\n" - " nt.pspec NTDLL exports\n" - " -arch is optional, default is %s\n", - argv0, - ncitool_data[0].arch - ); -} - -int main(int argc, char* argv[]) -{ - FILE * Files[Arguments] = {0}; - int FileNumber, ArgOffset = 1; - char * OpenType = "r"; - - /* Catch architecture argument */ - if (argc > 3 && !strcmp(argv[1],"-arch")) { - for( arch_sel = 0; ncitool_data[arch_sel].arch; arch_sel++ ) - if (strcmp(argv[2],ncitool_data[arch_sel].arch) == 0) - break; - if (!ncitool_data[arch_sel].arch) { - printf("Invalid arch '%s'\n", argv[2]); - usage(argv[0]); - return 1; - } - ArgOffset = 3; - } - /* Make sure all arguments all there */ - if (argc != Arguments + ArgOffset) { - usage(argv[0]); - return(1); - } - - /* Open all Output and bail out if any fail */ - for (FileNumber = 0; FileNumber < Arguments; FileNumber++) { - - /* Open the File */ - if (FileNumber == 2) OpenType = "wb"; - Files[FileNumber] = fopen(argv[FileNumber + ArgOffset], OpenType); - - /* Check for failure and error out if so */ - if (!Files[FileNumber]) { - perror(argv[FileNumber + ArgOffset]); - return (1); - } - } - - /* Write the File Headers */ - WriteFileHeader(Files[NtosUserStubs], - "System Call Stubs for Native API", - argv[NtosUserStubs + ArgOffset]); - fputs("#include \n" - "#include \n" - ".code\n\n", Files[NtosUserStubs]); - - WriteFileHeader(Files[NtosKernelStubs], - "System Call Stubs for Native API", - argv[NtosKernelStubs + ArgOffset]); - fputs("#include \n" - "#include \n" - ".code\n" - "EXTERN _KiSystemService:PROC\n\n", Files[NtosKernelStubs]); - - WriteFileHeader(Files[Win32kStubs], - "System Call Stubs for Native API", - argv[Win32kStubs + ArgOffset]); - fputs("#include \n" - "#include \n" - ".code\n\n", Files[Win32kStubs]); - - /* Create the System Stubs */ - CreateStubs(Files[NativeSystemDb], - &Files[NtosUserStubs], - Files[NtosKernelStubs], - MAIN_INDEX, - 1, - 1); - - /* Create the Graphics Stubs */ - CreateStubs(Files[NativeGuiDb], - &Files[Win32kStubs], - NULL, - WIN32K_INDEX, - 1, - 0); - - /* Create the Service Tables */ - rewind(Files[NativeSystemDb]); - CreateSystemServiceTable(Files[NativeSystemDb], - Files[NtosServiceTable], - "Main", - argv[NtosServiceTable + ArgOffset]); - - rewind(Files[NativeGuiDb]); - CreateSystemServiceTable(Files[NativeGuiDb], - Files[Win32kServiceTable], - "Win32k", - argv[Win32kServiceTable + ArgOffset]); - - /* Create the Spec Files */ - rewind(Files[NativeSystemDb]); - CreateSpec(Files[NativeSystemDb], - &Files[NtSpec], - 1, - 0); - - rewind(Files[NativeSystemDb]); - CreateSpec(Files[NativeSystemDb], - &Files[NtSpec], - 1, - 1); - - /* Close all files */ - for (FileNumber = 0; FileNumber < Arguments-ArgOffset; FileNumber++) { - - /* Close the File */ - fclose(Files[FileNumber]); - - } - - return(0); -} - diff --git a/reactos/tools/tools.mak b/reactos/tools/tools.mak index db4d27eb742..d2d846c749c 100644 --- a/reactos/tools/tools.mak +++ b/reactos/tools/tools.mak @@ -45,7 +45,6 @@ include tools/buildno/buildno.mak include tools/gendib/gendib.mak include tools/log2lines/log2lines.mak include tools/pipetools/pipetools.mak -include tools/nci/nci.mak ifeq ($(ARCH),powerpc) include tools/ofw_interface/ofw_interface.mak endif