Created bugs in wait and timer code

svn path=/trunk/; revision=152
This commit is contained in:
David Welch 1999-01-04 23:01:18 +00:00
parent 4850652d25
commit 36902d624f
34 changed files with 1708 additions and 824 deletions

View file

@ -6,5 +6,5 @@
void main()
{
NtDisplayString("Hello world\n");
ExitThread(0);
ExitProcess(0);
}

View file

@ -142,7 +142,7 @@ void ExecuteCommand(char* line)
}
cmd = line;
debug_printf("cmd '%s' tail '%s'\n",cmd,tail);
// debug_printf("cmd '%s' tail '%s'\n",cmd,tail);
if (cmd==NULL)
{
@ -194,6 +194,11 @@ void ReadLine(char* line)
line++;
}
} while (!(KeyEvent.bKeyDown && KeyEvent.AsciiChar == '\n'));
ReadFile(KeyboardHandle,
&KeyEvent,
sizeof(KEY_EVENT_RECORD),
&Result,
NULL);
line--;
*line = 0;
}

View file

@ -479,7 +479,12 @@ static unsigned int KeyboardHandler(unsigned int irq)
ProcessScanCode(thisKey,isDown);
DPRINT("Key: '%c'\n",VirtualToAscii(ScanToVirtual(thisKey),isDown));
// DbgPrint("Key: %c\n",VirtualToAscii(ScanToVirtual(thisKey),isDown));
// DbgPrint("Key: %x\n",ScanToVirtual(thisKey));
if (ScanToVirtual(thisKey)==0x2a)
{
KeBugCheck(0);
}
if (CurrentIrp!=NULL)
{

View file

@ -1,5 +1,3 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -19,7 +17,7 @@
#include <internal/debug.h>
#include "vfat.h"
//#include "dbgpool.c"
/* FUNCTIONS ***************************************************************/
BOOLEAN VFATReadSectors(IN PDEVICE_OBJECT pDeviceObject,
@ -33,27 +31,29 @@ BOOLEAN VFATReadSectors(IN PDEVICE_OBJECT pDeviceObject,
KEVENT event;
NTSTATUS status;
ULONG sectorSize;
PULONG mbr;
DPRINT("VFATReadSector(pDeviceObject %x, DiskSector %d,count %d, Buffer %x)\n",
pDeviceObject,DiskSector,SectorCount,Buffer);
SET_LARGE_INTEGER_LOW_PART(sectorNumber, DiskSector << 9);
SET_LARGE_INTEGER_HIGH_PART(sectorNumber, DiskSector >> 23);
KeInitializeEvent(&event, NotificationEvent, FALSE);
sectorSize = BLOCKSIZE * SectorCount;
DPRINT("SectorCount=%d,sectorSize=%d,BLOCKSIZE=%d\n",SectorCount,sectorSize,BLOCKSIZE);
mbr = ExAllocatePool(NonPagedPool, sectorSize);
if (!mbr) {
return FALSE;
}
/* FIXME: this routine does not need to alloc mem and copy */
DPRINT("VFATReadSector(pDeviceObject %x, DiskSector %d, Buffer %x)\n",
pDeviceObject,
DiskSector,
Buffer);
DPRINT("sectorNumber %08lx:%08lx sectorSize %ld\n",
(unsigned long int)GET_LARGE_INTEGER_HIGH_PART(sectorNumber),
(unsigned long int)GET_LARGE_INTEGER_LOW_PART(sectorNumber),
sectorSize);
DPRINT("Building synchronous FSD Request...\n");
irp = IoBuildSynchronousFsdRequest(IRP_MJ_READ,
pDeviceObject,
mbr,
Buffer,
sectorSize,
&sectorNumber,
&event,
@ -61,19 +61,21 @@ DPRINT("SectorCount=%d,sectorSize=%d,BLOCKSIZE=%d\n",SectorCount,sectorSize,BLOC
if (!irp) {
DbgPrint("READ failed!!!\n");
ExFreePool(mbr);
return FALSE;
}
DPRINT("Calling IO Driver...\n");
status = IoCallDriver(pDeviceObject,
irp);
DPRINT("Waiting for IO Operation...\n");
if (status == STATUS_PENDING) {
KeWaitForSingleObject(&event,
Suspended,
KernelMode,
FALSE,
NULL);
DPRINT("Getting IO Status...\n");
status = ioStatus.Status;
}
@ -85,13 +87,11 @@ DPRINT("SectorCount=%d,sectorSize=%d,BLOCKSIZE=%d\n",SectorCount,sectorSize,BLOC
Buffer,
GET_LARGE_INTEGER_HIGH_PART(sectorNumber),
GET_LARGE_INTEGER_LOW_PART(sectorNumber));
ExFreePool(mbr);
return FALSE;
}
RtlCopyMemory(Buffer,mbr,sectorSize);
ExFreePool(mbr);
DPRINT("Copying memory...\n");
DPRINT("Block request succeeded\n");
return TRUE;
}
@ -108,8 +108,9 @@ BOOLEAN VFATWriteSectors(IN PDEVICE_OBJECT pDeviceObject,
ULONG sectorSize;
PULONG mbr;
DPRINT("VFATWriteSector(pDeviceObject %x, DiskSector %d, count %d, Buffer %x)\n",
pDeviceObject,DiskSector,SectorCount,Buffer);
DPRINT("VFATWriteSector(pDeviceObject %x, DiskSector %d, Buffer %x)\n",
pDeviceObject,DiskSector,Buffer);
SET_LARGE_INTEGER_LOW_PART(sectorNumber, DiskSector << 9);
SET_LARGE_INTEGER_HIGH_PART(sectorNumber, DiskSector >> 23);
@ -122,7 +123,7 @@ BOOLEAN VFATWriteSectors(IN PDEVICE_OBJECT pDeviceObject,
if (!mbr) {
return FALSE;
}
memcpy(mbr,Buffer,sectorSize);
DPRINT("Building synchronous FSD Request...\n");
irp = IoBuildSynchronousFsdRequest(IRP_MJ_WRITE,
@ -168,4 +169,3 @@ BOOLEAN VFATWriteSectors(IN PDEVICE_OBJECT pDeviceObject,
return TRUE;
}

View file

@ -821,7 +821,14 @@ NTSTATUS FsdOpenFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
Status = FindFile(DeviceExt,Fcb,ParentFcb,current,NULL,NULL);
if (Status != STATUS_SUCCESS)
{
/* FIXME: should the VfatFCB be freed here? */
if (Fcb != NULL)
{
ExFreePool(Fcb);
}
if (ParentFcb != NULL)
{
ExFreePool(ParentFcb);
}
return(Status);
}
Temp = Fcb;

View file

@ -268,4 +268,7 @@ typedef struct _EPROCESS
KPROCESS Pcb;
} EPROCESS, *PEPROCESS;
#define PROCESS_STATE_TERMINATED (1)
#define PROCESS_STATE_ACTIVE (2)
#endif /* __INCLUDE_DDK_PSTYPES_H */

View file

@ -13,6 +13,7 @@ void PsInitThreadManagment(void);
VOID PsInitProcessManagment(VOID);
VOID PsInitIdleThread(VOID);
VOID PsDispatchThread(VOID);
VOID PiTerminateProcessThreads(PEPROCESS Process, NTSTATUS ExitStatus);
/*
* PURPOSE: Thread states

View file

@ -1,5 +1,11 @@
#include <windows.h>
#ifdef NDEBUG
#define DPRINT(args...)
#else
#define DPRINT(args...) do { dprintf("(KERNEL32:%s:%d) ",__FILE__,__LINE__); dprintf(args); } while(0);
#endif
void dprintf(char* fmt, ...);
void aprintf(char* fmt, ...);

View file

@ -20,6 +20,7 @@ typedef unsigned short wchar_t;
extern "C" {
#endif
wchar_t* wstrdup(const wchar_t* src);
extern wchar_t * ___wcstok;
extern wchar_t * wcscpy(wchar_t *,const wchar_t *);
extern wchar_t * wcsncpy(wchar_t *,const wchar_t *, __kernel_size_t);

View file

@ -0,0 +1,715 @@
;
; crtdll.def
;
; Exports from crtdll.dll from Windows 95 SYSTEM directory. Hopefully this
; should also work with the crtdll provided with Windows NT.
;
; 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.
;
; $Revision: 1.1 $
; $Author: dwelch $
; $Date: 1999/01/04 23:01:18 $
;
; These three functions appear to be name mangled in some way, so GCC is
; probably not going to be able to use them in any case.
;
; ??2@YAPAXI@Z
; ??3@YAXPAX@Z
; ?_set_new_handler@@YAP6AHI@ZP6AHI@Z@Z
;
; These are functions for which I have not yet written prototypes or
; otherwise set up (they are still included below though unlike those
; first three).
;
; _CIacos
; _CIasin
; _CIatan
; _CIatan2
; _CIcos
; _CIcosh
; _CIexp
; _CIfmod
; _CIlog
; _CIlog10
; _CIpow
; _CIsin
; _CIsinh
; _CIsqrt
; _CItan
; _CItanh
; __dllonexit
; __mb_cur_max_dll
; __threadhandle
; __threadid
; _abnormal_termination
; _acmdln_dll
; _aexit_rtn_dll
; _amsg_exit
; _commit
; _commode_dll
; _cpumode_dll
; _ctype
; _daylight_dll
; _environ_dll
; _expand
; _fcloseall
; _filbuf
; _fileinfo_dll
; _flsbuf
; _flushall
; _fmode_dll
; _fpieee_flt
; _fsopen
; _ftol
; _getdiskfree
; _getdllprocaddr
; _getdrive
; _getdrives
; _getsystime
; _getw
; _initterm
; _ismbbalnum
; _ismbbalpha
; _ismbbgraph
; _ismbbkalnum
; _ismbbkana
; _ismbbkpunct
; _ismbblead
; _ismbbprint
; _ismbbpunct
; _ismbbtrail
; _ismbcalpha
; _ismbcdigit
; _ismbchira
; _ismbckata
; _ismbcl0
; _ismbcl1
; _ismbcl2
; _ismbclegal
; _ismbclower
; _ismbcprint
; _ismbcspace
; _ismbcsymbol
; _ismbcupper
; _ismbslead
; _ismbstrail
; _lfind
; _loaddll
; _lrotl
; _lrotr
; _lsearch
; _makepath
; _matherr
; _mbbtombc
; _mbbtype
; _mbccpy
; _mbcjistojms
; _mbcjmstojis
; _mbclen
; _mbctohira
; _mbctokata
; _mbctolower
; _mbctombb
; _mbctoupper
; _mbctype
; _mbsbtype
; _mbscat
; _mbscmp
; _mbscpy
; _mbscspn
; _mbsdec
; _mbsdup
; _mbsicmp
; _mbsinc
; _mbslen
; _mbslwr
; _mbsnbcat
; _mbsnbcmp
; _mbsnbcnt
; _mbsnbcpy
; _mbsnbicmp
; _mbsnbset
; _mbsnccnt
; _mbsncmp
; _mbsncpy
; _mbsnextc
; _mbsnicmp
; _mbsninc
; _mbsnset
; _mbspbrk
; _mbsrchr
; _mbsrev
; _mbsset
; _mbsspn
; _mbsspnp
; _mbsstr
; _mbstrlen
; _mbsupr
; _onexit
; _osver_dll
; _osversion_dll
; _pctype_dll
; _purecall
; _putw
; _pwctype_dll
; _rmtmp
; _rotl
; _rotr
; _setsystime
; _snprintf
; _snwprintf
; _splitpath
; _strdate
; _strdec
; _strinc
; _strncnt
; _strnextc
; _strninc
; _strspnp
; _strtime
; _tempnam
; _timezone_dll
; _tzname
; _tzset
; _ultoa
; _unloaddll
; _vsnprintf
; _vsnwprintf
; _winmajor_dll
; _winminor_dll
; _winver_dll
; _wtoi
; _wtol
;
EXPORTS
_CIacos
_CIasin
_CIatan
_CIatan2
_CIcos
_CIcosh
_CIexp
_CIfmod
_CIlog
_CIlog10
_CIpow
_CIsin
_CIsinh
_CIsqrt
_CItan
_CItanh
_HUGE_dll
_XcptFilter
__GetMainArgs
__argc_dll
__argv_dll
__dllonexit
__doserrno
__fpecode
__isascii
__iscsym
__iscsymf
__mb_cur_max_dll
__pxcptinfoptrs
__threadhandle
__threadid
__toascii
_abnormal_termination
_access
_acmdln_dll
_aexit_rtn_dll
_amsg_exit
_assert
_basemajor_dll
_baseminor_dll
_baseversion_dll
_beep
_beginthread
_c_exit
_cabs
_cexit
_cgets
_chdir
_chdrive
_chgsign
_chmod
_chsize
_clearfp
_close
_commit
_commode_dll
_control87
_controlfp
_copysign
_cprintf
_cpumode_dll
_cputs
_creat
_cscanf
_ctype
_cwait
_daylight_dll
_dup
_dup2
_ecvt
_endthread
_environ_dll
_eof
_errno
_except_handler2
_execl
_execle
_execlp
_execlpe
_execv
_execve
_execvp
_execvpe
_exit
_expand
_fcloseall
_fcvt
_fdopen
_fgetchar
_fgetwchar
_filbuf
_fileinfo_dll
_filelength
_fileno
_findclose
_findfirst
_findnext
_finite
_flsbuf
_flushall
_fmode_dll
_fpclass
_fpieee_flt
_fpreset
_fputchar
_fputwchar
_fsopen
_fstat
_ftime
_ftol
_fullpath
_futime
_gcvt
_get_osfhandle
_getch
_getche
_getcwd
_getdcwd
_getdiskfree
_getdllprocaddr
_getdrive
_getdrives
_getpid
_getsystime
_getw
_global_unwind2
_heapchk
_heapmin
_heapset
_heapwalk
_hypot
_initterm
_iob
_isatty
_isctype
_ismbbalnum
_ismbbalpha
_ismbbgraph
_ismbbkalnum
_ismbbkana
_ismbbkpunct
_ismbblead
_ismbbprint
_ismbbpunct
_ismbbtrail
_ismbcalpha
_ismbcdigit
_ismbchira
_ismbckata
_ismbcl0
_ismbcl1
_ismbcl2
_ismbclegal
_ismbclower
_ismbcprint
_ismbcspace
_ismbcsymbol
_ismbcupper
_ismbslead
_ismbstrail
_isnan
_itoa
_j0
_j1
_jn
_kbhit
_lfind
_loaddll
_local_unwind2
_locking
_logb
_lrotl
_lrotr
_lsearch
_lseek
_ltoa
_makepath
_matherr
_mbbtombc
_mbbtype
_mbccpy
_mbcjistojms
_mbcjmstojis
_mbclen
_mbctohira
_mbctokata
_mbctolower
_mbctombb
_mbctoupper
_mbctype
_mbsbtype
_mbscat
_mbschr
_mbscmp
_mbscpy
_mbscspn
_mbsdec
_mbsdup
_mbsicmp
_mbsinc
_mbslen
_mbslwr
_mbsnbcat
_mbsnbcmp
_mbsnbcnt
_mbsnbcpy
_mbsnbicmp
_mbsnbset
_mbsncat
_mbsnccnt
_mbsncmp
_mbsncpy
_mbsnextc
_mbsnicmp
_mbsninc
_mbsnset
_mbspbrk
_mbsrchr
_mbsrev
_mbsset
_mbsspn
_mbsspnp
_mbsstr
_mbstok
_mbstrlen
_mbsupr
_memccpy
_memicmp
_mkdir
_mktemp
_msize
_nextafter
_onexit
_open
_open_osfhandle
_osmajor_dll
_osminor_dll
_osmode_dll
_osver_dll
_osversion_dll
_pclose
_pctype_dll
_pgmptr_dll
_pipe
_popen
_purecall
_putch
_putenv
_putw
_pwctype_dll
_read
_rmdir
_rmtmp
_rotl
_rotr
_scalb
_searchenv
_seterrormode
_setjmp
_setmode
_setsystime
_sleep
_snprintf
_snwprintf
_sopen
_spawnl
_spawnle
_spawnlp
_spawnlpe
_spawnv
_spawnve
_spawnvp
_spawnvpe
_splitpath
_stat
_statusfp
_strcmpi
_strdate
_strdec
_strdup
_strerror
_stricmp
_stricoll
_strinc
_strlwr
_strncnt
_strnextc
_strnicmp
_strninc
_strnset
_strrev
_strset
_strspnp
_strtime
_strupr
_swab
_sys_errlist
_sys_nerr_dll
_tell
_tempnam
_timezone_dll
_tolower
_toupper
_tzname
_tzset
_ultoa
_umask
_ungetch
_unlink
_unloaddll
_utime
_vsnprintf
_vsnwprintf
_wcsdup
_wcsicmp
_wcsicoll
_wcslwr
_wcsnicmp
_wcsnset
_wcsrev
_wcsset
_wcsupr
_winmajor_dll
_winminor_dll
_winver_dll
_write
_wtoi
_wtol
_y0
_y1
_yn
abort
abs
acos
asctime
asin
atan
atan2
atexit
atof
atoi
atol
bsearch
calloc
ceil
clearerr
clock
cos
cosh
ctime
difftime
div
exit
exp
fabs
fclose
feof
ferror
fflush
fgetc
fgetpos
fgets
fgetwc
floor
fmod
fopen
fprintf
fputc
fputs
fputwc
fread
free
freopen
frexp
fscanf
fseek
fsetpos
ftell
fwprintf
fwrite
fwscanf
getc
getchar
getenv
gets
gmtime
is_wctype
isalnum
isalpha
iscntrl
isdigit
isgraph
isleadbyte
islower
isprint
ispunct
isspace
isupper
iswalnum
iswalpha
iswascii
iswcntrl
iswctype
iswdigit
iswgraph
iswlower
iswprint
iswpunct
iswspace
iswupper
iswxdigit
isxdigit
labs
ldexp
ldiv
localeconv
localtime
log
log10
longjmp
malloc
mblen
mbstowcs
mbtowc
memchr
memcmp
memcpy
memmove
memset
mktime
modf
perror
pow
printf
putc
putchar
puts
qsort
raise
rand
realloc
remove
rename
rewind
scanf
setbuf
setlocale
setvbuf
signal
sin
sinh
sprintf
sqrt
srand
sscanf
strcat
strchr
strcmp
strcoll
strcpy
strcspn
strerror
strftime
strlen
strncat
strncmp
strncpy
strpbrk
strrchr
strspn
strstr
strtod
strtok
strtol
strtoul
strxfrm
swprintf
swscanf
system
tan
tanh
time
tmpfile
tmpnam
tolower
toupper
towlower
towupper
ungetc
ungetwc
vfprintf
vfwprintf
vprintf
vsprintf
vswprintf
vwprintf
wcscat
wcschr
wcscmp
wcscoll
wcscpy
wcscspn
wcsftime
wcslen
wcsncat
wcsncmp
wcsncpy
wcspbrk
wcsrchr
wcsspn
wcsstr
wcstod
wcstok
wcstol
wcstombs
wcstoul
wcsxfrm
wctomb
wprintf
wscanf

View file

@ -17,7 +17,7 @@ STDLIB_OBJECTS = stdlib/malloc.o
OBJECTS = $(STRING_OBJECTS) $(STDIO_OBJECTS) $(STDLIB_OBJECTS)
crtdll.a: $(OBJECTS)
$(AR) vrcs crtdll.a $(OBJECTS)
$(AR) rcs crtdll.a $(OBJECTS)
dummy:

View file

@ -2,15 +2,15 @@
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/kernel32/file/create.c
* PURPOSE: Directory functions
* PURPOSE: File create/open functions
* PROGRAMMER: Ariadne ( ariadne@xs4all.nl)
GetTempFileName is modified from WINE [ Alexandre Juiliard ]
* GetTempFileName is modified from WINE [ Alexandre Juiliard ]
* UPDATE HISTORY:
* Created 01/11/98
*/
/* INCLUDES *****************************************************************/
#undef WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <ddk/ntddk.h>
#include <wstring.h>
@ -18,6 +18,11 @@
#include <kernel32/li.h>
#include <ddk/rtl.h>
#define NDEBUG
#include <kernel32/kernel32.h>
/* FUNCTIONS ****************************************************************/
HANDLE STDCALL CreateFileA(LPCSTR lpFileName,
DWORD dwDesiredAccess,
DWORD dwShareMode,
@ -30,7 +35,7 @@ HANDLE STDCALL CreateFileA(LPCSTR lpFileName,
WCHAR FileNameW[MAX_PATH];
ULONG i = 0;
OutputDebugStringA("CreateFileA\n");
DPRINT("CreateFileA\n");
while ((*lpFileName)!=0 && i < MAX_PATH)
{
@ -69,7 +74,7 @@ HANDLE STDCALL CreateFileW(LPCWSTR lpFileName,
UINT Len = 0;
WCHAR CurrentDir[MAX_PATH];
OutputDebugStringA("CreateFileW\n");
DPRINT("CreateFileW\n");
if (!(dwFlagsAndAttributes & FILE_FLAG_OVERLAPPED))
{
@ -83,16 +88,16 @@ HANDLE STDCALL CreateFileW(LPCWSTR lpFileName,
PathNameW[3] = '\\';
PathNameW[4] = 0;
dprintf("Name %w\n",PathNameW);
DPRINT("Name %w\n",PathNameW);
if (lpFileName[0] != L'\\' && lpFileName[1] != L':')
{
Len = GetCurrentDirectoryW(MAX_PATH,CurrentDir);
dprintf("CurrentDir %w\n",CurrentDir);
DPRINT("CurrentDir %w\n",CurrentDir);
lstrcatW(PathNameW,CurrentDir);
dprintf("Name %w\n",PathNameW);
DPRINT("Name %w\n",PathNameW);
}
lstrcatW(PathNameW,lpFileName);
dprintf("Name %w\n",PathNameW);
DPRINT("Name %w\n",PathNameW);
FileNameString.Length = lstrlenW( PathNameW)*sizeof(WCHAR);

View file

@ -3,7 +3,6 @@
* PROJECT: ReactOS system libraries
* FILE: lib/kernel32/file/curdir.c
* PURPOSE: Current directory functions
* PROGRAMMER: David Welch (welch@mcmail.com)
* UPDATE HISTORY:
* Created 30/09/98
*/
@ -13,6 +12,9 @@
#include <windows.h>
#define NDEBUG
#include <kernel32/kernel32.h>
/* GLOBALS *******************************************************************/
@ -46,7 +48,7 @@ DWORD STDCALL GetCurrentDirectoryW(DWORD nBufferLength, LPWSTR lpBuffer)
{
UINT uSize;
dprintf("CurrentDirectoryW %w\n",CurrentDirectoryW);
DPRINT("CurrentDirectoryW %w\n",CurrentDirectoryW);
if ( lpBuffer == NULL )
return 0;
@ -54,7 +56,7 @@ DWORD STDCALL GetCurrentDirectoryW(DWORD nBufferLength, LPWSTR lpBuffer)
if ( nBufferLength > uSize )
lstrcpynW(lpBuffer,CurrentDirectoryW,uSize);
dprintf("GetCurrentDirectoryW() = %w\n",lpBuffer);
DPRINT("GetCurrentDirectoryW() = %w\n",lpBuffer);
return uSize;
}
@ -63,7 +65,7 @@ BOOL STDCALL SetCurrentDirectoryA(LPCSTR lpPathName)
{
UINT i;
dprintf("SetCurrentDirectoryA(lpPathName %s)\n",lpPathName);
DPRINT("SetCurrentDirectoryA(lpPathName %s)\n",lpPathName);
if ( lpPathName == NULL )
return FALSE;
@ -77,17 +79,13 @@ BOOL STDCALL SetCurrentDirectoryA(LPCSTR lpPathName)
}
CurrentDirectoryW[i] = 0;
dprintf("CurrentDirectoryW = '%w'\n",CurrentDirectoryW);
DPRINT("CurrentDirectoryW = '%w'\n",CurrentDirectoryW);
return(TRUE);
}
WINBOOL
STDCALL
SetCurrentDirectoryW(
LPCWSTR lpPathName
)
WINBOOL STDCALL SetCurrentDirectoryW(LPCWSTR lpPathName)
{
if ( lpPathName == NULL )
return FALSE;

View file

@ -14,6 +14,9 @@
#include <wstring.h>
#include <ddk/ntddk.h>
#define NDEBUG
#include <kernel32/kernel32.h>
/* TYPES ********************************************************************/
typedef struct _KERNEL32_FIND_FILE_DATA
@ -74,7 +77,7 @@ WINBOOL STDCALL InternalFindNextFile(HANDLE hFindFile,
TRUE,
&(IData->PatternStr),
FALSE);
dprintf("Found %w\n",IData->FileInfo.FileName);
DPRINT("Found %w\n",IData->FileInfo.FileName);
lpFindFileData->dwFileAttributes = IData->FileInfo.FileAttributes;
if (Status != STATUS_SUCCESS)
{
@ -95,7 +98,7 @@ HANDLE STDCALL InternalFindFirstFile(LPCWSTR lpFileName,
UNICODE_STRING DirectoryNameStr;
IO_STATUS_BLOCK IoStatusBlock;
dprintf("FindFirstFileW(lpFileName %w, lpFindFileData %x)\n",
DPRINT("FindFirstFileW(lpFileName %w, lpFindFileData %x)\n",
lpFileName, lpFindFileData);
GetCurrentDirectoryW(MAX_PATH, CurrentDirectory);
@ -104,17 +107,17 @@ HANDLE STDCALL InternalFindFirstFile(LPCWSTR lpFileName,
Directory[2] = '?';
Directory[3] = '\\';
Directory[4] = 0;
dprintf("Directory %w\n",Directory);
DPRINT("Directory %w\n",Directory);
wcscat(Directory, CurrentDirectory);
dprintf("Directory %w\n",Directory);
DPRINT("Directory %w\n",Directory);
wcscat(Directory, lpFileName);
dprintf("Directory %w\n",Directory);
DPRINT("Directory %w\n",Directory);
End = wcsrchr(Directory, '\\');
*End = 0;
wcscpy(Pattern, End+1);
dprintf("Directory %w Pattern %w\n",Directory,Pattern);
DPRINT("Directory %w Pattern %w\n",Directory,Pattern);
IData = HeapAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY,
@ -151,7 +154,7 @@ HANDLE STDCALL InternalFindFirstFile(LPCWSTR lpFileName,
TRUE,
&(IData->PatternStr),
FALSE);
dprintf("Found %w\n",IData->FileInfo.FileName);
DPRINT("Found %w\n",IData->FileInfo.FileName);
lpFindFileData->dwFileAttributes = IData->FileInfo.FileAttributes;
return(IData);

View file

@ -26,11 +26,16 @@
* Put the type definitions of the heap in a seperate header. Boudewijn Dekker
*/
#include <kernel32/proc.h>
/* INCLUDES *****************************************************************/
#define NDEBUG
#include <kernel32/kernel32.h>
#include <kernel32/proc.h>
#include <kernel32/heap.h>
#include <internal/string.h>
/* GLOBALS ******************************************************************/
static HEAP_BUCKET __HeapDefaultBuckets[]=
{
@ -46,6 +51,8 @@ static HEAP_BUCKET __HeapDefaultBuckets[]=
PHEAP __ProcessHeap = NULL;
/* FUNCTIONS ****************************************************************/
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);
@ -68,7 +75,7 @@ static PHEAP __HeapPrepare(LPVOID base, ULONG minsize, ULONG maxsize,
*********************************************************************/
static BOOL __HeapCommit(PHEAP pheap, LPVOID start, LPVOID end)
{
dprintf("__HeapCommit( 0x%lX, 0x%lX, 0x%lX)\n",
DPRINT("__HeapCommit( 0x%lX, 0x%lX, 0x%lX)\n",
(ULONG) pheap, (ULONG) start, (ULONG) end);
if(end >= pheap->LastBlock)
@ -87,7 +94,7 @@ static BOOL __HeapCommit(PHEAP pheap, LPVOID start, LPVOID end)
*********************************************************************/
static BOOL __HeapDecommit(PHEAP pheap, LPVOID start, LPVOID end)
{
dprintf("__HeapDecommit( 0x%lX, 0x%lX, 0x%lX)\n",
DPRINT("__HeapDecommit( 0x%lX, 0x%lX, 0x%lX)\n",
(ULONG) pheap, (ULONG) start, (ULONG) end);
#ifdef NOT
__VirtualDump();
@ -113,7 +120,7 @@ static LPVOID __HeapAlloc(PHEAP pheap, ULONG flags, ULONG size, ULONG tag)
ULONG freesize;
ULONG allocsize;
dprintf("__HeapAlloc(pheap %x, flags %x, size %d, tag %x)\n",
DPRINT("__HeapAlloc(pheap %x, flags %x, size %d, tag %x)\n",
pheap,flags,size,tag);
pfree=&(pheap->Start);
@ -235,7 +242,7 @@ static LPVOID __HeapReAlloc(PHEAP pheap, ULONG flags, LPVOID pold, DWORD size)
*/
if(size==0)
{
dprintf("__HeapReAlloc: freeing memory\n");
DPRINT("__HeapReAlloc: freeing memory\n");
__HeapFree(pheap, flags, pold);
return NULL;
}
@ -251,7 +258,7 @@ static LPVOID __HeapReAlloc(PHEAP pheap, ULONG flags, LPVOID pold, DWORD size)
#endif
else if(newsize < allocsize )
{
dprintf("__HeapReAlloc: shrinking memory\n");
DPRINT("__HeapReAlloc: shrinking memory\n");
/* free remaining region of memory */
prealloc->Size=size | HEAP_NORMAL_TAG;
pnext=HEAP_NEXT(prealloc);
@ -267,7 +274,7 @@ static LPVOID __HeapReAlloc(PHEAP pheap, ULONG flags, LPVOID pold, DWORD size)
}
else if(newsize == allocsize )
{
dprintf("__HeapReAlloc: no changes\n");
DPRINT("__HeapReAlloc: no changes\n");
/* nothing to do */
prealloc->Size= size | HEAP_NORMAL_TAG;
return pold;
@ -280,7 +287,7 @@ static LPVOID __HeapReAlloc(PHEAP pheap, ULONG flags, LPVOID pold, DWORD size)
if(((LPVOID) pnext< pheap->End)&& HEAP_ISFREE(pnext) &&
(HEAP_SIZE(pnext) + HEAP_ADMIN_SIZE >=newsize-allocsize))
{
dprintf("__HeapReAlloc: joining memory\n");
DPRINT("__HeapReAlloc: joining memory\n");
oldsize=HEAP_SIZE(prealloc);
prealloc->Size=size | HEAP_NORMAL_TAG;
@ -304,7 +311,7 @@ static LPVOID __HeapReAlloc(PHEAP pheap, ULONG flags, LPVOID pold, DWORD size)
{
if((flags&HEAP_REALLOC_IN_PLACE_ONLY)==0)
{
dprintf("__HeapReAlloc: allocating new memory\n");
DPRINT("__HeapReAlloc: allocating new memory\n");
/* alloc a new piece of memory */
oldsize=HEAP_SIZE(prealloc);
pmem=__HeapAlloc(pheap, flags, size, HEAP_NORMAL_TAG);
@ -590,7 +597,7 @@ PHEAP __HeapPrepare(LPVOID base, ULONG minsize, ULONG maxsize, ULONG flags)
{
PHEAP pheap=(PHEAP) base;
dprintf("__HeapPrepare(base %x, minsize %d, maxsize %d, flags %x)\n",
DPRINT("__HeapPrepare(base %x, minsize %d, maxsize %d, flags %x)\n",
base,minsize,maxsize,flags);
pheap->Magic=MAGIC_HEAP;
@ -670,7 +677,7 @@ LPVOID STDCALL HeapAlloc(HANDLE hheap, DWORD flags, DWORD size)
PHEAP pheap=hheap;
LPVOID retval;
aprintf("HeapAlloc( 0x%lX, 0x%lX, 0x%lX )\n",
DPRINT("HeapAlloc( 0x%lX, 0x%lX, 0x%lX )\n",
(ULONG) hheap, flags, (ULONG) size );
#ifdef NOT
HeapValidate(hheap, 0, 0);
@ -686,7 +693,7 @@ LPVOID STDCALL HeapAlloc(HANDLE hheap, DWORD flags, DWORD size)
if( (flags | pheap->Flags) & HEAP_NO_SERIALIZE )
LeaveCriticalSection(&(pheap->Synchronize));
aprintf("HeapAlloc returns 0x%lX\n", (ULONG) retval);
DPRINT("HeapAlloc returns 0x%lX\n", (ULONG) retval);
return retval;
}
@ -700,7 +707,7 @@ LPVOID STDCALL HeapReAlloc(HANDLE hheap, DWORD flags, LPVOID ptr, DWORD size)
PHEAP_BLOCK pfree=((PHEAP_BLOCK)ptr-1);
LPVOID retval;
aprintf("HeapReAlloc( 0x%lX, 0x%lX, 0x%lX, 0x%lX )\n",
DPRINT("HeapReAlloc( 0x%lX, 0x%lX, 0x%lX, 0x%lX )\n",
(ULONG) hheap, flags, (ULONG) ptr, size );
#ifdef NOT
HeapValidate(hheap, 0, 0);
@ -730,7 +737,7 @@ WINBOOL STDCALL HeapFree(HANDLE hheap, DWORD flags, LPVOID ptr)
PHEAP_BLOCK pfree=(PHEAP_BLOCK)((LPVOID)ptr-HEAP_ADMIN_SIZE);
BOOL retval;
aprintf("HeapFree( 0x%lX, 0x%lX, 0x%lX )\n",
DPRINT("HeapFree( 0x%lX, 0x%lX, 0x%lX )\n",
(ULONG) hheap, flags, (ULONG) ptr );
#ifdef NOT
HeapValidate(hheap, 0, 0);
@ -756,7 +763,7 @@ WINBOOL STDCALL HeapFree(HANDLE hheap, DWORD flags, LPVOID ptr)
*********************************************************************/
HANDLE WINAPI GetProcessHeap(VOID)
{
aprintf("GetProcessHeap()\n");
DPRINT("GetProcessHeap()\n");
return (HANDLE) __ProcessHeap;
}
@ -771,7 +778,7 @@ DWORD WINAPI GetProcessHeaps(DWORD maxheaps, PHANDLE phandles )
DWORD retval;
PHEAP pheap;
aprintf("GetProcessHeaps( %u, 0x%lX )\n", maxheaps, (ULONG) phandles );
DPRINT("GetProcessHeaps( %u, 0x%lX )\n", maxheaps, (ULONG) phandles );
pheap= __ProcessHeap;
retval=0;
@ -801,7 +808,7 @@ BOOL WINAPI HeapLock(HANDLE hheap)
{
PHEAP pheap=hheap;
aprintf("HeapLock( 0x%lX )\n", (ULONG) hheap );
DPRINT("HeapLock( 0x%lX )\n", (ULONG) hheap );
EnterCriticalSection(&(pheap->Synchronize));
return TRUE;
@ -815,7 +822,7 @@ BOOL WINAPI HeapUnlock(HANDLE hheap)
{
PHEAP pheap=hheap;
aprintf("HeapUnlock( 0x%lX )\n", (ULONG) hheap );
DPRINT("HeapUnlock( 0x%lX )\n", (ULONG) hheap );
LeaveCriticalSection(&(pheap->Synchronize));
return TRUE;
@ -866,7 +873,7 @@ DWORD WINAPI HeapSize(HANDLE hheap, DWORD flags, LPCVOID pmem)
PHEAP_BLOCK palloc=((PHEAP_BLOCK)pmem-1);
DWORD retval=0;
aprintf("HeapSize( 0x%lX, 0x%lX, 0x%lX )\n",
DPRINT("HeapSize( 0x%lX, 0x%lX, 0x%lX )\n",
(ULONG) hheap, flags, (ULONG) pmem );
if(pheap->Magic!=MAGIC_HEAP)
@ -924,7 +931,7 @@ BOOL WINAPI HeapValidate(HANDLE hheap, DWORD flags, LPCVOID pmem)
pnext=HEAP_NEXT(pcheck);
if((pprev)&&(HEAP_PREV(pcheck)!=pprev))
{
dprintf("HeapValidate: linked list invalid, region 0x%lX,"
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;
@ -948,13 +955,13 @@ BOOL WINAPI HeapValidate(HANDLE hheap, DWORD flags, LPCVOID pmem)
pnextfrag=(PHEAP_FRAGMENT)((LPVOID)pfrag+add);
if(pfrag->Magic!=HEAP_FRAG_MAGIC)
{
dprintf("HeapValidate: fragment %d magic invalid, region 0x%lX,"
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)
{
dprintf("HeapValidate: fragment %d number invalid, region 0x%lX,"
DPRINT("HeapValidate: fragment %d number invalid, region 0x%lX,"
" previous region 0x%lX\n", i, (ULONG)pcheck, (ULONG)pprev);
return FALSE;
}
@ -962,7 +969,7 @@ BOOL WINAPI HeapValidate(HANDLE hheap, DWORD flags, LPCVOID pmem)
number++;
if(pfrag->Sub!=psub)
{
dprintf("HeapValidate: fragment %d suballoc invalid, region 0x%lX,"
DPRINT("HeapValidate: fragment %d suballoc invalid, region 0x%lX,"
" previous region 0x%lX\n", i, (ULONG)pcheck, (ULONG)pprev);
return FALSE;
}
@ -971,11 +978,11 @@ BOOL WINAPI HeapValidate(HANDLE hheap, DWORD flags, LPCVOID pmem)
}
if(number!=psub->NumberFree)
{
dprintf("HeapValidate: invalid number of free fragments, region 0x%lX,"
DPRINT("HeapValidate: invalid number of free fragments, region 0x%lX,"
" previous region 0x%lX\n", (ULONG)pcheck, (ULONG)pprev);
return FALSE;
}
dprintf("HeapValidate: [0x%08lX-0x%08lX] suballocated,"
DPRINT("HeapValidate: [0x%08lX-0x%08lX] suballocated,"
" bucket size=%d, bitmap=0x%08lX\n",
(ULONG) pcheck, (ULONG) pnext, pbucket->Size, psub->Bitmap);
}
@ -983,22 +990,22 @@ BOOL WINAPI HeapValidate(HANDLE hheap, DWORD flags, LPCVOID pmem)
{
if(HEAP_RSIZE(pcheck)!=HEAP_SIZE(pcheck))
{
dprintf("HeapValidate: invalid size of free region 0x%lX,"
DPRINT("HeapValidate: invalid size of free region 0x%lX,"
" previous region 0x%lX\n",
(ULONG) pcheck, (ULONG) pprev);
return FALSE;
}
dprintf("HeapValidate: [0x%08lX-0x%08lX] free\n",
DPRINT("HeapValidate: [0x%08lX-0x%08lX] free\n",
(ULONG) pcheck, (ULONG) pnext );
}
else if(HEAP_ISNORMAL(pcheck))
{
dprintf("HeapValidate: [0x%08lX-0x%08lX] allocated\n",
DPRINT("HeapValidate: [0x%08lX-0x%08lX] allocated\n",
(ULONG) pcheck, (ULONG) pnext );
}
else
{
dprintf("HeapValidate: invalid tag %x, region 0x%lX,"
DPRINT("HeapValidate: invalid tag %x, region 0x%lX,"
" previous region 0x%lX\n", pcheck->Size>>28,
(ULONG)pcheck, (ULONG)pprev);
return FALSE;

View file

@ -1,11 +1,13 @@
#include <windows.h>
#define NDEBUG
#include <kernel32/kernel32.h>
VOID CopyMemory(PVOID Destination, CONST VOID* Source, DWORD Length)
{
DWORD i;
dprintf("CopyMemory(Destination %x, Source %x, Length %d)\n",
DPRINT("CopyMemory(Destination %x, Source %x, Length %d)\n",
Destination,Source,Length);
for (i=0; i<Length; i++)

View file

@ -584,19 +584,9 @@ FlushInstructionCache(
return TRUE;
}
VOID
STDCALL
ExitProcess(
UINT uExitCode
)
VOID STDCALL ExitProcess(UINT uExitCode)
{
NtTerminateProcess(
NtCurrentProcess() ,
uExitCode
);
NtTerminateProcess(NtCurrentProcess() ,uExitCode);
}
VOID

View file

@ -172,33 +172,33 @@ WaitForSingleObject(
return WaitForSingleObjectEx(hHandle,dwMilliseconds,FALSE);
}
DWORD
STDCALL
WaitForSingleObjectEx(
HANDLE hHandle,
DWORD STDCALL WaitForSingleObjectEx(HANDLE hHandle,
DWORD dwMilliseconds,
BOOL bAlertable
)
BOOL bAlertable)
{
NTSTATUS errCode;
PLARGE_INTEGER TimePtr;
LARGE_INTEGER Time;
DWORD retCode;
if (dwMilliseconds == INFINITE)
{
TimePtr = NULL;
}
else
{
SET_LARGE_INTEGER_LOW_PART(Time,dwMilliseconds);
TimePtr = &Time;
}
errCode = NtWaitForSingleObject(
hHandle,
errCode = NtWaitForSingleObject(hHandle,
(BOOLEAN) bAlertable,
&Time
);
TimePtr);
retCode = RtlNtStatusToDosError(errCode);
SetLastError(retCode);
return retCode;
}
DWORD

View file

@ -257,16 +257,22 @@ asmlinkage void exception_handler(unsigned int edi,
VOID KeDumpStackFrames(ULONG DummyArg)
{
PULONG Stack = ((PULONG)&DummyArg)[-1];
PULONG Stack = &((&DummyArg)[-1]);
ULONG i;
Stack = (PVOID)(((ULONG)Stack) & (~0x3));
DbgPrint("Frames:\n");
for (i=0; i<32; i++)
for (i=0; i<1024; i++)
{
if (Stack[i] > KERNEL_BASE)
if (Stack[i] > KERNEL_BASE && Stack[i] < ((ULONG)&etext))
{
DbgPrint("%.8x ",Stack[i]);
}
if (Stack[i] == 0xceafbeef)
{
DbgPrint("IRQ ");
}
}
DbgPrint("\n");
}

View file

@ -19,6 +19,9 @@ _irq_handler_%1:
push ds
push es
mov eax,0xceafbeef
push eax
;
; Load DS
;
@ -45,6 +48,9 @@ _irq_handler_%1:
; Restore stack, registers and return to interrupted routine
;
pop eax
pop eax
pop es
pop ds
popa
@ -59,12 +65,17 @@ _irq_handler_%1:
;
pusha
push ds
push es
mov eax,0xceafbeef
push eax
;
; Load DS
;
mov ax,KERNEL_DS
mov ds,ax
mov es,ax
;
; Mask the related vector at the PIC
@ -83,6 +94,10 @@ _irq_handler_%1:
; Restore stack, registers and return to the interrupted routine
;
pop eax
pop eax
pop es
pop ds
popa
iret

View file

@ -3,7 +3,7 @@
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/io/create.c
* PURPOSE: Handling file create/open apis
* PROGRAMMER: David Welch (welch@mcmail.com)
* PROGRAMMER: David Welch (welch@cwcom.net)
* UPDATE HISTORY:
* 24/05/98: Created
*/
@ -117,6 +117,7 @@ NTSTATUS ZwCreateFile(PHANDLE FileHandle,
if (Status != STATUS_SUCCESS && Status != STATUS_FS_QUERY_REQUIRED)
{
DPRINT("%s() = Failed to find object\n",__FUNCTION__);
ObDereferenceObject(FileObject);
ZwClose(*FileHandle);
*FileHandle=0;
return(STATUS_UNSUCCESSFUL);
@ -134,7 +135,7 @@ NTSTATUS ZwCreateFile(PHANDLE FileHandle,
FileObject->Flags = FileObject->Flags | FO_DIRECT_DEVICE_OPEN;
FileObject->FileName.Buffer = ExAllocatePool(NonPagedPool,
ObjectAttributes->ObjectName->Length);
FileObject->FileName.Length = ObjectAttributes->Length;
FileObject->FileName.Length = ObjectAttributes->ObjectName->Length;
RtlCopyUnicodeString(&(FileObject->FileName),
ObjectAttributes->ObjectName);
}
@ -146,7 +147,7 @@ NTSTATUS ZwCreateFile(PHANDLE FileHandle,
if (DeviceObject->DeviceType != FILE_DEVICE_FILE_SYSTEM &&
DeviceObject->DeviceType != FILE_DEVICE_DISK)
{
CHECKPOINT;
ObDereferenceObject(FileObject);
ZwClose(*FileHandle);
*FileHandle=0;
return(STATUS_UNSUCCESSFUL);
@ -158,7 +159,7 @@ NTSTATUS ZwCreateFile(PHANDLE FileHandle,
Status = IoTryToMountStorageDevice(DeviceObject);
if (Status!=STATUS_SUCCESS)
{
CHECKPOINT;
ObDereferenceObject(FileObject);
ZwClose(*FileHandle);
*FileHandle=0;
return(Status);
@ -167,13 +168,13 @@ NTSTATUS ZwCreateFile(PHANDLE FileHandle,
}
DPRINT("Remainder %x\n",Remainder);
DPRINT("Remainder %w\n",Remainder);
FileObject->FileName.Buffer = ExAllocatePool(NonPagedPool,
wstrlen(Remainder));
RtlInitUnicodeString(&(FileObject->FileName),Remainder);
DPRINT("FileObject->FileName.Buffer %w\n",FileObject->FileName.Buffer);
RtlInitUnicodeString(&(FileObject->FileName),wstrdup(Remainder));
DPRINT("FileObject->FileName.Buffer %x %w\n",
FileObject->FileName.Buffer,FileObject->FileName.Buffer);
}
CHECKPOINT;
DPRINT("FileObject->FileName.Buffer %x\n",FileObject->FileName.Buffer);
if (CreateOptions & FILE_SYNCHRONOUS_IO_ALERT)
{
@ -194,6 +195,8 @@ NTSTATUS ZwCreateFile(PHANDLE FileHandle,
Irp = IoAllocateIrp(DeviceObject->StackSize, FALSE);
if (Irp==NULL)
{
ExFreePool(FileObject->FileName.Buffer);
ObDereferenceObject(FileObject);
ZwClose(*FileHandle);
*FileHandle=0;
return(STATUS_UNSUCCESSFUL);
@ -215,6 +218,9 @@ NTSTATUS ZwCreateFile(PHANDLE FileHandle,
if (Status!=STATUS_SUCCESS)
{
DPRINT("FileObject->FileName.Buffer %x\n",FileObject->FileName.Buffer);
ExFreePool(FileObject->FileName.Buffer);
ObDereferenceObject(FileObject);
ZwClose(*FileHandle);
*FileHandle=0;
}

View file

@ -58,6 +58,8 @@ NTSTATUS ZwReadFile(HANDLE FileHandle,
PIO_STACK_LOCATION StackPtr;
KEVENT Event;
assert(KeGetCurrentIrql()==PASSIVE_LEVEL);
DPRINT("ZwReadFile(FileHandle %x Buffer %x Length %x ByteOffset %x, "
"IoStatusBlock %x)\n",
FileHandle,Buffer,Length,ByteOffset,IoStatusBlock);
@ -70,6 +72,8 @@ NTSTATUS ZwReadFile(HANDLE FileHandle,
NULL);
if (Status != STATUS_SUCCESS)
{
DPRINT("ZwReadFile() =");
DbgPrintErrorMessage(Status);
return(Status);
}
assert(FileObject != NULL);

View file

@ -33,7 +33,8 @@ NTSTATUS IoInitializeTimer(PDEVICE_OBJECT DeviceObject,
{
DeviceObject->Timer = ExAllocatePool(NonPagedPool,sizeof(IO_TIMER));
KeInitializeTimer(&(DeviceObject->Timer->timer));
KeInitializeDpc(&(DeviceObject->Timer->dpc),(PKDEFERRED_ROUTINE)TimerRoutine,Context);
KeInitializeDpc(&(DeviceObject->Timer->dpc),
(PKDEFERRED_ROUTINE)TimerRoutine,Context);
return(STATUS_SUCCESS);
}

View file

@ -20,8 +20,11 @@ VOID KiDispatchInterrupt(ULONG irq)
* FUNCTION: Called after an irq when the interrupted processor was at a lower
* level than DISPATCH_LEVEL
*/
{
if (irq == 0)
{
KeExpireTimers();
}
KeDrainDpcQueue();
PsDispatchThread();
}

View file

@ -55,6 +55,8 @@ void KeDrainDpcQueue(void)
PKDPC current;
KIRQL oldlvl;
DPRINT("KeDrainDpcQueue()\n");
KeAcquireSpinLockAtDpcLevel(&DpcQueueLock);
KeRaiseIrql(HIGH_LEVEL,&oldlvl);
current_entry = RemoveHeadList(&DpcQueueHead);

View file

@ -146,15 +146,19 @@ NTSTATUS STDCALL ZwQueryPerformanceCounter(IN PLARGE_INTEGER Counter,
}
NTSTATUS
KeAddThreadTimeout(PKTHREAD Thread, PLARGE_INTEGER Interval)
NTSTATUS KeAddThreadTimeout(PKTHREAD Thread, PLARGE_INTEGER Interval)
{
assert(Thread != NULL);
assert(Interval != NULL);
DPRINT("KeAddThreadTimeout(Thread %x, Interval %x)\n",Thread,Interval);
KeInitializeTimer(&(Thread->TimerBlock));
KeSetTimer(&(Thread->TimerBlock),*Interval,NULL);
DPRINT("Thread->TimerBlock.entry.Flink %x\n",
Thread->TimerBlock.entry.Flink);
return STATUS_SUCCESS;
}
@ -327,6 +331,8 @@ BOOLEAN KeSetTimerEx(PKTIMER Timer, LARGE_INTEGER DueTime, LONG Period,
{
KIRQL oldlvl;
DPRINT("KeSetTimerEx(Timer %x)\n",Timer);
KeAcquireSpinLock(&timer_list_lock,&oldlvl);
Timer->dpc=Dpc;
@ -346,9 +352,11 @@ BOOLEAN KeSetTimerEx(PKTIMER Timer, LARGE_INTEGER DueTime, LONG Period,
if (Timer->running)
{
KeReleaseSpinLock(&timer_list_lock,oldlvl);
return TRUE;
}
DPRINT("Inserting %x in list\n",&Timer->entry);
DPRINT("Timer->entry.Flink %x\n",Timer->entry.Flink);
Timer->running=TRUE;
InsertTailList(&timer_list_head,&Timer->entry);
KeReleaseSpinLock(&timer_list_lock,oldlvl);
@ -366,13 +374,17 @@ BOOLEAN KeCancelTimer(PKTIMER Timer)
{
KIRQL oldlvl;
DPRINT("KeCancelTimer(Timer %x)\n",Timer);
KeAcquireSpinLock(&timer_list_lock,&oldlvl);
if (!Timer->running)
{
KeReleaseSpinLock(&timer_list_lock,oldlvl);
return FALSE;
}
RemoveEntryList(&Timer->entry);
Timer->running = FALSE;
KeReleaseSpinLock(&timer_list_lock,oldlvl);
return TRUE;
@ -423,6 +435,7 @@ VOID KeQueryTickCount(PLARGE_INTEGER TickCount)
static void HandleExpiredTimer(PKTIMER current)
{
DPRINT("HandleExpiredTime(current %x)\n",current);
if (current->dpc!=NULL)
{
DPRINT("current->dpc->DeferredRoutine %x\n",
@ -431,6 +444,7 @@ static void HandleExpiredTimer(PKTIMER current)
current->dpc->DeferredContext,
current->dpc->SystemArgument1,
current->dpc->SystemArgument2);
DPRINT("Finished dpc routine\n");
}
current->signaled=TRUE;
if (current->period != 0)
@ -456,6 +470,12 @@ void KeExpireTimers(void)
PKTIMER current = CONTAINING_RECORD(current_entry,KTIMER,entry);
KIRQL oldlvl;
DPRINT("KeExpireTimers()\n");
DPRINT("&timer_list_head %x\n",&timer_list_head);
DPRINT("current_entry %x\n",current_entry);
DPRINT("current_entry->Flink %x\n",current_entry->Flink);
DPRINT("current_entry->Flink->Flink %x\n",current_entry->Flink->Flink);
KeAcquireSpinLock(&timer_list_lock,&oldlvl);
while (current_entry!=(&timer_list_head))
@ -469,6 +489,7 @@ void KeExpireTimers(void)
current = CONTAINING_RECORD(current_entry,KTIMER,entry);
}
KeReleaseSpinLock(&timer_list_lock,oldlvl);
DPRINT("Finished KeExpireTimers()\n");
}
extern unsigned int nr_used_blocks;
@ -511,8 +532,9 @@ BOOLEAN KiTimerInterrupt(VOID)
}
// sprintf(str,"%.8u %.8u",EiFreeNonPagedPool,ticks);
memset(str, 0, sizeof(str));
sprintf(str,"%.8u %.8u",EiNrUsedBlocks,KiTimerTicks);
// sprintf(str,"%.8u %.8u",EiNrUsedBlocks,KiTimerTicks);
// sprintf(str,"%.8u %.8u",EiFreeNonPagedPool,EiUsedNonPagedPool);
sprintf(str,"%.8u %.8u",PiNrThreads,KiTimerTicks);
for (i=0;i<17;i++)
{
*vidmem=str[i];

View file

@ -176,6 +176,11 @@ NTSTATUS KeWaitForSingleObject(PVOID Object,
// hdr->WaitListHead.Flink,hdr->WaitListHead.Blink);
KeReleaseDispatcherDatabaseLock(FALSE);
PsSuspendThread(PsGetCurrentThread());
if (Timeout!=NULL)
{
KeCancelTimer(&KeGetCurrentThread()->TimerBlock);
}
return(STATUS_SUCCESS);
}

View file

@ -28,7 +28,7 @@
#include <ddk/ntddk.h>
#if 1
#if 0
#define VALIDATE_POOL validate_kernel_pool()
#else
#define VALIDATE_POOL
@ -99,7 +99,8 @@ static void validate_free_list(void)
if (current->magic != BLOCK_HDR_MAGIC)
{
DbgPrint("Bad block magic (probable pool corruption)\n");
DbgPrint("Bad block magic (probable pool corruption) at %x\n",
current);
KeBugCheck(KBUG_POOL_FREE_LIST_CORRUPT);
}
@ -146,7 +147,8 @@ static void validate_used_list(void)
if (current->magic != BLOCK_HDR_MAGIC)
{
DbgPrint("Bad block magic (probable pool corruption)\n");
DbgPrint("Bad block magic (probable pool corruption) at %x\n",
current);
KeBugCheck(KBUG_POOL_FREE_LIST_CORRUPT);
}
if (base_addr < (kernel_pool_base) ||
@ -189,7 +191,8 @@ static void check_duplicates(block_hdr* blk)
{
if (current->magic != BLOCK_HDR_MAGIC)
{
DbgPrint("Bad block magic (probable pool corruption)\n");
DbgPrint("Bad block magic (probable pool corruption) at %x\n",
current);
KeBugCheck(KBUG_POOL_FREE_LIST_CORRUPT);
}
@ -538,8 +541,8 @@ asmlinkage VOID ExFreePool(PVOID block)
if (blk->magic != BLOCK_HDR_MAGIC)
{
DbgPrint("ExFreePool of non-allocated address\n");
for(;;);
DbgPrint("ExFreePool of non-allocated address %x\n",block);
KeBugCheck(0);
return;
}
@ -622,7 +625,8 @@ PVOID ExAllocateNonPagedPoolWithTag(ULONG type, ULONG size, ULONG Tag)
current->next);
if (current->magic != BLOCK_HDR_MAGIC)
{
DbgPrint("Bad block magic (probable pool corruption)\n");
DbgPrint("Bad block magic (probable pool corruption) at %x\n",
current);
KeBugCheck(KBUG_POOL_FREE_LIST_CORRUPT);
}
if (current->size>=size)

View file

@ -95,6 +95,9 @@ PVOID ObGenericCreateObject(PHANDLE Handle,
ACCESS_MASK DesiredAccess,
POBJECT_ATTRIBUTES ObjectAttributes,
POBJECT_TYPE Type)
/*
* FUNCTION: Creates a new object
*/
{
POBJECT_HEADER hdr = NULL;
PWSTR path;
@ -206,13 +209,12 @@ VOID ObInitializeObjectHeader(POBJECT_TYPE Type, PWSTR name,
*/
{
PWSTR temp_name;
extern unsigned long long ticks;
DPRINT("ObInitializeObjectHeader(id %x name %w obj %x)\n",Type,
name,ObjectHeader);
ObjectHeader->HandleCount = 0;
ObjectHeader->RefCount = 0;
ObjectHeader->HandleCount = 1;
ObjectHeader->RefCount = 1;
ObjectHeader->ObjectType = Type;
ObjectHeader->Permanent = FALSE;
if (name==NULL)

View file

@ -12,6 +12,7 @@
#include <ddk/ntddk.h>
#define NDEBUG
#include <internal/debug.h>
/* GLOBALS *******************************************************************/
@ -27,7 +28,7 @@ static VOID PsIdleThreadMain(PVOID Context)
for(;;)
{
// DbgPrint("Idling.... ");
DPRINT("Idling.... DpcQueueSize %d\n",DpcQueueSize);
if (DpcQueueSize > 0)
{
KeRaiseIrql(DISPATCH_LEVEL,&oldlvl);

View file

@ -22,6 +22,45 @@ extern ULONG PiNrThreads;
/* FUNCTIONS *****************************************************************/
NTSTATUS STDCALL NtTerminateProcess(IN HANDLE ProcessHandle,
IN NTSTATUS ExitStatus)
{
return(ZwTerminateProcess(ProcessHandle,ExitStatus));
}
NTSTATUS STDCALL ZwTerminateProcess(IN HANDLE ProcessHandle,
IN NTSTATUS ExitStatus)
{
PETHREAD Thread;
NTSTATUS Status;
PEPROCESS Process;
KIRQL oldlvl;
Status = ObReferenceObjectByHandle(ProcessHandle,
PROCESS_TERMINATE,
PsProcessType,
UserMode,
(PVOID*)&Process,
NULL);
if (Status != STATUS_SUCCESS)
{
return(Status);
}
PiTerminateProcessThreads(Process, ExitStatus);
KeRaiseIrql(DISPATCH_LEVEL, &oldlvl);
KeDispatcherObjectWakeAll(&Process->Pcb.DispatcherHeader);
Process->Pcb.ProcessState = PROCESS_STATE_TERMINATED;
if (PsGetCurrentThread()->ThreadsProcess == Process)
{
KeLowerIrql(oldlvl);
PsTerminateSystemThread(ExitStatus);
}
KeLowerIrql(oldlvl);
return(STATUS_SUCCESS);
}
NTSTATUS STDCALL NtTerminateThread(IN HANDLE ThreadHandle,
IN NTSTATUS ExitStatus)
{
@ -45,6 +84,11 @@ NTSTATUS STDCALL ZwTerminateThread(IN HANDLE ThreadHandle,
return(Status);
}
PsTerminateThread(Thread);
}
VOID PsTerminateThread(PETHREAD Thread, NTSTATUS ExitStatus)
{
if (Thread == PsGetCurrentThread())
{
PsTerminateSystemThread(ExitStatus);

View file

@ -205,23 +205,12 @@ NTSTATUS STDCALL ZwCreateProcess(
return(STATUS_UNSUCCESSFUL);
}
Process->Pcb.ProcessState = PROCESS_STATE_ACTIVE;
return(STATUS_SUCCESS);
}
NTSTATUS STDCALL NtTerminateProcess(IN HANDLE ProcessHandle,
IN NTSTATUS ExitStatus)
{
return(ZwTerminateProcess(ProcessHandle,ExitStatus));
}
NTSTATUS STDCALL ZwTerminateProcess(IN HANDLE ProcessHandle,
IN NTSTATUS ExitStatus)
{
UNIMPLEMENTED;
}
NTSTATUS STDCALL NtOpenProcess (OUT PHANDLE ProcessHandle,
IN ACCESS_MASK DesiredAccess,
IN POBJECT_ATTRIBUTES ObjectAttributes,
@ -241,8 +230,7 @@ NTSTATUS STDCALL ZwOpenProcess (OUT PHANDLE ProcessHandle,
UNIMPLEMENTED;
}
NTSTATUS STDCALL NtQueryInformationProcess(
IN HANDLE ProcessHandle,
NTSTATUS STDCALL NtQueryInformationProcess(IN HANDLE ProcessHandle,
IN CINT ProcessInformationClass,
OUT PVOID ProcessInformation,
IN ULONG ProcessInformationLength,
@ -255,8 +243,7 @@ NTSTATUS STDCALL NtQueryInformationProcess(
ReturnLength));
}
NTSTATUS STDCALL ZwQueryInformationProcess(
IN HANDLE ProcessHandle,
NTSTATUS STDCALL ZwQueryInformationProcess(IN HANDLE ProcessHandle,
IN CINT ProcessInformationClass,
OUT PVOID ProcessInformation,
IN ULONG ProcessInformationLength,
@ -305,14 +292,10 @@ NTSTATUS STDCALL ZwQueryInformationProcess(
return(Status);
}
NTSTATUS
STDCALL
NtSetInformationProcess(
IN HANDLE ProcessHandle,
NTSTATUS STDCALL NtSetInformationProcess(IN HANDLE ProcessHandle,
IN CINT ProcessInformationClass,
IN PVOID ProcessInformation,
IN ULONG ProcessInformationLength
)
IN ULONG ProcessInformationLength)
{
return(ZwSetInformationProcess(ProcessHandle,
ProcessInformationClass,
@ -320,14 +303,10 @@ NtSetInformationProcess(
ProcessInformationLength));
}
NTSTATUS
STDCALL
ZwSetInformationProcess(
IN HANDLE ProcessHandle,
NTSTATUS STDCALL ZwSetInformationProcess(IN HANDLE ProcessHandle,
IN CINT ProcessInformationClass,
IN PVOID ProcessInformation,
IN ULONG ProcessInformationLength
)
IN ULONG ProcessInformationLength)
{
UNIMPLEMENTED;
}

View file

@ -46,6 +46,7 @@ static KSPIN_LOCK ThreadListLock = {0,};
static LIST_ENTRY PriorityListHead[NR_THREAD_PRIORITY_LEVELS]={{NULL,NULL},};
static BOOLEAN DoneInitYet = FALSE;
ULONG PiNrThreads = 0;
ULONG PiNrRunnableThreads = 0;
static PETHREAD CurrentThread = NULL;
@ -63,6 +64,33 @@ PETHREAD PsGetCurrentThread(VOID)
return((PETHREAD)KeGetCurrentThread());
}
VOID PiTerminateProcessThreads(PEPROCESS Process, NTSTATUS ExitStatus)
{
KIRQL oldlvl;
PLIST_ENTRY current_entry;
PETHREAD current;
ULONG i;
KeAcquireSpinLock(&ThreadListLock, &oldlvl);
for (i=0; i<NR_THREAD_PRIORITY_LEVELS; i++)
{
current_entry = PriorityListHead[i].Flink;
while (current_entry != &PriorityListHead[i])
{
current = CONTAINING_RECORD(current_entry,ETHREAD,Tcb.Entry);
if (current->ThreadsProcess == Process &&
current != PsGetCurrentThread())
{
PsTerminateThread(current, ExitStatus);
}
current_entry = current_entry->Flink;
}
}
KeReleaseSpinLock(&ThreadListLock, oldlvl);
}
static VOID PsInsertIntoThreadList(KPRIORITY Priority, PETHREAD Thread)
{
KIRQL oldlvl;
@ -148,7 +176,7 @@ VOID PsDispatchThread(VOID)
Candidate = PsScanThreadList(CurrentPriority);
if (Candidate == CurrentThread)
{
// DbgPrint("Scheduling current thread\n");
DPRINT("Scheduling current thread\n");
KeQueryTickCount(&TickCount);
CurrentThread->Tcb.LastTick = GET_LARGE_INTEGER_LOW_PART(TickCount);
CurrentThread->Tcb.ThreadState = THREAD_STATE_RUNNING;
@ -157,7 +185,7 @@ VOID PsDispatchThread(VOID)
}
if (Candidate != NULL)
{
// DbgPrint("Scheduling %x\n",Candidate);
DPRINT("Scheduling %x\n",Candidate);
Candidate->Tcb.ThreadState = THREAD_STATE_RUNNING;
@ -171,6 +199,8 @@ VOID PsDispatchThread(VOID)
return;
}
}
DbgPrint("CRITICAL: No threads are runnable\n");
KeBugCheck(0);
}
NTSTATUS PsInitializeThread(HANDLE ProcessHandle,
@ -207,6 +237,7 @@ NTSTATUS PsInitializeThread(HANDLE ProcessHandle,
NULL);
if (Status != STATUS_SUCCESS)
{
DPRINT("Failed at %s:%d\n",__FILE__,__LINE__);
return(Status);
}
}

View file

@ -14,12 +14,22 @@
#include <ddk/ntddk.h>
#include <wstring.h>
#define NDEBUG
#include <internal/debug.h>
wchar_t * ___wcstok = NULL;
/* FUNCTIONS *****************************************************************/
wchar_t* wstrdup(const wchar_t* src)
{
wchar_t* dest;
dest = ExAllocatePool(NonPagedPool, (wstrlen(src)+1)*2);
wcscpy(dest,src);
return(dest);
}
wchar_t *
wcscat(wchar_t *dest, const wchar_t *src)
{
@ -86,13 +96,14 @@ int wcscmp(const wchar_t *cs, const wchar_t *ct)
wchar_t* wcscpy(wchar_t* str1, const wchar_t* str2)
{
wchar_t* s = str1;
DbgPrint("wcscpy(str1 %w, str2 %w)\n",str1,str2);
DPRINT("wcscpy(str1 %w, str2 %w)\n",str1,str2);
while ((*str2)!=0)
{
*s = *str2;
s++;
str2++;
}
*s = 0;
return(str1);
}