-0.0.14 (so far):
+0.0.14 (so far):
0.0.13: Mostly bugfixes (I think)
--- /dev/null
+#include <internal/mmhal.h>
+
+#include <ddk/ntddk.h>
+#include <stdarg.h>
+#include <string.h>
+
+HANDLE OutputHandle;
+HANDLE InputHandle;
+
+void debug_printf(char* fmt, ...)
+{
+ va_list args;
+ char buffer[255];
+
+ va_start(args,fmt);
+ vsprintf(buffer,fmt,args);
+ WriteConsoleA(OutputHandle, buffer, strlen(buffer), NULL, NULL);
+ va_end(args);
+}
+
+
+void main(int argc, char* argv[])
+{
+ int i;
+
+ AllocConsole();
+ InputHandle = GetStdHandle(STD_INPUT_HANDLE);
+ OutputHandle = GetStdHandle(STD_OUTPUT_HANDLE);
+
+ for (i=0; i<argc; i++)
+ {
+ debug_printf("Args: '%s'\n",argv[i]);
+ }
+}
+
--- /dev/null
+all: args.bin
+
+OBJECTS= ../common/crt0.o args.o
+LIBS= ../../lib/kernel32/kernel32.a ../../lib/ntdll/ntdll.a
+
+args.bin: $(OBJECTS) $(LIBS)
+ $(CC) -specs=../../specs -Ttext 0x10000 $(OBJECTS) $(LIBS) -lgcc \
+ -o args.exe
+ $(NM) --numeric-sort args.exe > args.sym
+ ../../ntoskrnl/utils/pe2bin/pe2bin$(EXE_POSTFIX) 0x10000 args.exe \
+ args.bin
-all: shell.bin
+all: shell.exe
OBJECTS= ../common/crt0.o shell.o
-LIBS= ../../lib/kernel32/kernel32.a ../../lib/ntdll/ntdll.a ../../ntoskrnl/libgcc.a
+LIBS= ../../lib/kernel32/kernel32.a ../../lib/ntdll/ntdll.a
-shell.bin: $(OBJECTS) $(LIBS)
- $(LD) -Ttext 0x10000 $(OBJECTS) $(LIBS) -o shell.exe
+shell.exe: $(OBJECTS) $(LIBS)
+ $(CC) -specs=../../specs $(OBJECTS) $(LIBS) -lgcc -o shell.exe
$(NM) --numeric-sort shell.exe > shell.sym
- $(OBJCOPY) -O binary shell.exe shell.bin
include ../../rules.mak
debug_printf("<REP> "),nRep++;
else
debug_printf(" %10d ",FindData.nFileSizeLow),nFile++;
- RtlTimeToTimeFields(&FindData.ftLastWriteTime ,&fTime);
- debug_printf("%02d/%02d/%04d %02d:%02d:%02d "
- ,fTime.Month,fTime.Day,fTime.Year
- ,fTime.Hour,fTime.Minute,fTime.Second);
+ // RtlTimeToTimeFields(&FindData.ftLastWriteTime ,&fTime);
+// debug_printf("%02d/%02d/%04d %02d:%02d:%02d "
+// ,fTime.Month,fTime.Day,fTime.Year
+// ,fTime.Hour,fTime.Minute,fTime.Second);
debug_printf("%s\n",FindData.cFileName);
} while(FindNextFile(shandle,&FindData));
debug_printf("\n %d files\n %d directories\n\n",nFile,nRep);
ExecuteType(tail);
return;
}
+ if (strcmp(cmd,"exit")==0)
+ {
+ ExitProcess(0);
+ return;
+ }
if (ExecuteProcess(cmd,tail))
{
return;
-loaders\dos\loadros ntoskrnl\kimage.bin services\dd\ide\ide.o services\fs\vfat\vfatfsd.o services\dd\keyboard\keyboard.o ext2fs.sys
+loadros kimage.bin ide.o vfatfsd.o keyboard.o
:
: copy files to HD...
:
-COPY /Y SHELL.BIN C:\reactos\system\SHELL.bin
-COPY /Y BLUES.o C:\reactos\system\drivers\BLUES.o
-COPY /Y KEYBOARD.o C:\reactos\system\drivers\KEYBOARD.o
+COPY /Y BLUE.SYS C:\reactos\system\drivers\blue.SYS
+COPY /Y KEYBOARD.SYS C:\reactos\system\drivers\KEYBOARD.SYS
+COPY /Y NTDLL.DLL C:\reactos\system\NTDLL.DLL
+: COPY /Y CRTDLL.DLL C:\reactos\system\CRTDLL.DLL
+COPY /Y SHELL.EXE C:\reactos\system\SHELL.EXE
:
: present a menu to the booter...
ECHO 1) Keyboard,IDE,VFatFSD
ECHO 2) IDE,VFatFSD
ECHO 3) No Drivers
-CHOICE /C:123 /T:2,10 "Select kernel boot config"
+CHOICE /C:123 /T:2,3 "Select kernel boot config"
IF ERRORLEVEL 3 GOTO :L3
IF ERRORLEVEL 2 GOTO :L2
:L1
CLS
-LOADROS KIMAGE.BIN KEYBOARD.O IDE.O VFATFSD.O
+LOADROS NTOSKRNL.EXE KEYBOARD.O IDE.SYS VFATFSD.SYS
GOTO :END
:L2
CLS
-LOADROS KIMAGE.BIN IDE.O VFATFSD.O
+LOADROS NTOSKRNL.EXE IDE.SYS VFATFSD.SYS
GOTO :END
:L3
CLS
-LOADROS KIMAGE.BIN
+LOADROS NTOSKRNL.EXE
GOTO :END
:END
--- /dev/null
+base.tmp
+junk.tmp
+temp.exp
+
-#undef WIN32_LEAN_AND_MEAN
#include <internal/mmhal.h>
#include <internal/halio.h>
#include <ddk/ntddk.h>
+#include <string.h>
#include <internal/string.h>
#include <defines.h>
/*
* Module entry point
*/
-NTSTATUS DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
+STDCALL NTSTATUS
+DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
{
PDEVICE_OBJECT DeviceObject;
ANSI_STRING adevice_name;
--- /dev/null
+#
+#
+#
+
+all: blue.sys
+
+.phony: all
+
+OBJECTS = blue.o ../../../ntoskrnl/ntoskrnl.a
+
+blue.sys: $(OBJECTS)
+ $(CC) -specs=../../svc_specs -mdll -o junk.tmp -Wl,--defsym,_end=end \
+ -Wl,--defsym,_edata=__data_end__ -Wl,--defsym,_etext=etext \
+ -Wl,--base-file,base.tmp $(OBJECTS)
+ - $(RM) junk.tmp
+ $(DLLTOOL) --dllname blue.sys --base-file base.tmp \
+ --output-exp temp.exp
+ - $(RM) base.tmp
+ $(CC) --verbose -Wl,--image-base,0x10000 -Wl,-e,_DriverEntry@8 \
+ -specs=../../svc_specs -mdll -o blue.sys $(OBJECTS) -Wl,temp.exp
+ - $(RM) temp.exp
+
+
}
-// EOF
\ No newline at end of file
+// EOF
}
-// EOF
\ No newline at end of file
+// EOF
--- /dev/null
+base.tmp
+junk.tmp
+temp.exp
// -------------------------------------------------------------------------
#include <internal/i386/io.h>
+#include <string.h>
#include <internal/string.h>
#define NDEBUG
// RETURNS:
// NTSTATUS
-NTSTATUS
+STDCALL NTSTATUS
DriverEntry(IN PDRIVER_OBJECT DriverObject,
IN PUNICODE_STRING RegistryPath)
{
-#
-#
-#
+all: ide.sys
-all: ide.o
+OBJECTS = ide.o ../../../ntoskrnl/ntoskrnl.a
-ide.o: ide.c ide.h idep.h partitio.h
-
-include ../../../rules.mak
+# --def ide.def --def ide.def
+ide.sys: $(OBJECTS)
+ $(DLLTOOL) --dllname ide.sys --output-lib ide.a
+ $(CC) -specs=../../svc_specs -mdll -o junk.tmp -Wl,--defsym,_end=end \
+ -Wl,--defsym,_edata=__data_end__ -Wl,--defsym,_etext=etext \
+ -Wl,--base-file,base.tmp $(OBJECTS)
+ - $(RM) junk.tmp
+ $(DLLTOOL) --dllname ide.sys --base-file base.tmp \
+ --output-exp temp.exp
+ - $(RM) base.tmp
+ $(CC) --verbose -Wl,--image-base,0x10000 -Wl,-e,_DriverEntry@8 -specs=../../svc_specs -mdll -o ide.sys $(OBJECTS) -Wl,temp.exp
+ - $(RM) temp.exp
((P)->PartitionType == PTDosExtended)
typedef struct Partition {
- __u8 BootFlags;
- __u8 StartingHead;
- __u8 StartingSector;
- __u8 StartingCylinder;
- __u8 PartitionType;
- __u8 EndingHead;
- __u8 EndingSector;
- __u8 EndingCylinder;
+ unsigned char BootFlags;
+ unsigned char StartingHead;
+ unsigned char StartingSector;
+ unsigned char StartingCylinder;
+ unsigned char PartitionType;
+ unsigned char EndingHead;
+ unsigned char EndingSector;
+ unsigned char EndingCylinder;
unsigned int StartingBlock;
unsigned int SectorCount;
--- /dev/null
+base.tmp
+junk.tmp
+temp.exp
+
**
*/
-#undef WIN32_LEAN_AND_MEAN
#include <internal/mmhal.h>
#include <internal/halio.h>
#include <ddk/ntddk.h>
+#include <string.h>
#include <internal/string.h>
#include <defines.h>
/*
* Module entry point
*/
-NTSTATUS DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
+STDCALL NTSTATUS
+DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
{
PDEVICE_OBJECT DeviceObject;
ANSI_STRING adevice_name;
-all: keyboard.o
+all: keyboard.sys
+
+OBJECTS = keyboard.o ../../../ntoskrnl/ntoskrnl.a
+
+keyboard.sys: $(OBJECTS)
+ $(CC) -specs=../../svc_specs -mdll -o junk.tmp -Wl,--defsym,_end=end \
+ -Wl,--defsym,_edata=__data_end__ -Wl,--defsym,_etext=etext \
+ -Wl,--base-file,base.tmp $(OBJECTS)
+ - $(RM) junk.tmp
+ $(DLLTOOL) --dllname keyboard.sys --base-file base.tmp \
+ --output-exp temp.exp
+ - $(RM) base.tmp
+ $(CC) --verbose -Wl,--image-base,0x10000 -Wl,-e,_DriverEntry@8 \
+ -specs=../../svc_specs -mdll -o keyboard.sys $(OBJECTS) -Wl,temp.exp
+ - $(RM) temp.exp
while ((inb(base+DSP_WRITE_PORT) & 0x80) != 0);
outb(base+DSP_WRITE_PORT, data);
}
-
\ No newline at end of file
+
if(lo==0x08) sb16->dma8=3;
if(lo==0x02) sb16->dma8=1;
if(lo==0x01) sb16->dma8=0;
-}
\ No newline at end of file
+}
unsigned char dma16;
unsigned char* buffer;
}SB16;
-
\ No newline at end of file
+
void write_wave()
{
-}
\ No newline at end of file
+}
#include <internal/hal/ddk.h>
#include <internal/dma.h>
#include <internal/mm.h>
+#include <string.h>
#include <internal/string.h>
#include <devices.h>
#include "sb16.h"
--- /dev/null
+ULONG OldIRQ;
+PKINTERRUPT IrqObject;
+BOOLEAN DMAOutputISR(PKINTERRUPT Interrupt, PVOID ServiceContext)
+{
+ printk("interrupt\n");
+ return FALSE;
+}
+
+void sb16_play(WAVE_HDR* wave)
+{
+ unsigned int eflags;
+ ULONG MappedIrq;
+ KIRQL Dirql;
+ KAFFINITY Affinity;
+ PKINTERRUPT IrqObject;
+ unsigned int mask,newmask;
+
+ unsigned int i;
+ unsigned int tmp[255];
+ i=0;
+ dump_wav(wave);
+ do
+ {
+ tmp[i++]=get_dma_page(0x0fffff+IDMAP_BASE);
+ printk("0x%x ",tmp[i-1]);
+ }
+ while((tmp[i-1]&0xffff)!=0);
+ free_page((tmp[0])-IDMAP_BASE,i-1);
+ sb16.buffer=((unsigned char*)tmp[i-1]);
+
+ /*
+ * Because this is used by alomost every subsystem including irqs it
+ * must be atomic. The following code sequence disables interrupts after
+ * saving the previous state of the interrupt flag
+ */
+
+ __asm__("pushf\n\tpop %0\n\tcli\n\t"
+ : "=m" (eflags)
+ : );
+
+ memcpy(sb16.buffer,(&wave->data),wave->dLen);
+
+
+ MappedIrq = HalGetInterruptVector(Internal,0,0,8+sb16.irq,&Dirql,&Affinity);
+
+
+
+ IoConnectInterrupt(&IrqObject,DMAOutputISR,0,NULL,MappedIrq,Dirql,Dirql,0,FALSE,Affinity,FALSE);
+
+ mask=inb(0x21);
+ newmask=((int)1<<sb16.irq);
+ outb(0x21,(mask&~newmask));
+
+ // Restore the interrupt flag
+ __asm__("push %0\n\tpopf\n\t"
+ :
+ : "m" (eflags));
+
+
+
+ disable_dma(sb16.dma8);
+ //outb(0x0a,5);
+ clear_dma_ff(1);
+ //outb(0xc,0);
+ set_dma_count(1,wave->dLen);
+ set_dma_mode(1,DMA_MODE_WRITE);
+ //outb(0xb,0x49);
+ //outb(0x3,(wave->dLen)&0xff);
+ //outb(0x3,((unsigned int)(wave->dLen)>>8)&0xff);
+ set_dma_addr(sb16.dma8,(unsigned int)sb16.buffer-IDMAP_BASE);
+ //outb(0x83,(((unsigned int)(sb16.buffer-IDMAP_BASE)>>16))&0xf);
+ //outb(0x2,((unsigned int)sb16.buffer&0xff));
+ //outb(0x2,(((unsigned int)(sb16.buffer-IDMAP_BASE)>>8))&0xff);
+ enable_dma(sb16.dma8);
+ //outb(0xa,1);
+
+ write_dsp(sb16.base,0x00D1);
+
+ write_dsp(sb16.base,0x40);
+ write_dsp(sb16.base,((unsigned char)256-(1000000/wave->nSamplesPerSec)));
+
+ outb(sb16.base + 4, (int) 0xa);
+ outb(sb16.base + 5, (int) 0x00);
+
+ outb(sb16.base + 4, (int) 4);
+ outb(sb16.base + 5, (int) 0xFF);
+
+ outb(sb16.base + 4, (int) 0x22);
+ outb(sb16.base + 5, (int) 0xFF);
+
+ write_dsp(sb16.base,0x14);
+ write_dsp(sb16.base,(wave->dLen&0x00ff));
+ write_dsp(sb16.base,((wave->dLen)&0xff00)>>8);
+
+// write_dsp(sb16.base,0xc0);
+// write_dsp(sb16.base,0x0);
+// OldIRQ=HalGetInterruptVector(Internal,0,0,irq+8,&irql,&affinity);
+// printk("OldIRQ: 0x%x\n",OldIRQ);
+
+// status=IoConnectInterrupt(&IrqObject,playRoutine,0,NULL,OldIRQ,irql,irql,0,FALSE,affinity,FALSE);
+// if(status!=STATUS_SUCCESS) printk("Couldn't set irq\n");
+// else printk("IRQ set\n");
+
+}
+
+void dump_wav(WAVE_HDR* wave)
+{
+ printk("wave.rID: %c%c%c%c\n",wave->rID[0],wave->rID[1],wave->rID[2],wave->rID[3]);
+ printk("wave.rLen: 0x%x\n",wave->rLen);
+ printk("wave.wID: %c%c%c%c\n",wave->wID[0],wave->wID[1],wave->wID[2],wave->wID[3]);
+ printk("wave.fID: %c%c%c%c\n",wave->fID[0],wave->fID[1],wave->fID[2],wave->fID[3]);
+ printk("wave.fLen: 0x%x\n",wave->fLen);
+ printk("wave.wFormatTag: 0x%x\n",wave->wFormatTag);
+ printk("wave.nChannels: 0x%x\n",wave->nChannels);
+ printk("wave.nSamplesPerSec: 0x%x\n",wave->nSamplesPerSec);
+ printk("wave.nAvgBytesPerSec: 0x%x\n",wave->nAvgBytesPerSec);
+ printk("wave.nBlockAlign: 0x%x\n",wave->nBlockAlign);
+ printk("wave.FormatSpecific: 0x%x\n",wave->FormatSpecific);
+ printk("wave.dID: %c%c%c%c\n",wave->dID[0],wave->dID[1],wave->dID[2],wave->dID[3]);
+ printk("wave.dLen: 0x%x\n",wave->dLen);
+}
+
+BOOLEAN playRoutine(PKINTERRUPT Interrupt,PVOID ServiceContext)
+{
+ return FALSE;
+}
void sb16_play(WAVE_HDR* wave);
void dump_wav(WAVE_HDR* wave);
-BOOLEAN playRoutine(PKINTERRUPT Interrupt,PVOID ServiceContext);
\ No newline at end of file
+BOOLEAN playRoutine(PKINTERRUPT Interrupt,PVOID ServiceContext);
--- /dev/null
+base.tmp
+junk.tmp
+temp.exp
+
-all: test.o
+all: test.sys
+
+OBJECTS = test.o ../../../ntoskrnl/ntoskrnl.a
+
+# --def test.def --def test.def
+test.sys: test.o
+ $(DLLTOOL) --dllname test.sys --output-lib test.a
+ $(CC) -specs=$(KM_SPECS) -mdll -o junk.tmp -Wl,--defsym,_end=end \
+ -Wl,--defsym,_edata=__data_end__ -Wl,--defsym,_etext=etext \
+ -Wl,--base-file,base.tmp $(OBJECTS)
+ - $(RM) junk.tmp
+ $(DLLTOOL) --dllname test.sys --base-file base.tmp \
+ --output-exp temp.exp
+ - $(RM) base.tmp
+ $(CC) --verbose -Wl,--image-base,0x10000 -Wl,-e,_DriverEntry -specs=$(KM_SPECS) -mdll -o test.sys $(OBJECTS) -Wl,temp.exp
+ - $(RM) temp.exp
/* FUNCTIONS **************************************************************/
+#if 0
+
NTSTATUS TestWrite(PIRP Irp, PIO_STACK_LOCATION Stk)
{
PVOID Address;
Address = MmGetSystemAddressForMdl(Irp->MdlAddress);
- printk("Asked to write '%s'\n",(PCH)Address);
+ DbgPrint("Asked to write '%s'\n",(PCH)Address);
return(STATUS_SUCCESS);
}
switch (Stack->MajorFunction)
{
case IRP_MJ_CREATE:
- printk("(Test Driver) Creating\n");
+ DbgPrint("(Test Driver) Creating\n");
status = STATUS_SUCCESS;
break;
break;
case IRP_MJ_WRITE:
- printk("(Test Driver) Writing\n");
+ DbgPrint("(Test Driver) Writing\n");
status = TestWrite(Irp,Stack);
break;
return(status);
}
+#endif
+
NTSTATUS DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
/*
* FUNCTION: Called by the system to initalize the driver
ANSI_STRING astr;
UNICODE_STRING ustr;
- printk("Test Driver 0.0.1\n");
-
+ DbgPrint("Test Driver 0.0.1\n");
+
+ #if 0
RtlInitAnsiString(&astr,"\\Device\\Test");
RtlAnsiStringToUnicodeString(&ustr,&astr,TRUE);
ret = IoCreateDevice(DriverObject,0,&ustr,
DriverObject->MajorFunction[IRP_MJ_WRITE] = TestDispatch;
DriverObject->MajorFunction[IRP_MJ_WRITE] = TestDispatch;
DriverObject->DriverUnload = NULL;
-
+ #endif
return(STATUS_SUCCESS);
}
/* INCLUDES *****************************************************************/
#include <ddk/ntddk.h>
+#include <string.h>
#include <internal/string.h>
#define NDEBUG
/* INCLUDES *****************************************************************/
#include <ddk/ntddk.h>
+#include <wchar.h>
#include <internal/string.h>
-#include <wstring.h>
#define NDEBUG
#include <internal/debug.h>
/* INCLUDES *****************************************************************/
#include <ddk/ntddk.h>
-#include <internal/string.h>
-#include <wstring.h>
#define NDEBUG
#include <internal/debug.h>
-OBJECTS = super.o blockdev.o inode.o file.o dir.o rw.o
+all: ext2fs.sys
-all: ext2.o
-
-ext2.o: $(OBJECTS)
- $(LD) -r $(OBJECTS) -o ext2fs.sys
-
-include ../../../rules.mak
+OBJECTS = super.o blockdev.o inode.o file.o dir.o rw.o \
+ ../../../ntoskrnl/ntoskrnl.a
+ext2fs.sys: $(OBJECTS)
+ $(CC) -specs=$(KM_SPECS) -mdll -o junk.tmp -Wl,--defsym,_end=end \
+ -Wl,--defsym,_edata=__data_end__ -Wl,--defsym,_etext=etext \
+ -Wl,--base-file,base.tmp $(OBJECTS)
+ $(RM) junk.tmp
+ $(DLLTOOL) --dllname ext2fs.sys --base-file base.tmp \
+ --output-exp temp.exp
+ $(RM) base.tmp
+ $(CC) --verbose -Wl,--image-base,0x10000 -Wl,-e,_DriverEntry \
+ -specs=$(KM_SPECS) -mdll -o ext2fs.sys $(OBJECTS) -Wl,temp.exp
+ $(RM) temp.exp
/* INCLUDES *****************************************************************/
#include <ddk/ntddk.h>
-#include <internal/string.h>
-#include <wstring.h>
#define NDEBUG
#include <internal/debug.h>
/* INCLUDES *****************************************************************/
#include <ddk/ntddk.h>
+#include <wchar.h>
#include <internal/string.h>
-#include <wstring.h>
#define NDEBUG
#include <internal/debug.h>
/* INCLUDES *****************************************************************/
#include <ddk/ntddk.h>
-#include <internal/string.h>
-#include <wstring.h>
#define NDEBUG
#include <internal/debug.h>
/* INCLUDES *****************************************************************/
#include <ddk/ntddk.h>
+#include <string.h>
#include <internal/string.h>
#define NDEBUG
/* INCLUDES *****************************************************************/
#include <ddk/ntddk.h>
-#include <internal/string.h>
-#include <wstring.h>
#define NDEBUG
#include <internal/debug.h>
/* INCLUDES *****************************************************************/
#include <ddk/ntddk.h>
+#include <string.h>
#include <internal/string.h>
#include <internal/bitops.h>
#include <ddk/ntifs.h>
#include <ddk/ntddk.h>
#include <ddk/ntifs.h>
-#include <internal/string.h>
-#include <wstring.h>
#define NDEBUG
#include <internal/debug.h>
/* INCLUDES *****************************************************************/
#include <ddk/ntddk.h>
-#include <internal/string.h>
-#include <wstring.h>
#define NDEBUG
#include <internal/debug.h>
--- /dev/null
+base.tmp
+junk.tmp
+temp.exp
+
/* INCLUDES *****************************************************************/
#include <ddk/ntddk.h>
-#include <internal/string.h>
-#include <wstring.h>
#define NDEBUG
#include <internal/debug.h>
19-12-1998 : created
*/
-#include <ddk/ntddk.h>
+
+#include <wchar.h>
#include <internal/string.h>
-#include <wstring.h>
+#include <ddk/ntddk.h>
#include <ddk/cctypes.h>
#include <ddk/zwtypes.h>
long long int mult;
Day=wDosDate&0x001f;
Month= (wDosDate&0x00e0)>>5;//1=January
- Year= ((wDosDate&0xfe00)>>9)+1980;
+ Year= ((wDosDate&0xff00)>>8)+1980;
Second=(wDosTime&0x001f)<<1;
Minute=(wDosTime&0x07e0)>>5;
Hour= (wDosTime&0xf100)>>11;
mult *=24;
*pTime +=(Day-1)*mult;
if((Year % 4 == 0 && (Year % 100 != 0 || Year % 400 == 0) ? 1 : 0))
- *pTime += MonthsDF1[1][Month-1]*mult;
+ *pTime += MonthsDF1[1][Month-1];
else
- *pTime += MonthsDF1[0][Month-1]*mult;
- *pTime +=((Year-1601)*365
+ *pTime += MonthsDF1[0][Month-1];
+ *pTime +=(Year-1601)*mult*365
+(Year-1601)/4
-(Year-1601)/100
- +(Year-1601)/400)*mult;
+ +(Year-1601)/400;
return TRUE;
}
#define DosDateTimeToFileTime fsdDosDateTimeToFileTime
PVfatCCB pCcb;
PDEVICE_EXTENSION DeviceExt;
WCHAR star[5],*pCharPattern;
- unsigned long OldEntry;
+ unsigned long OldEntry,OldSector;
DeviceExt = DeviceObject->DeviceExtension;
// Obtain the callers parameters
BufferLength = Stack->Parameters.QueryDirectory.Length;
pFcb = pCcb->pFcb;
if(Stack->Flags & SL_RESTART_SCAN)
{//FIXME : what is really use of RestartScan ?
- pCcb->StartEntry=0;
+ pCcb->StartEntry=pCcb->StartSector=0;
}
// determine Buffer for result :
if (Irp->MdlAddress)
tmpFcb.ObjectName=tmpFcb.PathName;
while(RC==STATUS_SUCCESS && BufferLength >0)
{
+ OldSector=pCcb->StartSector;
OldEntry=pCcb->StartEntry;
-CHECKPOINT;
- RC=FindFile(DeviceExt,&tmpFcb,pFcb,pCharPattern,&pCcb->StartEntry);
-DPRINT("Found %w,RC=%x,entry %x\n",tmpFcb.ObjectName,RC
- ,pCcb->StartEntry);
- pCcb->StartEntry++;
+ if(OldSector)pCcb->StartEntry++;
+ RC=FindFile(DeviceExt,&tmpFcb,pFcb,pCharPattern,&pCcb->StartSector,&pCcb->StartEntry);
+DPRINT("Found %w,RC=%x, sector %x entry %x\n",tmpFcb.ObjectName,RC
+ ,pCcb->StartSector,pCcb->StartEntry);
if (NT_SUCCESS(RC))
{
switch(FileInformationClass)
if(RC==STATUS_BUFFER_OVERFLOW)
{
if(Buffer0) Buffer0->NextEntryOffset=0;
+ pCcb->StartSector=OldSector;
pCcb->StartEntry=OldEntry;
break;
}
/* INCLUDES *****************************************************************/
-#include <ddk/ntddk.h>
+#include <ctype.h>
+#include <wchar.h>
#include <internal/string.h>
-#include <internal/ctype.h>
-#include <wstring.h>
+#include <ddk/ntddk.h>
#include <ddk/cctypes.h>
#define NDEBUG
#include "vfat.h"
-
-NTSTATUS updEntry(PDEVICE_EXTENSION DeviceExt,PVfatFCB pFcb)
+NTSTATUS updEntry(PDEVICE_EXTENSION DeviceExt,PFILE_OBJECT pFileObject)
/*
update an existing FAT entry
*/
{
WCHAR DirName[MAX_PATH],*FileName,*PathFileName;
VfatFCB FileFcb;
- ULONG Entry=0;
+ ULONG Sector=0,Entry=0;
+ PUCHAR Buffer;
+ FATDirEntry * pEntries;
NTSTATUS status;
FILE_OBJECT FileObject;
PVfatCCB pDirCcb;
- PVfatFCB pDirFcb;
+ PVfatFCB pDirFcb,pFcb;
short i,posCar,NameLen;
- CHECKPOINT;
- PathFileName=pFcb->PathName;
+ PathFileName=pFileObject->FileName.Buffer;
+ pFcb=((PVfatCCB)pFileObject->FsContext2)->pFcb;
//find last \ in PathFileName
posCar=-1;
for(i=0;PathFileName[i];i++)
if(FileName[0]==0 && DirName[0]==0)
return STATUS_SUCCESS;//root : nothing to do ?
memset(&FileObject,0,sizeof(FILE_OBJECT));
- FileObject.FileName.Buffer=DirName;
- FileObject.FileName.Length=posCar;
DPRINT("open directory %w for update of entry %w\n",DirName,FileName);
status=FsdOpenFile(DeviceExt,&FileObject,DirName);
pDirCcb=(PVfatCCB)FileObject.FsContext2;
pDirFcb=pDirCcb->pFcb;
assert(pDirFcb);
FileFcb.ObjectName=&FileFcb.PathName[0];
- status=FindFile(DeviceExt,&FileFcb,pDirFcb,FileName,&Entry);
+ status=FindFile(DeviceExt,&FileFcb,pDirFcb,FileName,&Sector,&Entry);
if(NT_SUCCESS(status))
{
- DPRINT("update entry: entry %d\n",Entry);
- status=FsdWriteFile(DeviceExt,pDirFcb,&pFcb->entry,sizeof(FATDirEntry)
- ,Entry*sizeof(FATDirEntry));
+ Buffer=ExAllocatePool(NonPagedPool,BLOCKSIZE);
+ DPRINT("update entry: sector %d, entry %d\n",Sector,Entry);
+ VFATReadSectors(DeviceExt->StorageDevice,Sector,1,Buffer);
+ pEntries=(FATDirEntry *)Buffer;
+ memcpy(&pEntries[Entry],&pFcb->entry,sizeof(FATDirEntry));
+ VFATWriteSectors(DeviceExt->StorageDevice,Sector,1,Buffer);
+ ExFreePool(Buffer);
}
FsdCloseFile(DeviceExt,&FileObject);
- CHECKPOINT;
return status;
}
slot *pSlots;
ULONG LengthRead,Offset;
short nbSlots=0,nbFree=0,i,j,posCar,NameLen;
- PUCHAR Buffer;
+ PUCHAR Buffer,Buffer2;
BOOLEAN needTilde=FALSE,needLong=FALSE;
- PVfatFCB newFCB,pDirFCB;
- PVfatCCB newCCB,pDirCCB;
+ PVfatFCB newFCB;
+ PVfatCCB newCCB;
ULONG CurrentCluster;
- TIME_FIELDS RTCTime;
- CHECKPOINT;
PathFileName=pFileObject->FileName.Buffer;
DPRINT("addEntry: Pathname=%w\n",PathFileName);
//find last \ in PathFileName
// open parent directory
memset(&FileObject,0,sizeof(FILE_OBJECT));
status=FsdOpenFile(DeviceExt,&FileObject,DirName);
- pDirCCB=FileObject.FsContext2;
- pDirFCB=pDirCCB->pFcb;
nbSlots=(NameLen+12)/13+1;//nb of entry needed for long name+normal entry
DPRINT("NameLen= %d, nbSlots =%d\n",NameLen,nbSlots);
Buffer=ExAllocatePool(NonPagedPool,(nbSlots+1)*sizeof(FATDirEntry));
memset(pEntry,' ',11);
for(i=0,j=0;j<8 && i<posCar;i++)
{
+ //FIXME : is there other characters to ignore ?
if( FileName[i]!='.'
&& FileName[i]!=' '
&& FileName[i]!='+'
DirName[7]='0'+i;
pEntry->Filename[7]='0'+i;
status=FindFile(DeviceExt,&FileFcb
- ,&DirFcb,DirName,NULL);
+ ,&DirFcb,DirName,NULL,NULL);
if(status!=STATUS_SUCCESS)break;
}
//try second with xxxxx~yy.zzz
DirName[7]='0'+i;
pEntry->Filename[7]='0'+i;
status=FindFile(DeviceExt,&FileFcb
- ,&DirFcb,DirName,NULL);
+ ,&DirFcb,DirName,NULL,NULL);
if(status!=STATUS_SUCCESS)break;
}
}
DirName[NameLen]=0;
}
DPRINT("dos name=%11.11s\n",pEntry->Filename);
- // set attributes, dates, times
+ //FIXME : set attributes, dates, times
pEntry->Attrib=ReqAttr;
if(RequestedOptions&FILE_DIRECTORY_FILE)
pEntry->Attrib |= FILE_ATTRIBUTE_DIRECTORY;
- HalQueryRealTimeClock(&RTCTime);
- pEntry->CreationTime
- = (RTCTime.Second>>1)+(RTCTime.Minute<<5)+(RTCTime.Hour<<11);
- pEntry->CreationDate
- = RTCTime.Day+(RTCTime.Month<<5)+((RTCTime.Year-1980)<<9);
- pEntry->UpdateDate=pEntry->CreationDate;
- pEntry->UpdateTime=pEntry->CreationTime;
- pEntry->AccessDate=pEntry->CreationDate;
+ pEntry->CreationDate=0x21;
+ pEntry->UpdateDate=0x21;
// calculate checksum for 8.3 name
for(pSlots[0].alias_checksum=i=0;i<11;i++)
{
pSlots[i].id=nbSlots-i-1+0x40;
pSlots[i].alias_checksum=pSlots[0].alias_checksum;
//FIXME pSlots[i].start=;
- memcpy(pSlots[i].name0_4 ,DirName+(nbSlots-i-2)*13
+ memcpy(pSlots[i].name0_4 ,FileName+(nbSlots-i-2)*13
,5*sizeof(WCHAR));
- memcpy(pSlots[i].name5_10 ,DirName+(nbSlots-i-2)*13+5
+ memcpy(pSlots[i].name5_10 ,FileName+(nbSlots-i-2)*13+5
,6*sizeof(WCHAR));
- memcpy(pSlots[i].name11_12,DirName+(nbSlots-i-2)*13+11
+ memcpy(pSlots[i].name11_12,FileName+(nbSlots-i-2)*13+11
,2*sizeof(WCHAR));
}
//try to find nbSlots contiguous entries frees in directory
for(i=0,status=STATUS_SUCCESS;status==STATUS_SUCCESS;i++)
{
- status=FsdReadFile(DeviceExt,pDirFCB,&FatEntry
+ status=FsdReadFile(DeviceExt,&FileObject,&FatEntry
,sizeof(FATDirEntry),i*sizeof(FATDirEntry),&LengthRead);
- if(IsLastEntry(&FatEntry))
+ if(IsLastEntry(&FatEntry,0))
break;
- if(IsDeletedEntry(&FatEntry)) nbFree++;
+ if(IsDeletedEntry(&FatEntry,0)) nbFree++;
else nbFree=0;
if (nbFree==nbSlots) break;
}
DPRINT("NbFree %d, entry number %d\n",nbFree,i);
if(RequestedOptions&FILE_DIRECTORY_FILE)
- { // directory has always a first cluster
+ {
CurrentCluster=GetNextWriteCluster(DeviceExt,0);
+ // zero the cluster
+ Buffer2=ExAllocatePool(NonPagedPool,DeviceExt->BytesPerCluster);
+ memset(Buffer2,0,DeviceExt->BytesPerCluster);
+ VFATWriteCluster(DeviceExt,Buffer2,CurrentCluster);
+ ExFreePool(Buffer2);
if (DeviceExt->FatType == FAT32)
{
pEntry->FirstClusterHigh=CurrentCluster>>16;
if(nbFree==nbSlots)
{//use old slots
Offset=(i-nbSlots+1)*sizeof(FATDirEntry);
- status=FsdWriteFile(DeviceExt,pDirFCB,Buffer
+ status=FsdWriteFile(DeviceExt,&FileObject,Buffer
,sizeof(FATDirEntry)*nbSlots,Offset);
}
else
{//write at end of directory
Offset=(i-nbFree)*sizeof(FATDirEntry);
- status=FsdWriteFile(DeviceExt,pDirFCB,Buffer
+ status=FsdWriteFile(DeviceExt,&FileObject,Buffer
,sizeof(FATDirEntry)*(nbSlots+1),Offset);
}
DPRINT("write entry offset %d status=%x\n",Offset,status);
newCCB->PtrFileObject=pFileObject;
newFCB->RefCount++;
//FIXME : initialize all fields in FCB and CCB
- newFCB->Buffer=ExAllocatePool(NonPagedPool,DeviceExt->BytesPerCluster);
- newFCB->Cluster=0xFFFFFFFF;
- newFCB->Flags=0;
+ newFCB->nextFcb=pFirstFcb;
memcpy(&newFCB->entry,pEntry,sizeof(FATDirEntry));
DPRINT("new : entry=%11.11s\n",newFCB->entry.Filename);
DPRINT("new : entry=%11.11s\n",pEntry->Filename);
- newFCB->nextFcb=pFirstFcb;
pFirstFcb=newFCB;
vfat_wcsncpy(newFCB->PathName,PathFileName,MAX_PATH);
newFCB->ObjectName=newFCB->PathName+(PathFileName-FileName);
{
// create . and ..
memcpy(pEntry->Filename,". ",11);
- status=FsdWriteFile(DeviceExt,newFCB,pEntry
+ status=FsdWriteFile(DeviceExt,pFileObject,pEntry
,sizeof(FATDirEntry),0L);
pEntry->FirstCluster
=((VfatCCB *)(FileObject.FsContext2))->pFcb->entry.FirstCluster;
memcpy(pEntry->Filename,".. ",11);
if(pEntry->FirstCluster==1 && DeviceExt->FatType!=FAT32)
pEntry->FirstCluster=0;
- status=FsdWriteFile(DeviceExt,newFCB,pEntry
+ status=FsdWriteFile(DeviceExt,pFileObject,pEntry
,sizeof(FATDirEntry),sizeof(FATDirEntry));
}
FsdCloseFile(DeviceExt,&FileObject);
+
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
/* INCLUDES *****************************************************************/
-#include <ddk/ntddk.h>
+#include <wchar.h>
#include <internal/string.h>
-#include <wstring.h>
+#include <ddk/ntddk.h>
#include <ddk/cctypes.h>
#define NDEBUG
#include "vfat.h"
+//#include "dbgpool.c"
/* GLOBALS *****************************************************************/
CurrentCluster = Block[CurrentCluster];
if (CurrentCluster >= 0xfff8 && CurrentCluster <= 0xffff)
CurrentCluster = 0xffffffff;
+ DPRINT("Returning %x\n",CurrentCluster);
return(CurrentCluster);
}
Entry = (CBlock[FATOffset] >> 4);
Entry |= (CBlock[FATOffset+1] << 4);
}
+ DPRINT("Entry %x\n",Entry);
if (Entry >= 0xff8 && Entry <= 0xfff)
Entry = 0xffffffff;
+ DPRINT("Returning %x\n",Entry);
return(Entry);
}
*/
{
+ DPRINT("GetNextCluster(DeviceExt %x, CurrentCluster %x)\n",
+ DeviceExt,CurrentCluster);
if (DeviceExt->FatType == FAT16)
return(Fat16GetNextCluster(DeviceExt, CurrentCluster));
else if (DeviceExt->FatType == FAT32)
*/
{
ULONG LastCluster, NewCluster;
- UCHAR *Buffer2;
+ DPRINT("GetNextWriteCluster(DeviceExt %x, CurrentCluster %x)\n",
+ DeviceExt,CurrentCluster);
+
/* Find out what was happening in the last cluster's AU */
LastCluster=GetNextCluster(DeviceExt,CurrentCluster);
/* Check to see if we must append or overwrite */
found AU */
if(CurrentCluster)
WriteCluster(DeviceExt, CurrentCluster, NewCluster);
- // fill cluster with zero : essential for directories, not for file
- Buffer2=ExAllocatePool(NonPagedPool,DeviceExt->BytesPerCluster);
- memset(Buffer2,0,DeviceExt->BytesPerCluster);
- VFATWriteCluster(DeviceExt,Buffer2,NewCluster);
- ExFreePool(Buffer2);
/* Return NewCluster as CurrentCluster */
return NewCluster;
}
return(dest);
}
-wchar_t * vfat_movstr(wchar_t *src, ULONG dpos,
+wchar_t * vfat_movstr(const wchar_t *src, ULONG dpos,
ULONG spos, ULONG len)
/*
* FUNCTION: Move the characters in a string to a new position in the same
return(src);
}
-BOOLEAN IsLastEntry(FATDirEntry *pEntry)
+BOOLEAN IsLastEntry(PVOID Block, ULONG Offset)
/*
* FUNCTION: Determine if the given directory entry is the last
*/
{
- return(pEntry->Filename[0] == 0);
+ return(((FATDirEntry *)Block)[Offset].Filename[0] == 0);
}
-BOOLEAN IsVolEntry(FATDirEntry *pEntry)
+BOOLEAN IsVolEntry(PVOID Block, ULONG Offset)
/*
* FUNCTION: Determine if the given directory entry is a vol entry
*/
{
- if( (pEntry->Attrib)==0x28 ) return TRUE;
+ if( (((FATDirEntry *)Block)[Offset].Attrib)==0x28 ) return TRUE;
else return FALSE;
}
-BOOLEAN IsDeletedEntry(FATDirEntry *pEntry)
+BOOLEAN IsDeletedEntry(PVOID Block, ULONG Offset)
/*
* FUNCTION: Determines if the given entry is a deleted one
*/
{
/* Checks special character */
- return (pEntry->Filename[0] == 0xe5);
+
+ return ((((FATDirEntry *)Block)[Offset].Filename[0] == 0xe5));
}
-BOOLEAN GetEntryName(PDEVICE_EXTENSION DeviceExt,PVfatFCB pFcb,PULONG pEntry
- , PWSTR Name,FATDirEntry *pFatEntry)
+BOOLEAN GetEntryName(PVOID Block, PULONG _Offset, PWSTR Name, PULONG _jloop,
+ PDEVICE_EXTENSION DeviceExt, ULONG * _StartingSector)
/*
* FUNCTION: Retrieves the file name, be it in short or long file name format
*/
{
- slot* test2;
- ULONG cpos,LengthRead;
- NTSTATUS Status;
+ FATDirEntry* test;
+ slot* test2;
+ ULONG Offset = *_Offset;
+ ULONG StartingSector = *_StartingSector;
+ ULONG jloop = *_jloop;
+ ULONG cpos;
+ WCHAR tmp[256];
- test2 = (slot *)pFatEntry;
+ test = (FATDirEntry *)Block;
+ test2 = (slot *)Block;
*Name = 0;
- if (IsDeletedEntry(pFatEntry))
- {
- return(FALSE);
- }
-
- if(test2->attr == 0x0f)
- { // long name : we read the long name, then we read the entry
- vfat_initstr(Name, 256);
- vfat_wcsncpy(Name,test2->name0_4,5);
- vfat_wcsncat(Name,test2->name5_10,5,6);
- vfat_wcsncat(Name,test2->name11_12,11,2);
-
- cpos=0;
- while((test2->id!=0x41) && (test2->id!=0x01) &&
- (test2->attr>0))
+ if (IsDeletedEntry(Block,Offset))
{
- (*pEntry)++;
- Status=FsdReadFile(DeviceExt,pFcb,pFatEntry,sizeof(FATDirEntry)
- ,(*pEntry)*sizeof(FATDirEntry),&LengthRead);
- if(!(NT_SUCCESS(Status))) return FALSE;
- cpos++;
- vfat_movstr(Name, 13, 0, cpos*13);
- vfat_wcsncpy(Name,test2->name0_4, 5);
- vfat_wcsncat(Name,test2->name5_10,5,6);
- vfat_wcsncat(Name,test2->name11_12,11,2);
+ return(FALSE);
}
- // now read the entry
- (*pEntry)++;
- Status=FsdReadFile(DeviceExt,pFcb,pFatEntry,sizeof(FATDirEntry)
- ,(*pEntry)*sizeof(FATDirEntry),&LengthRead);
- if (IsDeletedEntry(pFatEntry))
+
+ if(test2[Offset].attr == 0x0f)
+ {
+ vfat_initstr(Name, 256);
+ vfat_wcsncpy(Name,test2[Offset].name0_4,5);
+ vfat_wcsncat(Name,test2[Offset].name5_10,5,6);
+ vfat_wcsncat(Name,test2[Offset].name11_12,11,2);
+
+ cpos=0;
+ while((test2[Offset].id!=0x41) && (test2[Offset].id!=0x01) &&
+ (test2[Offset].attr>0))
+ {
+ Offset++;
+ if(Offset==ENTRIES_PER_SECTOR) {
+ Offset=0;
+ StartingSector++;//FIXME : nor always the next sector
+ jloop++;
+ VFATReadSectors(DeviceExt->StorageDevice,StartingSector,1,Block);
+ test2 = (slot *)Block;
+ }
+ cpos++;
+ vfat_movstr(Name, 13, 0, cpos*13);
+ vfat_wcsncpy(Name, test2[Offset].name0_4, 5);
+ vfat_wcsncat(Name,test2[Offset].name5_10,5,6);
+ vfat_wcsncat(Name,test2[Offset].name11_12,11,2);
+
+ }
+
+ if (IsDeletedEntry(Block,Offset+1))
+ {
+ Offset++;
+ *_Offset = Offset;
+ *_jloop = jloop;
+ *_StartingSector = StartingSector;
return(FALSE);
- return(TRUE);
- }
+ }
+
+ *_Offset = Offset;
+ *_jloop = jloop;
+ *_StartingSector = StartingSector;
+
+ return(TRUE);
+ }
- RtlAnsiToUnicode(Name,pFatEntry->Filename,8);
- if (pFatEntry->Ext[0]!=' ')
- {
- RtlCatAnsiToUnicode(Name,".",1);
- }
- RtlCatAnsiToUnicode(Name,pFatEntry->Ext,3);
+ RtlAnsiToUnicode(Name,test[Offset].Filename,8);
+ if (test[Offset].Ext[0]!=' ')
+ {
+ RtlCatAnsiToUnicode(Name,".",1);
+ }
+ RtlCatAnsiToUnicode(Name,test[Offset].Ext,3);
+
+ *_Offset = Offset;
+
return(TRUE);
}
}
NTSTATUS FindFile(PDEVICE_EXTENSION DeviceExt, PVfatFCB Fcb,
- PVfatFCB Parent, PWSTR FileToFind,ULONG *Entry)
+ PVfatFCB Parent, PWSTR FileToFind,ULONG *StartSector,ULONG *Entry)
/*
* FUNCTION: Find a file
*/
{
- ULONG i;
+ ULONG i, j;
ULONG Size;
+ char* block;
WCHAR name[256];
- FATDirEntry FatEntry;
- NTSTATUS Status;
- ULONG LengthRead;
- VfatFCB TempFcb;
+ ULONG StartingSector;
+ ULONG NextCluster;
+ WCHAR TempStr[2];
+
+ DPRINT("FindFile(Parent %x, FileToFind '%w')\n",Parent,FileToFind);
+
+ if (wcslen(FileToFind)==0)
+ {
+ TempStr[0] = (WCHAR)'.';
+ TempStr[1] = 0;
+ FileToFind=&TempStr;
+ }
+ if (Parent != NULL)
+ {
+ DPRINT("Parent->entry.FirstCluster %d\n",Parent->entry.FirstCluster);
+ }
+
if (Parent == NULL||Parent->entry.FirstCluster==1)
{
Size = DeviceExt->rootDirectorySectors;//FIXME : in fat32, no limit
- if(FileToFind[0]==0 ||(FileToFind[0]=='\\' && FileToFind[1]==0))
+ StartingSector = DeviceExt->rootStart;
+ NextCluster=0;
+ if(FileToFind[0]==0 ||(FileToFind[0]=='\\' && FileToFind[1]==0) ||
+ (FileToFind[0]=='.' && FileToFind[1]==0))
{// it's root : complete essentials fields then return ok
memset(Fcb,0,sizeof(VfatFCB));
memset(Fcb->entry.Filename,' ',11);
if (DeviceExt->FatType == FAT32)
Fcb->entry.FirstCluster=2;
else Fcb->entry.FirstCluster=1;//FIXME : is 1 the good value for mark root?
+ if(StartSector) *StartSector=StartingSector;
if(Entry) *Entry=0;
return(STATUS_SUCCESS);
}
}
- TempFcb.Buffer=NULL;
- if (Parent==NULL)
+ else
{
- memset(&TempFcb,0,sizeof(VfatFCB));
- memset(TempFcb.entry.Filename,' ',11);
- TempFcb.entry.FileSize=DeviceExt->rootDirectorySectors*BLOCKSIZE;
- TempFcb.entry.Attrib=FILE_ATTRIBUTE_DIRECTORY;
- TempFcb.Buffer=ExAllocatePool(NonPagedPool,DeviceExt->BytesPerCluster);
- TempFcb.Cluster=0xFFFFFFFF;
- TempFcb.Flags=0;
- if (DeviceExt->FatType == FAT32)
- TempFcb.entry.FirstCluster=2;
- else
- TempFcb.entry.FirstCluster=1;//FIXME : is 1 the good value for mark root?
- Parent=&TempFcb;
+ DPRINT("Parent->entry.FileSize %x\n",Parent->entry.FileSize);
+
+ Size = ULONG_MAX;
+ if (DeviceExt->FatType == FAT32)
+ NextCluster = Parent->entry.FirstCluster
+ +Parent->entry.FirstClusterHigh*65536;
+ else
+ NextCluster = Parent->entry.FirstCluster;
+ StartingSector = ClusterToSector(DeviceExt, NextCluster);
+ if(Parent->entry.FirstCluster==1 && DeviceExt->FatType!=FAT32)
+ {// read of root directory in FAT16 or FAT12
+ StartingSector=DeviceExt->rootStart;
+ }
}
+ block = ExAllocatePool(NonPagedPool,BLOCKSIZE);
+ if (StartSector && (*StartSector)) StartingSector=*StartSector;
i=(Entry)?(*Entry):0;
- for(; ; i++)
+ DPRINT("FindFile : start at sector %lx, entry %ld\n",StartingSector,i);
+ for (j=0; j<Size; j++)
{
- Status=FsdReadFile(DeviceExt,Parent,&FatEntry,sizeof(FATDirEntry)
- ,i*sizeof(FATDirEntry),&LengthRead);
- if(!NT_SUCCESS(Status))
- break;
- if (IsVolEntry(&FatEntry))
- continue;
- if (IsLastEntry(&FatEntry))
+ VFATReadSectors(DeviceExt->StorageDevice,StartingSector,1,block);
+
+ for (i=(Entry)?(*Entry):0; i<ENTRIES_PER_SECTOR; i++)
{
- if(Entry) *Entry=i;
- return(STATUS_UNSUCCESSFUL);
+ if (IsVolEntry((PVOID)block,i))
+ continue;
+ if (IsLastEntry((PVOID)block,i))
+ {
+ ExFreePool(block);
+ if(StartSector) *StartSector=StartingSector;
+ if(Entry) *Entry=i;
+ return(STATUS_UNSUCCESSFUL);
+ }
+ if (GetEntryName((PVOID)block,&i,name,&j,DeviceExt,&StartingSector))
+ {
+ DPRINT("Comparing '%w' '%w'\n",name,FileToFind);
+ if (wstrcmpjoki(name,FileToFind))
+ {
+ /* In the case of a long filename, the firstcluster is stored in
+ the next record -- where it's short name is */
+ if(((FATDirEntry *)block)[i].Attrib==0x0f) i++;
+ if( i==(ENTRIES_PER_SECTOR))
+ {// entry is in next sector
+ StartingSector++;
+ //FIXME : treat case of next sector fragmented
+ VFATReadSectors(DeviceExt->StorageDevice,StartingSector,1,block);
+ i=0;
+ }
+ memcpy(&Fcb->entry,&((FATDirEntry *)block)[i],
+ sizeof(FATDirEntry));
+ vfat_wcsncpy(Fcb->ObjectName,name,MAX_PATH);
+ ExFreePool(block);
+ if(StartSector) *StartSector=StartingSector;
+ if(Entry) *Entry=i;
+ return(STATUS_SUCCESS);
+ }
+ }
}
- if (GetEntryName(DeviceExt,Parent,&i,name,&FatEntry))
+ // not found in this sector, try next :
+
+ /* directory can be fragmented although it is best to keep them
+ unfragmented */
+ if(Entry) *Entry=0;
+ StartingSector++;
+ if ((Parent != NULL && Parent->entry.FirstCluster!=1)
+ || DeviceExt->FatType ==FAT32)
{
- if (wstrcmpjoki(name,FileToFind))
+ if(StartingSector==ClusterToSector(DeviceExt,NextCluster+1))
{
- memcpy(&Fcb->entry,&FatEntry,sizeof(FATDirEntry));
- vfat_wcsncpy(Fcb->ObjectName,name,MAX_PATH);
- if(Entry) *Entry=i;
- if(TempFcb.Buffer) ExFreePool(TempFcb.Buffer);
- return(STATUS_SUCCESS);
+ NextCluster = GetNextCluster(DeviceExt,NextCluster);
+ if (NextCluster == 0||NextCluster==0xffffffff)
+ {
+ if(StartSector) *StartSector=StartingSector;
+ if(Entry) *Entry=i;
+ ExFreePool(block);
+ return(STATUS_UNSUCCESSFUL);
+ }
+ StartingSector = ClusterToSector(DeviceExt,NextCluster);
}
}
}
+ ExFreePool(block);
+ if(StartSector) *StartSector=StartingSector;
if(Entry) *Entry=i;
- if(TempFcb.Buffer) ExFreePool(TempFcb.Buffer);
return(STATUS_UNSUCCESSFUL);
}
{
PVfatFCB pFcb;
PVfatCCB pCcb;
+
+ DPRINT("FsdCloseFile(DeviceExt %x, FileObject %x)\n",
+ DeviceExt,FileObject);
+
//FIXME : update entry in directory ?
- assert(FileObject);
pCcb = (PVfatCCB)(FileObject->FsContext2);
- if(!pCcb) return STATUS_UNSUCCESSFUL;
+
+ DPRINT("pCcb %x\n",pCcb);
+ if (pCcb == NULL)
+ {
+ return(STATUS_SUCCESS);
+ }
+
pFcb = pCcb->pFcb;
- assert(pFcb);
+
pFcb->RefCount--;
if(pFcb->RefCount<=0)
{
pFirstFcb=pFcb->nextFcb;
if(pFcb->nextFcb)
pFcb->nextFcb->prevFcb=pFcb->prevFcb;
- ExFreePool(pFcb->Buffer);
ExFreePool(pFcb);
}
ExFreePool(pCcb);
PFILE_OBJECT pRelFileObject;
PWSTR AbsFileName=NULL;
short i,j;
- if(FileObject->FileName.Length>0
- && FileName[FileObject->FileName.Length-1]=='\\')
- FileName[FileObject->FileName.Length-1]=0;
- // treat relative name
+
+ DPRINT("FsdOpenFile(%08lx, %08lx, %w)\n",
+ DeviceExt,
+ FileObject,
+ FileName);
+
+ //FIXME : treat relative name
if(FileObject->RelatedFileObject)
{
+DbgPrint("try related for %w\n",FileName);
pRelFileObject=FileObject->RelatedFileObject;
pRelCcb=pRelFileObject->FsContext2;
assert(pRelCcb);
return Status;
}
// construct absolute path name
- AbsFileName=ExAllocatePool(NonPagedPool,MAX_PATH*sizeof(WCHAR));
+ AbsFileName=ExAllocatePool(NonPagedPool,MAX_PATH);
for (i=0;pRelFcb->PathName[i];i++)
AbsFileName[i]=pRelFcb->PathName[i];
AbsFileName[i++]='\\';
Fcb = ExAllocatePool(NonPagedPool, sizeof(VfatFCB));
memset(Fcb,0,sizeof(VfatFCB));
Fcb->ObjectName=Fcb->PathName;
- Fcb->Buffer=ExAllocatePool(NonPagedPool,DeviceExt->BytesPerCluster);
- Fcb->Cluster=0xFFFFFFFF;
- Fcb->Flags=0;
- next = &string[0];
- current = next+1;
-
- if(*next==0) // root
- {
- memset(Fcb->entry.Filename,' ',11);
- Fcb->entry.FileSize=DeviceExt->rootDirectorySectors*BLOCKSIZE;
- Fcb->entry.Attrib=FILE_ATTRIBUTE_DIRECTORY;
- if (DeviceExt->FatType == FAT32)
- Fcb->entry.FirstCluster=2;
- else Fcb->entry.FirstCluster=1;//FIXME : is 1 the good value for mark root?
- ParentFcb=Fcb;
- Fcb=NULL;
- }
- else
+ next = &string[0];
+
while (next!=NULL)
{
*next = '\\';
current = next+1;
next = wcschr(next+1,'\\');
if (next!=NULL)
- *next=0;
- Status = FindFile(DeviceExt,Fcb,ParentFcb,current,NULL);
- if (Status != STATUS_SUCCESS)
- {
- if (Fcb != NULL)
- ExFreePool(Fcb);
- if (ParentFcb != NULL)
- ExFreePool(ParentFcb);
- if(AbsFileName)ExFreePool(AbsFileName);
- return(Status);
- }
- Temp = Fcb;
- if (ParentFcb == NULL)
- {
- Fcb = ExAllocatePool(NonPagedPool,sizeof(VfatFCB));
- memset(Fcb,0,sizeof(VfatFCB));
- Fcb->ObjectName=Fcb->PathName;
- Fcb->Buffer=ExAllocatePool(NonPagedPool,DeviceExt->BytesPerCluster);
- Fcb->Cluster=0xFFFFFFFF;
- Fcb->Flags=0;
- }
- else Fcb = ParentFcb;
- ParentFcb = Temp;
+ {
+ *next=0;
+ }
+ DPRINT("current '%w'\n",current);
+ Status = FindFile(DeviceExt,Fcb,ParentFcb,current,NULL,NULL);
+ if (Status != STATUS_SUCCESS)
+ {
+ if (Fcb != NULL)
+ ExFreePool(Fcb);
+ if (ParentFcb != NULL)
+ ExFreePool(ParentFcb);
+ if(AbsFileName)ExFreePool(AbsFileName);
+ return(Status);
+ }
+ Temp = Fcb;
+ if (ParentFcb == NULL)
+ {
+ Fcb = ExAllocatePool(NonPagedPool,sizeof(VfatFCB));
+ memset(Fcb,0,sizeof(VfatFCB));
+ Fcb->ObjectName=Fcb->PathName;
+ }
+ else Fcb = ParentFcb;
+ ParentFcb = Temp;
}
- CHECKPOINT;
- FileObject->FsContext =(PVOID) &ParentFcb->NTRequiredFCB;
- newCCB = ExAllocatePool(NonPagedPool,sizeof(VfatCCB));
- memset(newCCB,0,sizeof(VfatCCB));
- FileObject->FsContext2 = newCCB;
- newCCB->pFcb=ParentFcb;
- newCCB->PtrFileObject=FileObject;
- ParentFcb->RefCount++;
- //FIXME : initialize all fields in FCB and CCB
- ParentFcb->Cluster=0xFFFFFFFF;
- ParentFcb->Flags=0;
- ParentFcb->nextFcb=pFirstFcb;
- pFirstFcb=ParentFcb;
+ FileObject->FsContext =(PVOID) &ParentFcb->NTRequiredFCB;
+ newCCB = ExAllocatePool(NonPagedPool,sizeof(VfatCCB));
+ memset(newCCB,0,sizeof(VfatCCB));
+ FileObject->FsContext2 = newCCB;
+ newCCB->pFcb=ParentFcb;
+ newCCB->PtrFileObject=FileObject;
+ ParentFcb->RefCount++;
+ //FIXME : initialize all fields in FCB and CCB
+ ParentFcb->nextFcb=pFirstFcb;
+ pFirstFcb=ParentFcb;
vfat_wcsncpy(ParentFcb->PathName,FileName,MAX_PATH);
- ParentFcb->ObjectName=ParentFcb->PathName+(current-FileName);
- ParentFcb->pDevExt=DeviceExt;
- if(Fcb)
- {
- ExFreePool(Fcb->Buffer);
- ExFreePool(Fcb);
- }
- if(AbsFileName)ExFreePool(AbsFileName);
+ ParentFcb->ObjectName=ParentFcb->PathName+(current-FileName);
+ ParentFcb->pDevExt=DeviceExt;
+ DPRINT("file open, fcb=%x\n",ParentFcb);
+ DPRINT("FileSize %d\n",ParentFcb->entry.FileSize);
+ if(Fcb) ExFreePool(Fcb);
+ if(AbsFileName)ExFreePool(AbsFileName);
return(STATUS_SUCCESS);
-}
-
-BOOLEAN FsdHasFileSystem(PDEVICE_OBJECT DeviceToMount)
+ }
+
+
+ BOOLEAN FsdHasFileSystem(PDEVICE_OBJECT DeviceToMount)
/*
* FUNCTION: Tests if the device contains a filesystem that can be mounted
* by this fsd
{
BootSector* Boot;
- Boot = ExAllocatePool(NonPagedPool,BLOCKSIZE);
+ Boot = ExAllocatePool(NonPagedPool,512);
VFATReadSectors(DeviceToMount, 0, 1, (UCHAR *)Boot);
{
DPRINT("Mounting VFAT device...");
DPRINT("DeviceExt %x\n",DeviceExt);
- DeviceExt->Boot = ExAllocatePool(NonPagedPool,BLOCKSIZE);
+
+ DeviceExt->Boot = ExAllocatePool(NonPagedPool,512);
VFATReadSectors(DeviceToMount, 0, 1, (UCHAR *)DeviceExt->Boot);
DPRINT("DeviceExt->Boot->BytesPerSector %x\n",
*/
{
ULONG Sector;
+
+ DPRINT("VFATLoadCluster(DeviceExt %x, Buffer %x, Cluster %d)\n",
+ DeviceExt,Buffer,Cluster);
+
Sector = ClusterToSector(DeviceExt, Cluster);
VFATReadSectors(DeviceExt->StorageDevice,
*/
{
ULONG Sector;
+ DPRINT("VFATWriteCluster(DeviceExt %x, Buffer %x, Cluster %d)\n",
+ DeviceExt,Buffer,Cluster);
+
Sector = ClusterToSector(DeviceExt, Cluster);
VFATWriteSectors(DeviceExt->StorageDevice,
Buffer);
}
-NTSTATUS FsdReadFile(PDEVICE_EXTENSION DeviceExt, PVfatFCB Fcb,
+NTSTATUS FsdReadFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
PVOID Buffer, ULONG Length, ULONG ReadOffset,
PULONG LengthRead)
/*
ULONG CurrentCluster;
ULONG FileOffset;
ULONG FirstCluster;
-// PVOID Temp;
+ PVfatFCB Fcb;
+ PVOID Temp;
ULONG TempLength;
/* PRECONDITION */
assert(DeviceExt != NULL);
assert(DeviceExt->BytesPerCluster != 0);
- assert(Fcb);
- assert(Fcb->Buffer != NULL);
+ assert(FileObject != NULL);
+ assert(FileObject->FsContext != NULL);
+ DPRINT("FsdReadFile(DeviceExt %x, FileObject %x, Buffer %x, "
+ "Length %d, ReadOffset %d)\n",DeviceExt,FileObject,Buffer,
+ Length,ReadOffset);
+
+ Fcb = ((PVfatCCB)(FileObject->FsContext2))->pFcb;
if (DeviceExt->FatType == FAT32)
CurrentCluster = Fcb->entry.FirstCluster
+Fcb->entry.FirstClusterHigh*65536;
else
CurrentCluster = Fcb->entry.FirstCluster;
FirstCluster=CurrentCluster;
+ DPRINT("DeviceExt->BytesPerCluster %x\n",DeviceExt->BytesPerCluster);
+
if (ReadOffset >= Fcb->entry.FileSize
&& !(Fcb->entry.Attrib & FILE_ATTRIBUTE_DIRECTORY))
{
Length = Fcb->entry.FileSize - ReadOffset;
}
*LengthRead = 0;
+ /* FIXME: optimize by remembering the last cluster read and using if possible */
+ Temp = ExAllocatePool(NonPagedPool,DeviceExt->BytesPerCluster);
+ if(!Temp) return STATUS_UNSUCCESSFUL;
if (FirstCluster==1)
{ //root of FAT16 or FAT12
CurrentCluster=DeviceExt->rootStart+ReadOffset
{
CurrentCluster = GetNextCluster(DeviceExt,CurrentCluster);
}
+ CHECKPOINT;
if ((ReadOffset % DeviceExt->BytesPerCluster)!=0)
{
if (FirstCluster==1)
{
- if(CurrentCluster!=Fcb->Cluster)
- VFATReadSectors(DeviceExt->StorageDevice,CurrentCluster
- ,DeviceExt->Boot->SectorsPerCluster,Fcb->Buffer);
- Fcb->Cluster=CurrentCluster;
+ VFATReadSectors(DeviceExt->StorageDevice,CurrentCluster
+ ,DeviceExt->Boot->SectorsPerCluster,Temp);
CurrentCluster += DeviceExt->Boot->SectorsPerCluster;
}
else
{
- if(CurrentCluster!=Fcb->Cluster)
- VFATLoadCluster(DeviceExt,Fcb->Buffer,CurrentCluster);
- Fcb->Cluster=CurrentCluster;
+ VFATLoadCluster(DeviceExt,Temp,CurrentCluster);
CurrentCluster = GetNextCluster(DeviceExt, CurrentCluster);
}
TempLength = min(Length,DeviceExt->BytesPerCluster -
(ReadOffset % DeviceExt->BytesPerCluster));
- memcpy(Buffer, Fcb->Buffer + ReadOffset % DeviceExt->BytesPerCluster,
+ memcpy(Buffer, Temp + ReadOffset % DeviceExt->BytesPerCluster,
TempLength);
(*LengthRead) = (*LengthRead) + TempLength;
Length = Length - TempLength;
Buffer = Buffer + TempLength;
}
+ CHECKPOINT;
while (Length >= DeviceExt->BytesPerCluster)
{
if (FirstCluster==1)
{
- if(CurrentCluster!=Fcb->Cluster)
- VFATReadSectors(DeviceExt->StorageDevice,CurrentCluster
- ,DeviceExt->Boot->SectorsPerCluster,Fcb->Buffer);
- Fcb->Cluster=CurrentCluster;
+ VFATReadSectors(DeviceExt->StorageDevice,CurrentCluster
+ ,DeviceExt->Boot->SectorsPerCluster,Buffer);
CurrentCluster += DeviceExt->Boot->SectorsPerCluster;
}
else
{
- if(CurrentCluster!=Fcb->Cluster)
- VFATLoadCluster(DeviceExt,Fcb->Buffer,CurrentCluster);
- Fcb->Cluster=CurrentCluster;
+ VFATLoadCluster(DeviceExt,Buffer,CurrentCluster);
CurrentCluster = GetNextCluster(DeviceExt, CurrentCluster);
}
- memcpy(Buffer, Fcb->Buffer, DeviceExt->BytesPerCluster);
- if (CurrentCluster == 0xffffffff)
+ if (CurrentCluster == 0xffffffff)
{
+ ExFreePool(Temp);
return(STATUS_SUCCESS);
}
(*LengthRead) = (*LengthRead) + DeviceExt->BytesPerCluster;
Buffer = Buffer + DeviceExt->BytesPerCluster;
Length = Length - DeviceExt->BytesPerCluster;
- }
+ }
+ CHECKPOINT;
if (Length > 0)
- {
+ {
(*LengthRead) = (*LengthRead) + Length;
if (FirstCluster==1)
- {
- if(CurrentCluster!=Fcb->Cluster)
+ {
VFATReadSectors(DeviceExt->StorageDevice,CurrentCluster
- ,DeviceExt->Boot->SectorsPerCluster,Fcb->Buffer);
- Fcb->Cluster=CurrentCluster;
- CurrentCluster += DeviceExt->Boot->SectorsPerCluster;
- }
+ ,DeviceExt->Boot->SectorsPerCluster,Temp);
+ CurrentCluster += DeviceExt->Boot->SectorsPerCluster;
+ }
else
{
- if(CurrentCluster!=Fcb->Cluster)
- VFATLoadCluster(DeviceExt,Fcb->Buffer,CurrentCluster);
- Fcb->Cluster=CurrentCluster;
+ VFATLoadCluster(DeviceExt,Temp,CurrentCluster);
CurrentCluster = GetNextCluster(DeviceExt, CurrentCluster);
}
- memcpy(Buffer, Fcb->Buffer, Length);
+ memcpy(Buffer, Temp, Length);
}
+ ExFreePool(Temp);
return(STATUS_SUCCESS);
}
-NTSTATUS FsdWriteFile(PDEVICE_EXTENSION DeviceExt, PVfatFCB Fcb,
+NTSTATUS FsdWriteFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
PVOID Buffer, ULONG Length, ULONG WriteOffset)
/*
* FUNCTION: Writes data to file
ULONG CurrentCluster;
ULONG FileOffset;
ULONG FirstCluster;
+ PVfatFCB Fcb;
+ PVfatCCB pCcb;
+ PVOID Temp;
ULONG TempLength,Length2=Length;
- CHECKPOINT;
/* Locate the first cluster of the file */
+ assert(FileObject);
+ pCcb=(PVfatCCB)(FileObject->FsContext2);
+ assert(pCcb);
+ Fcb = pCcb->pFcb;
assert(Fcb);
- if(WriteOffset==FILE_WRITE_TO_END_OF_FILE)
- WriteOffset=Fcb->entry.FileSize;
- if(!(Fcb->entry.Attrib & FILE_ATTRIBUTE_DIRECTORY) && WriteOffset>Fcb->entry.FileSize)
- {
- //FIXME : we must extend the file with null bytes then write buffer
- return STATUS_UNSUCCESSFUL;
- }
if (DeviceExt->FatType == FAT32)
CurrentCluster = Fcb->entry.FirstCluster+Fcb->entry.FirstClusterHigh*65536;
else
CurrentCluster = Fcb->entry.FirstCluster;
FirstCluster=CurrentCluster;
+ /* Allocate a buffer to hold 1 cluster of data */
+
+ Temp = ExAllocatePool(NonPagedPool,DeviceExt->BytesPerCluster);
+ assert(Temp);
/* Find the cluster according to the offset in the file */
TempLength = min(Length,DeviceExt->BytesPerCluster -
(WriteOffset % DeviceExt->BytesPerCluster));
/* Read in the existing cluster data */
- if(CurrentCluster!=Fcb->Cluster)
- {
- if (FirstCluster==1)
- VFATReadSectors(DeviceExt->StorageDevice,CurrentCluster
- ,DeviceExt->Boot->SectorsPerCluster,Fcb->Buffer);
- else
- VFATLoadCluster(DeviceExt,Fcb->Buffer,CurrentCluster);
- Fcb->Cluster=CurrentCluster;
- }
+ if (FirstCluster==1)
+ VFATReadSectors(DeviceExt->StorageDevice,CurrentCluster
+ ,DeviceExt->Boot->SectorsPerCluster,Temp);
+ else
+ VFATLoadCluster(DeviceExt,Temp,CurrentCluster);
+
/* Overwrite the last parts of the data as necessary */
- memcpy(Fcb->Buffer + (WriteOffset % DeviceExt->BytesPerCluster), Buffer,
+ memcpy(Temp + (WriteOffset % DeviceExt->BytesPerCluster), Buffer,
TempLength);
/* Write the cluster back */
if (FirstCluster==1)
{
VFATWriteSectors(DeviceExt->StorageDevice,CurrentCluster
- ,DeviceExt->Boot->SectorsPerCluster,Fcb->Buffer);
+ ,DeviceExt->Boot->SectorsPerCluster,Temp);
CurrentCluster += DeviceExt->Boot->SectorsPerCluster;
}
else
{
- VFATWriteCluster(DeviceExt,Fcb->Buffer,CurrentCluster);
+ VFATWriteCluster(DeviceExt,Temp,CurrentCluster);
CurrentCluster = GetNextCluster(DeviceExt, CurrentCluster);
}
Length2 -= TempLength;
CHECKPOINT;
if (CurrentCluster == 0)
{
+ ExFreePool(Temp);
return(STATUS_UNSUCCESSFUL);
}
if (FirstCluster==1)
{
VFATWriteSectors(DeviceExt->StorageDevice,CurrentCluster
,DeviceExt->Boot->SectorsPerCluster,Buffer);
- Fcb->Cluster=CurrentCluster;
- memcpy(Fcb->Buffer,Buffer,DeviceExt->Boot->SectorsPerCluster);
CurrentCluster += DeviceExt->Boot->SectorsPerCluster;
}
else
{
VFATWriteCluster(DeviceExt,Buffer,CurrentCluster);
- Fcb->Cluster=CurrentCluster;
- memcpy(Fcb->Buffer,Buffer,DeviceExt->Boot->SectorsPerCluster);
CurrentCluster = GetNextCluster(DeviceExt, CurrentCluster);
}
Buffer = Buffer + DeviceExt->BytesPerCluster;
if (Length2 > 0)
{
+ CHECKPOINT;
if (CurrentCluster == 0)
{
+ ExFreePool(Temp);
return(STATUS_UNSUCCESSFUL);
}
+ CHECKPOINT;
/* Read in the existing cluster data */
- if(CurrentCluster!=Fcb->Cluster)
- {
- if (FirstCluster==1)
- VFATReadSectors(DeviceExt->StorageDevice,CurrentCluster
- ,DeviceExt->Boot->SectorsPerCluster,Fcb->Buffer);
- else
- VFATLoadCluster(DeviceExt,Fcb->Buffer,CurrentCluster);
- Fcb->Cluster=CurrentCluster;
- }
- memcpy(Fcb->Buffer, Buffer, Length2);
+ if (FirstCluster==1)
+ VFATReadSectors(DeviceExt->StorageDevice,CurrentCluster
+ ,DeviceExt->Boot->SectorsPerCluster,Temp);
+ else
+ VFATLoadCluster(DeviceExt,Temp,CurrentCluster);
+ CHECKPOINT;
+ memcpy(Temp, Buffer, Length2);
+ CHECKPOINT;
if (FirstCluster==1)
{
VFATWriteSectors(DeviceExt->StorageDevice,CurrentCluster
- ,DeviceExt->Boot->SectorsPerCluster,Fcb->Buffer);
+ ,DeviceExt->Boot->SectorsPerCluster,Temp);
}
else
- VFATWriteCluster(DeviceExt,Fcb->Buffer,CurrentCluster);
+ VFATWriteCluster(DeviceExt,Temp,CurrentCluster);
}
+ CHECKPOINT;
//FIXME : set last write time and date
if(Fcb->entry.FileSize<WriteOffset+Length
&& !(Fcb->entry.Attrib &FILE_ATTRIBUTE_DIRECTORY))
{
Fcb->entry.FileSize=WriteOffset+Length;
// update entry in directory
- updEntry(DeviceExt,Fcb);
+ updEntry(DeviceExt,FileObject);
}
+ ExFreePool(Temp);
return(STATUS_SUCCESS);
}
PDEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
NTSTATUS Status;
+ DPRINT("FsdClose(DeviceObject %x, Irp %x)\n",DeviceObject, Irp);
+
Status = FsdCloseFile(DeviceExtension,FileObject);
Irp->IoStatus.Status = Status;
ULONG RequestedDisposition,RequestedOptions;
PVfatCCB pCcb;
PVfatFCB pFcb;
+
assert(DeviceObject);
assert(Irp);
if(DeviceObject->Size==sizeof(DEVICE_OBJECT))
IoCompleteRequest(Irp, IO_NO_INCREMENT);
ExReleaseResourceForThreadLite(&(DeviceExt->Resource),ExGetCurrentResourceThread());
-DbgPrint("open, Status=%x\n",Status);
return Status;
}
PFILE_OBJECT FileObject = Stack->FileObject;
PDEVICE_EXTENSION DeviceExt = DeviceObject->DeviceExtension;
NTSTATUS Status;
- PVfatFCB pFcb;
DPRINT("FsdWrite(DeviceObject %x Irp %x)\n",DeviceObject,Irp);
Buffer = MmGetSystemAddressForMdl(Irp->MdlAddress);
Offset = GET_LARGE_INTEGER_LOW_PART(Stack->Parameters.Write.ByteOffset);
- assert(FileObject->FsContext2 != NULL);
- pFcb = ((PVfatCCB)(FileObject->FsContext2))->pFcb;
- Status = FsdWriteFile(DeviceExt,pFcb,Buffer,Length,Offset);
+ Status = FsdWriteFile(DeviceExt,FileObject,Buffer,Length,Offset);
Irp->IoStatus.Status = Status;
Irp->IoStatus.Information = Length;
PDEVICE_EXTENSION DeviceExt;
NTSTATUS Status;
ULONG LengthRead;
- PVfatFCB pFcb;
+ DPRINT("FsdRead(DeviceObject %x, Irp %x)\n",DeviceObject,Irp);
+
/* Precondition / Initialization */
assert(Irp != NULL);
Stack = IoGetCurrentIrpStackLocation(Irp);
Length = Stack->Parameters.Read.Length;
Buffer = MmGetSystemAddressForMdl(Irp->MdlAddress);
Offset = GET_LARGE_INTEGER_LOW_PART(Stack->Parameters.Read.ByteOffset);
- assert(FileObject->FsContext2 != NULL);
- pFcb = ((PVfatCCB)(FileObject->FsContext2))->pFcb;
- assert(pFcb);
- Status = FsdReadFile(DeviceExt,pFcb,Buffer,Length,Offset,
+
+ Status = FsdReadFile(DeviceExt,FileObject,Buffer,Length,Offset,
&LengthRead);
Irp->IoStatus.Status = Status;
Irp->IoStatus.Status = Status;
Irp->IoStatus.Information = 0;
+
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return(Status);
}
return RC;
}
-NTSTATUS DriverEntry(PDRIVER_OBJECT _DriverObject,
- PUNICODE_STRING RegistryPath)
+STDCALL NTSTATUS DriverEntry(PDRIVER_OBJECT _DriverObject,
+ PUNICODE_STRING RegistryPath)
/*
* FUNCTION: Called by the system to initalize the driver
* ARGUMENTS:
UNICODE_STRING ustr;
ANSI_STRING astr;
- DbgPrint("VFAT 0.0.7\n");
+ DbgPrint("VFAT 0.0.6\n");
pFirstFcb=NULL;
VFATDriverObject = _DriverObject;
-%.o: %.cc
- $(CC) $(CFLAGS) -c $< -o $@
-%.o: %.asm
- $(NASM) $(NFLAGS) $< -o $@
-
-OBJECTS= blockdev.o iface.o dir.o dirwr.o
-
-all: vfatfsd.o
-tests: tstvfat5.bin tstvfat6.bin
-
-vfatfsd.o: $(OBJECTS)
- $(LD) $(OBJECTS) -r -o vfatfsd.o
- $(NM) --numeric-sort vfatfsd.o > vfatfsd.sym
-
-OBJECTS2 = ../../../apps/common/crt0.o
-LIBS= ../../../lib/kernel32/kernel32.a ../../../lib/ntdll/ntdll.a
-
-%.bin: $(OBJECTS) %.o
- $(LD) -Ttext 0x10000 $(OBJECTS2) $*.o $(LIBS) -o $*.exe
- $(OBJCOPY) -O binary $*.exe $*.bin
-
-include ../../../rules.mak
+all: vfatfsd.sys
+
+OBJECTS = blockdev.o dir.o dirwr.o iface.o ../../../ntoskrnl/ntoskrnl.a
+
+vfatfsd.sys: $(OBJECTS)
+ $(CC) -specs=../../svc_specs -mdll -o junk.tmp -Wl,--defsym,_end=end \
+ -Wl,--defsym,_edata=__data_end__ -Wl,--defsym,_etext=etext \
+ -Wl,--base-file,base.tmp $(OBJECTS)
+ - $(RM) junk.tmp
+ $(DLLTOOL) --dllname vfatfsd.sys --base-file base.tmp \
+ --output-exp temp.exp
+ - $(RM) base.tmp
+ $(CC) --verbose -Wl,--image-base,0x10000 -Wl,-e,_DriverEntry@8 \
+ -specs=../../svc_specs -mdll -o vfatfsd.sys $(OBJECTS) -Wl,temp.exp
+ - $(RM) temp.exp
-
+#include <wchar.h>
PDEVICE_EXTENSION pDevExt;
struct _VfatFCB * nextFcb, *prevFcb;
struct _VfatFCB * parentFcb;
- UCHAR *Buffer;
- long Flags;
- ULONG Cluster;
} VfatFCB, *PVfatFCB;
typedef struct
LIST_ENTRY NextCCB;
PFILE_OBJECT PtrFileObject;
LARGE_INTEGER CurrentByteOffset;
+ ULONG StartSector; // for DirectoryControl
ULONG StartEntry; //for DirectoryControl
// PSTRING DirectorySearchPattern;// for DirectoryControl ?
} VfatCCB, *PVfatCCB;
//internal functions in iface.c :
NTSTATUS FindFile(PDEVICE_EXTENSION DeviceExt, PVfatFCB Fcb,
- PVfatFCB Parent, PWSTR FileToFind,ULONG *Entry);
+ PVfatFCB Parent, PWSTR FileToFind,ULONG *StartSector,ULONG *Entry);
NTSTATUS FsdCloseFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject);
NTSTATUS FsdGetStandardInformation(PVfatFCB FCB, PDEVICE_OBJECT DeviceObject,
PFILE_STANDARD_INFORMATION StandardInfo);
NTSTATUS FsdOpenFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
PWSTR FileName);
-NTSTATUS FsdReadFile(PDEVICE_EXTENSION DeviceExt, PVfatFCB pFcb,
+NTSTATUS FsdReadFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
PVOID Buffer, ULONG Length, ULONG ReadOffset,
PULONG LengthRead);
-NTSTATUS FsdWriteFile(PDEVICE_EXTENSION DeviceExt, PVfatFCB pFcb,
- PVOID Buffer, ULONG Length, ULONG WriteOffset);
+NTSTATUS FsdWriteFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
+ PVOID Buffer, ULONG Length, ULONG WriteOffset);
ULONG GetNextWriteCluster(PDEVICE_EXTENSION DeviceExt, ULONG CurrentCluster);
-BOOLEAN IsDeletedEntry(FATDirEntry *pEntry);
-BOOLEAN IsLastEntry(FATDirEntry *pEntry);
+BOOLEAN IsDeletedEntry(PVOID Block, ULONG Offset);
+BOOLEAN IsLastEntry(PVOID Block, ULONG Offset);
wchar_t * vfat_wcsncpy(wchar_t * dest, const wchar_t *src,size_t wcount);
void VFATWriteCluster(PDEVICE_EXTENSION DeviceExt, PVOID Buffer, ULONG Cluster);
//internal functions in dirwr.c
NTSTATUS addEntry(PDEVICE_EXTENSION DeviceExt
,PFILE_OBJECT pFileObject,ULONG RequestedOptions,UCHAR ReqAttr);
-NTSTATUS updEntry(PDEVICE_EXTENSION DeviceExt,PVfatFCB pFcb);
+NTSTATUS updEntry(PDEVICE_EXTENSION DeviceExt,PFILE_OBJECT pFileObject);
//FIXME : following defines must be removed
What's new :
- some bugfixes
- support for IRP_MJ_DIRECTORY_CONTROL
- (see reactos/tst/sshell.c for use of ZwQueryDirectoryFile)
\ No newline at end of file
+ (see reactos/tst/sshell.c for use of ZwQueryDirectoryFile)
--- /dev/null
+*asm:
+
+
+*asm_final:
+
+
+*cpp:
+-remap %(cpp_cpu) %{posix:-D_POSIX_SOURCE}
+
+*cc1:
+%(cc1_spec)
+
+*cc1plus:
+
+
+*endfile:
+
+
+*link:
+%{mwindows:--subsystem windows} %{mdll:--dll -e _DriverEntry@8}
+
+*lib:
+
+
+*libgcc:
+
+
+*startfile:
+
+
+*switches_need_spaces:
+
+
+*signed_char:
+%{funsigned-char:-D__CHAR_UNSIGNED__}
+
+*predefines:
+-Di386 -D_WIN32 -DWIN32 -D__WIN32__ -D__MINGW32__ -DWINNT -D_X86_=1 -D__STDC__=1 -D__stdcall=__attribute__((__stdcall__)) _D_stdcall=__attribute__((__stdcall__)) -D__cdecl=__attribute__((__cdecl__)) -D__declspec(x)=__attribute__((x)) -Asystem(winnt) -Acpu(i386) -Amachine(i386)
+
+*cross_compile:
+1
+
+*version:
+egcs-2.91.57
+
+*multilib:
+. ;
+
+*multilib_defaults:
+
+
+*multilib_extra:
+
+
+*multilib_matches:
+
+
+*linker:
+collect2
+
+*cpp_486:
+%{!ansi:-Di486} -D__i486 -D__i486__
+
+*cpp_586:
+%{!ansi:-Di586 -Dpentium} -D__i586 -D__i586__ -D__pentium -D__pentium__
+
+*cpp_686:
+%{!ansi:-Di686 -Dpentiumpro} -D__i686 -D__i686__ -D__pentiumpro -D__pentiumpro__
+
+*cpp_cpu_default:
+%(cpp_586)
+
+*cpp_cpu:
+-Acpu(i386) -Amachine(i386) %{!ansi:-Di386} -D__i386 -D__i386__ %{mcpu=i486:%(cpp_486)} %{m486:%(cpp_486)} %{mpentium:%(cpp_586)} %{mcpu=pentium:%(cpp_586)} %{mpentiumpro:%(cpp_686)} %{mcpu=pentiumpro:%(cpp_686)} %{!mcpu*:%{!m486:%{!mpentium*:%(cpp_cpu_default)}}}
+
+*cc1_cpu:
+%{!mcpu*: %{m386:-mcpu=i386 -march=i386} %{mno-486:-mcpu=i386 -march=i386} %{m486:-mcpu=i486 -march=i486} %{mno-386:-mcpu=i486 -march=i486} %{mno-pentium:-mcpu=i486 -march=i486} %{mpentium:-mcpu=pentium} %{mno-pentiumpro:-mcpu=pentium} %{mpentiumpro:-mcpu=pentiumpro}}
+
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#define TRUE 1
#define FALSE 0
+#define PARAMETERIZED_LIBS
+
/* FUNCTIONS ****************************************************************/
int process(FILE* in, FILE* out, FILE *out2)
char* name2;
int value;
char* nr_args;
-
+ char* stmp;
+
unsigned char first1 = TRUE;
fprintf(out,"// Machine generated, don't edit\n");
// value = strtok(NULL," \t");
nr_args = (char *)strtok(NULL," \t");
+ if ((stmp=strchr(nr_args,'\n'))!=NULL)
+ {
+ *stmp=0;
+ }
+
// printf("name %s value %d\n",name,value);
#ifdef PARAMETERIZED_LIBS
fprintf(out,"__asm__(\"\\n\\t.global _%s@%s\\n\\t\"\n",name,nr_args);
sysfuncs.lst: dummy
clean: dummy
- - $(RM) ../../lib/ntdll/sysfuncs.lst
- - $(RM) ../../include/ntdll/napi.h
+ $(RM) ../../lib/ntdll/sysfuncs.lst
+ $(RM) ../../include/ntdll/napi.h
dummy:
NtFsControlFile ZwFsControlFile 40
NtGetContextThread ZwGetContextThread 8
NtGetPlugPlayEvent ZwGetPlugPlayEvent 16
-NtGetTickCount ZwGetTickCount 0
+NtGetTickCount ZwGetTickCount 4
NtImpersonateClientOfPort ZwImpersonateClientOfPort 8
NtImpersonateThread ZwImpersonateThread 12
NtInitializeRegistry ZwInitializeRegistry 4
typedef void *PVOID;
typedef unsigned char BYTE;
typedef void *LPVOID;
+typedef DWORD *PDWORD;
+typedef float *PFLOAT;
+typedef unsigned short *PWCH;
+typedef unsigned short *PWORD;
/* Check VOID before defining CHAR, SHORT, and LONG */
#ifndef VOID
typedef const CHAR *PCCH;
typedef const char *PCSTR;
typedef const unsigned short *PCWCH;
-typedef DWORD *PDWORD;
-typedef float *PFLOAT;
/* typedef PHKEY; */
typedef int *PINT;
/* typedef LCID *PLCID; */
typedef char *PTSTR;
#endif /* UNICODE */
-typedef unsigned short *PWCH;
-typedef unsigned short *PWORD;
/*
typedef PWSTR;
typedef REGSAM;
+++ /dev/null
-/*
- * conio.h
- *
- * Low level console I/O functions. Pretty please try to use the ANSI
- * standard ones if you are writing new code.
- *
- * This file is part of the Mingw32 package.
- *
- * Contributors:
- * Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
- *
- * THIS SOFTWARE IS NOT COPYRIGHTED
- *
- * This source code is offered for use in the public domain. You may
- * use, modify or distribute it freely.
- *
- * This code is distributed in the hope that it will be useful but
- * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
- * DISCLAMED. This includes but is not limited to warranties of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * $Revision: 1.4 $
- * $Author: ariadne $
- * $Date: 1999/02/25 22:51:47 $
- *
- */
-
-#ifndef __STRICT_ANSI__
-
-#ifndef _CONIO_H_
-#define _CONIO_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-char* _cgets (char* szBuffer);
-int _cprintf (const char* szFormat, ...);
-int _cputs (const char* szString);
-int _cscanf (char* szFormat, ...);
-
-int _getch (void);
-int _getche (void);
-int _kbhit (void);
-int _putch (int cPut);
-int _ungetch (int cUnget);
-
-
-#ifndef _NO_OLDNAMES
-
-#define getch _getch
-#define getche _getche
-#define kbhit _kbhit
-#define putch _putch
-#define ungetch _ungetch
-
-#endif /* Not _NO_OLDNAMES */
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* Not _CONIO_H_ */
-
-#endif /* Not __STRICT_ANSI__ */
* DISCLAMED. This includes but is not limited to warranties of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Revision: 1.1 $
- * $Author: ariadne $
- * $Date: 1999/02/25 22:51:47 $
+ * $Revision: 1.2 $
+ * $Author: rex $
+ * $Date: 1999/03/19 05:55:07 $
*
*/
--- /dev/null
+/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
+#ifndef __dj_include_conio_h_
+#define __dj_include_conio_h_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef __dj_ENFORCE_ANSI_FREESTANDING
+
+#ifndef __STRICT_ANSI__
+
+#ifndef _POSIX_SOURCE
+
+
+extern int directvideo; /* ignored by gppconio */
+extern int _wscroll;
+
+#define _NOCURSOR 0
+#define _SOLIDCURSOR 1
+#define _NORMALCURSOR 2
+
+struct text_info {
+ unsigned char winleft;
+ unsigned char wintop;
+ unsigned char winright;
+ unsigned char winbottom;
+ unsigned char attribute;
+ unsigned char normattr;
+ unsigned char currmode;
+ unsigned char screenheight;
+ unsigned char screenwidth;
+ unsigned char curx;
+ unsigned char cury;
+};
+
+enum text_modes { LASTMODE=-1, BW40=0, C40, BW80, C80, MONO=7, C4350=64 };
+
+enum COLORS {
+ /* dark colors */
+ BLACK,
+ BLUE,
+ GREEN,
+ CYAN,
+ RED,
+ MAGENTA,
+ BROWN,
+ LIGHTGRAY,
+ /* light colors */
+ DARKGRAY,
+ LIGHTBLUE,
+ LIGHTGREEN,
+ LIGHTCYAN,
+ LIGHTRED,
+ LIGHTMAGENTA,
+ YELLOW,
+ WHITE
+};
+
+#define BLINK 0x80 /* blink bit */
+
+void blinkvideo(void);
+char * cgets(char *_str);
+void clreol(void);
+void clrscr(void);
+int _conio_kbhit(void); /* checks for ungetch char */
+//int cprintf(const char *_format, ...) __attribute__((format(printf,1,2)));
+int cputs(const char *_str);
+//int cscanf(const char *_format, ...) __attribute__((format(scanf,1,2)));
+void delline(void);
+int getch(void);
+int getche(void);
+int gettext(int _left, int _top, int _right, int _bottom, void *_destin);
+void gettextinfo(struct text_info *_r);
+void gotoxy(int _x, int _y);
+void gppconio_init(void);
+void highvideo(void);
+void insline(void);
+void intensevideo(void);
+void lowvideo(void);
+int movetext(int _left, int _top, int _right, int _bottom, int _destleft, int _desttop);
+void normvideo(void);
+int putch(int _c);
+int puttext(int _left, int _top, int _right, int _bottom, void *_source);
+void _setcursortype(int _type);
+void _set_screen_lines(int _nlines);
+void textattr(int _attr);
+void textbackground(int _color);
+void textcolor(int _color);
+void textmode(int _mode);
+int ungetch(int);
+unsigned int wherex(void);
+unsigned int wherey(void);
+void window(int _left, int _top, int _right, int _bottom);
+
+#define kbhit _conio_kbhit /* Who ever includes gppconio.h probably
+ also wants _conio_kbhit and not kbhit
+ from libc */
+
+#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_conio_h_ */
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* $Revision: 1.2 $
- * $Author: ariadne $
- * $Date: 1999/03/07 13:35:10 $
+ * $Author: rex $
+ * $Date: 1999/03/19 05:55:07 $
*
*/
#ifndef _LINUX_CTYPE_H
#define _ALPHA 0x0103
-// additionally defined
-#define _PRINT 0x0200
-#define _GRAPH 0x0400
-
+/* from DJGPP, see appropriate licence */
+#define __dj_ISALNUM 0x0001
+#define __dj_ISALPHA 0x0002
+#define __dj_ISCNTRL 0x0004
+#define __dj_ISDIGIT 0x0008
+#define __dj_ISGRAPH 0x0010
+#define __dj_ISLOWER 0x0020
+#define __dj_ISPRINT 0x0040
+#define __dj_ISPUNCT 0x0080
+#define __dj_ISSPACE 0x0100
+#define __dj_ISUPPER 0x0200
+#define __dj_ISXDIGIT 0x0400
#ifdef __cplusplus
extern "C" {
int isxdigit(int c);
#ifndef __STRICT_ANSI__
-int _isctype (unsigned char c, int ctypeFlags);
+int _isctype (unsigned int c, int ctypeFlags);
#endif
int tolower(int c);
typedef int wctype_t;
/* Wide character equivalents */
-int iswalnum(int wc);
-int iswalpha(int wc);
-int iswascii(int wc);
-int iswcntrl(int wc);
-int iswctype(unsigned short wc, int wctypeFlags);
-int is_wctype(unsigned short wc, int wctypeFlags); /* Obsolete! */
-int iswdigit(int wc);
-int iswgraph(int wc);
-int iswlower(int wc);
-int iswprint(int wc);
-int iswpunct(int wc);
-int iswspace(int wc);
-int iswupper(int wc);
-int iswxdigit(int wc);
+int iswalnum(wint_t wc);
+int iswalpha(wint_t wc);
+int iswascii(wint_t wc);
+int iswcntrl(wint_t wc);
+int iswctype(wint_t wc, wctype_t wctypeFlags);
+int is_wctype(wint_t wc, wctype_t wctypeFlags); /* Obsolete! */
+int iswdigit(wint_t wc);
+int iswgraph(wint_t wc);
+int iswlower(wint_t wc);
+int iswprint(wint_t wc);
+int iswpunct(wint_t wc);
+int iswspace(wint_t wc);
+int iswupper(wint_t wc);
+int iswxdigit(wint_t wc);
wchar_t towlower(wchar_t c);
wchar_t towupper(wchar_t c);
int __iscsym (int c); /* Valid character in C symbol (after first) */
#ifndef _NO_OLDNAMES
-#define isascii(c) (!((c)&(~0x7f)))
-#define toascii(c) ((unsigned)(c) &0x7F)
-#define iscsymf(c) (isalpha(c) || ( c == '_' ))
-#define iscsym(c) (isalnum(c) || ( c == '_' ))
+int isascii (int c);
+int toascii (int c);
+int iscsymf (int c);
+int iscsym (int c);
#endif /* Not _NO_OLDNAMES */
#endif /* Not __STRICT_ANSI__ */
* DISCLAMED. This includes but is not limited to warranties of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Revision: 1.1 $
- * $Author: ariadne $
- * $Date: 1999/02/25 22:51:47 $
+ * $Revision: 1.2 $
+ * $Author: rex $
+ * $Date: 1999/03/19 05:55:07 $
*
*/
--- /dev/null
+#ifndef __include_direct_h_
+#define __include_direct_h_
+
+struct _diskfree_t {
+ unsigned short total_clusters;
+ unsigned short avail_clusters;
+ unsigned short sectors_per_cluster;
+ unsigned short bytes_per_sector;
+};
+
+
+int _chdrive( int drive );
+int _getdrive( void );
+char *_getcwd( char *buffer, int maxlen );
+
+int _chdir(const char *_path);
+char *_getcwd(char *, int);
+int _mkdir(const char *_path);
+int _rmdir(const char *_path);
+unsigned int _getdiskfree(unsigned int _drive, struct _diskfree_t *_diskspace);
+#define chdir _chdir
+#define getcwd _getcwd
+#define mkdir _mkdir
+#define rmdir _rmdir
+
+
+#endif
* DISCLAMED. This includeds but is not limited to warranties of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Revision: 1.1 $
- * $Author: ariadne $
- * $Date: 1999/02/25 22:51:47 $
+ * $Revision: 1.2 $
+ * $Author: rex $
+ * $Date: 1999/03/19 05:55:07 $
*
*/
--- /dev/null
+/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
+#ifndef __dj_include_h_
+#define __dj_include_h_
+
+#ifndef __dj_ENFORCE_ANSI_FREESTANDING
+
+#ifndef __STRICT_ANSI__
+
+#ifndef _POSIX_SOURCE
+
+
+
+struct ftime {
+ unsigned ft_tsec:5; /* 0-29, double to get real seconds */
+ unsigned ft_min:6; /* 0-59 */
+ unsigned ft_hour:5; /* 0-23 */
+ unsigned ft_day:5; /* 1-31 */
+ unsigned ft_month:4; /* 1-12 */
+ unsigned ft_year:7; /* since 1980 */
+};
+
+struct date {
+ short da_year;
+ char da_day;
+ char da_mon;
+};
+
+struct time {
+ unsigned char ti_min;
+ unsigned char ti_hour;
+ unsigned char ti_hund;
+ unsigned char ti_sec;
+};
+
+struct dfree {
+ unsigned df_avail;
+ unsigned df_total;
+ unsigned df_bsec;
+ unsigned df_sclus;
+};
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern unsigned short _osmajor, _osminor;
+extern const char * _os_flavor;
+
+unsigned short _get_version(int);
+
+
+
+
+int getftime(int handle, struct ftime *ftimep);
+int setftime(int handle, struct ftime *ftimep);
+
+int getcbrk(void);
+int setcbrk(int new_value);
+
+void getdate(struct date *);
+void gettime(struct time *);
+void setdate(struct date *);
+void settime(struct time *);
+
+void getdfree(unsigned char drive, struct dfree *ptr);
+
+void delay(unsigned msec);
+/* int _get_default_drive(void);
+void _fixpath(const char *, char *); */
+
+
+/*
+ * For compatibility with other DOS C compilers.
+ */
+
+#define _A_NORMAL 0x00 /* Normal file - No read/write restrictions */
+#define _A_RDONLY 0x01 /* Read only file */
+#define _A_HIDDEN 0x02 /* Hidden file */
+#define _A_SYSTEM 0x04 /* System file */
+#define _A_VOLID 0x08 /* Volume ID file */
+#define _A_SUBDIR 0x10 /* Subdirectory */
+#define _A_ARCH 0x20 /* Archive file */
+
+#define _enable enable
+#define _disable disable
+
+struct date_t {
+ unsigned char day; /* 1-31 */
+ unsigned char month; /* 1-12 */
+ unsigned short year; /* 1980-2099 */
+ unsigned char dayofweek; /* 0-6, 0=Sunday */
+};
+#define dosdate_t date_t
+
+struct time_t {
+ unsigned char hour; /* 0-23 */
+ unsigned char minute; /* 0-59 */
+ unsigned char second; /* 0-59 */
+ unsigned char hsecond; /* 0-99 */
+};
+#define dostime_t time_t
+
+
+
+#define finddata_t _finddata_t
+
+
+#define diskfree_t _diskfree_t
+
+struct _DOSERROR {
+ int exterror;
+ #ifdef __cplusplus
+ char errclass;
+ #else
+ char class;
+ #endif
+ char action;
+ char locus;
+};
+#define DOSERROR _DOSERROR
+
+
+
+
+void _getdate(struct date_t *_date);
+unsigned int _setdate(struct date_t *_date);
+void _gettime(struct time_t *_time);
+unsigned int _settime(struct time_t *_time);
+
+unsigned int _getftime(int _handle, unsigned int *_p_date, unsigned int *_p_time);
+unsigned int _setftime(int _handle, unsigned int _date, unsigned int _time);
+unsigned int _getfileattr(const char *_filename, unsigned int *_p_attr);
+unsigned int _setfileattr(const char *_filename, unsigned int _attr);
+
+
+void _setdrive(unsigned int _drive, unsigned int *_p_drives);
+
+
+int exterr(struct _DOSERROR *_p_error);
+#define dosexterr(_ep) exterr(_ep)
+
+#include <direct.h>
+
+#define int386(_i, _ir, _or) int86(_i, _ir, _or)
+#define int386x(_i, _ir, _or, _sr) int86x(_i, _ir, _or, _sr)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* !_POSIX_SOURCE */
+#endif /* !__STRICT_ANSI__ */
+#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */
+
+#ifndef __dj_ENFORCE_FUNCTION_CALLS
+#endif /* !__dj_ENFORCE_FUNCTION_CALLS */
+
+#endif /* !__dj_include_h_ */
* DISCLAMED. This includes but is not limited to warranties of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Revision: 1.1 $
- * $Author: ariadne $
- * $Date: 1999/02/25 22:51:47 $
+ * $Revision: 1.2 $
+ * $Author: rex $
+ * $Date: 1999/03/19 05:55:07 $
*
*/
* sys_errlist.
*/
int* _errno(void);
-#define errno (*_errno(void))
+#define errno (*_errno())
int* __doserrno(void);
-#define _doserrno (*__doserrno(void))
+#define _doserrno (*__doserrno())
#if __MSVCRT__
/* One of the MSVCRTxx libraries */
--- /dev/null
+/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
+#ifndef __dj_include_fcntl_h_
+#define __dj_include_fcntl_h_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define _IOREAD 000010
+#define _IOWRT 000020
+#define _IOMYBUF 000040
+#define _IOEOF 000100
+#define _IOERR 000200
+#define _IOSTRG 000400
+#define _IORW 001000
+#define _IOAPPEND 002000
+#define _IORMONCL 004000 /* remove on close, for temp files */
+/* if _flag & _IORMONCL, ._name_to_remove needs freeing */
+#define _IOUNGETC 010000 /* there is an ungetc'ed character in the buffer */
+
+
+#ifndef __dj_ENFORCE_ANSI_FREESTANDING
+
+#ifndef __STRICT_ANSI__
+
+#define FD_CLOEXEC 0x0001
+
+#define F_DUPFD 1
+#define F_GETFD 2
+#define F_GETFL 3
+#define F_GETLK 4
+#define F_SETFD 5
+#define F_SETFL 6
+#define F_SETLK 7
+#define F_SETLKW 8
+
+#define F_UNLCK 0
+#define F_RDLCK 1
+#define F_WRLCK 2
+
+#define O_RDONLY 0x0000
+#define O_WRONLY 0x0001
+#define O_RDWR 0x0002
+#define O_ACCMODE 0x0003
+
+#define O_BINARY 0x0004 /* must fit in char, reserved by dos */
+#define O_TEXT 0x0008 /* must fit in char, reserved by dos */
+
+#define O_RANDOM 0x0010
+#define O_SEQUENTIAL 0x0020
+
+
+#define O_TEMPORARY 0x0040
+
+/* temporary access hint */
+
+
+
+/* sequential/random access hints */
+
+
+
+
+#define O_NOINHERIT 0x0080 /* DOS-specific */
+
+#define O_CREAT 0x0100 /* second byte, away from DOS bits */
+#define O_EXCL 0x0200
+#define O_NOCTTY 0x0400
+#define O_TRUNC 0x0800
+#define O_APPEND 0x1000
+#define O_NONBLOCK 0x2000
+
+#define O_SHORT_LIVED 0x1000
+
+//#include <sys/types.h>
+#include <sys/stat.h>
+
+//typedef int dev_t;
+//typedef int ino_t;
+//typedef int mode_t;
+//typedef int nlink_t;
+
+#include <io.h>
+
+
+struct flock {
+ off_t l_len;
+ pid_t l_pid;
+ off_t l_start;
+ short l_type;
+ short l_whence;
+};
+
+extern int _fmode; /* O_TEXT or O_BINARY */
+
+//int open(const char *_path, int _oflag, ...);
+//int creat(const char *_path, int _mode);
+int fcntl(int _fildes, int _cmd, ...);
+
+#ifndef _POSIX_SOURCE
+
+
+#define S_IREAD S_IRUSR
+#define S_IWRITE S_IWUSR
+#define S_IEXEC S_IXUSR
+
+/*
+ * For compatibility with other DOS C compilers.
+ */
+
+#define _O_RDONLY O_RDONLY
+#define _O_WRONLY O_WRONLY
+#define _O_RDWR O_RDWR
+#define _O_APPEND O_APPEND
+#define _O_CREAT O_CREAT
+#define _O_TRUNC O_TRUNC
+#define _O_EXCL O_EXCL
+#define _O_TEXT O_TEXT
+#define _O_BINARY O_BINARY
+#define _O_NOINHERIT O_NOINHERIT
+#define _O_RANDOM O_RANDOM
+#define _O_SEQUENTIAL O_RANDOM
+#define _O_SHORT_LIVED O_SHORT_LIVED
+#define _O_TEMPORARY O_TEMPORARY
+
+#define _S_IREAD S_IRUSR
+#define _S_IWRITE S_IWUSR
+#define _S_IEXEC S_IXUSR
+
+/*
+ * Support for advanced filesystems (Windows 9x VFAT, NTFS, LFN etc.)
+ */
+
+#define _FILESYS_UNKNOWN 0x80000000U
+#define _FILESYS_CASE_SENSITIVE 0x0001
+#define _FILESYS_CASE_PRESERVED 0x0002
+#define _FILESYS_UNICODE 0x0004
+#define _FILESYS_LFN_SUPPORTED 0x4000
+#define _FILESYS_VOL_COMPRESSED 0x8000
+
+unsigned _get_volume_info (const char *_path, int *_max_file_len, int *_max_path_len, char *_filesystype);
+char _use_lfn (const char *_path);
+char *_lfn_gen_short_fname (const char *_long_fname, char *_short_fname);
+
+#define _LFN_CTIME 1
+#define _LFN_ATIME 2
+
+unsigned _lfn_get_ftime (int _handle, int _which);
+
+char _preserve_fncase (void);
+#define _USE_LFN _use_lfn(0) /* assume it's the same on ALL drives */
+
+#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_fcntl_h_ */
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* $Revision: 1.2 $
- * $Author: ariadne $
- * $Date: 1999/03/07 13:35:10 $
+ * $Author: rex $
+ * $Date: 1999/03/19 05:55:07 $
*
*/
unsigned int _control87 (unsigned int unNew, unsigned int unMask);
-unsigned int _clearfp (void); /* Clear the FPU status word */
-unsigned int _statusfp (void); /* Report the FPU status word */
+unsigned int _clearfp (); /* Clear the FPU status word */
+unsigned int _statusfp (); /* Report the FPU status word */
#define _clear87 _clearfp
#define _status87 _statusfp
-void _fpreset (void); /* Reset the FPU */
+void _fpreset (); /* Reset the FPU */
/* Global 'variable' for the current floating point error code. */
-int * __fpecode(void);
+int * __fpecode();
#define _fpecode (*(__fpecode()))
/*
* DISCLAMED. This includes but is not limited to warranties of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Revision: 1.5 $
- * $Author: ariadne $
- * $Date: 1999/03/07 13:35:10 $
+ * $Revision: 1.2 $
+ * $Author: rex $
+ * $Date: 1999/03/19 05:55:07 $
*
*/
/* Appropriated for Reactos Crtdll by Ariadne */
* DISCLAMED. This includes but is not limited to warranties of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Revision: 1.1 $
- * $Author: ariadne $
- * $Date: 1999/02/25 22:51:47 $
+ * $Revision: 1.2 $
+ * $Author: rex $
+ * $Date: 1999/03/19 05:55:07 $
*
*/
* DISCLAMED. This includes but is not limited to warranties of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Revision: 1.3 $
- * $Author: ariadne $
- * $Date: 1999/03/07 13:35:10 $
+ * $Revision: 1.2 $
+ * $Author: rex $
+ * $Date: 1999/03/19 05:55:09 $
*
*/
/* Appropriated for Reactos Crtdll by Ariadne */
#define _SH_DENYRD SH_DENYRD
#define _SH_DENYNO SH_DENYNO
-#endif
\ No newline at end of file
+#endif
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* $Revision: 1.2 $
- * $Author: ariadne $
- * $Date: 1999/03/07 13:35:10 $
+ * $Author: rex $
+ * $Date: 1999/03/19 05:55:09 $
*
*/
/* added some extra signal constants */
* DISCLAMED. This includes but is not limited to warranties of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Revision: 1.1 $
- * $Author: ariadne $
- * $Date: 1999/02/21 13:29:56 $
+ * $Revision: 1.2 $
+ * $Author: rex $
+ * $Date: 1999/03/19 05:55:09 $
*
*/
/* Appropriated for Reactos Crtdll by Ariadne */
* DISCLAMED. This includes but is not limited to warranties of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Revision: 1.3 $
- * $Author: ariadne $
- * $Date: 1999/02/21 20:59:55 $
+ * $Revision: 1.2 $
+ * $Author: rex $
+ * $Date: 1999/03/19 05:55:09 $
*
*/
--- /dev/null
+/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
+
+#ifndef __dj_include_stdio_h_
+#define __dj_include_stdio_h_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef __dj_ENFORCE_ANSI_FREESTANDING
+
+#include <sys/djtypes.h>
+
+#define _IOFBF 00001
+#define _IONBF 00002
+#define _IOLBF 00004
+
+#define BUFSIZ 16384
+#define EOF (-1)
+#define FILENAME_MAX 260
+#define FOPEN_MAX 20
+#define L_tmpnam 260
+#ifndef NULL
+#define NULL 0
+#endif
+#define TMP_MAX 999999
+
+#define SEEK_SET 0
+#define SEEK_CUR 1
+#define SEEK_END 2
+
+#define _IOREAD 000010
+#define _IOWRT 000020
+#define _IOMYBUF 000040
+#define _IOEOF 000100
+#define _IOERR 000200
+#define _IOSTRG 000400
+#define _IORW 001000
+#define _IOAPPEND 002000
+#define _IORMONCL 004000 /* remove on close, for temp files */
+/* if _flag & _IORMONCL, ._name_to_remove needs freeing */
+#define _IOUNGETC 010000 /* there is an ungetc'ed character in the buffer */
+
+
+#include <internal/types.h>
+
+__DJ_va_list
+#undef __DJ_va_list
+#define __DJ_va_list
+
+#ifndef _FILE_DEFINED
+typedef struct {
+ char *_ptr;
+ int _cnt;
+ char *_base;
+ int _flag;
+ int _file;
+ int _ungotchar;
+ int _bufsiz;
+ char *_name_to_remove;
+} FILE;
+#define _FILE_DEFINED
+#endif
+
+typedef unsigned long fpos_t;
+
+extern FILE _iob[];
+
+#define stdin (&_iob[0])
+#define stdout (&_iob[1])
+#define stderr (&_iob[2])
+#define stdaux (&_iob[3])
+#define stdprn (&_iob[4])
+
+void clearerr(FILE *_stream);
+int fclose(FILE *_stream);
+int feof(FILE *_stream);
+int ferror(FILE *_stream);
+int fflush(FILE *_stream);
+int fgetc(FILE *_stream);
+int fgetpos(FILE *_stream, fpos_t *_pos);
+char * fgets(char *_s, int _n, FILE *_stream);
+FILE * fopen(const char *_filename, const char *_mode);
+int fprintf(FILE *_stream, const char *_format, ...);
+int fputc(int _c, FILE *_stream);
+int fputs(const char *_s, FILE *_stream);
+size_t fread(void *_ptr, size_t _size, size_t _nelem, FILE *_stream);
+FILE * freopen(const char *_filename, const char *_mode, FILE *_stream);
+int fscanf(FILE *_stream, const char *_format, ...);
+int fseek(FILE *_stream, long _offset, int _mode);
+int fsetpos(FILE *_stream, const fpos_t *_pos);
+long ftell(FILE *_stream);
+size_t fwrite(const void *_ptr, size_t _size, size_t _nelem, FILE *_stream);
+int getc(FILE *_stream);
+int getchar(void);
+char * gets(char *_s);
+void perror(const char *_s);
+int printf(const char *_format, ...);
+int putc(int _c, FILE *_stream);
+int putchar(int _c);
+int puts(const char *_s);
+int remove(const char *_filename);
+int rename(const char *_old, const char *_new);
+void rewind(FILE *_stream);
+int scanf(const char *_format, ...);
+void setbuf(FILE *_stream, char *_buf);
+int setvbuf(FILE *_stream, char *_buf, int _mode, size_t _size);
+int sprintf(char *_s, const char *_format, ...);
+int sscanf(const char *_s, const char *_format, ...);
+FILE * tmpfile(void);
+char * tmpnam(char *_s);
+char * _tmpnam(char *_s);
+int ungetc(int _c, FILE *_stream);
+int vfprintf(FILE *_stream, const char *_format, va_list _ap);
+int vprintf(const char *_format, va_list _ap);
+int vsprintf(char *_s, const char *_format, va_list _ap);
+
+#ifndef __STRICT_ANSI__
+
+#define L_ctermid
+#define L_cusrid
+/* #define STREAM_MAX 20 - DOS can change this */
+
+int fileno(FILE *_stream);
+int _fileno(FILE *_stream);
+FILE * fdopen(int _fildes, const char *_type);
+int pclose(FILE *_pf);
+FILE * popen(const char *_command, const char *_mode);
+
+#ifndef _POSIX_SOURCE
+
+void _djstat_describe_lossage(FILE *_to_where);
+int _doprnt(const char *_fmt, va_list _args, FILE *_f);
+int _doscan(FILE *_f, const char *_fmt, void **_argp);
+int _doscan_low(FILE *, int (*)(FILE *_get), int (*_unget)(int, FILE *), const char *_fmt, void **_argp);
+int fpurge(FILE *_f);
+int getw(FILE *_f);
+int mkstemp(char *_template);
+char * mktemp(char *_template);
+int putw(int _v, FILE *_f);
+void setbuffer(FILE *_f, void *_buf, int _size);
+void setlinebuf(FILE *_f);
+char * tempnam(const char *_dir, const char *_prefix);
+int _rename(const char *_old, const char *_new); /* Simple (no directory) */
+
+#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_stdio_h_ */
* DISCLAMED. This includes but is not limited to warranties of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Revision: 1.3 $
- * $Author: ariadne $
- * $Date: 1999/02/25 22:51:47 $
+ * $Revision: 1.2 $
+ * $Author: rex $
+ * $Date: 1999/03/19 05:55:09 $
*
*/
/* Appropriated for Reactos Crtdll by Ariadne */
--- /dev/null
+/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
+#ifndef __dj_include_sys_stat_h_
+#define __dj_include_sys_stat_h_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef __dj_ENFORCE_ANSI_FREESTANDING
+
+#ifndef __STRICT_ANSI__
+
+#define S_ISBLK(m) (((m) & 0xf000) == 0x1000)
+#define S_ISCHR(m) (((m) & 0xf000) == 0x2000)
+#define S_ISDIR(m) (((m) & 0xf000) == 0x3000)
+#define S_ISFIFO(m) (((m) & 0xf000) == 0x4000)
+#define S_ISREG(m) (((m) & 0xf000) == 0x0000)
+
+#define S_ISUID 0x80000000
+#define S_ISGID 0x40000000
+
+#define S_IRUSR 00400
+#define S_IRGRP 00040
+#define S_IROTH 00004
+#define S_IWUSR 00200
+#define S_IWGRP 00020
+#define S_IWOTH 00002
+#define S_IXUSR 00100
+#define S_IXGRP 00010
+#define S_IXOTH 00001
+#define S_IRWXU 00700
+#define S_IRWXG 00070
+#define S_IRWXO 00007
+
+#include <sys/types.h>
+#include <internal/types.h>
+//#include <sys/djtypes.h>
+__DJ_time_t
+#undef __DJ_time_t
+#define __DJ_time_t
+
+struct stat {
+ time_t st_atime;
+ time_t st_ctime;
+ dev_t st_dev;
+ gid_t st_gid;
+ ino_t st_ino;
+ mode_t st_mode;
+ time_t st_mtime;
+ nlink_t st_nlink;
+ off_t st_size;
+ off_t st_blksize;
+ uid_t st_uid;
+ dev_t st_rdev; /* unused */
+};
+
+int chmod(const char *_path, mode_t _mode);
+int fstat(int _fildes, struct stat *_buf);
+//int mkdir(const char *_path, mode_t _mode);
+int mkfifo(const char *_path, mode_t _mode);
+int stat(const char *_path, struct stat *_buf);
+mode_t umask(mode_t _cmask);
+
+#ifndef _POSIX_SOURCE
+
+/* POSIX.1 doesn't mention these at all */
+
+#define S_IFMT 0xf000
+
+#define S_IFREG 0x0000
+#define S_IFBLK 0x1000
+#define S_IFCHR 0x2000
+#define S_IFDIR 0x3000
+#define S_IFIFO 0x4000
+#define S_IFFIFO S_IFIFO
+
+#define S_IFLABEL 0x5000
+#define S_ISLABEL(m) (((m) & 0xf000) == 0x5000)
+
+void _fixpath(const char *, char *);
+unsigned short _get_magic(const char *, int);
+int _is_executable(const char *, int, const char *);
+int mknod(const char *_path, mode_t _mode, dev_t _dev);
+char * _truename(const char *, char *);
+
+/* Bit-mapped variable _djstat_flags describes what expensive
+ f?stat() features our application needs. If you don't need a
+ feature, set its bit in the variable. By default, all the
+ bits are cleared (i.e., you get the most expensive code). */
+#define _STAT_INODE 1 /* should we bother getting inode numbers? */
+#define _STAT_EXEC_EXT 2 /* get execute bits from file extension? */
+#define _STAT_EXEC_MAGIC 4 /* get execute bits from magic signature? */
+#define _STAT_DIRSIZE 8 /* compute directory size? */
+#define _STAT_ROOT_TIME 0x10 /* try to get root dir time stamp? */
+#define _STAT_WRITEBIT 0x20 /* fstat() needs write bit? */
+
+extern unsigned short _djstat_flags;
+
+/* Bit-mapped variable _djstat_fail_bits describes which individual
+ undocumented features f?stat() failed to use. To get a human-
+ readable description of the bits, call _djstat_describe_lossage(). */
+#define _STFAIL_SDA 1 /* Get SDA call failed */
+#define _STFAIL_OSVER 2 /* Unsupported DOS version */
+#define _STFAIL_BADSDA 4 /* Bad pointer to SDA */
+#define _STFAIL_TRUENAME 8 /* _truename() failed */
+#define _STFAIL_HASH 0x10 /* inode defaults to hashing */
+#define _STFAIL_LABEL 0x20 /* Root dir, but no volume label */
+#define _STFAIL_DCOUNT 0x40 /* dirent_count ridiculously large */
+#define _STFAIL_WRITEBIT 0x80 /* fstat() failed to get write access bit */
+#define _STFAIL_DEVNO 0x100 /* fstat() failed to get device number */
+#define _STFAIL_BADSFT 0x200 /* SFT entry found, but can't be trusted */
+#define _STFAIL_SFTIDX 0x400 /* bad SFT index in JFT */
+#define _STFAIL_SFTNF 0x800 /* file entry not found in SFT array */
+
+extern unsigned short _djstat_fail_bits;
+
+#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_sys_stat_h_ */
--- /dev/null
+/* Copyright (C) 1997 DJ Delorie, see COPYING.DJ for details */
+/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
+#ifndef __dj_include_sys_types_h_
+#define __dj_include_sys_types_h_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef __dj_ENFORCE_ANSI_FREESTANDING
+
+#ifndef __STRICT_ANSI__
+
+#include <sys/djtypes.h>
+
+typedef int dev_t;
+typedef int ino_t;
+typedef int mode_t;
+typedef int nlink_t;
+
+__DJ_gid_t
+#undef __DJ_gid_t
+#define __DJ_gid_t
+__DJ_off_t
+#undef __DJ_off_t
+#define __DJ_off_t
+__DJ_pid_t
+#undef __DJ_pid_t
+#define __DJ_pid_t
+//__DJ_size_t
+#undef __DJ_size_t
+#define __DJ_size_t
+__DJ_ssize_t
+#undef __DJ_ssize_t
+#define __DJ_ssize_t
+__DJ_uid_t
+#undef __DJ_uid_t
+#define __DJ_uid_t
+
+#ifndef _POSIX_SOURCE
+
+/* Allow including program to override. */
+#ifndef FD_SETSIZE
+#define FD_SETSIZE 256
+#endif
+
+typedef struct fd_set {
+ unsigned char fd_bits [((FD_SETSIZE) + 7) / 8];
+} fd_set;
+
+#define FD_SET(n, p) ((p)->fd_bits[(n) / 8] |= (1 << ((n) & 7)))
+#define FD_CLR(n, p) ((p)->fd_bits[(n) / 8] &= ~(1 << ((n) & 7)))
+#define FD_ISSET(n, p) ((p)->fd_bits[(n) / 8] & (1 << ((n) & 7)))
+#define FD_ZERO(p) memset ((void *)(p), 0, sizeof (*(p)))
+
+#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_sys_types_h_ */
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* $Revision: 1.2 $
- * $Author: ariadne $
- * $Date: 1999/02/21 13:29:57 $
+ * $Author: rex $
+ * $Date: 1999/03/19 05:55:10 $
*
*/
/* Appropriated for Reactos Crtdll by Ariadne */
+extern POBJECT_TYPE ExEventType;
typedef ULONG INTERLOCKED_RESULT;
typedef ULONG WORK_QUEUE_TYPE;
#define FILE_EXISTS 0x0004
#define FILE_DOES_NOT_EXIST 0x0005
-/*
- * ByteOffset parameter : special values
- */
-
-#define FILE_WRITE_TO_END_OF_FILE 0xffffffff
-#define FILE_USE_FILE_POINTER_POSITION 0xfffffffe
/*
* file creation flags
HANDLE DeleteHandle;
} u;
} SetFile;
-
- /*
- * This is a guess
- */
struct
{
ULONG Length;
typedef struct _IO_STATUS_BLOCK
{
- /*
- * Is the completion status
- */
NTSTATUS Status;
-
- /*
- * Is a request dependant value
- */
ULONG Information;
} IO_STATUS_BLOCK, *PIO_STATUS_BLOCK;
} KSEMAPHORE, *PKSEMAPHORE;
typedef struct _KEVENT
-/*
- * PURPOSE: Describes an event
- */
{
- /*
- * PURPOSE: So we can use the general wait routine
- */
DISPATCHER_HEADER Header;
} KEVENT, *PKEVENT;
struct _KINTERRUPT;
typedef BOOLEAN (*PKSERVICE_ROUTINE)(struct _KINTERRUPT* Interrupt,
- PVOID ServiceContext);
+ PVOID ServiceContext);
typedef struct _KINTERRUPT
{
#include <ddk/pstypes.h>
#include <ddk/zwtypes.h>
#include <ddk/ioctrl.h>
-
#include <ddk/rtl.h>
#include <internal/hal/ddk.h>
+
#include <ddk/zw.h>
#include <ddk/cmfuncs.h>
#include <ddk/exfuncs.h>
// Heap creation routine
-HANDLE
-STDCALL
-RtlCreateHeap(
- ULONG Flags,
- PVOID BaseAddress,
- ULONG SizeToReserve,
- ULONG SizeToCommit,
- PVOID Unknown,
- PRTL_HEAP_DEFINITION Definition
- );
+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
- );
+PVOID STDCALL RtlAllocateHeap(HANDLE Heap,
+ ULONG Flags,
+ ULONG Size);
-BOOLEAN
-STDCALL
-RtlFreeHeap(
- HANDLE Heap,
- ULONG Flags,
- PVOID Address
- );
+BOOLEAN STDCALL RtlFreeHeap(HANDLE Heap,
+ ULONG Flags,
+ PVOID Address);
NTSTATUS RtlUnicodeStringToAnsiString(IN OUT PANSI_STRING DestinationString,
IN PUNICODE_STRING SourceString,
STATUS_ALREADY_DISCONNECTED,
STATUS_LONGJUMP,
- STATUS_UNSUCCESSFUL=0xC0000001,
+ STATUS_UNSUCCESSFUL=0xC0000001,
STATUS_NOT_IMPLEMENTED,
STATUS_INVALID_INFO_CLASS,
STATUS_INFO_LENGTH_MISMATCH,
STATUS_INVALID_PARAMETER,
STATUS_NO_SUCH_DEVICE,
STATUS_NO_SUCH_FILE,
+
+// c0000010
STATUS_INVALID_DEVICE_REQUEST,
STATUS_END_OF_FILE,
STATUS_WRONG_VOLUME,
STATUS_ILLEGAL_INSTRUCTION,
STATUS_INVALID_LOCK_SEQUENCE,
STATUS_INVALID_VIEW_SIZE,
+
+// c0000020
STATUS_INVALID_FILE_FOR_SECTION,
STATUS_ALREADY_COMMITTED,
STATUS_ACCESS_DENIED,
#ifndef __DDK_ZW_H
#define __DDK_ZW_H
+
#include <windows.h>
//#ifndef WIN32_LEAN_AND_MEAN
-#define PTOKEN_USER PVOID
#define PTOKEN_GROUPS PVOID
-#define PTOKEN_OWNER PVOID
#define PTOKEN_PRIVILEGES PVOID
-#define PTOKEN_PRIMARY_GROUP PVOID
-#define PTOKEN_DEFAULT_DACL PVOID
-#define PTOKEN_SOURCE PVOID
#define TOKEN_INFORMATION_CLASS CINT
#define LCID ULONG
#define SECURITY_INFORMATION ULONG
IN ULONG Protect
);
-NTSTATUS
-STDCALL
-ZwAllocateVirtualMemory(
- IN HANDLE ProcessHandle,
- IN OUT PVOID *BaseAddress,
- IN ULONG ZeroBits,
- IN OUT PULONG RegionSize,
- IN ULONG AllocationType,
- IN ULONG Protect
- );
+NTSTATUS STDCALL ZwAllocateVirtualMemory(IN HANDLE ProcessHandle,
+ IN OUT PVOID *BaseAddress,
+ IN ULONG ZeroBits,
+ IN OUT PULONG RegionSize,
+ IN ULONG AllocationType,
+ IN ULONG Protect);
+
/*
* FUNCTION: Returns from a callback into user mode
* ARGUMENTS:
IN CINT TimerType
);
-/*
- * FUNCTION: Creates a token.
- * ARGUMENTS:
- * TokenHandle (OUT) = Caller supplied storage for the resulting handle
- * DesiredAccess = Specifies the allowed or desired access to the process can
- * be a combinate of STANDARD_RIGHTS_REQUIRED| ..
- * ObjectAttribute = Initialized attributes for the object, contains the rootdirectory and the filename
- * TokenType =
- * AuthenticationId =
- * ExpirationTime =
- * TokenUser =
- * TokenGroups =
- * TokenPrivileges =
- * TokenOwner =
- * TokenPrimaryGroup =
- * TokenDefaultDacl =
- * TokenSource =
- * REMARKS:
- * This function does not map to a win32 function
- * RETURNS: Status
- */
-
-NTSTATUS
-STDCALL
-NtCreateToken(
- OUT PHANDLE TokenHandle,
- IN ACCESS_MASK DesiredAccess,
- IN POBJECT_ATTRIBUTES ObjectAttributes,
- IN TOKEN_TYPE TokenType,
- IN PLUID AuthenticationId,
- IN PLARGE_INTEGER ExpirationTime,
- IN PTOKEN_USER TokenUser,
- IN PTOKEN_GROUPS TokenGroups,
- IN PTOKEN_PRIVILEGES TokenPrivileges,
- IN PTOKEN_OWNER TokenOwner,
- IN PTOKEN_PRIMARY_GROUP TokenPrimaryGroup,
- IN PTOKEN_DEFAULT_DACL TokenDefaultDacl,
- IN PTOKEN_SOURCE TokenSource
- );
-
-NTSTATUS
-STDCALL
-ZwCreateToken(
- OUT PHANDLE TokenHandle,
- IN ACCESS_MASK DesiredAccess,
- IN POBJECT_ATTRIBUTES ObjectAttributes,
- IN TOKEN_TYPE TokenType,
- IN PLUID AuthenticationId,
- IN PLARGE_INTEGER ExpirationTime,
- IN PTOKEN_USER TokenUser,
- IN PTOKEN_GROUPS TokenGroups,
- IN PTOKEN_PRIVILEGES TokenPrivileges,
- IN PTOKEN_OWNER TokenOwner,
- IN PTOKEN_PRIMARY_GROUP TokenPrimaryGroup,
- IN PTOKEN_DEFAULT_DACL TokenDefaultDacl,
- IN PTOKEN_SOURCE TokenSource
- );
/*
* FUNCTION: Returns the callers thread TEB.
NTSTATUS STDCALL NtConnectPort(VOID);
NTSTATUS STDCALL NtCreatePort(VOID);
+NTSTATUS STDCALL NtCreateToken(VOID);
NTSTATUS STDCALL NtGetPlugPlayEvent(VOID);
NTSTATUS STDCALL NtImpersonateClientOfPort(VOID);
PVOID DevCapsRoutine;
PVOID HwSetVolume;
ULONG IoMethod;
-}SOUND_DEVICE_INIT;
\ No newline at end of file
+}SOUND_DEVICE_INIT;
+++ /dev/null
-/*
- * direct.h
- *
- * Functions for manipulating paths and directories (included from dir.h)
- * plus functions for setting the current drive.
- *
- * This file is part of the Mingw32 package.
- *
- * Contributors:
- * Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
- *
- * THIS SOFTWARE IS NOT COPYRIGHTED
- *
- * This source code is offered for use in the public domain. You may
- * use, modify or distribute it freely.
- *
- * This code is distributed in the hope that it will be useful but
- * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
- * DISCLAMED. This includes but is not limited to warranties of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * $Revision: 1.3 $
- * $Author: ariadne $
- * $Date: 1999/02/25 22:51:47 $
- *
- */
-
-#ifndef __STRICT_ANSI__
-
-#ifndef _DIRECT_H_
-#define _DIRECT_H_
-
-#include <dir.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct _diskfree_t {
- unsigned long total_clusters;
- unsigned long avail_clusters;
- unsigned long sectors_per_cluster;
- unsigned long bytes_per_sector;
-};
-#define diskfree_t _diskfree_t
-
-/*
- * You really shouldn't be using these. Use the Win32 API functions instead.
- * However, it does make it easier to port older code.
- */
-
-
-int _chdrive (int nDrive);
-char* _getdcwd (int nDrive, char* caBuffer, int nBufLen);
-unsigned int _getdiskfree(unsigned int _drive, struct _diskfree_t *_diskspace);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* Not _DIRECT_H_ */
-
-#endif /* Not __STRICT_ANSI__ */
+++ /dev/null
-/*
- * dos.h
- *
- * Definitions for MS-DOS interface routines
- *
- * This header file is meant for use with CRTDLL.DLL as included with
- * Windows 95(tm) and Windows NT(tm). In conjunction with other versions
- * of the standard C library things may or may not work so well.
- *
- * Contributors:
- * Created by J.J. van der Heijden <J.J.vanderHeijden@student.utwente.nl>
- *
- * THIS SOFTWARE IS NOT COPYRIGHTED
- *
- * This source code is offered for use in the public domain. You may
- * use, modify or distribute it freely.
- *
- * This code is distributed in the hope that it will be useful but
- * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
- * DISCLAMED. This includes but is not limited to warranties of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef __STRICT_ANSI__
-
-#ifndef _DOS_H_
-#define _DOS_H_
-
-#define __need_wchar_t
-#include <stddef.h>
-
-/* For DOS file attributes */
-#include <dir.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern char** __imp__pgmptr_dll;
-#define _pgmptr (*__imp__pgmptr_dll)
-
-/* Wide character equivalent */
-extern wchar_t** __imp__wpgmptr_dll;
-#define _wpgmptr (*__imp__wpgmptr_dll)
-
-/* These are obsolete, but some may find them useful */
-extern unsigned int* __imp__basemajor_dll;
-extern unsigned int* __imp__baseminor_dll;
-extern unsigned int* __imp__baseversion_dll;
-extern unsigned int* __imp__osmajor_dll;
-extern unsigned int* __imp__osminor_dll;
-extern unsigned int* __imp__osversion_dll;
-
-#define _basemajor (*__imp__basemajor_dll)
-#define _baseminor (*__imp__baseminor_dll)
-#define _baseversion (*__imp__baseversion_dll)
-#define _osmajor (*__imp__osmajor_dll)
-#define _osminor (*__imp__osminor_dll)
-#define _osversion (*__imp__osversion_dll)
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _DOS_H_ */
-
-#endif /* Not __STRICT_ANSI__ */
-
+++ /dev/null
-/*
- * fcntl.h
- *
- * Access constants for _open. Note that the permissions constants are
- * in sys/stat.h (ick).
- *
- * This code is part of the Mingw32 package.
- *
- * Contributors:
- * Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
- *
- * THIS SOFTWARE IS NOT COPYRIGHTED
- *
- * This source code is offered for use in the public domain. You may
- * use, modify or distribute it freely.
- *
- * This code is distributed in the hope that it will be useful but
- * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
- * DISCLAMED. This includes but is not limited to warranties of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * $Revision: 1.2 $
- * $Author: ariadne $
- * $Date: 1999/02/21 13:29:56 $
- *
- */
-/* Appropriated for Reactos Crtdll by Ariadne */
-/* added _O_RANDOM_O_SEQUENTIAL _O_SHORT_LIVED*/
-#ifndef _FCNTL_H_
-#define _FCNTL_H_
-
-/*
- * It appears that fcntl.h should include io.h for compatibility...
- */
-#include <io.h>
-
-/*
- * This variable determines the default file mode.
- * TODO: Which flags work?
- */
-#if __MSVCRT__
-extern unsigned int* __imp__fmode;
-#define _fmode (*__imp__fmode)
-#else
-/* CRTDLL */
-extern unsigned int* __imp__fmode_dll;
-#define _fmode (*__imp__fmode_dll)
-#endif
-
-/* Specifiy one of these flags to define the access mode. */
-#define _O_RDONLY 0
-#define _O_WRONLY 1
-#define _O_RDWR 2
-
-/* Mask for access mode bits in the _open flags. */
-#define _O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR)
-
-#define _O_APPEND 0x0008 /* Writes will add to the end of the file. */
-#define _O_CREAT 0x0100 /* Create the file if it does not exist. */
-#define _O_TRUNC 0x0200 /* Truncate the file if it does exist. */
-#define _O_EXCL 0x0400 /* Open only if the file does not exist. */
-
-/* NOTE: Text is the default even if the given _O_TEXT bit is not on. */
-#define _O_TEXT 0x4000 /* CR-LF in file becomes LF in memory. */
-#define _O_BINARY 0x8000 /* Input and output is not translated. */
-#define _O_RAW _O_BINARY
-
-#define _O_TEMPORARY 0x0040 /* Make the file dissappear after closing.
- * WARNING: Even if not created by _open! */
-
-
-#define _O_RANDOM 0x0010
-#define _O_SEQUENTIAL _O_RANDOM
-#define _O_SHORT_LIVED 0x1000
-
-#ifndef __STRICT_ANSI__
-#ifndef _NO_OLDNAMES
-
-/* POSIX/Non-ANSI names for increased portability */
-#define O_RDONLY _O_RDONLY
-#define O_WRONLY _O_WRONLY
-#define O_RDWR _O_RDWR
-#define O_ACCMODE _O_ACCMODE
-#define O_APPEND _O_APPEND
-#define O_CREAT _O_CREAT
-#define O_TRUNC _O_TRUNC
-#define O_EXCL _O_EXCL
-#define O_TEXT _O_TEXT
-#define O_BINARY _O_BINARY
-#define O_TEMPORARY _O_TEMPORARY
-
-#define O_RANDOM _O_RANDOM
-#define O_SEQUENTIAL _O_RANDOM
-#define O_SHORT_LIVED _O_SHORT_LIVED
-
-#endif /* Not _NO_OLDNAMES */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-int _setmode (int nHandle, int nAccessMode);
-
-#ifndef _NO_OLDNAMES
-int setmode (int nHandle, int nAccessMode);
-#endif /* Not _NO_OLDNAMES */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* Not __STRICT_ANSI__ */
-#endif /* Not _FCNTL_H_ */
VOID CopyMemory(PVOID Destination, CONST VOID* Source, DWORD Length);
+DWORD STDCALL GetCurrentTime(VOID);
+
void WINAPI
SHAddToRecentDocs (UINT, LPCVOID);
0x7d,0x7e,0x7e,0x7e,0x7e,0x7e,0x7e,0x7e,
0x7e,0x7e,0x7e,0x7f,0x7f,0x7f,0x7f,0x7f,
0x7f,0x7f,0x80,0x80,0x80,0x80,0x80,0x80,
-};
\ No newline at end of file
+};
PPHYSICAL_ADDRESS TranslatedAddress);
BOOLEAN HalMakeBeep(ULONG Frequency);
VOID HalQueryRealTimeClock(PTIME_FIELDS pTime);
+
#endif /* __INCLUDE_INTERNAL_HAL_DDK_H */
#define PAGESIZE (4096)
-PULONG MmGetPageEntry(PEPROCESS Process, ULONG Address);
-
-/*
- * 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);
+PULONG MmGetPageEntry(PEPROCESS Process, PVOID Address);
/*
#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);
-
VOID MmSetPage(PEPROCESS Process,
PVOID Address,
ULONG flProtect,
--- /dev/null
+#ifndef _I386_STRING_H_
+#define _I386_STRING_H_
+
+/*
+ * On a 486 or Pentium, we are better off not using the
+ * byte string operations. But on a 386 or a PPro the
+ * byte string ops are faster than doing it by hand
+ * (MUCH faster on a Pentium).
+ *
+ * Also, the byte strings actually work correctly. Forget
+ * the i486 routines for now as they may be broken..
+ */
+#if FIXED_486_STRING && (CPU == 486 || CPU == 586)
+#include <asm/string-486.h>
+#else
+
+/*
+ * This string-include defines all string functions as inline
+ * functions. Use gcc. It also assumes ds=es=data space, this should be
+ * normal. Most of the string-functions are rather heavily hand-optimized,
+ * see especially strtok,strstr,str[c]spn. They should work, but are not
+ * very easy to understand. Everything is done entirely within the register
+ * set, making the functions fast and clean. String instructions have been
+ * used through-out, making for "slightly" unclear code :-)
+ *
+ * NO Copyright (C) 1991, 1992 Linus Torvalds,
+ * consider these trivial functions to be PD.
+ */
+
+#define __HAVE_ARCH_STRCPY
+extern inline char * strcpy(char * dest,const char *src)
+{
+int d0, d1, d2;
+__asm__ __volatile__(
+ "cld\n"
+ "1:\tlodsb\n\t"
+ "stosb\n\t"
+ "testb %%al,%%al\n\t"
+ "jne 1b"
+ : "=&S" (d0), "=&D" (d1), "=&a" (d2)
+ :"0" (src),"1" (dest) : "memory");
+return dest;
+}
+
+#define __HAVE_ARCH_STRNCPY
+extern inline char * strncpy(char * dest,const char *src,size_t count)
+{
+int d0, d1, d2, d3;
+__asm__ __volatile__(
+ "cld\n"
+ "1:\tdecl %2\n\t"
+ "js 2f\n\t"
+ "lodsb\n\t"
+ "stosb\n\t"
+ "testb %%al,%%al\n\t"
+ "jne 1b\n\t"
+ "rep\n\t"
+ "stosb\n"
+ "2:"
+ : "=&S" (d0), "=&D" (d1), "=&c" (d2), "=&a" (d3)
+ :"0" (src),"1" (dest),"2" (count) : "memory");
+return dest;
+}
+
+#define __HAVE_ARCH_STRCAT
+extern inline char * strcat(char * dest,const char * src)
+{
+int d0, d1, d2, d3;
+__asm__ __volatile__(
+ "cld\n\t"
+ "repne\n\t"
+ "scasb\n\t"
+ "decl %1\n"
+ "1:\tlodsb\n\t"
+ "stosb\n\t"
+ "testb %%al,%%al\n\t"
+ "jne 1b"
+ : "=&S" (d0), "=&D" (d1), "=&a" (d2), "=&c" (d3)
+ : "0" (src), "1" (dest), "2" (0), "3" (0xffffffff):"memory");
+return dest;
+}
+
+#define __HAVE_ARCH_STRNCAT
+extern inline char * strncat(char * dest,const char * src,size_t count)
+{
+int d0, d1, d2, d3;
+__asm__ __volatile__(
+ "cld\n\t"
+ "repne\n\t"
+ "scasb\n\t"
+ "decl %1\n\t"
+ "movl %8,%3\n"
+ "1:\tdecl %3\n\t"
+ "js 2f\n\t"
+ "lodsb\n\t"
+ "stosb\n\t"
+ "testb %%al,%%al\n\t"
+ "jne 1b\n"
+ "2:\txorl %2,%2\n\t"
+ "stosb"
+ : "=&S" (d0), "=&D" (d1), "=&a" (d2), "=&c" (d3)
+ : "0" (src),"1" (dest),"2" (0),"3" (0xffffffff), "g" (count)
+ : "memory");
+return dest;
+}
+
+#define __HAVE_ARCH_STRCMP
+extern inline int strcmp(const char * cs,const char * ct)
+{
+int d0, d1;
+register int __res;
+__asm__ __volatile__(
+ "cld\n"
+ "1:\tlodsb\n\t"
+ "scasb\n\t"
+ "jne 2f\n\t"
+ "testb %%al,%%al\n\t"
+ "jne 1b\n\t"
+ "xorl %%eax,%%eax\n\t"
+ "jmp 3f\n"
+ "2:\tsbbl %%eax,%%eax\n\t"
+ "orb $1,%%al\n"
+ "3:"
+ :"=a" (__res), "=&S" (d0), "=&D" (d1)
+ :"1" (cs),"2" (ct));
+return __res;
+}
+
+#define __HAVE_ARCH_STRNCMP
+extern inline int strncmp(const char * cs,const char * ct,size_t count)
+{
+register int __res;
+int d0, d1, d2;
+__asm__ __volatile__(
+ "cld\n"
+ "1:\tdecl %3\n\t"
+ "js 2f\n\t"
+ "lodsb\n\t"
+ "scasb\n\t"
+ "jne 3f\n\t"
+ "testb %%al,%%al\n\t"
+ "jne 1b\n"
+ "2:\txorl %%eax,%%eax\n\t"
+ "jmp 4f\n"
+ "3:\tsbbl %%eax,%%eax\n\t"
+ "orb $1,%%al\n"
+ "4:"
+ :"=a" (__res), "=&S" (d0), "=&D" (d1), "=&c" (d2)
+ :"1" (cs),"2" (ct),"3" (count));
+return __res;
+}
+
+#define __HAVE_ARCH_STRCHR
+extern inline char * strchr(const char * s, int c)
+{
+int d0;
+register char * __res;
+__asm__ __volatile__(
+ "cld\n\t"
+ "movb %%al,%%ah\n"
+ "1:\tlodsb\n\t"
+ "cmpb %%ah,%%al\n\t"
+ "je 2f\n\t"
+ "testb %%al,%%al\n\t"
+ "jne 1b\n\t"
+ "movl $1,%1\n"
+ "2:\tmovl %1,%0\n\t"
+ "decl %0"
+ :"=a" (__res), "=&S" (d0) : "1" (s),"0" (c));
+return __res;
+}
+
+#define __HAVE_ARCH_STRRCHR
+extern inline char * strrchr(const char * s, int c)
+{
+int d0, d1;
+register char * __res;
+__asm__ __volatile__(
+ "cld\n\t"
+ "movb %%al,%%ah\n"
+ "1:\tlodsb\n\t"
+ "cmpb %%ah,%%al\n\t"
+ "jne 2f\n\t"
+ "leal -1(%%esi),%0\n"
+ "2:\ttestb %%al,%%al\n\t"
+ "jne 1b"
+ :"=g" (__res), "=&S" (d0), "=&a" (d1) :"0" (0),"1" (s),"2" (c));
+return __res;
+}
+
+#define __HAVE_ARCH_STRLEN
+extern inline size_t strlen(const char * s)
+{
+int d0;
+register int __res;
+__asm__ __volatile__(
+ "cld\n\t"
+ "repne\n\t"
+ "scasb\n\t"
+ "notl %0\n\t"
+ "decl %0"
+ :"=c" (__res), "=&D" (d0) :"1" (s),"a" (0), "0" (0xffffffff));
+return __res;
+}
+
+extern inline void * __memcpy(void * to, const void * from, size_t n)
+{
+int d0, d1, d2;
+__asm__ __volatile__(
+ "cld\n\t"
+ "rep ; movsl\n\t"
+ "testb $2,%b4\n\t"
+ "je 1f\n\t"
+ "movsw\n"
+ "1:\ttestb $1,%b4\n\t"
+ "je 2f\n\t"
+ "movsb\n"
+ "2:"
+ : "=&c" (d0), "=&D" (d1), "=&S" (d2)
+ :"0" (n/4), "q" (n),"1" ((long) to),"2" ((long) from)
+ : "memory");
+return (to);
+}
+
+/*
+ * This looks horribly ugly, but the compiler can optimize it totally,
+ * as the count is constant.
+ */
+extern inline void * __constant_memcpy(void * to, const void * from, size_t n)
+{
+ switch (n) {
+ case 0:
+ return to;
+ case 1:
+ *(unsigned char *)to = *(const unsigned char *)from;
+ return to;
+ case 2:
+ *(unsigned short *)to = *(const unsigned short *)from;
+ return to;
+ case 3:
+ *(unsigned short *)to = *(const unsigned short *)from;
+ *(2+(unsigned char *)to) = *(2+(const unsigned char *)from);
+ return to;
+ case 4:
+ *(unsigned long *)to = *(const unsigned long *)from;
+ return to;
+ case 6: /* for Ethernet addresses */
+ *(unsigned long *)to = *(const unsigned long *)from;
+ *(2+(unsigned short *)to) = *(2+(const unsigned short *)from);
+ return to;
+ case 8:
+ *(unsigned long *)to = *(const unsigned long *)from;
+ *(1+(unsigned long *)to) = *(1+(const unsigned long *)from);
+ return to;
+ case 12:
+ *(unsigned long *)to = *(const unsigned long *)from;
+ *(1+(unsigned long *)to) = *(1+(const unsigned long *)from);
+ *(2+(unsigned long *)to) = *(2+(const unsigned long *)from);
+ return to;
+ case 16:
+ *(unsigned long *)to = *(const unsigned long *)from;
+ *(1+(unsigned long *)to) = *(1+(const unsigned long *)from);
+ *(2+(unsigned long *)to) = *(2+(const unsigned long *)from);
+ *(3+(unsigned long *)to) = *(3+(const unsigned long *)from);
+ return to;
+ case 20:
+ *(unsigned long *)to = *(const unsigned long *)from;
+ *(1+(unsigned long *)to) = *(1+(const unsigned long *)from);
+ *(2+(unsigned long *)to) = *(2+(const unsigned long *)from);
+ *(3+(unsigned long *)to) = *(3+(const unsigned long *)from);
+ *(4+(unsigned long *)to) = *(4+(const unsigned long *)from);
+ return to;
+ }
+#define COMMON(x) \
+__asm__ __volatile__( \
+ "cld\n\t" \
+ "rep ; movsl" \
+ x \
+ : "=&c" (d0), "=&D" (d1), "=&S" (d2) \
+ : "0" (n/4),"1" ((long) to),"2" ((long) from) \
+ : "memory");
+{
+ int d0, d1, d2;
+ switch (n % 4) {
+ case 0: COMMON(""); return to;
+ case 1: COMMON("\n\tmovsb"); return to;
+ case 2: COMMON("\n\tmovsw"); return to;
+ default: COMMON("\n\tmovsw\n\tmovsb"); return to;
+ }
+}
+
+#undef COMMON
+}
+
+#define __HAVE_ARCH_MEMCPY
+#define memcpy(t, f, n) \
+(__builtin_constant_p(n) ? \
+ __constant_memcpy((t),(f),(n)) : \
+ __memcpy((t),(f),(n)))
+
+#define __HAVE_ARCH_MEMMOVE
+extern inline void * memmove(void * dest,const void * src, size_t n)
+{
+int d0, d1, d2;
+if (dest<src)
+__asm__ __volatile__(
+ "cld\n\t"
+ "rep\n\t"
+ "movsb"
+ : "=&c" (d0), "=&S" (d1), "=&D" (d2)
+ :"0" (n),"1" (src),"2" (dest)
+ : "memory");
+else
+__asm__ __volatile__(
+ "std\n\t"
+ "rep\n\t"
+ "movsb\n\t"
+ "cld"
+ : "=&c" (d0), "=&S" (d1), "=&D" (d2)
+ :"0" (n),
+ "1" (n-1+(const char *)src),
+ "2" (n-1+(char *)dest)
+ :"memory");
+return dest;
+}
+
+#define memcmp __builtin_memcmp
+
+#define __HAVE_ARCH_MEMCHR
+extern inline void * memchr(const void * cs,int c,size_t count)
+{
+int d0;
+register void * __res;
+if (!count)
+ return NULL;
+__asm__ __volatile__(
+ "cld\n\t"
+ "repne\n\t"
+ "scasb\n\t"
+ "je 1f\n\t"
+ "movl $1,%0\n"
+ "1:\tdecl %0"
+ :"=D" (__res), "=&c" (d0) : "a" (c),"0" (cs),"1" (count));
+return __res;
+}
+
+extern inline void * __memset_generic(void * s, char c,size_t count)
+{
+int d0, d1;
+__asm__ __volatile__(
+ "cld\n\t"
+ "rep\n\t"
+ "stosb"
+ : "=&c" (d0), "=&D" (d1)
+ :"a" (c),"1" (s),"0" (count)
+ :"memory");
+return s;
+}
+
+/* we might want to write optimized versions of these later */
+#define __constant_count_memset(s,c,count) __memset_generic((s),(c),(count))
+
+/*
+ * memset(x,0,y) is a reasonably common thing to do, so we want to fill
+ * things 32 bits at a time even when we don't know the size of the
+ * area at compile-time..
+ */
+extern inline void * __constant_c_memset(void * s, unsigned long c, size_t count)
+{
+int d0, d1;
+__asm__ __volatile__(
+ "cld\n\t"
+ "rep ; stosl\n\t"
+ "testb $2,%b3\n\t"
+ "je 1f\n\t"
+ "stosw\n"
+ "1:\ttestb $1,%b3\n\t"
+ "je 2f\n\t"
+ "stosb\n"
+ "2:"
+ : "=&c" (d0), "=&D" (d1)
+ :"a" (c), "q" (count), "0" (count/4), "1" ((long) s)
+ :"memory");
+return (s);
+}
+
+/* Added by Gertjan van Wingerde to make minix and sysv module work */
+#define __HAVE_ARCH_STRNLEN
+extern inline size_t strnlen(const char * s, size_t count)
+{
+int d0;
+register int __res;
+__asm__ __volatile__(
+ "movl %2,%0\n\t"
+ "jmp 2f\n"
+ "1:\tcmpb $0,(%0)\n\t"
+ "je 3f\n\t"
+ "incl %0\n"
+ "2:\tdecl %1\n\t"
+ "cmpl $-1,%1\n\t"
+ "jne 1b\n"
+ "3:\tsubl %2,%0"
+ :"=a" (__res), "=&d" (d0)
+ :"c" (s),"1" (count));
+return __res;
+}
+/* end of additional stuff */
+
+/*
+ * This looks horribly ugly, but the compiler can optimize it totally,
+ * as we by now know that both pattern and count is constant..
+ */
+extern inline void * __constant_c_and_count_memset(void * s, unsigned long pattern, size_t count)
+{
+ switch (count) {
+ case 0:
+ return s;
+ case 1:
+ *(unsigned char *)s = pattern;
+ return s;
+ case 2:
+ *(unsigned short *)s = pattern;
+ return s;
+ case 3:
+ *(unsigned short *)s = pattern;
+ *(2+(unsigned char *)s) = pattern;
+ return s;
+ case 4:
+ *(unsigned long *)s = pattern;
+ return s;
+ }
+#define COMMON(x) \
+__asm__ __volatile__("cld\n\t" \
+ "rep ; stosl" \
+ x \
+ : "=&c" (d0), "=&D" (d1) \
+ : "a" (pattern),"0" (count/4),"1" ((long) s) \
+ : "memory")
+{
+ int d0, d1;
+ switch (count % 4) {
+ case 0: COMMON(""); return s;
+ case 1: COMMON("\n\tstosb"); return s;
+ case 2: COMMON("\n\tstosw"); return s;
+ default: COMMON("\n\tstosw\n\tstosb"); return s;
+ }
+}
+
+#undef COMMON
+}
+
+#define __constant_c_x_memset(s, c, count) \
+(__builtin_constant_p(count) ? \
+ __constant_c_and_count_memset((s),(c),(count)) : \
+ __constant_c_memset((s),(c),(count)))
+
+#define __memset(s, c, count) \
+(__builtin_constant_p(count) ? \
+ __constant_count_memset((s),(c),(count)) : \
+ __memset_generic((s),(c),(count)))
+
+#define __HAVE_ARCH_MEMSET
+#define memset(s, c, count) \
+(__builtin_constant_p(c) ? \
+ __constant_c_x_memset((s),(0x01010101UL*(unsigned char)c),(count)) : \
+ __memset((s),(c),(count)))
+
+/*
+ * find the first occurrence of byte 'c', or 1 past the area if none
+ */
+#define __HAVE_ARCH_MEMSCAN
+extern inline void * memscan(void * addr, int c, size_t size)
+{
+ if (!size)
+ return addr;
+ __asm__("cld
+ repnz; scasb
+ jnz 1f
+ dec %%edi
+1: "
+ : "=D" (addr), "=c" (size)
+ : "0" (addr), "1" (size), "a" (c));
+ return addr;
+}
+
+#endif
+#endif
*/
-#define BASE_OBJECT_ID (0x12345678)
-#define FILE_OBJECT_ID (BASE_OBJECT_ID + 1)
-#define DEVICE_OBJECT_ID (BASE_OBJECT_ID + 2)
-#define DRIVER_OBJECT_ID (BASE_OBJECT_ID + 3)
-#define DIRECTORY_OBJECT_ID (BASE_OBJECT_ID + 4)
-#define CC1_CCB_ID (BASE_OBJECT_ID + 5)
+#define ID_BASE_OBJECT (0x1234)
+#define ID_FILE_OBJECT (ID_BASE_OBJECT + 1)
+#define ID_DEVICE_OBJECT (ID_BASE_OBJECT + 2)
+#define ID_DRIVER_OBJECT (ID_BASE_OBJECT + 3)
+#define ID_DIRECTORY_OBJECT (ID_BASE_OBJECT + 4)
+#define ID_EVENT_OBJECT (ID_BASE_OBJECT + 5)
+#define ID_TIMER_OBJECT (ID_BASE_OBJECT + 6)
* entry = pointer to the driver initialization routine
* RETURNS: Success or failure
*/
-NTSTATUS InitializeLoadedDriver(PDRIVER_INITIALIZE entry);
+NTSTATUS IoInitializeDriver(PDRIVER_INITIALIZE DriverEntry);
PDEVICE_OBJECT DeviceToMount);
NTSTATUS IoPageRead(PFILE_OBJECT FileObject,
PVOID Address,
- PLARGE_INTEGER Offset,
- PIO_STATUS_BLOCK StatusBlock);
+ PLARGE_INTEGER Offset,
+ PIO_STATUS_BLOCK StatusBlock);
VOID IoSecondStageCompletion(PIRP Irp, CCHAR PriorityBoost);
NTSTATUS IopCreateFile(PVOID ObjectBody,
VOID KeInitBugCheck(VOID);
VOID KeInitDispatcher(VOID);
VOID KeCalibrateTimerLoop(VOID);
-
-
-
-
-
-
+VOID KeInitializeDispatcher(VOID);
+VOID KeInitializeTimerImpl(VOID);
#endif
--- /dev/null
+
+NTSTATUS LdrLoadDriver(PUNICODE_STRING Filename);
+NTSTATUS LdrLoadInitialProcess(VOID);
+VOID LdrLoadAutoConfigDrivers(VOID);
+
+
VOID KeInit(VOID);
VOID HalInitConsole(boot_param* bp);
-/*
- * Loader functions (called in main())
- */
-VOID LdrInitModuleManagement(VOID);
-VOID LdrLoadAutoConfigDrivers(VOID);
+extern WCHAR wtolower(WCHAR ch);
#endif
-/*
- * Adapted from linux for the reactos kernel, march 1998 -- David Welch
- */
-
-#ifndef _LINUX_STRING_H_
-#define _LINUX_STRING_H_
-
-#include "types.h" /* for size_t */
-
-#ifndef NULL
-#define NULL ((void *) 0)
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern char * ___strtok;
-extern char * strcpy(char *,const char *);
-extern char * strncpy(char *,const char *, __kernel_size_t);
-extern char * strcat(char *, const char *);
-extern char * strncat(char *, const char *, __kernel_size_t);
-extern char * strchr(const char *,int);
-extern char * strrchr(const char *,int);
-extern char * strpbrk(const char *,const char *);
-extern char * strtok(char *,const char *);
-extern char * strstr(const char *,const char *);
-extern __kernel_size_t strlen(const char *);
-extern __kernel_size_t strnlen(const char *,__kernel_size_t);
-extern __kernel_size_t strspn(const char *,const char *);
-extern int strcmp(const char *,const char *);
-extern int strncmp(const char *,const char *,__kernel_size_t);
-
-extern void * memset(void *,int,__kernel_size_t);
-extern void * memcpy(void *,const void *,__kernel_size_t);
-extern void * memmove(void *,const void *,__kernel_size_t);
-extern void * memscan(void *,int,__kernel_size_t);
-extern int memcmp(const void *,const void *,__kernel_size_t);
-
-/*
- * Include machine specific inline routines
- */
#ifndef _I386_STRING_H_
#define _I386_STRING_H_
+#ifndef _LINUX_TYPES_H
+#include <internal/types.h>
+#endif
+
/*
* On a 486 or Pentium, we are better off not using the
* byte string operations. But on a 386 or a PPro the
* set, making the functions fast and clean. String instructions have been
* used through-out, making for "slightly" unclear code :-)
*
- * Copyright (C) 1991, 1992 Linus Torvalds
+ * NO Copyright (C) 1991, 1992 Linus Torvalds,
+ * consider these trivial functions to be PD.
*/
#define __HAVE_ARCH_STRCPY
extern inline char * strcpy(char * dest,const char *src)
{
+int d0, d1, d2;
__asm__ __volatile__(
"cld\n"
"1:\tlodsb\n\t"
"stosb\n\t"
"testb %%al,%%al\n\t"
"jne 1b"
- : /* no output */
- :"S" (src),"D" (dest):"si","di","ax","memory");
+ : "=&S" (d0), "=&D" (d1), "=&a" (d2)
+ :"0" (src),"1" (dest) : "memory");
return dest;
}
#define __HAVE_ARCH_STRNCPY
extern inline char * strncpy(char * dest,const char *src,size_t count)
{
+int d0, d1, d2, d3;
__asm__ __volatile__(
"cld\n"
"1:\tdecl %2\n\t"
"rep\n\t"
"stosb\n"
"2:"
- : /* no output */
- :"S" (src),"D" (dest),"c" (count):"si","di","ax","cx","memory");
+ : "=&S" (d0), "=&D" (d1), "=&c" (d2), "=&a" (d3)
+ :"0" (src),"1" (dest),"2" (count) : "memory");
return dest;
}
#define __HAVE_ARCH_STRCAT
extern inline char * strcat(char * dest,const char * src)
{
+int d0, d1, d2, d3;
__asm__ __volatile__(
"cld\n\t"
"repne\n\t"
"stosb\n\t"
"testb %%al,%%al\n\t"
"jne 1b"
- : /* no output */
- :"S" (src),"D" (dest),"a" (0),"c" (0xffffffff):"si","di","ax","cx");
+ : "=&S" (d0), "=&D" (d1), "=&a" (d2), "=&c" (d3)
+ : "0" (src), "1" (dest), "2" (0), "3" (0xffffffff):"memory");
return dest;
}
#define __HAVE_ARCH_STRNCAT
extern inline char * strncat(char * dest,const char * src,size_t count)
{
+int d0, d1, d2, d3;
__asm__ __volatile__(
"cld\n\t"
"repne\n\t"
"scasb\n\t"
"decl %1\n\t"
- "movl %4,%3\n"
+ "movl %8,%3\n"
"1:\tdecl %3\n\t"
"js 2f\n\t"
"lodsb\n\t"
"jne 1b\n"
"2:\txorl %2,%2\n\t"
"stosb"
- : /* no output */
- :"S" (src),"D" (dest),"a" (0),"c" (0xffffffff),"g" (count)
- :"si","di","ax","cx","memory");
+ : "=&S" (d0), "=&D" (d1), "=&a" (d2), "=&c" (d3)
+ : "0" (src),"1" (dest),"2" (0),"3" (0xffffffff), "g" (count)
+ : "memory");
return dest;
}
#define __HAVE_ARCH_STRCMP
extern inline int strcmp(const char * cs,const char * ct)
{
+int d0, d1;
register int __res;
__asm__ __volatile__(
"cld\n"
"xorl %%eax,%%eax\n\t"
"jmp 3f\n"
"2:\tsbbl %%eax,%%eax\n\t"
- "orb $1,%%eax\n"
+ "orb $1,%%al\n"
"3:"
- :"=a" (__res):"S" (cs),"D" (ct):"si","di");
+ :"=a" (__res), "=&S" (d0), "=&D" (d1)
+ :"1" (cs),"2" (ct));
return __res;
}
extern inline int strncmp(const char * cs,const char * ct,size_t count)
{
register int __res;
+int d0, d1, d2;
__asm__ __volatile__(
"cld\n"
"1:\tdecl %3\n\t"
"3:\tsbbl %%eax,%%eax\n\t"
"orb $1,%%al\n"
"4:"
- :"=a" (__res):"S" (cs),"D" (ct),"c" (count):"si","di","cx");
+ :"=a" (__res), "=&S" (d0), "=&D" (d1), "=&c" (d2)
+ :"1" (cs),"2" (ct),"3" (count));
return __res;
}
#define __HAVE_ARCH_STRCHR
extern inline char * strchr(const char * s, int c)
{
+int d0;
register char * __res;
__asm__ __volatile__(
"cld\n\t"
"movl $1,%1\n"
"2:\tmovl %1,%0\n\t"
"decl %0"
- :"=a" (__res):"S" (s),"0" (c):"si");
+ :"=a" (__res), "=&S" (d0) : "1" (s),"0" (c));
return __res;
}
#define __HAVE_ARCH_STRRCHR
extern inline char * strrchr(const char * s, int c)
{
+int d0, d1;
register char * __res;
__asm__ __volatile__(
"cld\n\t"
"leal -1(%%esi),%0\n"
"2:\ttestb %%al,%%al\n\t"
"jne 1b"
- :"=d" (__res):"0" (0),"S" (s),"a" (c):"ax","si");
-return __res;
-}
-
-#define __HAVE_ARCH_STRSPN
-extern inline size_t strspn(const char * cs, const char * ct)
-{
-register char * __res;
-__asm__ __volatile__(
- "cld\n\t"
- "movl %4,%%edi\n\t"
- "repne\n\t"
- "scasb\n\t"
- "notl %%ecx\n\t"
- "decl %%ecx\n\t"
- "movl %%ecx,%%edx\n"
- "1:\tlodsb\n\t"
- "testb %%al,%%al\n\t"
- "je 2f\n\t"
- "movl %4,%%edi\n\t"
- "movl %%edx,%%ecx\n\t"
- "repne\n\t"
- "scasb\n\t"
- "je 1b\n"
- "2:\tdecl %0"
- :"=S" (__res):"a" (0),"c" (0xffffffff),"0" (cs),"g" (ct)
- :"ax","cx","dx","di");
-return __res-cs;
-}
-
-#define __HAVE_ARCH_STRCSPN
-extern inline size_t strcspn(const char * cs, const char * ct)
-{
-register char * __res;
-__asm__ __volatile__(
- "cld\n\t"
- "movl %4,%%edi\n\t"
- "repne\n\t"
- "scasb\n\t"
- "notl %%ecx\n\t"
- "decl %%ecx\n\t"
- "movl %%ecx,%%edx\n"
- "1:\tlodsb\n\t"
- "testb %%al,%%al\n\t"
- "je 2f\n\t"
- "movl %4,%%edi\n\t"
- "movl %%edx,%%ecx\n\t"
- "repne\n\t"
- "scasb\n\t"
- "jne 1b\n"
- "2:\tdecl %0"
- :"=S" (__res):"a" (0),"c" (0xffffffff),"0" (cs),"g" (ct)
- :"ax","cx","dx","di");
-return __res-cs;
-}
-
-#define __HAVE_ARCH_STRPBRK
-extern inline char * strpbrk(const char * cs,const char * ct)
-{
-register char * __res;
-__asm__ __volatile__(
- "cld\n\t"
- "movl %4,%%edi\n\t"
- "repne\n\t"
- "scasb\n\t"
- "notl %%ecx\n\t"
- "decl %%ecx\n\t"
- "movl %%ecx,%%edx\n"
- "1:\tlodsb\n\t"
- "testb %%al,%%al\n\t"
- "je 2f\n\t"
- "movl %4,%%edi\n\t"
- "movl %%edx,%%ecx\n\t"
- "repne\n\t"
- "scasb\n\t"
- "jne 1b\n\t"
- "decl %0\n\t"
- "jmp 3f\n"
- "2:\txorl %0,%0\n"
- "3:"
- :"=S" (__res):"a" (0),"c" (0xffffffff),"0" (cs),"g" (ct)
- :"ax","cx","dx","di");
-return __res;
-}
-
-#define __HAVE_ARCH_STRSTR
-extern inline char * strstr(const char * cs,const char * ct)
-{
-register char * __res;
-__asm__ __volatile__(
- "cld\n\t" \
- "movl %4,%%edi\n\t"
- "repne\n\t"
- "scasb\n\t"
- "notl %%ecx\n\t"
- "decl %%ecx\n\t" /* NOTE! This also sets Z if searchstring='' */
- "movl %%ecx,%%edx\n"
- "1:\tmovl %4,%%edi\n\t"
- "movl %%esi,%%eax\n\t"
- "movl %%edx,%%ecx\n\t"
- "repe\n\t"
- "cmpsb\n\t"
- "je 2f\n\t" /* also works for empty string, see above */
- "xchgl %%eax,%%esi\n\t"
- "incl %%esi\n\t"
- "cmpb $0,-1(%%eax)\n\t"
- "jne 1b\n\t"
- "xorl %%eax,%%eax\n\t"
- "2:"
- :"=a" (__res):"0" (0),"c" (0xffffffff),"S" (cs),"g" (ct)
- :"cx","dx","di","si");
+ :"=g" (__res), "=&S" (d0), "=&a" (d1) :"0" (0),"1" (s),"2" (c));
return __res;
}
#define __HAVE_ARCH_STRLEN
extern inline size_t strlen(const char * s)
{
+int d0;
register int __res;
__asm__ __volatile__(
"cld\n\t"
"scasb\n\t"
"notl %0\n\t"
"decl %0"
- :"=c" (__res):"D" (s),"a" (0),"0" (0xffffffff):"di");
-return __res;
-}
-
-#define __HAVE_ARCH_STRTOK
-extern inline char * strtok(char * s,const char * ct)
-{
-register char * __res;
-__asm__ __volatile__(
- "testl %1,%1\n\t"
- "jne 1f\n\t"
- "testl %0,%0\n\t"
- "je 8f\n\t"
- "movl %0,%1\n"
- "1:\txorl %0,%0\n\t"
- "movl $-1,%%ecx\n\t"
- "xorl %%eax,%%eax\n\t"
- "cld\n\t"
- "movl %4,%%edi\n\t"
- "repne\n\t"
- "scasb\n\t"
- "notl %%ecx\n\t"
- "decl %%ecx\n\t"
- "je 7f\n\t" /* empty delimiter-string */
- "movl %%ecx,%%edx\n"
- "2:\tlodsb\n\t"
- "testb %%al,%%al\n\t"
- "je 7f\n\t"
- "movl %4,%%edi\n\t"
- "movl %%edx,%%ecx\n\t"
- "repne\n\t"
- "scasb\n\t"
- "je 2b\n\t"
- "decl %1\n\t"
- "cmpb $0,(%1)\n\t"
- "je 7f\n\t"
- "movl %1,%0\n"
- "3:\tlodsb\n\t"
- "testb %%al,%%al\n\t"
- "je 5f\n\t"
- "movl %4,%%edi\n\t"
- "movl %%edx,%%ecx\n\t"
- "repne\n\t"
- "scasb\n\t"
- "jne 3b\n\t"
- "decl %1\n\t"
- "cmpb $0,(%1)\n\t"
- "je 5f\n\t"
- "movb $0,(%1)\n\t"
- "incl %1\n\t"
- "jmp 6f\n"
- "5:\txorl %1,%1\n"
- "6:\tcmpb $0,(%0)\n\t"
- "jne 7f\n\t"
- "xorl %0,%0\n"
- "7:\ttestl %0,%0\n\t"
- "jne 8f\n\t"
- "movl %0,%1\n"
- "8:"
- :"=b" (__res),"=S" (___strtok)
- :"0" (___strtok),"1" (s),"g" (ct)
- :"ax","cx","dx","di","memory");
+ :"=c" (__res), "=&D" (d0) :"1" (s),"a" (0), "0" (0xffffffff));
return __res;
}
extern inline void * __memcpy(void * to, const void * from, size_t n)
{
+int d0, d1, d2;
__asm__ __volatile__(
"cld\n\t"
"rep ; movsl\n\t"
- "testb $2,%b1\n\t"
+ "testb $2,%b4\n\t"
"je 1f\n\t"
"movsw\n"
- "1:\ttestb $1,%b1\n\t"
+ "1:\ttestb $1,%b4\n\t"
"je 2f\n\t"
"movsb\n"
"2:"
- : /* no output */
- :"c" (n/4), "q" (n),"D" ((long) to),"S" ((long) from)
- : "cx","di","si","memory");
+ : "=&c" (d0), "=&D" (d1), "=&S" (d2)
+ :"0" (n/4), "q" (n),"1" ((long) to),"2" ((long) from)
+ : "memory");
return (to);
}
case 4:
*(unsigned long *)to = *(const unsigned long *)from;
return to;
+ case 6: /* for Ethernet addresses */
+ *(unsigned long *)to = *(const unsigned long *)from;
+ *(2+(unsigned short *)to) = *(2+(const unsigned short *)from);
+ return to;
case 8:
*(unsigned long *)to = *(const unsigned long *)from;
*(1+(unsigned long *)to) = *(1+(const unsigned long *)from);
return to;
}
#define COMMON(x) \
-__asm__("cld\n\t" \
+__asm__ __volatile__( \
+ "cld\n\t" \
"rep ; movsl" \
x \
- : /* no outputs */ \
- : "c" (n/4),"D" ((long) to),"S" ((long) from) \
- : "cx","di","si","memory");
-
+ : "=&c" (d0), "=&D" (d1), "=&S" (d2) \
+ : "0" (n/4),"1" ((long) to),"2" ((long) from) \
+ : "memory");
+{
+ int d0, d1, d2;
switch (n % 4) {
case 0: COMMON(""); return to;
case 1: COMMON("\n\tmovsb"); return to;
case 2: COMMON("\n\tmovsw"); return to;
- case 3: COMMON("\n\tmovsw\n\tmovsb"); return to;
+ default: COMMON("\n\tmovsw\n\tmovsb"); return to;
}
+}
+
#undef COMMON
}
#define __HAVE_ARCH_MEMMOVE
extern inline void * memmove(void * dest,const void * src, size_t n)
{
+int d0, d1, d2;
if (dest<src)
__asm__ __volatile__(
"cld\n\t"
"rep\n\t"
"movsb"
- : /* no output */
- :"c" (n),"S" (src),"D" (dest)
- :"cx","si","di");
+ : "=&c" (d0), "=&S" (d1), "=&D" (d2)
+ :"0" (n),"1" (src),"2" (dest)
+ : "memory");
else
__asm__ __volatile__(
"std\n\t"
"rep\n\t"
"movsb\n\t"
"cld"
- : /* no output */
- :"c" (n),
- "S" (n-1+(const char *)src),
- "D" (n-1+(char *)dest)
- :"cx","si","di","memory");
+ : "=&c" (d0), "=&S" (d1), "=&D" (d2)
+ :"0" (n),
+ "1" (n-1+(const char *)src),
+ "2" (n-1+(char *)dest)
+ :"memory");
return dest;
}
#define __HAVE_ARCH_MEMCHR
extern inline void * memchr(const void * cs,int c,size_t count)
{
+int d0;
register void * __res;
if (!count)
return NULL;
"je 1f\n\t"
"movl $1,%0\n"
"1:\tdecl %0"
- :"=D" (__res):"a" (c),"D" (cs),"c" (count)
- :"cx");
+ :"=D" (__res), "=&c" (d0) : "a" (c),"0" (cs),"1" (count));
return __res;
}
extern inline void * __memset_generic(void * s, char c,size_t count)
{
+int d0, d1;
__asm__ __volatile__(
"cld\n\t"
"rep\n\t"
"stosb"
- : /* no output */
- :"a" (c),"D" (s),"c" (count)
- :"cx","di","memory");
+ : "=&c" (d0), "=&D" (d1)
+ :"a" (c),"1" (s),"0" (count)
+ :"memory");
return s;
}
*/
extern inline void * __constant_c_memset(void * s, unsigned long c, size_t count)
{
+int d0, d1;
__asm__ __volatile__(
"cld\n\t"
"rep ; stosl\n\t"
- "testb $2,%b1\n\t"
+ "testb $2,%b3\n\t"
"je 1f\n\t"
"stosw\n"
- "1:\ttestb $1,%b1\n\t"
+ "1:\ttestb $1,%b3\n\t"
"je 2f\n\t"
"stosb\n"
"2:"
- : /* no output */
- :"a" (c), "q" (count), "c" (count/4), "D" ((long) s)
- :"cx","di","memory");
+ : "=&c" (d0), "=&D" (d1)
+ :"a" (c), "q" (count), "0" (count/4), "1" ((long) s)
+ :"memory");
return (s);
}
#define __HAVE_ARCH_STRNLEN
extern inline size_t strnlen(const char * s, size_t count)
{
+int d0;
register int __res;
__asm__ __volatile__(
- "movl %1,%0\n\t"
+ "movl %2,%0\n\t"
"jmp 2f\n"
"1:\tcmpb $0,(%0)\n\t"
"je 3f\n\t"
"incl %0\n"
- "2:\tdecl %2\n\t"
- "cmpl $-1,%2\n\t"
+ "2:\tdecl %1\n\t"
+ "cmpl $-1,%1\n\t"
"jne 1b\n"
- "3:\tsubl %1,%0"
- :"=a" (__res)
- :"c" (s),"d" (count)
- :"dx");
+ "3:\tsubl %2,%0"
+ :"=a" (__res), "=&d" (d0)
+ :"c" (s),"1" (count));
return __res;
}
/* end of additional stuff */
return s;
}
#define COMMON(x) \
-__asm__("cld\n\t" \
+__asm__ __volatile__("cld\n\t" \
"rep ; stosl" \
x \
- : /* no outputs */ \
- : "a" (pattern),"c" (count/4),"D" ((long) s) \
- : "cx","di","memory")
-
+ : "=&c" (d0), "=&D" (d1) \
+ : "a" (pattern),"0" (count/4),"1" ((long) s) \
+ : "memory")
+{
+ int d0, d1;
switch (count % 4) {
case 0: COMMON(""); return s;
case 1: COMMON("\n\tstosb"); return s;
case 2: COMMON("\n\tstosw"); return s;
- case 3: COMMON("\n\tstosw\n\tstosb"); return s;
+ default: COMMON("\n\tstosw\n\tstosb"); return s;
}
+}
+
#undef COMMON
}
#endif
#endif
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _LINUX_STRING_H_ */
#endif
-typedef int size_t;
+#ifndef SIZE_T_DEFINED
+#define SIZE_T_DEFINED
+typedef unsigned int size_t;
+#endif
+
typedef size_t __kernel_size_t;
#endif /* _LINUX_TYPES_H */
BOOL __ErrorReturnFalse(ULONG ErrorCode);
PVOID __ErrorReturnNull(ULONG ErrorCode);
+
+BOOL KERNEL32_AnsiToUnicode(PWSTR DestStr,
+ LPCSTR SrcStr,
+ ULONG MaxLen);
#define GET_LARGE_INTEGER_LOW_PART(LargeInteger) ( (LargeInteger.LowPart) )
#define SET_LARGE_INTEGER_HIGH_PART(LargeInteger,Signed_Long) ( LargeInteger.HighPart= Signed_Long )
#define SET_LARGE_INTEGER_LOW_PART(LargeInteger,Unsigned_Long) ( LargeInteger.LowPart = Unsigned_Long )
-#endif
\ No newline at end of file
+#endif
int __fileno_alloc(void *hFile, int mode);
int _doprnt(const char *fmt, va_list args, FILE *f);
-int _dowprnt(const char *fmt, va_list args, FILE *f);
int _doscan(FILE *iop, const char *fmt, void **argp);
int _dowscan(FILE *iop, const wchar_t *fmt, void **argp);
int __fileno_close(int _fd);
-
#endif /* !_POSIX_SOURCE */
#endif /* !__STRICT_ANSI__ */
#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */
--- /dev/null
+extern void dprintf(char* fmt,...);
+
+#ifdef NDEBUG
+#define DPRINT(args...)
+#else
+#define DPRINT(args...) do { dprintf("(NTDLL:%s:%d) ",__FILE__,__LINE__); dprintf(args); } while(0);
+#endif
+
+#define ROUNDUP(a,b) ((((a)+(b)-1)/(b))*(b))
+#define ROUNDDOWN(a,b) (((a)/(b))*(b))
+
+#define MAGIC(c1,c2,c3,c4) ((c1) + ((c2)<<8) + ((c3)<<16) + ((c4)<<24))
+
+#define MAGIC_HEAP MAGIC( 'H','E','A','P' )
#define ROUND_UP(N, S) ((((N) + (S) - 1) / (S)) * (S))
-#ifndef PWORD
-typedef WORD *PWORD;
-#endif
+#define IMAGE_SECTION_CHAR_CODE 0x00000020
+#define IMAGE_SECTION_CHAR_DATA 0x00000040
+#define IMAGE_SECTION_CHAR_BSS 0x00000080
+#define IMAGE_SECTION_CHAR_NON_CACHABLE 0x04000000
+#define IMAGE_SECTION_CHAR_NON_PAGEABLE 0x08000000
+#define IMAGE_SECTION_CHAR_SHARED 0x10000000
+#define IMAGE_SECTION_CHAR_EXECUTABLE 0x20000000
+#define IMAGE_SECTION_CHAR_READABLE 0x40000000
+#define IMAGE_SECTION_CHAR_WRITABLE 0x80000000
-#ifndef PDWORD
-typedef DWORD *PDWORD;
-#endif
#define IMAGE_DOS_MAGIC 0x5a4d
#define IMAGE_PE_MAGIC 0x00004550
#define IMAGE_FILE_MACHINE_ALPHA 0x184 // Alpha_AXP
#define IMAGE_FILE_MACHINE_POWERPC 0x1F0 // IBM PowerPC Little-Endian
+
//
// Directory format.
//
IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES];
} IMAGE_OPTIONAL_HEADER, *PIMAGE_OPTIONAL_HEADER;
+
+typedef struct _IMAGE_NT_HEADERS {
+ DWORD Signature;
+ IMAGE_FILE_HEADER FileHeader;
+ IMAGE_OPTIONAL_HEADER OptionalHeader;
+} IMAGE_NT_HEADERS, *PIMAGE_NT_HEADERS;
+
+
// Directory Entries
#define IMAGE_DIRECTORY_ENTRY_EXPORT 0 // Export Directory
#define IMAGE_DIRECTORY_ENTRY_TLS 9 // TLS Directory
#define IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG 10 // Load Configuration Directory
#define IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT 11 // Bound Import Directory in headers
-#define IMAGE_DIRECTORY_ENTRY_IAT 12 // Import Address Table
-
-typedef struct _IMAGE_NT_HEADERS {
- DWORD Signature;
- IMAGE_FILE_HEADER FileHeader;
- IMAGE_OPTIONAL_HEADER OptionalHeader;
-} IMAGE_NT_HEADERS, *PIMAGE_NT_HEADERS;
-
+#define IMAGE_DIRECTORY_ENTRY_IAT 12 // Import Address
//
// Section header format.
//
#define IMAGE_SIZEOF_SECTION_HEADER 40
-
-#define IMAGE_SECTION_CHAR_CODE 0x00000020
-#define IMAGE_SECTION_CHAR_DATA 0x00000040
-#define IMAGE_SECTION_CHAR_BSS 0x00000080
-#define IMAGE_SECTION_CHAR_NON_CACHABLE 0x04000000
-#define IMAGE_SECTION_CHAR_NON_PAGEABLE 0x08000000
-#define IMAGE_SECTION_CHAR_SHARED 0x10000000
-#define IMAGE_SECTION_CHAR_EXECUTABLE 0x20000000
-#define IMAGE_SECTION_CHAR_READABLE 0x40000000
-#define IMAGE_SECTION_CHAR_WRITABLE 0x80000000
+#define IMAGE_SECTION_CODE (0x20)
+#define IMAGE_SECTION_INITIALIZED_DATA (0x40)
+#define IMAGE_SECTION_UNINITIALIZED_DATA (0x80)
//
// Export Format
#define RT_NEWRESOURCE 0x2000
#define RT_ERROR 0x7fff
-#define RT_CURSOR 1
-#define RT_BITMAP 2
-#define RT_ICON 3
-#define RT_MENU 4
-#define RT_DIALOG 5
-#define RT_STRING 6
-#define RT_FONTDIR 7
-#define RT_FONT 8
-#define RT_ACCELERATORS 9
-#define RT_RCDATA 10
-#define RT_MESSAGETABLE 11
-#define RT_GROUP_CURSOR 12
-#define RT_GROUP_ICON 14
-#define RT_VERSION 16
#define NEWBITMAP (RT_BITMAP|RT_NEWRESOURCE)
#define NEWMENU (RT_MENU|RT_NEWRESOURCE)
#define NEWDIALOG (RT_DIALOG|RT_NEWRESOURCE)
#define MI_MENUBREAK 0x0040 // MENUBREAK keyword
#define MI_ENDMENU 0x0080 // used internally
-
// Dialog Box Resources .................. added by sang cho.
// A dialog box is contained in a single resource and has a header and
// SCROLLBAR SCROLLBAR None
///
-#define WS_OVERLAPPED 0x00000000L
-#define WS_POPUP 0x80000000L
-#define WS_CHILD 0x40000000L
-#define WS_CLIPSIBLINGS 0x04000000L
-#define WS_CLIPCHILDREN 0x02000000L
-#define WS_VISIBLE 0x10000000L
-#define WS_DISABLED 0x08000000L
-#define WS_MINIMIZE 0x20000000L
-#define WS_MAXIMIZE 0x01000000L
-#define WS_CAPTION 0x00C00000L
-#define WS_BORDER 0x00800000L
-#define WS_DLGFRAME 0x00400000L
-#define WS_VSCROLL 0x00200000L
-#define WS_HSCROLL 0x00100000L
-#define WS_SYSMENU 0x00080000L
-#define WS_THICKFRAME 0x00040000L
-#define WS_MINIMIZEBOX 0x00020000L
-#define WS_MAXIMIZEBOX 0x00010000L
-#define WS_GROUP 0x00020000L
-#define WS_TABSTOP 0x00010000L
-
-// other aliases
-#define WS_OVERLAPPEDWINDOW (WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX)
-#define WS_POPUPWINDOW (WS_POPUP | WS_BORDER | WS_SYSMENU)
-#define WS_CHILDWINDOW (WS_CHILD)
-#define WS_TILED WS_OVERLAPPED
-#define WS_ICONIC WS_MINIMIZE
-#define WS_SIZEBOX WS_THICKFRAME
-#define WS_TILEDWINDOW WS_OVERLAPPEDWINDOW
-
-#define WS_EX_DLGMODALFRAME 0x00000001L
-#define WS_EX_NOPARENTNOTIFY 0x00000004L
-#define WS_EX_TOPMOST 0x00000008L
-#define WS_EX_ACCEPTFILES 0x00000010L
-#define WS_EX_TRANSPARENT 0x00000020L
-
-#define BS_PUSHBUTTON 0x00000000L
-#define BS_DEFPUSHBUTTON 0x00000001L
-#define BS_CHECKBOX 0x00000002L
-#define BS_AUTOCHECKBOX 0x00000003L
-#define BS_RADIOBUTTON 0x00000004L
-#define BS_3STATE 0x00000005L
-#define BS_AUTO3STATE 0x00000006L
-#define BS_GROUPBOX 0x00000007L
-#define BS_USERBUTTON 0x00000008L
-#define BS_AUTORADIOBUTTON 0x00000009L
-#define BS_OWNERDRAW 0x0000000BL
-#define BS_LEFTTEXT 0x00000020L
-
-#define ES_LEFT 0x00000000L
-#define ES_CENTER 0x00000001L
-#define ES_RIGHT 0x00000002L
-#define ES_MULTILINE 0x00000004L
-#define ES_UPPERCASE 0x00000008L
-#define ES_LOWERCASE 0x00000010L
-#define ES_PASSWORD 0x00000020L
-#define ES_AUTOVSCROLL 0x00000040L
-#define ES_AUTOHSCROLL 0x00000080L
-#define ES_NOHIDESEL 0x00000100L
-#define ES_OEMCONVERT 0x00000400L
-#define ES_READONLY 0x00000800L
-#define ES_WANTRETURN 0x00001000L
-
-#define LBS_NOTIFY 0x0001L
-#define LBS_SORT 0x0002L
-#define LBS_NOREDRAW 0x0004L
-#define LBS_MULTIPLESEL 0x0008L
-#define LBS_OWNERDRAWFIXED 0x0010L
-#define LBS_OWNERDRAWVARIABLE 0x0020L
-#define LBS_HASSTRINGS 0x0040L
-#define LBS_USETABSTOPS 0x0080L
-#define LBS_NOINTEGRALHEIGHT 0x0100L
-#define LBS_MULTICOLUMN 0x0200L
-#define LBS_WANTKEYBOARDINPUT 0x0400L
-#define LBS_EXTENDEDSEL 0x0800L
-#define LBS_DISABLENOSCROLL 0x1000L
-
-#define SS_LEFT 0x00000000L
-#define SS_CENTER 0x00000001L
-#define SS_RIGHT 0x00000002L
-#define SS_ICON 0x00000003L
-#define SS_BLACKRECT 0x00000004L
-#define SS_GRAYRECT 0x00000005L
-#define SS_WHITERECT 0x00000006L
-#define SS_BLACKFRAME 0x00000007L
-#define SS_GRAYFRAME 0x00000008L
-#define SS_WHITEFRAME 0x00000009L
-#define SS_SIMPLE 0x0000000BL
-#define SS_LEFTNOWORDWRAP 0x0000000CL
-#define SS_BITMAP 0x0000000EL
-
//
// Debug Format
//
* DISCLAMED. This includes but is not limited to warranties of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Revision: 1.5 $
- * $Author: ariadne $
- * $Date: 1999/03/07 13:35:10 $
+ * $Revision: 1.6 $
+ * $Author: rex $
+ * $Date: 1999/03/19 05:55:06 $
*
*/
/* Appropriated for Reactos Crtdll by Ariadne */
typedef long fpos_t;
int fgetpos (FILE* fileGetPosition, fpos_t* pfpos);
-int fsetpos (FILE* fileSetPosition, fpos_t* pfpos);
+int fsetpos (FILE* fileSetPosition, const fpos_t* pfpos);
/*
+++ /dev/null
-/*
- * string.h
- *
- * Definitions for memory and string functions.
- *
- * This file is part of the Mingw32 package.
- *
- * Contributors:
- * Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
- *
- * THIS SOFTWARE IS NOT COPYRIGHTED
- *
- * This source code is offered for use in the public domain. You may
- * use, modify or distribute it freely.
- *
- * This code is distributed in the hope that it will be useful but
- * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
- * DISCLAMED. This includes but is not limited to warranties of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * $Revision: 1.5 $
- * $Author: ariadne $
- * $Date: 1999/02/21 20:59:55 $
- *
- */
-/* Appropriated for Reactos Crtdll by Ariadne */
-/* changed prototype for _strerror */
-#ifndef _LINUX_WSTRING_H_
-#define _LINUX_WSTRING_H_
-
-#ifndef _LINUX_STRING_H_
-#define _LINUX_STRING_H_
-
-#ifndef _STRING_H_
-#define _STRING_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * Define size_t, wchar_t and NULL
- */
-#define __need_size_t
-#define __need_wchar_t
-#define __need_NULL
-#include <stddef.h>
-
-char * ___strtok; // removed extern specifier 02-06-98, BD
-
-/*
- * Prototypes of the ANSI Standard C library string functions.
- */
-void* memchr (const void* p, int cSearchFor, size_t sizeSearch);
-int memcmp (const void* p1, const void* p2, size_t sizeSearch);
-void* memcpy (void* pCopyTo, const void* pSource, size_t sizeSource);
-void* memmove (void* pMoveTo, const void* pSource, size_t sizeSource);
-void* memset (void* p, int cFill, size_t sizeRepeatCount);
-char* strcat (char* szAddTo, const char* szAdd);
-char* strchr (const char* szSearch, int cFor);
-int strcmp (const char* sz1, const char* sz2);
-int strcoll (const char* sz1, const char* sz2); /* Compare using locale */
-char* strcpy (char* szCopyTo, const char* szSource);
-size_t strcspn (const char* szGetPrefix, const char* szNotIncluding);
-char* strerror (int nError); /* NOTE: NOT an old name wrapper. */
-char * _strerror(const char *s);
-size_t strlen (const char* sz);
-char* strncat (char* szAddTo, const char* szAdd, size_t sizeMaxAdd);
-int strncmp (const char* sz1, const char* sz2, size_t sizeMaxCompare);
-char* strncpy (char* szCopyTo, const char* szSource, size_t sizeMaxCopy);
-char* strpbrk (const char* szSearch, const char* szAnyOf);
-char* strrchr (const char* szSearch, int cFor);
-size_t strspn (const char* szGetPrefix, const char *szIncluding);
-char* strstr (const char* szSearch, const char *szFor);
-char* strtok (char* szTokenize, const char* szDelimiters);
-size_t strxfrm (char* szTransformed, const char *szSource,
- size_t sizeTransform);
-
-#ifndef __STRICT_ANSI__
-/*
- * Extra non-ANSI functions provided by the CRTDLL library
- */
-void* _memccpy (void* pCopyTo, const void* pSource, int cTerminator,
- size_t sizeMaxCopy);
-int _memicmp (const void* p1, const void* p2, size_t sizeSearch);
-char* _strdup (const char *szDuplicate);
-int _strcmpi (const char* sz1, const char* sz2);
-int _stricmp (const char* sz1, const char* sz2);
-int _stricoll (const char* sz1, const char* sz2);
-char* _strlwr (char* szToConvert);
-int _strnicmp (const char* sz1, const char* sz2,
- size_t sizeMaxCompare);
-char* _strnset (char* szToFill, int cFill, size_t sizeMaxFill);
-char* _strrev (char* szToReverse);
-char* _strset (char* szToFill, int cFill);
-char* _strupr (char* szToConvert);
-void _swab (const char* caFrom, char* caTo, size_t sizeToCopy);
-
-#endif /* Not __STRICT_ANSI__ */
-
-
-/*
- * Unicode versions of the standard calls.
- */
-wchar_t* wcscat (wchar_t* wsAddTo, const wchar_t* wsAdd);
-wchar_t* wcschr (const wchar_t* wsSearch, wchar_t wcFor);
-int wcscmp (const wchar_t* ws1, const wchar_t* ws2);
-int wcscoll (const wchar_t* ws1, const wchar_t* ws2);
-wchar_t* wcscpy (wchar_t* wsCopyTo, const wchar_t* wsSource);
-size_t wcscspn (const wchar_t* wsGetPrefix, const wchar_t* wsNotIncluding);
-/* Note: No wcserror in CRTDLL. */
-size_t wcslen (const wchar_t* ws);
-wchar_t* wcsncat (wchar_t* wsAddTo, const wchar_t* wsAdd, size_t sizeMaxAdd);
-int wcsncmp(const wchar_t* ws1, const wchar_t* ws2, size_t sizeMaxCompare);
-wchar_t* wcsncpy(wchar_t* wsCopyTo, const wchar_t* wsSource,
- size_t sizeMaxCopy);
-wchar_t* wcspbrk(const wchar_t* wsSearch, const wchar_t* wsAnyOf);
-wchar_t* wcsrchr(const wchar_t* wsSearch, wchar_t wcFor);
-size_t wcsspn(const wchar_t* wsGetPrefix, const wchar_t* wsIncluding);
-wchar_t* wcsstr(const wchar_t* wsSearch, const wchar_t* wsFor);
-wchar_t* wcstok(wchar_t* wsTokenize, const wchar_t* wsDelimiters);
-size_t wcsxfrm(wchar_t* wsTransformed, const wchar_t *wsSource,
- size_t sizeTransform);
-
-
-#ifndef __STRICT_ANSI__
-/*
- * Unicode versions of non-ANSI functions provided by CRTDLL.
- */
-
-/* NOTE: _wcscmpi not provided by CRTDLL, this define is for portability */
-#define _wcscmpi _wcsicmp
-
-wchar_t* _wcsdup (const wchar_t* wsToDuplicate);
-int _wcsicmp (const wchar_t* ws1, const wchar_t* ws2);
-int _wcsicoll (const wchar_t* ws1, const wchar_t* ws2);
-wchar_t* _wcslwr (wchar_t* wsToConvert);
-int _wcsnicmp (const wchar_t* ws1, const wchar_t* ws2,
- size_t sizeMaxCompare);
-wchar_t* _wcsnset (wchar_t* wsToFill, wchar_t wcFill, size_t sizeMaxFill);
-wchar_t* _wcsrev (wchar_t* wsToReverse);
-wchar_t* _wcsset (wchar_t* wsToFill, wchar_t wcToFill);
-wchar_t* _wcsupr (wchar_t* wsToConvert);
-
-#endif /* Not __STRICT_ANSI__ */
-
-
-#ifndef __STRICT_ANSI__
-#ifndef _NO_OLDNAMES
-
-/*
- * Non-underscored versions of non-ANSI functions. They live in liboldnames.a
- * and provide a little extra portability. Also a few extra UNIX-isms like
- * strcasecmp.
- */
-
-void* memccpy (void* pCopyTo, const void* pSource, int cTerminator,
- size_t sizeMaxCopy);
-int memicmp (const void* p1, const void* p2, size_t sizeSearch);
-char* strdup (const char *szDuplicate);
-int strcmpi (const char* sz1, const char* sz2);
-int stricmp (const char* sz1, const char* sz2);
-int strcasecmp (const char* sz1, const char* sz2);
-int stricoll (const char* sz1, const char* sz2);
-char* strlwr (char* szToConvert);
-int strnicmp (const char* sz1, const char* sz2, size_t sizeMaxCompare);
-int strncasecmp (const char* sz1, const char* sz2, size_t sizeMaxCompare);
-char* strnset (char* szToFill, int cFill, size_t sizeMaxFill);
-char* strrev (char* szToReverse);
-char* strset (char* szToFill, int cFill);
-char* strupr (char* szToConvert);
-void swab (const char* caFrom, char* caTo, size_t sizeToCopy);
-
-/* NOTE: There is no _wcscmpi, but this is for compatibility. */
-int wcscmpi (const wchar_t* ws1, const wchar_t* ws2);
-wchar_t* wcsdup (const wchar_t* wsToDuplicate);
-int wcsicmp (const wchar_t* ws1, const wchar_t* ws2);
-int wcsicoll (const wchar_t* ws1, const wchar_t* ws2);
-wchar_t* wcslwr (wchar_t* wsToConvert);
-int wcsnicmp (const wchar_t* ws1, const wchar_t* ws2,
- size_t sizeMaxCompare);
-wchar_t* wcsnset (wchar_t* wsToFill, wchar_t wcFill, size_t sizeMaxFill);
-wchar_t* wcsrev (wchar_t* wsToReverse);
-wchar_t* wcsset (wchar_t* wsToFill, wchar_t wcToFill);
-wchar_t* wcsupr (wchar_t* wsToConvert);
-
-#endif /* Not _NO_OLDNAMES */
-#endif /* Not strict ANSI */
-
-
-
-/*
- * Include machine specific inline routines
- */
-#ifndef _I386_STRING_H_
-#define _I386_STRING_H_
-
-/*
- * On a 486 or Pentium, we are better off not using the
- * byte string operations. But on a 386 or a PPro the
- * byte string ops are faster than doing it by hand
- * (MUCH faster on a Pentium).
- *
- * Also, the byte strings actually work correctly. Forget
- * the i486 routines for now as they may be broken..
- */
-#if FIXED_486_STRING && (CPU == 486 || CPU == 586)
- #include <asm/string-486.h>
-#else
-
-/*
- * This string-include defines all string functions as inline
- * functions. Use gcc. It also assumes ds=es=data space, this should be
- * normal. Most of the string-functions are rather heavily hand-optimized,
- * see especially strtok,strstr,str[c]spn. They should work, but are not
- * very easy to understand. Everything is done entirely within the register
- * set, making the functions fast and clean. String instructions have been
- * used through-out, making for "slightly" unclear code :-)
- *
- * Copyright (C) 1991, 1992 Linus Torvalds
- */
-
-#define __HAVE_ARCH_STRCPY
-extern inline char * strcpy(char * dest,const char *src)
-{
-__asm__ __volatile__(
- "cld\n"
- "1:\tlodsb\n\t"
- "stosb\n\t"
- "testb %%al,%%al\n\t"
- "jne 1b"
- : /* no output */
- :"S" (src),"D" (dest):"si","di","ax","memory");
-return dest;
-}
-
-#define __HAVE_ARCH_STRNCPY
-extern inline char * strncpy(char * dest,const char *src,size_t count)
-{
-__asm__ __volatile__(
- "cld\n"
- "1:\tdecl %2\n\t"
- "js 2f\n\t"
- "lodsb\n\t"
- "stosb\n\t"
- "testb %%al,%%al\n\t"
- "jne 1b\n\t"
- "rep\n\t"
- "stosb\n"
- "2:"
- : /* no output */
- :"S" (src),"D" (dest),"c" (count):"si","di","ax","cx","memory");
-return dest;
-}
-
-#define __HAVE_ARCH_STRCAT
-extern inline char * strcat(char * dest,const char * src)
-{
-__asm__ __volatile__(
- "cld\n\t"
- "repne\n\t"
- "scasb\n\t"
- "decl %1\n"
- "1:\tlodsb\n\t"
- "stosb\n\t"
- "testb %%al,%%al\n\t"
- "jne 1b"
- : /* no output */
- :"S" (src),"D" (dest),"a" (0),"c" (0xffffffff):"si","di","ax","cx");
-return dest;
-}
-
-#define __HAVE_ARCH_STRNCAT
-extern inline char * strncat(char * dest,const char * src,size_t count)
-{
-__asm__ __volatile__(
- "cld\n\t"
- "repne\n\t"
- "scasb\n\t"
- "decl %1\n\t"
- "movl %4,%3\n"
- "1:\tdecl %3\n\t"
- "js 2f\n\t"
- "lodsb\n\t"
- "stosb\n\t"
- "testb %%al,%%al\n\t"
- "jne 1b\n"
- "2:\txorl %2,%2\n\t"
- "stosb"
- : /* no output */
- :"S" (src),"D" (dest),"a" (0),"c" (0xffffffff),"g" (count)
- :"si","di","ax","cx","memory");
-return dest;
-}
-
-#define __HAVE_ARCH_STRCMP
-extern inline int strcmp(const char * cs,const char * ct)
-{
-register int __res;
-__asm__ __volatile__(
- "cld\n"
- "1:\tlodsb\n\t"
- "scasb\n\t"
- "jne 2f\n\t"
- "testb %%al,%%al\n\t"
- "jne 1b\n\t"
- "xorl %%eax,%%eax\n\t"
- "jmp 3f\n"
- "2:\tsbbl %%eax,%%eax\n\t"
- "orb $1,%%eax\n"
- "3:"
- :"=a" (__res):"S" (cs),"D" (ct):"si","di");
-return __res;
-}
-
-#define __HAVE_ARCH_STRNCMP
-extern inline int strncmp(const char * cs,const char * ct,size_t count)
-{
-register int __res;
-__asm__ __volatile__(
- "cld\n"
- "1:\tdecl %3\n\t"
- "js 2f\n\t"
- "lodsb\n\t"
- "scasb\n\t"
- "jne 3f\n\t"
- "testb %%al,%%al\n\t"
- "jne 1b\n"
- "2:\txorl %%eax,%%eax\n\t"
- "jmp 4f\n"
- "3:\tsbbl %%eax,%%eax\n\t"
- "orb $1,%%al\n"
- "4:"
- :"=a" (__res):"S" (cs),"D" (ct),"c" (count):"si","di","cx");
-return __res;
-}
-
-#define __HAVE_ARCH_STRCHR
-extern inline char * strchr(const char * s, int c)
-{
-register char * __res;
-__asm__ __volatile__(
- "cld\n\t"
- "movb %%al,%%ah\n"
- "1:\tlodsb\n\t"
- "cmpb %%ah,%%al\n\t"
- "je 2f\n\t"
- "testb %%al,%%al\n\t"
- "jne 1b\n\t"
- "movl $1,%1\n"
- "2:\tmovl %1,%0\n\t"
- "decl %0"
- :"=a" (__res):"S" (s),"0" (c):"si");
-return __res;
-}
-
-#define __HAVE_ARCH_STRRCHR
-extern inline char * strrchr(const char * s, int c)
-{
-register char * __res;
-__asm__ __volatile__(
- "cld\n\t"
- "movb %%al,%%ah\n"
- "1:\tlodsb\n\t"
- "cmpb %%ah,%%al\n\t"
- "jne 2f\n\t"
- "leal -1(%%esi),%0\n"
- "2:\ttestb %%al,%%al\n\t"
- "jne 1b"
- :"=d" (__res):"0" (0),"S" (s),"a" (c):"ax","si");
-return __res;
-}
-
-#define __HAVE_ARCH_STRSPN
-extern inline size_t strspn(const char * cs, const char * ct)
-{
-register char * __res;
-__asm__ __volatile__(
- "cld\n\t"
- "movl %4,%%edi\n\t"
- "repne\n\t"
- "scasb\n\t"
- "notl %%ecx\n\t"
- "decl %%ecx\n\t"
- "movl %%ecx,%%edx\n"
- "1:\tlodsb\n\t"
- "testb %%al,%%al\n\t"
- "je 2f\n\t"
- "movl %4,%%edi\n\t"
- "movl %%edx,%%ecx\n\t"
- "repne\n\t"
- "scasb\n\t"
- "je 1b\n"
- "2:\tdecl %0"
- :"=S" (__res):"a" (0),"c" (0xffffffff),"0" (cs),"g" (ct)
- :"ax","cx","dx","di");
-return __res-cs;
-}
-
-#define __HAVE_ARCH_STRCSPN
-extern inline size_t strcspn(const char * cs, const char * ct)
-{
-register char * __res;
-__asm__ __volatile__(
- "cld\n\t"
- "movl %4,%%edi\n\t"
- "repne\n\t"
- "scasb\n\t"
- "notl %%ecx\n\t"
- "decl %%ecx\n\t"
- "movl %%ecx,%%edx\n"
- "1:\tlodsb\n\t"
- "testb %%al,%%al\n\t"
- "je 2f\n\t"
- "movl %4,%%edi\n\t"
- "movl %%edx,%%ecx\n\t"
- "repne\n\t"
- "scasb\n\t"
- "jne 1b\n"
- "2:\tdecl %0"
- :"=S" (__res):"a" (0),"c" (0xffffffff),"0" (cs),"g" (ct)
- :"ax","cx","dx","di");
-return __res-cs;
-}
-
-#define __HAVE_ARCH_STRPBRK
-extern inline char * strpbrk(const char * cs,const char * ct)
-{
-register char * __res;
-__asm__ __volatile__(
- "cld\n\t"
- "movl %4,%%edi\n\t"
- "repne\n\t"
- "scasb\n\t"
- "notl %%ecx\n\t"
- "decl %%ecx\n\t"
- "movl %%ecx,%%edx\n"
- "1:\tlodsb\n\t"
- "testb %%al,%%al\n\t"
- "je 2f\n\t"
- "movl %4,%%edi\n\t"
- "movl %%edx,%%ecx\n\t"
- "repne\n\t"
- "scasb\n\t"
- "jne 1b\n\t"
- "decl %0\n\t"
- "jmp 3f\n"
- "2:\txorl %0,%0\n"
- "3:"
- :"=S" (__res):"a" (0),"c" (0xffffffff),"0" (cs),"g" (ct)
- :"ax","cx","dx","di");
-return __res;
-}
-
-#define __HAVE_ARCH_STRSTR
-extern inline char * strstr(const char * cs,const char * ct)
-{
-register char * __res;
-__asm__ __volatile__(
- "cld\n\t" \
- "movl %4,%%edi\n\t"
- "repne\n\t"
- "scasb\n\t"
- "notl %%ecx\n\t"
- "decl %%ecx\n\t" /* NOTE! This also sets Z if searchstring='' */
- "movl %%ecx,%%edx\n"
- "1:\tmovl %4,%%edi\n\t"
- "movl %%esi,%%eax\n\t"
- "movl %%edx,%%ecx\n\t"
- "repe\n\t"
- "cmpsb\n\t"
- "je 2f\n\t" /* also works for empty string, see above */
- "xchgl %%eax,%%esi\n\t"
- "incl %%esi\n\t"
- "cmpb $0,-1(%%eax)\n\t"
- "jne 1b\n\t"
- "xorl %%eax,%%eax\n\t"
- "2:"
- :"=a" (__res):"0" (0),"c" (0xffffffff),"S" (cs),"g" (ct)
- :"cx","dx","di","si");
-return __res;
-}
-
-#define __HAVE_ARCH_STRLEN
-extern inline size_t strlen(const char * s)
-{
-register int __res;
-__asm__ __volatile__(
- "cld\n\t"
- "repne\n\t"
- "scasb\n\t"
- "notl %0\n\t"
- "decl %0"
- :"=c" (__res):"D" (s),"a" (0),"0" (0xffffffff):"di");
-return __res;
-}
-
-#define __HAVE_ARCH_STRTOK
-extern inline char * strtok(char * s,const char * ct)
-{
-register char * __res;
-__asm__ __volatile__(
- "testl %1,%1\n\t"
- "jne 1f\n\t"
- "testl %0,%0\n\t"
- "je 8f\n\t"
- "movl %0,%1\n"
- "1:\txorl %0,%0\n\t"
- "movl $-1,%%ecx\n\t"
- "xorl %%eax,%%eax\n\t"
- "cld\n\t"
- "movl %4,%%edi\n\t"
- "repne\n\t"
- "scasb\n\t"
- "notl %%ecx\n\t"
- "decl %%ecx\n\t"
- "je 7f\n\t" /* empty delimiter-string */
- "movl %%ecx,%%edx\n"
- "2:\tlodsb\n\t"
- "testb %%al,%%al\n\t"
- "je 7f\n\t"
- "movl %4,%%edi\n\t"
- "movl %%edx,%%ecx\n\t"
- "repne\n\t"
- "scasb\n\t"
- "je 2b\n\t"
- "decl %1\n\t"
- "cmpb $0,(%1)\n\t"
- "je 7f\n\t"
- "movl %1,%0\n"
- "3:\tlodsb\n\t"
- "testb %%al,%%al\n\t"
- "je 5f\n\t"
- "movl %4,%%edi\n\t"
- "movl %%edx,%%ecx\n\t"
- "repne\n\t"
- "scasb\n\t"
- "jne 3b\n\t"
- "decl %1\n\t"
- "cmpb $0,(%1)\n\t"
- "je 5f\n\t"
- "movb $0,(%1)\n\t"
- "incl %1\n\t"
- "jmp 6f\n"
- "5:\txorl %1,%1\n"
- "6:\tcmpb $0,(%0)\n\t"
- "jne 7f\n\t"
- "xorl %0,%0\n"
- "7:\ttestl %0,%0\n\t"
- "jne 8f\n\t"
- "movl %0,%1\n"
- "8:"
- :"=b" (__res),"=S" (___strtok)
- :"0" (___strtok),"1" (s),"g" (ct)
- :"ax","cx","dx","di","memory");
-return __res;
-}
-
-
-#define __HAVE_ARCH_STRICMP
-extern inline int stricmp(const char* cs,const char * ct)
-{
-register int __res;
-
-
-__asm__ __volatile__(
- "cld\n"
- "1:\tmovb (%%esi), %%eax\n\t"
- "movb (%%edi), %%dl \n\t"
- "cmpb $0x5A, %%al\n\t"
- "ja 2f\t\n"
- "cmpb $0x40, %%al\t\n"
- "jbe 2f\t\n"
- "addb $0x20, %%al\t\n"
- "2:\t cmpb $0x5A, %%dl\t\n"
- "ja 3f\t\n"
- "cmpb $0x40, %%dl\t\n"
- "jbe 3f\t\n"
- "addb $0x20, %%dl\t\n"
- "3:\t inc %%esi\t\n"
- "inc %%edi\t\n"
- "cmpb %%al, %%dl\t\n"
- "jne 4f\n\t"
- "cmpb $00, %%al\n\t"
- "jne 1b\n\t"
- "xorl %%eax,%%eax\n\t"
- "jmp 5f\n"
- "4:\tsbbl %%eax,%%eax\n\t"
- "orb $1,%%eax\n"
- "5:"
- :"=a" (__res):"S" (cs),"D" (ct):"si","di");
-
-return __res;
-}
-
-
-#define __HAVE_ARCH_STRNICMP
-extern inline int strnicmp(const char* cs,const char * ct, size_t count)
-{
-register int __res;
-
-
-__asm__ __volatile__(
- "cld\n"
- "1:\t decl %3\n\t"
- "js 6f\n\t"
- "movb (%%esi), %%al\n\t"
- "movb (%%edi), %%dl \n\t"
- "cmpb $0x5A, %%al\n\t"
- "ja 2f\t\n"
- "cmpb $0x40, %%al\t\n"
- "jbe 2f\t\n"
- "addb $0x20, %%al\t\n"
- "2:\t cmpb $0x5A, %%dl\t\n"
- "ja 3f\t\n"
- "cmpb $0x40, %%dl\t\n"
- "jbe 3f\t\n"
- "addb $0x20, %%dl\t\n"
- "3:\t inc %%esi\t\n"
- "inc %%edi\t\n"
- "cmpb %%al, %%dl\t\n"
- "jne 4f\n\t"
- "cmpb $00, %%al\n\t"
- "jne 1b\n\t"
- "6:xorl %%eax,%%eax\n\t"
- "jmp 5f\n"
- "4:\tsbbl %%eax,%%eax\n\t"
- "orb $1,%%eax\n"
- "5:"
- :"=a" (__res):"S" (cs),"D" (ct), "c" (count):"si","di", "cx");
-
-
-return __res;
-}
-
-
-
-
-
-
-extern inline void * __memcpy(void * to, const void * from, size_t n)
-{
-__asm__ __volatile__(
- "cld\n\t"
- "rep ; movsl\n\t"
- "testb $2,%b1\n\t"
- "je 1f\n\t"
- "movsw\n"
- "1:\ttestb $1,%b1\n\t"
- "je 2f\n\t"
- "movsb\n"
- "2:"
- : /* no output */
- :"c" (n/4), "q" (n),"D" ((long) to),"S" ((long) from)
- : "cx","di","si","memory");
-return (to);
-}
-
-/*
- * This looks horribly ugly, but the compiler can optimize it totally,
- * as the count is constant.
- */
-extern inline void * __constant_memcpy(void * to, const void * from, size_t n)
-{
- switch (n) {
- case 0:
- return to;
- case 1:
- *(unsigned char *)to = *(const unsigned char *)from;
- return to;
- case 2:
- *(unsigned short *)to = *(const unsigned short *)from;
- return to;
- case 3:
- *(unsigned short *)to = *(const unsigned short *)from;
- *(2+(unsigned char *)to) = *(2+(const unsigned char *)from);
- return to;
- case 4:
- *(unsigned long *)to = *(const unsigned long *)from;
- return to;
- case 8:
- *(unsigned long *)to = *(const unsigned long *)from;
- *(1+(unsigned long *)to) = *(1+(const unsigned long *)from);
- return to;
- case 12:
- *(unsigned long *)to = *(const unsigned long *)from;
- *(1+(unsigned long *)to) = *(1+(const unsigned long *)from);
- *(2+(unsigned long *)to) = *(2+(const unsigned long *)from);
- return to;
- case 16:
- *(unsigned long *)to = *(const unsigned long *)from;
- *(1+(unsigned long *)to) = *(1+(const unsigned long *)from);
- *(2+(unsigned long *)to) = *(2+(const unsigned long *)from);
- *(3+(unsigned long *)to) = *(3+(const unsigned long *)from);
- return to;
- case 20:
- *(unsigned long *)to = *(const unsigned long *)from;
- *(1+(unsigned long *)to) = *(1+(const unsigned long *)from);
- *(2+(unsigned long *)to) = *(2+(const unsigned long *)from);
- *(3+(unsigned long *)to) = *(3+(const unsigned long *)from);
- *(4+(unsigned long *)to) = *(4+(const unsigned long *)from);
- return to;
- }
-#define COMMON(x) \
-__asm__("cld\n\t" \
- "rep ; movsl" \
- x \
- : /* no outputs */ \
- : "c" (n/4),"D" ((long) to),"S" ((long) from) \
- : "cx","di","si","memory");
-
- switch (n % 4) {
- case 0: COMMON(""); return to;
- case 1: COMMON("\n\tmovsb"); return to;
- case 2: COMMON("\n\tmovsw"); return to;
- case 3: COMMON("\n\tmovsw\n\tmovsb"); return to;
- }
-#undef COMMON
-}
-
-#define __HAVE_ARCH_MEMCPY
-#define memcpy(t, f, n) \
-(__builtin_constant_p(n) ? \
- __constant_memcpy((t),(f),(n)) : \
- __memcpy((t),(f),(n)))
-
-#define __HAVE_ARCH_MEMMOVE
-extern inline void * memmove(void * dest,const void * src, size_t n)
-{
-if (dest<src)
-__asm__ __volatile__(
- "cld\n\t"
- "rep\n\t"
- "movsb"
- : /* no output */
- :"c" (n),"S" (src),"D" (dest)
- :"cx","si","di");
-else
-__asm__ __volatile__(
- "std\n\t"
- "rep\n\t"
- "movsb\n\t"
- "cld"
- : /* no output */
- :"c" (n),
- "S" (n-1+(const char *)src),
- "D" (n-1+(char *)dest)
- :"cx","si","di","memory");
-return dest;
-}
-
-#define memcmp __builtin_memcmp
-
-#define __HAVE_ARCH_MEMCHR
-extern inline void * memchr(const void * cs,int c,size_t count)
-{
-register void * __res;
-if (!count)
- return NULL;
-__asm__ __volatile__(
- "cld\n\t"
- "repne\n\t"
- "scasb\n\t"
- "je 1f\n\t"
- "movl $1,%0\n"
- "1:\tdecl %0"
- :"=D" (__res):"a" (c),"D" (cs),"c" (count)
- :"cx");
-return __res;
-}
-
-extern inline void * __memset_generic(void * s, char c,size_t count)
-{
-__asm__ __volatile__(
- "cld\n\t"
- "rep\n\t"
- "stosb"
- : /* no output */
- :"a" (c),"D" (s),"c" (count)
- :"cx","di","memory");
-return s;
-}
-
-/* we might want to write optimized versions of these later */
-#define __constant_count_memset(s,c,count) __memset_generic((s),(c),(count))
-
-/*
- * memset(x,0,y) is a reasonably common thing to do, so we want to fill
- * things 32 bits at a time even when we don't know the size of the
- * area at compile-time..
- */
-extern inline void * __constant_c_memset(void * s, unsigned long c, size_t count)
-{
-__asm__ __volatile__(
- "cld\n\t"
- "rep ; stosl\n\t"
- "testb $2,%b1\n\t"
- "je 1f\n\t"
- "stosw\n"
- "1:\ttestb $1,%b1\n\t"
- "je 2f\n\t"
- "stosb\n"
- "2:"
- : /* no output */
- :"a" (c), "q" (count), "c" (count/4), "D" ((long) s)
- :"cx","di","memory");
-return (s);
-}
-
-/* Added by Gertjan van Wingerde to make minix and sysv module work */
-#define __HAVE_ARCH_STRNLEN
-extern inline size_t strnlen(const char * s, size_t count)
-{
-register int __res;
-__asm__ __volatile__(
- "movl %1,%0\n\t"
- "jmp 2f\n"
- "1:\tcmpb $0,(%0)\n\t"
- "je 3f\n\t"
- "incl %0\n"
- "2:\tdecl %2\n\t"
- "cmpl $-1,%2\n\t"
- "jne 1b\n"
- "3:\tsubl %1,%0"
- :"=a" (__res)
- :"c" (s),"d" (count)
- :"dx");
-return __res;
-}
-/* end of additional stuff */
-
-/*
- * This looks horribly ugly, but the compiler can optimize it totally,
- * as we by now know that both pattern and count is constant..
- */
-extern inline void * __constant_c_and_count_memset(void * s, unsigned long pattern, size_t count)
-{
- switch (count) {
- case 0:
- return s;
- case 1:
- *(unsigned char *)s = pattern;
- return s;
- case 2:
- *(unsigned short *)s = pattern;
- return s;
- case 3:
- *(unsigned short *)s = pattern;
- *(2+(unsigned char *)s) = pattern;
- return s;
- case 4:
- *(unsigned long *)s = pattern;
- return s;
- }
-#define COMMON(x) \
-__asm__("cld\n\t" \
- "rep ; stosl" \
- x \
- : /* no outputs */ \
- : "a" (pattern),"c" (count/4),"D" ((long) s) \
- : "cx","di","memory")
-
- switch (count % 4) {
- case 0: COMMON(""); return s;
- case 1: COMMON("\n\tstosb"); return s;
- case 2: COMMON("\n\tstosw"); return s;
- case 3: COMMON("\n\tstosw\n\tstosb"); return s;
- }
-#undef COMMON
-}
-
-#define __constant_c_x_memset(s, c, count) \
-(__builtin_constant_p(count) ? \
- __constant_c_and_count_memset((s),(c),(count)) : \
- __constant_c_memset((s),(c),(count)))
-
-#define __memset(s, c, count) \
-(__builtin_constant_p(count) ? \
- __constant_count_memset((s),(c),(count)) : \
- __memset_generic((s),(c),(count)))
-
-#define __HAVE_ARCH_MEMSET
-#define memset(s, c, count) \
-(__builtin_constant_p(c) ? \
- __constant_c_x_memset((s),(0x01010101UL*(unsigned char)c),(count)) : \
- __memset((s),(c),(count)))
-
-/*
- * find the first occurrence of byte 'c', or 1 past the area if none
- */
-#define __HAVE_ARCH_MEMSCAN
-extern inline void * memscan(void * addr, int c, size_t size)
-{
- if (!size)
- return addr;
- __asm__("cld
- repnz; scasb
- jnz 1f
- dec %%edi
-1: "
- : "=D" (addr), "=c" (size)
- : "0" (addr), "1" (size), "a" (c));
- return addr;
-}
-
-
-
-
-
-#endif
-#endif
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _STRING_H_ */
-#endif
-
-#endif
/* PE executable header. */
+#ifndef WIN32_NO_PEHDR
+
typedef struct
{
WORD e_magic; /* Magic number, 0x5a4d */
/* DWORD nt_signature; * required NT signature, 0x4550 */
} IMAGE_DOS_HEADER, *PIMAGE_DOS_HEADER;
+#endif /* WIN32_NO_PEHDR */
+
#ifdef __cplusplus
}
#endif /* __cplusplus */
+++ /dev/null
-/*
- * stat.h
- *
- * Symbolic constants for opening and creating files, also stat, fstat and
- * chmod functions.
- *
- * This file is part of the Mingw32 package.
- *
- * Contributors:
- * Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
- *
- * THIS SOFTWARE IS NOT COPYRIGHTED
- *
- * This source code is offered for use in the public domain. You may
- * use, modify or distribute it freely.
- *
- * This code is distributed in the hope that it will be useful but
- * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
- * DISCLAMED. This includes but is not limited to warranties of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * $Revision: 1.2 $
- * $Author: ariadne $
- * $Date: 1999/02/21 13:29:57 $
- *
- */
-
-#ifndef __STRICT_ANSI__
-
-#ifndef _STAT_H_
-#define _STAT_H_
-
-#include <sys/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-
-
-/*
- * Constants for the stat st_mode member.
- */
-#define S_IFIFO 0x1000 /* FIFO */
-#define S_IFCHR 0x2000 /* Character */
-#define S_IFBLK 0x3000 /* Block */
-#define S_IFDIR 0x4000 /* Directory */
-#define S_IFREG 0x8000 /* Regular */
-
-#define S_IFMT 0xF000 /* File type mask */
-
-#define S_IEXEC 0x0040
-#define S_IWRITE 0x0080
-#define S_IREAD 0x0100
-
-#define _S_IREAD S_IREAD
-#define _S_IWRITE S_IWRITE
-#define _S_IEXEC S_IEXEC
-
-
-
-#define S_ISDIR(m) ((m) & S_IFDIR)
-#define S_ISFIFO(m) ((m) & S_IFIFO)
-#define S_ISCHR(m) ((m) & S_IFCHR)
-#define S_ISBLK(m) ((m) & S_IFBLK)
-#define S_ISREG(m) ((m) & S_IFREG)
-
-#define S_IRWXU (S_IREAD | S_IWRITE | S_IEXEC)
-#define S_IXUSR S_IEXEC
-#define S_IWUSR S_IWRITE
-#define S_IRUSR S_IREAD
-
-/*
- * The structure manipulated and returned by stat and fstat.
- *
- * NOTE: If called on a directory the values in the time fields are not only
- * invalid, they will cause localtime et. al. to return NULL. And calling
- * asctime with a NULL pointer causes an Invalid Page Fault. So watch it!
- */
-struct stat
-{
- short st_dev; /* Equivalent to drive number 0=A 1=B ... */
- short st_ino; /* Always zero ? */
- short st_mode; /* See above constants */
- short st_nlink; /* Number of links. */
- int st_uid; /* User: Maybe significant on NT ? */
- short st_gid; /* Group: Ditto */
- short st_rdev; /* Seems useless (not even filled in) */
- long st_size; /* File size in bytes */
- time_t st_atime; /* Accessed date (always 00:00 hrs local
- * on FAT) */
- time_t st_mtime; /* Modified time */
- time_t st_ctime; /* Creation time */
-};
-
-
-int _fstat (int nHandle, struct stat* pstat);
-int _chmod (const char* szPath, int nMode);
-int _stat (const char* szPath, struct stat* pstat);
-
-
-#ifndef _NO_OLDNAMES
-
-/* These functions live in liboldnames.a. */
-int fstat (int nHandle, struct stat* pstat);
-int chmod (const char* szPath, int nMode);
-int stat (const char* szPath, struct stat* pstat);
-
-#endif /* Not _NO_OLDNAMES */
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* Not _STAT_H_ */
-
-#endif /* Not __STRICT_ANSI__ */
+++ /dev/null
-/*
- * types.h
- *
- * The definition of constants, data types and global variables.
- *
- * This file is part of the Mingw32 package.
- *
- * Contributors:
- * Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
- * Lots of types supplied by Pedro A. Aranda <paag@tid.es>
- *
- * THIS SOFTWARE IS NOT COPYRIGHTED
- *
- * This source code is offered for use in the public domain. You may
- * use, modify or distribute it freely.
- *
- * This code is distributed in the hope that it will be useful but
- * WITHOUT ANY WARRANTY. ALL WARRENTIES, EXPRESS OR IMPLIED ARE HEREBY
- * DISCLAMED. This includes but is not limited to warrenties of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * $Revision: 1.2 $
- * $Author: ariadne $
- * $Date: 1999/02/21 13:29:57 $
- *
- */
-/* Appropriated for Reactos Crtdll by Ariadne */
-
-#ifndef _TYPES_H_
-#define _TYPES_H_
-
-#define __need_wchar_t
-#define __need_size_t
-#define __need_ptrdiff_t
-#include <stddef.h>
-
-#ifndef RC_INVOKED
-
-#ifndef _TIME_T_
-#define _TIME_T_
-typedef long time_t;
-#endif
-
-
-#ifndef __STRICT_ANSI__
-
-#ifndef _OFF_T_
-#define _OFF_T_
-typedef long _off_t;
-
-#ifndef _NO_OLDNAMES
-typedef _off_t off_t;
-#endif
-#endif /* Not _OFF_T_ */
-
-
-#ifndef _DEV_T_
-#define _DEV_T_
-typedef short _dev_t;
-
-#ifndef _NO_OLDNAMES
-typedef _dev_t dev_t;
-#endif
-#endif /* Not _DEV_T_ */
-
-
-#ifndef _INO_T_
-#define _INO_T_
-typedef short _ino_t;
-
-#ifndef _NO_OLDNAMES
-typedef _ino_t ino_t;
-#endif
-#endif /* Not _INO_T_ */
-
-
-#ifndef _PID_T_
-#define _PID_T_
-typedef int _pid_t;
-
-#ifndef _NO_OLDNAMES
-typedef _pid_t pid_t;
-#endif
-#endif /* Not _PID_T_ */
-
-
-#ifndef _MODE_T_
-#define _MODE_T_
-typedef unsigned short _mode_t;
-
-#ifndef _NO_OLDNAMES
-typedef _mode_t mode_t;
-#endif
-#endif /* Not _MODE_T_ */
-
-
-#ifndef _SIGSET_T_
-#define _SIGSET_T_
-typedef int _sigset_t;
-
-
-
-#ifndef _NO_OLDNAMES
-typedef _sigset_t sigset_t;
-#endif
-#endif /* Not _SIGSET_T_ */
-
-#endif /* Not __STRICT_ANSI__ */
-
-#endif /* Not RC_INVOKED */
-
-#endif /* Not _TYPES_H_ */
+++ /dev/null
-/*
- * Added wide character type wchar_t, june 1998 -- Boudewijn Dekker
- */
-#ifndef _LINUX_TYPES_H
-#define _LINUX_TYPES_H
-
-#ifndef NULL
-# define NULL ((void *) 0)
-#endif
-
-
-#ifndef _I386_TYPES_H
-#define _I386_TYPES_H
-
-/*
- * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the
- * header files exported to user space
- */
-
-typedef __signed__ char __s8;
-typedef unsigned char __u8;
-
-typedef __signed__ short __s16;
-typedef unsigned short __u16;
-
-typedef __signed__ int __s32;
-typedef unsigned int __u32;
-
-#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
-typedef __signed__ long long __s64;
-typedef unsigned long long __u64;
-#endif
-
-/*
- * These aren't exported outside the kernel to avoid name space clashes
- */
-#ifdef __KERNEL__
-
-typedef signed char s8;
-typedef unsigned char u8;
-
-typedef signed short s16;
-typedef unsigned short u16;
-
-typedef signed int s32;
-typedef unsigned int u32;
-
-typedef signed long long s64;
-typedef unsigned long long u64;
-
-#endif /* __KERNEL__ */
-
-#endif
-
-
-typedef unsigned int size_t;
-typedef size_t __kernel_size_t;
-//typedef unsigned short wchar_t;
-
-
-#endif /* _LINUX_TYPES_H */
+++ /dev/null
-/*
- * wchar.h
- *
- * Defines of all functions for supporting wide characters. Actually it
- * just includes all those headers, which is not a good thing to do from a
- * processing time point of view, but it does mean that everything will be
- * in sync.
- *
- * This file is part of the Mingw32 package.
- *
- * THIS SOFTWARE IS NOT COPYRIGHTED
- *
- * This source code is offered for use in the public domain. You may
- * use, modify or distribute it freely.
- *
- * This code is distributed in the hope that it will be useful but
- * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
- * DISCLAMED. This includes but is not limited to warranties of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * $Revision: 1.3 $
- * $Author: ariadne $
- * $Date: 1999/02/21 17:43:45 $
- *
- */
-
-#include <ctype.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
+++ /dev/null
-/*
- * Adapted from linux for the reactos kernel, march 1998 -- David Welch
- * Added wide character string functions, june 1998 -- Boudewijn Dekker
- * Removed extern specifier from ___wcstok, june 1998 -- Boudewijn Dekker
- * Added wcsicmp and wcsnicmp -- Boudewijn Dekker
- */
-
-#ifndef _STRING_H_
-#define _STRING_H_
-
-
-#ifndef _LINUX_WSTRING_H_
-#define _LINUX_WSTRING_H_
-
-#include <internal/types.h>
-
-
-
-
-
-#ifndef _WCHAR_T_
-#define _WCHAR_T_
-#define _WCHAR_T
- typedef unsigned short wchar_t;
-#endif
-#define Aa_Difference (L'A'-L'a')
-
-#define towupper(c) (((c>=L'a') && (c<=L'z')) ? c+Aa_Difference : c)
-#define towlower(c) (((c>=L'A') && (c<=L'Z')) ? c-Aa_Difference : c)
-
-//obsolete
-wchar_t wtolower(wchar_t c );
-wchar_t wtoupper(wchar_t c );
-
-
-#define iswlower(c) ((c) >= L'a' && (c) <= L'z')
-#define iswupper(c) ((c) >= L'A' && (c) <= L'Z')
-
-#define iswdigit(c) ((c) >= L'0' && (c) <= L'9')
-#define iswxdigit(c) (((c) >= L'0' && (c) <= L'9') || ((c) >= L'A' && (c) <= L'F') || ((c) >= L'a' && (c) <= L'f') )
-
-#ifndef NULL
-#define NULL ((void *) 0)
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-//wchar_t * ___wcstok = NULL;
-wchar_t * wcscpy(wchar_t *,const wchar_t *);
-wchar_t * wcsncpy(wchar_t *,const wchar_t *, size_t);
-wchar_t * wcscat(wchar_t *, const wchar_t *);
-wchar_t * wcsncat(wchar_t *, const wchar_t *, size_t);
-int wcscmp(const wchar_t *,const wchar_t *);
-int wcsncmp(const wchar_t *,const wchar_t *,size_t);
-wchar_t* wcschr(const wchar_t* str, wchar_t ch);
-wchar_t * wcsrchr(const wchar_t *,wchar_t);
-wchar_t * wcspbrk(const wchar_t *,const wchar_t *);
-wchar_t * wcstok(wchar_t *,const wchar_t *);
-wchar_t * wcsstr(const wchar_t *,const wchar_t *);
-size_t wcslen(const wchar_t * s);
-size_t wcsnlen(const wchar_t * s, size_t count);
-int wcsicmp(const wchar_t* cs,const wchar_t * ct);
-int wcsnicmp(const wchar_t* cs,const wchar_t * ct, size_t count);
-size_t wcsspn(const wchar_t *str,const wchar_t *accept);
-size_t wcscspn(const wchar_t *str,const wchar_t *reject);
-wchar_t *wcsrev(wchar_t *s);
-wchar_t *wcsstr(const wchar_t *s,const wchar_t *b);
-wchar_t *wcsdup(const wchar_t *ptr);
-wchar_t *wcsupr(wchar_t *x);
-wchar_t * wcslwr(wchar_t *x);
-
-//obsolete
-size_t wstrlen(const wchar_t * s);
-int wcscmpi (const wchar_t* ws1, const wchar_t* ws2);
-
-
-
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-
-#endif
)
{
return RtlSetSecurityDescriptorLength(pSecurityDescriptor);
-}
\ No newline at end of file
+}
if ( !WriteFile(GetStdHandle(STD_OUTPUT_HANDLE),_str,len,&written,NULL))
return -1;
return 0;
-}
\ No newline at end of file
+}
* UPDATE HISTORY:
* 28/12/98: Created
*/
-#include <windows.h>
#include <conio.h>
#include <stdio.h>
-#include <io.h>
-
+#include <windows.h>
extern int char_avail;
extern int ungot_char;
+int getch( void )
+{
+ return _getch();
+}
int
_getch(void)
}
else
{
- ReadConsoleA(_get_osfhandle(stdin->_file), &c,1,&NumberOfCharsRead ,NULL);
+ ReadConsoleA(filehnd(stdin->_file), &c,1,&NumberOfCharsRead ,NULL);
}
if ( c == 10 )
ungot_char = c;
char_avail = 1;
return(c);
-}
\ No newline at end of file
+}
return ((_pctype_dll[(c & 0xFF)]&t) == t );
}
-
#include <windows.h>
#include <ctype.h>
-
+char _SetCurrentDirectory(char *dir);
+int _GetCurrentDirectory(int count,char *buffer);
#undef chdir
int chdir( const char *_path )
if ( !GetDiskFreeSpaceA(RootPathName,&_diskspace->sectors_per_cluster,&_diskspace->bytes_per_sector,&_diskspace->avail_clusters,&_diskspace->total_clusters ) )
return 0;
return _diskspace->avail_clusters;
-}
\ No newline at end of file
+}
if (!CreateDirectoryA(_path,NULL))
return -1;
return 0;
-}
\ No newline at end of file
+}
if (!RemoveDirectoryA(_path))
return -1;
return 0;
-}
\ No newline at end of file
+}
-#include <windows.h>
#include <io.h>
+#include <windows.h>
+
+#define F_OK 0x01
+#define R_OK 0x02
+#define W_OK 0x04
+#define X_OK 0x08
+#define D_OK 0x10
+
+int access(const char *_path, int _amode)
+{
+ return _access(_path,_amode);
+}
int _access( const char *_path, int _amode )
{
if ( Attributes == -1 )
return -1;
- if ( (_amode & W_OK) == W_OK ) {
+ if ( _amode & W_OK == W_OK ) {
if ( (Attributes & FILE_ATTRIBUTE_READONLY) == FILE_ATTRIBUTE_READONLY )
return -1;
}
- if ( (_amode & D_OK) != D_OK ) {
- if ( (Attributes & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY )
- return -1;
+ if ( _amode & D_OK == D_OK ) {
+ if ( (Attributes & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY )
+ return 0;
}
return 0;
-#include <windows.h>
#include <io.h>
-#include <libc/file.h>
+#include <windows.h>
+//#include <libc/file.h>
+
+
+int close(int _fd)
+{
+ return _close(_fd);
+}
int _close(int _fd)
{
- CloseHandle(_get_osfhandle(_fd));
+ CloseHandle(filehnd(_fd));
return __fileno_close(_fd);
}
#include <io.h>
#include <fcntl.h>
-
-int _creat(const char *filename, int mode)
+#undef creat
+int creat(const char *filename, int mode)
{
- return _open(filename,_O_CREAT|_O_TRUNC,mode);
+ return open(filename,_O_CREAT|_O_TRUNC,mode);
}
#include <windows.h>
#include <io.h>
+#undef dup
+int dup( int handle )
+{
+ return _dup(handle);
+}
-
-int _dup( int _fd )
+int _dup( int handle )
{
- return _open_osfhandle(_get_osfhandle(_fd), 0666);
+ return _open_osfhandle(filehnd(handle), 0666);
}
#include <windows.h>
#include <io.h>
-#include <libc/file.h>
+
+#undef dup2
+int dup2( int handle1, int handle2 )
+{
+ return _dup2(handle1,handle2);
+}
-int _dup2( int _fd1, int _fd2 )
+int _dup2( int handle1, int handle2 )
{
- return __fileno_dup2( _fd1, _fd2 );
+ return __fileno_dup2( handle1, handle2 );
}
#include <io.h>
#include <string.h>
+#if 0
+
+//UnixTimeToFileTime
+//FileTimeToUnixTime
/*
* DOS file system functions
*
time_t FileTimeToUnixTime( const FILETIME *filetime, DWORD *remainder );
-int _findfirst(const char *_name, struct _finddata_t *result)
+long _findfirst(char *_name, struct _finddata_t *result)
{
WIN32_FIND_DATA FindFileData;
char dir[MAX_PATH];
}
else
strcpy(dir,_name);
- hFindFile = FindFirstFileA( dir, &FindFileData );
+ hFindFile = FindFirstFile( dir, &FindFileData );
result->attrib = FindFileData.dwFileAttributes;
return hFindFile;
}
-int _findnext(int handle, struct _finddata_t *result)
+int _findnext(long handle, struct _finddata_t *result)
{
WIN32_FIND_DATA FindFileData;
if (handle == -1 )
strncpy(result->name,&FindFileData.cFileName,260);
return 0;
}
-int _findclose(int handle)
+int _findclose(long handle)
{
return FindClose(handle);
}
}
-
+#endif
unsigned int _fmode = O_TEXT;
unsigned int *_fmode_dll = &_fmode;
+
#include <io.h>
+#undef isatty
-
-int _isatty( int handle )
+int isatty( int handle )
{
- if ( handle < 5 )
- return 1;
- return 0;
+ return (handle & 3);
}
#include <windows.h>
#include <io.h>
+//#include <libc/file.h>
-off_t _lseek(int _fd, off_t _offset, int _whence)
+#undef lseek
+long lseek(int _fildes, long _offset, int _whence)
{
- return _llseek((HFILE)_get_osfhandle(_fd),_offset,_whence);
+ return _lseek(_fildes,_offset,_whence);
+}
+
+long _lseek(int _fildes, long _offset, int _whence)
+{
+ //return _llseek(filehnd(_fildes),_offset,_whence);
}
+
+int __fileno_alloc(HANDLE hFile, int mode);
+
+// fixme
+#undef open
+int open(const char *_path, int _oflag,...)
+{
+ return _open(_path,_oflag);
+}
+
int _open(const char *_path, int _oflag,...)
{
return i;
}
-void *_get_osfhandle(int fileno)
+void *filehnd(int fileno)
{
fileno_modes[_fd].fd = -1;
fileno_modes[_fd].hFile = (HANDLE)-1;
-
- return 0;
}
#include <io.h>
#include <windows.h>
-
+size_t read(int _fd, void *_buf, size_t _nbyte)
+{
+ return _read(_fd,_buf,_nbyte);
+}
size_t _read(int _fd, void *_buf, size_t _nbyte)
{
size_t _rbyte;
- if ( !ReadFile(_get_osfhandle(_fd),_buf,_nbyte,&_rbyte,NULL) ) {
+ if ( !ReadFile(filehnd(_fd),_buf,_nbyte,&_rbyte,NULL) ) {
+ printf("%d\n",GetLastError());
return -1;
}
int _setmode(int _fd, int _newmode)
{
return __fileno_setmode(_fd, _newmode);
-}
\ No newline at end of file
+}
#include <windows.h>
#include <io.h>
+int unlink( const char *filename )
+{
+ return _unlink(filename);
+}
int _unlink( const char *filename )
{
- if ( !DeleteFileA(filename) )
+ if ( !DeleteFile(filename) )
return -1;
return 0;
}
#include <io.h>
#include <windows.h>
+int write(int _fd, const void *_buf,int _nbyte)
+{
+ return _write(_fd,_buf,_nbyte);
+}
size_t _write(int _fd, const void *_buf, size_t _nbyte)
{
size_t _wbyte;
- if ( !WriteFile(_get_osfhandle(_fd),_buf,_nbyte,(DWORD *)&_wbyte,NULL) ) {
+ if ( !WriteFile(filehnd(_fd),_buf,_nbyte,&_wbyte,NULL) ) {
+ printf("%d\n",GetLastError());
return -1;
}
return _wbyte;
cmdline = GetCommandLineA();
afterlastspace=0;
- //dprintf("cmdline '%s'\n",cmdline);
+ dprintf("cmdline '%s'\n",cmdline);
while (cmdline[i])
{
if (cmdline[i]==' ')
{
- // dprintf("cmdline '%s'\n",cmdline);
+ dprintf("cmdline '%s'\n",cmdline);
__argc++;
cmdline[i]='\0';
__argv[__argc-1] = strdup( cmdline+afterlastspace);
return 0;
}
-int _chkstk(void)
+int _chkstk()
{
return 0;
}
void sleep(unsigned long timeout)
{
Sleep((timeout)?timeout:1);
-}
\ No newline at end of file
+}
void _local_unwind2( PEXCEPTION_FRAME endframe, DWORD nr )
{
TRACE(crtdll,"(%p,%ld)\n",endframe,nr);
-}
\ No newline at end of file
+}
return -1;
// WAIT_TIMEOUT
-}
\ No newline at end of file
+}
extern char *const *_environ;
-int _execl(const char *path, const char *argv0, ...)
+int execl(const char *path, const char *argv0, ...)
{
- return _spawnve(P_OVERLAY, path, (const char *const*)&argv0,(const char *const*) _environ);
+ return spawnve(P_OVERLAY, path, (char *const*)&argv0, _environ);
}
u.ccp = *++ptr; \
ptr = u.ccpp;
-int _execle(const char *path, const char *argv0, ... /*, const char **envp */)
+int execle(const char *path, const char *argv0, ... /*, const char **envp */)
{
scan_ptr();
- return _spawnve(P_OVERLAY, path, (const char *const *)&argv0, (const char *const *)ptr);
+ return spawnve(P_OVERLAY, path, (char *const *)&argv0, (char *const *)ptr);
}
#include <process.h>
-extern char **_environ;
+extern char * const *_environ;
-int _execlp(const char *path, const char *argv0, ...)
+int execlp(const char *path, const char *argv0, ...)
{
- return _spawnvpe(P_OVERLAY, path, (const char * const *)&argv0,(const char *const*) _environ);
+ return spawnvpe(P_OVERLAY, path, (char * const *)&argv0, _environ);
}
u.ccp = *++ptr; \
ptr = u.ccpp;
-int _execlpe(const char *path, const char *argv0, ... /*, const char **envp */)
+int execlpe(const char *path, const char *argv0, ... /*, const char **envp */)
{
scan_ptr();
- return _spawnvpe(P_OVERLAY, path, (const char * const *)&argv0, (const char * const *)ptr);
+ return spawnvpe(P_OVERLAY, path, (char * const *)&argv0, (char * const *)ptr);
}
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
-
+//#include <libc/stubs.h>
+//#include <unistd.h>
#include <process.h>
extern char * const *_environ;
-int _execv(const char *path, const char * const *argv)
+int execv(const char *path, const char * const *argv)
{
- return _spawnve(P_OVERLAY, path, argv,(const char *const*) _environ);
+ return spawnve(P_OVERLAY, path, argv, _environ);
}
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
-
+//#include <libc/stubs.h>
+//#include <unistd.h>
#include <process.h>
-int _execve(const char *path,const char * const argv[], char * const envp[])
+int execve(const char *path,const char * const argv[], char * const envp[])
{
- return _spawnve(P_OVERLAY, path, argv, envp);
+ return spawnve(P_OVERLAY, path, argv, envp);
}
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
+//#include <libc/stubs.h>
+//#include <unistd.h>
#include <process.h>
extern char *const *_environ;
-int _execvp(const char *path,const char * const argv[])
+int execvp(const char *path,const char * const argv[])
{
- return _spawnvpe(P_OVERLAY,path,(const char *const*) argv,(const char *const*) _environ);
+ return spawnvpe(P_OVERLAY, path, argv, _environ);
}
#include <process.h>
-int _execvpe(const char *path,const char * const argv[],const char * const envp[])
+int execvpe(const char *path,const char * const argv[],const char * const envp[])
{
- return _spawnvpe(P_OVERLAY, path, argv, envp);
+ return spawnvpe(P_OVERLAY, path, argv, envp);
}
-
+int _execvpe(const char *path,const char * const argv[],const char * const envp[])
+{
+ return spawnvpe(P_OVERLAY, path, argv, envp);
+}
#include <process.h>
-extern char *_environ[];
+extern char **_environ;
-int _spawnl(int mode, const char *path, const char *argv0, ...)
+int spawnl(int mode, const char *path, const char *argv0, ...)
{
- return _spawnve(mode, path, (const char * const *)&argv0,(const char *const *) _environ);
+ return spawnve(mode, path, (char * const *)&argv0, _environ);
}
u.ccp = *++ptr; \
ptr = u.ccpp;
-int _spawnle(int mode, const char *path, const char *argv0, ... /*, const char **envp */)
+int spawnle(int mode, const char *path, const char *argv0, ... /*, const char **envp */)
{
scan_ptr();
- return _spawnve(mode, path, (const char * const *)&argv0, (const char * const *)ptr);
+ return spawnve(mode, path, (char * const *)&argv0, (char * const *)ptr);
}
extern char **_environ;
-int _spawnlp(int mode, const char *path, const char *argv0, ...)
+int spawnlp(int mode, const char *path, const char *argv0, ...)
{
- return _spawnvpe(mode, path, (const char * const *)&argv0, (const char * const *)_environ);
+ return spawnvpe(mode, path, (char * const *)&argv0, (char * const *)_environ);
}
int spawnlpe(int mode, const char *path, const char *argv0, ... /*, const char **envp */)
{
scan_ptr();
- return spawnvpe(mode, path, (const char * const *)&argv0, (const char * const *)ptr);
+ return spawnvpe(mode, path, (char * const *)&argv0, (char * const *)ptr);
}
#include <process.h>
-extern char *_environ[];
+extern char **_environ;
-int _spawnv(int mode, const char *path,const char *const argv[])
+int spawnv(int mode, const char *path,const char *const argv[])
{
- return _spawnve(mode, path, (const char * const *)argv,(const char * const *) _environ);
+ return spawnve(mode, path, (char * const *)argv, _environ);
}
-#include <windows.h>
#include <process.h>
#include <string.h>
+#include <windows.h>
#include <stdio.h>
-#include <stdlib.h>
int _p_overlay = 2;
-int _spawnve(int mode, const char *path,const char *const argv[],const char *const envp[])
+int spawnve(int mode, const char *path,const char *const argv[],const char *const envp[])
{
char ApplicationName[MAX_PATH];
StartupInfo.dwFlags = 0;
- if ( CreateProcessA(ApplicationName,CommandLine,NULL,NULL,TRUE,CREATE_NEW_CONSOLE|NORMAL_PRIORITY_CLASS,NULL,*envp,&StartupInfo,&ProcessInformation) ) {
- //errno = GetLastError();
- return -1;
- }
+// if ( CreateProcessA(ApplicationName,CommandLine,NULL,NULL,TRUE,CREATE_NEW_CONSOLE|NORMAL_PRIORITY_CLASS,NULL,*envp,&StartupInfo,&ProcessInformation) ) {
+// errno = GetLastError();
+// return -1;
+// }
if (mode == P_OVERLAY)
exit(i);
// _P_NOWAIT or _P_NOWAITO
- return (int)ProcessInformation.hProcess;
+ return ProcessInformation.hProcess;
}
#include <process.h>
-extern char *_environ[];
+extern char **_environ;
-int _spawnvp(int mode, const char *path,const char *const argv[])
+int spawnvp(int mode, const char *path,const char *const argv[])
{
- return _spawnvpe(mode, path, (const char * const *)argv,(const char * const *) _environ);
+ return spawnvpe(mode, path, (char * const *)argv, _environ);
}
#include <errno.h>
-int _spawnvpe(int mode, const char *path,const char *const argv[],const char *const envp[])
+int spawnvpe(int mode, const char *path,const char *const argv[],const char *const envp[])
{
-// djgpp does something like a searchpath here
-
- return _spawnve(mode, path, argv, envp);
+
+ char rpath[300];
+ union {const char * const *cpcp; char **cpp; } u;
+ u.cpcp = envp;
+/*
+ if (!__dosexec_find_on_path(path, u.cpp, rpath))
+ {
+ errno = ENOENT;
+ return -1;
+ }
+ else
+*/
+ return spawnve(mode, rpath, argv, envp);
}
#include <string.h>
#include <stdlib.h>
#include <libc/file.h>
-
+//#include <libc/local.h>
+//#include <libc/stdiohk.h>
FILE * __alloc_file(void);
return 0;
}
-int _dowprnt(const wchar_t *fmt, va_list args, FILE *f)
-{
- return 0;
-}
-
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
+//#include <libc/stubs.h>
#include <stdio.h>
#include <io.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdlib.h>
-
+//#include <unistd.h>
#include <libc/file.h>
+#if 0
+#ifndef __dj_include_stdio_h_
+#define _name_to_remove _tmpfname
+#endif
+#endif
int
fclose(FILE *f)
int _fileno(FILE *f)
{
return f->_file;
-}
\ No newline at end of file
+}
/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
-
+//#include <libc/stubs.h>
#include <stdio.h>
#include <sys/types.h>
#include <stdlib.h>
+//#include <unistd.h>
+//#include <go32.h>
#include <libc/file.h>
#include <io.h>
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
-
+//#include <libc/stubs.h>
#include <sys/types.h>
#include <stdio.h>
#include <io.h>
#include <fcntl.h>
+//#include <unistd.h>
#include <libc/file.h>
-
+//#include <libc/local.h>
+//#include <libc/dosio.h>
FILE * __alloc_file(void);
+extern int _fmode;
FILE *
fopen(const char *file, const char *mode)
len = _doprnt(fmt, (&fmt)+1, iop);
return ferror(iop) ? EOF : len;
}
-
-int
-fwprintf(register FILE *iop, const wchar_t *fmt, ...)
-{
- int len;
- wchar_t localbuf[BUFSIZ];
-
- if (iop->_flag & _IONBF)
- {
- iop->_flag &= ~_IONBF;
- iop->_ptr = iop->_base = localbuf;
- iop->_bufsiz = BUFSIZ;
- len = _dowprnt(fmt, (&fmt)+sizeof(wchar_t), iop);
- fflush(iop);
- iop->_flag |= _IONBF;
- iop->_base = NULL;
- iop->_bufsiz = 0;
- iop->_cnt = 0;
- }
- else
- len = _dowprnt(fmt, (va_list)(&fmt)+sizeof(wchar_t), iop);
- return ferror(iop) ? EOF : len;
-}
return(r);
*/
int r = 0;
- if ( !WriteFile(_get_osfhandle(f->_file),s,strlen(s),&r,NULL) )
+ if ( !WriteFile(filehnd(f->_file),s,strlen(s),&r,NULL) )
return -1;
return r;
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
-
+//#include <libc/stubs.h>
#include <sys/types.h>
#include <stdio.h>
#include <fcntl.h>
+//#include <unistd.h>
#include <libc/file.h>
#include <io.h>
+extern int _fmode;
FILE *
freopen(const char *file, const char *mode, FILE *f)
int r;
va_list a=0;
va_start(a, fmt);
- r = _doscan(f, fmt,(void *) a);
+ r = _doscan(f, fmt, a);
va_end(a);
return r;
}
#include <errno.h>
int
-fsetpos(FILE *stream, fpos_t *pos)
+fsetpos(FILE *stream, const fpos_t *pos)
{
if (stream && pos)
{
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
#include <stdio.h>
-#include <io.h>
#include <windows.h>
#include <libc/file.h>
-
+#undef getc
int getc(FILE *f)
{
int c;
DWORD NumberOfBytesRead;
- if ( !ReadFile(_get_osfhandle(f->_file),&c, 1, &NumberOfBytesRead, NULL) )
+ if ( !ReadFile(filehnd(f->_file),&c, 1, &NumberOfBytesRead, NULL) )
return -1;
if ( NumberOfBytesRead == 0 )
return -1;
if ( GetEnvironmentVariableA(name,buffer,MAX_PATH) == 0 )
return NULL;
return buffer;
-}
\ No newline at end of file
+}
return ferror(stdout) ? EOF : len;
}
-
-int wprintf(const wchar_t *fmt, ...)
-{
- int len;
-
- len = _dowprnt(fmt, (&fmt)+sizeof(wchar_t), stdout);
-
- /* People were confused when printf() didn't flush stdout,
- so we'll do it to reduce confusion */
- if (stdout->_flag & _IOLBF)
- fflush(stdout);
-
- return ferror(stdout) ? EOF : len;
-}
}
return(_flsbuf(c,fp));
}
- if ( !WriteFile(_get_osfhandle(fp->_file),&c,1,&r,NULL) )
+ if ( !WriteFile(filehnd(fp->_file),&c,1,&r,NULL) )
return -1;
return r;
return putchar('\n');
*/
int r = 0;
- if ( !WriteFile(_get_osfhandle(stdout->_file),s,strlen(s),&r,NULL) )
+ if ( !WriteFile(filehnd(stdout->_file),s,strlen(s),&r,NULL) )
return -1;
return putchar('\n');;
#include <windows.h>
-#include <io.h>
int remove(const char *fn)
{
#include <stdio.h>
#include <io.h>
-
-
int rename(const char *old, const char *new)
+{
+ return _rename(old,new);
+}
+
+int _rename(const char *old, const char *new)
{
if ( !MoveFile(old,new) )
return -1;
*_strbuf._ptr = 0;
return len;
}
-
-swprintf(wchar_t *str, const wchar_t *fmt, ...)
-{
- FILE _strbuf;
- int len;
-
- _strbuf._flag = _IOWRT|_IOSTRG;
- _strbuf._ptr = str;
- _strbuf._cnt = INT_MAX;
- len = _dowprnt(fmt,(va_list) &(fmt)+sizeof(wchar_t), &_strbuf);
- *_strbuf._ptr = 0;
- return len;
-}
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
#include <stdio.h>
#include <libc/file.h>
+//#include <libc/stdiohk.h>
TempFileName
);
return TempFileName;
-}
\ No newline at end of file
+}
/* Copyright (C) 1997 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
-
+//#include <libc/stubs.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <fcntl.h>
+//#include <unistd.h>
#include <io.h>
#include <libc/file.h>
#include <share.h>
+#if 0
+#ifndef __dj_include_stdio_h_
+#define _name_to_remove _tmpfname
+#endif
+#endif
FILE * __alloc_file(void);
len = _doprnt(fmt, ap, f);
return (ferror(f) ? EOF : len);
}
-
-int vfwprintf(FILE *f, const wchar_t *fmt, va_list ap)
-{
- int len;
- wchar_t localbuf[BUFSIZ];
-
- if (f->_flag & _IONBF)
- {
- f->_flag &= ~_IONBF;
- f->_ptr = f->_base = localbuf;
- f->_bufsiz = BUFSIZ;
- len = _dowprnt(fmt, ap, f);
- (void)fflush(f);
- f->_flag |= _IONBF;
- f->_base = NULL;
- f->_bufsiz = 0;
- f->_cnt = 0;
- }
- else
- len = _dowprnt(fmt, ap, f);
- return (ferror(f) ? EOF : len);
-}
len = _doprnt(fmt, ap, stdout);
return (ferror(stdout) ? EOF : len);
}
-
-int
-vwprintf(const wchar_t *fmt, va_list ap)
-{
- int len;
-
- len = _dowprnt(fmt, ap, stdout);
- return (ferror(stdout) ? EOF : len);
-}
\ No newline at end of file
*f._ptr = 0;
return len;
}
-
-vswprintf(wchar_t *str, const wchar_t *fmt, va_list ap)
-{
- FILE f;
- int len;
-
- f._flag = _IOWRT|_IOSTRG;
- f._ptr = str;
- f._cnt = INT_MAX;
- len = _dowprnt(fmt, ap, &f);
- *f._ptr = 0;
- return len;
-}
\ No newline at end of file
#include <fcntl.h>
#include <libc/atexit.h>
+void _exit(int _status);
struct __atexit *__atexit_ptr = 0;
void _exit(int _status)
{
- ExitProcess(_status);
+ //ExitProcess(_status);
}
void _cexit( void )
static char msg[] = "Abort!\r\n";
void
-abort(void)
+abort()
{
_write(stderr->_file, msg, sizeof(msg)-1);
_exit(1);
#include <stdlib.h>
int
-abs(int _i)
+abs(int j)
{
- return _i<0 ? -_i : _i;
+ return j<0 ? -j : j;
}
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
#include <stdlib.h>
-#include <string.h>
long double
_atold(const char *ascii)
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
#include <stdlib.h>
-#include <libc/unconst.h>
+// #include <libc/unconst.h>
void *
-bsearch(const void *key, const void *base0, size_t nelem,
+bsearch(const void *key, const void *base, size_t nelem,
size_t size, int (*cmp)(const void *ck, const void *ce))
{
- char *base = unconst(base0, char *);
int lim, cmpval;
void *p;
-/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
-#include <windows.h>
#include <errno.h>
-#undef _doserrno
-int _doserrno;
-
#undef errno
-unsigned int errno;
+int errno;
+#undef _doserrno
+int _doserrno;
int *_errno(void)
{
-
return &errno;
}
#include <stdlib.h>
#include <windows.h>
+#undef fullpath
+char *fullpath( char *absPath, const char *relPath, size_t maxLength )
+{
+ return _fullpath(absPath,relPath,maxLength );
+}
char *_fullpath( char *absPath, const char *relPath, size_t maxLength )
{
+
+
char *lpFilePart;
if ( GetFullPathName(relPath,maxLength,absPath,&lpFilePart) == 0 )
return NULL;
}
-}
\ No newline at end of file
+}
#include <windows.h>
#include <stdlib.h>
-//#include <ddk/ntddk.h>
+//#include <types.h>
+#include <ddk/ntddk.h>
void* malloc(size_t _size)
{
- return(HeapAlloc(GetProcessHeap(),0,_size));
+ return(HeapAlloc(GetProcessHeap(),
+ 0,
+ _size));
}
void free(void* _ptr)
{
- HeapFree(GetProcessHeap(),0,_ptr);
+ HeapFree(GetProcessHeap(),
+ 0,
+ _ptr);
}
void* calloc(size_t _nmemb, size_t _size)
{
- return(HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,_nmemb*_size));
+ return(HeapAlloc(GetProcessHeap(),
+ HEAP_ZERO_MEMORY,
+ _nmemb*_size));
}
void* realloc(void* _ptr, size_t _size)
{
- return(HeapReAlloc(GetProcessHeap(),0, _ptr, _size));
+ return(HeapReAlloc(GetProcessHeap(),
+ 0,
+ _ptr,
+ _size));
}
#include <string.h>
+
int
-_putenv(const char *val)
+putenv(const char *val)
{
char buffer[1024];
*/
void
-qsort(const void *base0, size_t n, size_t size, _pfunccmp_t compar)
+qsort(void *base0, size_t n, size_t size, int (*compar)(const void *, const void *))
{
char *base = (char *)base0;
char c, *i, *j, *lo, *hi;
}
return;
-}
\ No newline at end of file
+}
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
#include <math.h>
#include <stdlib.h>
-#include <wchar.h>
+
double
strtod(const char *s, char **sret)
*sret = (char *)s;
return r * sign;
}
-
-
-double
-wcstod(const wchar_t *s, wchar_t **sret)
-{
- long double r; /* result */
- int e; /* exponent */
- long double d; /* scale */
- int sign; /* +- 1.0 */
- int esign;
- int i;
- int flags=0;
-
- r = 0.0;
- sign = 1;
- e = 0;
- esign = 1;
-
- while ((*s == ' ') || (*s == '\t'))
- s++;
-
- if (*s == '+')
- s++;
- else if (*s == '-')
- {
- sign = -1;
- s++;
- }
-
- while ((*s >= '0') && (*s <= '9'))
- {
- flags |= 1;
- r *= 10.0;
- r += *s - '0';
- s++;
- }
-
- if (*s == '.')
- {
- d = 0.1L;
- s++;
- while ((*s >= '0') && (*s <= '9'))
- {
- flags |= 2;
- r += d * (*s - '0');
- s++;
- d *= 0.1L;
- }
- }
-
- if (flags == 0)
- {
- if (sret)
- *sret = (wchar_t *)s;
- return 0;
- }
-
- if ((*s == 'e') || (*s == 'E'))
- {
- s++;
- if (*s == '+')
- s++;
- else if (*s == '-')
- {
- s++;
- esign = -1;
- }
- if ((*s < '0') || (*s > '9'))
- {
- if (sret)
- *sret = (wchar_t *)s;
- return r;
- }
-
- while ((*s >= '0') && (*s <= '9'))
- {
- e *= 10;
- e += *s - '0';
- s++;
- }
- }
-
- if (esign < 0)
- for (i = 1; i <= e; i++)
- r *= 0.1L;
- else
- for (i = 1; i <= e; i++)
- r *= 10.0;
-
- if (sret)
- *sret = (wchar_t *)s;
- return r * sign;
-}
-
#include <ctype.h>
#include <errno.h>
#include <stdlib.h>
-#include <wchar.h>
long
if (any < 0)
{
acc = neg ? LONG_MIN : LONG_MAX;
-// errno = ERANGE;
+ errno = ERANGE;
}
else if (neg)
acc = -acc;
*endptr = any ? (char *)s - 1 : (char *)nptr;
return acc;
}
-
-
-long
-wcstol(const wchar_t *nptr, wchar_t **endptr, int base)
-{
- const wchar_t *s = nptr;
- unsigned long acc;
- int c;
- unsigned long cutoff;
- int neg = 0, any, cutlim;
-
- /*
- * Skip white space and pick up leading +/- sign if any.
- * If base is 0, allow 0x for hex and 0 for octal, else
- * assume decimal; if base is already 16, allow 0x.
- */
- do {
- c = *s++;
- } while (isspace(c));
- if (c == '-')
- {
- neg = 1;
- c = *s++;
- }
- else if (c == '+')
- c = *s++;
- if ((base == 0 || base == 16) &&
- c == '0' && (*s == 'x' || *s == 'X'))
- {
- c = s[1];
- s += 2;
- base = 16;
- }
- if (base == 0)
- base = c == '0' ? 8 : 10;
-
- /*
- * Compute the cutoff value between legal numbers and illegal
- * numbers. That is the largest legal value, divided by the
- * base. An input number that is greater than this value, if
- * followed by a legal input character, is too big. One that
- * is equal to this value may be valid or not; the limit
- * between valid and invalid numbers is then based on the last
- * digit. For instance, if the range for longs is
- * [-2147483648..2147483647] and the input base is 10,
- * cutoff will be set to 214748364 and cutlim to either
- * 7 (neg==0) or 8 (neg==1), meaning that if we have accumulated
- * a value > 214748364, or equal but the next digit is > 7 (or 8),
- * the number is too big, and we will return a range error.
- *
- * Set any if any `digits' consumed; make it negative to indicate
- * overflow.
- */
- cutoff = neg ? -(unsigned long)LONG_MIN : LONG_MAX;
- cutlim = cutoff % (unsigned long)base;
- cutoff /= (unsigned long)base;
- for (acc = 0, any = 0;; c = *s++)
- {
- if (isdigit(c))
- c -= '0';
- else if (isalpha(c))
- c -= isupper(c) ? 'A' - 10 : 'a' - 10;
- else
- break;
- if (c >= base)
- break;
- if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim))
- any = -1;
- else
- {
- any = 1;
- acc *= base;
- acc += c;
- }
- }
- if (any < 0)
- {
- acc = neg ? LONG_MIN : LONG_MAX;
- // errno = ERANGE;
- }
- else if (neg)
- acc = -acc;
- if (endptr != 0)
- *endptr = any ? (wchar_t *)s - 1 : (wchar_t *)nptr;
- return acc;
-}
-
#include <ctype.h>
#include <errno.h>
#include <stdlib.h>
-#include <wchar.h>
+#include <libc/unconst.h>
/*
* Convert a string to an unsigned long integer.
if (any < 0)
{
acc = ULONG_MAX;
- // errno = ERANGE;
+ errno = ERANGE;
}
else if (neg)
acc = -acc;
if (endptr != 0)
- *endptr = any ? (char *)s - 1 : (char *)nptr;
+ *endptr = any ? unconst(s, char *) - 1 : unconst(nptr, char *);
return acc;
}
-
-unsigned long
-wcstoul(const wchar_t *nptr, wchar_t **endptr, int base)
-{
- const wchar_t *s = nptr;
- unsigned long acc;
- int c;
- unsigned long cutoff;
- int neg = 0, any, cutlim;
-
- /*
- * See strtol for comments as to the logic used.
- */
- do {
- c = *s++;
- } while (isspace(c));
- if (c == '-')
- {
- neg = 1;
- c = *s++;
- }
- else if (c == '+')
- c = *s++;
- if ((base == 0 || base == 16) &&
- c == '0' && (*s == 'x' || *s == 'X'))
- {
- c = s[1];
- s += 2;
- base = 16;
- }
- if (base == 0)
- base = c == '0' ? 8 : 10;
- cutoff = (unsigned long)ULONG_MAX / (unsigned long)base;
- cutlim = (unsigned long)ULONG_MAX % (unsigned long)base;
- for (acc = 0, any = 0;; c = *s++)
- {
- if (isdigit(c))
- c -= '0';
- else if (isalpha(c))
- c -= isupper(c) ? 'A' - 10 : 'a' - 10;
- else
- break;
- if (c >= base)
- break;
- if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim))
- any = -1;
- else {
- any = 1;
- acc *= base;
- acc += c;
- }
- }
- if (any < 0)
- {
- acc = ULONG_MAX;
- // errno = ERANGE;
- }
- else if (neg)
- acc = -acc;
- if (endptr != 0)
- *endptr = any ? (wchar_t *)s - 1 : (wchar_t *)nptr;
- return acc;
-}
-
return dest;
-}
\ No newline at end of file
+}
count--;
}
return src;
-}
\ No newline at end of file
+}
#include <string.h>
#include <stdlib.h>
#include <errno.h>
+//#include <libc/unconst.h>
char __syserr00[] = "No Error";
y++;
}
return x;
-}
\ No newline at end of file
+}
if (endp)
*endp = (char *)cp;
return result;
-}
\ No newline at end of file
+}
return -1;
}
- if ( !GetFileInformationByHandle(_get_osfhandle(handle),&FileInformation) )
+ if ( !GetFileInformationByHandle(filehnd(handle),&FileInformation) )
return -1;
statbuf->st_ctime = FileTimeToUnixTime( &FileInformation.ftCreationTime,NULL);
statbuf->st_atime = FileTimeToUnixTime( &FileInformation.ftLastAccessTime,NULL);
return ret;
-}
\ No newline at end of file
+}
*/
-
+#ifndef _TM_DEFINED
+struct tm {
+ int tm_sec;
+ int tm_min;
+ int tm_hour;
+ int tm_mday;
+ int tm_mon;
+ int tm_year;
+ int tm_wday;
+ int tm_yday;
+ int tm_isdst;
+ char *tm_zone;
+ int tm_gmtoff;
+};
+#define _TM_DEFINED
+#endif
//#include <libc/stubs.h>
#include <fcntl.h>
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
#include <string.h>
+#ifndef _TM_DEFINED
+struct tm {
+ int tm_sec;
+ int tm_min;
+ int tm_hour;
+ int tm_mday;
+ int tm_mon;
+ int tm_year;
+ int tm_wday;
+ int tm_yday;
+ int tm_isdst;
+ char *tm_zone;
+ int tm_gmtoff;
+};
+#define _TM_DEFINED
+#endif
+
#include <time.h>
#define TM_YEAR_BASE 1900
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
-
+#ifndef _TM_DEFINED
+struct tm {
+ int tm_sec;
+ int tm_min;
+ int tm_hour;
+ int tm_mday;
+ int tm_mon;
+ int tm_year;
+ int tm_wday;
+ int tm_yday;
+ int tm_isdst;
+ char *tm_zone;
+ int tm_gmtoff;
+};
+#define _TM_DEFINED
+#endif
#include <time.h>
#include <windows.h>
{
SYSTEMTIME SystemTime;
GetLocalTime(&SystemTime);
-
+
+
}
}
return *cs - *ct;
-}
\ No newline at end of file
+}
{
/* FIXME: handle collates */
return wcscmp(a1,a2);
-}
\ No newline at end of file
+}
for (; (*str1 = *str2); ++str2, ++str1);
return save;
-}
\ No newline at end of file
+}
s++;
} while (*s);
return s-str; /* nr of wchars */
-}
\ No newline at end of file
+}
}
return towlower(*cs) - towlower(*ct);
-}
\ No newline at end of file
+}
y++;
}
return x;
-}
\ No newline at end of file
+}
if (ch == 0)
sp = (wchar_t *)str;
return sp;
-}
\ No newline at end of file
+}
e--;
}
return s;
-}
\ No newline at end of file
+}
s++;
} while (*s);
return s-str; /* nr of wchars */
-}
\ No newline at end of file
+}
x++;
}
return NULL;
-}
\ No newline at end of file
+}
}
/* NOTREACHED */
-}
\ No newline at end of file
+}
{
lstrcpynWtoA( dst, src, len );
return strlen(dst); /* FIXME: is this right? */
-}
\ No newline at end of file
+}
--- /dev/null
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS system libraries
+ * FILE: lib/kernel32/file/copy.c
+ * PURPOSE: Copying files
+ * PROGRAMMER: Ariadne ( ariadne@xs4all.nl)
+ * UPDATE HISTORY:
+ * 01/11/98 Created
+ * 07/02/99 Moved to seperate file
+ */
+
+/* INCLUDES ****************************************************************/
+
+#include <windows.h>
+#include <ddk/ntddk.h>
+#include <wchar.h>
+#include <string.h>
+
+#define NDEBUG
+#include <kernel32/kernel32.h>
+
+#define LPPROGRESS_ROUTINE void*
+
+/* FUNCTIONS ****************************************************************/
+
+WINBOOL STDCALL CopyFileExW(LPCWSTR lpExistingFileName,
+ LPCWSTR lpNewFileName,
+ LPPROGRESS_ROUTINE lpProgressRoutine,
+ LPVOID lpData,
+ WINBOOL * pbCancel,
+ DWORD dwCopyFlags)
+{
+ NTSTATUS errCode = 0;
+ HANDLE FileHandleSource, FileHandleDest;
+ IO_STATUS_BLOCK IoStatusBlock;
+ FILE_STANDARD_INFORMATION FileStandard;
+ FILE_BASIC_INFORMATION FileBasic;
+ FILE_POSITION_INFORMATION FilePosition;
+ UCHAR *lpBuffer = NULL;
+ ULONG RegionSize = 0x1000000;
+ BOOL bCancel = FALSE;
+
+ FileHandleSource = CreateFileW(lpExistingFileName,
+ GENERIC_READ,
+ FILE_SHARE_READ,
+ NULL,
+ OPEN_EXISTING,
+ FILE_ATTRIBUTE_NORMAL|FILE_FLAG_NO_BUFFERING,
+ NULL);
+ if (FileHandleSource == NULL)
+ {
+ return(FALSE);
+ }
+
+ errCode = NtQueryInformationFile(FileHandleSource,
+ &IoStatusBlock,
+ &FileStandard,
+ sizeof(FILE_STANDARD_INFORMATION),
+ FileStandardInformation);
+ if (!NT_SUCCESS(errCode))
+ {
+ NtClose(FileHandleSource);
+ SetLastError(RtlNtStatusToDosError(errCode));
+ return FALSE;
+ }
+
+ errCode = NtQueryInformationFile(FileHandleSource,
+ &IoStatusBlock,&FileBasic,
+ sizeof(FILE_BASIC_INFORMATION),
+ FileBasicInformation);
+ if (!NT_SUCCESS(errCode))
+ {
+ NtClose(FileHandleSource);
+ SetLastError(RtlNtStatusToDosError(errCode));
+ return FALSE;
+ }
+
+ FileHandleDest = CreateFileW(lpNewFileName,
+ GENERIC_WRITE,
+ FILE_SHARE_WRITE,
+ NULL,
+ dwCopyFlags ? CREATE_NEW : CREATE_ALWAYS ,
+ FileBasic.FileAttributes|FILE_FLAG_NO_BUFFERING,
+ NULL);
+ if (FileHandleDest == NULL)
+ {
+ return(FALSE);
+ }
+
+ SET_LARGE_INTEGER_LOW_PART(FilePosition.CurrentByteOffset, 0);
+ SET_LARGE_INTEGER_HIGH_PART(FilePosition.CurrentByteOffset, 0);
+
+ errCode = NtSetInformationFile(FileHandleSource,
+ &IoStatusBlock,
+ &FilePosition,
+ sizeof(FILE_POSITION_INFORMATION),
+ FilePositionInformation);
+ if (!NT_SUCCESS(errCode))
+ {
+ NtClose(FileHandleSource);
+ NtClose(FileHandleDest);
+ SetLastError(RtlNtStatusToDosError(errCode));
+ return FALSE;
+ }
+
+ errCode = NtSetInformationFile(FileHandleDest,
+ &IoStatusBlock,
+ &FilePosition,
+ sizeof(FILE_POSITION_INFORMATION),
+ FilePositionInformation);
+ if (!NT_SUCCESS(errCode))
+ {
+ NtClose(FileHandleSource);
+ NtClose(FileHandleDest);
+ SetLastError(RtlNtStatusToDosError(errCode));
+ return FALSE;
+ }
+
+ errCode = NtAllocateVirtualMemory(NtCurrentProcess(),
+ (PVOID *)&lpBuffer,
+ 2,
+ &RegionSize,
+ MEM_COMMIT,
+ PAGE_READWRITE);
+
+ if (!NT_SUCCESS(errCode))
+ {
+ NtClose(FileHandleSource);
+ NtClose(FileHandleDest);
+ SetLastError(RtlNtStatusToDosError(errCode));
+ return FALSE;
+ }
+
+ do {
+ errCode = NtReadFile(FileHandleSource,
+ NULL,
+ NULL,
+ NULL,
+ (PIO_STATUS_BLOCK)&IoStatusBlock,
+ lpBuffer,
+ RegionSize,
+ NULL,
+ NULL);
+ if (pbCancel != NULL)
+ bCancel = *pbCancel;
+
+ if (!NT_SUCCESS(errCode) || bCancel)
+ {
+ NtFreeVirtualMemory(NtCurrentProcess(),
+ (PVOID *)&lpBuffer, &RegionSize,MEM_RELEASE);
+ NtClose(FileHandleSource);
+ NtClose(FileHandleDest);
+ if ( errCode == STATUS_END_OF_FILE )
+ break;
+ else
+ return FALSE;
+ }
+
+ errCode = NtWriteFile(FileHandleDest,
+ NULL,
+ lpProgressRoutine,
+ lpData,
+ (PIO_STATUS_BLOCK)&IoStatusBlock,
+ lpBuffer,
+ RegionSize,
+ NULL,
+ NULL);
+
+ if (!NT_SUCCESS(errCode))
+ {
+ NtFreeVirtualMemory(NtCurrentProcess(),
+ (PVOID *)&lpBuffer,
+ &RegionSize,
+ MEM_RELEASE);
+ NtClose(FileHandleSource);
+ NtClose(FileHandleDest);
+ return FALSE;
+ }
+
+ } while ( TRUE );
+ return TRUE;
+}
+
+WINBOOL STDCALL CopyFileExA(LPCSTR lpExistingFileName,
+ LPCSTR lpNewFileName,
+ LPPROGRESS_ROUTINE lpProgressRoutine,
+ LPVOID lpData,
+ WINBOOL* pbCancel,
+ DWORD dwCopyFlags)
+{
+ ULONG i;
+ WCHAR ExistingFileNameW[MAX_PATH];
+ WCHAR NewFileNameW[MAX_PATH];
+
+ if (!KERNEL32_AnsiToUnicode(ExistingFileNameW,
+ lpExistingFileName,
+ MAX_PATH))
+ {
+ return(FALSE);
+ }
+ if (!KERNEL32_AnsiToUnicode(NewFileNameW,
+ lpNewFileName,
+ MAX_PATH))
+ {
+ return(FALSE);
+ }
+ return(CopyFileExW(ExistingFileNameW,
+ NewFileNameW,
+ lpProgressRoutine,
+ lpData,
+ pbCancel,
+ dwCopyFlags));
+}
+
+
+WINBOOL STDCALL CopyFileA(LPCSTR lpExistingFileName,
+ LPCSTR lpNewFileName,
+ WINBOOL bFailIfExists)
+{
+ return CopyFileExA(lpExistingFileName,
+ lpNewFileName,
+ NULL,
+ NULL,
+ FALSE,
+ bFailIfExists);
+}
+WINBOOL STDCALL CopyFileW(LPCWSTR lpExistingFileName,
+ LPCWSTR lpNewFileName,
+ WINBOOL bFailIfExists)
+{
+ return CopyFileExW(lpExistingFileName,
+ lpNewFileName,
+ NULL,
+ NULL,
+ NULL,
+ bFailIfExists);
+}
#include <windows.h>
#include <ddk/ntddk.h>
-#include <wstring.h>
+#include <wchar.h>
#include <string.h>
-#include <ddk/li.h>
-#include <ddk/rtl.h>
//#define NDEBUG
#include <kernel32/kernel32.h>
+/* EXTERNS ******************************************************************/
+
+DWORD STDCALL GetCurrentDriveW(DWORD nBufferLength, PWSTR lpBuffer);
+
/* FUNCTIONS ****************************************************************/
HANDLE STDCALL CreateFileA(LPCSTR lpFileName,
Flags |= FILE_SYNCHRONOUS_IO_ALERT;
}
- if ( lpFileName[0] == L'\\' || lpFileName[1] == L':')
+ if (lpFileName[1] == (WCHAR)':')
+ {
+ wcscpy(PathNameW, lpFileName);
+ }
+ else if (wcslen(lpFileName) > 4 &&
+ lpFileName[0] == (WCHAR)'\\' &&
+ lpFileName[1] == (WCHAR)'\\' &&
+ lpFileName[2] == (WCHAR)'.' &&
+ lpFileName[3] == (WCHAR)'\\')
+ {
+ wcscpy(PathNameW, lpFileName);
+ }
+ else if (lpFileName[0] == (WCHAR)'\\')
{
- wcscpy(PathNameW,lpFileName);
+ GetCurrentDriveW(MAX_PATH,PathNameW);
+ wcscat(PathNameW, lpFileName);
}
- else
+ else
{
Len = GetCurrentDirectoryW(MAX_PATH,PathNameW);
if ( Len == 0 )
WINBOOL STDCALL SetCurrentDirectoryW(LPCWSTR lpPathName);
/* FUNCTIONS *****************************************************************/
-
+
+DWORD STDCALL GetCurrentDriveW(DWORD nBufferLength, PWSTR lpBuffer)
+{
+ lpBuffer[0] = 'A' + CurrentDrive;
+ lpBuffer[1] = ':';
+ lpBuffer[2] = '\\';
+ lpBuffer[3] = 0;
+ return(4);
+}
+
DWORD STDCALL GetCurrentDirectoryA(DWORD nBufferLength, LPSTR lpBuffer)
{
UINT uSize,i;
{
lpBuffer[0] = 'A' + CurrentDrive;
lpBuffer[1] = ':';
+ lpBuffer[2] = 0;
lstrcpyW(&lpBuffer[2], DriveDirectoryW[CurrentDrive]);
}
- DPRINT("GetCurrentDirectoryW() = %w\n",lpBuffer);
+ DPRINT("GetCurrentDirectoryW() = '%w'\n",lpBuffer);
return uSize;
}
HANDLE hDir;
PWSTR prev, current;
- DPRINT("SetCurrentDirectoryW(lpPathName %w\n",lpPathName);
+ DPRINT("SetCurrentDirectoryW(lpPathName %w)\n",lpPathName);
if (lpPathName == NULL)
return FALSE;
}
hCurrentDirectory = hDir;
- if (isalpha(lpPathName[0]) && lpPathName[1] == ':' )
+ DPRINT("lpPathName %w %x\n",lpPathName,lpPathName);
+ if (wcslen(lpPathName) > 2 &&
+ isalpha(lpPathName[0]) &&
+ lpPathName[1] == ':' )
{
DPRINT("lpPathName %w\n",lpPathName);
#include <windows.h>
#include <ddk/ntddk.h>
#include <string.h>
-#include <wstring.h>
+#include <wchar.h>
#define NDEBUG
#include <kernel32/kernel32.h>
LPSECURITY_ATTRIBUTES lpSecurityAttributes)
{
WCHAR TemplateDirectoryW[MAX_PATH];
- PWCHAR pTemplateDirectoryW;
WCHAR NewDirectoryW[MAX_PATH];
ULONG i;
i = 0;
- if(lpTemplateDirectory)
- {
while ((*lpTemplateDirectory)!=0 && i < MAX_PATH)
{
TemplateDirectoryW[i] = *lpTemplateDirectory;
i++;
}
TemplateDirectoryW[i] = 0;
- pTemplateDirectoryW=TemplateDirectoryW;
- }
- else pTemplateDirectoryW=NULL;
i = 0;
- while ((*lpNewDirectory)!=0 && i < MAX_PATH-1)
+ while ((*lpNewDirectory)!=0 && i < MAX_PATH)
{
NewDirectoryW[i] = *lpNewDirectory;
lpNewDirectory++;
OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING DirectoryNameString;
IO_STATUS_BLOCK IoStatusBlock;
- WCHAR FileNameW[MAX_PATH];
if ( lpTemplateDirectory != NULL )
{
return(FALSE);
}
- FileNameW[0] = '\\';
- FileNameW[1] = '?';
- FileNameW[2] = '?';
- FileNameW[3] = '\\';
- FileNameW[4] = 0;
- wcscat(FileNameW,lpNewDirectory);
- DirectoryNameString.Length = lstrlenW(FileNameW)*sizeof(WCHAR);
- DirectoryNameString.Buffer = (WCHAR *)FileNameW;
+ DirectoryNameString.Length = lstrlenW(lpNewDirectory)*sizeof(WCHAR);
+ DirectoryNameString.Buffer = (WCHAR *)lpNewDirectory;
DirectoryNameString.MaximumLength = DirectoryNameString.Length+sizeof(WCHAR);
ObjectAttributes.Length = sizeof(OBJECT_ATTRIBUTES);
&ObjectAttributes,
&IoStatusBlock,
NULL,
- FILE_ATTRIBUTE_NORMAL,
+ FILE_ATTRIBUTE_DIRECTORY,
0,
FILE_CREATE,
- FILE_DIRECTORY_FILE,
+ 0,
NULL,
0);
/* FIXME: the large integer manipulations in this file dont handle overflow */
-#undef WIN32_LEAN_AND_MEAN
+/* INCLUDES ****************************************************************/
+
#include <windows.h>
#include <ddk/ntddk.h>
-#include <wstring.h>
+#include <wchar.h>
#include <string.h>
-#include <ddk/li.h>
-#include <ddk/rtl.h>
#define NDEBUG
#include <kernel32/kernel32.h>
#define LPPROGRESS_ROUTINE void*
+/* GLOBALS ******************************************************************/
+static BOOLEAN bIsFileApiAnsi; // set the file api to ansi or oem
+/* FUNCTIONS ****************************************************************/
-WINBOOL
-CopyFileExW(
- LPCWSTR lpExistingFileName,
- LPCWSTR lpNewFileName,
- LPPROGRESS_ROUTINE lpProgressRoutine,
- LPVOID lpData,
- WINBOOL * pbCancel,
- DWORD dwCopyFlags
- );
-
-WINBOOL
-CopyFileExA(
- LPCSTR lpExistingFileName,
- LPCSTR lpNewFileName,
- LPPROGRESS_ROUTINE lpProgressRoutine,
- LPVOID lpData,
- WINBOOL * pbCancel,
- DWORD dwCopyFlags
- );
-
-
-
-BOOLEAN bIsFileApiAnsi; // set the file api to ansi or oem
-
-
-
-VOID
-STDCALL
-SetFileApisToOEM(VOID)
+VOID STDCALL SetFileApisToOEM(VOID)
{
- bIsFileApiAnsi = FALSE;
- return;
+ bIsFileApiAnsi = FALSE;
}
-WINBASEAPI
-VOID
-WINAPI
-SetFileApisToANSI(VOID)
+WINBASEAPI VOID WINAPI SetFileApisToANSI(VOID)
{
- bIsFileApiAnsi = TRUE;
- return;
+ bIsFileApiAnsi = TRUE;
}
-
-
-WINBOOL
-STDCALL
-AreFileApisANSI(VOID)
+WINBOOL STDCALL AreFileApisANSI(VOID)
{
- return bIsFileApiAnsi;
-
+ return(bIsFileApiAnsi);
}
-
-
-
WINBOOL STDCALL WriteFile(HANDLE hFile,
LPCVOID lpBuffer,
DWORD nNumberOfBytesToWrite,
LPOVERLAPPED lpOverLapped)
{
- LARGE_INTEGER Offset,*pOffset;
+ LARGE_INTEGER Offset;
HANDLE hEvent = NULL;
NTSTATUS errCode;
PIO_STATUS_BLOCK IoStatusBlock;
lpOverLapped->Internal = STATUS_PENDING;
hEvent= lpOverLapped->hEvent;
IoStatusBlock = (PIO_STATUS_BLOCK)lpOverLapped;
- pOffset=&Offset;
}
else
{
IoStatusBlock = &IIosb;
- pOffset = NULL;
+ Offset = NULL;
}
errCode = NtWriteFile(hFile,
hEvent,
IoStatusBlock,
(PVOID)lpBuffer,
nNumberOfBytesToWrite,
- pOffset,
+ &Offset,
NULL);
if (!NT_SUCCESS(errCode))
{
return(TRUE);
}
-WINBOOL STDCALL ReadFile(HANDLE hFile,
- LPVOID lpBuffer,
- DWORD nNumberOfBytesToRead,
- LPDWORD lpNumberOfBytesRead,
- LPOVERLAPPED lpOverLapped)
+WINBOOL STDCALL KERNEL32_ReadFile(HANDLE hFile,
+ LPVOID lpBuffer,
+ DWORD nNumberOfBytesToRead,
+ LPDWORD lpNumberOfBytesRead,
+ LPOVERLAPPED lpOverLapped,
+ LPOVERLAPPED_COMPLETION_ROUTINE
+ lpCompletionRoutine)
{
-
HANDLE hEvent = NULL;
- PLARGE_INTEGER Offset;
- LARGE_INTEGER ByteOffset;
+ LARGE_INTEGER Offset;
NTSTATUS errCode;
- PIO_STATUS_BLOCK IoStatusBlock;
IO_STATUS_BLOCK IIosb;
-
- if (lpOverLapped != NULL)
+ PIO_STATUS_BLOCK IoStatusBlock;
+ PLARGE_INTEGER ptrOffset;
+
+ if (lpOverLapped != NULL)
{
- SET_LARGE_INTEGER_LOW_PART(ByteOffset, lpOverLapped->Offset);
- SET_LARGE_INTEGER_HIGH_PART(ByteOffset, lpOverLapped->OffsetHigh);
- Offset = &ByteOffset;
+ SET_LARGE_INTEGER_LOW_PART(Offset, lpOverLapped->Offset);
+ SET_LARGE_INTEGER_HIGH_PART(Offset, lpOverLapped->OffsetHigh);
lpOverLapped->Internal = STATUS_PENDING;
hEvent = lpOverLapped->hEvent;
IoStatusBlock = (PIO_STATUS_BLOCK)lpOverLapped;
+ ptrOffset = &Offset;
}
- else
+ else
{
+ ptrOffset = NULL;
IoStatusBlock = &IIosb;
- Offset = NULL;
}
-
+
errCode = NtReadFile(hFile,
hEvent,
- NULL,
+ (PIO_APC_ROUTINE)lpCompletionRoutine,
NULL,
IoStatusBlock,
lpBuffer,
nNumberOfBytesToRead,
- Offset,
+ ptrOffset,
NULL);
- if ( !NT_SUCCESS(errCode) )
- {
- SetLastError(RtlNtStatusToDosError(errCode));
- return FALSE;
+ if (errCode != STATUS_PENDING && lpNumberOfBytesRead != NULL)
+ {
+ *lpNumberOfBytesRead = IoStatusBlock->Information;
}
-
- if (lpNumberOfBytesRead != NULL )
+
+ if (!NT_SUCCESS(errCode))
{
- *lpNumberOfBytesRead = IoStatusBlock->Information;
+ SetLastError(RtlNtStatusToDosError(errCode));
+ return(FALSE);
}
-
- return TRUE;
+ return(TRUE);
}
-WINBOOL
-STDCALL
-ReadFileEx(
- HANDLE hFile,
- LPVOID lpBuffer,
- DWORD nNumberOfBytesToRead,
- LPOVERLAPPED lpOverLapped,
- LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine
- )
+WINBOOL STDCALL ReadFile(HANDLE hFile,
+ LPVOID lpBuffer,
+ DWORD nNumberOfBytesToRead,
+ LPDWORD lpNumberOfBytesRead,
+ LPOVERLAPPED lpOverLapped)
{
- HANDLE hEvent = NULL;
- LARGE_INTEGER Offset;
- NTSTATUS errCode;
- IO_STATUS_BLOCK IIosb;
- PIO_STATUS_BLOCK IoStatusBlock;
-
-
- if ( lpOverLapped != NULL ) {
- SET_LARGE_INTEGER_LOW_PART(Offset, lpOverLapped->Offset);
- SET_LARGE_INTEGER_HIGH_PART(Offset, lpOverLapped->OffsetHigh);
- lpOverLapped->Internal = STATUS_PENDING;
- hEvent = lpOverLapped->hEvent;
- IoStatusBlock = (PIO_STATUS_BLOCK)lpOverLapped;
- }
- else {
- SET_LARGE_INTEGER_LOW_PART(Offset, 0);
- SET_LARGE_INTEGER_HIGH_PART(Offset, 0);
- IoStatusBlock = &IIosb;
- }
-
-
-
-
- errCode = NtReadFile(hFile,
- hEvent,
- (PIO_APC_ROUTINE)lpCompletionRoutine,
- NULL,
- IoStatusBlock,
- lpBuffer,
- nNumberOfBytesToRead,
- &Offset,
- NULL);
- if ( !NT_SUCCESS(errCode) ) {
- SetLastError(RtlNtStatusToDosError(errCode));
- return FALSE;
- }
-
+ return(KERNEL32_ReadFile(hFile,
+ lpBuffer,
+ nNumberOfBytesToRead,
+ lpNumberOfBytesRead,
+ lpOverLapped,
+ NULL));
+}
- return TRUE;
+WINBOOL STDCALL ReadFileEx(HANDLE hFile,
+ LPVOID lpBuffer,
+ DWORD nNumberOfBytesToRead,
+ LPOVERLAPPED lpOverLapped,
+ LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
+{
+ return(KERNEL32_ReadFile(hFile,
+ lpBuffer,
+ nNumberOfBytesToRead,
+ NULL,
+ lpOverLapped,
+ lpCompletionRoutine));
}
-
-WINBOOL
-STDCALL
-CopyFileA(
- LPCSTR lpExistingFileName,
- LPCSTR lpNewFileName,
- WINBOOL bFailIfExists
- )
-{
- return CopyFileExA(lpExistingFileName,lpNewFileName,NULL,NULL,FALSE,bFailIfExists);
-}
-
-WINBOOL
-STDCALL
-CopyFileExA(
- LPCSTR lpExistingFileName,
- LPCSTR lpNewFileName,
- LPPROGRESS_ROUTINE lpProgressRoutine,
- LPVOID lpData,
- WINBOOL * pbCancel,
- DWORD dwCopyFlags
- )
-{
- ULONG i;
- WCHAR ExistingFileNameW[MAX_PATH];
- WCHAR NewFileNameW[MAX_PATH];
-
-
-
- i = 0;
- while ((*lpExistingFileName)!=0 && i < MAX_PATH)
- {
- ExistingFileNameW[i] = *lpExistingFileName;
- lpExistingFileName++;
- i++;
- }
- ExistingFileNameW[i] = 0;
-
- i = 0;
- while ((*lpNewFileName)!=0 && i < MAX_PATH)
- {
- NewFileNameW[i] = *lpNewFileName;
- lpNewFileName++;
- i++;
- }
- NewFileNameW[i] = 0;
-
- return CopyFileExW(ExistingFileNameW,NewFileNameW,lpProgressRoutine,lpData,pbCancel,dwCopyFlags);
-}
-
-
-WINBOOL
-STDCALL
-CopyFileW(
- LPCWSTR lpExistingFileName,
- LPCWSTR lpNewFileName,
- WINBOOL bFailIfExists
- )
-{
- return CopyFileExW(lpExistingFileName,lpNewFileName,NULL,NULL,NULL,bFailIfExists);
-}
-
-
-
-
-
-WINBOOL
-STDCALL
-CopyFileExW(
- LPCWSTR lpExistingFileName,
- LPCWSTR lpNewFileName,
- LPPROGRESS_ROUTINE lpProgressRoutine,
- LPVOID lpData,
- WINBOOL * pbCancel,
- DWORD dwCopyFlags
- )
-{
-
- NTSTATUS errCode = 0;
- HANDLE FileHandleSource, FileHandleDest;
- IO_STATUS_BLOCK IoStatusBlock;
-
- FILE_STANDARD_INFORMATION FileStandard;
- FILE_BASIC_INFORMATION FileBasic;
- FILE_POSITION_INFORMATION FilePosition;
-
- UCHAR *lpBuffer = NULL;
-
-
-
- ULONG RegionSize = 0x1000000;
-
- BOOL bCancel = FALSE;
-
-
-
- FileHandleSource = CreateFileW(
- lpExistingFileName,
- GENERIC_READ,
- FILE_SHARE_READ,
- NULL,
- OPEN_EXISTING,
- FILE_ATTRIBUTE_NORMAL|FILE_FLAG_NO_BUFFERING,
- NULL
- );
-
-
-
- if ( !NT_SUCCESS(errCode) ) {
- SetLastError(RtlNtStatusToDosError(errCode));
- return FALSE;
- }
-
-
- errCode = NtQueryInformationFile(FileHandleSource,
- &IoStatusBlock,&FileStandard, sizeof(FILE_STANDARD_INFORMATION),
- FileStandardInformation);
- if ( !NT_SUCCESS(errCode) ) {
- NtClose(FileHandleSource);
- SetLastError(RtlNtStatusToDosError(errCode));
- return FALSE;
- }
-
- errCode = NtQueryInformationFile(FileHandleSource,
- &IoStatusBlock,&FileBasic, sizeof(FILE_BASIC_INFORMATION),
- FileBasicInformation);
- if ( !NT_SUCCESS(errCode) ) {
- NtClose(FileHandleSource);
- SetLastError(RtlNtStatusToDosError(errCode));
- return FALSE;
- }
-
-
-
-
-
-
- FileHandleDest = CreateFileW(
- lpNewFileName,
- GENERIC_WRITE,
- FILE_SHARE_WRITE,
- NULL,
- dwCopyFlags ? CREATE_NEW : CREATE_ALWAYS ,
- FileBasic.FileAttributes|FILE_FLAG_NO_BUFFERING,
- NULL
- );
-
- if ( !NT_SUCCESS(errCode) ) {
- NtClose(FileHandleSource);
- SetLastError(RtlNtStatusToDosError(errCode));
- return FALSE;
- }
-
-
-
-
- SET_LARGE_INTEGER_LOW_PART(FilePosition.CurrentByteOffset, 0);
- SET_LARGE_INTEGER_HIGH_PART(FilePosition.CurrentByteOffset, 0);
-
- errCode = NtSetInformationFile(FileHandleSource,
- &IoStatusBlock,&FilePosition, sizeof(FILE_POSITION_INFORMATION),
- FilePositionInformation);
- if ( !NT_SUCCESS(errCode) ) {
- NtClose(FileHandleSource);
- NtClose(FileHandleDest);
- SetLastError(RtlNtStatusToDosError(errCode));
- return FALSE;
- }
-
- errCode = NtSetInformationFile(FileHandleDest,
- &IoStatusBlock,&FilePosition, sizeof(FILE_POSITION_INFORMATION),
- FilePositionInformation);
-
- if ( !NT_SUCCESS(errCode) ) {
- NtClose(FileHandleSource);
- NtClose(FileHandleDest);
- SetLastError(RtlNtStatusToDosError(errCode));
- return FALSE;
- }
-
-
-
- errCode = NtAllocateVirtualMemory(
- NtCurrentProcess(),
- (PVOID *)&lpBuffer,
- 2,
- &RegionSize,
- MEM_COMMIT,
- PAGE_READWRITE
- );
-
- if ( !NT_SUCCESS(errCode) ) {
- NtClose(FileHandleSource);
- NtClose(FileHandleDest);
- SetLastError(RtlNtStatusToDosError(errCode));
- return FALSE;
- }
-
-
-
-
-
-
- do {
-
- errCode = NtReadFile(
- FileHandleSource,
- NULL,
- NULL,
- NULL,
- (PIO_STATUS_BLOCK)&IoStatusBlock,
- lpBuffer,
- RegionSize,
- NULL,
- NULL);
- if ( pbCancel != NULL )
- bCancel = *pbCancel;
-
-
- if ( !NT_SUCCESS(errCode) || bCancel ) {
- NtFreeVirtualMemory(NtCurrentProcess(),(PVOID *)&lpBuffer, &RegionSize,MEM_RELEASE);
- NtClose(FileHandleSource);
- NtClose(FileHandleDest);
- if ( errCode == STATUS_END_OF_FILE )
- break;
- else
- return FALSE;
-
- }
-
- errCode = NtWriteFile(FileHandleDest,
- NULL,
- lpProgressRoutine,
- lpData,
- (PIO_STATUS_BLOCK)&IoStatusBlock,
- lpBuffer,
- RegionSize,
- NULL,
- NULL);
-
-
-
- if ( !NT_SUCCESS(errCode) ) {
- NtFreeVirtualMemory(NtCurrentProcess(),(PVOID *)&lpBuffer, &RegionSize,MEM_RELEASE);
- NtClose(FileHandleSource);
- NtClose(FileHandleDest);
- return FALSE;
- }
-
- } while ( TRUE );
-
- return TRUE;
-
-
-}
-
-
HFILE
STDCALL
OpenFile(
}
-WINBOOL
-STDCALL
-SetFileAttributesA(
- LPCSTR lpFileName,
- DWORD dwFileAttributes
- )
+WINBOOL STDCALL SetFileAttributesA(LPCSTR lpFileName,
+ DWORD dwFileAttributes)
{
ULONG i;
WCHAR FileNameW[MAX_PATH];
}
-WINBOOL
-STDCALL
-SetFileAttributesW(
- LPCWSTR lpFileName,
- DWORD dwFileAttributes
- )
+WINBOOL STDCALL SetFileAttributesW(LPCWSTR lpFileName,
+ DWORD dwFileAttributes)
{
- IO_STATUS_BLOCK IoStatusBlock;
- FILE_BASIC_INFORMATION FileBasic;
- HANDLE hFile;
- NTSTATUS errCode;
-
-
- hFile = CreateFileW(
- lpFileName,
- GENERIC_READ,
- FILE_SHARE_READ,
- NULL,
- OPEN_EXISTING,
- FILE_ATTRIBUTE_NORMAL,
- NULL
- );
-
-
- errCode = NtQueryInformationFile(hFile,&IoStatusBlock,&FileBasic, sizeof(FILE_BASIC_INFORMATION),FileBasicInformation);
- if ( !NT_SUCCESS(errCode) ) {
- CloseHandle(hFile);
- SetLastError(RtlNtStatusToDosError(errCode));
- return FALSE;
- }
- FileBasic.FileAttributes = dwFileAttributes;
- errCode = NtSetInformationFile(hFile,&IoStatusBlock,&FileBasic, sizeof(FILE_BASIC_INFORMATION),FileBasicInformation);
- if ( !NT_SUCCESS(errCode) ) {
- CloseHandle(hFile);
- SetLastError(RtlNtStatusToDosError(errCode));
- return FALSE;
- }
+ IO_STATUS_BLOCK IoStatusBlock;
+ FILE_BASIC_INFORMATION FileBasic;
+ HANDLE hFile;
+ NTSTATUS errCode;
+
+ hFile = CreateFileW(lpFileName,
+ FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES,
+ FILE_SHARE_READ,
+ NULL,
+ OPEN_EXISTING,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL);
+
+ errCode = NtQueryInformationFile(hFile,
+ &IoStatusBlock,
+ &FileBasic,
+ sizeof(FILE_BASIC_INFORMATION),
+ FileBasicInformation);
+ if (!NT_SUCCESS(errCode))
+ {
CloseHandle(hFile);
- return TRUE;
-
+ SetLastError(RtlNtStatusToDosError(errCode));
+ return FALSE;
+ }
+ FileBasic.FileAttributes = dwFileAttributes;
+ errCode = NtSetInformationFile(hFile,
+ &IoStatusBlock,
+ &FileBasic,
+ sizeof(FILE_BASIC_INFORMATION),
+ FileBasicInformation);
+ if (!NT_SUCCESS(errCode))
+ {
+ CloseHandle(hFile);
+ SetLastError(RtlNtStatusToDosError(errCode));
+ return FALSE;
+ }
+ CloseHandle(hFile);
+ return TRUE;
}
/* INCLUDES *****************************************************************/
#include <windows.h>
-#include <wstring.h>
+#include <wchar.h>
#include <ddk/ntddk.h>
#define NDEBUG
{
int i;
lpFindFileData->dwFileAttributes = IData->FileInfo.FileAttributes;
- memcpy(&lpFindFileData->ftCreationTime,&IData->FileInfo.CreationTime,sizeof(FILETIME));
- memcpy(&lpFindFileData->ftLastAccessTime,&IData->FileInfo.LastAccessTime,sizeof(FILETIME));
- memcpy(&lpFindFileData->ftLastWriteTime,&IData->FileInfo.LastWriteTime,sizeof(FILETIME));
+// memcpy(&lpFindFileData->ftCreationTime,&IData->FileInfo.CreationTime,sizeof(FILETIME));
+// memcpy(&lpFindFileData->ftLastAccessTime,&IData->FileInfo.LastAccessTime,sizeof(FILETIME));
+// memcpy(&lpFindFileData->ftLastWriteTime,&IData->FileInfo.LastWriteTime,sizeof(FILETIME));
lpFindFileData->nFileSizeHigh = IData->FileInfo.EndOfFile>>32;
lpFindFileData->nFileSizeLow = IData->FileInfo.EndOfFile;
+++ /dev/null
-/*
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS system libraries
- * FILE: lib/kernel32/file/find.c
- * PURPOSE: Find functions
- * PROGRAMMER: Ariadne ( ariadne@xs4all.nl)
- * UPDATE HISTORY:
- * Created 01/11/98
- */
-
-/* INCLUDES *****************************************************************/
-
-#include <windows.h>
-#include <wstring.h>
-#include <ddk/ntddk.h>
-
-/* TYPES ********************************************************************/
-
-typedef struct _KERNEL32_FIND_FILE_DATA;
-{
- HANDLE DirectoryHandle;
- FILE_DIRECTORY_INFORMATION FileInfo;
-} KERNEL32_FIND_FILE_DATA, *PKERNEL32_FIND_FILE_DATA;
-
-/* FUNCTIONS *****************************************************************/
-
-HANDLE FindFirstFileA(LPCTSTR lpFileName, LPWIN32_FIND_DATA lpFindFileData)
-{
- WCHAR lpFileNameW[MAX_PATH];
- ULONG i;
-
- i = 0;
- while (lpFileName[i]!=0)
- {
- lpFileName[i] = lpFileName[i];
- i++;
- }
-
- return(FindFirstFileW(lpFileName,lpFindFileData));
-}
-
-BOOLEAN FindNextFileA(HANDLE hFindFile, LPWIN32_FIND_DATA lpFindFileData)
-{
- return(FindNextFileW(hFindFile, lpFindFileData));
-}
-
-BOOL FindClose(HANDLE hFindFile)
-{
- PKERNEL32_FIND_FILE_DATA IData;
-
- IData = (PKERNEL32_FIND_FILE_DATA)hFindFile;
- NtClose(IData->DirectoryHandle);
- HeapFree(IData);
-}
-
-HANDLE STDCALL FindFirstFileW(LPCWSTR lpFileName,
- LPWIN32_FIND_DATA lpFindFileData)
-{
- WCHAR CurrentDirectory[MAX_PATH];
- WCHAR Pattern[MAX_PATH];
- WCHAR Directory[MAX_PATH];
- PWSTR End;
- PKERNEL32_FIND_FILE_DATA IData;
- OBJECT_ATTRIBUTES ObjectAttributes;
- UNICODE_STRING DirectoryNameStr;
- IO_STATUS_BLOCK IoStatusBlock;
-
- dprintf("FindFirstFileW(lpFileName %w, lpFindFileData %x)\n",
- lpFileName, lpFindFileData);
-
- GetCurrentDirectoryW(MAX_PATH, CurrentDirectory);
- Directory[0] = '\\';
- Directory[1] = '?';
- Directory[2] = '?';
- Directory[3] = '\\';
- Directory[4] = 0;
- wstrcat(Directory, CurrentDirectory);
- wstrcat(Directory, lpFileName);
- End = wstrchr(Directory, '\\');
- *End = 0;
-
- wstrcpy(Pattern, End+1);
-
- dprintf("Directory %w End %w\n",Directory,End);
-
- IData = HeapAlloc(GetProcessHeap(),
- HEAP_ZERO_MEMORY,
- sizeof(KERNEL32_FIND_FILE_DATA));
-
- RtlInitUnicodeString(&DirectoryNameStr, Directory);
- InitializeObjectAttributes(&ObjectAttributes,
- &DirectoryNameStr,
- 0,
- NULL,
- NULL);
-
- if (ZwOpenFile(&IData->DirectoryHandle,
- FILE_TRAVERSE,
- &ObjectAttributes,
- 0,
- OPEN_EXISTING)!=STATUS_SUCCESS)
- {
- return(NULL);
- }
-
- NtQueryDirectoryFile(IData->DirectoryHandle,
- NULL,
- NULL,
- NULL,
- &IoStatusBlock,
- &IData->FileInfo,
- sizeof(IData->FileInfo),
- FileDirectoryInformation,
- TRUE,
- Pattern,
- FALSE);
-
- return(IData);
-}
-
-WINBOOL STDCALL FindNextFileW(HANDLE hFindFile,
- LPWIN32_FIND_DATA lpFindFileData)
-{
-}
#include <windows.h>
#include <ddk/ntddk.h>
-#include <wstring.h>
-#include <ddk/rtl.h>
+#include <wchar.h>
typedef struct _FILE_COMPLETION_INFORMATION {
#undef WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <string.h>
-#include <wstring.h>
+#include <wchar.h>
* Copyright 1996 Alexandre Julliard
*/
-#undef WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <ddk/ntddk.h>
-#include <wstring.h>
+#include <wchar.h>
#include <string.h>
-#include <ddk/li.h>
#define MAX_DOS_DRIVES 26
VOID STDCALL OutputDebugStringA(LPCSTR lpOutputString)
{
- NtDisplayString(lpOutputString);
- #if 0
- WCHAR DebugStringW[161];
- int i,j;
- i = 0;
+ WCHAR DebugStringW[161];
+ int i,j;
+ i = 0;
+ j = 0;
+ while ( lpOutputString[i] != 0 )
+ {
+ while ( j < 160 && lpOutputString[i] != 0 )
+ {
+ DebugStringW[j] = (WCHAR)lpOutputString[i];
+ i++;
+ j++;
+ }
+ DebugStringW[j] = 0;
+ OutputDebugStringW(DebugStringW);
j = 0;
- while ( lpOutputString[i] != 0 )
- {
- while ( j < 160 && lpOutputString[i] != 0 )
- {
- DebugStringW[j] = (WCHAR)lpOutputString[i];
- i++;
- j++;
- }
- DebugStringW[j] = 0;
- OutputDebugStringW(DebugStringW);
- j = 0;
- }
-
- return;
- #endif
+ }
+ return;
}
-VOID
-STDCALL
-OutputDebugStringW(
- LPCWSTR lpOutputString
- )
+VOID STDCALL OutputDebugStringW(LPCWSTR lpOutputString)
{
UNICODE_STRING UnicodeOutput;
va_start(va_args,fmt);
vsprintf(buffer,fmt,va_args);
- OutputDebugString(buffer);
+ OutputDebugStringA(buffer);
va_end(fmt);
}
#include <ddk/ntddk.h>
#include <stdarg.h>
-VOID KERNEL32_Init(PWSTR Args)
+#include <kernel32/kernel32.h>
+
+VOID WINAPI __HeapInit(LPVOID base, ULONG minsize, ULONG maxsize);
+
+VOID KERNEL32_Init()
{
- InitializePeb(Args);
+ DPRINT("KERNEL32_Init()\n");
__HeapInit(0, 4*1024*1024, 4*1024*1024);
}
--- /dev/null
+#include <windows.h>
+#include <ddk/ntddk.h>
+#include <stdarg.h>
+
+BOOL KERNEL32_AnsiToUnicode(PWSTR DestStr,
+ LPCSTR SrcStr,
+ ULONG MaxLen)
+{
+ ULONG i=0;
+
+ while (SrcStr[i] != 0 && i < MaxLen)
+ {
+ DestStr[i] = (WCHAR)SrcStr[i];
+ i++;
+ }
+ if (i == MaxLen && SrcStr[i] != 0)
+ {
+ return(FALSE);
+ }
+ return(TRUE);
+}
FILE_OBJECTS = file/file.o file/curdir.o file/lfile.o file/dir.o \
file/iocompl.o file/volume.o file/deviceio.o file/dosdev.o \
- file/create.o file/find.o
+ file/create.o file/find.o file/copy.o
MEM_OBJECTS = mem/virtual.o mem/heap.o mem/utils.o
+NLS_OBJECTS = # nls/mbtowc.o nls/wctomb.o
+
THREAD_OBJECTS = thread/thread.o
PROCESS_OBJECTS = process/proc.o process/cmdline.o
STRING_OBJECTS = string/lstring.o
-INTERNAL_OBJECTS = internal/dprintf.o internal/init.o
+INTERNAL_OBJECTS = internal/dprintf.o internal/init.o internal/string.o
EXCEPT_OBJECTS = except/except.o
OBJECTS = $(MISC_OBJECTS) $(FILE_OBJECTS) $(THREAD_OBJECTS) \
- $(PROCESS_OBJECTS) $(STRING_OBJECTS) $(MEM_OBJECTS) \
+ $(PROCESS_OBJECTS) $(STRING_OBJECTS) $(MEM_OBJECTS) $(NLS_OBJECTS) \
$(INTERNAL_OBJECTS) $(SYNCH_OBJECTS) $(EXCEPT_OBJECTS)
#include <kernel32/proc.h>
#include <kernel32/heap.h>
-#include <internal/string.h>
+#include <string.h>
#include <ddk/ntddk.h>
* Created 01/11/98
*/
-#include <kernel32\atom.h>
-#include <kernel32\proc.h>
-#include <kernel32\thread.h>
-#include <wstring.h>
+#include <kernel32/atom.h>
+#include <kernel32/proc.h>
+#include <kernel32/thread.h>
+#include <wchar.h>
#include <string.h>
//#include <stdlib.h>
AllocConsole( VOID )
{
/* FIXME: add CreateFile error checking */
- StdInput = CreateFile("\\Keyboard",
+ StdInput = CreateFile("\\\\.\\Keyboard",
FILE_GENERIC_READ,
0,
NULL,
0,
NULL);
- StdOutput = CreateFile("\\BlueScreen",
+ StdOutput = CreateFile("\\\\.\\BlueScreen",
FILE_GENERIC_WRITE|FILE_GENERIC_READ,
0,
NULL,
if (!lpConsoleTitle || !nSize) return 0;
nWideTitle = GetConsoleTitleW( (LPWSTR) WideTitle, nWideTitle );
if (!nWideTitle) return 0;
+#if 0
if ( (nWritten = WideCharToMultiByte(
CP_ACP, // ANSI code page
0, // performance and mapping flags
lpConsoleTitle[nWritten] = '\0';
return nWritten;
}
+#endif
return 0;
}
return FALSE;
}
AnsiTitle[nWideTitle] = '\0';
+#if 0
if ( MultiByteToWideChar(
CP_ACP, // ANSI code page
MB_PRECOMPOSED, // character-type options
{
return SetConsoleTitleW( (LPWSTR) WideTitle );
}
+#endif
return FALSE;
}
#include <windows.h>
#include <ddk/ntddk.h>
-#include <wstring.h>
+#include <wchar.h>
#include <kernel32/proc.h>
WINBOOL
#include <windows.h>
#include <ddk/ntddk.h>
-#include <wstring.h>
+#include <wchar.h>
#include <string.h>
#define MAX_ENVIRONMENT_VARS 255
DWORD RtlNtStatusToDosError(NTSTATUS Status)
{
- if (NT_SUCCESS(Status)) return(0);
- else
- {
- // FIXME must return different values
- return 1;
- }
+ return(0);
}
* Created 01/11/98
*/
#include <windows.h>
-#include <ddk\ntddk.h>
+#include <ddk/ntddk.h>
*/
#include <windows.h>
#include <ddk/ntddk.h>
-#include <string.h>
-
-TIME_ZONE_INFORMATION TimeZoneInformation;
typedef struct __DOSTIME
{
#define NSPERSEC 10000000
-
-
#define SECOND 1
#define MINUTE 60*SECOND
#define HOUR 60*MINUTE
-
#define DAY 24*HOUR
#define YEAR (365*DAY)
#define FOURYEAR (4*YEAR+DAY)
#define CENTURY (25*FOURYEAR-DAY)
-#define FOURCENTURY (4*CENTURY+DAY)
-
-
-#define MINUTE60 1
-#define HOUR60 60*MINUTE60
-#define DAY60 24*HOUR60
-#define YEAR60 (365*DAY60)
-#define FOURYEAR60 (4*YEAR60+DAY60)
-#define CENTURY60 (25*FOURYEAR60-DAY60)
-#define FOURCENTURY60 (4*CENTURY60+DAY60)
-
-#ifdef COMPILER_LARGE_INTEGERS
- #define RtlEnlargedUnsignedMultiply(m,n) (LARGE_INTEGER_QUAD_PART(((ULONGLONG)m)*((ULONGLONG)n)))
- #define RtlEnlargedIntegerMultiply(m,n) (LARGE_INTEGER_QUAD_PART(((LONGLONG)m)*((LONGLONG)n)))
- #define RtlLargeIntegerAdd(a1,a2) (LARGE_INTEGER_QUAD_PART(a1) + LARGE_INTEGER_QUAD_PART(a2))
- #define RtlExtendedIntegerMultiply(m1,m2) (LARGE_INTEGER_QUAD_PART(m1) * m2)
- #define RtlLargeIntegerDivide(d1,d2,r1) LARGE_INTEGER_QUAD_PART(d1) / LARGE_INTEGER_QUAD_PART(d2);LARGE_INTEGER_QUAD_PART(*r1) = LARGE_INTEGER_QUAD_PART(d1) % LARGE_INTEGER_QUAD_PART(d2)
-
-#endif
+#define MILLENIUM (100*CENTURY)
+
#define LISECOND RtlEnlargedUnsignedMultiply(SECOND,NSPERSEC)
-#define LIMINUTE RtlEnlargedUnsignedMultiply(MINUTE60,60*NSPERSEC)
-#define LIHOUR RtlEnlargedUnsignedMultiply(HOUR60,60*NSPERSEC)
-#define LIDAY RtlEnlargedUnsignedMultiply(DAY60,60*NSPERSEC)
-#define LIYEAR RtlEnlargedUnsignedMultiply(YEAR60,60*NSPERSEC)
-#define LIFOURYEAR RtlEnlargedUnsignedMultiply(FOURYEAR60,60*NSPERSEC)
-#define LICENTURY RtlEnlargedUnsignedMultiply(CENTURY60,60*NSPERSEC)
-#define LIFOURCENTURY RtlEnlargedUnsignedMultiply(FOURCENTURY60,60*NSPERSEC)
+#define LIMINUTE RtlEnlargedUnsignedMultiply(MINUTE,NSPERSEC)
+#define LIHOUR RtlEnlargedUnsignedMultiply(HOUR,NSPERSEC)
+#define LIDAY RtlEnlargedUnsignedMultiply(DAY,NSPERSEC)
+#define LIYEAR RtlEnlargedUnsignedMultiply(YEAR,NSPERSEC)
+#define LIFOURYEAR RtlEnlargedUnsignedMultiply(FOURYEAR,NSPERSEC)
+#define LICENTURY RtlEnlargedUnsignedMultiply(CENTURY,NSPERSEC)
+#define LIMILLENIUM RtlEnlargedUnsignedMultiply(CENTURY,10*NSPERSEC)
+
+
CONST FILETIME *lpFileTime2
)
{
- LARGE_INTEGER FileTime1, FileTime2;
-
-
-
+
if ( lpFileTime1 == NULL )
return 0;
if ( lpFileTime2 == NULL )
return 0;
-
- memcpy(&FileTime1,lpFileTime1,sizeof(FILETIME));
- memcpy(&FileTime2,lpFileTime2,sizeof(FILETIME));
- if ((GET_LARGE_INTEGER_HIGH_PART((FileTime1))) > (GET_LARGE_INTEGER_HIGH_PART((FileTime2))) )
+ /*
+ if ((GET_LARGE_INTEGER_HIGH_PART(lpFileTime1)) > (GET_LARGE_INTEGER_HIGH_PART(lpFileTime2)) )
return 1;
- else if ((GET_LARGE_INTEGER_HIGH_PART(FileTime1)) < (GET_LARGE_INTEGER_HIGH_PART(FileTime2)))
+ else if ((GET_LARGE_INTEGER_HIGH_PART(lpFileTime1)) < (GET_LARGE_INTEGER_HIGH_PART(lpFileTime2)))
return -1;
- else if ((GET_LARGE_INTEGER_LOW_PART(FileTime1)) > (GET_LARGE_INTEGER_LOW_PART(FileTime2)))
+ else if ((GET_LARGE_INTEGER_LOW_PART(lpFileTime1)) > (GET_LARGE_INTEGER_LOW_PART(lpFileTime2)))
return 1;
- else if ((GET_LARGE_INTEGER_LOW_PART(FileTime1)) < (GET_LARGE_INTEGER_LOW_PART(FileTime2)))
+ else if ((GET_LARGE_INTEGER_LOW_PART(lpFileTime1)) < (GET_LARGE_INTEGER_LOW_PART(lpFileTime2)))
return -1;
else
return 0;
-
+ */
}
VOID
LARGE_INTEGER FileTime;
- LARGE_INTEGER liFourCentury;
- LARGE_INTEGER liRemFourCentury;
+ LARGE_INTEGER dwMillenium;
+ LARGE_INTEGER dwRemMillenium;
- LARGE_INTEGER liCentury;
- LARGE_INTEGER liRemCentury;
+ LARGE_INTEGER dwCentury;
+ LARGE_INTEGER dwRemCentury;
- LARGE_INTEGER liFourYear;
- LARGE_INTEGER liRemFourYear;
+ LARGE_INTEGER dwFourYear;
+ LARGE_INTEGER dwRemFourYear;
- LARGE_INTEGER liYear;
- LARGE_INTEGER liRemYear;
+ LARGE_INTEGER dwYear;
+ LARGE_INTEGER dwRemYear;
- LARGE_INTEGER liDay;
- LARGE_INTEGER liRemDay;
+ LARGE_INTEGER dwDay;
+ LARGE_INTEGER dwRemDay;
- LARGE_INTEGER liHour;
- LARGE_INTEGER liRemHour;
+ LARGE_INTEGER dwHour;
+ LARGE_INTEGER dwRemHour;
- LARGE_INTEGER liMinute;
- LARGE_INTEGER liRemMinute;
+ LARGE_INTEGER dwMinute;
+ LARGE_INTEGER dwRemMinute;
- LARGE_INTEGER liSecond;
- LARGE_INTEGER liRemSecond;
+ LARGE_INTEGER dwSecond;
+ LARGE_INTEGER dwRemSecond;
- LARGE_INTEGER liDayOfWeek;
+ LARGE_INTEGER dwDayOfWeek;
DWORD LeapDay = 0;
memcpy(&FileTime,lpFileTime,sizeof(FILETIME));
- liFourCentury = RtlLargeIntegerDivide(FileTime,LIFOURCENTURY,&liRemFourCentury);
- liCentury = RtlLargeIntegerDivide(liRemFourCentury,LICENTURY,&liRemCentury);
- liFourYear = RtlLargeIntegerDivide(liRemCentury,LIFOURYEAR,&liRemFourYear);
- liYear = RtlLargeIntegerDivide(liRemFourYear,LIYEAR,&liRemYear);
- liDay = RtlLargeIntegerDivide(liRemYear,LIDAY,&liRemDay);
- liHour = RtlLargeIntegerDivide(liRemDay,LIHOUR,&liRemHour);
- liMinute = RtlLargeIntegerDivide(liRemHour,LIMINUTE,&liRemMinute);
- liSecond = RtlLargeIntegerDivide(liRemMinute,LISECOND,&liRemSecond);
+ dwMillenium = RtlLargeIntegerDivide(FileTime,LIMILLENIUM,&dwRemMillenium);
+ dwCentury = RtlLargeIntegerDivide(dwRemMillenium,LICENTURY,&dwRemCentury);
+ dwFourYear = RtlLargeIntegerDivide(dwRemCentury,LIFOURYEAR,&dwRemFourYear);
+ dwYear = RtlLargeIntegerDivide(dwRemFourYear,LIYEAR,&dwRemYear);
+ dwDay = RtlLargeIntegerDivide(dwRemYear,LIDAY,&dwRemDay);
+ dwHour = RtlLargeIntegerDivide(dwRemDay,LIHOUR,&dwRemHour);
+ dwMinute = RtlLargeIntegerDivide(dwRemHour,LIMINUTE,&dwRemMinute);
+ dwSecond = RtlLargeIntegerDivide(dwRemMinute,LISECOND,&dwRemSecond);
- lpSystemTime->wHour= (WORD) GET_LARGE_INTEGER_LOW_PART(liHour);
- lpSystemTime->wMinute= (WORD)GET_LARGE_INTEGER_LOW_PART(liMinute);
- lpSystemTime->wSecond= (WORD)GET_LARGE_INTEGER_LOW_PART(liSecond);
- lpSystemTime->wMilliseconds = (WORD)(GET_LARGE_INTEGER_LOW_PART(liRemSecond)/10000);
+ lpSystemTime->wHour= (WORD) GET_LARGE_INTEGER_LOW_PART(dwHour);
+ lpSystemTime->wMinute= (WORD)GET_LARGE_INTEGER_LOW_PART(dwMinute);
+ lpSystemTime->wSecond= (WORD)GET_LARGE_INTEGER_LOW_PART(dwSecond);
+ lpSystemTime->wMilliseconds = (WORD)(GET_LARGE_INTEGER_LOW_PART(dwRemSecond)/10000);
if ( lpSystemTime->wSecond > 60 ) {
if (lpSystemTime->wHour > 24 ) {
lpSystemTime->wHour-= 24;
- SET_LARGE_INTEGER_LOW_PART(liDay,GET_LARGE_INTEGER_LOW_PART(liDay)+1);
+ SET_LARGE_INTEGER_LOW_PART(dwDay,GET_LARGE_INTEGER_LOW_PART(dwDay)+1);
}
//FIXME since 1972 some years have a leap second [ aprox 15 out of 20 ]
- // printf("400 %d 100 %d 4 %d 1 %d\n",(LONG)GET_LARGE_INTEGER_LOW_PART(liFourCentury) , (LONG)GET_LARGE_INTEGER_LOW_PART(liCentury), (LONG)GET_LARGE_INTEGER_LOW_PART(liFourYear), (LONG)GET_LARGE_INTEGER_LOW_PART(liYear));
// if leap year
- lpSystemTime->wYear= 1601 + 400* (WORD)GET_LARGE_INTEGER_LOW_PART(liFourCentury) + 100 * (WORD)GET_LARGE_INTEGER_LOW_PART(liCentury) + 4*(LONG)GET_LARGE_INTEGER_LOW_PART(liFourYear) + (WORD)GET_LARGE_INTEGER_LOW_PART(liYear);
+ lpSystemTime->wYear= 1601 + 1000* (LONG)GET_LARGE_INTEGER_LOW_PART(dwMillenium) + 100 * (LONG)GET_LARGE_INTEGER_LOW_PART(dwCentury) + 4*(LONG)GET_LARGE_INTEGER_LOW_PART(dwFourYear) + (LONG)GET_LARGE_INTEGER_LOW_PART(dwYear);
if ( (lpSystemTime->wYear % 4 == 0 && lpSystemTime->wYear % 100 != 0) || lpSystemTime->wYear % 400 == 0)
LeapDay = 1;
- if ( GET_LARGE_INTEGER_LOW_PART(liDay) >= 0 && GET_LARGE_INTEGER_LOW_PART(liDay) < 31 ) {
+ if ( GET_LARGE_INTEGER_LOW_PART(dwDay) >= 0 && GET_LARGE_INTEGER_LOW_PART(dwDay) < 31 ) {
lpSystemTime->wMonth = 1;
- lpSystemTime->wDay = GET_LARGE_INTEGER_LOW_PART(liDay) + 1;
+ lpSystemTime->wDay = GET_LARGE_INTEGER_LOW_PART(dwDay) + 1;
}
- else if ( GET_LARGE_INTEGER_LOW_PART(liDay) >= 31 && GET_LARGE_INTEGER_LOW_PART(liDay) < ( 59 + LeapDay )) {
+ else if ( GET_LARGE_INTEGER_LOW_PART(dwDay) >= 31 && GET_LARGE_INTEGER_LOW_PART(dwDay) < ( 59 + LeapDay )) {
lpSystemTime->wMonth = 2;
- lpSystemTime->wDay = GET_LARGE_INTEGER_LOW_PART(liDay) + 1 - 31;
+ lpSystemTime->wDay = GET_LARGE_INTEGER_LOW_PART(dwDay) + 1 - 31;
}
- else if ( GET_LARGE_INTEGER_LOW_PART(liDay) >= ( 59 + LeapDay ) && GET_LARGE_INTEGER_LOW_PART(liDay) < ( 90 + LeapDay ) ) {
+ else if ( GET_LARGE_INTEGER_LOW_PART(dwDay) >= ( 59 + LeapDay ) && GET_LARGE_INTEGER_LOW_PART(dwDay) < ( 90 + LeapDay ) ) {
lpSystemTime->wMonth = 3;
- lpSystemTime->wDay = GET_LARGE_INTEGER_LOW_PART(liDay) + 1 - ( 59 + LeapDay);
+ lpSystemTime->wDay = GET_LARGE_INTEGER_LOW_PART(dwDay) + 1 - ( 59 + LeapDay);
}
- else if ( GET_LARGE_INTEGER_LOW_PART(liDay) >= 90+ LeapDay && GET_LARGE_INTEGER_LOW_PART(liDay) < 120 + LeapDay) {
+ else if ( GET_LARGE_INTEGER_LOW_PART(dwDay) >= 90+ LeapDay && GET_LARGE_INTEGER_LOW_PART(dwDay) < 120 + LeapDay) {
lpSystemTime->wMonth = 4;
- lpSystemTime->wDay = GET_LARGE_INTEGER_LOW_PART(liDay) + 1 - (31 + LeapDay );
+ lpSystemTime->wDay = GET_LARGE_INTEGER_LOW_PART(dwDay) + 1 - (31 + LeapDay );
}
- else if ( GET_LARGE_INTEGER_LOW_PART(liDay) >= 120 + LeapDay && GET_LARGE_INTEGER_LOW_PART(liDay) < 151 + LeapDay ) {
+ else if ( GET_LARGE_INTEGER_LOW_PART(dwDay) >= 120 + LeapDay && GET_LARGE_INTEGER_LOW_PART(dwDay) < 151 + LeapDay ) {
lpSystemTime->wMonth = 5;
- lpSystemTime->wDay = GET_LARGE_INTEGER_LOW_PART(liDay) + 1 - (120 + LeapDay);
+ lpSystemTime->wDay = GET_LARGE_INTEGER_LOW_PART(dwDay) + 1 - (120 + LeapDay);
}
- else if ( GET_LARGE_INTEGER_LOW_PART(liDay) >= ( 151 + LeapDay) && GET_LARGE_INTEGER_LOW_PART(liDay) < ( 181 + LeapDay ) ) {
+ else if ( GET_LARGE_INTEGER_LOW_PART(dwDay) >= ( 151 + LeapDay) && GET_LARGE_INTEGER_LOW_PART(dwDay) < ( 181 + LeapDay ) ) {
lpSystemTime->wMonth = 6;
- lpSystemTime->wDay = GET_LARGE_INTEGER_LOW_PART(liDay) + 1 - ( 151 + LeapDay );
+ lpSystemTime->wDay = GET_LARGE_INTEGER_LOW_PART(dwDay) + 1 - ( 151 + LeapDay );
}
- else if ( GET_LARGE_INTEGER_LOW_PART(liDay) >= ( 181 + LeapDay ) && GET_LARGE_INTEGER_LOW_PART(liDay) < ( 212 + LeapDay ) ) {
+ else if ( GET_LARGE_INTEGER_LOW_PART(dwDay) >= ( 181 + LeapDay ) && GET_LARGE_INTEGER_LOW_PART(dwDay) < ( 212 + LeapDay ) ) {
lpSystemTime->wMonth = 7;
- lpSystemTime->wDay = GET_LARGE_INTEGER_LOW_PART(liDay) + 1 - ( 181 + LeapDay );
+ lpSystemTime->wDay = GET_LARGE_INTEGER_LOW_PART(dwDay) + 1 - ( 181 + LeapDay );
}
- else if ( GET_LARGE_INTEGER_LOW_PART(liDay) >= ( 212 + LeapDay ) && GET_LARGE_INTEGER_LOW_PART(liDay) < ( 243 + LeapDay ) ) {
+ else if ( GET_LARGE_INTEGER_LOW_PART(dwDay) >= ( 212 + LeapDay ) && GET_LARGE_INTEGER_LOW_PART(dwDay) < ( 243 + LeapDay ) ) {
lpSystemTime->wMonth = 8;
- lpSystemTime->wDay = GET_LARGE_INTEGER_LOW_PART(liDay) + 1 - (212 + LeapDay );
+ lpSystemTime->wDay = GET_LARGE_INTEGER_LOW_PART(dwDay) + 1 - (212 + LeapDay );
}
- else if ( GET_LARGE_INTEGER_LOW_PART(liDay) >= ( 243+ LeapDay ) && GET_LARGE_INTEGER_LOW_PART(liDay) < ( 273 + LeapDay ) ) {
+ else if ( GET_LARGE_INTEGER_LOW_PART(dwDay) >= ( 243+ LeapDay ) && GET_LARGE_INTEGER_LOW_PART(dwDay) < ( 273 + LeapDay ) ) {
lpSystemTime->wMonth = 9;
- lpSystemTime->wDay = GET_LARGE_INTEGER_LOW_PART(liDay) + 1 - ( 243 + LeapDay );
+ lpSystemTime->wDay = GET_LARGE_INTEGER_LOW_PART(dwDay) + 1 - ( 243 + LeapDay );
}
- else if ( GET_LARGE_INTEGER_LOW_PART(liDay) >= ( 273 + LeapDay ) && GET_LARGE_INTEGER_LOW_PART(liDay) < ( 304 + LeapDay ) ) {
+ else if ( GET_LARGE_INTEGER_LOW_PART(dwDay) >= ( 273 + LeapDay ) && GET_LARGE_INTEGER_LOW_PART(dwDay) < ( 304 + LeapDay ) ) {
lpSystemTime->wMonth = 10;
- lpSystemTime->wDay = GET_LARGE_INTEGER_LOW_PART(liDay) + 1 - ( 273 + LeapDay);
+ lpSystemTime->wDay = GET_LARGE_INTEGER_LOW_PART(dwDay) + 1 - ( 273 + LeapDay);
}
- else if ( GET_LARGE_INTEGER_LOW_PART(liDay) >= ( 304 + LeapDay ) && GET_LARGE_INTEGER_LOW_PART(liDay) < ( 334 + LeapDay ) ) {
+ else if ( GET_LARGE_INTEGER_LOW_PART(dwDay) >= ( 304 + LeapDay ) && GET_LARGE_INTEGER_LOW_PART(dwDay) < ( 334 + LeapDay ) ) {
lpSystemTime->wMonth = 11;
- lpSystemTime->wDay = GET_LARGE_INTEGER_LOW_PART(liDay) + 1 - ( 304 + LeapDay );
+ lpSystemTime->wDay = GET_LARGE_INTEGER_LOW_PART(dwDay) + 1 - ( 304 + LeapDay );
}
- else if ( GET_LARGE_INTEGER_LOW_PART(liDay) >= ( 334 + LeapDay ) && GET_LARGE_INTEGER_LOW_PART(liDay) < ( 365 + LeapDay )) {
+ else if ( GET_LARGE_INTEGER_LOW_PART(dwDay) >= ( 334 + LeapDay ) && GET_LARGE_INTEGER_LOW_PART(dwDay) < ( 365 + LeapDay )) {
lpSystemTime->wMonth = 12;
- lpSystemTime->wDay = GET_LARGE_INTEGER_LOW_PART(liDay) + 1 - ( 334 + LeapDay );
+ lpSystemTime->wDay = GET_LARGE_INTEGER_LOW_PART(dwDay) + 1 - ( 334 + LeapDay );
}
- liDayOfWeek = RtlLargeIntegerDivide(FileTime,LIDAY,&liRemDay);
- lpSystemTime->wDayOfWeek = 1 + GET_LARGE_INTEGER_LOW_PART(liDayOfWeek) % 7;
+ dwDayOfWeek = RtlLargeIntegerDivide(FileTime,LIDAY,&dwRemDay);
+ lpSystemTime->wDayOfWeek = 1 + GET_LARGE_INTEGER_LOW_PART(dwDayOfWeek) % 7;
LPFILETIME lpLocalFileTime
)
{
- TIME_ZONE_INFORMATION TimeZoneInformation;
- LARGE_INTEGER *FileTime, *LocalFileTime;
-
- if ( lpFileTime == NULL || lpLocalFileTime == NULL )
- return FALSE;
- FileTime = (LARGE_INTEGER *)lpFileTime;
- LocalFileTime = (LARGE_INTEGER *)lpLocalFileTime;
-
- GetTimeZoneInformation(&TimeZoneInformation);
- *LocalFileTime = RtlLargeIntegerAdd(*FileTime,RtlExtendedIntegerMultiply((LIMINUTE),(LONG)-1*TimeZoneInformation.Bias));
-
- return TRUE;
+ // memcpy(lpLocalFileTime,lpFileTime,sizeof(FILETIME));
+
+ return TRUE;
}
WINBOOL
LPFILETIME lpFileTime
)
{
- TIME_ZONE_INFORMATION TimeZoneInformation;
- LARGE_INTEGER *FileTime, *LocalFileTime;
-
- if ( lpFileTime == NULL || lpLocalFileTime == NULL )
- return FALSE;
- FileTime = (LARGE_INTEGER *)lpFileTime;
- LocalFileTime = (LARGE_INTEGER *)lpLocalFileTime;
-
- GetTimeZoneInformation(&TimeZoneInformation);
- *FileTime = RtlLargeIntegerAdd(*LocalFileTime,RtlExtendedIntegerMultiply((LIMINUTE),(LONG)TimeZoneInformation.Bias));
-
- return TRUE;
+
+ return TRUE;
}
VOID
LPSYSTEMTIME lpSystemTime
)
{
-
- FILETIME FileTime;
- FILETIME LocalTime;
- GetSystemTimeAsFileTime(&FileTime);
- FileTimeToLocalFileTime(&FileTime,&LocalTime);
- FileTimeToSystemTime(&LocalTime,lpSystemTime);
-
+ GetSystemTime(lpSystemTime);
return;
}
CONST SYSTEMTIME *lpSystemTime
)
{
- NTSTATUS errCode;
- FILETIME FileTime, LocalTime;
- SystemTimeToFileTime(lpSystemTime,&LocalTime);
- LocalFileTimeToFileTime(&LocalTime,&FileTime);
- errCode = NtSetSystemTime ((LARGE_INTEGER *)&FileTime,(LARGE_INTEGER *)&FileTime);
- if ( !NT_SUCCESS(errCode) )
- return FALSE;
- return TRUE;
-
+ return SetSystemTime(lpSystemTime);
}
-
WINBOOL
STDCALL
SetSystemTime(
LARGE_INTEGER NewSystemTime;
SystemTimeToFileTime(lpSystemTime, (FILETIME *)&NewSystemTime);
- errCode = NtSetSystemTime ((LARGE_INTEGER *)&NewSystemTime,(LARGE_INTEGER *)&NewSystemTime);
+ errCode = NtSetSystemTime (&NewSystemTime,&NewSystemTime);
if ( !NT_SUCCESS(errCode) )
return FALSE;
return TRUE;
}
-
-DWORD
-STDCALL
-GetCurrentTime(VOID)
-{
- return GetTickCount();
-}
-
-DWORD
-STDCALL
-GetTickCount(VOID)
-{
- ULONG UpTime;
- NtGetTickCount(&UpTime);
- return UpTime;
-}
-
-
-
-VOID __InitTimeZoneInformation(VOID)
-{
- TimeZoneInformation.Bias = 60;
- TimeZoneInformation.StandardName[0] = 0;
- TimeZoneInformation.StandardDate.wMonth = 9;
- TimeZoneInformation.StandardDate.wDay = 21;
- TimeZoneInformation.StandardBias = 0;
- TimeZoneInformation.DaylightName[0] = 0;
- TimeZoneInformation.DaylightDate.wMonth = 3;
- TimeZoneInformation.DaylightDate.wDay = 21;
- TimeZoneInformation.DaylightBias = -60;
-
-}
-
-WINBOOL
-STDCALL
-SetTimeZoneInformation(
- CONST TIME_ZONE_INFORMATION *lpTimeZoneInformation
- )
-{
- if ( lpTimeZoneInformation == NULL )
- return FALSE;
- TimeZoneInformation = *lpTimeZoneInformation;
- return TRUE;
-}
-
-
-
+/*
+typedef struct _TIME_ZONE_INFORMATION { // tzi
+ LONG Bias;
+ WCHAR StandardName[ 32 ];
+ SYSTEMTIME StandardDate;
+ LONG StandardBias;
+ WCHAR DaylightName[ 32 ];
+ SYSTEMTIME DaylightDate;
+ LONG DaylightBias;
+} TIME_ZONE_INFORMATION;
+TIME_ZONE_INFORMATION TimeZoneInformation = {60,"CET",;
+
+*/
DWORD
STDCALL
GetTimeZoneInformation(
)
{
// aprintf("GetTimeZoneInformation()\n");
- SYSTEMTIME SystemTime;
- if ( lpTimeZoneInformation == NULL )
- return -1;
+
+ // memset(lpTimeZoneInformation, 0, sizeof(TIME_ZONE_INFORMATION));
-
- *lpTimeZoneInformation = TimeZoneInformation;
-/*
- FIXME I should not recurse
- GetLocalTime(&SystemTime);
- if ( TimeZoneInformation.DaylightDate.wMonth == 0 || TimeZoneInformation.StandardDate.wMonth == 0 )
- return TIME_ZONE_ID_UNKNOWN;
- else if ( ( SystemTime.wMonth > TimeZoneInformation.DaylightDate.wMonth &&
- SystemTime.wDay > TimeZoneInformation.DaylightDate.wDay ) &&
- ( SystemTime.wMonth < TimeZoneInformation.StandardDate.wMonth &&
- SystemTime.wDay < TimeZoneInformation.StandardDate.wDay ) )
- return TIME_ZONE_ID_DAYLIGHT;
- else
- return TIME_ZONE_ID_STANDARD;
- */
return TIME_ZONE_ID_UNKNOWN;
}
-
-WINBOOL
-STDCALL
-SetSystemTimeAdjustment(
- DWORD dwTimeAdjustment,
- WINBOOL bTimeAdjustmentDisabled
- )
+DWORD STDCALL GetCurrentTime(VOID)
{
- return FALSE;
+ return GetTickCount();
}
-
-WINBOOL
+DWORD
STDCALL
-GetSystemTimeAdjustment(
- PDWORD lpTimeAdjustment,
- PDWORD lpTimeIncrement,
- PWINBOOL lpTimeAdjustmentDisabled
- )
+GetTickCount(VOID)
{
- return FALSE;
+ ULONG UpTime;
+ NtGetTickCount(&UpTime);
+ return UpTime;
}
#include <windows.h>
#include <kernel32/proc.h>
#include <kernel32/thread.h>
-#include <wstring.h>
+#include <wchar.h>
#include <string.h>
-#include <ddk/rtl.h>
-#include <ddk/li.h>
/* GLOBALS ******************************************************************/
#include <windows.h>
#include <kernel32/proc.h>
#include <kernel32/thread.h>
-#include <wstring.h>
+#include <wchar.h>
#include <string.h>
-#include <ddk/rtl.h>
-#include <ddk/li.h>
#include <internal/i386/segment.h>
#define NDEBUG
BaseAddress = (PVOID)0x10000;
LARGE_INTEGER_QUAD_PART(SectionOffset) = 0;
- Size = 0x10000;
+ Size = 0x20000;
NtMapViewOfSection(hSection,
hProcess,
&BaseAddress,
* UPDATE HISTORY:
* Created 01/11/98
*/
-#undef WIN32_LEAN_AND_MEAN
+
#include <windows.h>
#include <string.h>
-#include <wstring.h>
+#include <wchar.h>
int
* UPDATE HISTORY:
* Created 01/11/98
*/
-#undef WIN32_LEAN_AND_MEAN
+
#include <windows.h>
#include <ddk/ntddk.h>
-#include <ddk/rtl.h>
-#include <wstring.h>
+#include <wchar.h>
WINBOOL
return FALSE;
}
return TRUE;
-}
\ No newline at end of file
+}
*/
#include <windows.h>
-#include <wstring.h>
+#include <wchar.h>
#include <ddk/ntddk.h>
-#include <ddk/li.h>
HANDLE
STDCALL
+++ /dev/null
-/*
- * main.c
- *
- * Extra startup code for applications which do not have a main function
- * of their own (but do have a WinMain). Generally these are GUI
- * applications, but they don't *have* to be.
- *
- * This code was written to interface with CRTDLL.DLL as supplied with
- * Windows NT and Windows 95, although it could, conceivably, be useful
- * under other circumstances.
- *
- * Contributors:
- * Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
- *
- * THIS SOFTWARE IS NOT COPYRIGHTED
- *
- * This source code is offered for use in the public domain. You may
- * use, modify or distribute it freely.
- *
- * This code is distributed in the hope that it will be useful but
- * WITHOUT ANY WARRANTY. ALL WARRENTIES, EXPRESS OR IMPLIED ARE HEREBY
- * DISCLAMED. This includes but is not limited to warrenties of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#include <stdlib.h>
-#include <process.h>
-#include <windows.h>
-
-#define ISSPACE(a) (a == ' ' || a == '\t')
-
-extern int PASCAL WinMain (HANDLE hInst, HANDLE hPrevInst, LPSTR szCmdLine,
- int nShow);
-
-int
-main (int argc, char* argv[], char* environ[])
-{
- char* szCmd;
- STARTUPINFO startinfo;
- int nRet;
-
- /* Get the command line passed to the process. */
- szCmd = GetCommandLineA();
- GetStartupInfoA(&startinfo);
-
- /* Strip off the name of the application and any leading
- * whitespace. */
- if (szCmd)
- {
- while(ISSPACE(*szCmd))
- {
- szCmd++;
- }
-
- /* On my system I always get the app name enclosed
- * in quotes... */
- if (*szCmd == '\"')
- {
- do
- {
- szCmd++;
- }
- while (*szCmd != '\"' && *szCmd != '\0');
-
- if (*szCmd == '\"')
- {
- szCmd++;
- }
- }
- else
- {
- /* If no quotes then assume first token is program
- * name. */
- while (!ISSPACE(*szCmd) && *szCmd != '\0')
- {
- szCmd++;
- }
- }
-
- while (ISSPACE(*szCmd))
- {
- szCmd++;
- }
- }
-
- nRet = WinMain (GetModuleHandle(NULL), NULL, szCmd,
- (startinfo.dwFlags & STARTF_USESHOWWINDOW) ?
- startinfo.wShowWindow : SW_SHOWDEFAULT);
-
- return nRet;
-}
-
+++ /dev/null
-all: mingw32.a
-
-OBJECTS = main.o
-
-mingw32.a: $(OBJECTS)
- $(AR) vrcs mingw32.a $(OBJECTS)
-
-dummy:
-
-include ../../rules.mak
--- /dev/null
+napi.asm
+ntdll.lib
+base.tmp
+junk.tmp
+ntdll.dll
+temp.exp
EXPORTS
-NtAcceptConnectPort
-NtAccessCheck
-NtAccessCheckAndAuditAlarm
-NtAddAtom
-NtAdjustGroupsToken
-NtAdjustPrivilegesToken
-NtAlertResumeThread
-NtAlertThread
-NtAllocateLocallyUniqueId
-NtAllocateUuids
-NtAllocateVirtualMemory
-NtCallbackReturn
-NtCancelIoFile
-NtCancelTimer
-NtClearEvent
-NtClose
-NtCloseObjectAuditAlarm
-NtCompleteConnectPort
-NtConnectPort
-NtContinue
-NtCreateDirectoryObject
-NtCreateEvent
-NtCreateEventPair
-NtCreateFile
-NtCreateIoCompletion
-NtCreateKey
-NtCreateMailslotFile
-NtCreateMutant
-NtCreateNamedPipeFile
-NtCreatePagingFile
-NtCreatePort
-NtCreateProcess
-NtCreateProfile
-NtCreateSection
-NtCreateSemaphore
-NtCreateSymbolicLinkObject
-NtCreateThread
-NtCreateTimer
-NtCreateToken
-NtDelayExecution
-NtDeleteAtom
-NtDeleteFile
-NtDeleteKey
-NtDeleteObjectAuditAlarm
-NtDeleteValueKey
-NtDeviceIoControlFile
-NtDisplayString
-NtDuplicateObject
-NtDuplicateToken
-NtEnumerateKey
-NtEnumerateValueKey
-NtExtendSection
-NtFindAtom
-NtFlushBuffersFile
-NtFlushInstructionCache
-NtFlushKey
-NtFlushVirtualMemory
-NtFlushWriteBuffer
-NtFreeVirtualMemory
-NtFsControlFile
-NtGetContextThread
-NtGetPlugPlayEvent
-NtGetTickCount
-NtImpersonateClientOfPort
-NtImpersonateThread
-NtInitializeRegistry
-NtListenPort
-NtLoadDriver
-NtLoadKey
-NtLoadKey2
-NtLockFile
-NtLockVirtualMemory
-NtMakeTemporaryObject
-NtMapViewOfSection
-NtNotifyChangeDirectoryFile
-NtNotifyChangeKey
-NtOpenDirectoryObject
-NtOpenEvent
-NtOpenEventPair
-NtOpenFile
-NtOpenIoCompletion
-NtOpenKey
-NtOpenMutant
-NtOpenObjectAuditAlarm
-NtOpenProcess
-NtOpenProcessToken
-NtOpenSection
-NtOpenSemaphore
-NtOpenSymbolicLinkObject
-NtOpenThread
-NtOpenThreadToken
-NtOpenTimer
-NtPlugPlayControl
-NtPrivilegeCheck
-NtPrivilegedServiceAuditAlarm
-NtPrivilegeObjectAuditAlarm
-NtProtectVirtualMemory
-NtPulseEvent
-NtQueryInformationAtom
-NtQueryAttributesFile
-NtQueryDefaultLocale
-NtQueryDirectoryFile
-NtQueryDirectoryObject
-NtQueryEaFile
-NtQueryEvent
-NtQueryFullAttributesFile
-NtQueryInformationFile
-NtQueryIoCompletion
-NtQueryInformationPort
-NtQueryInformationProcess
-NtQueryInformationThread
-NtQueryInformationToken
-NtQueryIntervalProfile
-NtQueryKey
-NtQueryMultipleValueKey
-NtQueryMutant
-NtQueryObject
-NtQueryOleDirectoryFile
-NtQueryPerformanceCounter
-NtQuerySection
-NtQuerySecurityObject
-NtQuerySemaphore
-NtQuerySymbolicLinkObject
-NtQuerySystemEnvironmentValue
-NtQuerySystemInformation
-NtQuerySystemTime
-NtQueryTimer
-NtQueryTimerResolution
-NtQueryValueKey
-NtQueryVirtualMemory
-NtQueryVolumeInformationFile
-NtQueueApcThread
-NtRaiseException
-NtRaiseHardError
-NtReadFile
-NtReadFileScatter
-NtReadRequestData
-NtReadVirtualMemory
-NtRegisterThreadTerminatePort
-NtReleaseMutant
-NtReleaseSemaphore
-NtRemoveIoCompletion
-NtReplaceKey
-NtReplyPort
-NtReplyWaitReceivePort
-NtReplyWaitReplyPort
-NtRequestPort
-NtRequestWaitReplyPort
-NtResetEvent
-NtRestoreKey
-NtResumeThread
-NtSaveKey
-NtSetIoCompletion
-NtSetContextThread
-NtSetDefaultHardErrorPort
-NtSetDefaultLocale
-NtSetEaFile
-NtSetEvent
-NtSetHighEventPair
-NtSetHighWaitLowEventPair
-NtSetInformationFile
-NtSetInformationKey
-NtSetInformationObject
-NtSetInformationProcess
-NtSetInformationThread
-NtSetInformationToken
-NtSetIntervalProfile
-NtSetLdtEntries
-NtSetLowEventPair
-NtSetLowWaitHighEventPair
-NtSetSecurityObject
-NtSetSystemEnvironmentValue
-NtSetSystemInformation
-NtSetSystemPowerState
-NtSetSystemTime
-NtSetTimer
-NtSetTimerResolution
-NtSetValueKey
-NtSetVolumeInformationFile
-NtShutdownSystem
-NtSignalAndWaitForSingleObject
-NtStartProfile
-NtStopProfile
-NtSuspendThread
-NtSystemDebugControl
-NtTerminateProcess
-NtTerminateThread
-NtTestAlert
-NtUnloadDriver
-NtUnloadKey
-NtUnlockFile
-NtUnlockVirtualMemory
-NtUnmapViewOfSection
-NtVdmControl
-NtWaitForMultipleObjects
-NtWaitForSingleObject
-NtWaitHighEventPair
-NtWaitLowEventPair
-NtWriteFile
-NtWriteFileGather
-NtWriteRequestData
-NtWriteVirtualMemory
-NtW32Call
-NtCreateChannel
-NtListenChannel
-NtOpenChannel
-NtReplyWaitSendChannel
-NtSendWaitReplyChannel
-NtSetContextChannel
-NtYieldExecution
-ZwAcceptConnectPort
-ZwAccessCheck
-ZwAccessCheckAndAuditAlarm
-ZwAddAtom
-ZwAdjustGroupsToken
-ZwAdjustPrivilegesToken
-ZwAlertResumeThread
-ZwAlertThread
-ZwAllocateLocallyUniqueId
-ZwAllocateUuids
-ZwAllocateVirtualMemory
-ZwCallbackReturn
-ZwCancelIoFile
-ZwCancelTimer
-ZwClearEvent
-ZwClose
-ZwCloseObjectAuditAlarm
-ZwCompleteConnectPort
-ZwConnectPort
-ZwContinue
-ZwCreateDirectoryObject
-ZwCreateEvent
-ZwCreateEventPair
-ZwCreateFile
-ZwCreateIoCompletion
-ZwCreateKey
-ZwCreateMailslotFile
-ZwCreateMutant
-ZwCreateNamedPipeFile
-ZwCreatePagingFile
-ZwCreatePort
-ZwCreateProcess
-ZwCreateProfile
-ZwCreateSection
-ZwCreateSemaphore
-ZwCreateSymbolicLinkObject
-ZwCreateThread
-ZwCreateTimer
-ZwCreateToken
-ZwDelayExecution
-ZwDeleteAtom
-ZwDeleteFile
-ZwDeleteKey
-ZwDeleteObjectAuditAlarm
-ZwDeleteValueKey
-ZwDeviceIoControlFile
-ZwDisplayString
-ZwDuplicateObject
-ZwDuplicateToken
-ZwEnumerateKey
-ZwEnumerateValueKey
-ZwExtendSection
-ZwFindAtom
-ZwFlushBuffersFile
-ZwFlushInstructionCache
-ZwFlushKey
-ZwFlushVirtualMemory
-ZwFlushWriteBuffer
-ZwFreeVirtualMemory
-ZwFsControlFile
-ZwGetContextThread
-ZwGetPlugPlayEvent
-ZwGetTickCount
-ZwImpersonateClientOfPort
-ZwImpersonateThread
-ZwInitializeRegistry
-ZwListenPort
-ZwLoadDriver
-ZwLoadKey
-ZwLoadKey2
-ZwLockFile
-ZwLockVirtualMemory
-ZwMakeTemporaryObject
-ZwMapViewOfSection
-ZwNotifyChangeDirectoryFile
-ZwNotifyChangeKey
-ZwOpenDirectoryObject
-ZwOpenEvent
-ZwOpenEventPair
-ZwOpenFile
-ZwOpenIoCompletion
-ZwOpenKey
-ZwOpenMutant
-ZwOpenObjectAuditAlarm
-ZwOpenProcess
-ZwOpenProcessToken
-ZwOpenSection
-ZwOpenSemaphore
-ZwOpenSymbolicLinkObject
-ZwOpenThread
-ZwOpenThreadToken
-ZwOpenTimer
-ZwPlugPlayControl
-ZwPrivilegeCheck
-ZwPrivilegedServiceAuditAlarm
-ZwPrivilegeObjectAuditAlarm
-ZwProtectVirtualMemory
-ZwPulseEvent
-ZwQueryInformationAtom
-ZwQueryAttributesFile
-ZwQueryDefaultLocale
-ZwQueryDirectoryFile
-ZwQueryDirectoryObject
-ZwQueryEaFile
-ZwQueryEvent
-ZwQueryFullAttributesFile
-ZwQueryInformationFile
-ZwQueryIoCompletion
-ZwQueryInformationPort
-ZwQueryInformationProcess
-ZwQueryInformationThread
-ZwQueryInformationToken
-ZwQueryIntervalProfile
-ZwQueryKey
-ZwQueryMultipleValueKey
-ZwQueryMutant
-ZwQueryObject
-ZwQueryOleDirectoryFile
-ZwQueryPerformanceCounter
-ZwQuerySection
-ZwQuerySecurityObject
-ZwQuerySemaphore
-ZwQuerySymbolicLinkObject
-ZwQuerySystemEnvironmentValue
-ZwQuerySystemInformation
-ZwQuerySystemTime
-ZwQueryTimer
-ZwQueryTimerResolution
-ZwQueryValueKey
-ZwQueryVirtualMemory
-ZwQueryVolumeInformationFile
-ZwQueueApcThread
-ZwRaiseException
-ZwRaiseHardError
-ZwReadFile
-ZwReadFileScatter
-ZwReadRequestData
-ZwReadVirtualMemory
-ZwRegisterThreadTerminatePort
-ZwReleaseMutant
-ZwReleaseSemaphore
-ZwRemoveIoCompletion
-ZwReplaceKey
-ZwReplyPort
-ZwReplyWaitReceivePort
-ZwReplyWaitReplyPort
-ZwRequestPort
-ZwRequestWaitReplyPort
-ZwResetEvent
-ZwRestoreKey
-ZwResumeThread
-ZwSaveKey
-ZwSetIoCompletion
-ZwSetContextThread
-ZwSetDefaultHardErrorPort
-ZwSetDefaultLocale
-ZwSetEaFile
-ZwSetEvent
-ZwSetHighEventPair
-ZwSetHighWaitLowEventPair
-ZwSetInformationFile
-ZwSetInformationKey
-ZwSetInformationObject
-ZwSetInformationProcess
-ZwSetInformationThread
-ZwSetInformationToken
-ZwSetIntervalProfile
-ZwSetLdtEntries
-ZwSetLowEventPair
-ZwSetLowWaitHighEventPair
-ZwSetSecurityObject
-ZwSetSystemEnvironmentValue
-ZwSetSystemInformation
-ZwSetSystemPowerState
-ZwSetSystemTime
-ZwSetTimer
-ZwSetTimerResolution
-ZwSetValueKey
-ZwSetVolumeInformationFile
-ZwShutdownSystem
-ZwSignalAndWaitForSingleObject
-ZwStartProfile
-ZwStopProfile
-ZwSuspendThread
-ZwSystemDebugControl
-ZwTerminateProcess
-ZwTerminateThread
-ZwTestAlert
-ZwUnloadDriver
-ZwUnloadKey
-ZwUnlockFile
-ZwUnlockVirtualMemory
-ZwUnmapViewOfSection
-ZwVdmControl
-ZwWaitForMultipleObjects
-ZwWaitForSingleObject
-ZwWaitHighEventPair
-ZwWaitLowEventPair
-ZwWriteFile
-ZwWriteFileGather
-ZwWriteRequestData
-ZwWriteVirtualMemory
-ZwW32Call
-ZwCreateChannel
-ZwListenChannel
-ZwOpenChannel
-ZwReplyWaitSendChannel
-ZwSendWaitReplyChannel
-ZwSetContextChannel
-ZwYieldExecution
+InitializeObjectAttributes
+NtAcceptConnectPort@24
+NtAccessCheck@32
+NtAccessCheckAndAuditAlarm@44
+NtAddAtom@8
+NtAdjustGroupsToken@24
+NtAdjustPrivilegesToken@24
+NtAlertResumeThread@8
+NtAlertThread@4
+NtAllocateLocallyUniqueId@4
+NtAllocateUuids@12
+NtAllocateVirtualMemory@24
+NtCallbackReturn@12
+NtCancelIoFile@8
+NtCancelTimer@8
+NtClearEvent@4
+NtClose@4
+NtCloseObjectAuditAlarm@12
+NtCompleteConnectPort@4
+NtConnectPort@32
+NtContinue@8
+NtCreateDirectoryObject@12
+NtCreateEvent@20
+NtCreateEventPair@12
+NtCreateFile@44
+NtCreateIoCompletion@16
+NtCreateKey@28
+NtCreateMailslotFile@32
+NtCreateMutant@16
+NtCreateNamedPipeFile@56
+NtCreatePagingFile@16
+NtCreatePort@20
+NtCreateProcess@32
+NtCreateProfile@36
+NtCreateSection@28
+NtCreateSemaphore@20
+NtCreateSymbolicLinkObject@16
+NtCreateThread@32
+NtCreateTimer@16
+NtCreateToken@52
+NtDelayExecution@8
+NtDeleteAtom@4
+NtDeleteFile@4
+NtDeleteKey@4
+NtDeleteObjectAuditAlarm@12
+NtDeleteValueKey@8
+NtDeviceIoControlFile@40
+NtDisplayString@4
+NtDuplicateObject@28
+NtDuplicateToken@24
+NtEnumerateKey@24
+NtEnumerateValueKey@24
+NtExtendSection@8
+NtFindAtom@8
+NtFlushBuffersFile@8
+NtFlushInstructionCache@12
+NtFlushKey@4
+NtFlushVirtualMemory@16
+NtFlushWriteBuffer@0
+NtFreeVirtualMemory@16
+NtFsControlFile@40
+NtGetContextThread@8
+NtGetPlugPlayEvent@16
+NtGetTickCount@4
+NtImpersonateClientOfPort@8
+NtImpersonateThread@12
+NtInitializeRegistry@4
+NtListenPort@8
+NtLoadDriver@4
+NtLoadKey@8
+NtLoadKey2@12
+NtLockFile@40
+NtLockVirtualMemory@16
+NtMakeTemporaryObject@4
+NtMapViewOfSection@40
+NtNotifyChangeDirectoryFile@36
+NtNotifyChangeKey@40
+NtOpenDirectoryObject@12
+NtOpenEvent@12
+NtOpenEventPair@12
+NtOpenFile@24
+NtOpenIoCompletion@12
+NtOpenKey@12
+NtOpenMutant@12
+NtOpenObjectAuditAlarm@48
+NtOpenProcess@16
+NtOpenProcessToken@12
+NtOpenSection@12
+NtOpenSemaphore@12
+NtOpenSymbolicLinkObject@12
+NtOpenThread@16
+NtOpenThreadToken@16
+NtOpenTimer@12
+NtPlugPlayControl@16
+NtPrivilegeCheck@12
+NtPrivilegedServiceAuditAlarm@20
+NtPrivilegeObjectAuditAlarm@24
+NtProtectVirtualMemory@20
+NtPulseEvent@8
+NtQueryInformationAtom@20
+NtQueryAttributesFile@8
+NtQueryDefaultLocale@8
+NtQueryDirectoryFile@44
+NtQueryDirectoryObject@28
+NtQueryEaFile@36
+NtQueryEvent@20
+NtQueryFullAttributesFile@8
+NtQueryInformationFile@20
+NtQueryIoCompletion@20
+NtQueryInformationPort@20
+NtQueryInformationProcess@20
+NtQueryInformationThread@20
+NtQueryInformationToken@20
+NtQueryIntervalProfile@8
+NtQueryKey@20
+NtQueryMultipleValueKey@24
+NtQueryMutant@20
+NtQueryObject@20
+NtQueryOleDirectoryFile@44
+NtQueryPerformanceCounter@8
+NtQuerySection@20
+NtQuerySecurityObject@20
+NtQuerySemaphore@20
+NtQuerySymbolicLinkObject@12
+NtQuerySystemEnvironmentValue@16
+NtQuerySystemInformation@16
+NtQuerySystemTime@4
+NtQueryTimer@20
+NtQueryTimerResolution@12
+NtQueryValueKey@24
+NtQueryVirtualMemory@24
+NtQueryVolumeInformationFile@20
+NtQueueApcThread@20
+NtRaiseException@12
+NtRaiseHardError@24
+NtReadFile@36
+NtReadFileScatter@36
+NtReadRequestData@24
+NtReadVirtualMemory@20
+NtRegisterThreadTerminatePort@4
+NtReleaseMutant@8
+NtReleaseSemaphore@12
+NtRemoveIoCompletion@20
+NtReplaceKey@12
+NtReplyPort@8
+NtReplyWaitReceivePort@16
+NtReplyWaitReplyPort@8
+NtRequestPort@8
+NtRequestWaitReplyPort@12
+NtResetEvent@8
+NtRestoreKey@12
+NtResumeThread@8
+NtSaveKey@8
+NtSetIoCompletion@20
+NtSetContextThread@8
+NtSetDefaultHardErrorPort@4
+NtSetDefaultLocale@8
+NtSetEaFile@16
+NtSetEvent@8
+NtSetHighEventPair@4
+NtSetHighWaitLowEventPair@4
+NtSetInformationFile@20
+NtSetInformationKey@16
+NtSetInformationObject@16
+NtSetInformationProcess@16
+NtSetInformationThread@16
+NtSetInformationToken@16
+NtSetIntervalProfile@8
+NtSetLdtEntries@24
+NtSetLowEventPair@4
+NtSetLowWaitHighEventPair@4
+NtSetSecurityObject@12
+NtSetSystemEnvironmentValue@8
+NtSetSystemInformation@12
+NtSetSystemPowerState@12
+NtSetSystemTime@8
+NtSetTimer@28
+NtSetTimerResolution@12
+NtSetValueKey@24
+NtSetVolumeInformationFile@20
+NtShutdownSystem@4
+NtSignalAndWaitForSingleObject@16
+NtStartProfile@4
+NtStopProfile@4
+NtSuspendThread@8
+NtSystemDebugControl@24
+NtTerminateProcess@8
+NtTerminateThread@8
+NtTestAlert@0
+NtUnloadDriver@4
+NtUnloadKey@4
+NtUnlockFile@20
+NtUnlockVirtualMemory@16
+NtUnmapViewOfSection@8
+NtVdmControl@8
+NtWaitForMultipleObjects@20
+NtWaitForSingleObject@12
+NtWaitHighEventPair@4
+NtWaitLowEventPair@4
+NtWriteFile@36
+NtWriteFileGather@36
+NtWriteRequestData@24
+NtWriteVirtualMemory@20
+NtW32Call@20
+NtCreateChannel@8
+NtListenChannel@8
+NtOpenChannel@8
+NtReplyWaitSendChannel@12
+NtSendWaitReplyChannel@16
+NtSetContextChannel@4
+NtYieldExecution@0
+ZwAcceptConnectPort@24
+ZwAccessCheck@32
+ZwAccessCheckAndAuditAlarm@44
+ZwAddAtom@8
+ZwAdjustGroupsToken@24
+ZwAdjustPrivilegesToken@24
+ZwAlertResumeThread@8
+ZwAlertThread@4
+ZwAllocateLocallyUniqueId@4
+ZwAllocateUuids@12
+ZwAllocateVirtualMemory@24
+ZwCallbackReturn@12
+ZwCancelIoFile@8
+ZwCancelTimer@8
+ZwClearEvent@4
+ZwClose@4
+ZwCloseObjectAuditAlarm@12
+ZwCompleteConnectPort@4
+ZwConnectPort@32
+ZwContinue@8
+ZwCreateDirectoryObject@12
+ZwCreateEvent@20
+ZwCreateEventPair@12
+ZwCreateFile@44
+ZwCreateIoCompletion@16
+ZwCreateKey@28
+ZwCreateMailslotFile@32
+ZwCreateMutant@16
+ZwCreateNamedPipeFile@56
+ZwCreatePagingFile@16
+ZwCreatePort@20
+ZwCreateProcess@32
+ZwCreateProfile@36
+ZwCreateSection@28
+ZwCreateSemaphore@20
+ZwCreateSymbolicLinkObject@16
+ZwCreateThread@32
+ZwCreateTimer@16
+ZwCreateToken@52
+ZwDelayExecution@8
+ZwDeleteAtom@4
+ZwDeleteFile@4
+ZwDeleteKey@4
+ZwDeleteObjectAuditAlarm@12
+ZwDeleteValueKey@8
+ZwDeviceIoControlFile@40
+ZwDisplayString@4
+ZwDuplicateObject@28
+ZwDuplicateToken@24
+ZwEnumerateKey@24
+ZwEnumerateValueKey@24
+ZwExtendSection@8
+ZwFindAtom@8
+ZwFlushBuffersFile@8
+ZwFlushInstructionCache@12
+ZwFlushKey@4
+ZwFlushVirtualMemory@16
+ZwFlushWriteBuffer@0
+ZwFreeVirtualMemory@16
+ZwFsControlFile@40
+ZwGetContextThread@8
+ZwGetPlugPlayEvent@16
+ZwGetTickCount@4
+ZwImpersonateClientOfPort@8
+ZwImpersonateThread@12
+ZwInitializeRegistry@4
+ZwListenPort@8
+ZwLoadDriver@4
+ZwLoadKey@8
+ZwLoadKey2@12
+ZwLockFile@40
+ZwLockVirtualMemory@16
+ZwMakeTemporaryObject@4
+ZwMapViewOfSection@40
+ZwNotifyChangeDirectoryFile@36
+ZwNotifyChangeKey@40
+ZwOpenDirectoryObject@12
+ZwOpenEvent@12
+ZwOpenEventPair@12
+ZwOpenFile@24
+ZwOpenIoCompletion@12
+ZwOpenKey@12
+ZwOpenMutant@12
+ZwOpenObjectAuditAlarm@48
+ZwOpenProcess@16
+ZwOpenProcessToken@12
+ZwOpenSection@12
+ZwOpenSemaphore@12
+ZwOpenSymbolicLinkObject@12
+ZwOpenThread@16
+ZwOpenThreadToken@16
+ZwOpenTimer@12
+ZwPlugPlayControl@16
+ZwPrivilegeCheck@12
+ZwPrivilegedServiceAuditAlarm@20
+ZwPrivilegeObjectAuditAlarm@24
+ZwProtectVirtualMemory@20
+ZwPulseEvent@8
+ZwQueryInformationAtom@20
+ZwQueryAttributesFile@8
+ZwQueryDefaultLocale@8
+ZwQueryDirectoryFile@44
+ZwQueryDirectoryObject@28
+ZwQueryEaFile@36
+ZwQueryEvent@20
+ZwQueryFullAttributesFile@8
+ZwQueryInformationFile@20
+ZwQueryIoCompletion@20
+ZwQueryInformationPort@20
+ZwQueryInformationProcess@20
+ZwQueryInformationThread@20
+ZwQueryInformationToken@20
+ZwQueryIntervalProfile@8
+ZwQueryKey@20
+ZwQueryMultipleValueKey@24
+ZwQueryMutant@20
+ZwQueryObject@20
+ZwQueryOleDirectoryFile@44
+ZwQueryPerformanceCounter@8
+ZwQuerySection@20
+ZwQuerySecurityObject@20
+ZwQuerySemaphore@20
+ZwQuerySymbolicLinkObject@12
+ZwQuerySystemEnvironmentValue@16
+ZwQuerySystemInformation@16
+ZwQuerySystemTime@4
+ZwQueryTimer@20
+ZwQueryTimerResolution@12
+ZwQueryValueKey@24
+ZwQueryVirtualMemory@24
+ZwQueryVolumeInformationFile@20
+ZwQueueApcThread@20
+ZwRaiseException@12
+ZwRaiseHardError@24
+ZwReadFile@36
+ZwReadFileScatter@36
+ZwReadRequestData@24
+ZwReadVirtualMemory@20
+ZwRegisterThreadTerminatePort@4
+ZwReleaseMutant@8
+ZwReleaseSemaphore@12
+ZwRemoveIoCompletion@20
+ZwReplaceKey@12
+ZwReplyPort@8
+ZwReplyWaitReceivePort@16
+ZwReplyWaitReplyPort@8
+ZwRequestPort@8
+ZwRequestWaitReplyPort@12
+ZwResetEvent@8
+ZwRestoreKey@12
+ZwResumeThread@8
+ZwSaveKey@8
+ZwSetIoCompletion@20
+ZwSetContextThread@8
+ZwSetDefaultHardErrorPort@4
+ZwSetDefaultLocale@8
+ZwSetEaFile@16
+ZwSetEvent@8
+ZwSetHighEventPair@4
+ZwSetHighWaitLowEventPair@4
+ZwSetInformationFile@20
+ZwSetInformationKey@16
+ZwSetInformationObject@16
+ZwSetInformationProcess@16
+ZwSetInformationThread@16
+ZwSetInformationToken@16
+ZwSetIntervalProfile@8
+ZwSetLdtEntries@24
+ZwSetLowEventPair@4
+ZwSetLowWaitHighEventPair@4
+ZwSetSecurityObject@12
+ZwSetSystemEnvironmentValue@8
+ZwSetSystemInformation@12
+ZwSetSystemPowerState@12
+ZwSetSystemTime@8
+ZwSetTimer@28
+ZwSetTimerResolution@12
+ZwSetValueKey@24
+ZwSetVolumeInformationFile@20
+ZwShutdownSystem@4
+ZwSignalAndWaitForSingleObject@16
+ZwStartProfile@4
+ZwStopProfile@4
+ZwSuspendThread@8
+ZwSystemDebugControl@24
+ZwTerminateProcess@8
+ZwTerminateThread@8
+ZwTestAlert@0
+ZwUnloadDriver@4
+ZwUnloadKey@4
+ZwUnlockFile@20
+ZwUnlockVirtualMemory@16
+ZwUnmapViewOfSection@8
+ZwVdmControl@8
+ZwWaitForMultipleObjects@20
+ZwWaitForSingleObject@12
+ZwWaitHighEventPair@4
+ZwWaitLowEventPair@4
+ZwWriteFile@36
+ZwWriteFileGather@36
+ZwWriteRequestData@24
+ZwWriteVirtualMemory@20
+ZwW32Call@20
+ZwCreateChannel@8
+ZwListenChannel@8
+ZwOpenChannel@8
+ZwReplyWaitSendChannel@12
+ZwSendWaitReplyChannel@16
+ZwSetContextChannel@4
+ZwYieldExecution@0
+RtlInitAnsiString
+RtlInitUnicodeString
+RtlLargeIntegerDivide
+RtlLargeIntegerAdd
+RtlEnlargedIntegerMultiply
+RtlEnlargedUnsignedMultiply
+RtlExtendedIntegerMultiply
+isalpha
+memcpy
+memset
+strcat
+strcmp
+stricmp
+strcpy
+strncpy
+strlen
+strrchr
+toupper
+wcscpy
+wcschr
+wcscat
+wcscmp
+wcsicmp
+wcsnicmp
+wcsncpy
+wcslen
+wcsrchr
+vsprintf
--- /dev/null
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS kernel
+ * FILE: lib/ntdll/ldr/startup.c
+ * PURPOSE: Process startup for PE executables
+ * PROGRAMMERS: Jean Michault
+ * Rex Jolliff (rex@lvcablemodem.com)
+ */
+
+/* INCLUDES *****************************************************************/
+
+#define WIN32_NO_PEHDR
+#include <windows.h>
+#include <ddk/ntddk.h>
+#include <pe.h>
+#include <string.h>
+#include <internal/string.h>
+#include <wchar.h>
+
+#define NDEBUG
+#include <ntdll/ntdll.h>
+
+VOID WINAPI __RtlInitHeap(LPVOID base, ULONG minsize, ULONG maxsize);
+
+/* MACROS ********************************************************************/
+
+#define RVA(m, b) ((ULONG)b + m->BaseAddress)
+
+/* TYPEDEFS ******************************************************************/
+
+typedef NTSTATUS (*PEPFUNC)(VOID);
+
+typedef struct _DLL
+{
+ PIMAGE_NT_HEADERS Headers;
+ PVOID BaseAddress;
+ struct _DLL* Prev;
+ struct _DLL* Next;
+} DLL, *PDLL;
+
+/* GLOBALS *******************************************************************/
+
+static DLL DllListHead;
+
+/* FORWARD DECLARATIONS ******************************************************/
+
+static PEPFUNC LdrPEStartup(DWORD ImageBase, HANDLE SectionHandle);
+
+/* FUNCTIONS *****************************************************************/
+
+static NTSTATUS LdrMapSections(PVOID ImageBase, HANDLE SectionHandle,
+ PIMAGE_NT_HEADERS NTHeaders)
+{
+ ULONG i;
+ NTSTATUS Status;
+
+ for (i=0; i<NTHeaders->FileHeader.NumberOfSections; i++)
+ {
+ PIMAGE_SECTION_HEADER Sections;
+ LARGE_INTEGER Offset;
+ ULONG Base;
+
+ Sections = (PIMAGE_SECTION_HEADER)SECHDROFFSET(ImageBase);
+ Base = Sections[i].VirtualAddress + ImageBase;
+ SET_LARGE_INTEGER_HIGH_PART(Offset,0);
+ SET_LARGE_INTEGER_LOW_PART(Offset,Sections[i].PointerToRawData);
+ Status = ZwMapViewOfSection(SectionHandle,
+ NtCurrentProcess(),
+ (PVOID *)&Base,
+ 0,
+ Sections[i].Misc.VirtualSize,
+ &Offset,
+ &Sections[i].Misc.VirtualSize,
+ 0,
+ MEM_COMMIT,
+ PAGE_READWRITE);
+ if (!NT_SUCCESS(Status))
+ {
+ return Status;
+ }
+ }
+ return(STATUS_SUCCESS);
+}
+
+static NTSTATUS LdrLoadDll(PDLL* Base, PCHAR Name)
+{
+ PIMAGE_EXPORT_DIRECTORY ExportDir;
+ DLL* current;
+ PIMAGE_OPTIONAL_HEADER OptionalHeader;
+
+ DPRINT("LdrLoadDll(Name %s)\n",Name);
+
+ current = &DllListHead;
+ do
+ {
+ OptionalHeader = ¤t->Headers->OptionalHeader;
+ ExportDir = (PIMAGE_EXPORT_DIRECTORY)OptionalHeader->DataDirectory[
+ IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress;
+ ExportDir = ((ULONG)ExportDir + (ULONG)current->BaseAddress);
+
+ DPRINT("ExportDir %x\n",ExportDir);
+ DPRINT("Scanning %x\n",ExportDir->Name);
+ DPRINT("Scanning %s\n",ExportDir->Name + current->BaseAddress);
+ if (strcmp(ExportDir->Name + current->BaseAddress, Name) == 0)
+ {
+ *Base = current;
+ return(STATUS_SUCCESS);
+ }
+
+ current = current->Next;
+ } while (current != &DllListHead);
+
+ return(STATUS_UNSUCCESSFUL);
+}
+
+#define HEAP_BASE (0xa0000000)
+
+/* LdrStartup
+ * FUNCTION:
+ * Handles Process Startup Activities.
+ * ARGUMENTS:
+ * DWORD ImageBase The base address of the process image
+ */
+VOID LdrStartup(HANDLE SectionHandle, DWORD ImageBase)
+{
+ PEPFUNC EntryPoint;
+ PIMAGE_DOS_HEADER PEDosHeader;
+ char buffer[512];
+ NTSTATUS Status;
+ PIMAGE_NT_HEADERS NTHeaders;
+
+ DPRINT("LdrStartup(ImageBase %x, SectionHandle %x)\n",ImageBase,
+ SectionHandle);
+
+ DllListHead.BaseAddress = 0x80000000;
+ DllListHead.Prev = &DllListHead;
+ DllListHead.Next = &DllListHead;
+ PEDosHeader = (PIMAGE_DOS_HEADER)DllListHead.BaseAddress;
+ DllListHead.Headers = (PIMAGE_NT_HEADERS)(DllListHead.BaseAddress +
+ PEDosHeader->e_lfanew);
+
+ /* If MZ header exists */
+ PEDosHeader = (PIMAGE_DOS_HEADER) ImageBase;
+ if (PEDosHeader->e_magic != IMAGE_DOS_MAGIC ||
+ PEDosHeader->e_lfanew == 0L ||
+ *(PULONG)((PUCHAR)ImageBase + PEDosHeader->e_lfanew) != IMAGE_PE_MAGIC)
+ {
+ DPRINT("Image has bad header\n");
+ ZwTerminateProcess(NULL,STATUS_UNSUCCESSFUL);
+ }
+
+ NTHeaders = (PIMAGE_NT_HEADERS)(ImageBase + PEDosHeader->e_lfanew);
+ __RtlInitHeap(HEAP_BASE,
+ NTHeaders->OptionalHeader.SizeOfHeapCommit,
+ NTHeaders->OptionalHeader.SizeOfHeapReserve);
+ EntryPoint = LdrPEStartup(ImageBase, SectionHandle);
+
+ if (EntryPoint == NULL)
+ {
+ DPRINT("Failed to initialize image\n");
+ ZwTerminateProcess(NULL,STATUS_UNSUCCESSFUL);
+ }
+
+ DPRINT("Transferring control to image\n");
+ Status = EntryPoint();
+ ZwTerminateProcess(NtCurrentProcess(),Status);
+}
+
+static PVOID LdrGetExport(PDLL Module, PUCHAR SymbolName)
+{
+ PIMAGE_EXPORT_DIRECTORY ExportDir;
+ PDWORD* ExFunctions;
+ PDWORD* ExNames;
+ USHORT* ExOrdinals;
+ ULONG i;
+ PVOID ExName;
+ ULONG Ordinal;
+
+ DPRINT("LdrFindExport(Module %x, SymbolName %s)\n",
+ Module, SymbolName);
+
+ ExportDir = (Module->BaseAddress +
+ (Module->Headers->OptionalHeader.
+ DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress));
+
+ /* Get header pointers */
+ ExNames = (PDWORD*)RVA(Module, ExportDir->AddressOfNames);
+ ExOrdinals = (USHORT*)RVA(Module, ExportDir->AddressOfNameOrdinals);
+ ExFunctions = (PDWORD*)RVA(Module, ExportDir->AddressOfFunctions);
+ for (i=0; i<ExportDir->NumberOfFunctions; i++)
+ {
+ ExName = RVA(Module, ExNames[i]);
+ if (strcmp(ExName,SymbolName) == 0)
+ {
+ Ordinal = ExOrdinals[i];
+ return(RVA(Module, ExFunctions[Ordinal]));
+ }
+ }
+ return(NULL);
+}
+
+static PEPFUNC LdrPEStartup(DWORD ImageBase, HANDLE SectionHandle)
+{
+ int i;
+ PVOID SectionBase;
+ NTSTATUS Status;
+ PEPFUNC EntryPoint;
+ PIMAGE_DOS_HEADER DosHeader;
+ PIMAGE_NT_HEADERS NTHeaders;
+ PIMAGE_SECTION_HEADER SectionList;
+ char buffer[512];
+ PDLL Module;
+
+ DosHeader = (PIMAGE_DOS_HEADER) ImageBase;
+ NTHeaders = (PIMAGE_NT_HEADERS)(ImageBase + DosHeader->e_lfanew);
+ SectionList = (PIMAGE_SECTION_HEADER) (ImageBase + DosHeader->e_lfanew +
+ sizeof(ULONG) + sizeof(IMAGE_FILE_HEADER) + sizeof(IMAGE_OPTIONAL_HEADER));
+
+ /* Initialize Image sections */
+ LdrMapSections(ImageBase, SectionHandle, NTHeaders);
+
+ /* FIXME: if actual load address is different from ImageBase, then reloc */
+ if (ImageBase != (DWORD) NTHeaders->OptionalHeader.ImageBase)
+ {
+ USHORT NumberOfEntries;
+ PUSHORT pValue16;
+ ULONG RelocationRVA;
+ ULONG Delta32, Offset;
+ PULONG pValue32;
+ PRELOCATION_DIRECTORY RelocationDir;
+ PRELOCATION_ENTRY RelocationBlock;
+
+ RelocationRVA = NTHeaders->OptionalHeader.DataDirectory[
+ IMAGE_DIRECTORY_ENTRY_BASERELOC].VirtualAddress;
+ if (RelocationRVA)
+ {
+ RelocationDir = (PRELOCATION_DIRECTORY)
+ ((PCHAR)ImageBase + RelocationRVA);
+ while (RelocationDir->SizeOfBlock)
+ {
+ Delta32 = (unsigned long)(ImageBase -
+ NTHeaders->OptionalHeader.ImageBase);
+ RelocationBlock = (PRELOCATION_ENTRY)
+ (RelocationRVA + ImageBase + sizeof(RELOCATION_DIRECTORY));
+ NumberOfEntries =
+ (RelocationDir->SizeOfBlock - sizeof(RELOCATION_DIRECTORY)) /
+ sizeof(RELOCATION_ENTRY);
+ for (i = 0; i < NumberOfEntries; i++)
+ {
+ Offset = (RelocationBlock[i].TypeOffset & 0xfff) +
+ RelocationDir->VirtualAddress;
+ switch (RelocationBlock[i].TypeOffset >> 12)
+ {
+ case TYPE_RELOC_ABSOLUTE:
+ break;
+
+ case TYPE_RELOC_HIGH:
+ pValue16 = (PUSHORT) (ImageBase + Offset);
+ *pValue16 += Delta32 >> 16;
+ break;
+
+ case TYPE_RELOC_LOW:
+ pValue16 = (PUSHORT)(ImageBase + Offset);
+ *pValue16 += Delta32 & 0xffff;
+ break;
+
+ case TYPE_RELOC_HIGHLOW:
+ pValue32 = (PULONG) (ImageBase + Offset);
+ *pValue32 += Delta32;
+ break;
+
+ case TYPE_RELOC_HIGHADJ:
+ /* FIXME: do the highadjust fixup */
+ DPRINT(
+ "TYPE_RELOC_HIGHADJ fixup not implemented, sorry\n");
+ return 0;
+
+ default:
+ DPRINT("unexpected fixup type\n");
+ return 0;
+ }
+ }
+ RelocationRVA += RelocationDir->SizeOfBlock;
+ RelocationDir = (PRELOCATION_DIRECTORY)(ImageBase +
+ RelocationRVA);
+ }
+ }
+ }
+
+ /* FIXME: do import fixups/load required libraries */
+ /* Resolve Import Library references */
+ if (NTHeaders->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].
+ VirtualAddress != 0)
+ {
+ PIMAGE_IMPORT_MODULE_DIRECTORY ImportModuleDirectory;
+
+ /* Process each import module */
+ ImportModuleDirectory = (PIMAGE_IMPORT_MODULE_DIRECTORY)
+ (ImageBase + NTHeaders->OptionalHeader.
+ DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress);
+ while (ImportModuleDirectory->dwRVAModuleName)
+ {
+ DWORD LibraryBase;
+ PIMAGE_DOS_HEADER LibDosHeader;
+ PIMAGE_NT_HEADERS LibNTHeaders;
+ PVOID *ImportAddressList; // was pImpAddr
+ PULONG FunctionNameList;
+ DWORD pName;
+ PWORD pHint;
+
+ Status = LdrLoadDll(&Module,
+ (PCHAR)(ImageBase +
+ ImportModuleDirectory->dwRVAModuleName));
+ if (!NT_SUCCESS(Status))
+ {
+ return 0;
+ }
+
+ /* Get the import address list */
+ ImportAddressList = (PVOID *)
+ (NTHeaders->OptionalHeader.ImageBase +
+ ImportModuleDirectory->dwRVAFunctionAddressList);
+
+ /* Get the list of functions to import */
+ if (ImportModuleDirectory->dwRVAFunctionNameList != 0)
+ {
+ FunctionNameList = (PULONG) (ImageBase +
+ ImportModuleDirectory->dwRVAFunctionNameList);
+ }
+ else
+ {
+ FunctionNameList = (PULONG) (ImageBase +
+ ImportModuleDirectory->dwRVAFunctionAddressList);
+ }
+
+ /* Walk through function list and fixup addresses */
+ while(*FunctionNameList != 0L)
+ {
+ if ((*FunctionNameList) & 0x80000000) // hint
+ {
+// *ImportAddressList = LibraryExports[(*FunctionNameList) & 0x7fffffff];
+ DPRINT("Import by ordinal unimplemented\n");
+ for(;;);
+ }
+ else // hint-name
+ {
+ pName = (DWORD)(ImageBase + *FunctionNameList + 2);
+ pHint = (PWORD)(ImageBase + *FunctionNameList);
+
+ /* FIXME: verify name */
+
+ if (strcmp(pName,"vsprintf")==0)
+ {
+ DPRINT("Fixing up reference to %s at %x\n",
+ pName,ImportAddressList);
+ DPRINT("pHint %x\n",pHint);
+ }
+
+
+
+ *ImportAddressList = LdrGetExport(Module,pName);
+ }
+ /* FIXME: verify value of hint */
+
+ ImportAddressList++;
+ FunctionNameList++;
+ }
+ ImportModuleDirectory++;
+ }
+ }
+
+ /* FIXME: locate the entry point for the image */
+ EntryPoint = NTHeaders->OptionalHeader.ImageBase +
+ NTHeaders->OptionalHeader.AddressOfEntryPoint;
+
+ return EntryPoint;
+}
+
+
+
#include <windows.h>
+#include <stdarg.h>
+#include <ddk/ntddk.h>
+#include <ntdll/ntdll.h>
-/* FIXME: Should this function be called DllEntryPoint? */
+void dprintf(char* fmt,...)
+{
+ char buffer[512];
+ va_list ap;
+ WCHAR bufferw[512];
+ UNICODE_STRING UnicodeString;
+ ULONG i;
+
+ va_start(ap, fmt);
+ vsprintf(buffer, fmt, ap);
+ for (i=0; buffer[i] != 0; i++)
+ {
+ bufferw[i] = buffer[i];
+ }
+ bufferw[i] = 0;
+ RtlInitUnicodeString(&UnicodeString, bufferw);
+ NtDisplayString(&UnicodeString);
+ va_end(ap);
+}
-BOOL WINAPI STDCALL DllMainCRTStartup(HINSTANCE hDLLInst, DWORD fdwReason, LPVOID lpvReserved)
+BOOL WINAPI DllMainCRTStartup(HINSTANCE hinstDll,
+ DWORD fdwReason,
+ LPVOID fImpLoad)
{
- return 0;
+ return TRUE;
}
+
+
-all: ntdll.a
-OBJECTS = napi.o stubs/stubs.o string/wstring.o stdio/vsprintf.o \
- rtl/unicode.o rtl/namespc.o string/ctype.o string/strlen.o \
- rtl/time.o string/memcpy.o
+ifneq ($(HOST),mingw32-windows)
+ ifneq ($(HOST),mingw32-linux)
+ DLLTARGET=ntdll.a
+ DLLMAIN=
+ else
+ DLLTARGET=ntdll.dll
+ DLLMAIN=main/dllmain.o
+ endif
+else
+ DLLTARGET=ntdll.dll
+ DLLMAIN=main/dllmain.o
+endif
+
+all: $(DLLTARGET)
+
+OBJECTS = napi.o ldr/startup.o rtl/largeint.o rtl/namespc.o rtl/unicode.o \
+ stdio/vsprintf.o string/ctype.o string/memcpy.o string/memset.o \
+ string/strcat.o string/strcmp.o string/strcpy.o string/stricmp.o \
+ string/strlen.o string/strncmp.o string/strncpy.o string/strnlen.o \
+ string/strrchr.o string/wstring.o stubs/stubs.o rtl/heap.o \
+ rtl/critical.o rtl/mem.o
ntdll.a: $(OBJECTS)
- $(AR) vcsr ntdll.a $(OBJECTS)
-
-dummy:
+ $(AR) csr ntdll.a $(OBJECTS)
+
+ntdll.dll: $(DLLMAIN) $(OBJECTS)
+ $(LD) -r $(DLLMAIN) $(OBJECTS) -o ntdll.o
+ $(DLLTOOL) --dllname ntdll.dll --def def/ntdll.def \
+ --output-lib ntdll.a
+ $(CC) -specs=ntdll_specs -mdll -o junk.tmp \
+ -Wl,--base-file,base.tmp ntdll.o
+ - $(RM) junk.tmp
+ $(DLLTOOL) --dllname ntdll.dll --base-file base.tmp \
+ --output-exp temp.exp --def def/ntdll.def
+ - $(RM) base.tmp
+ $(CC) -specs=ntdll_specs -mdll -o ntdll.dll ntdll.o \
+ -Wl,--entry=_LdrStartup \
+ -Wl,--image-base,0x80000000 \
+ -Wl,--file-alignment,0x1000 \
+ -Wl,--section-alignment,0x1000 \
+ -Wl,temp.exp
+ - $(RM) temp.exp
+ $(NM) --numeric-sort ntdll.dll > ntdll.sym
include ../../rules.mak
--- /dev/null
+*asm:
+
+
+*asm_final:
+
+
+*cpp:
+-remap %(cpp_cpu) %{posix:-D_POSIX_SOURCE}
+
+*cc1:
+%(cc1_spec)
+
+*cc1plus:
+
+
+*endfile:
+
+
+*link:
+%{mwindows:--subsystem windows} %{mdll:--dll -e _DllMainCRTStartup@12}
+
+*lib:
+
+
+*libgcc:
+-lgcc
+
+*startfile:
+
+
+*switches_need_spaces:
+
+
+*signed_char:
+%{funsigned-char:-D__CHAR_UNSIGNED__}
+
+*predefines:
+-Di386 -D_WIN32 -DWIN32 -D__WIN32__ -D__MINGW32__ -DWINNT -D_X86_=1 -D__STDC__=1 -D__stdcall=__attribute__((__stdcall__)) _D_stdcall=__attribute__((__stdcall__)) -D__cdecl=__attribute__((__cdecl__)) -D__declspec(x)=__attribute__((x)) -Asystem(winnt) -Acpu(i386) -Amachine(i386)
+
+*cross_compile:
+1
+
+*version:
+egcs-2.91.57
+
+*multilib:
+. ;
+
+*multilib_defaults:
+
+
+*multilib_extra:
+
+
+*multilib_matches:
+
+
+*linker:
+collect2
+
+*cpp_486:
+%{!ansi:-Di486} -D__i486 -D__i486__
+
+*cpp_586:
+%{!ansi:-Di586 -Dpentium} -D__i586 -D__i586__ -D__pentium -D__pentium__
+
+*cpp_686:
+%{!ansi:-Di686 -Dpentiumpro} -D__i686 -D__i686__ -D__pentiumpro -D__pentiumpro__
+
+*cpp_cpu_default:
+%(cpp_586)
+
+*cpp_cpu:
+-Acpu(i386) -Amachine(i386) %{!ansi:-Di386} -D__i386 -D__i386__ %{mcpu=i486:%(cpp_486)} %{m486:%(cpp_486)} %{mpentium:%(cpp_586)} %{mcpu=pentium:%(cpp_586)} %{mpentiumpro:%(cpp_686)} %{mcpu=pentiumpro:%(cpp_686)} %{!mcpu*:%{!m486:%{!mpentium*:%(cpp_cpu_default)}}}
+
+*cc1_cpu:
+%{!mcpu*: %{m386:-mcpu=i386 -march=i386} %{mno-486:-mcpu=i386 -march=i386} %{m486:-mcpu=i486 -march=i486} %{mno-386:-mcpu=i486 -march=i486} %{mno-pentium:-mcpu=i486 -march=i486} %{mpentium:-mcpu=pentium} %{mno-pentiumpro:-mcpu=pentium} %{mpentiumpro:-mcpu=pentiumpro}}
+
--- /dev/null
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS system libraries
+ * FILE: lib/kernel32/sync/critical.c
+ * PURPOSE: Critical regions
+ * UPDATE HISTORY:
+ * Created 30/09/98
+ */
+
+/* INCLUDES ******************************************************************/
+
+#include <windows.h>
+
+/* FUNCTIONS *****************************************************************/
+
+VOID RtlDeleteCriticalSection(LPCRITICAL_SECTION lpCriticalSection)
+{
+ lpCriticalSection->Reserved = -1;
+}
+
+VOID RtlEnterCriticalSection(LPCRITICAL_SECTION lpCriticalSection)
+{
+}
+
+VOID RtlInitializeCriticalSection(LPCRITICAL_SECTION pcritical)
+{
+ pcritical->LockCount = -1;
+ pcritical->RecursionCount = 0;
+ pcritical->LockSemaphore = NULL;
+ pcritical->OwningThread = (HANDLE)-1;
+ pcritical->Reserved = 0;
+}
+
+VOID RtlLeaveCriticalSection(LPCRITICAL_SECTION lpCriticalSection)
+{
+}
+
+WINBOOL RtlTryEntryCriticalSection(LPCRITICAL_SECTION lpCriticalSection)
+{
+}
+
--- /dev/null
+/*
+ * kernel/heap.c
+ * Copyright (C) 1996, Onno Hovers, All rights reserved
+ *
+ * This software 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 software 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.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this software; see the file COPYING.LIB. If
+ * not, write to the Free Software Foundation, Inc., 675 Mass Ave,
+ * Cambridge, MA 02139, USA.
+ *
+ * Win32 heap functions (HeapXXX).
+ *
+ */
+
+/*
+ * Adapted for the ReactOS system libraries by David Welch (welch@mcmail.com)
+ * Put the type definitions of the heap in a seperate header. Boudewijn Dekker
+ */
+
+#include <string.h>
+#include <ddk/ntddk.h>
+
+//#define NDEBUG
+#include <ntdll/ntdll.h>
+
+#define HEAP_VALIDATE
+
+static HEAP_BUCKET __HeapDefaultBuckets[]=
+{
+ { NULL, 16, 18, 504 },
+ { NULL, 24, 30, 1016 },
+ { NULL, 32, 24, 1016 },
+ { NULL, 48, 17, 1016 },
+ { NULL, 64, 27, 2040 },
+ { NULL, 96, 19, 2040 },
+ { NULL, 128, 29, 4088 },
+ { NULL, 256, 15, 4088 },
+};
+
+PHEAP __ProcessHeap = NULL;
+
+static BOOL __HeapCommit(PHEAP pheap, LPVOID start, LPVOID end);
+static BOOL __HeapDecommit(PHEAP pheap, LPVOID start, LPVOID end);
+static LPVOID __HeapAlloc(PHEAP pheap, ULONG flags, ULONG size, ULONG tag);
+static VOID __HeapFreeRest(PHEAP pheap, PHEAP_BLOCK pfree, ULONG allocsize,
+ ULONG newsize);
+static LPVOID __HeapReAlloc(PHEAP pheap, ULONG flags, LPVOID pold, DWORD size);
+static BOOL __HeapFree(PHEAP pheap, ULONG flags, LPVOID pmem);
+static PHEAP_SUBALLOC __HeapAllocSub(PHEAP pheap, PHEAP_BUCKET pbucket);
+static LPVOID __HeapAllocFragment(PHEAP pheap, ULONG flags, ULONG size);
+static LPVOID __HeapReAllocFragment(PHEAP pheap, ULONG flags,
+ LPVOID pold, ULONG size);
+static BOOL __HeapFreeFragment(PHEAP pheap, ULONG flags, LPVOID ptr);
+static PHEAP __HeapPrepare(LPVOID base, ULONG minsize, ULONG maxsize,
+ ULONG flags);
+
+
+
+/*********************************************************************
+* __HeapCommit *
+* *
+* commits a range of memory in the heap *
+*********************************************************************/
+static BOOL __HeapCommit(PHEAP pheap, LPVOID start, LPVOID end)
+{
+ NTSTATUS Result;
+ ULONG length;
+
+ DPRINT("__HeapCommit( 0x%lX, 0x%lX, 0x%lX)\n",
+ (ULONG) pheap, (ULONG) start, (ULONG) end);
+
+ if(end >= pheap->LastBlock)
+ pheap->LastBlock=end;
+
+ length = end - start;
+ Result = ZwAllocateVirtualMemory(NtCurrentProcess(),
+ &start,
+ 0,
+ &length,
+ MEM_COMMIT,
+ PAGE_READWRITE);
+
+ return(NT_SUCCESS(Result));
+}
+
+/*********************************************************************
+* __HeapDecommit *
+* *
+* decommits a range of memory in the heap *
+*********************************************************************/
+static BOOL __HeapDecommit(PHEAP pheap, LPVOID start, LPVOID end)
+{
+ NTSTATUS Status;
+ ULONG size;
+
+ DPRINT("__HeapDecommit( 0x%lX, 0x%lX, 0x%lX)\n",
+ (ULONG) pheap, (ULONG) start, (ULONG) end);
+#ifdef NOT
+ __VirtualDump();
+#endif
+ if((end >= pheap->LastBlock)&&(start<= pheap->LastBlock))
+ pheap->LastBlock=start;
+
+ size = end - start;
+ Status = ZwFreeVirtualMemory(NtCurrentProcess(),
+ &start,
+ &size,
+ MEM_DECOMMIT);
+
+ return(NT_SUCCESS(Status));
+}
+
+/*********************************************************************
+* __HeapAlloc *
+* *
+* allocates a range of memory from the heap *
+*********************************************************************/
+static LPVOID __HeapAlloc(PHEAP pheap, ULONG flags, ULONG size, ULONG tag)
+{
+ PHEAP_BLOCK pfree;
+ PHEAP_BLOCK palloc;
+ PHEAP_BLOCK pnext;
+ LPVOID commitstart;
+ LPVOID commitend;
+ ULONG freesize;
+ ULONG allocsize;
+
+ DPRINT("__HeapAlloc(pheap %x, flags %x, size %d, tag %x)\n",
+ pheap,flags,size,tag);
+
+ if (size <= HEAP_ADMIN_SIZE)
+ {
+ size = size + HEAP_ADMIN_SIZE;
+ }
+
+ pfree=&(pheap->Start);
+ allocsize=SIZE_ROUND(size);
+ freesize=HEAP_SIZE(pfree);
+ /* look for a free region of memory: simple First Fit */
+ while( HEAP_ISALLOC(pfree) || ( freesize<allocsize ))
+ {
+ pfree=HEAP_NEXT(pfree);
+ if((LPVOID) pfree>=pheap->End)
+ return NULL;
+ freesize=HEAP_SIZE(pfree);
+ }
+ palloc=pfree;
+
+ if(freesize>allocsize)
+ {
+ /* commit necessary memory */
+ commitstart=(LPVOID) ROUNDDOWN((ULONG) palloc+HEAP_ADMIN_SIZE,PAGESIZE);
+ commitend =(LPVOID) ROUNDUP ((ULONG) palloc+
+ allocsize+2*HEAP_ADMIN_SIZE, PAGESIZE);
+ if(commitstart<commitend)
+ if(!__HeapCommit(pheap, commitstart, commitend))
+ return NULL;
+
+ /* split this block in two */
+ pfree= (LPVOID) palloc+ HEAP_ADMIN_SIZE + allocsize;
+
+ /* update admin */
+ pfree->Size =(freesize-allocsize-HEAP_ADMIN_SIZE) | HEAP_FREE_TAG;
+ pfree->PrevSize=(LPVOID)pfree-(LPVOID)palloc;
+
+ pnext=HEAP_NEXT(pfree);
+ if((LPVOID) pnext < pheap->End )
+ pnext->PrevSize=freesize-allocsize;
+ }
+ else
+ {
+ /* commit necessary memory */
+ commitstart=(LPVOID) ROUNDDOWN((ULONG) palloc+HEAP_ADMIN_SIZE, PAGESIZE);
+ commitend =(LPVOID) ROUNDUP((ULONG) palloc+HEAP_ADMIN_SIZE +allocsize,
+ PAGESIZE);
+ if(commitstart<commitend)
+ if(!__HeapCommit(pheap, commitstart, commitend))
+ return NULL;
+ }
+ /* update our administration */
+ palloc->Size= size | tag;
+ if((flags | pheap->Flags)& HEAP_ZERO_MEMORY)
+ FillMemory((LPVOID)palloc+HEAP_ADMIN_SIZE, allocsize, 0);
+ return (LPVOID)palloc+HEAP_ADMIN_SIZE;
+}
+
+/*********************************************************************
+* __HeapFreeRest *
+* *
+* used by realloc to free a part of the heap *
+*********************************************************************/
+static VOID __HeapFreeRest(PHEAP pheap, PHEAP_BLOCK pfree,
+ ULONG allocsize, ULONG newsize)
+{
+ PHEAP_BLOCK pnext;
+
+ if(allocsize==newsize)
+ {
+ pfree->PrevSize=allocsize+HEAP_ADMIN_SIZE;
+ return;
+ }
+
+ pfree->Size = (allocsize-newsize-HEAP_ADMIN_SIZE) | HEAP_FREE_TAG;
+ pfree->PrevSize = newsize+HEAP_ADMIN_SIZE;
+
+ pnext=HEAP_NEXT(pfree);
+ /* if there is a free region of memory after us, join it */
+ if(((LPVOID) pnext< pheap->End)&& HEAP_ISFREE(pnext))
+ {
+ pfree->Size = (HEAP_SIZE(pfree)+HEAP_SIZE(pnext) + HEAP_ADMIN_SIZE) |
+ HEAP_FREE_TAG;
+
+ pnext->Size=0;
+ pnext->PrevSize=0;
+ }
+
+ pnext=HEAP_NEXT(pfree);
+ if((LPVOID) pnext< pheap->End)
+ pnext->PrevSize=(LPVOID)pnext-(LPVOID)pfree;
+}
+
+/*********************************************************************
+* __HeapReAlloc *
+* *
+* reallocates a range of memory from the heap *
+*********************************************************************/
+
+static LPVOID __HeapReAlloc(PHEAP pheap, ULONG flags, LPVOID pold, DWORD size)
+{
+ PHEAP_BLOCK prealloc=(PHEAP_BLOCK)((LPVOID)pold-HEAP_ADMIN_SIZE);
+ PHEAP_BLOCK pnext;
+ LPVOID pmem;
+ LPVOID commitstart;
+ LPVOID commitend;
+ ULONG allocsize;
+ ULONG newsize;
+ ULONG oldsize;
+
+ /* check that this is a valid allocated block */
+ if(!HEAP_ISALLOC(prealloc))
+ return NULL;
+
+ allocsize = HEAP_RSIZE(prealloc);
+ newsize = SIZE_ROUND(size);
+ /*
+ * cases: size=0 free memory
+ * [ size<HEAP_FRAGMENT_THRESHOLD realloc ]
+ * newsize<previous size free rest
+ * newsize=previous size nop
+ * newsize>previous size try to merge
+ * else realloc
+ */
+ if(size==0)
+ {
+ DPRINT("__HeapReAlloc: freeing memory\n");
+ __HeapFree(pheap, flags, pold);
+ return NULL;
+ }
+#ifdef NOT
+ else if(size < HEAP_FRAGMENT_THRESHOLD)
+ {
+ /* alloc a new fragment */
+ pmem=__HeapAllocFragment(pheap, flags, size);
+ if(pmem)
+ RtlCopyMemory(pmem, pold, size);
+ return pmem;
+ }
+#endif
+ else if(newsize < allocsize )
+ {
+ DPRINT("__HeapReAlloc: shrinking memory\n");
+ /* free remaining region of memory */
+ prealloc->Size=size | HEAP_NORMAL_TAG;
+ pnext=HEAP_NEXT(prealloc);
+ __HeapFreeRest(pheap, pnext, allocsize, newsize);
+
+ /* decommit unnecessary memory */
+ commitstart=(LPVOID) ROUNDUP((ULONG) pnext+HEAP_ADMIN_SIZE ,PAGESIZE);
+ commitend =(LPVOID) ROUNDDOWN((ULONG) pnext+HEAP_ADMIN_SIZE+
+ HEAP_SIZE(pnext), PAGESIZE);
+ if(commitstart<commitend)
+ __HeapDecommit(pheap, commitstart, commitend);
+ return pold;
+ }
+ else if(newsize == allocsize )
+ {
+ DPRINT("__HeapReAlloc: no changes\n");
+ /* nothing to do */
+ prealloc->Size= size | HEAP_NORMAL_TAG;
+ return pold;
+ }
+ else if(newsize > allocsize)
+ {
+ /* try to merge */
+ pnext=HEAP_NEXT(prealloc);
+
+ if(((LPVOID) pnext< pheap->End)&& HEAP_ISFREE(pnext) &&
+ (HEAP_SIZE(pnext) + HEAP_ADMIN_SIZE >=newsize-allocsize))
+ {
+ DPRINT("__HeapReAlloc: joining memory\n");
+ oldsize=HEAP_SIZE(prealloc);
+ prealloc->Size=size | HEAP_NORMAL_TAG;
+
+ /* commit new memory if necessary */
+ commitstart=(LPVOID) ROUNDDOWN((ULONG) pnext+HEAP_ADMIN_SIZE,
+ PAGESIZE);
+ commitend =(LPVOID) ROUNDUP((ULONG) pnext+newsize-allocsize+
+ HEAP_ADMIN_SIZE, PAGESIZE);
+ if(commitstart<commitend)
+ if(!__HeapCommit(pheap, commitstart, commitend))
+ return NULL;
+
+ __HeapFreeRest(pheap, HEAP_NEXT(prealloc),
+ allocsize+HEAP_ADMIN_SIZE+HEAP_SIZE(pnext), newsize);
+
+ if((flags|pheap->Flags)&HEAP_ZERO_MEMORY)
+ memset(pold+oldsize, 0, size-oldsize);
+ return pold;
+ }
+ else
+ {
+ if((flags&HEAP_REALLOC_IN_PLACE_ONLY)==0)
+ {
+ DPRINT("__HeapReAlloc: allocating new memory\n");
+ /* alloc a new piece of memory */
+ oldsize=HEAP_SIZE(prealloc);
+ pmem=__HeapAlloc(pheap, flags, size, HEAP_NORMAL_TAG);
+ if(pmem)
+ RtlCopyMemory(pmem, pold, oldsize);
+ if((flags|pheap->Flags)&HEAP_ZERO_MEMORY)
+ memset(pmem + oldsize, 0, size-oldsize);
+ __HeapFree(pheap, flags, pold);
+ return pmem;
+ }
+ else
+ return NULL;
+ }
+ }
+ return NULL;
+}
+
+/*********************************************************************
+* __HeapFree *
+* *
+* frees a range of memory from the heap *
+*********************************************************************/
+
+static BOOL __HeapFree(PHEAP pheap, ULONG flags, LPVOID ptr)
+{
+ PHEAP_BLOCK pfree=(PHEAP_BLOCK)((LPVOID)ptr-HEAP_ADMIN_SIZE);
+ PHEAP_BLOCK pprev;
+ PHEAP_BLOCK pnext;
+ LPVOID decommitstart;
+ LPVOID decommitend;
+
+ /* check that this is a valid allocated block */
+ if(!HEAP_ISALLOC(pfree))
+ return FALSE;
+
+ pfree->Size = HEAP_RSIZE(pfree) | HEAP_FREE_TAG;
+
+ /* if there is a free region of memory before us, join it */
+ pprev=HEAP_PREV(pfree);
+ pnext=HEAP_NEXT(pfree);
+ if((pprev!=pfree) && HEAP_ISFREE(pprev))
+ {
+ pprev->Size = (HEAP_SIZE(pprev)+HEAP_SIZE(pfree) + HEAP_ADMIN_SIZE) |
+ HEAP_FREE_TAG;
+ if((LPVOID) pnext<pheap->End)
+ pnext->PrevSize=(LPVOID)pnext-(LPVOID)pprev;
+
+ pfree->Size=0;
+ pfree->PrevSize=0;
+ pfree=pprev;
+ }
+ /* if there is a free region of memory after us, join it */
+ if(((LPVOID) pnext< pheap->End)&& HEAP_ISFREE(pnext))
+ {
+ pfree->Size = (HEAP_SIZE(pfree)+HEAP_SIZE(pnext) + HEAP_ADMIN_SIZE) |
+ HEAP_FREE_TAG;
+
+ pnext->Size=0;
+ pnext->PrevSize=0;
+
+ pnext=HEAP_NEXT(pfree);
+ if((LPVOID) pnext< pheap->End)
+ pnext->PrevSize=(LPVOID)pnext-(LPVOID)pfree;
+ }
+
+ /* decommit unnecessary memory */
+ decommitstart=(LPVOID) ROUNDUP((ULONG) pfree+HEAP_ADMIN_SIZE ,PAGESIZE);
+ decommitend =(LPVOID) ROUNDDOWN((ULONG) pfree+HEAP_ADMIN_SIZE+
+ HEAP_SIZE(pfree), PAGESIZE);
+ if(decommitstart<decommitend)
+ __HeapDecommit(pheap, decommitstart, decommitend);
+
+ return TRUE;
+}
+
+/*********************************************************************
+* __HeapAllocSub *
+* *
+* allocates a range of memory that is used to allocate small *
+* fragments *
+*********************************************************************/
+PHEAP_SUBALLOC __HeapAllocSub(PHEAP pheap, PHEAP_BUCKET pbucket)
+{
+ INT i;
+ INT add;
+ PHEAP_SUBALLOC psub;
+ PHEAP_FRAGMENT pprev;
+ PHEAP_FRAGMENT pnext;
+ PHEAP_FRAGMENT palloc;
+
+ psub=(PHEAP_SUBALLOC) __HeapAlloc(pheap, 0, pbucket->TotalSize,
+ HEAP_SUB_TAG);
+ if(!psub)
+ return NULL;
+
+ /* initialize suballoc */
+ palloc=(PHEAP_FRAGMENT) ((LPVOID)psub + sizeof(HEAP_SUBALLOC));
+ psub->FirstFree=palloc;
+ psub->NumberFree=pbucket->Number;
+ psub->Bitmap=0;
+ psub->Next=pbucket->FirstFree;
+ psub->Prev=NULL;
+ psub->Bucket=pbucket;
+ pbucket->FirstFree=psub;
+
+ /* initialize free fragments */
+ add=pbucket->Size+HEAP_FRAG_ADMIN_SIZE;
+ pprev=NULL;
+ for(i=0;i<pbucket->Number;i++)
+ {
+ pnext=(PHEAP_FRAGMENT)((LPVOID)palloc+add);
+ palloc->Magic=HEAP_FRAG_MAGIC;
+ palloc->Number=i;
+ palloc->Size=pbucket->Size;
+ palloc->Sub=psub;
+ palloc->FreeNext=pnext;
+ palloc->FreePrev=pprev;
+ pprev=palloc;
+ palloc=pnext;
+ }
+ pprev->FreeNext=NULL;
+ return psub;
+}
+
+/*********************************************************************
+* __HeapAllocFragment *
+* *
+* allocates a small fragment of memory from the heap *
+*********************************************************************/
+static LPVOID __HeapAllocFragment(PHEAP pheap, ULONG flags, ULONG size )
+{
+ PHEAP_BUCKET pbucket;
+ PHEAP_SUBALLOC psub;
+ PHEAP_FRAGMENT palloc;
+ INT nalloc;
+
+ DPRINT("__HeapAllocFragment(pheap %x, flags %d, size %d)\n",
+ pheap,flags,size);
+
+ size = size + HEAP_FRAG_ADMIN_SIZE;
+
+ /* get bucket size */
+ pbucket=pheap->Bucket;
+ while(size>pbucket->Size)
+ {
+ DPRINT("pbucket->Size %d\n",pbucket->Size);
+ pbucket++;
+ }
+ /* get suballoc */
+ psub = pbucket->FirstFree;
+ if(!psub)
+ psub = __HeapAllocSub(pheap, pbucket);
+ if(!psub)
+ return NULL;
+
+ /* do our bookkeeping */
+ palloc = psub->FirstFree;
+ psub->FirstFree = palloc->FreeNext;
+ nalloc = palloc->Number;
+ psub->NumberFree--;
+ psub->Bitmap|=(1<<nalloc);
+
+ /* advance freelist */
+ if(!psub->NumberFree)
+ pbucket->FirstFree=psub->Next;
+
+ /* initialize allocated block */
+ palloc->Magic=HEAP_FRAG_MAGIC;
+ palloc->Size=size;
+
+ if((flags|pheap->Flags)&HEAP_ZERO_MEMORY)
+ memset((LPVOID)palloc+HEAP_FRAG_ADMIN_SIZE, 0, pbucket->Size);
+ return (LPVOID) palloc+HEAP_FRAG_ADMIN_SIZE;
+}
+
+/*********************************************************************
+* __HeapReAllocFragment *
+* *
+* reallocates a small fragment of memory *
+*********************************************************************/
+static LPVOID __HeapReAllocFragment(PHEAP pheap, ULONG flags,
+ LPVOID pold, ULONG size )
+{
+ PHEAP_BUCKET pbucket;
+ PHEAP_SUBALLOC psub;
+ PHEAP_FRAGMENT pfrag=(PHEAP_FRAGMENT)
+ ((LPVOID)pold-HEAP_FRAG_ADMIN_SIZE);
+ LPVOID pmem;
+
+ /* sanity checks */
+ if(pfrag->Magic!=HEAP_FRAG_MAGIC)
+ return NULL;
+
+ /* get bucket size */
+ psub=pfrag->Sub;
+ pbucket=psub->Bucket;
+ if(size<=pbucket->Size)
+ {
+ pfrag->Size=size;
+ return pold;
+ }
+ else
+ {
+ if((flags&HEAP_REALLOC_IN_PLACE_ONLY)==0)
+ {
+ /* alloc a new piece of memory */
+ if(size>HEAP_FRAGMENT_THRESHOLD)
+ pmem=__HeapAlloc(pheap, flags, size, HEAP_NORMAL_TAG);
+ else
+ pmem=__HeapAllocFragment(pheap, flags, size);
+
+ if(pmem)
+ RtlCopyMemory(pmem, pold, size);
+ if((flags|pheap->Flags)&HEAP_ZERO_MEMORY)
+ memset(pmem+pfrag->Size, 0, size-pfrag->Size);
+
+ __HeapFreeFragment(pheap, flags, pold);
+ return pmem;
+ }
+ }
+ return NULL;
+}
+
+/*********************************************************************
+* __HeapFreeFragment *
+* *
+* frees a small fragment of memory *
+*********************************************************************/
+static BOOL __HeapFreeFragment(PHEAP pheap, ULONG flags, LPVOID pfree )
+{
+ PHEAP_BUCKET pbucket;
+ PHEAP_SUBALLOC psub;
+ PHEAP_FRAGMENT pfrag=(PHEAP_FRAGMENT)
+ ((DWORD)pfree - HEAP_FRAG_ADMIN_SIZE);
+ INT nalloc;
+
+ /* sanity checks */
+ if(pfrag->Magic!=HEAP_FRAG_MAGIC)
+ return FALSE;
+
+ /* get bucket size */
+ psub=pfrag->Sub;
+ pbucket=psub->Bucket;
+
+ nalloc=pfrag->Number;
+ if((psub->Bitmap&(1<<nalloc))==0)
+ return FALSE;
+ psub->NumberFree++;
+ if(psub->NumberFree==pbucket->Number)
+ {
+ /* free suballoc */
+ if(psub==pbucket->FirstFree)
+ pbucket->FirstFree=psub->Next;
+ if(psub->Prev)
+ psub->Prev->Next=psub->Next;
+ if(psub->Next)
+ psub->Next->Prev=psub->Prev;
+ if(!__HeapFree(pheap, flags, psub))
+ return FALSE;
+ }
+ else
+ {
+ /* free fragment */
+ psub->Bitmap&= ~(1<<nalloc);
+
+ if(psub->FirstFree)
+ {
+ pfrag->FreeNext = psub->FirstFree;
+ pfrag->FreePrev = NULL;
+ psub->FirstFree->FreePrev = pfrag;
+ psub->FirstFree = pfrag;
+ }
+ else
+ {
+ psub->FirstFree=pfrag;
+ pfrag->FreePrev=NULL;
+ pfrag->FreeNext=NULL;
+ }
+ }
+
+ return TRUE;
+}
+
+/*********************************************************************
+* __HeapPrepare *
+* *
+* Fills in all the data structures of a heap *
+*********************************************************************/
+PHEAP __HeapPrepare(LPVOID base, ULONG minsize, ULONG maxsize, ULONG flags)
+{
+ PHEAP pheap=(PHEAP) base;
+
+ DPRINT("__HeapPrepare(base %x, minsize %d, maxsize %d, flags %x)\n",
+ base,minsize,maxsize,flags);
+
+ pheap->Magic=MAGIC_HEAP;
+ pheap->End= ((LPVOID)pheap)+minsize;
+ pheap->Flags=flags;
+ pheap->LastBlock=(LPVOID)pheap + PAGESIZE;
+ RtlCopyMemory(pheap->Bucket,
+ __HeapDefaultBuckets,
+ sizeof(__HeapDefaultBuckets));
+ if (__ProcessHeap)
+ {
+ pheap->NextHeap=__ProcessHeap->NextHeap;
+ __ProcessHeap->NextHeap=pheap;
+ }
+ else
+ {
+ pheap->NextHeap=0;
+ __ProcessHeap=pheap;
+ }
+ RtlInitializeCriticalSection(&(pheap->Synchronize));
+ pheap->Start.Size= (minsize-sizeof(HEAP))|HEAP_FREE_TAG;
+ pheap->Start.PrevSize =0;
+
+ return pheap;
+}
+
+/*********************************************************************
+* __HeapInit *
+* *
+* Called by __VirtualInit to initialize the default process heap *
+*********************************************************************/
+
+VOID WINAPI __RtlInitHeap(LPVOID base, ULONG minsize, ULONG maxsize)
+{
+ NTSTATUS Result;
+ PHEAP NewHeap;
+ ULONG Length;
+
+ Result = ZwAllocateVirtualMemory(NtCurrentProcess(),
+ &base,
+ 0,
+ &maxsize,
+ MEM_RESERVE,
+ PAGE_READWRITE);
+ NewHeap = base;
+
+ Length = PAGESIZE;
+ ZwAllocateVirtualMemory(NtCurrentProcess(),
+ (PVOID*)&NewHeap,
+ 0,
+ &Length,
+ MEM_COMMIT,
+ PAGE_READWRITE);
+ __HeapPrepare(NewHeap, minsize, maxsize, 0);
+ __ProcessHeap = NewHeap;
+}
+
+
+/*********************************************************************
+* HeapCreate -- KERNEL32 *
+*********************************************************************/
+HANDLE STDCALL RtlCreateHeap(ULONG Flags,
+ PVOID BaseAddress,
+ ULONG SizeToReserve,
+ ULONG SizeToCommit,
+ PVOID Unknown,
+ PRTL_HEAP_DEFINITION Definition)
+{
+ NTSTATUS Status;
+
+ DPRINT("RtlHeapCreate( 0x%lX, 0x%lX, 0x%lX )\n", Flags,
+ SizeToReserve, SizeToCommit);
+
+ Status = ZwAllocateVirtualMemory(NtCurrentProcess(),
+ &BaseAddress,
+ 0,
+ &SizeToReserve,
+ MEM_TOP_DOWN | MEM_RESERVE,
+ PAGE_READWRITE);
+ Status = ZwAllocateVirtualMemory(NtCurrentProcess(),
+ &BaseAddress,
+ 0,
+ &SizeToCommit,
+ MEM_COMMIT,
+ PAGE_READWRITE);
+
+ return (HANDLE) __HeapPrepare(BaseAddress,
+ SizeToCommit,
+ SizeToReserve,
+ Flags);
+}
+
+/*********************************************************************
+* HeapDestroy -- KERNEL32 *
+*********************************************************************/
+BOOL WINAPI RtlDestroyHeap(HANDLE hheap)
+{
+ PHEAP pheap=(PHEAP) hheap;
+ ULONG Length;
+
+ DPRINT("RtlDestroyHeap( 0x%lX )\n", (ULONG) hheap );
+
+ if (pheap->Magic != MAGIC_HEAP)
+ return FALSE;
+
+ RtlDeleteCriticalSection(&(pheap->Synchronize));
+
+ Length = 0;
+ ZwFreeVirtualMemory(NtCurrentProcess(),
+ (PVOID*)&pheap,
+ &Length,
+ MEM_RELEASE);
+
+ return TRUE;
+}
+
+/*********************************************************************
+* HeapAlloc -- KERNEL32 *
+*********************************************************************/
+PVOID STDCALL RtlAllocateHeap(HANDLE Heap,
+ ULONG Flags,
+ ULONG Size)
+{
+ PHEAP pheap=Heap;
+ LPVOID retval;
+
+ DPRINT("HeapAlloc(hheap 0x%lX, flags 0x%lX, size 0x%lX )\n",
+ (ULONG) Heap, Flags, (ULONG) Size );
+#ifdef HEAP_VALIDATE
+ HeapValidate(Heap, 0, 0);
+#endif
+ if(( Flags | pheap->Flags) & HEAP_NO_SERIALIZE )
+ RtlEnterCriticalSection(&(pheap->Synchronize));
+
+ if(Size>HEAP_FRAGMENT_THRESHOLD)
+ retval=__HeapAlloc(pheap, Flags, Size, HEAP_NORMAL_TAG);
+ else
+ retval=__HeapAllocFragment(pheap, Flags, Size);
+
+ if( (Flags | pheap->Flags) & HEAP_NO_SERIALIZE )
+ RtlLeaveCriticalSection(&(pheap->Synchronize));
+
+ DPRINT("HeapAlloc returns 0x%lX\n", (ULONG) retval);
+
+ HeapValidate(Heap, 0, 0);
+ return retval;
+
+
+}
+
+/*********************************************************************
+* HeapReAlloc -- KERNEL32 *
+*********************************************************************/
+LPVOID STDCALL RtlReAllocHeap(HANDLE hheap, DWORD flags, LPVOID ptr,
+ DWORD size)
+{
+
+ PHEAP pheap=hheap;
+ PHEAP_BLOCK pfree=((PHEAP_BLOCK)ptr-1);
+ LPVOID retval;
+
+ DPRINT("HeapReAlloc( 0x%lX, 0x%lX, 0x%lX, 0x%lX )\n",
+ (ULONG) hheap, flags, (ULONG) ptr, size );
+#ifdef HEAP_VALIDATE
+ HeapValidate(hheap, 0, 0);
+#endif
+ if(( flags | pheap->Flags) & HEAP_NO_SERIALIZE )
+ RtlEnterCriticalSection(&(pheap->Synchronize));
+
+ if(HEAP_ISNORMAL(pfree))
+ retval=__HeapReAlloc(pheap, flags, ptr, size);
+ else if(HEAP_ISFRAG(pfree))
+ retval=__HeapReAllocFragment(pheap, flags, ptr, size);
+ else
+ retval = NULL;
+
+ if( (flags| pheap->Flags) & HEAP_NO_SERIALIZE )
+ RtlLeaveCriticalSection(&(pheap->Synchronize));
+
+ return retval;
+
+
+}
+
+/*********************************************************************
+* HeapFree -- KERNEL32 *
+********************************************************************/
+BOOLEAN STDCALL RtlFreeHeap(HANDLE Heap, ULONG Flags, PVOID Address)
+{
+
+ PHEAP pheap=Heap;
+ PHEAP_BLOCK pfree=(PHEAP_BLOCK)((DWORD)Address-HEAP_ADMIN_SIZE);
+ BOOL retval;
+
+ DPRINT("HeapFree( 0x%lX, 0x%lX, 0x%lX )\n",
+ (ULONG) Heap, Flags, (ULONG) Address );
+#ifdef HEAP_VALIDATE
+ HeapValidate(Heap, 0, 0);
+#endif
+ if(( Flags | pheap->Flags) & HEAP_NO_SERIALIZE )
+ RtlEnterCriticalSection(&(pheap->Synchronize));
+
+ if(HEAP_ISNORMAL(pfree))
+ {
+ retval = __HeapFree(pheap, Flags, Address);
+ }
+ else if(HEAP_ISFRAG(pfree))
+ {
+ retval = __HeapFreeFragment(pheap, Flags, Address);
+ }
+ else
+ {
+ retval = FALSE;
+ }
+
+ if( (Flags| pheap->Flags) & HEAP_NO_SERIALIZE )
+ RtlLeaveCriticalSection(&(pheap->Synchronize));
+
+ return retval;
+
+}
+
+/*********************************************************************
+* GetProcessHeap -- KERNEL32 *
+*********************************************************************/
+HANDLE WINAPI GetProcessHeap(VOID)
+{
+ DPRINT("GetProcessHeap()\n");
+ return (HANDLE) __ProcessHeap;
+}
+
+/********************************************************************
+* GetProcessHeaps -- KERNEL32 *
+* *
+* NOTE in Win95 this function is not implemented and just returns *
+* ERROR_CALL_NOT_IMPLEMENTED *
+********************************************************************/
+DWORD WINAPI RtlEnumProcessHeaps(DWORD maxheaps, PHANDLE phandles )
+{
+ DWORD retval;
+ PHEAP pheap;
+
+ DPRINT("GetProcessHeaps( %u, 0x%lX )\n", maxheaps, (ULONG) phandles );
+
+ pheap= __ProcessHeap;
+ retval=0;
+ while((pheap)&&(maxheaps))
+ {
+ *phandles=pheap;
+ phandles++;
+ maxheaps--;
+ retval++;
+ pheap=pheap->NextHeap;
+ }
+ while(pheap)
+ {
+ retval++;
+ pheap=pheap->NextHeap;
+ }
+
+
+ return retval;
+}
+
+/*********************************************************************
+* HeapLock -- KERNEL32 *
+*********************************************************************/
+
+BOOL WINAPI RtlLockHeap(HANDLE hheap)
+{
+ PHEAP pheap=hheap;
+
+ DPRINT("HeapLock( 0x%lX )\n", (ULONG) hheap );
+
+ RtlEnterCriticalSection(&(pheap->Synchronize));
+ return TRUE;
+}
+
+/*********************************************************************
+* HeapUnlock -- KERNEL32 *
+*********************************************************************/
+
+BOOL WINAPI RtlUnlockHeap(HANDLE hheap)
+{
+ PHEAP pheap=hheap;
+
+ DPRINT("HeapUnlock( 0x%lX )\n", (ULONG) hheap );
+
+ RtlLeaveCriticalSection(&(pheap->Synchronize));
+ return TRUE;
+}
+
+/*********************************************************************
+* HeapCompact -- KERNEL32 *
+* *
+* NT uses this function to compact moveable blocks and other things *
+* Here it does not compact, but it finds the largest free region *
+*********************************************************************/
+
+UINT RtlCompactHeap(HANDLE hheap, DWORD flags)
+{
+ PHEAP pheap=hheap;
+ PHEAP_BLOCK pfree;
+ ULONG freesize;
+ ULONG largestfree;
+
+ if(( flags | pheap->Flags) & HEAP_NO_SERIALIZE )
+ RtlEnterCriticalSection(&(pheap->Synchronize));
+
+ pfree=&(pheap->Start);
+ /* look for the largest free region of memory */
+ largestfree=0;
+ do
+ {
+ freesize=HEAP_SIZE(pfree);
+ if(HEAP_ISFREE(pfree) && freesize>largestfree)
+ largestfree=freesize;
+
+ pfree=HEAP_NEXT(pfree);
+ }
+ while( (LPVOID)pfree < pheap->End );
+
+ if( (flags| pheap->Flags) & HEAP_NO_SERIALIZE )
+ RtlLeaveCriticalSection(&(pheap->Synchronize));
+
+ return largestfree;
+}
+
+/*********************************************************************
+* HeapSize -- KERNEL32 *
+*********************************************************************/
+DWORD WINAPI HeapSize(HANDLE hheap, DWORD flags, LPCVOID pmem)
+{
+ PHEAP pheap=(PHEAP) hheap;
+ PHEAP_BLOCK palloc=((PHEAP_BLOCK)pmem-1);
+ DWORD retval=0;
+
+ DPRINT("HeapSize( 0x%lX, 0x%lX, 0x%lX )\n",
+ (ULONG) hheap, flags, (ULONG) pmem );
+
+ if (pheap->Magic != MAGIC_HEAP)
+ {
+ return 0;
+ }
+
+ if(( flags | pheap->Flags) & HEAP_NO_SERIALIZE )
+ RtlEnterCriticalSection(&(pheap->Synchronize));
+
+ if((pmem> (LPVOID)pheap)&&(pmem < pheap->End))
+ {
+ if(HEAP_ISALLOC(palloc))
+ retval=HEAP_SIZE(palloc); /* normal allocation */
+ else if(HEAP_ISFRAG(palloc))
+ retval=HEAP_FRAG_SIZE(palloc); /* fragment */
+ else
+ {
+ retval = -1;
+ }
+ }
+
+ if( (flags| pheap->Flags) & HEAP_NO_SERIALIZE )
+ RtlLeaveCriticalSection(&(pheap->Synchronize));
+
+ return retval;
+}
+
+/*********************************************************************
+* HeapValidate -- KERNEL32 *
+* *
+* NOTE: only implemented in NT *
+*********************************************************************/
+BOOL WINAPI HeapValidate(HANDLE hheap, DWORD flags, LPCVOID pmem)
+{
+ PHEAP pheap=(PHEAP)hheap;
+ PHEAP_BLOCK pcheck;
+ PHEAP_BLOCK pprev;
+ PHEAP_BLOCK pnext;
+ PHEAP_SUBALLOC psub;
+ PHEAP_FRAGMENT pfrag;
+ PHEAP_FRAGMENT pnextfrag;
+ PHEAP_FRAGMENT pprevfrag;
+ PHEAP_BUCKET pbucket;
+ INT i;
+ INT number;
+ INT add;
+
+ if(( flags | pheap->Flags) & HEAP_NO_SERIALIZE )
+ RtlEnterCriticalSection(&(pheap->Synchronize));
+
+ if(pmem==NULL)
+ {
+ pcheck=&(pheap->Start);
+ pprev=NULL;
+ /* verify all blocks */
+ do
+ {
+ pnext=HEAP_NEXT(pcheck);
+ if((pprev)&&(HEAP_PREV(pcheck)!=pprev))
+ {
+ DPRINT("HeapValidate: linked list invalid, region 0x%lX,"
+ " previous region 0x%lX, list says 0x%lX\n",
+ (ULONG)pcheck, (ULONG)pprev, (ULONG) HEAP_PREV(pcheck));
+ return FALSE;
+ }
+ if(HEAP_ISSUB(pcheck))
+ {
+
+ /* check fragments */
+ psub=(PHEAP_SUBALLOC) ((PHEAP_BLOCK)pcheck+1);
+ pbucket=psub->Bucket;
+ pfrag=(PHEAP_FRAGMENT) ((LPVOID)psub + sizeof(HEAP_SUBALLOC));
+
+ if(psub->NumberFree>pbucket->Number)
+ return FALSE;
+
+ add=pbucket->Size+HEAP_FRAG_ADMIN_SIZE;
+ pprevfrag=NULL;
+ number=0;
+ for(i=0;i<pbucket->Number;i++)
+ {
+ pnextfrag=(PHEAP_FRAGMENT)((LPVOID)pfrag+add);
+ if(pfrag->Magic!=HEAP_FRAG_MAGIC)
+ {
+ DPRINT("HeapValidate: fragment %d magic invalid, region 0x%lX,"
+ " previous region 0x%lX\n", i, (ULONG)pcheck, (ULONG)pprev);
+ return FALSE;
+ }
+ if(pfrag->Number!=i)
+ {
+ DPRINT("HeapValidate: fragment %d number invalid, region 0x%lX,"
+ " previous region 0x%lX\n", i, (ULONG)pcheck, (ULONG)pprev);
+ return FALSE;
+ }
+ if((psub->Bitmap&(1<<i))==0)
+ number++;
+ if(pfrag->Sub!=psub)
+ {
+ DPRINT("HeapValidate: fragment %d suballoc invalid, region 0x%lX,"
+ " previous region 0x%lX\n", i, (ULONG)pcheck, (ULONG)pprev);
+ return FALSE;
+ }
+ pprevfrag=pfrag;
+ pfrag=pnextfrag;
+ }
+ if(number!=psub->NumberFree)
+ {
+ DPRINT("HeapValidate: invalid number of free fragments, region 0x%lX,"
+ " previous region 0x%lX\n", (ULONG)pcheck, (ULONG)pprev);
+ return FALSE;
+ }
+ DPRINT("HeapValidate: [0x%08lX-0x%08lX] suballocated,"
+ " bucket size=%d, bitmap=0x%08lX\n",
+ (ULONG) pcheck, (ULONG) pnext, pbucket->Size, psub->Bitmap);
+ }
+ else if(HEAP_ISFREE(pcheck))
+ {
+ if(HEAP_RSIZE(pcheck)!=HEAP_SIZE(pcheck))
+ {
+ DPRINT("HeapValidate: invalid size of free region 0x%lX,"
+ " previous region 0x%lX\n",
+ (ULONG) pcheck, (ULONG) pprev);
+ return FALSE;
+ }
+ DPRINT("HeapValidate: [0x%08lX-0x%08lX] free\n",
+ (ULONG) pcheck, (ULONG) pnext );
+ }
+ else if(HEAP_ISNORMAL(pcheck))
+ {
+ DPRINT("HeapValidate: [0x%08lX-0x%08lX] allocated\n",
+ (ULONG) pcheck, (ULONG) pnext );
+ }
+ else
+ {
+ DPRINT("HeapValidate: invalid tag %x, region 0x%lX,"
+ " previous region 0x%lX\n", pcheck->Size>>28,
+ (ULONG)pcheck, (ULONG)pprev);
+ return FALSE;
+ }
+ pprev=pcheck;
+ pcheck=HEAP_NEXT(pcheck);
+ }
+ while( (LPVOID)pcheck < pheap->End );
+ }
+
+ if( (flags| pheap->Flags) & HEAP_NO_SERIALIZE )
+ RtlLeaveCriticalSection(&(pheap->Synchronize));
+
+ return TRUE;
+}
+
--- /dev/null
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS kernel
+ * FILE: lib/ntdll/rtl/largeint.c
+ * PURPOSE: Large integer operations
+ * UPDATE HISTORY:
+ * Created 22/05/98
+ * 08/30/98 RJJ Implemented several functions
+ */
+
+/* INCLUDES *****************************************************************/
+
+#include <internal/ke.h>
+#include <internal/linkage.h>
+#include <ddk/ntddk.h>
+
+#define NDEBUG
+#include <internal/debug.h>
+
+typedef long long int LLI, *PLLI;
+typedef unsigned long long int ULLI, *PULLI;
+
+#define LIFromLLI(X) (*(PLARGE_INTEGER)&(X))
+#define LLIFromLI(X) (*(PLLI)&(X))
+#define ULIFromULLI(X) (*(PULARGE_INTEGER)&(X))
+
+/* FUNCTIONS *****************************************************************/
+
+LARGE_INTEGER RtlLargeIntegerDivide(LARGE_INTEGER Dividend,
+ LARGE_INTEGER Divisor,
+ PLARGE_INTEGER Remainder)
+{
+}
+
+LARGE_INTEGER
+RtlConvertLongToLargeInteger(LONG SignedInteger)
+{
+ LARGE_INTEGER RC;
+
+ LARGE_INTEGER_QUAD_PART(RC) = SignedInteger;
+
+ return RC;
+}
+
+LARGE_INTEGER
+RtlConvertUlongToLargeInteger(ULONG UnsignedInteger)
+{
+ LARGE_INTEGER RC;
+
+ LARGE_INTEGER_QUAD_PART(RC) = UnsignedInteger;
+
+ return RC;
+}
+
+LARGE_INTEGER
+RtlEnlargedIntegerMultiply(LONG Multiplicand,
+ LONG Multiplier)
+{
+ LARGE_INTEGER RC;
+
+ LARGE_INTEGER_QUAD_PART(RC) = (LONGLONG) Multiplicand * Multiplier;
+
+ return RC;
+}
+
+LARGE_INTEGER RtlEnlargedUnsignedMultiply(ULONG Multiplicand,
+ ULONG Multiplier)
+{
+ LARGE_INTEGER RC;
+
+ LARGE_INTEGER_QUAD_PART(RC) = (ULONGLONG) Multiplicand * Multiplier;
+
+ return RC;
+}
+
+LARGE_INTEGER
+RtlExtendedIntegerMultiply(LARGE_INTEGER Multiplicand,
+ LONG Multiplier)
+{
+ LARGE_INTEGER RC;
+
+ LARGE_INTEGER_QUAD_PART(RC) = LARGE_INTEGER_QUAD_PART(Multiplicand) *
+ Multiplier;
+
+ return RC;
+}
+
+LARGE_INTEGER
+RtlLargeIntegerAdd(LARGE_INTEGER Addend1,
+ LARGE_INTEGER Addend2)
+{
+ LARGE_INTEGER RC;
+
+ RC = LARGE_INTEGER_QUAD_PART(Addend1) +
+ LARGE_INTEGER_QUAD_PART(Addend2);
+
+ return RC;
+}
+
+VOID RtlLargeIntegerAnd(PLARGE_INTEGER Result,
+ LARGE_INTEGER Source,
+ LARGE_INTEGER Mask)
+{
+ LARGE_INTEGER_QUAD_PART(*Result) = LARGE_INTEGER_QUAD_PART(Source) &
+ LARGE_INTEGER_QUAD_PART(Mask);
+}
+
+BOOLEAN
+RtlLargeIntegerEqualTo(LARGE_INTEGER Operand1,
+ LARGE_INTEGER Operand2)
+{
+ return LARGE_INTEGER_QUAD_PART(Operand1) ==
+ LARGE_INTEGER_QUAD_PART(Operand2);
+#if 0
+ return Operand1.HighPart == Operand2.HighPart &&
+ Operand1.LowPart == Operand2.LowPart;
+#endif
+}
+
+BOOLEAN
+RtlLargeIntegerEqualToZero(LARGE_INTEGER Operand)
+{
+ return LARGE_INTEGER_QUAD_PART(Operand) == 0 ;
+}
+
+BOOLEAN
+RtlLargeIntegerGreaterThan(LARGE_INTEGER Operand1,
+ LARGE_INTEGER Operand2)
+{
+ return LARGE_INTEGER_QUAD_PART(Operand1) >
+ LARGE_INTEGER_QUAD_PART(Operand2);
+#if 0
+ return Operand1.HighPart > Operand2.HighPart ||
+ (Operand1.HighPart == Operand2.HighPart &&
+ Operand1.LowPart > Operand2.LowPart);
+#endif
+}
+
+BOOLEAN
+RtlLargeIntegerGreaterThanOrEqualTo(LARGE_INTEGER Operand1,
+ LARGE_INTEGER Operand2)
+{
+ return LARGE_INTEGER_QUAD_PART(Operand1) >=
+ LARGE_INTEGER_QUAD_PART(Operand2);
+#if 0
+ return Operand1.HighPart > Operand2.HighPart ||
+ (Operand1.HighPart == Operand2.HighPart &&
+ Operand1.LowPart >= Operand2.LowPart);
+#endif
+}
+
+BOOLEAN
+RtlLargeIntegerGreaterThanOrEqualToZero(LARGE_INTEGER Operand1)
+{
+ return LARGE_INTEGER_QUAD_PART(Operand1) > 0;
+#if 0
+ return Operand1.HighPart >= 0;
+#endif
+}
+
+BOOLEAN
+RtlLargeIntegerGreaterThanZero(LARGE_INTEGER Operand1)
+{
+ return LARGE_INTEGER_QUAD_PART(Operand1) >= 0;
+#if 0
+ return Operand1.HighPart > 0 ||
+ (Operand1.HighPart == 0 && Operand1.LowPart > 0);
+#endif
+}
+
+BOOLEAN
+RtlLargeIntegerLessThan(LARGE_INTEGER Operand1,
+ LARGE_INTEGER Operand2)
+{
+ return LARGE_INTEGER_QUAD_PART(Operand1) <
+ LARGE_INTEGER_QUAD_PART(Operand2);
+#if 0
+ return Operand1.HighPart < Operand2.HighPart ||
+ (Operand1.HighPart == Operand2.HighPart &&
+ Operand1.LowPart < Operand2.LowPart);
+#endif
+}
+
+BOOLEAN
+RtlLargeIntegerLessThanOrEqualTo(LARGE_INTEGER Operand1,
+ LARGE_INTEGER Operand2)
+{
+ return LARGE_INTEGER_QUAD_PART(Operand1) <=
+ LARGE_INTEGER_QUAD_PART(Operand2);
+#if 0
+ return Operand1.HighPart < Operand2.HighPart ||
+ (Operand1.HighPart == Operand2.HighPart &&
+ Operand1.LowPart <= Operand2.LowPart);
+#endif
+}
+
+BOOLEAN
+RtlLargeIntegerLessThanOrEqualToZero(LARGE_INTEGER Operand)
+{
+ return LARGE_INTEGER_QUAD_PART(Operand) <= 0;
+#if 0
+ return Operand.HighPart < 0 ||
+ (Operand.HighPart == 0 && Operand.LowPart == 0);
+#endif
+}
+
+BOOLEAN
+RtlLargeIntegerLessThanZero(LARGE_INTEGER Operand)
+{
+ return LARGE_INTEGER_QUAD_PART(Operand) < 0;
+#if 0
+ return Operand.HighPart < 0;
+#endif
+}
+
+LARGE_INTEGER RtlLargeIntegerNegate(LARGE_INTEGER Subtrahend)
+{
+ LARGE_INTEGER RC;
+
+ LARGE_INTEGER_QUAD_PART(RC) = - LARGE_INTEGER_QUAD_PART(Subtrahend);
+
+ return RC;
+}
+
+BOOLEAN
+RtlLargeIntegerNotEqualTo(LARGE_INTEGER Operand1,
+ LARGE_INTEGER Operand2)
+{
+ return LARGE_INTEGER_QUAD_PART(Operand1) !=
+ LARGE_INTEGER_QUAD_PART(Operand2);
+#if 0
+ return Operand1.LowPart != Operand2.LowPart ||
+ Operand1.HighPart != Operand2.HighPart;
+#endif
+}
+
+BOOLEAN
+RtlLargeIntegerNotEqualToZero(LARGE_INTEGER Operand)
+{
+ return LARGE_INTEGER_QUAD_PART(Operand) != 0;
+#if 0
+ return Operand.LowPart != 0 || Operand.HighPart != 0;
+#endif
+}
+
+LARGE_INTEGER RtlLargeIntegerShiftLeft(LARGE_INTEGER LargeInteger,
+ CCHAR ShiftCount)
+{
+ LARGE_INTEGER RC;
+
+ LARGE_INTEGER_QUAD_PART(RC) = LARGE_INTEGER_QUAD_PART(LargeInteger) <<
+ ShiftCount;
+
+ return RC;
+}
+
+LARGE_INTEGER RtlLargeIntegerShiftRight(LARGE_INTEGER LargeInteger,
+ CCHAR ShiftCount)
+{
+ LARGE_INTEGER RC;
+
+ LARGE_INTEGER_QUAD_PART(RC) = LARGE_INTEGER_QUAD_PART(LargeInteger) >>
+ ShiftCount;
+
+ return RC;
+}
+
+LARGE_INTEGER RtlLargeIntegerSubtract(LARGE_INTEGER Minuend,
+ LARGE_INTEGER Subtrahend)
+{
+ LARGE_INTEGER RC;
+
+ RC = LARGE_INTEGER_QUAD_PART(Minuend) - LARGE_INTEGER_QUAD_PART(Subtrahend);
+
+ return RC;
+}
+
--- /dev/null
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS kernel
+ * FILE: kernel/rtl/mem.c
+ * PURPOSE: Memory functions
+ * PROGRAMMER: David Welch (welch@mcmail.com)
+ * UPDATE HISTORY:
+ * Created 22/05/98
+ */
+
+/* INCLUDES *****************************************************************/
+
+#include <ddk/ntddk.h>
+#include <string.h>
+#include <internal/string.h>
+
+#define NDEBUG
+#include <internal/debug.h>
+
+/* FUNCTIONS *****************************************************************/
+
+ULONG RtlCompareMemory(PVOID Source1, PVOID Source2, ULONG Length)
+/*
+ * FUNCTION: Compares blocks of memory and returns the number of equal bytes
+ * ARGUMENTS:
+ * Source1 = Block to compare
+ * Source2 = Block to compare
+ * Length = Number of bytes to compare
+ * RETURNS: Number of equal bytes
+ */
+{
+ int i,total;
+
+ for (i=0,total=0;i<Length;i++)
+ {
+ if ( ((PUCHAR)Source1)[i] == ((PUCHAR)Source2)[i] )
+ {
+ total++;
+ }
+ }
+ return(total);
+}
+
+VOID RtlCopyBytes(PVOID Destination,
+ CONST VOID* Source,
+ ULONG Length)
+{
+ RtlCopyMemory(Destination,Source,Length);
+}
+
+VOID RtlCopyMemory(VOID* Destination, VOID* Source, ULONG Length)
+{
+ DPRINT("RtlCopyMemory(Destination %x Source %x Length %d\n",
+ Destination,Source,Length);
+ memcpy(Destination,Source,Length);
+ DPRINT("*Destination %x\n",*(PULONG)Destination);
+}
+
+VOID RtlFillMemory(PVOID Destination, ULONG Length, UCHAR Fill)
+{
+ memset(Destination,Fill,Length);
+}
+
+VOID RtlZeroMemory(PVOID Destination, ULONG Length)
+{
+ RtlFillMemory(Destination,Length,0);
+}
+
+VOID RtlMoveMemory(PVOID Destination,
+ CONST VOID* Source,
+ ULONG Length)
+{
+ memmove(Destination,Source,Length);
+}
* Created 10/08/98
*/
-#include <base.h>
-#include <wstring.h>
-
#include <ddk/ntddk.h>
-#include <internal/string.h>
-#include <internal/ke.h>
-#include <internal/ctype.h>
-
#define NDEBUG
#include <internal/debug.h>
}
}
-VOID RtlUpperString(PSTRING DestinationString, PSTRING SourceString)
-{
- UNIMPLEMENTED;
-}
-
WCHAR wtoupper(WCHAR c)
{
if((c>='a') && (c<='z')) return c+Aa_Difference;
NTSTATUS RtlAppendUnicodeToString(IN OUT PUNICODE_STRING Destination,
IN PWSTR Source)
{
- unsigned long i, slen=wstrlen(Source);
+ unsigned long i, slen=wcslen(Source);
if(Destination->MaximumLength-Destination->Length-slen<0)
return STATUS_BUFFER_TOO_SMALL;
DestinationString->MaximumLength=0;
DestinationString->Buffer=NULL;
} else {
- DestSize=wstrlen((PWSTR)SourceString);
+ DestSize=wcslen((PWSTR)SourceString);
DestinationString->Length=DestSize;
DestinationString->MaximumLength=DestSize+1;
*/
#include <stdarg.h>
+#include <stdlib.h>
+#include <ctype.h>
#include <internal/debug.h>
-#include <internal/ctype.h>
-#include <internal/string.h>
unsigned long simple_strtoul(const char *cp,char **endp,unsigned int base)
{
return w;
}
-char iswlower(unsigned short w)
+int iswlower(wint_t w)
{
if ( w < L'A' )
return 1;
--- /dev/null
+typedef int size_t;
+
+void * memset(void *src,int val,size_t count)
+{
+ char *char_src = src;
+
+ while(count>0) {
+ *char_src = val;
+ char_src++;
+ count--;
+ }
+ return src;
+}
\ No newline at end of file
--- /dev/null
+/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
+#include <string.h>
+
+char *
+strcat(char *s, const char *append)
+{
+ char *save = s;
+
+ for (; *s; ++s);
+ while ((*s++ = *append++));
+ return save;
+}
--- /dev/null
+/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
+#include <string.h>
+
+int
+strcmp(const char *s1, const char *s2)
+{
+ while (*s1 == *s2)
+ {
+ if (*s1 == 0)
+ return 0;
+ s1++;
+ s2++;
+ }
+ return *(unsigned const char *)s1 - *(unsigned const char *)(s2);
+}
--- /dev/null
+/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
+char* strcpy(char *to, const char *from);
+
+char* strcpy(char *to, const char *from)
+{
+ char *save = to;
+
+ for (; (*to = *from); ++from, ++to);
+ return save;
+}
--- /dev/null
+/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
+#include <string.h>
+#include <ctype.h>
+
+int
+stricmp(const char *s1, const char *s2)
+{
+ while (toupper(*s1) == toupper(*s2))
+ {
+ if (*s1 == 0)
+ return 0;
+ s1++;
+ s2++;
+ }
+ return toupper(*(unsigned const char *)s1) - toupper(*(unsigned const char *)(s2));
+}
--- /dev/null
+/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
+#include <string.h>
+
+
+int
+strncmp(const char *s1, const char *s2, size_t n)
+{
+
+ if (n == 0)
+ return 0;
+ do {
+ if (*s1 != *s2++)
+ return *(unsigned const char *)s1 - *(unsigned const char *)--s2;
+ if (*s1++ == 0)
+ break;
+ } while (--n != 0);
+ return 0;
+}
--- /dev/null
+/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
+#include <string.h>
+
+char *
+strncpy(char *dst, const char *src, size_t n)
+{
+ if (n != 0) {
+ char *d = dst;
+ const char *s = src;
+
+ do {
+ if ((*d++ = *s++) == 0)
+ {
+ while (--n != 0)
+ *d++ = 0;
+ break;
+ }
+ } while (--n != 0);
+ }
+ return dst;
+}
--- /dev/null
+/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
+#include <string.h>
+
+size_t
+strnlen(const char *str, size_t count)
+{
+ const char *s;
+
+ if (str == 0)
+ return 0;
+ for (s = str; *s && count; ++s, count--);
+ return s-str;
+}
+
--- /dev/null
+/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */
+/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
+#include <string.h>
+//#include <libc/unconst.h>
+
+char *
+strrchr(const char *s, int c)
+{
+ char cc = c;
+ const char *sp=(char *)0;
+ while (*s)
+ {
+ if (*s == cc)
+ sp = s;
+ s++;
+ }
+ if (cc == 0)
+ sp = s;
+ return (char *)sp;
+}
+
/* INCLUDES *****************************************************************/
#include <ddk/ntddk.h>
-#include <wstring.h>
+#include <wchar.h>
-#include <internal/debug.h>
-
-wchar_t * ___wcstok = NULL;
+static wchar_t * ___wcstok = NULL;
/* FUNCTIONS *****************************************************************/
-wchar_t *
-wcscat(wchar_t *dest, const wchar_t *src)
+int wcsicmp(const wchar_t* ws1, const wchar_t* ws2)
+{
+}
+
+int wcsnicmp(const wchar_t* ws1, const wchar_t* ws2, size_t size)
+{
+}
+
+wchar_t* wcscat(wchar_t *dest, const wchar_t *src)
{
int i, j;
return(str1);
}
-#if 0
-
-size_t
-wcscspn(const wchar_t *cs, const wchar_t *ct)
-{
- register wchar_t * __res;
- __asm__ __volatile__(
- "cld\n\t"
- "movl %4,%%edi\n\t"
- "repne\n\t"
- "scasw\n\t"
- "notl %%ecx\n\t"
- "decl %%ecx\n\t"
- "movl %%ecx,%%edx\n"
- "1:\tlodsw\n\t"
- "testw %%eax,%%eax\n\t"
- "je 2f\n\t"
- "movl %4,%%edi\n\t"
- "movl %%edx,%%ecx\n\t"
- "repne\n\t"
- "scasw\n\t"
- "jne 1b\n"
- "2:\tdecl %0"
- : "=S" (__res)
- : "a" (0),"c" (0xffffffff),"0" (cs),"g" (ct)
- : "eax","ecx","edx","edi");
-
- return __res-cs;
-}
-
-#else
-
-size_t
-wcscspn(const wchar_t *cs, const wchar_t *ct)
-{
-UNIMPLEMENTED;
-}
-
-#endif
-
-#ifdef i386
-
-int
-wcsicmp(const wchar_t *cs,const wchar_t *ct)
-{
- register int __res;
-
- __asm__ __volatile__(
- "cld\n"
- "1:\tmovw (%%esi), %%eax\n\t"
- "movw (%%edi), %%edx \n\t"
- "cmpw $0x5A, %%eax\n\t"
- "ja 2f\t\n"
- "cmpw $0x40, %%eax\t\n"
- "jbe 2f\t\n"
- "addw $0x20, %%eax\t\n"
- "2:\t cmpw $0x5A, %%edx\t\n"
- "ja 3f\t\n"
- "cmpw $0x40, %%edx\t\n"
- "jbe 3f\t\n"
- "addw $0x20, %%edx\t\n"
- "3:\t inc %%esi\t\n"
- "inc %%esi\t\n"
- "inc %%edi\t\n"
- "inc %%edi\t\n"
- "cmpw %%eax, %%edx\t\n"
- "jne 4f\n\t"
- "cmpw $00, %%eax\n\t"
- "jne 1b\n\t"
- "xorl %%eax,%%eax\n\t"
- "jmp 5f\n"
- "4:\tsbbl %%eax,%%eax\n\t"
- "orw $1,%%eax\n"
- "5:"
- : "=a" (__res)
- : "S" (cs),"D" (ct)
- : "esi","edi");
-
- return __res;
-}
-
-#else
-
-int
-wcsicmp(const wchar_t *cs,const wchar_t *ct)
-{
-UNIMPLEMENTED;
-}
-
-#endif
-size_t
-wcslen(const wchar_t *s)
+size_t wcslen(const wchar_t *s)
{
unsigned int len = 0;
return dest;
}
-#ifdef i386
-
-int
-wcsncmp(const wchar_t *cs, const wchar_t *ct, size_t count)
-{
- register int __res;
-
- __asm__ __volatile__(
- "cld\n"
- "1:\tdecl %3\n\t"
- "js 2f\n\t"
- "lodsw\n\t"
- "scasw\n\t"
- "jne 3f\n\t"
- "testw %%eax,%%eax\n\t"
- "jne 1b\n"
- "2:\txorl %%eax,%%eax\n\t"
- "jmp 4f\n"
- "3:\tsbbl %%eax,%%eax\n\t"
- "orw $1,%%eax\n"
- "4:"
- : "=a" (__res)
- : "S" (cs), "D" (ct), "c" (count)
- : "esi","edi","ecx");
-
- return __res;
-}
-
-#else
-int
-wcsncmp(const wchar_t *cs, const wchar_t *ct, size_t count)
-{
-UNIMPLEMENTED;
-}
-
-#endif
wchar_t* wcsncpy(wchar_t *dest, const wchar_t *src, size_t count)
{
return dest;
}
-#ifdef i386
-
-int
-wcsnicmp(const wchar_t *cs,const wchar_t *ct, size_t count)
-{
- register int __res;
-
- __asm__ __volatile__(
- "cld\n"
- "1:\t decl %3\n\t"
- "js 6f\n\t"
- "movw (%%esi), %%eax\n\t"
- "movw (%%edi), %%edx \n\t"
- "cmpw $0x5A, %%eax\n\t"
- "ja 2f\t\n"
- "cmpw $0x40, %%eax\t\n"
- "jbe 2f\t\n"
- "addw $0x20, %%eax\t\n"
- "2:\t cmpw $0x5A, %%edx\t\n"
- "ja 3f\t\n"
- "cmpw $0x40, %%edx\t\n"
- "jbe 3f\t\n"
- "addw $0x20, %%edx\t\n"
- "3:\t inc %%esi\t\n"
- "inc %%esi\t\n"
- "inc %%edi\t\n"
- "inc %%edi\t\n"
- "cmpw %%eax, %%edx\t\n"
- "jne 4f\n\t"
- "cmpw $00, %%eax\n\t"
- "jne 1b\n\t"
- "6:xorl %%eax,%%eax\n\t"
- "jmp 5f\n"
- "4:\tsbbl %%eax,%%eax\n\t"
- "orw $1,%%eax\n"
- "5:"
- : "=a" (__res)
- : "S" (cs), "D" (ct), "c" (count)
- : "esi", "edi", "ecx");
-
- return __res;
-}
-
-#else
-
-int
-wcsnicmp(const wchar_t *cs,const wchar_t *ct, size_t count)
-{
-UNIMPLEMENTED;
-}
-
-#endif
-
-#ifdef i386
-
-size_t
-wcsnlen(const wchar_t *s, size_t count)
-{
- register int __res;
- __asm__ __volatile__(
- "movl %1,%0\n\t"
- "jmp 2f\n"
- "1:\tcmpw $0,(%0)\n\t"
- "je 3f\n\t"
- "incl %0\n"
- "2:\tdecl %2\n\t"
- "cmpl $-1,%2\n\t"
- "jne 1b\n"
- "3:\tsubl %1,%0"
- : "=a" (__res)
- : "c" (s), "d" (count)
- : "edx");
-
- return __res;
-}
-
-#else
-
-size_t
-wcsnlen(const wchar_t *s, size_t count)
-{
-UNIMPLEMENTED;
-}
-
-#endif
-
-#ifdef i386
-
-wchar_t *
-wcspbrk(const wchar_t *cs, const wchar_t *ct)
-{
- register wchar_t * __res;
- __asm__ __volatile__(
- "cld\n\t"
- "movl %4,%%edi\n\t"
- "repne\n\t"
- "scasw\n\t"
- "notl %%ecx\n\t"
- "decl %%ecx\n\t"
- "movl %%ecx,%%edx\n"
- "1:\tlodsw\n\t"
- "testw %%eax,%%eax\n\t"
- "je 2f\n\t"
- "movl %4,%%edi\n\t"
- "movl %%edx,%%ecx\n\t"
- "repne\n\t"
- "scasw\n\t"
- "jne 1b\n\t"
- "decl %0\n\t"
- "jmp 3f\n"
- "2:\txorl %0,%0\n"
- "3:"
- : "=S" (__res)
- : "a" (0), "c" (0xffffffff), "0" (cs), "g" (ct)
- : "eax", "ecx", "edx", "edi");
-
- return __res;
-}
-
-#else
-
-wchar_t *
-wcspbrk(const wchar_t *cs, const wchar_t *ct)
-{
-UNIMPLEMENTED;
-}
-
-#endif
wchar_t *
wcsrchr(const wchar_t *str, wchar_t ch)
return NULL;
}
-#ifdef i386
-
-size_t
-wcsspn(const wchar_t *cs, const wchar_t *ct)
-{
- register wchar_t * __res;
-
- __asm__ __volatile__(
- "cld\n\t"
- "movl %4,%%edi\n\t"
- "repne\n\t"
- "scasw\n\t"
- "notl %%ecx\n\t"
- "decl %%ecx\n\t"
- "movl %%ecx,%%edx\n"
- "1:\tlodsw\n\t"
- "testw %%eax,%%eax\n\t"
- "je 2f\n\t"
- "movl %4,%%edi\n\t"
- "movl %%edx,%%ecx\n\t"
- "repne\n\t"
- "scasb\n\t"
- "je 1b\n"
- "2:\tdecl %0"
- : "=S" (__res)
- : "a" (0), "c" (0xffffffff), "0" (cs), "g" (ct)
- : "eax", "ecx", "edx", "edi");
-
- return __res-cs;
-}
-
-#else
-
-size_t
-wcsspn(const wchar_t *cs, const wchar_t *ct)
-{
-UNIMPLEMENTED;
-}
-
-#endif
-
-#ifdef i386
-
-wchar_t *
-wcsstr(const wchar_t *cs, const wchar_t *ct)
-{
- register wchar_t * __res;
-
- __asm__ __volatile__(
- "cld\n\t" \
- "movl %4,%%edi\n\t"
- "repne\n\t"
- "scasw\n\t"
- "notl %%ecx\n\t"
- "decl %%ecx\n\t" /* NOTE! This also sets Z if searchstring='' */
- "movl %%ecx,%%edx\n"
- "1:\tmovl %4,%%edi\n\t"
- "movl %%esi,%%eax\n\t"
- "movl %%edx,%%ecx\n\t"
- "repe\n\t"
- "cmpsw\n\t"
- "je 2f\n\t" /* also works for empty string, see above */
- "xchgl %%eax,%%esi\n\t"
- "incl %%esi\n\t"
- "cmpw $0,-1(%%eax)\n\t"
- "jne 1b\n\t"
- "xorl %%eax,%%eax\n\t"
- "2:"
- : "=a" (__res)
- : "0" (0), "c" (0xffffffff), "S" (cs), "g" (ct)
- : "ecx", "edx", "edi", "esi");
-
- return __res;
-}
-
-#else
-
-wchar_t *
-wcsstr(const wchar_t *cs, const wchar_t *ct)
-{
-UNIMPLEMENTED;
-}
-
-#endif
-
-size_t wstrlen(const wchar_t *s)
-{
- return wcslen(s);
-}
-
-#ifdef i386
-
-wchar_t *
-wcstok(wchar_t * s,const wchar_t * ct)
-{
- register wchar_t * __res;
-
- __asm__ __volatile__(
- "testl %1,%1\n\t"
- "jne 1f\n\t"
- "testl %0,%0\n\t"
- "je 8f\n\t"
- "movl %0,%1\n"
- "1:\txorl %0,%0\n\t"
- "movl $-1,%%ecx\n\t"
- "xorl %%eax,%%eax\n\t"
- "cld\n\t"
- "movl %4,%%edi\n\t"
- "repnz\n\t"
- "scasw\n\t"
- "notl %%ecx\n\t"
- "decl %%ecx\n\t"
- "decl %%ecx\n\t"
- "je 7f\n\t" /* empty delimiter-string */
- "movl %%ecx,%%edx\n"
- "2:\tlodsw\n\t"
- "testw %%eax,%%eax\n\t"
- "je 7f\n\t"
- "movl %4,%%edi\n\t"
- "movl %%edx,%%ecx\n\t"
- "repne\n\t"
- "scasw\n\t"
- "je 2b\n\t"
- "decl %1\n\t"
- "decl %1\n\t"
- "cmpw $0,(%1)\n\t"
- "je 7f\n\t"
- "movl %1,%0\n"
- "3:\tlodsw\n\t"
- "testw %%eax,%%eax\n\t"
- "je 5f\n\t"
- "movl %4,%%edi\n\t"
- "movl %%edx,%%ecx\n\t"
- "repne\n\t"
- "scasw\n\t"
- "jne 3b\n\t"
- "decl %1\n\t"
- "decl %1\n\t"
- "decl %1\n\t"
- "decl %1\n\t"
- "cmpw $0,(%1)\n\t"
- "je 5f\n\t"
- "movw $0,(%1)\n\t"
- "incl %1\n\t"
- "incl %1\n\t"
- "jmp 6f\n"
- "5:\txorl %1,%1\n"
- "6:\tcmpw $0,(%0)\n\t"
- "jne 7f\n\t"
- "xorl %0,%0\n"
- "7:\ttestl %0,%0\n\t"
- "jne 8f\n\t"
- "movl %0,%1\n"
- "8:"
- : "=b" (__res), "=S" (___wcstok)
- : "0" (___wcstok), "1" (s), "g" (ct)
- : "eax", "ecx", "edx", "edi", "memory");
-
- return __res;
-}
-
-#else
-
-wchar_t *
-wcstok(wchar_t * s,const wchar_t * ct)
-{
-UNIMPLEMENTED;
-}
-
-#endif
#include <windows.h>
+#include <ddk/ntddk.h>
-#define STUB(x) void x(void) { NtDisplayString("NTDLL: Stub for "#x"\n"); }
+#define STUB(x) void x(void) { UNICODE_STRING UnicodeString; \
+ RtlInitUnicodeString(&UnicodeString,\
+ L"NTDLL: Stub for "#x"\n"); \
+ NtDisplayString(&UnicodeString); }
// ?Allocate@CBufferAllocator@@UAEPAXK@Z
STUB(PropertyLengthAsVariant)
STUB(CsrProbeForWrite)
STUB(CsrSetPriorityClass)
STUB(DbgBreakPoint)
-STUB(DbgPrint)
STUB(DbgPrompt)
STUB(DbgSsHandleKmApiMsg)
STUB(DbgSsInitialize)
STUB(LdrGetDllHandle)
STUB(LdrGetProcedureAddress)
STUB(LdrInitializeThunk)
-STUB(LdrLoadDll)
STUB(LdrProcessRelocationBlock)
STUB(LdrQueryImageFileExecutionOptions)
STUB(LdrQueryProcessModuleInformation)
STUB(PfxInsertPrefix)
STUB(PfxRemovePrefix)
STUB(RestoreEm87Context)
-STUB(RtlAbortRXact)
-STUB(RtlAbsoluteToSelfRelativeSD)
-STUB(RtlAcquirePebLock)
-STUB(RtlAcquireResourceExclusive)
-STUB(RtlAcquireResourceShared)
-STUB(RtlAddAccessAllowedAce)
-STUB(RtlAddAccessDeniedAce)
-STUB(RtlAddAce)
-STUB(RtlAddActionToRXact)
-STUB(RtlAddAtomToAtomTable)
-STUB(RtlAddAttributeActionToRXact)
-STUB(RtlAddAuditAccessAce)
-STUB(RtlAddCompoundAce)
-STUB(RtlAdjustPrivilege)
-STUB(RtlAllocateAndInitializeSid)
-STUB(RtlAllocateHandle)
-STUB(RtlAllocateHeap)
-STUB(RtlAnsiCharToUnicodeChar)
-STUB(RtlAppendAsciizToString)
-STUB(RtlAppendStringToString)
-STUB(RtlApplyRXact)
-STUB(RtlApplyRXactNoFlush)
-STUB(RtlAreAllAccessesGranted)
-STUB(RtlAreAnyAccessesGranted)
-STUB(RtlAreBitsClear)
-STUB(RtlAreBitsSet)
-STUB(RtlAssert)
-STUB(RtlCaptureStackBackTrace)
-STUB(RtlCheckRegistryKey)
-STUB(RtlClearAllBits)
-STUB(RtlClearBits)
-STUB(RtlClosePropertySet)
-STUB(RtlCompactHeap)
-STUB(RtlCompareMemory)
-STUB(RtlCompareMemoryUlong)
-STUB(RtlCompressBuffer)
-STUB(RtlConsoleMultiByteToUnicodeN)
-STUB(RtlConvertExclusiveToShared)
-STUB(RtlConvertLongToLargeInteger)
-STUB(RtlConvertSharedToExclusive)
-STUB(RtlConvertSidToUnicodeString)
-STUB(RtlConvertUiListToApiList)
-STUB(RtlConvertUlongToLargeInteger)
-STUB(RtlCopyLuid)
-STUB(RtlCopyLuidAndAttributesArray)
-STUB(RtlCopySecurityDescriptor)
-STUB(RtlCopySid)
-STUB(RtlCopySidAndAttributesArray)
-STUB(RtlCreateAcl)
-STUB(RtlCreateAndSetSD)
-STUB(RtlCreateAtomTable)
-STUB(RtlCreateEnvironment)
-STUB(RtlCreateHeap)
-STUB(RtlCreateProcessParameters)
-STUB(RtlCreatePropertySet)
-STUB(RtlCreateQueryDebugBuffer)
-STUB(RtlCreateRegistryKey)
-STUB(RtlCreateSecurityDescriptor)
-STUB(RtlCreateTagHeap)
-STUB(RtlCreateUnicodeString)
-STUB(RtlCreateUnicodeStringFromAsciiz)
-STUB(RtlCreateUserProcess)
-STUB(RtlCreateUserSecurityObject)
-STUB(RtlCreateUserThread)
-STUB(RtlCustomCPToUnicodeN)
-STUB(RtlCutoverTimeToSystemTime)
-STUB(RtlDeNormalizeProcessParams)
-STUB(RtlDecompressBuffer)
-STUB(RtlDecompressFragment)
-STUB(RtlDelete)
-STUB(RtlDeleteAce)
-STUB(RtlDeleteAtomFromAtomTable)
-STUB(RtlDeleteCriticalSection)
-STUB(RtlDeleteElementGenericTable)
-STUB(RtlDeleteNoSplay)
-STUB(RtlDeleteRegistryValue)
-STUB(RtlDeleteResource)
-STUB(RtlDeleteSecurityObject)
-STUB(RtlDestroyAtomTable)
-STUB(RtlDestroyEnvironment)
-STUB(RtlDestroyHandleTable)
-STUB(RtlDestroyHeap)
-STUB(RtlDestroyProcessParameters)
-STUB(RtlDestroyQueryDebugBuffer)
-STUB(RtlDetermineDosPathNameType_U)
-STUB(RtlDoesFileExists_U)
-STUB(RtlDosPathNameToNtPathName_U)
-STUB(RtlDosSearchPath_U)
-STUB(RtlDowncaseUnicodeString)
-STUB(RtlDumpResource)
-STUB(RtlEmptyAtomTable)
-STUB(RtlEnlargedIntegerMultiply)
-STUB(RtlEnlargedUnsignedDivide)
-STUB(RtlEnlargedUnsignedMultiply)
-STUB(RtlEnterCriticalSection)
-STUB(RtlEnumProcessHeaps)
-STUB(RtlEnumerateGenericTable)
-STUB(RtlEnumerateGenericTableWithoutSplaying)
-STUB(RtlEnumerateProperties)
-STUB(RtlEqualComputerName)
-STUB(RtlEqualDomainName)
-STUB(RtlEqualLuid)
-STUB(RtlEqualPrefixSid)
-STUB(RtlEqualSid)
-STUB(RtlEraseUnicodeString)
-STUB(RtlExpandEnvironmentStrings_U)
-STUB(RtlExtendHeap)
-STUB(RtlExtendedIntegerMultiply)
-STUB(RtlExtendedLargeIntegerDivide)
-STUB(RtlExtendedMagicDivide)
-STUB(RtlFillMemory)
-STUB(RtlFillMemoryUlong)
-STUB(RtlFindClearBits)
-STUB(RtlFindClearBitsAndSet)
-STUB(RtlFindLongestRunClear)
-STUB(RtlFindLongestRunSet)
-STUB(RtlFindMessage)
-STUB(RtlFindSetBits)
-STUB(RtlFindSetBitsAndClear)
-STUB(RtlFirstFreeAce)
-STUB(RtlFlushPropertySet)
-STUB(RtlFormatCurrentUserKeyPath)
-STUB(RtlFormatMessage)
-STUB(RtlFreeHandle)
-STUB(RtlFreeHeap)
-STUB(RtlFreeOemString)
-STUB(RtlFreeSid)
-STUB(RtlFreeUserThreadStack)
-STUB(RtlGenerate8dot3Name)
-STUB(RtlGetAce)
-STUB(RtlGetCallersAddress)
-STUB(RtlGetCompressionWorkSpaceSize)
-STUB(RtlGetControlSecurityDescriptor)
-STUB(RtlGetCurrentDirectory_U)
-STUB(RtlGetDaclSecurityDescriptor)
-STUB(RtlGetElementGenericTable)
-STUB(RtlGetFullPathName_U)
-STUB(RtlGetGroupSecurityDescriptor)
-STUB(RtlGetLongestNtPathLength)
-STUB(RtlGetNtGlobalFlags)
-STUB(RtlGetNtProductType)
-STUB(RtlGetOwnerSecurityDescriptor)
-STUB(RtlGetProcessHeaps)
-STUB(RtlGetSaclSecurityDescriptor)
-STUB(RtlGetUserInfoHeap)
-STUB(RtlGuidToPropertySetName)
-STUB(RtlIdentifierAuthoritySid)
-STUB(RtlImageDirectoryEntryToData)
-STUB(RtlImageNtHeader)
-STUB(RtlImageRvaToSection)
-STUB(RtlImageRvaToVa)
-STUB(RtlImpersonateSelf)
-STUB(RtlInitCodePageTable)
-STUB(RtlInitNlsTables)
-STUB(RtlInitializeAtomPackage)
-STUB(RtlInitializeBitMap)
-STUB(RtlInitializeContext)
-STUB(RtlInitializeCriticalSection)
-STUB(RtlInitializeCriticalSectionAndSpinCount)
-STUB(RtlInitializeGenericTable)
-STUB(RtlInitializeHandleTable)
-STUB(RtlInitializeRXact)
-STUB(RtlInitializeResource)
-STUB(RtlInitializeSid)
-STUB(RtlInsertElementGenericTable)
-STUB(RtlIntegerToChar)
-STUB(RtlIsDosDeviceName_U)
-STUB(RtlIsGenericTableEmpty)
-STUB(RtlIsNameLegalDOS8Dot3)
-STUB(RtlIsTextUnicode)
-STUB(RtlIsValidHandle)
-STUB(RtlIsValidIndexHandle)
-STUB(RtlLargeIntegerAdd)
-STUB(RtlLargeIntegerArithmeticShift)
-STUB(RtlLargeIntegerDivide)
-STUB(RtlLargeIntegerNegate)
-STUB(RtlLargeIntegerShiftLeft)
-STUB(RtlLargeIntegerShiftRight)
-STUB(RtlLargeIntegerSubtract)
-STUB(RtlLargeIntegerToChar)
-STUB(RtlLeaveCriticalSection)
-STUB(RtlLengthRequiredSid)
-STUB(RtlLengthSecurityDescriptor)
-STUB(RtlLengthSid)
-STUB(RtlLocalTimeToSystemTime)
-STUB(RtlLockHeap)
-STUB(RtlLookupAtomInAtomTable)
-STUB(RtlLookupElementGenericTable)
-STUB(RtlMakeSelfRelativeSD)
-STUB(RtlMapGenericMask)
-STUB(RtlMoveMemory)
-STUB(RtlMultiByteToUnicodeN)
-STUB(RtlMultiByteToUnicodeSize)
-STUB(RtlNewInstanceSecurityObject)
-STUB(RtlNewSecurityGrantedAccess)
-STUB(RtlNewSecurityObject)
-STUB(RtlNormalizeProcessParams)
-/*STUB(RtlNtStatusToDosError)*/
-STUB(RtlNumberGenericTableElements)
-STUB(RtlNumberOfClearBits)
-STUB(RtlNumberOfSetBits)
-STUB(RtlOemStringToUnicodeSize)
-STUB(RtlOemStringToUnicodeString)
-STUB(RtlOemToUnicodeN)
-STUB(RtlOnMappedStreamEvent)
-STUB(RtlOpenCurrentUser)
-STUB(RtlPcToFileHeader)
-STUB(RtlPinAtomInAtomTable)
-STUB(RtlPrefixString)
-STUB(RtlPrefixUnicodeString)
-STUB(RtlPropertySetNameToGuid)
-STUB(RtlProtectHeap)
-STUB(RtlQueryAtomInAtomTable)
-STUB(RtlQueryEnvironmentVariable_U)
-STUB(RtlQueryInformationAcl)
-STUB(RtlQueryProcessBackTraceInformation)
-STUB(RtlQueryProcessDebugInformation)
-STUB(RtlQueryProcessHeapInformation)
-STUB(RtlQueryProcessLockInformation)
-STUB(RtlQueryProperties)
-STUB(RtlQueryPropertyNames)
-STUB(RtlQueryPropertySet)
-STUB(RtlQueryRegistryValues)
-STUB(RtlQuerySecurityObject)
-STUB(RtlQueryTagHeap)
-STUB(RtlQueryTimeZoneInformation)
-STUB(RtlRaiseException)
-STUB(RtlRaiseStatus)
-STUB(RtlRandom)
-STUB(RtlReAllocateHeap)
-STUB(RtlRealPredecessor)
-STUB(RtlRealSuccessor)
-STUB(RtlReleasePebLock)
-STUB(RtlReleaseResource)
-STUB(RtlRemoteCall)
-STUB(RtlResetRtlTranslations)
-STUB(RtlRunDecodeUnicodeString)
-STUB(RtlRunEncodeUnicodeString)
-STUB(RtlSecondsSince1970ToTime)
-STUB(RtlSecondsSince1980ToTime)
-STUB(RtlSelfRelativeToAbsoluteSD)
-STUB(RtlSetAllBits)
-STUB(RtlSetAttributesSecurityDescriptor)
-STUB(RtlSetBits)
-STUB(RtlSetCriticalSectionSpinCount)
-STUB(RtlSetCurrentDirectory_U)
-STUB(RtlSetCurrentEnvironment)
-STUB(RtlSetDaclSecurityDescriptor)
-STUB(RtlSetEnvironmentVariable)
-STUB(RtlSetGroupSecurityDescriptor)
-STUB(RtlSetInformationAcl)
-STUB(RtlSetOwnerSecurityDescriptor)
-STUB(RtlSetProperties)
-STUB(RtlSetPropertyNames)
-STUB(RtlSetPropertySetClassId)
-STUB(RtlSetSaclSecurityDescriptor)
-STUB(RtlSetSecurityObject)
-STUB(RtlSetTimeZoneInformation)
-STUB(RtlSetUnicodeCallouts)
-STUB(RtlSetUserFlagsHeap)
-STUB(RtlSetUserValueHeap)
-STUB(RtlSizeHeap)
-STUB(RtlSplay)
-STUB(RtlStartRXact)
-STUB(RtlSubAuthorityCountSid)
-STUB(RtlSubAuthoritySid)
-STUB(RtlSubtreePredecessor)
-STUB(RtlSubtreeSuccessor)
-STUB(RtlSystemTimeToLocalTime)
-STUB(RtlTimeToElapsedTimeFields)
-STUB(RtlTimeToSecondsSince1970)
-STUB(RtlTimeToSecondsSince1980)
-STUB(RtlTryEnterCriticalSection)
-STUB(RtlUnicodeStringToAnsiSize)
-STUB(RtlUnicodeStringToCountedOemString)
-STUB(RtlUnicodeStringToOemSize)
-STUB(RtlUnicodeStringToOemString)
-STUB(RtlUnicodeToCustomCPN)
-STUB(RtlUnicodeToMultiByteN)
-STUB(RtlUnicodeToMultiByteSize)
-STUB(RtlUnicodeToOemN)
-STUB(RtlUniform)
-STUB(RtlUnlockHeap)
-STUB(RtlUnwind)
-STUB(RtlUpcaseUnicodeChar)
-STUB(RtlUpcaseUnicodeStringToAnsiString)
-STUB(RtlUpcaseUnicodeStringToCountedOemString)
-STUB(RtlUpcaseUnicodeStringToOemString)
-STUB(RtlUpcaseUnicodeToCustomCPN)
-STUB(RtlUpcaseUnicodeToMultiByteN)
-STUB(RtlUpcaseUnicodeToOemN)
-STUB(RtlUpperChar)
-STUB(RtlUsageHeap)
-STUB(RtlValidAcl)
-STUB(RtlValidSecurityDescriptor)
-STUB(RtlValidSid)
STUB(RtlValidateHeap)
STUB(RtlValidateProcessHeaps)
STUB(RtlWalkHeap)
-STUB(RtlWriteRegistryValue)
STUB(RtlZeroHeap)
-STUB(RtlZeroMemory)
STUB(RtlpNtCreateKey)
STUB(RtlpNtEnumerateSubKey)
STUB(RtlpNtMakeTemporaryKey)
STUB(memchr)
STUB(memcmp)
STUB(memmove)
-STUB(memset)
STUB(pow)
STUB(qsort)
STUB(sin)
STUB(sqrt)
STUB(sscanf)
-STUB(strcat)
STUB(strchr)
-STUB(strcmp)
-STUB(strcpy)
STUB(strcspn)
STUB(strncat)
-STUB(strncmp)
-STUB(strncpy)
STUB(strpbrk)
-STUB(strrchr)
STUB(strspn)
STUB(strstr)
STUB(strtol)
STUB(strtoul)
STUB(swprintf)
STUB(tan)
+
;
push edx
push dword 0
- jmp dword KERNEL_CS:KERNEL_BASE
+ jmp dword KERNEL_CS:(KERNEL_BASE+0x1000)
;
echo copying latest files to a:...
copy /Y bootflop.bat a:\autoexec.bat
copy /Y loaders\dos\loadros.com a:
-copy /Y apps\shell\shell.bin a:
-copy /Y ntoskrnl\kimage.bin a:
-copy /Y services\dd\blue\blues.o a:
-copy /Y services\dd\keyboard\keyboard.o a:
-copy /Y services\dd\ide\ide.o a:
-copy /Y services\fs\vfat\vfatfsd.o a:
-
+copy /Y apps\shell\shell.exe a:
+copy /Y ntoskrnl\ntoskrnl.exe a:
+copy /Y services\dd\blue\blue.sys a:
+copy /Y services\dd\keyboard\keyboard.sys a:
+copy /Y services\dd\ide\ide.sys a:
+copy /Y services\fs\vfat\vfatfsd.sys a:
+copy /Y lib\ntdll\ntdll.dll a:
+: copy /Y lib\crtdll\crtdll.dll a:
#
#HOST = djgpp-linux
#HOST = mingw32-linux
-HOST = djgpp-msdos
-#HOST = mingw32-windows
+#HOST = djgpp-msdos
+HOST = mingw32-windows
+
+ifeq ($(HOST),mingw32-windows)
+TOPDIR := /TEMP/M32/REACTOS
+endif
include rules.mak
#
# Required to run the system
#
-COMPONENTS = iface_native ntoskrnl kernel32 ntdll crtdll mingw32
+COMPONENTS = iface_native ntoskrnl kernel32 ntdll
+# crtdll mingw32
#
# Select the server(s) you want to build
#
# Select the device drivers and filesystems you want
-#
-KERNEL_SERVICES = parallel keyboard blues null mouse serial sound ide test sdisk \
+#
+KERNEL_SERVICES = blue parallel keyboard null mouse serial sound ide test sdisk \
minix vfat
APPS = hello shell
all: $(COMPONENTS) $(LOADERS) $(KERNEL_SERVICES) $(APPS)
+.PHONY: all
-clean: dummy
- make -C iface/native clean
+clean: $(COMPONENTS:%=%_clean) $(LOADERS:%=%_clean) \
+ $(KERNEL_SERVICES:%=%_clean) $(APPS:%=%_clean)
+.PHONY: clean
#
# Applications
#
-hello: dummy
- make -C apps/hello
+$(APPS): %:
+ make -C apps/$*
-cmd: dummy
- make -C apps/cmd
+$(APPS:%=%_clean): %_clean:
+ make -C apps/$* clean
-shell: dummy
- make -C apps/shell
+.PHONY: $(APPS:%=%) $(APPS:%=%_clean)
#
# Interfaces
#
-iface_native: dummy
+iface_native:
make -C iface/native
+iface_native_clean:
+ make -C iface/native clean
+
+.PHONY: iface_native iface_native_clean
+
#
# Device driver rules
#
keyboard: dummy
make -C services/dd/keyboard
-blues: dummy
+blue: dummy
make -C services/dd/blue
mouse: dummy
#
# Select your host
#
-#HOST = djgpp-linux
-#HOST = mingw32-linux
-HOST = djgpp-msdos
+HOST = mingw32-linux
+#HOST = djgpp-msdos
#HOST = mingw32-windows
include rules.mak
#
# Required to run the system
#
-LIBRARIES = kernel32 ntdll crtdll mingw32
-COMPONENTS = iface_native ntoskrnl $(LIBRARIES)
-.PHONY: $(COMPONENTS) $(COMPONENTS:%=%_clean)
+COMPONENTS = iface_native ntoskrnl kernel32 ntdll
#
# Select the server(s) you want to build
#
SERVERS = win32 posix linux os2
-.PHONY: $(SERVERS) $(SERVERS:%=%_clean)
#
# Select the loader(s) you want to build
#
LOADERS = dos
-.PHONY: $(LOADERS) $(LOADERS:%=%_clean)
#
# Select the device drivers and filesystems you want
#
-DD_SERVICES = blue ide keyboard mouse null parallel sdisk serial sound test
-FS_SERVICES = minix vfat ext2
-KERNEL_SERVICES = $(DD_SERVICES) $(FS_SERVICES)
-.PHONY: $(KERNEL_SERVICES) $(KERNEL_SERVICES:%=%_clean)
+KERNEL_SERVICES = parallel keyboard blues null mouse serial sound ide test sdisk \
+ minix vfat ext2
-APPS = hello shell # args
-.PHONY: $(APPS:%=%) $(APPS:%=%_clean)
+APPS = hello shell args
all: $(COMPONENTS) $(LOADERS) $(KERNEL_SERVICES) $(APPS)
-.PHONY: all
-clean: $(COMPONENTS:%=%_clean) $(LOADERS:%=%_clean) \
- $(KERNEL_SERVICES:%=%_clean) $(APPS:%=%_clean)
-.PHONY: clean
+clean: dummy
+ make -C iface/native clean
#
# Applications
#
-$(APPS): %:
- make -C apps/$*
+hello: dummy
+ make -C apps/hello
+
+args: dummy
+ make -C apps/args
+
+cmd: dummy
+ make -C apps/cmd
-$(APPS:%=%_clean): %_clean:
- make -C apps/$* clean
+shell: dummy
+ make -C apps/shell
#
# Interfaces
#
-
-iface_native:
+iface_native: dummy
make -C iface/native
-iface_native_clean:
- make -C iface/native clean
-
#
# Device driver rules
#
+vfat: dummy
+ make -C services/fs/vfat
+
+sdisk: dummy
+ make -C services/dd/sdisk
+
+minix: dummy
+ make -C services/fs/minix
+
+template: dummy
+ make -C services/fs/template
-$(DD_SERVICES): %:
- make -C services/dd/$*
-$(DD_SERVICES:%=%_clean): %_clean:
- make -C services/dd/$* clean
+ide-test: dummy
+ make -C services/dd/ide-test
-$(FS_SERVICES): %:
- make -C services/fs/$*
+ide: dummy
+ make -C services/dd/ide
-$(FS_SERVICES:%=%_clean): %_clean:
- make -C services/fs/$* clean
+test: dummy
+ make -C services/dd/test
-#
-# Kernel loaders
-#
+test1: dummy
+ make -C services/dd/test1
-$(LOADERS): %:
- make -C loaders/$*
+null: dummy
+ make -C services/dd/null
-$(LOADERS:%=%_clean): %_clean:
- make -C loaders/$* clean
+parallel: dummy
+ make -C services/dd/parallel
+
+keyboard: dummy
+ make -C services/dd/keyboard
+
+blues: dummy
+ make -C services/dd/blue
+
+mouse: dummy
+ make -C services/dd/mouse
+
+serial: dummy
+ make -C services/dd/serial
+
+sound: dummy
+ make -C services/dd/sound
+
+ext2: dummy
+ make -C services/fs/ext2
#
-# Libraries
+# Kernel loaders
#
-$(LIBRARIES): %:
- make -C lib/$*
-
-$(LIBRARIES:%=%_clean): %_clean:
- make -C lib/$* clean
+dos: dummy
+ make -C loaders/dos
#
# Required system components
#
-ntoskrnl:
+ntoskrnl: dummy
make -C ntoskrnl
-ntoskrnl_clean:
- make -C ntoskrnl clean
+kernel32: dummy
+ make -C lib/kernel32
+
+ntdll: dummy
+ make -C lib/ntdll
+
+crtdll: dummy
+ make -C lib/crtdll
+mingw32: dummy
+ make -C lib/mingw32
+dummy:
--- /dev/null
+base.tmp
+junk.tmp
+temp.exp
#include <ddk/ntddk.h>
#include <internal/debug.h>
+#include <string.h>
#include <internal/string.h>
#include <internal/ntoskrnl.h> /* for sprintf */
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/ex/napi.c
* PURPOSE: Native API support routines
- * PROGRAMMER: David Welch (welch@mcmail.com)
+ * PROGRAMMER: David Welch (welch@cwcom.net)
*/
/* INCLUDES *****************************************************************/
#include <ddk/ntddk.h>
-#include <wstring.h>
#include <internal/debug.h>
/* GLOBALS ******************************************************************/
HalSetBusData
HalSetBusDataByOffset
HalTranslateBusAddress
-HalQueryRealTimeClock
IoAcquireCancelSpinLock
IoAllocateAdapterChannel
IoAllocateController
wcschr
wcsncat
wcsncpy
-wtolower
-wtoupper
CbInitDccb
CbAcquireForRead
CbReleaseFromRead
+wtolower
+tolower
+toupper
#include <ddk/ntddk.h>
#include <internal/mm.h>
+#include <string.h>
#include <internal/string.h>
#include <internal/mmhal.h>
#include <internal/i386/segment.h>
/* FUNCTIONS *****************************************************************/
-VOID HalInitializeAdapterSupport()
+VOID HalInitializeAdapterSupport(VOID)
{
/* ?? */
}
#define EXCEPTION_HANDLER_WITH_ERROR(x,y) \
void exception_handler##y (void); \
+ void tmp_exception_handler##y (void) { \
__asm__("\n\t_exception_handler"##x":\n\t" \
"pushl %gs\n\t" \
"pushl %fs\n\t" \
"popl %fs\n\t" \
"popl %gs\n\t" \
"addl $4,%esp\n\t" \
- "iret\n\t")
+ "iret\n\t"); }
#define EXCEPTION_HANDLER_WITHOUT_ERROR(x,y) \
asmlinkage void exception_handler##y (void); \
+ void tmp_exception_handler##y (void) { \
__asm__("\n\t_exception_handler"##x":\n\t" \
"pushl $0\n\t" \
"pushl %gs\n\t" \
"popl %fs\n\t" \
"popl %gs\n\t" \
"addl $4,%esp\n\t" \
- "iret\n\t")
+ "iret\n\t"); }
-asmlinkage void exception_handler_unknown(void);
+asmlinkage void exception_handler_unknown(void);
+asmlinkage void tmp_exception_handler_unknown(void)
+{
__asm__("\n\t_exception_handler_unknown:\n\t"
"pushl $0\n\t"
"pushl %gs\n\t"
"popa\n\t"
"addl $8,%esp\n\t"
"iret\n\t");
-
+}
EXCEPTION_HANDLER_WITHOUT_ERROR("0",0);
EXCEPTION_HANDLER_WITHOUT_ERROR("1",1);
stack=(unsigned int *)(esp0);
printk("Stack:\n");
- for (i=0;i<16;i=i+4)
+ for (i=0; i<16; i++)
{
- printk("%.8x %.8x %.8x %.8x\n",stack[i],stack[i+1],stack[i+2],
- stack[i+3]);
+ if (MmIsPagePresent(NULL,&stack[i]))
+ {
+ DbgPrint("%.8x ",stack[i]);
+ if (((i+1)%4) == 0)
+ {
+ DbgPrint("\n");
+ }
+ }
}
}
static void set_interrupt_gate(unsigned int sel, unsigned int func)
{
+ DPRINT("set_interrupt_gate(sel %d, func %x)\n",sel,func);
idt[sel].a = (((int)func)&0xffff) +
(KERNEL_CS << 16);
idt[sel].b = 0x8f00 + (((int)func)&0xffff0000);
.globl _start
.globl _mainCRTStartup
.globl start
+/*.globl _DllMainCRTStartup@12*/
+/*_DllMainCRTStartup@12:*/
_stext:
_mainCRTStartup:
_start:
#include <internal/ke.h>
#include <internal/bitops.h>
#include <internal/linkage.h>
+#include <string.h>
#include <internal/string.h>
#include <internal/i386/segment.h>
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/hal/x86/irql.c
* PURPOSE: Implements IRQLs
- * PROGRAMMER: David Welch (welch@mcmail.com)
+ * PROGRAMMER: David Welch (welch@cwcom.net)
*/
/* INCLUDES *****************************************************************/
-#include <windows.h>
#include <ddk/ntddk.h>
#include <internal/bitops.h>
#include <internal/halio.h>
+#include <internal/ke.h>
#define NDEBUG
#include <internal/debug.h>
if (NewIrql > CurrentIrql)
{
DbgPrint("NewIrql %x CurrentIrql %x\n",NewIrql,CurrentIrql);
- KeDumpStackFrames(0);
+ KeDumpStackFrames(0,32);
for(;;);
}
CurrentIrql = NewIrql;
#include <internal/mmhal.h>
#include <internal/mm.h>
+#include <string.h>
#include <internal/string.h>
#include <internal/bitops.h>
#include <ddk/ntddk.h>
return(Attributes);
}
-PULONG MmGetPageEntry(PEPROCESS Process, ULONG Address)
+PULONG MmGetPageEntry(PEPROCESS Process, PVOID PAddress)
{
ULONG page_table;
PULONG page_tlb;
PULONG page_dir;
+ ULONG Address = (ULONG)PAddress;
DPRINT("MmGetPageEntry(Process %x, Address %x)\n",Process,Address);
}
else
{
- page_dir = get_page_directory();
+ page_dir = (PULONG)get_page_directory();
}
DPRINT("page_dir %x\n",page_dir);
- page_tlb = (unsigned int *)physical_to_linear(
+ page_tlb = (PULONG)physical_to_linear(
PAGE_MASK(page_dir[VADDR_TO_PD_OFFSET(Address)]));
DPRINT("page_tlb %x\n",page_tlb);
{
DPRINT("Creating new page directory\n",0);
page_table = get_free_page(); // Returns a physical address
- page_tlb=(unsigned int *)physical_to_linear(page_table);
+ page_tlb=(PULONG)physical_to_linear(page_table);
memset(page_tlb,0,PAGESIZE);
page_dir[VADDR_TO_PD_OFFSET(Address)]=page_table+0x7;
/* INCLUDES *****************************************************************/
#include <internal/ntoskrnl.h>
+#include <string.h>
#include <internal/string.h>
#include <internal/mmhal.h>
#include <internal/halio.h>
*/
static unsigned int in_hal_console = 1;
-/*
- * PURPOSE: Defines the hal console video mode
- */
-static unsigned char mode03[] = {0x67,0x00,0x03,0x00,0x03,0x00,0x02,
- 0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,
- 0x1f,0x00,0x4f,0x0e,0x0f,0x00,0x00,
- 0x00,0x00,0x9c,0x0e,0x8f,0x28,0x01,
- 0x96,0xb9,0xa3,0xff,0x00,0x00,0x00,
- 0x00,0x00,0x10,0x0e,0x00,0xff,0x00,
- 0x00,0x01,0x02,0x03,0x04,0x05,0x06,
- 0x07,0x10,0x11,0x12,0x13,0x14,0x15,
- 0x16,0x17,0x0c,0x00,0x0f,0x08,0x00};
-
/* FUNCTIONS ***************************************************************/
NTSTATUS STDCALL NtDisplayString(IN PUNICODE_STRING DisplayString)
{
-// DbgPrint("DisplayString %x\n",DisplayString);
- DbgPrint("%s",DisplayString);
-// DbgPrint("Returning from NtDisplayString()\n");
+// DbgPrint("NtDisplayString(%w)\n",DisplayString->Buffer);
+ DbgPrint("%w",DisplayString->Buffer);
return(STATUS_SUCCESS);
}
* NOTE: This function handles newlines as well
*/
{
- char* address;
int offset;
int i;
: "m" (eflags));
}
-int bad_user_access_length(void)
-{
- printk("Bad user access length\n");
-}
ULONG DbgPrint(PCH Format, ...)
{
__asm__("push %0\n\tpopf\n\t"
:
: "m" (eflags));
+ return(strlen(buffer));
}
void HalInitConsole(boot_param* bp)
hal/x86/irql.o hal/x86/bios32.o hal/x86/thread.o hal/x86/spinlock.o \
hal/x86/printk.o hal/x86/mp.o hal/x86/dma.o hal/x86/bus.o hal/x86/mbr.o \
hal/x86/sysinfo.o hal/x86/time.o hal/x86/usercall.o hal/x86/beep.o
+
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/hal/x86/thread.c
* PURPOSE: HAL multitasking functions
- * PROGRAMMER: David Welch (welch@mcmail.com)
+ * PROGRAMMER: David Welch (welch@cwcom.net)
* REVISION HISTORY:
* 27/06/98: Created
*/
/* INCLUDES ****************************************************************/
-#include <windows.h>
#include <ddk/ntddk.h>
#include <internal/ntoskrnl.h>
#include <internal/ps.h>
+#include <string.h>
#include <internal/string.h>
#include <internal/hal.h>
#include <internal/i386/segment.h>
{
ExFreePool(Thread->Tcb.Context.KernelStackBase);
}
+ return(STATUS_SUCCESS);
}
NTSTATUS HalInitTaskWithContext(PETHREAD Thread, PCONTEXT Context)
Thread->Tcb.Context.iomap_base = FIELD_OFFSET(hal_thread_state,io_bitmap);
Thread->Tcb.Context.esp0 = (ULONG)stack_start;
Thread->Tcb.Context.ss0 = KERNEL_DS;
- Thread->Tcb.Context.esp = stack_start;
+ Thread->Tcb.Context.esp = (ULONG)stack_start;
Thread->Tcb.Context.ss = KERNEL_DS;
Thread->Tcb.Context.cs = KERNEL_CS;
- Thread->Tcb.Context.eip = PsBeginThreadWithContextInternal;
+ Thread->Tcb.Context.eip = (ULONG)PsBeginThreadWithContextInternal;
Thread->Tcb.Context.io_bitmap[0] = 0xff;
- Thread->Tcb.Context.cr3 =
- linear_to_physical(Thread->ThreadsProcess->Pcb.PageTableDirectory);
+ Thread->Tcb.Context.cr3 = (ULONG)MmGetPhysicalAddress(
+ Thread->ThreadsProcess->Pcb.PageTableDirectory);
Thread->Tcb.Context.ds = KERNEL_DS;
Thread->Tcb.Context.es = KERNEL_DS;
Thread->Tcb.Context.fs = KERNEL_DS;
*/
kernel_stack[1023] = (unsigned int)StartContext;
kernel_stack[1022] = (unsigned int)fn;
- kernel_stack[1021] = NULL;
+ kernel_stack[1021] = 0;
/*
* Initialize the thread context
thread->Tcb.Context.ldt = null_ldt_sel;
thread->Tcb.Context.eflags = (1<<1)+(1<<9);
thread->Tcb.Context.iomap_base = FIELD_OFFSET(hal_thread_state,io_bitmap);
- thread->Tcb.Context.esp0 = &kernel_stack[1021];
+ thread->Tcb.Context.esp0 = (ULONG)&kernel_stack[1021];
thread->Tcb.Context.ss0 = KERNEL_DS;
- thread->Tcb.Context.esp = &kernel_stack[1021];
+ thread->Tcb.Context.esp = (ULONG)&kernel_stack[1021];
thread->Tcb.Context.ss = KERNEL_DS;
thread->Tcb.Context.cs = KERNEL_CS;
thread->Tcb.Context.eip = (unsigned long)PsBeginThread;
thread->Tcb.Context.io_bitmap[0] = 0xff;
thread->Tcb.Context.cr3 =
- linear_to_physical(thread->ThreadsProcess->Pcb.PageTableDirectory);
+ MmGetPhysicalAddress(thread->ThreadsProcess->Pcb.PageTableDirectory);
thread->Tcb.Context.ds = KERNEL_DS;
thread->Tcb.Context.es = KERNEL_DS;
thread->Tcb.Context.fs = KERNEL_DS;
#include <windows.h>
#include <ddk/ntddk.h>
#include <internal/io.h>
+#include <string.h>
#include <internal/string.h>
#include <internal/ob.h>
/* INCLUDES ***************************************************************/
-#include <windows.h>
+#include <wchar.h>
#include <ddk/ntddk.h>
#include <internal/ob.h>
#include <internal/io.h>
+#include <internal/id.h>
#include <internal/string.h>
-#include <wstring.h>
#define NDEBUG
#include <internal/debug.h>
UNIMPLEMENTED;
}
-NTSTATUS NtCreateFile(PHANDLE FileHandle,
- ACCESS_MASK DesiredAccess,
- POBJECT_ATTRIBUTES ObjectAttributes,
- PIO_STATUS_BLOCK IoStatusBlock,
- PLARGE_INTEGER AllocateSize,
- ULONG FileAttributes,
- ULONG ShareAccess,
- ULONG CreateDisposition,
- ULONG CreateOptions,
- PVOID EaBuffer,
- ULONG EaLength)
+NTSTATUS STDCALL NtCreateFile(PHANDLE FileHandle,
+ ACCESS_MASK DesiredAccess,
+ POBJECT_ATTRIBUTES ObjectAttributes,
+ PIO_STATUS_BLOCK IoStatusBlock,
+ PLARGE_INTEGER AllocateSize,
+ ULONG FileAttributes,
+ ULONG ShareAccess,
+ ULONG CreateDisposition,
+ ULONG CreateOptions,
+ PVOID EaBuffer,
+ ULONG EaLength)
{
return(ZwCreateFile(FileHandle,
DesiredAccess,
}
DeviceObject = IoGetAttachedDevice(DeviceObject);
}
- RtlInitUnicodeString(&(FileObject->FileName),wstrdup(RemainingPath));
+ RtlInitUnicodeString(&(FileObject->FileName),wcsdup(RemainingPath));
}
DPRINT("FileObject->FileName.Buffer %w\n",FileObject->FileName.Buffer);
- FileObject->DeviceObject=DeviceObject;
- FileObject->Vpb=DeviceObject->Vpb;
-
+ FileObject->DeviceObject = DeviceObject;
+ FileObject->Vpb = DeviceObject->Vpb;
+ FileObject->Type = ID_FILE_OBJECT;
+
return(STATUS_SUCCESS);
}
-NTSTATUS ZwCreateFile(PHANDLE FileHandle,
- ACCESS_MASK DesiredAccess,
- POBJECT_ATTRIBUTES ObjectAttributes,
- PIO_STATUS_BLOCK IoStatusBlock,
- PLARGE_INTEGER AllocateSize,
- ULONG FileAttributes,
- ULONG ShareAccess,
- ULONG CreateDisposition,
- ULONG CreateOptions,
- PVOID EaBuffer,
- ULONG EaLength)
+NTSTATUS STDCALL ZwCreateFile(PHANDLE FileHandle,
+ ACCESS_MASK DesiredAccess,
+ POBJECT_ATTRIBUTES ObjectAttributes,
+ PIO_STATUS_BLOCK IoStatusBlock,
+ PLARGE_INTEGER AllocateSize,
+ ULONG FileAttributes,
+ ULONG ShareAccess,
+ ULONG CreateDisposition,
+ ULONG CreateOptions,
+ PVOID EaBuffer,
+ ULONG EaLength)
/*
* FUNCTION: Either causes a new file or directory to be created, or it opens
* an existing file, device, directory or volume, giving the caller a handle
return(Status);
}
-NTSTATUS NtOpenFile(PHANDLE FileHandle,
- ACCESS_MASK DesiredAccess,
- POBJECT_ATTRIBUTES ObjectAttributes,
- PIO_STATUS_BLOCK IoStatusBlock,
- ULONG ShareAccess,
- ULONG OpenOptions)
+NTSTATUS STDCALL NtOpenFile(PHANDLE FileHandle,
+ ACCESS_MASK DesiredAccess,
+ POBJECT_ATTRIBUTES ObjectAttributes,
+ PIO_STATUS_BLOCK IoStatusBlock,
+ ULONG ShareAccess,
+ ULONG OpenOptions)
{
return(ZwOpenFile(FileHandle,
DesiredAccess,
OpenOptions));
}
-NTSTATUS ZwOpenFile(PHANDLE FileHandle,
- ACCESS_MASK DesiredAccess,
- POBJECT_ATTRIBUTES ObjectAttributes,
- PIO_STATUS_BLOCK IoStatusBlock,
- ULONG ShareAccess,
- ULONG OpenOptions)
+NTSTATUS STDCALL ZwOpenFile(PHANDLE FileHandle,
+ ACCESS_MASK DesiredAccess,
+ POBJECT_ATTRIBUTES ObjectAttributes,
+ PIO_STATUS_BLOCK IoStatusBlock,
+ ULONG ShareAccess,
+ ULONG OpenOptions)
/*
* FUNCTION: Opens a file (simpler than ZwCreateFile)
* ARGUMENTS:
#include <internal/io.h>
#include <internal/ob.h>
+#include <string.h>
#include <internal/string.h>
#define NDEBUG
return(STATUS_NOT_IMPLEMENTED);
}
-NTSTATUS InitializeLoadedDriver(PDRIVER_INITIALIZE entry)
+NTSTATUS IoInitializeDriver(PDRIVER_INITIALIZE DriverEntry)
/*
* FUNCTION: Called to initalize a loaded driver
* ARGUMENTS:
*/
{
- NTSTATUS ret;
+ NTSTATUS Status;
PDRIVER_OBJECT DriverObject;
ULONG i;
- /*
- * Allocate memory for a driver object
- * NOTE: The object only becomes system visible once the associated
- * device objects are initialized
- */
- DriverObject=ExAllocatePool(NonPagedPool,sizeof(DRIVER_OBJECT));
- if (DriverObject==NULL)
+ DriverObject = ExAllocatePool(NonPagedPool,sizeof(DRIVER_OBJECT));
+ if (DriverObject == NULL)
{
- DbgPrint("%s:%d\n",__FILE__,__LINE__);
return STATUS_INSUFFICIENT_RESOURCES;
}
memset(DriverObject, 0, sizeof(DRIVER_OBJECT));
+ DriverObject->Type = ID_DRIVER_OBJECT;
+
for (i=0; i<=IRP_MJ_MAXIMUM_FUNCTION; i++)
{
DriverObject->MajorFunction[i] = IopDefaultDispatchFunction;
}
-
- /*
- * Initalize the driver
- * FIXME: Registry in general please
- */
- DPRINT("Calling driver entrypoint at %08lx\n", entry);
- if ((ret=entry(DriverObject,NULL)) != STATUS_SUCCESS)
+
+ DPRINT("Calling driver entrypoint at %08lx\n", DriverEntry);
+ Status = DriverEntry(DriverObject, NULL);
+ if (!NT_SUCCESS(Status))
{
- DPRINT("Failed to load driver (status %x)\n",ret);
ExFreePool(DriverObject);
- return ret;
+ return(Status);
}
- CHECKPOINT;
- return STATUS_SUCCESS;
+ return(Status);
}
NTSTATUS IoAttachDevice(PDEVICE_OBJECT SourceDevice,
* NOTES: See the DDK documentation for more information
*/
{
- PDEVICE_OBJECT dev;
- OBJECT_ATTRIBUTES dev_attr;
- HANDLE devh;
+ PDEVICE_OBJECT CreatedDeviceObject;
+ OBJECT_ATTRIBUTES ObjectAttributes;
+ HANDLE DeviceHandle;
- if (DeviceName!=NULL)
+ if (DeviceName != NULL)
{
DPRINT("IoCreateDevice(DriverObject %x, DeviceName %w)\n",DriverObject,
DeviceName->Buffer);
DPRINT("IoCreateDevice(DriverObject %x)\n",DriverObject);
}
- if (DeviceName!=NULL)
+ if (DeviceName != NULL)
{
- InitializeObjectAttributes(&dev_attr,DeviceName,0,NULL,NULL);
- dev = ObCreateObject(&devh,0,&dev_attr,IoDeviceType);
+ InitializeObjectAttributes(&ObjectAttributes,DeviceName,0,NULL,NULL);
+ CreatedDeviceObject = ObCreateObject(&DeviceHandle,
+ 0,
+ &ObjectAttributes,
+ IoDeviceType);
}
else
{
- dev = ObCreateObject(&devh,0,NULL,IoDeviceType);
+ CreatedDeviceObject = ObCreateObject(&DeviceHandle,
+ 0,
+ NULL,
+ IoDeviceType);
}
*DeviceObject=NULL;
- if (dev==NULL)
+ if (CreatedDeviceObject == NULL)
{
return(STATUS_INSUFFICIENT_RESOURCES);
}
-
- if (DriverObject->DeviceObject==NULL)
+
+ if (DriverObject->DeviceObject == NULL)
{
- DriverObject->DeviceObject = dev;
- dev->NextDevice=NULL;
+ DriverObject->DeviceObject = CreatedDeviceObject;
+ CreatedDeviceObject->NextDevice = NULL;
}
else
{
- dev->NextDevice=DriverObject->DeviceObject;
- DriverObject->DeviceObject=dev;
+ CreatedDeviceObject->NextDevice = DriverObject->DeviceObject;
+ DriverObject->DeviceObject = CreatedDeviceObject;
}
- dev->DriverObject = DriverObject;
- DPRINT("dev %x\n",dev);
- DPRINT("dev->DriverObject %x\n",dev->DriverObject);
-
- dev->CurrentIrp=NULL;
- dev->Flags=0;
+ CreatedDeviceObject->Type = ID_DEVICE_OBJECT;
+ CreatedDeviceObject->DriverObject = DriverObject;
+ CreatedDeviceObject->CurrentIrp = NULL;
+ CreatedDeviceObject->Flags = 0;
- dev->DeviceExtension=ExAllocatePool(NonPagedPool,DeviceExtensionSize);
- if (DeviceExtensionSize > 0 && dev->DeviceExtension==NULL)
+ CreatedDeviceObject->DeviceExtension = ExAllocatePool(NonPagedPool,
+ DeviceExtensionSize);
+ if (DeviceExtensionSize > 0 && CreatedDeviceObject->DeviceExtension == NULL)
{
- ExFreePool(dev);
+ ExFreePool(CreatedDeviceObject);
return(STATUS_INSUFFICIENT_RESOURCES);
}
- dev->AttachedDevice=NULL;
- dev->DeviceType=DeviceType;
- dev->StackSize=1;
- dev->AlignmentRequirement=1;
- KeInitializeDeviceQueue(&dev->DeviceQueue);
+ CreatedDeviceObject->AttachedDevice = NULL;
+ CreatedDeviceObject->DeviceType = DeviceType;
+ CreatedDeviceObject->StackSize = 1;
+ CreatedDeviceObject->AlignmentRequirement = 1;
+ KeInitializeDeviceQueue(&CreatedDeviceObject->DeviceQueue);
- if (dev->DeviceType==FILE_DEVICE_DISK)
+ if (CreatedDeviceObject->DeviceType == FILE_DEVICE_DISK)
{
- IoAttachVpb(dev);
+ IoAttachVpb(CreatedDeviceObject);
}
- *DeviceObject=dev;
- DPRINT("dev->DriverObject %x\n",dev->DriverObject);
+ *DeviceObject = CreatedDeviceObject;
return(STATUS_SUCCESS);
}
/* INCLUDES ****************************************************************/
+#include <ddk/ntddk.h>
+#include <string.h>
#include <internal/string.h>
#include <internal/io.h>
-#include <ddk/ntddk.h>
#define NDEBUG
#include <internal/debug.h>
IN PLARGE_INTEGER TimeOut
)
{
-}
\ No newline at end of file
+}
/* INCLUDES ****************************************************************/
-#include <windows.h>
#include <ddk/ntddk.h>
#include <internal/io.h>
+#include <string.h>
#include <internal/string.h>
#include <internal/ob.h>
PFILE_OBJECT FileObject;
PIRP Irp;
PIO_STACK_LOCATION StackPtr;
+ PKEVENT ptrEvent = NULL;
KEVENT Event;
assert(KeGetCurrentIrql()==PASSIVE_LEVEL);
Status = ObReferenceObjectByHandle(FileHandle,
FILE_READ_DATA,
- NULL,
+ IoFileType,
UserMode,
(PVOID *) &FileObject,
NULL);
ByteOffset = &(FileObject->CurrentByteOffset);
}
- KeInitializeEvent(&Event,NotificationEvent,FALSE);
+ if (EventHandle != NULL)
+ {
+ Status = ObReferenceObjectByHandle(EventHandle,
+ SYNCHRONIZE,
+ ExEventType,
+ UserMode,
+ (PVOID *)ptrEvent,
+ NULL);
+ if (!NT_SUCCESS(Status))
+ {
+ return(Status);
+ }
+ }
+ else
+ {
+ KeInitializeEvent(&Event,NotificationEvent,FALSE);
+ ptrEvent = &Event;
+ }
+
DPRINT("FileObject %x\n",FileObject);
Irp = IoBuildSynchronousFsdRequest(IRP_MJ_READ,
FileObject->DeviceObject,
Buffer,
Length,
ByteOffset,
- &Event,
+ ptrEvent,
IoStatusBlock);
StackPtr = IoGetNextIrpStackLocation(Irp);
PIO_STACK_LOCATION StackPtr;
KEVENT Event;
+ DPRINT("ZwWriteFile(FileHandle %x, Buffer %x, Length %d)\n",
+ FileHandle,Buffer,Length);
+
Status = ObReferenceObjectByHandle(FileHandle,
FILE_WRITE_DATA,
- NULL,
+ IoFileType,
UserMode,
(PVOID *) &FileObject,
NULL);
/* INCLUDES *****************************************************************/
#include <ddk/ntddk.h>
+#include <string.h>
#include <internal/string.h>
#include <internal/ob.h>
/* INCLUDES *****************************************************************/
#include <ddk/ntddk.h>
+#include <string.h>
#include <internal/string.h>
#include <internal/i386/segment.h>
#include <internal/ps.h>
DbgPrint("Bug detected (code %x param %x %x %x %x)\n",BugCheckCode,
BugCheckParameter1,BugCheckParameter2,BugCheckParameter3,
BugCheckParameter4);
- KeDumpStackFrames(0,32);
+ KeDumpStackFrames(0,64);
for(;;);
}
ret = InterlockedExchange(&(Event->Header.SignalState),1);
KeDispatcherObjectWake((DISPATCHER_HEADER *)Event);
KeReleaseDispatcherDatabaseLock(Wait);
+ return(ret);
}
KeInitDpc();
KeInitializeBugCheck();
KeInitializeDispatcher();
- InitializeTimer();
+ KeInitializeTimerImpl();
/*
* Allow interrupts
#include <internal/ntoskrnl.h>
#include <internal/version.h>
#include <internal/mm.h>
+#include <string.h>
#include <internal/string.h>
#include <internal/symbol.h>
#include <internal/module.h>
+#include <internal/ldr.h>
#include <internal/mmhal.h>
#include <internal/i386/segment.h>
start1 = start+PAGE_ROUND_UP(bp.module_length[1]);
for (i=1;i<bp.nr_files;i++)
{
+ DPRINT("process module at %08lx\n", start);
LdrProcessDriver(start);
start=start+PAGE_ROUND_UP(bp.module_length[i]);
}
*/
LdrLoadAutoConfigDrivers();
+#ifdef KRNL_TEST
/*
* Test various features of the kernel
*/
TstBegin();
-
+#endif
+
+ /*
+ * Launch initial thread
+ */
+ LdrLoadInitialProcess();
+
/*
* Enter idle loop
*/
+++ /dev/null
-/*
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS kernel
- * FILE: ntoskrnl/ke/module.c
- * PURPOSE: Loading kernel components
- * PROGRAMMER: David Welch (welch@mcmail.com)
- * UPDATE HISTORY:
- * 28/05/98: Created
- */
-
-/* INCLUDES ****************************************************************/
-
-#include <windows.h>
-#include <coff.h>
-
-#include <ddk/ntddk.h>
-
-#include <internal/io.h>
-#include <internal/symbol.h>
-#include <internal/string.h>
-#include <internal/mm.h>
-#include <internal/module.h>
-
-#define NDEBUG
-#include <internal/debug.h>
-
-/* FUNCTIONS **************************************************************/
-
-static unsigned int get_kernel_symbol_addr(char* name)
-/*
- * FUNCTION: Get the address of a kernel symbol
- * ARGUMENTS:
- * name = symbol name
- * RETURNS: The address of the symbol on success
- * NULL on failure
- */
-{
- int i=0;
- while (symbol_table[i].name!=NULL)
- {
- if (strcmp(symbol_table[i].name,name)==0)
- {
- return(symbol_table[i].value);
- }
- i++;
- }
- return(0);
-}
-
-static void get_symbol_name(module* mod, unsigned int i, char* name)
-/*
- * FUNCTION: Get the name of a symbol from a loaded module by ordinal
- * ARGUMENTS:
- * mod = module
- * i = index of symbol
- * name (OUT) = pointer to a string where the symbol name will be
- * stored
- */
-{
- if (mod->sym_list[i].e.e_name[0]!=0)
- {
- strncpy(name,mod->sym_list[i].e.e_name,8);
- }
- else
- {
- strcpy(name,&mod->str_tab[mod->sym_list[i].e.e.e_offset]);
- }
-}
-
-static unsigned int get_symbol_value_by_name(module* mod, char* sname,
- unsigned int idx)
-{
- unsigned int i;
- char name[255];
-
- DPRINT("get_symbol_value_by_name(sname %s, idx %x)\n",sname,idx);
-
- for (i=0; i<mod->nsyms; i++)
- {
- get_symbol_name(mod,i,name);
- DPRINT("Scanning %s Value %x\n",name,mod->sym_list[i].e_value);
- if (strcmp(name,sname)==0)
- {
- DPRINT("Returning %x\n",mod->sym_list[i].e_value);
- return(mod->sym_list[i].e_value);
- }
- }
- return(0);
-}
-
-static unsigned int get_symbol_value(module* mod, unsigned int i)
-/*
- * FUNCTION: Get the value of a module defined symbol
- * ARGUMENTS:
- * mod = module
- * i = index of symbol
- * RETURNS: The value of the symbol
- * NOTE: This fixes up references to known sections
- */
-{
- char name[255];
- get_symbol_name(mod,i,name);
- // DPRINT("name %s ",name);
-
- /*
- * Check if the symbol is a section we have relocated
- */
- if (strcmp(name,".text")==0)
- {
- return(mod->text_base);
- }
- if (strcmp(name,".data")==0)
- {
- return(mod->data_base);
- }
- if (strcmp(name,".bss")==0)
- {
- return(mod->bss_base);
- }
- return(mod->sym_list[i].e_value);
-}
-
-static int do_reloc32_reloc(module* mod, SCNHDR* scn, RELOC* reloc)
-/*
- * FUNCTION: Performs a reloc32 relocation on a loaded module
- * ARGUMENTS:
- * mod = module to perform the relocation on
- * scn = Section to perform the relocation in
- * reloc = Pointer to a data structure describing the relocation
- * RETURNS: Success or failure
- * NOTE: This fixes up an undefined reference to a kernel function in a module
- */
-{
- char name[255];
- unsigned int val;
- unsigned int * loc;
-
- memset(name,0,255);
- get_symbol_name(mod,reloc->r_symndx,name);
- val = get_kernel_symbol_addr(name);
- if (val==0)
- {
- val = get_symbol_value_by_name(mod,name,reloc->r_symndx);
- if (val==0)
- {
- DbgPrint("Undefined symbol %s in module\n",name);
- return(0);
- }
- loc=(unsigned int *)(mod->base+reloc->r_vaddr);
- DPRINT("old %x ",*loc);
-// (*loc) = (*loc) + val + mod->base - scn->s_vaddr;
- (*loc) = (*loc);
- DPRINT("mod->base %x scn->s_vaddr %x\n",mod->base,scn->s_vaddr);
-
- DPRINT("new %x\n",*loc);
-
- }
- else
- {
- DPRINT("REL32 value %x name %s\n",val,name);
- DPRINT("value %x\n",val);
- loc=(unsigned int *)(mod->base+reloc->r_vaddr);
- DPRINT("old %x ",*loc);
- DPRINT("mod->base %x scn->s_vaddr %x\n",mod->base,scn->s_vaddr);
- (*loc) = (*loc) + val - mod->base + scn->s_vaddr;
-
- DPRINT("new %x\n",*loc);
- }
- return(1);
-}
-
-static int do_addr32_reloc(module* mod, SCNHDR* scn, RELOC* reloc)
-/*
- * FUNCTION: Performs a addr32 relocation on a loaded module
- * ARGUMENTS:
- * mod = module to perform the relocation on
- * scn = Section to perform the relocation in
- * reloc = Pointer to a data structure describing the relocation
- * RETURNS: Success or failure
- * NOTE: This fixes up a relocation needed when changing the base address of a
- * module
- */
-{
- unsigned int value;
- unsigned int * loc;
- // printk("ADDR32 ");
-
-
- value=get_symbol_value(mod,reloc->r_symndx);
-
- // printk("value %x\n",value);
-
- loc=(unsigned int *)(mod->base+reloc->r_vaddr);
-// DPRINT("ADDR32 loc %x value %x *loc %x ",loc,value,*loc);
- *loc=(*loc)+mod->base;
- // *loc = value;
- // *loc=(*loc)+value
-
-// DPRINT("*loc %x\n",*loc);
-
- return(1);
-}
-
-static BOOLEAN do_reloc(module* mod, unsigned int scn_idx)
-/*
- * FUNCTION: Do the relocations for a module section
- * ARGUMENTS:
- * mod = Pointer to the module
- * scn_idx = Index of the section to be relocated
- * RETURNS: Success or failure
- */
-{
- SCNHDR* scn = &mod->scn_list[scn_idx];
- RELOC* reloc = (RELOC *)(mod->raw_data_off + scn->s_relptr);
- int j;
-
- DPRINT("scn_idx %d name %.8s relocs %d\n",scn_idx,
- mod->scn_list[scn_idx].s_name,scn->s_nreloc);
-
- for (j=0;j<scn->s_nreloc;j++)
- {
- // printk("vaddr %x ",reloc->r_vaddr);
- // printk("symndex %x ",reloc->r_symndx);
-
- switch(reloc->r_type)
- {
- case RELOC_ADDR32:
- if (!do_addr32_reloc(mod,scn,reloc))
- {
- return(0);
- }
- break;
-
- case RELOC_REL32:
- if (!do_reloc32_reloc(mod,scn,reloc))
- {
- return(0);
- }
- break;
-
- default:
- DbgPrint("Unknown relocation type %x at %d in module\n",
- reloc->r_type,j);
- return(0);
- }
-
- reloc = (RELOC *)(((unsigned int)reloc) + sizeof(RELOC));
- }
-
- DPRINT("Done relocations for %.8s\n",mod->scn_list[scn_idx].s_name);
-
- return(1);
-}
-
-BOOLEAN process_boot_module(unsigned int start)
-/*
- * FUNCTION: Processes and initializes a module whose disk image has been
- * loaded
- * ARGUMENTS:
- * start = start of the module in memory
- * RETURNS: Success or failure
- */
-{
- FILHDR hdr;
- AOUTHDR ohdr;
- module* mod;
- unsigned int entry=0;
- unsigned int found_entry=0;
- PDRIVER_INITIALIZE func;
- int i;
-
- DPRINT("process_boot_module(start %x)\n",start);
- DPRINT("n = %x\n",*((unsigned int *)start));
- mod=(module *)ExAllocatePool(NonPagedPool,sizeof(module));
-
- DPRINT("magic %x\n",((FILHDR *)start)->f_magic);
-// DbgPrint("Start1 %x\n",*((unsigned int *)0xc0017000));
-
- memcpy(&hdr,(void *)start,FILHSZ);
-
- if (I386BADMAG(hdr))
- {
- DbgPrint("(%s:%d) Module has bad magic value (%x)\n",__FILE__,
- __LINE__,hdr.f_magic);
- return(0);
- }
-
- memcpy(&ohdr,(void *)(start+FILHSZ),AOUTSZ);
-
- mod->sym_list = (SYMENT *)(start + hdr.f_symptr);
-
- mod->str_tab = (char *)(start + hdr.f_symptr +
- hdr.f_nsyms * SYMESZ);
-
- mod->scn_list = (SCNHDR *)(start+FILHSZ+hdr.f_opthdr);
- mod->size=0;
- mod->raw_data_off = start;
- mod->nsyms = hdr.f_nsyms;
-
- /*
- * Determine the length of the module
- */
- for (i=0;i<hdr.f_nscns;i++)
- {
- DPRINT("Section name: %.8s\n",mod->scn_list[i].s_name);
- DPRINT("size %x vaddr %x size %x\n",mod->size,
- mod->scn_list[i].s_vaddr,mod->scn_list[i].s_size);
- if (mod->scn_list[i].s_flags & STYP_TEXT)
- {
- mod->text_base=mod->scn_list[i].s_vaddr;
- }
- if (mod->scn_list[i].s_flags & STYP_DATA)
- {
- mod->data_base=mod->scn_list[i].s_vaddr;
- }
- if (mod->scn_list[i].s_flags & STYP_BSS)
- {
- mod->bss_base=mod->scn_list[i].s_vaddr;
- }
- if (mod->size <
- (mod->scn_list[i].s_vaddr + mod->scn_list[i].s_size))
- {
- mod->size = mod->size + mod->scn_list[i].s_vaddr +
- mod->scn_list[i].s_size;
- }
- }
-
- CHECKPOINT;
-// DbgPrint("Start1 %x\n",*((unsigned int *)0xc0017000));
- mod->base = (unsigned int)MmAllocateSection(mod->size);
-// DbgPrint("Start1 %x\n",*((unsigned int *)0xc0017000));
- if (mod->base == 0)
- {
- DbgPrint("Failed to alloc section for module\n");
- return(0);
- }
- CHECKPOINT;
-
- /*
- * Adjust section vaddrs for allocated area
- */
- mod->data_base=mod->data_base+mod->base;
- mod->text_base=mod->text_base+mod->base;
- mod->bss_base=mod->bss_base+mod->base;
-
- /*
- * Relocate module and fixup imports
- */
- for (i=0;i<hdr.f_nscns;i++)
- {
- if (mod->scn_list[i].s_flags & STYP_TEXT ||
- mod->scn_list[i].s_flags & STYP_DATA)
- {
- memcpy((void *)(mod->base + mod->scn_list[i].s_vaddr),
- (void *)(start + mod->scn_list[i].s_scnptr),
- mod->scn_list[i].s_size);
- if (!do_reloc(mod,i))
- {
- DPRINT("Relocation failed for section %s\n",
- mod->scn_list[i].s_name);
- return(0);
- }
- }
- if (mod->scn_list[i].s_flags & STYP_BSS)
- {
- memset((void *)(mod->base + mod->scn_list[i].s_vaddr),0,
- mod->scn_list[i].s_size);
- }
- }
-
- DbgPrint("Module base: %x\n",mod->base);
-
- /*
- * Find the entry point
- */
-
- for (i=0;i<hdr.f_nsyms;i++)
- {
- char name[255];
- get_symbol_name(mod,i,name);
- if (strcmp(name,"_DriverEntry")==0)
- {
- entry = mod->sym_list[i].e_value;
- found_entry=1;
- DPRINT("Found entry at %x\n",entry);
- }
- }
-
- if (!found_entry)
- {
- DbgPrint("No module entry point defined\n");
- return(0);
- }
-
- /*
- * Call the module initalization routine
- */
- func = (PDRIVER_INITIALIZE)(mod->base + entry);
- return(InitializeLoadedDriver(func));
-}
#include <limits.h>
#include <ddk/ntddk.h>
#include <string.h>
+#include <internal/string.h>
#define NDEBUG
#include <internal/debug.h>
NTSTATUS STDCALL ZwDelayExecution(IN BOOLEAN Alertable,
IN TIME *Interval)
{
- UNIMPLEMENTED;
+ KeBugCheck(0);
+ return(STATUS_UNSUCCESSFUL);
}
NTSTATUS KeDelayExecutionThread(KPROCESSOR_MODE WaitMode,
}
-void InitializeTimer(void)
+VOID KeInitializeTimerImpl(VOID)
/*
* FUNCTION: Initializes timer irq handling
* NOTE: This is only called once from main()
* RJJ 10/12/98 Completed image loader function and added hooks for MZ/PE
* RJJ 10/12/98 Built driver loader function and added hooks for PE/COFF
* RJJ 10/12/98 Rolled in David's code to load COFF drivers
- * JM 14/12/98 Built initail PE user module loader
+ * JM 14/12/98 Built initial PE user module loader
+ * RJJ 06/03/99 Moved user PE loader into NTDLL
*/
/* INCLUDES *****************************************************************/
+#include <windows.h>
+
#include <internal/i386/segment.h>
-#include <internal/ntoskrnl.h>
#include <internal/linkage.h>
#include <internal/module.h>
+#include <internal/ntoskrnl.h>
#include <internal/ob.h>
+#include <internal/ps.h>
+#include <string.h>
#include <internal/string.h>
#include <internal/symbol.h>
#define NDEBUG
#include <internal/debug.h>
+/* FIXME: this should appear in a kernel header file */
+NTSTATUS IoInitializeDriver(PDRIVER_INITIALIZE DriverEntry);
+
/* MACROS ********************************************************************/
/* GLOBALS *******************************************************************/
static unsigned int LdrCOFFGetSymbolValue(module *Module, unsigned int Idx);
static unsigned int LdrCOFFGetSymbolValueByName(module *Module, char *SymbolName, unsigned int Idx);
-/* Image loader forward delcarations */
-static NTSTATUS LdrProcessMZImage(HANDLE ProcessHandle, HANDLE ModuleHandle, HANDLE FileHandle);
-static NTSTATUS LdrProcessPEImage(HANDLE ProcessHandle, HANDLE ModuleHandle, HANDLE FileHandle);
-static NTSTATUS LdrProcessBinImage(HANDLE ProcessHandle, HANDLE ModuleHandle, HANDLE FileHandle);
-
/* FUNCTIONS *****************************************************************/
VOID LdrInitModuleManagement(VOID)
ANSI_STRING AnsiDriverName;
UNICODE_STRING DriverName;
- RtlInitAnsiString(&AnsiDriverName,"\\??\\C:\\reactos\\system\\drivers\\keyboard.o");
+ RtlInitAnsiString(&AnsiDriverName,"\\??\\C:\\reactos\\system\\drivers\\keyboard.sys");
RtlAnsiStringToUnicodeString(&DriverName, &AnsiDriverName, TRUE);
Status = LdrLoadDriver(&DriverName);
RtlFreeUnicodeString(&DriverName);
DbgPrint("driver load failed, status;%d(%x)\n", Status, Status);
DbgPrintErrorMessage(Status);
}
- RtlInitAnsiString(&AnsiDriverName,"\\??\\C:\\reactos\\system\\drivers\\blues.o");
+ RtlInitAnsiString(&AnsiDriverName,"\\??\\C:\\reactos\\system\\drivers\\blue.sys");
RtlAnsiStringToUnicodeString(&DriverName, &AnsiDriverName, TRUE);
Status = LdrLoadDriver(&DriverName);
RtlFreeUnicodeString(&DriverName);
LdrPEProcessDriver(PVOID ModuleLoadBase)
{
unsigned int DriverSize, Idx;
- long int RelocDelta, NumRelocs;
- DWORD CurrentSize;
+ ULONG RelocDelta, NumRelocs;
+ DWORD CurrentSize, TotalRelocs;
PVOID DriverBase, CurrentBase, EntryPoint;
PULONG PEMagic;
PIMAGE_DOS_HEADER PEDosHeader;
CHECKPOINT;
/* Determine the size of the module */
- DPRINT("Sections: (section align:%08lx)\n",
- PEOptionalHeader->SectionAlignment);
- DriverSize = PESectionHeaders[0].PointerToRawData;
- for (Idx = 0; Idx < PEFileHeader->NumberOfSections; Idx++)
- {
- DPRINT("Name:%-8.8s VA:%08lx RawSz:%6d Offs:%08lx CHAR:%08lx OfsA: %08lx\n",
- PESectionHeaders[Idx].Name,
- PESectionHeaders[Idx].VirtualAddress,
- PESectionHeaders[Idx].SizeOfRawData,
- PESectionHeaders[Idx].PointerToRawData,
- PESectionHeaders[Idx].Characteristics,
- DriverSize);
- DriverSize += ROUND_UP(PESectionHeaders[Idx].SizeOfRawData,
- PEOptionalHeader->SectionAlignment);
- }
- DPRINT("DriverSize computed by using section headers: %d(%08lx)\n",
- DriverSize,
- DriverSize);
-
+
+ DriverSize = PEOptionalHeader->SizeOfImage;
+ DPRINT("DriverSize %x\n",DriverSize);
+
/* Allocate a virtual section for the module */
DriverBase = MmAllocateSection(DriverSize);
if (DriverBase == 0)
if (PESectionHeaders[Idx].Characteristics &
(IMAGE_SECTION_CHAR_CODE | IMAGE_SECTION_CHAR_DATA))
{
- memcpy(CurrentBase,
+ DPRINT("PESectionHeaders[Idx].VirtualAddress + DriverBase %x\n",
+ PESectionHeaders[Idx].VirtualAddress + DriverBase);
+ memcpy(PESectionHeaders[Idx].VirtualAddress + DriverBase,
(PVOID)(ModuleLoadBase + PESectionHeaders[Idx].PointerToRawData),
PESectionHeaders[Idx].SizeOfRawData);
}
else
{
- memset(CurrentBase, '\0', PESectionHeaders[Idx].SizeOfRawData);
+ DPRINT("PESectionHeaders[Idx].VirtualAddress + DriverBase %x\n",
+ PESectionHeaders[Idx].VirtualAddress + DriverBase);
+ memset(PESectionHeaders[Idx].VirtualAddress + DriverBase,
+ '\0', PESectionHeaders[Idx].SizeOfRawData);
}
CurrentSize += ROUND_UP(PESectionHeaders[Idx].SizeOfRawData,
PEOptionalHeader->SectionAlignment);
/* Perform relocation fixups */
RelocDelta = (DWORD) DriverBase - PEOptionalHeader->ImageBase;
- RelocDir = (PRELOCATION_DIRECTORY) ((DWORD)ModuleLoadBase +
- PEOptionalHeader->DataDirectory[
+ RelocDir = (PRELOCATION_DIRECTORY)(PEOptionalHeader->DataDirectory[
IMAGE_DIRECTORY_ENTRY_BASERELOC].VirtualAddress);
DPRINT("DrvrBase:%08lx ImgBase:%08lx RelocDelta:%08lx\n",
DriverBase,
PEOptionalHeader->ImageBase,
RelocDelta);
- while (RelocDir->SizeOfBlock != 0)
+ DPRINT("RelocDir %x\n",RelocDir);
+ for (Idx = 0; Idx < PEFileHeader->NumberOfSections; Idx++)
+ {
+ if (PESectionHeaders[Idx].VirtualAddress == (DWORD)RelocDir)
+ {
+ DPRINT("Name %.8s PESectionHeader[Idx].PointerToRawData %x\n",
+ PESectionHeaders[Idx].Name,
+ PESectionHeaders[Idx].PointerToRawData);
+ RelocDir = PESectionHeaders[Idx].PointerToRawData +
+ ModuleLoadBase;
+ CurrentSize = PESectionHeaders[Idx].Misc.VirtualSize;
+ break;
+ }
+ }
+ DPRINT("RelocDir %08lx CurrentSize %08lx\n", RelocDir, CurrentSize);
+ TotalRelocs = 0;
+ while (TotalRelocs < CurrentSize && RelocDir->SizeOfBlock != 0)
{
NumRelocs = (RelocDir->SizeOfBlock - sizeof(RELOCATION_DIRECTORY)) /
sizeof(WORD);
- DPRINT("RelocDir at %08lx for VA %08lx with %08lx relocs\n",
+/* DPRINT("RelocDir at %08lx for VA %08lx with %08lx relocs\n",
RelocDir,
RelocDir->VirtualAddress,
- NumRelocs);
+ NumRelocs);*/
RelocEntry = (PRELOCATION_ENTRY) ((DWORD)RelocDir +
sizeof(RELOCATION_DIRECTORY));
for (Idx = 0; Idx < NumRelocs; Idx++)
{
- DPRINT(" reloc at %08lx %x %s old:%08lx new:%08lx\n",
- DriverBase + RelocDir->VirtualAddress +
- (RelocEntry[Idx].TypeOffset & 0x0fff),
- (RelocEntry[Idx].TypeOffset >> 12) & 0xf,
- (RelocEntry[Idx].TypeOffset >> 12) & 0xf ? "HIGHLOW" : "ABS",
- *(PDWORD)((DWORD) DriverBase + RelocDir->VirtualAddress +
- (RelocEntry[Idx].TypeOffset & 0x0fff)),
- (*(PDWORD)((DWORD) DriverBase + RelocDir->VirtualAddress +
- (RelocEntry[Idx].TypeOffset & 0x0fff))) + RelocDelta);
- if (((RelocEntry[Idx].TypeOffset >> 12) & 0xf) == 3)
+ ULONG Offset;
+ ULONG Type;
+ PDWORD RelocItem;
+
+ Offset = RelocEntry[Idx].TypeOffset & 0xfff;
+ Type = (RelocEntry[Idx].TypeOffset >> 12) & 0xf;
+ RelocItem = (PDWORD)(DriverBase + RelocDir->VirtualAddress +
+ Offset);
+/* DPRINT(" reloc at %08lx %x %s old:%08lx new:%08lx\n",
+ RelocItem,
+ Type,
+ Type ? "HIGHLOW" : "ABS",
+ *RelocItem,
+ (*RelocItem) + RelocDelta); */
+ if (Type == 3)
{
- (*(PDWORD)((DWORD) DriverBase + RelocDir->VirtualAddress +
- (RelocEntry[Idx].TypeOffset & 0x0fff))) += RelocDelta;
+ (*RelocItem) += RelocDelta;
}
- else if (((RelocEntry[Idx].TypeOffset >> 12) & 0xf) != 0)
+ else if (Type != 0)
{
- DPRINT("Unknown relocation type %x\n",
- (RelocEntry[Idx].TypeOffset >> 12) & 0xf);
+ DPRINT("Unknown relocation type %x\n",Type);
return STATUS_UNSUCCESSFUL;
}
}
+ TotalRelocs += RelocDir->SizeOfBlock;
RelocDir = (PRELOCATION_DIRECTORY)((DWORD)RelocDir +
RelocDir->SizeOfBlock);
+// DPRINT("TotalRelocs: %08lx CurrentSize: %08lx\n", TotalRelocs, CurrentSize);
}
-
+
+ DPRINT("PEOptionalHeader->DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT] %x\n",
+ PEOptionalHeader->DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT]
+ .VirtualAddress);
/* Perform import fixups */
if (PEOptionalHeader->DataDirectory[
IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress)
/* Process each import module */
ImportModuleDirectory = (PIMAGE_IMPORT_MODULE_DIRECTORY)
- ((DWORD)ModuleLoadBase + PEOptionalHeader->
+ ((DWORD)DriverBase + PEOptionalHeader->
DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress);
while (ImportModuleDirectory->dwRVAModuleName)
{
/* Check to make sure that import lib is kernel */
Library = NULL;
- pName = (PCHAR) ModuleLoadBase +
+ pName = (PCHAR) DriverBase +
ImportModuleDirectory->dwRVAModuleName;
- DPRINT("Import module: %s\n", pName);
- if (strcmp(pName, "ntoskrnl.exe") &&
- strcmp(pName, "roskrnl.exe") &&
- strcmp(pName, "HAL.dll"))
+// DPRINT("Import module: %s\n", pName);
+ if (strcmp(pName, "ntoskrnl.exe")!=0 &&
+ strcmp(pName, "HAL.dll")!=0)
{
DPRINT("Kernel mode DLLs are currently unsupported\n");
}
/* Get the import address list */
- ImportAddressList = (PVOID *) ((DWORD)ModuleLoadBase +
+ ImportAddressList = (PVOID *) ((DWORD)DriverBase +
ImportModuleDirectory->dwRVAFunctionAddressList);
/* Get the list of functions to import */
if (ImportModuleDirectory->dwRVAFunctionNameList != 0)
{
- FunctionNameList = (PULONG) ((DWORD)ModuleLoadBase +
+ FunctionNameList = (PULONG) ((DWORD)DriverBase +
ImportModuleDirectory->dwRVAFunctionNameList);
}
else
{
- FunctionNameList = (PULONG) ((DWORD)ModuleLoadBase +
+ FunctionNameList = (PULONG) ((DWORD)DriverBase +
ImportModuleDirectory->dwRVAFunctionAddressList);
}
{
if ((*FunctionNameList) & 0x80000000) // hint
{
- DPRINT(" Hint: %08lx\n", *FunctionNameList);
+// DPRINT(" Hint: %08lx\n", *FunctionNameList);
if (Library == NULL)
{
DPRINT("Hints for kernel symbols are not handled.\n");
}
else // hint-name
{
- pName = (PCHAR)((DWORD)ModuleLoadBase +
+ pName = (PCHAR)((DWORD)DriverBase+
*FunctionNameList + 2);
- pHint = (PWORD)((DWORD)ModuleLoadBase + *FunctionNameList);
- DPRINT(" Hint:%04x Name:%s\n", pHint, pName);
+ pHint = (PWORD)((DWORD)DriverBase + *FunctionNameList);
+ // DPRINT(" Hint:%04x Name:%s\n", pHint, pName);
/* Get address for symbol */
if (Library == NULL)
/* Compute address of entry point */
EntryPoint = (PVOID) ((DWORD)DriverBase + PEOptionalHeader->AddressOfEntryPoint);
- return InitializeLoadedDriver(EntryPoint);
+ return IoInitializeDriver(EntryPoint);
}
NTSTATUS
/* Cleanup */
ExFreePool(Module);
- return InitializeLoadedDriver(EntryRoutine);
+ return IoInitializeDriver(EntryRoutine);
}
/* LdrCOFFDoRelocations
LdrGetKernelSymbolAddr(char *Name)
{
int i = 0;
-
+ char* s;
+
+ if ((s=strchr(Name,'@'))!=NULL)
+ {
+ *s=0;
+ DbgPrint("Name %s ",Name);
+ }
while (symbol_table[i].name != NULL)
{
if (strcmp(symbol_table[i].name, Name) == 0)
{
+ if (s!=NULL)
+ {
+ *s=0;
+ DbgPrint("Matched with %s\n",symbol_table[i].name);
+ }
return symbol_table[i].value;
}
i++;
}
-
- return 0L;
+ if (s!=NULL)
+ {
+ *s=0;
+ }
+ return 0L;
}
static unsigned int
return 0L;
}
-NTSTATUS LdrLoadLibrary(HANDLE ProcessHandle,
- PHANDLE ModuleHandle,
- PCHAR Name)
-{
-#if 0
- NTSTATUS Status;
- ANSI_STRING afilename;
- UNICODE_STRING ufilename,umodName;
- PMODULE *Library, *Module;
- OBJECT_ATTRIBUTES attr;
- PWSTR Ignored;
- char name2[512];
-
- /* FIXME: this is broke */
- /* FIXME: check for module already loaded */
- /* FIXME: otherwise load module */
- /* FIXME: we need to fix how modules are loaded so that they can
- be shared... :( */
-
- /* If module is already loaded, get a reference and return it */
- strcpy(name2, "\\modules\\");
- strcat(name2, Name);
- RtlInitAnsiString(&afilename, name2);
- RtlAnsiStringToUnicodeString(&umodName, &afilename, TRUE);
- InitializeObjectAttributes(&attr, &umodName, 0, NULL, NULL);
- Status = ObOpenObjectByName(&attr, (PVOID *) &Library, &Ignored);
- DPRINT("LoadLibrary : Status=%x,pLibrary=%x\n",Status, Library);
- if (!NT_SUCCESS(Status) || Library == NULL)
- {
- strcpy(name2, "\\??\\C:\\reactos\\system\\");
- strcat(name2, name);
- RtlInitAnsiString(&afilename, name2);
- RtlAnsiStringToUnicodeString(&ufilename, &afilename, TRUE);
- DPRINT("LoadLibrary,load %s\n", name2);
- Library = LdrLoadImage(&ufilename);
- /* FIXME: execute start code ? */
- Module = ObGenericCreateObject(NULL, PROCESS_ALL_ACCESS, &attr, ObModuleType);
- if (Module)
- {
- memcpy(Module, Library, PMODULE);
- }
- else
- {
- DbgPrint("library object not created\n");
- }
- RtlFreeUnicodeString(&ufilename);
- Status = ObOpenObjectByName(&attr, (PVOID *)&Library, &Ignored);
- }
- else
- {
- DPRINT("Library already loaded\n");
- *Module = Library
- }
- RtlFreeUnicodeString(&umodName);
-
- return STATUS_SUCCESS;
-#endif
- UNIMPLEMENTED;
-}
-
/* LdrLoadImage
* FUNCTION:
- * Loads a module into the specified process
+ * Builds the initial environment for a process. Should be used
+ * to load the initial user process.
* ARGUMENTS:
* HANDLE ProcessHandle handle of the process to load the module into
- * PHANDLE ModuleHandle handle of the loaded module
* PUNICODE_STRING Filename name of the module to load
* RETURNS:
* NTSTATUS
*/
-NTSTATUS
-LdrLoadImage(HANDLE ProcessHandle,
- PHANDLE ModuleHandle,
- PUNICODE_STRING Filename)
+#define STACK_TOP (0xb0000000)
+
+NTSTATUS LdrLoadImage(HANDLE ProcessHandle, PUNICODE_STRING Filename)
{
char BlockBuffer[1024];
+ DWORD ImageBase, LdrStartupAddr, StackBase;
+ ULONG ImageSize, StackSize;
NTSTATUS Status;
OBJECT_ATTRIBUTES FileObjectAttributes;
- HANDLE FileHandle;
- PMODULE Module;
- PIMAGE_DOS_HEADER PEDosHeader;
-
- /* FIXME: should DLLs be named sections? */
-
- /* Open the image file */
+ HANDLE FileHandle, SectionHandle, ThreadHandle;
+ CONTEXT Context;
+ ANSI_STRING AnsiString;
+ UNICODE_STRING DllPathname;
+ PIMAGE_DOS_HEADER DosHeader;
+ PIMAGE_NT_HEADERS NTHeaders;
+ ULONG BytesWritten;
+ ULONG InitialViewSize;
+ ULONG i;
+ HANDLE DupSectionHandle;
+
+ /* Locate and open NTDLL to determine ImageBase and LdrStartup */
+ RtlInitUnicodeString(&DllPathname,L"\\??\\C:\\reactos\\system\\ntdll.dll");
InitializeObjectAttributes(&FileObjectAttributes,
- Filename,
+ &DllPathname,
0,
NULL,
NULL);
- Status = ZwOpenFile(&FileHandle, 0, &FileObjectAttributes, NULL, 0, 0);
+ DPRINT("Opening NTDLL\n");
+ Status = ZwOpenFile(&FileHandle, FILE_ALL_ACCESS, &FileObjectAttributes, NULL, 0, 0);
if (!NT_SUCCESS(Status))
{
- return Status;
- }
+ DPRINT("NTDLL open failed ");
+ DbgPrintErrorMessage(Status);
- /* Build a module structure for the image */
- Module = ObCreateObject(ModuleHandle,
- PROCESS_ALL_ACCESS,
- NULL,
- ObModuleType);
- if (Module == NULL)
- {
- ZwClose(FileHandle);
return Status;
}
-
- /* Read first block of image to determine type */
Status = ZwReadFile(FileHandle, 0, 0, 0, 0, BlockBuffer, 1024, 0, 0);
if (!NT_SUCCESS(Status))
{
- ObDereferenceObject(*ModuleHandle);
- *ModuleHandle = NULL;
+ DPRINT("NTDLL header read failed ");
+ DbgPrintErrorMessage(Status);
ZwClose(FileHandle);
return Status;
}
-
- /* If MZ header exists */
- PEDosHeader = (PIMAGE_DOS_HEADER) BlockBuffer;
- if (PEDosHeader->e_magic == IMAGE_DOS_MAGIC &&
- PEDosHeader->e_lfanew != 0L &&
- *(PULONG)((PUCHAR)BlockBuffer + PEDosHeader->e_lfanew) == IMAGE_PE_MAGIC)
- {
- Status = LdrProcessPEImage(ProcessHandle,
- ModuleHandle,
- FileHandle);
- }
- else if (PEDosHeader->e_magic == 0x54AD)
- {
- Status = LdrProcessMZImage(ProcessHandle,
- ModuleHandle,
- FileHandle);
- }
- else /* Assume bin format and load */
- {
- Status = LdrProcessBinImage(ProcessHandle,
- ModuleHandle,
- FileHandle);
- }
- /* FIXME: {else} could check for a.out, ELF, COFF, etc. images here... */
-
- /* FIXME: should we unconditionally dereference the module handle here? */
- if (!NT_SUCCESS(Status))
+ /* FIXME: this will fail if the NT headers are more than 1024 bytes from start */
+ DosHeader = (PIMAGE_DOS_HEADER) BlockBuffer;
+ if (DosHeader->e_magic != IMAGE_DOS_MAGIC ||
+ DosHeader->e_lfanew == 0L ||
+ *(PULONG)((PUCHAR)BlockBuffer + DosHeader->e_lfanew) != IMAGE_PE_MAGIC)
{
- ObDereferenceObject(*ModuleHandle);
- *ModuleHandle = NULL;
- }
- ZwClose(FileHandle);
-
- return Status;
-}
-
-static NTSTATUS
-LdrProcessMZImage(HANDLE ProcessHandle,
- HANDLE ModuleHandle,
- HANDLE FileHandle)
-{
-
- /* FIXME: map VDM into low memory */
- /* FIXME: Build/Load image sections */
-
- return STATUS_NOT_IMPLEMENTED;
-}
+ DPRINT("NTDLL format invalid\n");
+ ZwClose(FileHandle);
-static NTSTATUS
-LdrProcessPEImage(HANDLE ProcessHandle,
- HANDLE ModuleHandle,
- HANDLE FileHandle)
-{
- int i;
- NTSTATUS Status;
- PVOID BaseSection;
- PIMAGE_DOS_HEADER DosHeader;
- PIMAGE_NT_HEADERS NTHeaders;
- PMODULE Module;
- LARGE_INTEGER SectionOffset;
- HANDLE SectionHandle;
-
- /* Allocate memory for headers */
- Module = HEADER_TO_BODY(ModuleHandle);
- if (Module == NULL)
- {
return STATUS_UNSUCCESSFUL;
}
- DosHeader = (PIMAGE_DOS_HEADER)ExAllocatePool(NonPagedPool,
- sizeof(IMAGE_DOS_HEADER) +
- sizeof(IMAGE_NT_HEADERS));
- if (DosHeader == NULL)
- {
- return STATUS_UNSUCCESSFUL;
- }
- NTHeaders = (PIMAGE_NT_HEADERS)((PUCHAR) DosHeader + sizeof(IMAGE_DOS_HEADER));
-
- /* Read the headers into memory */
- memset(Module, '\0', sizeof(PMODULE));
- Status = ZwReadFile(FileHandle,
- NULL, NULL, NULL, NULL,
- DosHeader,
- sizeof(IMAGE_DOS_HEADER),
- 0, 0);
- if (!NT_SUCCESS(Status))
- {
- ExFreePool(DosHeader);
- return Status;
- }
- SET_LARGE_INTEGER_HIGH_PART(SectionOffset, 0);
- SET_LARGE_INTEGER_LOW_PART(SectionOffset, DosHeader->e_lfanew);
- Status = ZwReadFile(FileHandle,
- NULL, NULL, NULL, NULL,
- NTHeaders,
- sizeof(IMAGE_NT_HEADERS),
- &SectionOffset,
- 0);
- if (!NT_SUCCESS(Status))
- {
- ExFreePool(DosHeader);
- return Status;
- }
-
- /* Create the section for the code */
+ NTHeaders = (PIMAGE_NT_HEADERS)(BlockBuffer + DosHeader->e_lfanew);
+ ImageBase = NTHeaders->OptionalHeader.ImageBase;
+ ImageSize = NTHeaders->OptionalHeader.SizeOfImage;
+ /* FIXME: retrieve the offset of LdrStartup from NTDLL */
+ DPRINT("ImageBase %x\n",ImageBase);
+ LdrStartupAddr = ImageBase + NTHeaders->OptionalHeader.AddressOfEntryPoint;
+
+ /* Create a section for NTDLL */
Status = ZwCreateSection(&SectionHandle,
SECTION_ALL_ACCESS,
NULL,
FileHandle);
if (!NT_SUCCESS(Status))
{
+ DPRINT("NTDLL create section failed ");
+ DbgPrintErrorMessage(Status);
+ ZwClose(FileHandle);
+
return Status;
}
- /* Map the Image into the process */
- Module->Flags = MODULE_FLAG_PE;
- Module->Base = (PVOID) NTHeaders->OptionalHeader.ImageBase;
- Module->Size = NTHeaders->OptionalHeader.SizeOfImage;
+ /* Map the NTDLL into the process */
+ InitialViewSize = DosHeader->e_lfanew + sizeof(IMAGE_NT_HEADERS)
+ + sizeof(IMAGE_SECTION_HEADER) * NTHeaders->FileHeader.NumberOfSections;
Status = ZwMapViewOfSection(SectionHandle,
ProcessHandle,
- &Module->Base,
+ (PVOID *)&ImageBase,
0,
- Module->Size,
+ InitialViewSize,
NULL,
- &Module->Size,
+ &InitialViewSize,
0,
MEM_COMMIT,
PAGE_READWRITE);
if (!NT_SUCCESS(Status))
{
+ DPRINT("NTDLL map view of secion failed ");
+ DbgPrintErrorMessage(Status);
+
/* FIXME: destroy the section here */
- ExFreePool(DosHeader);
- return Status;
- }
-
- /* FIXME: create stack and other BSS sections */
- /* FIXME: if actual load address is different from ImageBase, then reloc */
- /* FIXME: do import fixups/load required libraries */
-
-#if 0
- /* Load headers into virtual memory */
- Status = ZwReadFile(FileHandle,
- NULL, NULL, NULL, NULL,
- Module->Base,
- NTHeaders->OptionalHeader.SizeOfHeaders,
- 0, 0);
- if (!NT_SUCCESS(Status))
- {
- ZwFreeVirtualMemory(ProcessHandle,
- Module->Base,
- 0,
- MEM_RELEASE);
- ExFreePool(DosHeader);
- return Status;
- }
- /* Adjust module pointers into virtual memory */
- DosHeader = (PIMAGE_DOS_HEADER) Module->Base;
- NTHeaders = (PIMAGE_NT_HEADERS) ((PUCHAR)Module->Base +
- DosHeader->e_lfanew);
- Module->Image.PE.FileHeader = (PIMAGE_FILE_HEADER) ((PUCHAR)NTHeaders +
- sizeof(DWORD));
- Module->Image.PE.OptionalHeader = (PIMAGE_OPTIONAL_HEADER)
- ((PUCHAR)Module->Image.PE.FileHeader + sizeof(IMAGE_FILE_HEADER));
- Module->Image.PE.SectionList = (PCOFF_SECTION_HEADER) ((PUCHAR)NTHeaders +
- sizeof(IMAGE_NT_HEADERS));
-
- /* Build Image Sections */
- /* FIXME: should probably use image directory to load sections. */
- for (i = 0; i < Module->Image.PE.FileHeader->NumberOfSections; i++)
- {
- DPRINT("section %d\n", i);
- BaseSection = (PVOID)((PCHAR) Module->Base +
- Module->Image.PE.SectionList[i].s_vaddr);
+ ZwClose(FileHandle);
- /* Load code and initialized data sections from disk */
- if ((Module->Image.PE.SectionList[i].s_flags & STYP_TEXT) ||
- (Module->Image.PE.SectionList[i].s_flags & STYP_DATA))
- {
- SET_LARGE_INTEGER_HIGH_PART(SectionOffset, 0);
- SET_LARGE_INTEGER_LOW_PART(SectionOffset,
- Module->Image.PE.SectionList[i].s_scnptr);
-
- /* FIXME: should probably map sections into sections */
- Status = ZwReadFile(FileHandle,
- NULL, NULL, NULL, NULL,
- Module->Base + Module->Image.PE.SectionList[i].s_vaddr,
- min(Module->Image.PE.SectionList[i].s_size,
- Module->Image.PE.SectionList[i].s_paddr),
- &SectionOffset, 0);
- if (!NT_SUCCESS(Status))
- {
- ZwFreeVirtualMemory(ProcessHandle,
- Module->Base,
- 0,
- MEM_RELEASE);
- ExFreePool(DosHeader);
- return Status;
- }
- }
- else if (Module->Image.PE.SectionList[i].s_flags & STYP_BSS)
- {
- memset((PVOID)(Module->Base +
- Module->Image.PE.SectionList[i].s_vaddr),
- 0,
- Module->Image.PE.SectionList[i].s_size);
- }
+ return Status;
}
+ for (i=0; i<NTHeaders->FileHeader.NumberOfSections; i++)
+ {
+ PIMAGE_SECTION_HEADER Sections;
+ LARGE_INTEGER Offset;
+ ULONG Base;
+
+ Sections = (PIMAGE_SECTION_HEADER)SECHDROFFSET(BlockBuffer);
+ Base = Sections[i].VirtualAddress + ImageBase;
+ SET_LARGE_INTEGER_HIGH_PART(Offset,0);
+ SET_LARGE_INTEGER_LOW_PART(Offset,Sections[i].PointerToRawData);
+ Status = ZwMapViewOfSection(SectionHandle,
+ ProcessHandle,
+ (PVOID *)&Base,
+ 0,
+ Sections[i].Misc.VirtualSize,
+ &Offset,
+ &Sections[i].Misc.VirtualSize,
+ 0,
+ MEM_COMMIT,
+ PAGE_READWRITE);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT("NTDLL map view of secion failed ");
+ DbgPrintErrorMessage(Status);
+
+ /* FIXME: destroy the section here */
+
+ ZwClose(FileHandle);
+ return Status;
+ }
+ }
+ ZwClose(FileHandle);
- /* Resolve Import Library references */
- if (Module->Image.PE.OptionalHeader->DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress)
+ /* Open process image to determine ImageBase and StackBase/Size */
+ InitializeObjectAttributes(&FileObjectAttributes,
+ Filename,
+ 0,
+ NULL,
+ NULL);
+ DPRINT("Opening image file %w\n",FileObjectAttributes.ObjectName->Buffer);
+ Status = ZwOpenFile(&FileHandle, FILE_ALL_ACCESS, &FileObjectAttributes,
+ NULL, 0, 0);
+ if (!NT_SUCCESS(Status))
{
- PIMAGE_IMPORT_MODULE_DIRECTORY ImportModuleDirectory;
-
- /* Process each import module */
- ImportModuleDirectory = (PIMAGE_IMPORT_MODULE_DIRECTORY)
- ((PUCHAR)Module->Base + Module->Image.PE.OptionalHeader->
- DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress);
- while (ImportModuleDirectory->dwRVAModuleName)
- {
- PMODULE Library;
- PVOID *LibraryExports;
- PVOID *ImportAddressList; // was pImpAddr
- PULONG FunctionNameList;
- DWORD pName;
- PWORD pHint;
-
- /* Load the library module into the process */
- /* FIXME: this should take a UNICODE string */
- Status = LdrLoadLibrary(ProcessHandle,
- &Library,
- (PCHAR)(Module->Base +
- ImportModuleDirectory->dwRVAModuleName));
- if (!NT_SUCCESS(Status))
- {
- /* FIXME: Dereference all loaded modules */
- ZwFreeVirtualMemory(ProcessHandle,
- Module->Base,
- 0,
- MEM_RELEASE);
- ExFreePool(DosHeader);
-
- return Status;
- }
-
- /* Get the address of the export list for the library */
- LibraryExports = (PVOID *)(Library->Base +
- Library->Image.PE.OptionalHeader->
- DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress +
- sizeof(IMAGE_EXPORT_DIRECTORY));
-
- /* Get the import address list */
- ImportAddressList = (PVOID *)
- ((PCHAR)Module->Image.PE.OptionalHeader->ImageBase +
- ImportModuleDirectory->dwRVAFunctionAddressList);
-
- /* Get the list of functions to import */
- if (ImportModuleDirectory->dwRVAFunctionNameList != 0)
- {
- FunctionNameList = (PULONG) ((PCHAR)Module->Base +
- ImportModuleDirectory->dwRVAFunctionNameList);
- }
- else
- {
- FunctionNameList = (PULONG) ((PCHAR)Module->Base +
- ImportModuleDirectory->dwRVAFunctionAddressList);
- }
-
- /* Walk through function list and fixup addresses */
- while(*FunctionNameList != 0L)
- {
- if ((*FunctionNameList) & 0x80000000) // hint
- {
- *ImportAddressList = LibraryExports[(*FunctionNameList) & 0x7fffffff];
- }
- else // hint-name
- {
- pName = (DWORD)((PCHAR)Module->Base + *FunctionNameList + 2);
- pHint = (PWORD)((PCHAR)Module->Base + *FunctionNameList);
-
- /* FIXME: verify name */
-
- *ImportAddressList = LibraryExports[*pHint];
- }
-
- /* FIXME: verify value of hint */
+ DPRINT("Image open failed ");
+ DbgPrintErrorMessage(Status);
- ImportAddressList++;
- FunctionNameList++;
- }
- ImportModuleDirectory++;
- }
+ return Status;
}
-
- /* Do fixups */
- if (Module->Base != (PVOID)Module->Image.PE.OptionalHeader->ImageBase)
+ Status = ZwReadFile(FileHandle, 0, 0, 0, 0, BlockBuffer, 1024, 0, 0);
+ if (!NT_SUCCESS(Status))
{
- USHORT NumberOfEntries;
- PUSHORT pValue16;
- ULONG RelocationRVA;
- ULONG Delta32, Offset;
- PULONG pValue32;
- PRELOCATION_DIRECTORY RelocationDir;
- PRELOCATION_ENTRY RelocationBlock;
-
- RelocationRVA = NTHeaders->OptionalHeader.DataDirectory[
- IMAGE_DIRECTORY_ENTRY_BASERELOC].VirtualAddress;
- if (RelocationRVA)
- {
- RelocationDir = (PRELOCATION_DIRECTORY)
- ((PCHAR)Module->Base + RelocationRVA);
- while (RelocationDir->SizeOfBlock)
- {
- Delta32 = (unsigned long)(Module->Base - NTHeaders->OptionalHeader.ImageBase);
- RelocationBlock = (PRELOCATION_ENTRY)
- (RelocationRVA + Module->Base + sizeof(RELOCATION_DIRECTORY));
- NumberOfEntries =
- (RelocationDir->SizeOfBlock - sizeof(RELOCATION_DIRECTORY)) /
- sizeof(RELOCATION_ENTRY);
- for (i = 0; i < NumberOfEntries; i++)
- {
- Offset = (RelocationBlock[i].TypeOffset & 0xfff) + RelocationDir->VirtualAddress;
- switch (RelocationBlock[i].TypeOffset >> 12)
- {
- case TYPE_RELOC_ABSOLUTE:
- break;
-
- case TYPE_RELOC_HIGH:
- pValue16 = (PUSHORT) (Module->Base + Offset);
- *pValue16 += Delta32 >> 16;
- break;
-
- case TYPE_RELOC_LOW:
- pValue16 = (PUSHORT)(Module->Base + Offset);
- *pValue16 += Delta32 & 0xffff;
- break;
-
- case TYPE_RELOC_HIGHLOW:
- pValue32 = (PULONG) (Module->Base + Offset);
- *pValue32 += Delta32;
- break;
-
- case TYPE_RELOC_HIGHADJ:
- /* FIXME: do the highadjust fixup */
- DbgPrint("TYPE_RELOC_HIGHADJ fixup not implemented, sorry\n");
-// break;
-
- default:
- DbgPrint("unexpected fixup type\n");
-
- /* FIXME: Dereference all loaded modules */
-
- ZwFreeVirtualMemory(ProcessHandle,
- Module->Base,
- 0,
- MEM_RELEASE);
- ExFreePool(DosHeader);
- return STATUS_UNSUCCESSFUL;
- }
- }
- RelocationRVA += RelocationDir->SizeOfBlock;
- RelocationDir = (PRELOCATION_DIRECTORY)((PCHAR)Module->Base +
- RelocationRVA);
- }
- }
- }
-#endif
-
- /* FIXME: Create the stack for the process */
- /* FIXME: Setup the context for the initial thread */
- /* FIXME: Create the initial thread */
-
-// fail: ZwFreeVirtualMemory(ProcessHandle, Module->ImageBase, 0, MEM_RELEASE);
- ExFreePool(DosHeader);
-
- return STATUS_NOT_IMPLEMENTED;
-}
+ DPRINT("Image header read failed ");
+ DbgPrintErrorMessage(Status);
+ ZwClose(FileHandle);
-NTSTATUS
-LdrProcessBinImage(HANDLE ProcessHandle,
- HANDLE ModuleHandle,
- HANDLE FileHandle)
-{
- NTSTATUS Status;
- FILE_STANDARD_INFORMATION FileStdInfo;
- ULONG SectionSize;
- HANDLE ThreadHandle;
- CONTEXT Context;
- HANDLE SectionHandle;
- PVOID BaseAddress;
+ return Status;
+ }
- /* FIXME: should set module pointers */
+ /* FIXME: this will fail if the NT headers are more than 1024 bytes from start */
- /* Get the size of the file for the section */
- Status = ZwQueryInformationFile(FileHandle,
- NULL,
- &FileStdInfo,
- sizeof(FileStdInfo),
- FileStandardInformation);
- if (!NT_SUCCESS(Status))
+ DosHeader = (PIMAGE_DOS_HEADER) BlockBuffer;
+ if (DosHeader->e_magic != IMAGE_DOS_MAGIC ||
+ DosHeader->e_lfanew == 0L ||
+ *(PULONG)((PUCHAR)BlockBuffer + DosHeader->e_lfanew) != IMAGE_PE_MAGIC)
{
- return Status;
+ DPRINT("Image invalid format rc=%08lx\n", Status);
+ ZwClose(FileHandle);
+
+ return STATUS_UNSUCCESSFUL;
}
+ NTHeaders = (PIMAGE_NT_HEADERS)(BlockBuffer + DosHeader->e_lfanew);
+ ImageBase = NTHeaders->OptionalHeader.ImageBase;
+ ImageSize = NTHeaders->OptionalHeader.SizeOfImage;
- /* Create the section for the code */
+ /* Create a section for the image */
Status = ZwCreateSection(&SectionHandle,
SECTION_ALL_ACCESS,
NULL,
FileHandle);
if (!NT_SUCCESS(Status))
{
+ DPRINT("Image create section failed ");
+ DbgPrintErrorMessage(Status);
+ ZwClose(FileHandle);
+
return Status;
}
- /* Map a view of the section into the desired process */
- BaseAddress = (PVOID)0x10000;
- SectionSize = GET_LARGE_INTEGER_LOW_PART(FileStdInfo.AllocationSize);
- Status = ZwMapViewOfSection(SectionHandle,
- ProcessHandle,
- &BaseAddress,
- 0,
- SectionSize,
- NULL,
- &SectionSize,
- 0,
- MEM_COMMIT,
- PAGE_READWRITE);
+ /* Map the image into the process */
+ InitialViewSize = DosHeader->e_lfanew + sizeof(IMAGE_NT_HEADERS)
+ + sizeof(IMAGE_SECTION_HEADER) * NTHeaders->FileHeader.NumberOfSections;
+ DPRINT("InitialViewSize %x\n",InitialViewSize);
+ Status = ZwMapViewOfSection(SectionHandle,
+ ProcessHandle,
+ (PVOID *)&ImageBase,
+ 0,
+ InitialViewSize,
+ NULL,
+ &InitialViewSize,
+ 0,
+ MEM_COMMIT,
+ PAGE_READWRITE);
if (!NT_SUCCESS(Status))
{
+ DPRINT("Image map view of section failed ");
+ DbgPrintErrorMessage(Status);
+
/* FIXME: destroy the section here */
- return Status;
+
+ ZwClose(FileHandle);
+
+ return Status;
}
-
- /* Setup the context for the initial thread */
- memset(&Context,0,sizeof(CONTEXT));
- Context.SegSs = USER_DS;
- Context.Esp = 0x2000;
- Context.EFlags = 0x202;
- Context.SegCs = USER_CS;
- Context.Eip = 0x10000;
- Context.SegDs = USER_DS;
- Context.SegEs = USER_DS;
- Context.SegFs = USER_DS;
- Context.SegGs = USER_DS;
-
- /* Create the stack for the process */
- BaseAddress = (PVOID) 0x1000;
- SectionSize = 0x1000;
+ ZwClose(FileHandle);
+
+ /* Create page backed section for stack */
+ StackBase = (STACK_TOP - NTHeaders->OptionalHeader.SizeOfStackReserve);
+ StackSize = NTHeaders->OptionalHeader.SizeOfStackReserve;
Status = ZwAllocateVirtualMemory(ProcessHandle,
- &BaseAddress,
+ (PVOID *)&StackBase,
0,
- &SectionSize,
+ &StackSize,
MEM_COMMIT,
PAGE_READWRITE);
if (!NT_SUCCESS(Status))
{
+ DPRINT("Stack allocation failed ");
+ DbgPrintErrorMessage(Status);
+
/* FIXME: unmap the section here */
/* FIXME: destroy the section here */
return Status;
}
- /* Create the initial thread */
+ ZwDuplicateObject(NtCurrentProcess(),
+ &SectionHandle,
+ ProcessHandle,
+ &DupSectionHandle,
+ 0,
+ FALSE,
+ DUPLICATE_SAME_ACCESS);
+
+ ZwWriteVirtualMemory(ProcessHandle,
+ STACK_TOP - 4,
+ &ImageBase,
+ sizeof(ImageBase),
+ &BytesWritten);
+ ZwWriteVirtualMemory(ProcessHandle,
+ STACK_TOP - 8,
+ &DupSectionHandle,
+ sizeof(DupSectionHandle),
+ &BytesWritten);
+
+ /* Initialize context to point to LdrStartup */
+ memset(&Context,0,sizeof(CONTEXT));
+ Context.SegSs = USER_DS;
+ Context.Esp = STACK_TOP - 12;
+ Context.EFlags = 0x202;
+ Context.SegCs = USER_CS;
+ Context.Eip = LdrStartupAddr;
+ Context.SegDs = USER_DS;
+ Context.SegEs = USER_DS;
+ Context.SegFs = USER_DS;
+ Context.SegGs = USER_DS;
+
+ DPRINT("LdrStartupAddr %x\n",LdrStartupAddr);
+ /* FIXME: Create process and let 'er rip */
Status = ZwCreateThread(&ThreadHandle,
THREAD_ALL_ACCESS,
NULL,
FALSE);
if (!NT_SUCCESS(Status))
{
+ DPRINT("Thread creation failed ");
+ DbgPrintErrorMessage(Status);
+
/* FIXME: destroy the stack memory block here */
/* FIXME: unmap the section here */
/* FIXME: destroy the section here */
- return Status;
+
+ return Status;
}
return STATUS_SUCCESS;
}
+NTSTATUS LdrLoadInitialProcess(VOID)
+{
+ NTSTATUS Status;
+ HANDLE ProcessHandle;
+ ANSI_STRING AnsiString;
+ UNICODE_STRING ProcessName;
+
+ Status = ZwCreateProcess(&ProcessHandle,
+ PROCESS_ALL_ACCESS,
+ NULL,
+ SystemProcessHandle,
+ FALSE,
+ NULL,
+ NULL,
+ NULL);
+ if (!NT_SUCCESS(Status))
+ {
+ DbgPrint("Could not create process\n");
+ return Status;
+ }
+
+ RtlInitAnsiString(&AnsiString, "\\??\\C:\\reactos\\system\\shell.exe");
+ RtlAnsiStringToUnicodeString(&ProcessName, &AnsiString, TRUE);
+
+ Status = LdrLoadImage(ProcessHandle, &ProcessName);
+
+ RtlFreeUnicodeString(&ProcessName);
+ return Status;
+}
-all: kimage
+all: ntoskrnl.exe utils/pe2bin/pe2bin$(EXE_POSTFIX)
#
# Defines $(HAL_OBJECTS)
RTL_OBJECTS = rtl/vsprintf.o rtl/lookas.o rtl/unicode.o rtl/strtok.o \
rtl/time.o rtl/unalign.o rtl/mem.o rtl/largeint.o rtl/ctype.o \
rtl/list.o rtl/slist.o rtl/interlck.o rtl/return.o \
- rtl/wstring.o
+ rtl/wstring.o rtl/memcpy.o
KE_OBJECTS = ke/main.o ke/timer.o ke/error.o ke/catch.o ke/exports.o \
- ke/module.o ke/dpc.o ke/wait.o ke/kqueue.o ke/dispatch.o \
+ ke/dpc.o ke/wait.o ke/kqueue.o ke/dispatch.o \
ke/sem.o ke/critical.o ke/event.o ke/apc.o ke/bug.o \
ke/mutex.o ke/kernel.o ke/ldt.o ke/apchelp.o
objects/se.o objects/cm.o objects/tst.o objects/dbg.o\
objects/nt.o objects/cc.o objects/ldr.o
+utils/pe2bin/pe2bin$(EXE_POSTFIX): utils/pe2bin/pe2bin.c
+ $(NATIVE_CC) -I../include -g utils/pe2bin/pe2bin.c -o utils/pe2bin/pe2bin$(EXE_POSTFIX)
+
utils/export/export$(EXE_POSTFIX): utils/export/export.c
$(NATIVE_CC) -g utils/export/export.c -o utils/export/export$(EXE_POSTFIX)
ke/exports.o: exports.lst utils/export/export$(EXE_POSTFIX)
+ifeq ($(HOST),mingw32-windows)
+ .\\utils\\export\\export$(EXE_POSTFIX) < exports.lst > ke\\exports.c
+else
utils/export/export$(EXE_POSTFIX) < exports.lst > ke/exports.c
+endif
$(CC) $(CFLAGS) -c ke/exports.c -o ke/exports.o
-kimage: $(OBJECTS)
- $(LD) --defsym _end=end --defsym _etext=etext $(KERNEL_BFD_TARGET) -Ttext c0000000 $(LDFLAGS) $(OBJECTS) $(LIBGCC) -o kimage
- $(NM) --numeric-sort kimage > kernel.sym
- $(OBJCOPY) -S --gap-fill=0 -O binary kimage kimage.bin
-
-old_kimage: $(OBJECTS)
- $(LD) --defsym _end=end --defsym _etext=etext --oformat=$(KERNEL_BFD_TARGET) -Ttext c0000000 $(LDFLAGS) $(OBJECTS) $(LIBGCC) -o kimage
- $(NM) --numeric-sort kimage > kernel.sym
- $(OBJCOPY) -S --gap-fill=0 -O binary kimage kimage.bin
-
+ntoskrnl.exe: $(OBJECTS) ntoskrnl.def
+ $(LD) -r $(OBJECTS) -o ntoskrnl.o
+ $(DLLTOOL) --dllname ntoskrnl.exe --def ntoskrnl.def \
+ --output-lib ntoskrnl.a
+ $(CC) -specs=../specs -mdll -o junk.tmp \
+ -Wl,--image-base,0xc0000000 \
+ -Wl,--file-alignment,0x1000 \
+ -Wl,--section-alignment,0x1000 \
+ -Wl,--defsym,_end=end \
+ -Wl,--defsym,_edata=__data_end__ \
+ -Wl,--defsym,_etext=etext -Wl,--base-file,base.tmp ntoskrnl.o
+ - $(RM) junk.tmp
+ $(DLLTOOL) --dllname ntoskrnl.exe --base-file base.tmp \
+ --output-exp temp.exp --def ntoskrnl.def
+ - $(RM) base.tmp
+ $(CC) -specs=../specs -mdll -o ntoskrnl.exe ntoskrnl.o \
+ -Wl,--image-base,0xc0000000 \
+ -Wl,--file-alignment,0x1000 \
+ -Wl,--section-alignment,0x1000 \
+ -Wl,--defsym,_end=end \
+ -Wl,--defsym,_edata=__data_end__ \
+ -Wl,--defsym,_etext=etext -Wl,temp.exp
+ - $(RM) temp.exp
+ $(NM) --numeric-sort ntoskrnl.exe > ntoskrnl.sym
+
dummy:
ex/napi.o: ex/napi.c ../include/ntdll/napi.h
-WITH_DEBUGGING = yes
+#WITH_DEBUGGING = yes
WIN32_LEAN_AND_MEAN = yes
include ../rules.mak
--- /dev/null
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS kernel
+ * FILE: ntoskrnl/mm/freelist.c
+ * PURPOSE: Handle the list of free physical pages
+ * PROGRAMMER: David Welch (welch@cwcom.net)
+ * UPDATE HISTORY:
+ * 27/05/98: Created
+ * 18/08/98: Added a fix from Robert Bergkvist
+ */
+
+/* INCLUDES ****************************************************************/
+
+#include <internal/stddef.h>
+#include <internal/mmhal.h>
+#include <internal/mm.h>
+#include <internal/ntoskrnl.h>
+#include <internal/bitops.h>
+#include <ddk/ntddk.h>
+
+#define NDEBUG
+#include <internal/debug.h>
+
+/* TYPES *******************************************************************/
+
+#define PHYSICAL_PAGE_FREE (0x1)
+#define PHYSICAL_PAGE_INUSE (0x2)
+#define PHYSICAL_PAGE_BIOS (0x4)
+
+#define PHYSICAL_PAGE_PAGEIN (0x8)
+
+typedef struct _PHYSICAL_PAGE
+{
+ ULONG Flags;
+ LIST_ENTRY ListEntry;
+} PHYSICAL_PAGE, *PPHYSICAL_PAGE;
+
+/* GLOBALS ****************************************************************/
+
+static PAGE_ARRAY[] PageArray;
+
+static LIST_ENTRY UsedPageListHead;
+static LIST_ENTRY FreePageListHead;
+static LIST_ENTRY BiosPageListHead;
+
+/* FUNCTIONS *************************************************************/
+
+PVOID MmMapKernelPage(PVOID PhysicalAddress)
+{
+
+}
+
+VOID MmInitializePageList(PVOID FirstKernelAddress,
+ PVOID LastKernelAddress,
+ ULONG MemorySizeInPages)
+/*
+ * FUNCTION: Initializes the page list with all pages free
+ * except those known to be reserved and those used by the kernel
+ * ARGUMENTS:
+ * PageBuffer = Page sized buffer
+ * FirstKernelAddress = First physical address used by the kernel
+ * LastKernelAddress = Last physical address used by the kernel
+ */
+{
+ PHYSICAL_PAGE PageArray[];
+ ULONG i;
+ ULONG Reserved;
+
+ InitializeListHead(&UsedPageListHead);
+ InitializeListHead(&FreePageListHead);
+ InitializeListHead(&BiosPageListHead);
+
+ Reserved = (MemorySizeInPages * sizeof(PHYSICAL_PAGE)) / PAGESIZE;
+
+ PageArray = MmMapKernelPages(LastKernelAddress + PAGESIZE,
+ Reserved);
+
+ for (i=1; i<MemorySizeInPages; i++)
+ {
+ if (i >= (0xa0000 / PAGESIZE) &&
+ i < (0x100000 / PAGESIZE))
+ {
+ PageArray[i].Flags = PHYSICAL_PAGE_BIOS;
+ InsertTailList(&BiosPageListHead,
+ &PageArray[CurrentOffset].ListEntry);
+ }
+ else if (i >= (FirstKernelAddress / PAGE_SIZE) &&
+ i < (LastKernelAddress / PAGESIZE))
+ {
+ PageArray[i].Flags = PHYSICAL_PAGE_INUSE;
+ InsertTailList(&UsedPageListHead,
+ &PageArray[CurrentOffset].ListEntry);
+ }
+ else
+ {
+ PageArray[i].Flags = PHYSICAL_PAGE_FREE;
+ InsertTailList(&UsedPageListHead,
+ &PageArray[CurrentOffset].ListEntry);
+ }
+ }
+
+}
+
+VOID MmFreePage(PVOID PhysicalAddress,
+ PVOID Nr)
+{
+ ULONG i;
+ ULONG Start = PhysicalAddress / PAGESIZE;
+
+ for (i=0; i++; i<Nr)
+ {
+ PageArray[Start + i].Flags = PHYSICAL_PAGE_FREE;
+ RemoveEntryList(&PageArray[Start + i].ListEntry);
+ InsertTailList(&FreePageListHead, &PageArray[Start + i].ListEntry);
+ }
+}
+
+PVOID MmAllocDmaPage(PVOID MaxPhysicalAddress)
+{
+ ULONG i;
+
+ for (i=0; i<(MaxPhysicalAddress / PAGESIZE); i++)
+ {
+ if (PageArray[i].Flags & PHYSICAL_PAGE_FREE)
+ {
+ PageDescriptor->Flags = PHYSICAL_PAGE_INUSE;
+ RemoveEntryList(&PageDescriptor->ListEntry);
+ InsertTailList(&UsedPageListHead,
+ &PageDescriptor->ListEntry);
+ return(i * PAGESIZE);
+ }
+ }
+ return(NULL);
+}
+
+PVOID MmAllocPage(VOID)
+{
+ PLIST_ENTRY ListEntry;
+ PPHYSICAL_PAGE PageDescriptor;
+
+ ListEntry = RemoveHeadList(&FreePageListHead);
+ PageDescriptor = CONTAING_RECORD(ListEntry, PHYSICAL_PAGE, ListEntry);
+
+ PageDescriptor->Flags = PHYSICAL_PAGE_INUSE;
+ InsertTailList(&UsedPageListHead,
+ ListEntry);
+
+ return((PageDescriptor - PageArray) / sizeof(PHYSICAL_PAGE) * PAGESIZE);
+}
#include <ddk/ntddk.h>
#include <internal/mm.h>
#include <internal/mmhal.h>
+#include <string.h>
#include <internal/string.h>
#define NDEBUG
#include <internal/stddef.h>
#include <internal/mm.h>
+#include <string.h>
#include <internal/string.h>
#include <internal/ntoskrnl.h>
#include <internal/bitops.h>
/* INCLUDES ****************************************************************/
+#include <string.h>
#include <internal/string.h>
#include <internal/stddef.h>
#include <internal/mm.h>
return(Status);
}
-NTSTATUS NtMapViewOfSection(HANDLE SectionHandle,
- HANDLE ProcessHandle,
- PVOID* BaseAddress,
- ULONG ZeroBits,
- ULONG CommitSize,
- PLARGE_INTEGER SectionOffset,
- PULONG ViewSize,
- SECTION_INHERIT InheritDisposition,
- ULONG AllocationType,
- ULONG Protect)
+NTSTATUS STDCALL NtMapViewOfSection(HANDLE SectionHandle,
+ HANDLE ProcessHandle,
+ PVOID* BaseAddress,
+ ULONG ZeroBits,
+ ULONG CommitSize,
+ PLARGE_INTEGER SectionOffset,
+ PULONG ViewSize,
+ SECTION_INHERIT InheritDisposition,
+ ULONG AllocationType,
+ ULONG Protect)
{
return(ZwMapViewOfSection(SectionHandle,
ProcessHandle,
Protect));
}
-NTSTATUS ZwMapViewOfSection(HANDLE SectionHandle,
- HANDLE ProcessHandle,
- PVOID* BaseAddress,
- ULONG ZeroBits,
- ULONG CommitSize,
- PLARGE_INTEGER SectionOffset,
- PULONG ViewSize,
- SECTION_INHERIT InheritDisposition,
- ULONG AllocationType,
- ULONG Protect)
+NTSTATUS STDCALL ZwMapViewOfSection(HANDLE SectionHandle,
+ HANDLE ProcessHandle,
+ PVOID* BaseAddress,
+ ULONG ZeroBits,
+ ULONG CommitSize,
+ PLARGE_INTEGER SectionOffset,
+ PULONG ViewSize,
+ SECTION_INHERIT InheritDisposition,
+ ULONG AllocationType,
+ ULONG Protect)
/*
* FUNCTION: Maps a view of a section into the virtual address space of a
* process
MEMORY_AREA* Result;
NTSTATUS Status;
- DPRINT("ZwMapViewOfSection(SectionHandle %x, ProcessHandle %x)\n",
- SectionHandle,ProcessHandle);
+ DPRINT("ZwMapViewOfSection(Section:%08lx, Process:%08lx,\n"
+ " Base:%08lx, ZeroBits:%08lx, CommitSize:%08lx,\n"
+ " SectionOffs:%08lx, *ViewSize:%08lx, InheritDisp:%08lx,\n"
+ " AllocType:%08lx, Protect:%08lx)\n",
+ SectionHandle,
+ ProcessHandle,
+ BaseAddress,
+ ZeroBits,
+ CommitSize,
+ SectionOffset,
+ *ViewSize,
+ InheritDisposition,
+ AllocationType,
+ Protect);
+ DPRINT(" *Base:%08lx\n", *BaseAddress);
Status = ObReferenceObjectByHandle(SectionHandle,
SECTION_MAP_READ,
NULL);
if (Status != STATUS_SUCCESS)
{
- DPRINT("%s() = %x\n",Status);
+ DPRINT("ObReference failed rc=%x\n",Status);
return(Status);
}
+ DPRINT("Section %x\n",Section);
+
Status = ObReferenceObjectByHandle(ProcessHandle,
PROCESS_VM_OPERATION,
PsProcessType,
return(Status);
}
+ DPRINT("ViewSize %x\n",ViewSize);
if ((*ViewSize) > GET_LARGE_INTEGER_LOW_PART(Section->MaximumSize))
{
(*ViewSize) = GET_LARGE_INTEGER_LOW_PART(Section->MaximumSize);
}
- MmCreateMemoryArea(UserMode,
- Process,
- MEMORY_AREA_SECTION_VIEW_COMMIT,
- BaseAddress,
- *ViewSize,
- Protect,
- &Result);
+ Status = MmCreateMemoryArea(UserMode,
+ Process,
+ MEMORY_AREA_SECTION_VIEW_COMMIT,
+ BaseAddress,
+ *ViewSize,
+ Protect,
+ &Result);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT("ZwMapViewOfSection() = %x\n",Status);
+ return(Status);
+ }
Result->Data.SectionData.Section = Section;
- Result->Data.SectionData.ViewOffset = GET_LARGE_INTEGER_LOW_PART(*SectionOffset);
+
+ DPRINT("SectionOffset %x\n",SectionOffset);
+
+ if (SectionOffset == NULL)
+ {
+ Result->Data.SectionData.ViewOffset = 0;
+ }
+ else
+ {
+ Result->Data.SectionData.ViewOffset =
+ GET_LARGE_INTEGER_LOW_PART(*SectionOffset);
+ }
DPRINT("*BaseAddress %x\n",*BaseAddress);
- DPRINT("Result->Data.SectionData.Section->FileObject %x\n",
- Result->Data.SectionData.Section->FileObject);
return(STATUS_SUCCESS);
}
/* INCLUDE *****************************************************************/
-#include <windows.h>
-
#include <internal/i386/segment.h>
#include <internal/mm.h>
#include <internal/mmhal.h>
NTSTATUS Status;
DPRINT("ZwAllocateVirtualMemory(ProcessHandle %x, *BaseAddress %x, "
- "ZeroBits %d, RegionSize %d, AllocationType %x, Protect %x)\n",
+ "ZeroBits %d, *RegionSize %x, AllocationType %x, Protect %x)\n",
ProcessHandle,*BaseAddress,ZeroBits,*RegionSize,AllocationType,
Protect);
--- /dev/null
+EXPORTS
+__putchar
+__getscreensize
+__goxy
+__wherey
+__wherex
+memcpy
+strtok
+toupper
+wcschr
+wcslen
+wtolower
+DbgPrint
+ExAllocatePool
+ExFreePool
+HalGetInterruptVector
+KeBugCheck
+KeBugCheckEx
+KeFlushIoBuffers
+KeInitializeDpc
+KeInitializeEvent
+KeInitializeSpinLock
+KeInsertQueueDpc
+KeLowerIrql
+KeStallExecutionProcessor
+KeSynchronizeExecution
+KeRaiseIrql
+KeWaitForSingleObject
+InitializeObjectAttributes
+IoAllocateController
+IoAttachDeviceToDeviceStack
+IoBuildSynchronousFsdRequest
+IoCallDriver
+IoCompleteRequest
+IoConnectInterrupt
+IoCreateController
+IoCreateDevice
+IoCreateSymbolicLink
+IoDeleteController
+IoDisconnectInterrupt
+IoFreeController
+IoGetCurrentIrpStackLocation
+IoInitializeDpcRequest
+IoInitializeTimer
+IoMarkIrpPending
+IoRegisterFileSystem
+IoRequestDpc
+IoStartPacket
+IoStartNextPacket
+IoStartNextPacketByKey
+IoStartTimer
+MmGetSystemAddressForMdl
+RtlAnsiStringToUnicodeString
+RtlConvertLongToLargeInteger
+RtlConvertUlongToLargeInteger
+RtlCopyMemory
+RtlEnlargedIntegerMultiply
+RtlExtendedIntegerMultiply
+RtlFreeUnicodeString
+RtlInitAnsiString
+RtlInitUnicodeString
+RtlLargeIntegerAdd
+RtlLargeIntegerGreaterThan
+RtlLargeIntegerShiftRight
+RtlZeroMemory
+ZwCreateDirectoryObject@12
--- /dev/null
+EXPORTS
+ExAcquireFastMutexUnsafe
+ExInterlockedAddLargeStatistic
+ExInterlockedCompareExchange64
+ExInterlockedPopEntrySList
+ExInterlockedPushEntrySList
+ExReleaseFastMutexUnsafe
+ExReleaseResourceLite
+ExfInterlockedAddUlong
+ExfInterlockedInsertHeadList
+ExfInterlockedInsertTailList
+ExfInterlockedPopEntryList
+ExfInterlockedPushEntryList
+ExfInterlockedRemoveHeadList
+Exfi386InterlockedDecrementLong
+Exfi386InterlockedExchangeUlong
+Exfi386InterlockedIncrementLong
+InterlockedCompareExchange
+InterlockedDecrement
+InterlockedExchange
+InterlockedExchangeAdd
+InterlockedIncrement
+IofCallDriver
+IofCompleteRequest
+KeSetSwapContextNotifyRoutine
+KeSetThreadSelectNotifyRoutine
+KeSetTimeUpdateNotifyRoutine
+KefAcquireSpinLockAtDpcLevel
+KefReleaseSpinLockFromDpcLevel
+KiAcquireSpinLock
+KiReleaseSpinLock
+ObfDereferenceObject
+ObfReferenceObject
+Kei386EoiHelper
+Kii386SpinOnSpinLock
+CcCanIWrite
+CcCopyRead
+CcCopyWrite
+CcDeferWrite
+CcFastCopyRead
+CcFastCopyWrite
+CcFastMdlReadWait
+CcFastReadNotPossible
+CcFastReadWait
+CcFlushCache
+CcGetDirtyPages
+CcGetFileObjectFromBcb
+CcGetFileObjectFromSectionPtrs
+CcGetLsnForFileObject
+CcInitializeCacheMap
+CcIsThereDirtyData
+CcMapData
+CcMdlRead
+CcMdlReadComplete
+CcMdlWriteComplete
+CcPinMappedData
+CcPinRead
+CcPrepareMdlWrite
+CcPreparePinWrite
+CcPurgeCacheSection
+CcRepinBcb
+CcScheduleReadAhead
+CcSetAdditionalCacheAttributes
+CcSetBcbOwnerPointer
+CcSetDirtyPageThreshold
+CcSetDirtyPinnedData
+CcSetFileSizes
+CcSetLogHandleForFile
+CcSetReadAheadGranularity
+CcUninitializeCacheMap
+CcUnpinData
+CcUnpinDataForThread
+CcUnpinRepinnedBcb
+CcZeroData
+DbgBreakPoint
+DbgBreakPointWithStatus
+DbgLoadImageSymbols
+DbgPrint
+DbgPrompt
+ExAcquireResourceExclusive
+ExAcquireResourceExclusiveLite
+ExAcquireResourceSharedLite
+ExAcquireSharedStarveExclusive
+ExAcquireSharedWaitForExclusive
+ExAllocateFromPagedLookasideList
+ExAllocatePool
+ExAllocatePoolWithQuota
+ExAllocatePoolWithQuotaTag
+ExAllocatePoolWithTag
+ExConvertExclusiveToSharedLite
+ExCreateCallback
+ExDeleteNPagedLookasideList
+ExDeletePagedLookasideList
+ExDeleteResource
+ExDeleteResourceLite
+ExDesktopObjectType
+ExDisableResourceBoostLite
+ExEnumHandleTable
+ExEventObjectType
+ExExtendZone
+ExFreePool
+ExFreeToPagedLookasideList
+ExGetExclusiveWaiterCount
+ExGetPreviousMode
+ExGetSharedWaiterCount
+ExInitializeNPagedLookasideList
+ExInitializePagedLookasideList
+ExInitializeResource
+ExInitializeResourceLite
+ExInitializeZone
+ExInterlockedAddLargeInteger
+ExInterlockedAddUlong
+ExInterlockedDecrementLong
+ExInterlockedExchangeUlong
+ExInterlockedExtendZone
+ExInterlockedIncrementLong
+ExInterlockedInsertHeadList
+ExInterlockedInsertTailList
+ExInterlockedPopEntryList
+ExInterlockedPushEntryList
+ExInterlockedRemoveHeadList
+ExIsProcessorFeaturePresent
+ExIsResourceAcquiredExclusiveLite
+ExIsResourceAcquiredSharedLite
+ExLocalTimeToSystemTime
+ExNotifyCallback
+ExPostSystemEvent
+ExQueryPoolBlockSize
+ExQueueWorkItem
+ExRaiseAccessViolation
+ExRaiseDatatypeMisalignment
+ExRaiseException
+ExRaiseHardError
+ExRaiseStatus
+ExRegisterCallback
+ExReinitializeResourceLite
+ExReleaseResourceForThread
+ExReleaseResourceForThreadLite
+ExSetResourceOwnerPointer
+ExSystemExceptionFilter
+ExSystemTimeToLocalTime
+ExUnregisterCallback
+ExWindowStationObjectType
+Exi386InterlockedDecrementLong
+Exi386InterlockedExchangeUlong
+Exi386InterlockedIncrementLong
+FsRtlAddLargeMcbEntry
+FsRtlAddMcbEntry
+FsRtlAddToTunnelCache
+FsRtlAllocatePool
+FsRtlAllocatePoolWithQuota
+FsRtlAllocatePoolWithQuotaTag
+FsRtlAllocatePoolWithTag
+FsRtlAllocateResource
+FsRtlAreNamesEqual
+FsRtlBalanceReads
+FsRtlCheckLockForReadAccess
+FsRtlCheckLockForWriteAccess
+FsRtlCheckOplock
+FsRtlCopyRead
+FsRtlCopyWrite
+FsRtlCurrentBatchOplock
+FsRtlDeleteKeyFromTunnelCache
+FsRtlDeleteTunnelCache
+FsRtlDeregisterUncProvider
+FsRtlDissectDbcs
+FsRtlDissectName
+FsRtlDoesDbcsContainWildCards
+FsRtlDoesNameContainWildCards
+FsRtlFastCheckLockForRead
+FsRtlFastCheckLockForWrite
+FsRtlFastUnlockAll
+FsRtlFastUnlockAllByKey
+FsRtlFastUnlockSingle
+FsRtlFindInTunnelCache
+FsRtlGetFileSize
+FsRtlGetNextFileLock
+FsRtlGetNextLargeMcbEntry
+FsRtlGetNextMcbEntry
+FsRtlInitializeFileLock
+FsRtlInitializeLargeMcb
+FsRtlInitializeMcb
+FsRtlInitializeOplock
+FsRtlInitializeTunnelCache
+FsRtlIsDbcsInExpression
+FsRtlIsFatDbcsLegal
+FsRtlIsHpfsDbcsLegal
+FsRtlIsNameInExpression
+FsRtlIsNtstatusExpected
+FsRtlIsTotalDeviceFailure
+FsRtlLegalAnsiCharacterArray
+FsRtlLookupLargeMcbEntry
+FsRtlLookupLastLargeMcbEntry
+FsRtlLookupLastMcbEntry
+FsRtlLookupMcbEntry
+FsRtlMdlRead
+FsRtlMdlReadComplete
+FsRtlMdlReadCompleteDev
+FsRtlMdlReadDev
+FsRtlMdlWriteComplete
+FsRtlMdlWriteCompleteDev
+FsRtlNormalizeNtstatus
+FsRtlNotifyChangeDirectory
+FsRtlNotifyCleanup
+FsRtlNotifyFullChangeDirectory
+FsRtlNotifyFullReportChange
+FsRtlNotifyInitializeSync
+FsRtlNotifyReportChange
+FsRtlNotifyUninitializeSync
+FsRtlNumberOfRunsInLargeMcb
+FsRtlNumberOfRunsInMcb
+FsRtlOplockFsctrl
+FsRtlOplockIsFastIoPossible
+FsRtlPostPagingFileStackOverflow
+FsRtlPostStackOverflow
+FsRtlPrepareMdlWrite
+FsRtlPrepareMdlWriteDev
+FsRtlPrivateLock
+FsRtlProcessFileLock
+FsRtlRegisterUncProvider
+FsRtlRemoveLargeMcbEntry
+FsRtlRemoveMcbEntry
+FsRtlSplitLargeMcb
+FsRtlSyncVolumes
+FsRtlTruncateLargeMcb
+FsRtlTruncateMcb
+FsRtlUninitializeFileLock
+FsRtlUninitializeLargeMcb
+FsRtlUninitializeMcb
+FsRtlUninitializeOplock
+HalDispatchTable
+HalPrivateDispatchTable
+IoAcquireCancelSpinLock
+IoAcquireVpbSpinLock
+IoAdapterObjectType
+IoAllocateAdapterChannel
+IoAllocateController
+IoAllocateErrorLogEntry
+IoAllocateIrp
+IoAllocateMdl
+IoAssignResources
+IoAttachDevice
+IoAttachDeviceByPointer
+IoAttachDeviceToDeviceStack
+IoBuildAsynchronousFsdRequest
+IoBuildDeviceIoControlRequest
+IoBuildPartialMdl
+IoBuildSynchronousFsdRequest
+IoCallDriver
+IoCancelIrp
+IoCheckDesiredAccess
+IoCheckEaBufferValidity
+IoCheckFunctionAccess
+IoCheckShareAccess
+IoCompleteRequest
+IoConnectInterrupt
+IoCreateController
+IoCreateDevice
+IoCreateFile
+IoCreateNotificationEvent
+IoCreateStreamFileObject
+IoCreateSymbolicLink
+IoCreateSynchronizationEvent
+IoCreateUnprotectedSymbolicLink
+IoDeleteController
+IoDeleteDevice
+IoDeleteSymbolicLink
+IoDetachDevice
+IoDeviceHandlerObjectSize
+IoDeviceHandlerObjectType
+IoDeviceObjectType
+IoDisconnectInterrupt
+IoDriverObjectType
+IoEnqueueIrp
+IoFastQueryNetworkAttributes
+IoFileObjectType
+IoFreeController
+IoFreeIrp
+IoFreeMdl
+IoGetAttachedDevice
+IoGetBaseFileSystemDeviceObject
+IoGetConfigurationInformation
+IoGetCurrentProcess
+IoGetDeviceObjectPointer
+IoGetDeviceToVerify
+IoGetFileObjectGenericMapping
+IoGetInitialStack
+IoGetRelatedDeviceObject
+IoGetRequestorProcess
+IoGetStackLimits
+IoGetTopLevelIrp
+IoInitializeIrp
+IoInitializeTimer
+IoIsOperationSynchronous
+IoIsSystemThread
+IoMakeAssociatedIrp
+IoOpenDeviceInstanceKey
+IoPageRead
+IoQueryDeviceDescription
+IoQueryDeviceEnumInfo
+IoQueryFileInformation
+IoQueryVolumeInformation
+IoQueueThreadIrp
+IoRaiseHardError
+IoRaiseInformationalHardError
+IoReadOperationCount
+IoReadTransferCount
+IoRegisterDriverReinitialization
+IoRegisterFileSystem
+IoRegisterFsRegistrationChange
+IoRegisterShutdownNotification
+IoReleaseCancelSpinLock
+IoReleaseVpbSpinLock
+IoRemoveShareAccess
+IoReportHalResourceUsage
+IoReportResourceUsage
+IoSetDeviceToVerify
+IoSetHardErrorOrVerifyDevice
+IoSetInformation
+IoSetShareAccess
+IoSetThreadHardErrorMode
+IoSetTopLevelIrp
+IoStartNextPacket
+IoStartNextPacketByKey
+IoStartPacket
+IoStartTimer
+IoStatisticsLock
+IoStopTimer
+IoSynchronousPageWrite
+IoThreadToProcess
+IoUnregisterFileSystem
+IoUnregisterFsRegistrationChange
+IoUnregisterShutdownNotification
+IoUpdateShareAccess
+IoVerifyVolume
+IoWriteErrorLogEntry
+IoWriteOperationCount
+IoWriteTransferCount
+KdDebuggerEnabled
+KdDebuggerNotPresent
+KdPollBreakIn
+Ke386CallBios
+Ke386IoSetAccessProcess
+Ke386QueryIoAccessMap
+Ke386SetIoAccessMap
+KeAcquireSpinLockAtDpcLevel
+KeAddSystemServiceTable
+KeAttachProcess
+KeBoostCurrentThread
+KeBugCheck
+KeBugCheckEx
+KeCancelTimer
+KeClearEvent
+KeConnectInterrupt
+KeDcacheFlushCount
+KeDelayExecutionThread
+KeDeregisterBugCheckCallback
+KeDetachProcess
+KeDisconnectInterrupt
+KeEnterCriticalRegion
+KeEnterKernelDebugger
+KeFindConfigurationEntry
+KeFindConfigurationNextEntry
+KeFlushEntireTb
+KeGetCurrentThread
+KeGetPreviousMode
+KeI386AbiosCall
+KeI386AllocateGdtSelectors
+KeI386Call16BitCStyleFunction
+KeI386Call16BitFunction
+KeI386FlatToGdtSelector
+KeI386GetLid
+KeI386MachineType
+KeI386ReleaseGdtSelectors
+KeI386ReleaseLid
+KeI386SetGdtSelector
+KeIcacheFlushCount
+KeInitializeApc
+KeInitializeDeviceQueue
+KeInitializeDpc
+KeInitializeEvent
+KeInitializeInterrupt
+KeInitializeMutant
+KeInitializeMutex
+KeInitializeQueue
+KeInitializeSemaphore
+KeInitializeSpinLock
+KeInitializeTimer
+KeInitializeTimerEx
+KeInsertByKeyDeviceQueue
+KeInsertDeviceQueue
+KeInsertHeadQueue
+KeInsertQueue
+KeInsertQueueApc
+KeInsertQueueDpc
+KeIsExecutingDpc
+KeLeaveCriticalRegion
+KeLoaderBlock
+KeNumberProcessors
+KeProfileInterrupt
+KeProfileInterruptWithSource
+KePulseEvent
+KeQuerySystemTime
+KeQueryTickCount
+KeQueryTimeIncrement
+KeRaiseUserException
+KeReadStateEvent
+KeReadStateMutant
+KeReadStateMutex
+KeReadStateQueue
+KeReadStateSemaphore
+KeReadStateTimer
+KeRegisterBugCheckCallback
+KeReleaseMutant
+KeReleaseMutex
+KeReleaseSemaphore
+KeReleaseSpinLockFromDpcLevel
+KeRemoveByKeyDeviceQueue
+KeRemoveDeviceQueue
+KeRemoveEntryDeviceQueue
+KeRemoveQueue
+KeRemoveQueueDpc
+KeResetEvent
+KeRestoreFloatingPointState
+KeRundownQueue
+KeSaveFloatingPointState
+KeServiceDescriptorTable
+KeSetAffinityThread
+KeSetBasePriorityThread
+KeSetDmaIoCoherency
+KeSetEvent
+KeSetEventBoostPriority
+KeSetIdealProcessorThread
+KeSetImportanceDpc
+KeSetKernelStackSwapEnable
+KeSetPriorityThread
+KeSetProfileIrql
+KeSetTargetProcessorDpc
+KeSetTimeIncrement
+KeSetTimer
+KeSetTimerEx
+KeSynchronizeExecution
+KeTerminateThread
+KeTickCount
+KeUpdateRunTime
+KeUpdateSystemTime
+KeUserModeCallback
+KeWaitForMultipleObjects
+KeWaitForMutexObject
+KeWaitForSingleObject
+KiBugCheckData
+KiCoprocessorError
+KiDeliverApc
+KiDispatchInterrupt
+KiIpiServiceRoutine
+KiUnexpectedInterrupt
+LdrAccessResource
+LdrEnumResources
+LdrFindResourceDirectory_U
+LdrFindResource_U
+LpcRequestPort
+LsaCallAuthenticationPackage
+LsaDeregisterLogonProcess
+LsaFreeReturnBuffer
+LsaLogonUser
+LsaLookupAuthenticationPackage
+LsaRegisterLogonProcess
+MmAdjustWorkingSetSize
+MmAllocateContiguousMemory
+MmAllocateNonCachedMemory
+MmBuildMdlForNonPagedPool
+MmCanFileBeTruncated
+MmCreateMdl
+MmCreateSection
+MmDbgTranslatePhysicalAddress
+MmDisableModifiedWriteOfSection
+MmFlushImageSection
+MmForceSectionClosed
+MmFreeContiguousMemory
+MmFreeNonCachedMemory
+MmGetPhysicalAddress
+MmGrowKernelStack
+MmIsAddressValid
+MmIsNonPagedSystemAddressValid
+MmIsRecursiveIoFault
+MmIsThisAnNtAsSystem
+MmLockPagableDataSection
+MmLockPagableImageSection
+MmLockPagableSectionByHandle
+MmMapIoSpace
+MmMapLockedPages
+MmMapMemoryDumpMdl
+MmMapVideoDisplay
+MmMapViewInSystemSpace
+MmMapViewOfSection
+MmPageEntireDriver
+MmProbeAndLockPages
+MmQuerySystemSize
+MmResetDriverPaging
+MmSectionObjectType
+MmSecureVirtualMemory
+MmSetAddressRangeModified
+MmSetBankedSection
+MmSizeOfMdl
+MmUnlockPagableImageSection
+MmUnlockPages
+MmUnmapIoSpace
+MmUnmapLockedPages
+MmUnmapVideoDisplay
+MmUnmapViewInSystemSpace
+MmUnmapViewOfSection
+MmUnsecureVirtualMemory
+NlsAnsiCodePage
+NlsLeadByteInfo
+NlsMbCodePageTag
+NlsMbOemCodePageTag
+NlsOemLeadByteInfo
+NtAddAtom
+NtAdjustPrivilegesToken
+NtAllocateLocallyUniqueId
+NtAllocateUuids
+NtAllocateVirtualMemory
+NtBuildNumber
+NtClose
+NtConnectPort
+NtCreateEvent
+NtCreateFile
+NtCreateSection
+NtDeleteAtom
+NtDeleteFile
+NtDeviceIoControlFile
+NtDuplicateObject
+NtDuplicateToken
+NtFindAtom
+NtFreeVirtualMemory
+NtFsControlFile
+NtGlobalFlag
+NtLockFile
+NtMapViewOfSection
+NtNotifyChangeDirectoryFile
+NtOpenFile
+NtOpenProcess
+NtOpenProcessToken
+NtQueryDirectoryFile
+NtQueryEaFile
+NtQueryInformationAtom
+NtQueryInformationFile
+NtQueryInformationProcess
+NtQueryInformationToken
+NtQueryOleDirectoryFile
+NtQuerySecurityObject
+NtQueryVolumeInformationFile
+NtReadFile
+NtRequestPort
+NtRequestWaitReplyPort
+NtSetEvent
+NtSetInformationFile
+NtSetInformationProcess
+NtSetInformationThread
+NtSetSecurityObject
+NtUnlockFile
+NtVdmControl
+NtWaitForSingleObject
+NtWriteFile
+ObAssignSecurity
+ObCheckCreateObjectAccess
+ObCheckObjectAccess
+ObCreateObject
+ObDereferenceObject
+ObFindHandleForObject
+ObGetObjectPointerCount
+ObGetObjectSecurity
+ObInsertObject
+ObMakeTemporaryObject
+ObOpenObjectByName
+ObOpenObjectByPointer
+ObQueryNameString
+ObQueryObjectAuditingByHandle
+ObReferenceObjectByHandle
+ObReferenceObjectByName
+ObReferenceObjectByPointer
+ObReleaseObjectSecurity
+ObSetSecurityDescriptorInfo
+PfxFindPrefix
+PfxInitialize
+PfxInsertPrefix
+PfxRemovePrefix
+PoQueryPowerSequence
+PoRequestPowerChange
+PoSetDeviceIdleDetection
+ProbeForWrite
+PsAssignImpersonationToken
+PsChargePoolQuota
+PsCreateSystemProcess
+PsCreateSystemThread
+PsCreateWin32Process
+PsEstablishWin32Callouts
+PsGetCurrentProcessId
+PsGetCurrentThreadId
+PsGetProcessExitTime
+PsGetVersion
+PsImpersonateClient
+PsInitialSystemProcess
+PsIsThreadTerminating
+PsLookupProcessByProcessId
+PsLookupProcessThreadByCid
+PsLookupThreadByThreadId
+PsProcessType
+PsReferenceImpersonationToken
+PsReferencePrimaryToken
+PsReturnPoolQuota
+PsRevertToSelf
+PsSetCreateProcessNotifyRoutine
+PsSetCreateThreadNotifyRoutine
+PsSetLegoNotifyRoutine
+PsSetProcessPriorityByClass
+PsTerminateSystemThread
+PsThreadType
+READ_REGISTER_BUFFER_UCHAR
+READ_REGISTER_BUFFER_ULONG
+READ_REGISTER_BUFFER_USHORT
+READ_REGISTER_UCHAR
+READ_REGISTER_ULONG
+READ_REGISTER_USHORT
+RtlAbsoluteToSelfRelativeSD
+RtlAddAccessAllowedAce
+RtlAddAce
+RtlAddAtomToAtomTable
+RtlAllocateAndInitializeSid
+RtlAllocateHeap
+RtlAnsiCharToUnicodeChar
+RtlAnsiStringToUnicodeSize
+RtlAnsiStringToUnicodeString
+RtlAppendAsciizToString
+RtlAppendStringToString
+RtlAppendUnicodeStringToString
+RtlAppendUnicodeToString
+RtlAreAllAccessesGranted
+RtlAreAnyAccessesGranted
+RtlAreBitsClear
+RtlAreBitsSet
+RtlAssert
+RtlCaptureStackBackTrace
+RtlCharToInteger
+RtlCheckRegistryKey
+RtlClearAllBits
+RtlClearBits
+RtlCompareMemory
+RtlCompareMemoryUlong
+RtlCompareString
+RtlCompareUnicodeString
+RtlCompressBuffer
+RtlCompressChunks
+RtlConvertLongToLargeInteger
+RtlConvertSidToUnicodeString
+RtlConvertUlongToLargeInteger
+RtlCopyLuid
+RtlCopySid
+RtlCopyString
+RtlCopyUnicodeString
+RtlCreateAcl
+RtlCreateAtomTable
+RtlCreateHeap
+RtlCreateRegistryKey
+RtlCreateSecurityDescriptor
+RtlCreateUnicodeString
+RtlCustomCPToUnicodeN
+RtlDecompressBuffer
+RtlDecompressChunks
+RtlDecompressFragment
+RtlDelete
+RtlDeleteAtomFromAtomTable
+RtlDeleteElementGenericTable
+RtlDeleteNoSplay
+RtlDeleteRegistryValue
+RtlDescribeChunk
+RtlDestroyAtomTable
+RtlDestroyHeap
+RtlDowncaseUnicodeString
+RtlEmptyAtomTable
+RtlEnlargedIntegerMultiply
+RtlEnlargedUnsignedDivide
+RtlEnlargedUnsignedMultiply
+RtlEnumerateGenericTable
+RtlEnumerateGenericTableWithoutSplaying
+RtlEqualLuid
+RtlEqualSid
+RtlEqualString
+RtlEqualUnicodeString
+RtlExtendedIntegerMultiply
+RtlExtendedLargeIntegerDivide
+RtlExtendedMagicDivide
+RtlFillMemory
+RtlFillMemoryUlong
+RtlFindClearBits
+RtlFindClearBitsAndSet
+RtlFindFirstRunClear
+RtlFindFirstRunSet
+RtlFindLongestRunClear
+RtlFindLongestRunSet
+RtlFindMessage
+RtlFindSetBits
+RtlFindSetBitsAndClear
+RtlFindUnicodePrefix
+RtlFormatCurrentUserKeyPath
+RtlFreeAnsiString
+RtlFreeHeap
+RtlFreeOemString
+RtlFreeUnicodeString
+RtlGenerate8dot3Name
+RtlGetCallersAddress
+RtlGetCompressionWorkSpaceSize
+RtlGetDaclSecurityDescriptor
+RtlGetDefaultCodePage
+RtlGetElementGenericTable
+RtlGetGroupSecurityDescriptor
+RtlGetOwnerSecurityDescriptor
+RtlImageNtHeader
+RtlInitAnsiString
+RtlInitCodePageTable
+RtlInitString
+RtlInitUnicodeString
+RtlInitializeBitMap
+RtlInitializeGenericTable
+RtlInitializeSid
+RtlInitializeUnicodePrefix
+RtlInsertElementGenericTable
+RtlInsertUnicodePrefix
+RtlIntegerToChar
+RtlIntegerToUnicodeString
+RtlIsNameLegalDOS8Dot3
+RtlLargeIntegerAdd
+RtlLargeIntegerArithmeticShift
+RtlLargeIntegerDivide
+RtlLargeIntegerNegate
+RtlLargeIntegerShiftLeft
+RtlLargeIntegerShiftRight
+RtlLargeIntegerSubtract
+RtlLengthRequiredSid
+RtlLengthSecurityDescriptor
+RtlLengthSid
+RtlLookupAtomInAtomTable
+RtlLookupElementGenericTable
+RtlMapGenericMask
+RtlMoveMemory
+RtlMultiByteToUnicodeN
+RtlMultiByteToUnicodeSize
+RtlNextUnicodePrefix
+RtlNtStatusToDosError
+RtlNtStatusToDosErrorNoTeb
+RtlNumberGenericTableElements
+RtlNumberOfClearBits
+RtlNumberOfSetBits
+RtlOemStringToCountedUnicodeString
+RtlOemStringToUnicodeSize
+RtlOemStringToUnicodeString
+RtlOemToUnicodeN
+RtlPinAtomInAtomTable
+RtlPrefixString
+RtlPrefixUnicodeString
+RtlQueryAtomInAtomTable
+RtlQueryRegistryValues
+RtlQueryTimeZoneInformation
+RtlRaiseException
+RtlRandom
+RtlRemoveUnicodePrefix
+RtlReserveChunk
+RtlSecondsSince1970ToTime
+RtlSecondsSince1980ToTime
+RtlSetAllBits
+RtlSetBits
+RtlSetDaclSecurityDescriptor
+RtlSetGroupSecurityDescriptor
+RtlSetOwnerSecurityDescriptor
+RtlSetSaclSecurityDescriptor
+RtlSetTimeZoneInformation
+RtlSplay
+RtlSubAuthorityCountSid
+RtlSubAuthoritySid
+RtlTimeFieldsToTime
+RtlTimeToSecondsSince1970
+RtlTimeToSecondsSince1980
+RtlTimeToTimeFields
+RtlUnicodeStringToAnsiSize
+RtlUnicodeStringToAnsiString
+RtlUnicodeStringToCountedOemString
+RtlUnicodeStringToInteger
+RtlUnicodeStringToOemSize
+RtlUnicodeStringToOemString
+RtlUnicodeToCustomCPN
+RtlUnicodeToMultiByteN
+RtlUnicodeToMultiByteSize
+RtlUnicodeToOemN
+RtlUnwind
+RtlUpcaseUnicodeChar
+RtlUpcaseUnicodeString
+RtlUpcaseUnicodeStringToAnsiString
+RtlUpcaseUnicodeStringToCountedOemString
+RtlUpcaseUnicodeStringToOemString
+RtlUpcaseUnicodeToCustomCPN
+RtlUpcaseUnicodeToMultiByteN
+RtlUpcaseUnicodeToOemN
+RtlUpperChar
+RtlUpperString
+RtlValidSecurityDescriptor
+RtlValidSid
+RtlWriteRegistryValue
+RtlZeroHeap
+RtlZeroMemory
+RtlxAnsiStringToUnicodeSize
+RtlxOemStringToUnicodeSize
+RtlxUnicodeStringToAnsiSize
+RtlxUnicodeStringToOemSize
+SeAccessCheck
+SeAppendPrivileges
+SeAssignSecurity
+SeAuditingFileEvents
+SeAuditingFileOrGlobalEvents
+SeCaptureSecurityDescriptor
+SeCaptureSubjectContext
+SeCloseObjectAuditAlarm
+SeCreateAccessState
+SeCreateClientSecurity
+SeDeassignSecurity
+SeDeleteAccessState
+SeDeleteObjectAuditAlarm
+SeExports
+SeFreePrivileges
+SeImpersonateClient
+SeLockSubjectContext
+sionForTerminationNotification
+SeOpenObjectAuditAlarm
+SeOpenObjectForDeleteAuditAlarm
+SePrivilegeCheck
+SePrivilegeObjectAuditAlarm
+SePublicDefaultDacl
+SeQueryAuthenticationIdToken
+SeQuerySecurityDescriptorInfo
+SeRegisterLogonSessionTerminatedRoutine
+SeReleaseSecurityDescriptor
+SeReleaseSubjectContext
+SeSetAccessStateGenericMapping
+SeSetSecurityDescriptorInfo
+SeSinglePrivilegeCheck
+SeSystemDefaultDacl
+SeTokenImpersonationLevel
+SeTokenType
+SeUnlockSubjectContext
+SeUnregisterLogonSessionTerminatedRoutine
+SeValidSecurityDescriptor
+WRITE_REGISTER_BUFFER_UCHAR
+WRITE_REGISTER_BUFFER_ULONG
+WRITE_REGISTER_BUFFER_USHORT
+WRITE_REGISTER_UCHAR
+WRITE_REGISTER_ULONG
+WRITE_REGISTER_USHORT
+ZwAccessCheckAndAuditAlarm
+ZwAlertThread
+ZwAllocateVirtualMemory
+ZwClearEvent
+ZwClose
+ZwCloseObjectAuditAlarm
+ZwConnectPort
+ZwCreateDirectoryObject
+ZwCreateEvent
+ZwCreateFile
+ZwCreateKey
+ZwCreateSection
+ZwCreateSymbolicLinkObject
+ZwDeleteFile
+ZwDeleteKey
+ZwDeleteValueKey
+ZwDeviceIoControlFile
+ZwDisplayString
+ZwDuplicateObject
+ZwDuplicateToken
+ZwEnumerateKey
+ZwEnumerateValueKey
+ZwFlushInstructionCache
+ZwFlushKey
+ZwFreeVirtualMemory
+ZwFsControlFile
+ZwLoadDriver
+ZwLoadKey
+ZwMakeTemporaryObject
+ZwMapViewOfSection
+ZwNotifyChangeKey
+ZwOpenDirectoryObject
+ZwOpenEvent
+ZwOpenFile
+ZwOpenKey
+ZwOpenProcess
+ZwOpenProcessToken
+ZwOpenSection
+ZwOpenSymbolicLinkObject
+ZwOpenThread
+ZwOpenThreadToken
+ZwPulseEvent
+ZwQueryDefaultLocale
+ZwQueryDirectoryFile
+ZwQueryInformationFile
+ZwQueryInformationProcess
+ZwQueryInformationToken
+ZwQueryKey
+ZwQueryObject
+ZwQuerySection
+ZwQuerySecurityObject
+ZwQuerySymbolicLinkObject
+ZwQuerySystemInformation
+ZwQueryValueKey
+ZwQueryVolumeInformationFile
+ZwReadFile
+ZwReplaceKey
+ZwRequestWaitReplyPort
+ZwResetEvent
+ZwSaveKey
+ZwSetDefaultLocale
+ZwSetEvent
+ZwSetInformationFile
+ZwSetInformationObject
+ZwSetInformationProcess
+ZwSetInformationThread
+ZwSetSystemInformation
+ZwSetSystemTime
+ZwSetValueKey
+ZwTerminateProcess
+ZwUnloadDriver
+ZwUnloadKey
+ZwUnmapViewOfSection
+ZwWaitForMultipleObjects
+ZwWaitForSingleObject
+ZwWriteFile
+ZwYieldExecution
+_abnormal_termination
+_alldiv
+_allmul
+_allrem
+_allshl
+_allshr
+_aulldiv
+_aullrem
+_aullshr
+_except_handler2
+_global_unwind2
+_itoa
+_local_unwind2
+_purecall
+_snprintf
+_snwprintf
+_stricmp
+_strlwr
+_strnicmp
+_strnset
+_strrev
+_strset
+_strupr
+_vsnprintf
+_wcsicmp
+_wcslwr
+_wcsnicmp
+_wcsnset
+_wcsrev
+_wcsupr
+atoi
+atol
+isdigit
+islower
+isprint
+isspace
+isupper
+isxdigit
+mbstowcs
+mbtowc
+memchr
+memcpy
+memmove
+memset
+qsort
+rand
+sprintf
+srand
+strcat
+strchr
+strcmp
+strcpy
+strlen
+strncat
+strncmp
+strncpy
+strrchr
+strspn
+strstr
+swprintf
+tolower
+toupper
+towlower
+towupper
+vsprintf
+wcscat
+wcschr
+wcscmp
+wcscpy
+wcscspn
+wcslen
+wcsncat
+wcsncmp
+wcsncpy
+wcsrchr
+wcsspn
+wcsstr
+wcstombs
+wctomb
+KdPortSave
+KeRaiseIrqlToDpcLevel
+ExReleaseFastMutex
+ExAcquireFastMutex
+ExTryToAcquireFastMutex
+HalRequestSoftwareInterrupt
+HalReturnToFirmware
+HalDisplayString
+HalQueryRealTimeClock
+HalSetRealTimeClock
+HalSetTimeIncrement
+KeGetCurrentIrql
+KeQueryPerformanceCounter
+HalGetEnvironmentVariable
+HalSetEnvironmentVariable
+KfRaiseIrql
+HalInitSystem
+HalReportResourceUsage
+HalAllProcessorsStarted
+HalAllocateAdapterChannel
+HalGetInterruptVector
+HalTranslateBusAddress
+HalAdjustResourceList
+IoAssignDriveLetters
+IoReadPartitionTable
+HalAllocateCommonBuffer
+KdPortInitialize
+KdPortGetByte
+KdPortPutByte
+KdPortPollByte
+KfLowerIrql
+KdPortRestore
+READ_PORT_ULONG
+READ_PORT_USHORT
+READ_PORT_UCHAR
+WRITE_PORT_ULONG
+WRITE_PORT_USHORT
+WRITE_PORT_UCHAR
+HalInitializeProcessor
+HalProcessorIdle
+HalClearSoftwareInterrupt
+KeRaiseIrqlToSynchLevel
+HalHandleNMI
+HalBeginSystemInterrupt
+HalEndSystemInterrupt
+HalEnableSystemInterrupt
+HalDisableSystemInterrupt
+HalSystemVectorDispatchEntry
+KeRaiseIrql
+KeLowerIrql
+HalSetProfileInterval
+HalStartProfileInterrupt
+HalStopProfileInterrupt
+HalQueryDisplayParameters
+KfReleaseSpinLock
+KfAcquireSpinLock
+KeFlushWriteBuffer
+KeStallExecutionProcessor
/* INCLUDES ***************************************************************/
-#include <windows.h>
-#include <wstring.h>
+#include <wchar.h>
#include <ddk/ntddk.h>
#include <internal/ob.h>
#include <internal/io.h>
}
-NTSTATUS NtCreateDirectoryObject(PHANDLE DirectoryHandle,
- ACCESS_MASK DesiredAccess,
- POBJECT_ATTRIBUTES ObjectAttributes)
+NTSTATUS STDCALL NtCreateDirectoryObject(PHANDLE DirectoryHandle,
+ ACCESS_MASK DesiredAccess,
+ POBJECT_ATTRIBUTES ObjectAttributes)
{
return(ZwCreateDirectoryObject(DirectoryHandle,
DesiredAccess,
ObjectAttributes));
}
-NTSTATUS ZwCreateDirectoryObject(PHANDLE DirectoryHandle,
- ACCESS_MASK DesiredAccess,
- POBJECT_ATTRIBUTES ObjectAttributes)
+NTSTATUS STDCALL ZwCreateDirectoryObject(PHANDLE DirectoryHandle,
+ ACCESS_MASK DesiredAccess,
+ POBJECT_ATTRIBUTES ObjectAttributes)
/*
* FUNCTION: Creates or opens a directory object (a container for other
* objects)
#include <windows.h>
#include <ddk/ntddk.h>
#include <internal/ob.h>
+#include <string.h>
#include <internal/string.h>
#define NDEBUG
/* INCLUDES ***************************************************************/
-#include <windows.h>
-#include <wstring.h>
+#include <wchar.h>
#include <ddk/ntddk.h>
#include <internal/ob.h>
#include <internal/io.h>
KIRQL oldlvl;
POBJECT_HEADER Header = BODY_TO_HEADER(Object);
- RtlInitUnicodeString(&Header->Name, wstrdup(Name));
+ RtlInitUnicodeString(&Header->Name, wcsdup(Name));
Header->Parent = Parent;
KeAcquireSpinLock(&Parent->Lock, &oldlvl);
/* INCLUDES *****************************************************************/
+#include <wchar.h>
#include <ddk/ntddk.h>
#include <internal/ob.h>
-#include <wstring.h>
#include <string.h>
#define NDEBUG
/* INCLUDES *****************************************************************/
+#include <wchar.h>
#include <ddk/ntddk.h>
#include <internal/ob.h>
-#include <wstring.h>
-#include <string.h>
+#include <internal/string.h>
#define NDEBUG
#include <internal/debug.h>
#include <ddk/ntddk.h>
#include <internal/ob.h>
#include <internal/mm.h>
+#include <string.h>
#include <internal/string.h>
#define NDEBUG
#include <ddk/ntddk.h>
#include <internal/ke.h>
#include <internal/ob.h>
+#include <string.h>
#include <internal/string.h>
#include <internal/hal.h>
#include <internal/ps.h>
* Copyright (C) 1991, 1992 Linus Torvalds
*/
-#include <internal/ctype.h>
+#include <ctype.h>
#if 0
char _ctmp;
_L,_L,_L,_L,_L,_L,_L,_P,_L,_L,_L,_L,_L,_L,_L,_L}; /* 240-255 */
#endif
+int toupper(int c)
+{
+ if ('a' <= c && 'z' >= c)
+ {
+ return(c + 'A' - 'a');
+ }
+ return(c);
+}
+
+int tolower(int c)
+{
+ if ('A' <= c && 'Z' >= c)
+ {
+ return(c + 'a' - 'A');
+ }
+ return(c);
+}
+
+int islower(int c)
+{
+ return(('a' <= c && 'z' >= c));
+}
+
+int isdigit(int c)
+{
+ return(('0' <= c && '9' >= c));
+}
+
+int isxdigit(int c)
+{
+ return(('0' <= c && '9' >= c) || ('a' <= 'c' && 'f' >= 'c') ||
+ ('A' <= c && 'Z' >= c));
+}
/* INCLUDES *****************************************************************/
-#include <internal/string.h>
#include <ddk/ntddk.h>
+#include <string.h>
+#include <internal/string.h>
#define NDEBUG
#include <internal/debug.h>
--- /dev/null
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS kernel
+ * FILE: ntoskrnl/rtl/memcpy.c
+ * PROGRAMMER: David Welch (welch@cwcom.net)
+ * UPDATE HISTORY:
+ */
+
+/* INCLUDES *****************************************************************/
+
+#include <ddk/ntddk.h>
+#include <string.h>
+
+#define NDEBUG
+#include <internal/debug.h>
+
+/* FUNCTIONS *****************************************************************/
+
+#undef memcpy
+void *memcpy (void *to, const void *from, size_t count)
+{
+ register char *f = from;
+ register char *t = to;
+ register int i = count;
+
+ while (i-- > 0)
+ *t++ = *f++;
+
+ return to;
+}
+
/* FUNCTIONS *****************************************************************/
+char* strtok(char *s, const char *delim)
+{
+ const char *spanp;
+ int c, sc;
+ char *tok;
+ static char *last;
+
+
+ if (s == NULL && (s = last) == NULL)
+ return (NULL);
+
+ /*
+ * Skip (span) leading delimiters (s += strspn(s, delim), sort of).
+ */
+ cont:
+ c = *s++;
+ for (spanp = delim; (sc = *spanp++) != 0;) {
+ if (c == sc)
+ goto cont;
+ }
+
+ if (c == 0) { /* no non-delimiter characters */
+ last = NULL;
+ return (NULL);
+ }
+ tok = s - 1;
+
+ /*
+ * Scan token (scan for delimiters: s += strcspn(s, delim), sort of).
+ * Note that delim must have one NUL; we stop if we see that, too.
+ */
+ for (;;) {
+ c = *s++;
+ spanp = delim;
+ do {
+ if ((sc = *spanp++) == c) {
+ if (c == 0)
+ s = NULL;
+ else
+ s[-1] = 0;
+ last = s;
+ return (tok);
+ }
+ } while (sc != 0);
+ }
+ /* NOTREACHED */
+}
+
PWSTR RtlStrtok(PUNICODE_STRING _string, PWSTR _sep,
PWSTR* temp)
/*
int LeapSecondCorrections, SecondsInDay, CurYear;
int LeapYear, CurMonth, GMTOffset;
long int Days;
- long long int Time = *(long long int *)liTime;
+ long long int Time = *(long long int *)&liTime;
/* Extract millisecond from time and convert time into seconds */
TimeFields->Milliseconds = (CSHORT) ((Time % TICKSPERSEC) / TICKSPERMSEC);
* Created 10/08/98
*/
-#include <base.h>
-#include <wstring.h>
+#include <wchar.h>
#include <ddk/ntddk.h>
#include <internal/string.h>
#include <internal/ke.h>
-#include <internal/ctype.h>
+#include <ctype.h>
#define NDEBUG
#include <internal/debug.h>
NTSTATUS RtlAppendUnicodeToString(IN OUT PUNICODE_STRING Destination,
IN PWSTR Source)
{
- unsigned long i, slen=wstrlen(Source);
+ unsigned long i, slen=wcslen(Source);
if(Destination->MaximumLength-Destination->Length-slen<0)
return STATUS_BUFFER_TOO_SMALL;
}
else
{
- DestSize=wstrlen((PWSTR)SourceString);
+ DestSize=wcslen((PWSTR)SourceString);
DestinationString->Length=DestSize;
DestinationString->MaximumLength=DestSize+1;
DestinationString->Buffer=(PWSTR)SourceString;
#include <stdarg.h>
#include <internal/debug.h>
-#include <internal/ctype.h>
+#include <string.h>
#include <internal/string.h>
#include <ddk/ntddk.h>
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/rtl/wstring.c
* PURPOSE: Wide string functions
- * PROGRAMMER: David Welch (welch@mcmail.com)
+ * PROGRAMMER: David Welch (welch@cwcom.net)
* UPDATE HISTORY:
* Created 22/05/98
* 1998/12/04 RJJ Cleaned up and added i386 def checks
/* INCLUDES *****************************************************************/
#include <ddk/ntddk.h>
-#include <wstring.h>
+#include <wchar.h>
#define NDEBUG
#include <internal/debug.h>
+/* GLOBALS *****************************************************************/
+
wchar_t * ___wcstok = NULL;
/* FUNCTIONS *****************************************************************/
-wchar_t* wstrdup(const wchar_t* src)
+wchar_t* wcsdup(wchar_t* src)
{
wchar_t* dest;
- dest = ExAllocatePool(NonPagedPool, (wstrlen(src)+1)*2);
+ dest = ExAllocatePool(NonPagedPool, (wcslen(src)+1)*2);
wcscpy(dest,src);
return(dest);
}
-wchar_t *
-wcscat(wchar_t *dest, const wchar_t *src)
+wchar_t * wcscat(wchar_t *dest, const wchar_t *src)
{
int i, j;
{
if ((*str) == ch)
{
- return str;
+ return (wchar_t *) str;
}
str++;
}
int wcsicmp(const wchar_t* cs, const wchar_t* ct)
{
- while (*cs != '\0' && *ct != '\0' && towupper(*cs) == towupper(*ct))
+ while (*cs != '\0' && *ct != '\0' && wtoupper(*cs) == wtoupper(*ct))
{
cs++;
ct++;
return(str1);
}
-#ifdef i386
-
-size_t
-wcscspn(const wchar_t *cs, const wchar_t *ct)
+size_t wcscspn(const wchar_t *cs, const wchar_t *ct)
{
- register wchar_t * __res;
- __asm__ __volatile__(
- "cld\n\t"
- "movl %4,%%edi\n\t"
- "repne\n\t"
- "scasw\n\t"
- "notl %%ecx\n\t"
- "decl %%ecx\n\t"
- "movl %%ecx,%%edx\n"
- "1:\tlodsw\n\t"
- "testw %%eax,%%eax\n\t"
- "je 2f\n\t"
- "movl %4,%%edi\n\t"
- "movl %%edx,%%ecx\n\t"
- "repne\n\t"
- "scasw\n\t"
- "jne 1b\n"
- "2:\tdecl %0"
- : "=S" (__res)
- : "a" (0),"c" (0xffffffff),"0" (cs),"g" (ct)
- : "eax","ecx","edx","edi");
-
- return __res-cs;
+ UNIMPLEMENTED;
}
-#else
-
-size_t
-wcscspn(const wchar_t *cs, const wchar_t *ct)
-{
-UNIMPLEMENTED;
-}
-
-#endif
-
-#if 0
-
-int
-wcsicmp(const wchar_t *cs,const wchar_t *ct)
-{
- register int __res;
-
- __asm__ __volatile__(
- "cld\n"
- "1:\tmovw (%%esi), %%eax\n\t"
- "movw (%%edi), %%edx \n\t"
- "cmpw $0x5A, %%eax\n\t"
- "ja 2f\t\n"
- "cmpw $0x40, %%eax\t\n"
- "jbe 2f\t\n"
- "addw $0x20, %%eax\t\n"
- "2:\t cmpw $0x5A, %%edx\t\n"
- "ja 3f\t\n"
- "cmpw $0x40, %%edx\t\n"
- "jbe 3f\t\n"
- "addw $0x20, %%edx\t\n"
- "3:\t inc %%esi\t\n"
- "inc %%esi\t\n"
- "inc %%edi\t\n"
- "inc %%edi\t\n"
- "cmpw %%eax, %%edx\t\n"
- "jne 4f\n\t"
- "cmpw $00, %%eax\n\t"
- "jne 1b\n\t"
- "xorl %%eax,%%eax\n\t"
- "jmp 5f\n"
- "4:\tsbbl %%eax,%%eax\n\t"
- "orw $1,%%eax\n"
- "5:"
- : "=a" (__res)
- : "S" (cs),"D" (ct)
- : "esi","edi");
-
- return __res;
-}
-
-
-
-int
-wcsicmp(const wchar_t *cs,const wchar_t *ct)
-{
-UNIMPLEMENTED;
-}
-
-#endif
-
-size_t
-wcslen(const wchar_t *s)
+size_t wcslen(const wchar_t *s)
{
unsigned int len = 0;
return dest;
}
-#ifdef i386
-
-int
-wcsncmp(const wchar_t *cs, const wchar_t *ct, size_t count)
-{
- register int __res;
-
- __asm__ __volatile__(
- "cld\n"
- "1:\tdecl %3\n\t"
- "js 2f\n\t"
- "lodsw\n\t"
- "scasw\n\t"
- "jne 3f\n\t"
- "testw %%eax,%%eax\n\t"
- "jne 1b\n"
- "2:\txorl %%eax,%%eax\n\t"
- "jmp 4f\n"
- "3:\tsbbl %%eax,%%eax\n\t"
- "orw $1,%%eax\n"
- "4:"
- : "=a" (__res)
- : "S" (cs), "D" (ct), "c" (count)
- : "esi","edi","ecx");
-
- return __res;
-}
-
-#else
-
int
wcsncmp(const wchar_t *cs, const wchar_t *ct, size_t count)
{
UNIMPLEMENTED;
}
-#endif
wchar_t *
wcsncpy(wchar_t *dest, const wchar_t *src, size_t count)
return dest;
}
-#ifdef i386
-
-int
-wcsnicmp(const wchar_t *cs,const wchar_t *ct, size_t count)
-{
- register int __res;
-
- __asm__ __volatile__(
- "cld\n"
- "1:\t decl %3\n\t"
- "js 6f\n\t"
- "movw (%%esi), %%eax\n\t"
- "movw (%%edi), %%edx \n\t"
- "cmpw $0x5A, %%eax\n\t"
- "ja 2f\t\n"
- "cmpw $0x40, %%eax\t\n"
- "jbe 2f\t\n"
- "addw $0x20, %%eax\t\n"
- "2:\t cmpw $0x5A, %%edx\t\n"
- "ja 3f\t\n"
- "cmpw $0x40, %%edx\t\n"
- "jbe 3f\t\n"
- "addw $0x20, %%edx\t\n"
- "3:\t inc %%esi\t\n"
- "inc %%esi\t\n"
- "inc %%edi\t\n"
- "inc %%edi\t\n"
- "cmpw %%eax, %%edx\t\n"
- "jne 4f\n\t"
- "cmpw $00, %%eax\n\t"
- "jne 1b\n\t"
- "6:xorl %%eax,%%eax\n\t"
- "jmp 5f\n"
- "4:\tsbbl %%eax,%%eax\n\t"
- "orw $1,%%eax\n"
- "5:"
- : "=a" (__res)
- : "S" (cs), "D" (ct), "c" (count)
- : "esi", "edi", "ecx");
-
- return __res;
-}
-
-#else
-
-int
-wcsnicmp(const wchar_t *cs,const wchar_t *ct, size_t count)
-{
-UNIMPLEMENTED;
-}
-
-#endif
-
-#ifdef i386
-
-size_t
-wcsnlen(const wchar_t *s, size_t count)
-{
- register int __res;
- __asm__ __volatile__(
- "movl %1,%0\n\t"
- "jmp 2f\n"
- "1:\tcmpw $0,(%0)\n\t"
- "je 3f\n\t"
- "incl %0\n"
- "2:\tdecl %2\n\t"
- "cmpl $-1,%2\n\t"
- "jne 1b\n"
- "3:\tsubl %1,%0"
- : "=a" (__res)
- : "c" (s), "d" (count)
- : "edx");
-
- return __res;
-}
-
-#else
-
-size_t
-wcsnlen(const wchar_t *s, size_t count)
-{
-UNIMPLEMENTED;
-}
-
-#endif
-
-#ifdef i386
-wchar_t *
-wcspbrk(const wchar_t *cs, const wchar_t *ct)
+int wcsnicmp(const wchar_t *cs, const wchar_t *ct, size_t count)
{
- register wchar_t * __res;
- __asm__ __volatile__(
- "cld\n\t"
- "movl %4,%%edi\n\t"
- "repne\n\t"
- "scasw\n\t"
- "notl %%ecx\n\t"
- "decl %%ecx\n\t"
- "movl %%ecx,%%edx\n"
- "1:\tlodsw\n\t"
- "testw %%eax,%%eax\n\t"
- "je 2f\n\t"
- "movl %4,%%edi\n\t"
- "movl %%edx,%%ecx\n\t"
- "repne\n\t"
- "scasw\n\t"
- "jne 1b\n\t"
- "decl %0\n\t"
- "jmp 3f\n"
- "2:\txorl %0,%0\n"
- "3:"
- : "=S" (__res)
- : "a" (0), "c" (0xffffffff), "0" (cs), "g" (ct)
- : "eax", "ecx", "edx", "edi");
-
- return __res;
+ UNIMPLEMENTED;
}
-#else
-
-wchar_t *
-wcspbrk(const wchar_t *cs, const wchar_t *ct)
-{
-UNIMPLEMENTED;
-}
-
-#endif
wchar_t *
wcsrchr(const wchar_t *str, wchar_t ch)
return NULL;
}
-#ifdef i386
-
-size_t
-wcsspn(const wchar_t *cs, const wchar_t *ct)
-{
- register wchar_t * __res;
-
- __asm__ __volatile__(
- "cld\n\t"
- "movl %4,%%edi\n\t"
- "repne\n\t"
- "scasw\n\t"
- "notl %%ecx\n\t"
- "decl %%ecx\n\t"
- "movl %%ecx,%%edx\n"
- "1:\tlodsw\n\t"
- "testw %%eax,%%eax\n\t"
- "je 2f\n\t"
- "movl %4,%%edi\n\t"
- "movl %%edx,%%ecx\n\t"
- "repne\n\t"
- "scasb\n\t"
- "je 1b\n"
- "2:\tdecl %0"
- : "=S" (__res)
- : "a" (0), "c" (0xffffffff), "0" (cs), "g" (ct)
- : "eax", "ecx", "edx", "edi");
-
- return __res-cs;
-}
-
-#else
-
size_t
wcsspn(const wchar_t *cs, const wchar_t *ct)
{
UNIMPLEMENTED;
}
-#endif
-
-#ifdef i386
-
-wchar_t *
-wcsstr(const wchar_t *cs, const wchar_t *ct)
-{
- register wchar_t * __res;
-
- __asm__ __volatile__(
- "cld\n\t" \
- "movl %4,%%edi\n\t"
- "repne\n\t"
- "scasw\n\t"
- "notl %%ecx\n\t"
- "decl %%ecx\n\t" /* NOTE! This also sets Z if searchstring='' */
- "movl %%ecx,%%edx\n"
- "1:\tmovl %4,%%edi\n\t"
- "movl %%esi,%%eax\n\t"
- "movl %%edx,%%ecx\n\t"
- "repe\n\t"
- "cmpsw\n\t"
- "je 2f\n\t" /* also works for empty string, see above */
- "xchgl %%eax,%%esi\n\t"
- "incl %%esi\n\t"
- "cmpw $0,-1(%%eax)\n\t"
- "jne 1b\n\t"
- "xorl %%eax,%%eax\n\t"
- "2:"
- : "=a" (__res)
- : "0" (0), "c" (0xffffffff), "S" (cs), "g" (ct)
- : "ecx", "edx", "edi", "esi");
-
- return __res;
-}
-
-#else
-
-wchar_t *
-wcsstr(const wchar_t *cs, const wchar_t *ct)
+wchar_t * wcsstr(const wchar_t *cs, const wchar_t *ct)
{
UNIMPLEMENTED;
}
-#endif
-
-size_t wstrlen(const wchar_t *s)
-{
- return wcslen(s);
-}
-
-#ifdef i386
-
-wchar_t *
-wcstok(wchar_t * s,const wchar_t * ct)
-{
- register wchar_t * __res;
-
- __asm__ __volatile__(
- "testl %1,%1\n\t"
- "jne 1f\n\t"
- "testl %0,%0\n\t"
- "je 8f\n\t"
- "movl %0,%1\n"
- "1:\txorl %0,%0\n\t"
- "movl $-1,%%ecx\n\t"
- "xorl %%eax,%%eax\n\t"
- "cld\n\t"
- "movl %4,%%edi\n\t"
- "repnz\n\t"
- "scasw\n\t"
- "notl %%ecx\n\t"
- "decl %%ecx\n\t"
- "decl %%ecx\n\t"
- "je 7f\n\t" /* empty delimiter-string */
- "movl %%ecx,%%edx\n"
- "2:\tlodsw\n\t"
- "testw %%eax,%%eax\n\t"
- "je 7f\n\t"
- "movl %4,%%edi\n\t"
- "movl %%edx,%%ecx\n\t"
- "repne\n\t"
- "scasw\n\t"
- "je 2b\n\t"
- "decl %1\n\t"
- "decl %1\n\t"
- "cmpw $0,(%1)\n\t"
- "je 7f\n\t"
- "movl %1,%0\n"
- "3:\tlodsw\n\t"
- "testw %%eax,%%eax\n\t"
- "je 5f\n\t"
- "movl %4,%%edi\n\t"
- "movl %%edx,%%ecx\n\t"
- "repne\n\t"
- "scasw\n\t"
- "jne 3b\n\t"
- "decl %1\n\t"
- "decl %1\n\t"
- "decl %1\n\t"
- "decl %1\n\t"
- "cmpw $0,(%1)\n\t"
- "je 5f\n\t"
- "movw $0,(%1)\n\t"
- "incl %1\n\t"
- "incl %1\n\t"
- "jmp 6f\n"
- "5:\txorl %1,%1\n"
- "6:\tcmpw $0,(%0)\n\t"
- "jne 7f\n\t"
- "xorl %0,%0\n"
- "7:\ttestl %0,%0\n\t"
- "jne 8f\n\t"
- "movl %0,%1\n"
- "8:"
- : "=b" (__res), "=S" (___wcstok)
- : "0" (___wcstok), "1" (s), "g" (ct)
- : "eax", "ecx", "edx", "edi", "memory");
-
- return __res;
-}
-
-#else
-
-wchar_t *
-wcstok(wchar_t * s,const wchar_t * ct)
+wchar_t * wcstok(wchar_t * s,const wchar_t * ct)
{
UNIMPLEMENTED;
}
-#endif
-
{
}
-NTSTATUS
-STDCALL
-NtCreateToken(
- OUT PHANDLE TokenHandle,
- IN ACCESS_MASK DesiredAccess,
- IN POBJECT_ATTRIBUTES ObjectAttributes,
- IN TOKEN_TYPE TokenType,
- IN PLUID AuthenticationId,
- IN PLARGE_INTEGER ExpirationTime,
- IN PTOKEN_USER TokenUser,
- IN PTOKEN_GROUPS TokenGroups,
- IN PTOKEN_PRIVILEGES TokenPrivileges,
- IN PTOKEN_OWNER TokenOwner,
- IN PTOKEN_PRIMARY_GROUP TokenPrimaryGroup,
- IN PTOKEN_DEFAULT_DACL TokenDefaultDacl,
- IN PTOKEN_SOURCE TokenSource
- )
+NTSTATUS STDCALL NtCreateToken(VOID)
{
}
#include <windows.h>
#include <ddk/ntddk.h>
+#include <string.h>
#include <internal/string.h>
#include <internal/mm.h>
#include <internal/mmhal.h>
fprintf(stdout,"#include <internal/ke.h>\n");
fprintf(stdout,"#include <internal/ntoskrnl.h>\n");
fprintf(stdout,"#include <internal/mm.h>\n");
- fprintf(stdout,"#include <wstring.h>\n");
+ fprintf(stdout,"#include <wchar.h>\n");
while (!feof(stdin))
{
--- /dev/null
+#include <stdio.h>
+#include <base.h>
+#include <pe.h>
+
+int main(int argc, char* argv[])
+{
+ FILE* in;
+ FILE* out;
+ IMAGE_DOS_HEADER dos_header;
+ DWORD pe_signature;
+ IMAGE_FILE_HEADER file_header;
+ IMAGE_OPTIONAL_HEADER opt_header;
+ IMAGE_SECTION_HEADER scn_header;
+ int i;
+ int prev_pos;
+ void* buffer;
+ ULONG base_address;
+
+ if (argc != 4)
+ {
+ printf("usage: pe2bin base infile outfile\n");
+ return(1);
+ }
+
+ base_address = strtoul(argv[1],NULL,0);
+ printf("Generating for base %x\n",base_address);
+
+ in = fopen(argv[2], "rb");
+ if (in == NULL)
+ {
+ printf("Unable to open %s\n",argv[1]);
+ return(1);
+ }
+
+ out = fopen(argv[3], "wb");
+ if (out == NULL)
+ {
+ printf("Unable to open %s\n",argv[2]);
+ return(1);
+ }
+
+ fread(&dos_header,sizeof(IMAGE_DOS_HEADER),1,in);
+// printf("dos_header.e_magic %x\n",dos_header.e_magic);
+ if (dos_header.e_magic != IMAGE_DOS_MAGIC)
+ {
+ printf("Bad magic in dos header\n");
+ return(1);
+ }
+
+ fseek(in,dos_header.e_lfanew,SEEK_SET);
+ fread(&pe_signature,sizeof(DWORD),1,in);
+ if (pe_signature != IMAGE_PE_MAGIC)
+ {
+ printf("Bad magic in pe header\n");
+ return(1);
+ }
+
+ fread(&file_header,sizeof(IMAGE_FILE_HEADER),1,in);
+ fread(&opt_header,sizeof(IMAGE_OPTIONAL_HEADER),1,in);
+
+// printf("Linker version: %d.%d\n",opt_header.MajorLinkerVersion,
+// opt_header.MinorLinkerVersion);
+
+ for (i=0; i<file_header.NumberOfSections; i++)
+ {
+ fread(&scn_header,sizeof(IMAGE_SECTION_HEADER),1,in);
+// printf("Section name: %.8s\n",scn_header.Name);
+// printf("Virtual address: %x\n",scn_header.VirtualAddress
+// + opt_header.ImageBase);
+// printf("Characteristics: %x\n",scn_header.Characteristics);
+
+ if ((scn_header.Characteristics & IMAGE_SECTION_CODE) ||
+ (scn_header.Characteristics & IMAGE_SECTION_INITIALIZED_DATA))
+ {
+// printf("Writing section to output file\n");
+ prev_pos = ftell(in);
+ fseek(in, scn_header.PointerToRawData, SEEK_SET);
+ buffer = malloc(scn_header.SizeOfRawData);
+ fread(buffer, scn_header.SizeOfRawData, 1, in);
+ fseek(out, scn_header.VirtualAddress + opt_header.ImageBase -
+ base_address,
+ SEEK_SET);
+ fwrite(buffer, scn_header.SizeOfRawData, 1, out);
+ fseek(in, prev_pos, SEEK_SET);
+ }
+ }
+ return(0);
+}
#
.EXPORT_ALL_VARIABLES:
+ifeq ($(HOST),mingw32-linux)
+TOPDIR := $(shell if [ "$$PWD" != "" ]; then echo $$PWD; else pwd; fi)
+endif
#
# Choose various options
#
-ifeq ($(HOST),elf-linux)
-NASM_FORMAT = elf
-PREFIX =
-KERNEL_BFD_TARGET = --oformat=elf32-i386
-EXE_POSTFIX =
-CP = cp
-endif
-
-ifeq ($(HOST),djgpp-linux)
-NASM_FORMAT = coff
-PREFIX = dos-
-KERNEL_BFD_TARGET = --oformat=coff-i386
-EXE_POSTFIX =
-CP = cp
-LIBGCC = ./libgcc.a
-endif
-
ifeq ($(HOST),mingw32-linux)
NASM_FORMAT = win32
-PREFIX = i386-mingw32-
-#KERNEL_BFD_TARGET = pe-i386
-KERNEL_BFD_TARGET =
+PREFIX = i586-mingw32-
EXE_POSTFIX =
CP = cp
DLLTOOL = $(PREFIX)dlltool --as=$(PREFIX)as
-LIBGCC = /usr/lib/gcc-lib/i386-mingw32/2.8.1/libgcc.a
-NASM_CMD = nasm
-endif
-
-ifeq ($(HOST),djgpp-msdos)
-NASM_FORMAT = coff
-PREFIX =
-KERNEL_BFD_TARGET = --oformat=coff-go32
-EXE_POSTFIX = .exe
-CP = COPY
-RM = DELETE
-LIBGCC = libgcc.a
NASM_CMD = nasm
+KM_SPECS = $(TOPDIR)/specs
endif
ifeq ($(HOST),mingw32-windows)
NASM_FORMAT = win32
PREFIX =
-KERNEL_BFD_TARGET = --oformat=pe-i386
EXE_POSTFIX = .exe
CP = copy
+DLLTOOL = $(PREFIX)dlltool --as=$(PREFIX)as
+NASM_CMD = nasm
+RM = DELETE
+KM_SPECS = specs
endif
#
DEBUGGING_CFLAGS =
endif
-DEFINES = -DDBG -DCHECKED -DCOMPILER_LARGE_INTEGERS
+DEFINES = -DDBG -DCOMPILER_LARGE_INTEGERS
ifeq ($(WIN32_LEAN_AND_MEAN),yes)
LEAN_AND_MEAN_DEFINE = -DWIN32_LEAN_AND_MEAN
CPP = $(PREFIX)cpp
AR = $(PREFIX)ar
-%.o: %.cc
+%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@
%.o: %.asm
$(NASM_CMD) $(NFLAGS) $< -o $@
--- /dev/null
+*asm:
+
+
+*asm_final:
+
+
+*cpp:
+-remap %(cpp_cpu) %{posix:-D_POSIX_SOURCE}
+
+*cc1:
+%(cc1_spec)
+
+*cc1plus:
+
+
+*endfile:
+
+
+*link:
+%{mwindows:--subsystem windows} %{mdll:--dll -e _DllMainCRTStartup@12}
+
+*lib:
+
+
+*libgcc:
+-lgcc
+
+*startfile:
+
+
+*switches_need_spaces:
+
+
+*signed_char:
+%{funsigned-char:-D__CHAR_UNSIGNED__}
+
+*predefines:
+-Di386 -D_WIN32 -DWIN32 -D__WIN32__ -D__MINGW32__ -DWINNT -D_X86_=1 -D__STDC__=1 -D__stdcall=__attribute__((__stdcall__)) _D_stdcall=__attribute__((__stdcall__)) -D__cdecl=__attribute__((__cdecl__)) -D__declspec(x)=__attribute__((x)) -Asystem(winnt) -Acpu(i386) -Amachine(i386)
+
+*cross_compile:
+1
+
+*version:
+egcs-2.91.57
+
+*multilib:
+. ;
+
+*multilib_defaults:
+
+
+*multilib_extra:
+
+
+*multilib_matches:
+
+
+*linker:
+collect2
+
+*cpp_486:
+%{!ansi:-Di486} -D__i486 -D__i486__
+
+*cpp_586:
+%{!ansi:-Di586 -Dpentium} -D__i586 -D__i586__ -D__pentium -D__pentium__
+
+*cpp_686:
+%{!ansi:-Di686 -Dpentiumpro} -D__i686 -D__i686__ -D__pentiumpro -D__pentiumpro__
+
+*cpp_cpu_default:
+%(cpp_586)
+
+*cpp_cpu:
+-Acpu(i386) -Amachine(i386) %{!ansi:-Di386} -D__i386 -D__i386__ %{mcpu=i486:%(cpp_486)} %{m486:%(cpp_486)} %{mpentium:%(cpp_586)} %{mcpu=pentium:%(cpp_586)} %{mpentiumpro:%(cpp_686)} %{mcpu=pentiumpro:%(cpp_686)} %{!mcpu*:%{!m486:%{!mpentium*:%(cpp_cpu_default)}}}
+
+*cc1_cpu:
+%{!mcpu*: %{m386:-mcpu=i386 -march=i386} %{mno-486:-mcpu=i386 -march=i386} %{m486:-mcpu=i486 -march=i486} %{mno-386:-mcpu=i486 -march=i486} %{mno-pentium:-mcpu=i486 -march=i486} %{mpentium:-mcpu=pentium} %{mno-pentiumpro:-mcpu=pentium} %{mpentiumpro:-mcpu=pentiumpro}}
+