mirror of
https://github.com/reactos/reactos.git
synced 2025-02-24 17:34:57 +00:00
fixed my bug in ZwXXX stubs generation
svn path=/trunk/; revision=557
This commit is contained in:
parent
1e589af8e1
commit
3d0fe049f6
1 changed files with 48 additions and 33 deletions
|
@ -1,4 +1,4 @@
|
|||
/* $Id: genntdll.c,v 1.6 1999/06/17 00:10:30 ea Exp $
|
||||
/* $Id: genntdll.c,v 1.7 1999/06/17 18:09:27 ea Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS version of ntdll
|
||||
|
@ -9,6 +9,8 @@
|
|||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -18,13 +20,12 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
|
||||
#define PARAMETERIZED_LIBS
|
||||
|
||||
#define VERBOSE
|
||||
|
||||
#define INPUT_BUFFER_SIZE 255
|
||||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
int
|
||||
|
@ -35,16 +36,14 @@ process(
|
|||
FILE * out3
|
||||
)
|
||||
{
|
||||
char line [255];
|
||||
char line [INPUT_BUFFER_SIZE];
|
||||
char * s;
|
||||
char * name; /* NtXXX name */
|
||||
char * name2; /* ZwXXX name */
|
||||
int value;
|
||||
int sys_call_idx; /* NtXXX index number in the service table */
|
||||
char * nr_args; /* stack_size / machine_word_size */
|
||||
char * stmp;
|
||||
|
||||
unsigned char first1 = TRUE;
|
||||
|
||||
/*
|
||||
* NTDLL stubs file header
|
||||
*/
|
||||
|
@ -63,7 +62,6 @@ process(
|
|||
*/
|
||||
fprintf(out3,"// Machine generated, 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
|
||||
|
@ -74,28 +72,47 @@ process(
|
|||
* STACK_SIZE (in machine words: for x[3456]86
|
||||
* processors a machine word is 4 bytes)
|
||||
*/
|
||||
value = 0;
|
||||
while (!feof(in) && fgets(line,255,in) != NULL)
|
||||
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++
|
||||
)
|
||||
{
|
||||
//fgets(line,255,in);
|
||||
if ((s=(char *)strchr(line,13))!=NULL)
|
||||
/*
|
||||
* Remove, if present, the trailing CR.
|
||||
* (os specific?)
|
||||
*/
|
||||
if ((s = (char *) strchr(line,'\r')) != NULL)
|
||||
{
|
||||
*s=0;
|
||||
*s = '\0';
|
||||
}
|
||||
/*
|
||||
* Skip comments (#) and empty lines.
|
||||
*/
|
||||
s = & line[0];
|
||||
if ((*s)!='#' && (*s) != 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");
|
||||
|
||||
if ((stmp=strchr(nr_args,'\n'))!=NULL)
|
||||
/*
|
||||
* Remove, if present, the trailing LF.
|
||||
*/
|
||||
if ((stmp = strchr(nr_args, '\n')) != NULL)
|
||||
{
|
||||
*stmp=0;
|
||||
*stmp = '\0';
|
||||
}
|
||||
#ifdef VERBOSE
|
||||
printf("name = \"%s\" value = %d\n",name,value);
|
||||
printf("name = \"%s\" value = %d\n",name,sys_call_idx);
|
||||
#endif
|
||||
/*
|
||||
* Write the NTDLL stub for the current
|
||||
|
@ -113,26 +130,24 @@ process(
|
|||
fprintf(out,"\"_%s:\\n\\t\"\n",name);
|
||||
fprintf(out,"\"_%s:\\n\\t\"\n",name2);
|
||||
#endif
|
||||
fprintf(out,"\t\"mov\t$%d,%%eax\\n\\t\"\n",value);
|
||||
fprintf(out,"\t\"mov\t$%d,%%eax\\n\\t\"\n",sys_call_idx);
|
||||
fprintf(out,"\t\"lea\t4(%%esp),%%edx\\n\\t\"\n");
|
||||
fprintf(out,"\t\"int\t$0x2E\\n\\t\"\n");
|
||||
fprintf(out,"\t\"ret\t$%s\\n\\t\");\n\n",nr_args);
|
||||
|
||||
/*
|
||||
* Mark the end of the previous service
|
||||
* table's element (C array syntax). When
|
||||
* the current function is the n-th, we
|
||||
* close the (n - 1)-th entry.
|
||||
*/
|
||||
if (sys_call_idx > 0)
|
||||
{
|
||||
fprintf(out2,",\n");
|
||||
}
|
||||
/*
|
||||
* Now write the current system call's name
|
||||
* in the service table.
|
||||
*/
|
||||
value++;
|
||||
|
||||
if (first1 == TRUE)
|
||||
{
|
||||
first1 = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(out2,",\n");
|
||||
}
|
||||
|
||||
fprintf(out2,"\t\t{ %s, (ULONG)%s }",nr_args,name);
|
||||
/*
|
||||
* Now write the NTOSKRNL stub for the
|
||||
|
@ -142,13 +157,13 @@ process(
|
|||
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\"mov\t$%d,%%eax\\n\\t\"\n",value);
|
||||
fprintf(out3,"\t\"mov\t$%d,%%eax\\n\\t\"\n",sys_call_idx);
|
||||
fprintf(out3,"\t\"lea\t4(%%esp),%%edx\\n\\t\"\n");
|
||||
fprintf(out3,"\t\"int\t$0x2E\\n\\t\"\n");
|
||||
fprintf(out3,"\t\"ret\t$%s\\n\\t\");\n\n",nr_args);
|
||||
}
|
||||
}
|
||||
|
||||
/* Close the service table (C syntax) */
|
||||
fprintf(out2,"\n};\n");
|
||||
|
||||
return(0);
|
||||
|
|
Loading…
Reference in a new issue