mirror of
https://github.com/reactos/reactos.git
synced 2024-06-30 01:42:30 +00:00
Fixed several bugs
Commented out code that wouldn't compile in lib/crtdll Began removed memory and file leaks svn path=/trunk/; revision=170
This commit is contained in:
parent
73d2af04d9
commit
c2059de8af
|
@ -1274,8 +1274,8 @@ NTSTATUS FsdCreate(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
|||
Stack = IoGetCurrentIrpStackLocation(Irp);
|
||||
RequestedDisposition = ((Stack->Parameters.Create.Options>>24)&0xff);
|
||||
RequestedOptions=Stack->Parameters.Create.Options&FILE_VALID_OPTION_FLAGS;
|
||||
DbgPrint("CROptions=%x\n",Stack->Parameters.Create.Options);
|
||||
DbgPrint("REquestedOptions=%x\n",RequestedOptions);
|
||||
DPRINT("CROptions=%x\n",Stack->Parameters.Create.Options);
|
||||
DPRINT("REquestedOptions=%x\n",RequestedOptions);
|
||||
FileObject = Stack->FileObject;
|
||||
DeviceExt = DeviceObject->DeviceExtension;
|
||||
Status = FsdOpenFile(DeviceExt,FileObject,FileObject->FileName.Buffer);
|
||||
|
@ -1285,7 +1285,7 @@ DbgPrint("REquestedOptions=%x\n",RequestedOptions);
|
|||
||RequestedDisposition==FILE_OPEN_IF
|
||||
||RequestedDisposition==FILE_OVERWRITE_IF)
|
||||
{
|
||||
DbgPrint("try to create file\n");
|
||||
DPRINT("try to create file\n");
|
||||
Status=addEntry(DeviceExt,FileObject,RequestedOptions);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ typedef struct _OBJECT_TYPE
|
|||
/*
|
||||
* PURPOSE: Called to close an object if OkayToClose returns true
|
||||
*/
|
||||
VOID (*Close)(VOID);
|
||||
VOID (*Close)(PVOID ObjectBody);
|
||||
|
||||
/*
|
||||
* PURPOSE: Called to close an object if OkayToClose returns true
|
||||
|
@ -91,15 +91,15 @@ typedef struct _OBJECT_TYPE
|
|||
} OBJECT_TYPE, *POBJECT_TYPE;
|
||||
|
||||
|
||||
typedef struct _OBJECT
|
||||
typedef struct _OBJECT_HEADER
|
||||
/*
|
||||
* PURPOSE: Header for every object managed by the object manager
|
||||
*/
|
||||
{
|
||||
UNICODE_STRING Name;
|
||||
LIST_ENTRY Entry;
|
||||
ULONG RefCount;
|
||||
ULONG HandleCount;
|
||||
LONG RefCount;
|
||||
LONG HandleCount;
|
||||
BOOLEAN Permanent;
|
||||
struct _DIRECTORY_OBJECT* Parent;
|
||||
POBJECT_TYPE ObjectType;
|
||||
|
|
|
@ -47,6 +47,9 @@ typedef struct
|
|||
unsigned short iomap_base;
|
||||
|
||||
unsigned short nr;
|
||||
PVOID KernelStackBase;
|
||||
PVOID SavedKernelEsp;
|
||||
PVOID SavedKernelStackBase;
|
||||
|
||||
unsigned char io_bitmap[1];
|
||||
} hal_thread_state;
|
||||
|
|
|
@ -50,7 +50,7 @@ typedef unsigned long long u64;
|
|||
#endif
|
||||
|
||||
|
||||
typedef unsigned int size_t;
|
||||
typedef int size_t;
|
||||
typedef size_t __kernel_size_t;
|
||||
|
||||
#endif /* _LINUX_TYPES_H */
|
||||
|
|
|
@ -17,9 +17,9 @@
|
|||
; DISCLAMED. This includes but is not limited to warrenties of
|
||||
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
;
|
||||
; $Revision: 1.1 $
|
||||
; $Revision: 1.2 $
|
||||
; $Author: dwelch $
|
||||
; $Date: 1999/01/04 23:01:18 $
|
||||
; $Date: 1999/01/16 21:02:58 $
|
||||
;
|
||||
; 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.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include <io.h>
|
||||
#include <windows.h>
|
||||
#include <libc/file.h>
|
||||
//#include <libc/file.h>
|
||||
|
||||
|
||||
int close(int _fd)
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#include <windows.h>
|
||||
#include <io.h>
|
||||
#include <string.h>
|
||||
#include <libc/file.h>
|
||||
|
||||
#if 0
|
||||
|
||||
//UnixTimeToFileTime
|
||||
//FileTimeToUnixTime
|
||||
|
@ -251,3 +252,4 @@ time_t FileTimeToUnixTime( const FILETIME *filetime, DWORD *remainder )
|
|||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include <windows.h>
|
||||
#include <io.h>
|
||||
#include <libc/file.h>
|
||||
//#include <libc/file.h>
|
||||
|
||||
#undef lseek
|
||||
long lseek(int _fildes, long _offset, int _whence)
|
||||
|
|
|
@ -12,10 +12,12 @@
|
|||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <stdlib.h>
|
||||
#include <libc/file.h>
|
||||
//#include <libc/file.h>
|
||||
#include <string.h>
|
||||
#include <share.h>
|
||||
|
||||
#if 0
|
||||
|
||||
typedef struct _fileno_modes_type
|
||||
{
|
||||
HANDLE hFile;
|
||||
|
@ -252,3 +254,4 @@ int _open_osfhandle (void *osfhandle, int flags )
|
|||
{
|
||||
return __fileno_alloc((HANDLE)osfhandle, flags);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
*/
|
||||
#include <io.h>
|
||||
#include <windows.h>
|
||||
#include <libc/file.h>
|
||||
|
||||
int write(int _fd, const void *_buf,int _nbyte)
|
||||
{
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <windows.h>
|
||||
#include <libc/file.h>
|
||||
//#include <libc/file.h>
|
||||
|
||||
void UnixTimeToFileTime( time_t unix_time, FILETIME *filetime, DWORD remainder );
|
||||
time_t FileTimeToUnixTime( const FILETIME *filetime, DWORD *remainder );
|
||||
|
|
|
@ -18,6 +18,9 @@
|
|||
#include <ddk/li.h>
|
||||
#include <ddk/rtl.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <kernel32/kernel32.h>
|
||||
|
||||
HANDLE STDCALL CreateFileA(LPCSTR lpFileName,
|
||||
DWORD dwDesiredAccess,
|
||||
DWORD dwShareMode,
|
||||
|
@ -141,7 +144,7 @@ HANDLE STDCALL CreateFileW(LPCWSTR lpFileName,
|
|||
NULL,
|
||||
0);
|
||||
|
||||
dprintf("After create file");
|
||||
DPRINT("After create file\n");
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
SetLastError(RtlNtStatusToDosError(Status));
|
||||
|
|
|
@ -13,14 +13,15 @@
|
|||
|
||||
#include <windows.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <kernel32/kernel32.h>
|
||||
|
||||
/* GLOBALS *******************************************************************/
|
||||
|
||||
|
||||
WCHAR CurrentDirectoryW[MAX_PATH] = {0,};
|
||||
|
||||
WCHAR SystemDirectoryW[MAX_PATH];
|
||||
|
||||
WCHAR WindowsDirectoryW[MAX_PATH];
|
||||
static WCHAR CurrentDirectoryW[MAX_PATH] = {0,};
|
||||
static WCHAR SystemDirectoryW[MAX_PATH];
|
||||
static WCHAR WindowsDirectoryW[MAX_PATH];
|
||||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
|
@ -46,7 +47,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 +55,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 +64,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,7 +78,7 @@ BOOL STDCALL SetCurrentDirectoryA(LPCSTR lpPathName)
|
|||
}
|
||||
CurrentDirectoryW[i] = 0;
|
||||
|
||||
dprintf("CurrentDirectoryW = '%w'\n",CurrentDirectoryW);
|
||||
DPRINT("CurrentDirectoryW = '%w'\n",CurrentDirectoryW);
|
||||
|
||||
return(TRUE);
|
||||
}
|
||||
|
|
|
@ -7,38 +7,27 @@
|
|||
* UPDATE HISTORY:
|
||||
* Created 01/11/98
|
||||
*/
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <windows.h>
|
||||
#include <wstring.h>
|
||||
#include <string.h>
|
||||
#include <ddk/ntddk.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <kernel32/kernel32.h>
|
||||
|
||||
/* TYPES ********************************************************************/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
typedef struct _FIND_FILE_INFO
|
||||
typedef struct _KERNEL32_FIND_FILE_DATA
|
||||
{
|
||||
ULONG Offset;
|
||||
WCHAR PathName[MAX_PATH];
|
||||
WCHAR FileName[MAX_PATH];
|
||||
FILE_DIRECTORY_INFORMATION *FileDirectory;
|
||||
} FIND_FILE_INFO;
|
||||
HANDLE DirectoryHandle;
|
||||
FILE_DIRECTORY_INFORMATION FileInfo;
|
||||
WCHAR FileNameExtra[MAX_PATH];
|
||||
UNICODE_STRING PatternStr;
|
||||
} KERNEL32_FIND_FILE_DATA, *PKERNEL32_FIND_FILE_DATA;
|
||||
|
||||
typedef struct _NOTIFY_INFO
|
||||
{
|
||||
HANDLE Event;
|
||||
HANDLE FileHandle;
|
||||
DWORD dwNotifyFilter;
|
||||
WINBOOL bWatchSubtree;
|
||||
} NOTIFY_INFO;
|
||||
|
||||
|
||||
|
||||
|
||||
typedef struct _WIN32_FIND_DATAW {
|
||||
typedef struct _WIN32_FIND_DATA_UNICODE {
|
||||
DWORD dwFileAttributes;
|
||||
FILETIME ftCreationTime;
|
||||
FILETIME ftLastAccessTime;
|
||||
|
@ -49,415 +38,239 @@ typedef struct _WIN32_FIND_DATAW {
|
|||
DWORD dwReserved1;
|
||||
WCHAR cFileName[ MAX_PATH ];
|
||||
WCHAR cAlternateFileName[ 14 ];
|
||||
} WIN32_FIND_DATAW, *LPWIN32_FIND_DATAW, *PWIN32_FIND_DATAW;
|
||||
} WIN32_FIND_DATA_UNICODE, *PWIN32_FIND_DATA_UNICODE;
|
||||
|
||||
typedef struct _WIN32_FIND_DATA_ASCII {
|
||||
DWORD dwFileAttributes;
|
||||
FILETIME ftCreationTime;
|
||||
FILETIME ftLastAccessTime;
|
||||
FILETIME ftLastWriteTime;
|
||||
DWORD nFileSizeHigh;
|
||||
DWORD nFileSizeLow;
|
||||
DWORD dwReserved0;
|
||||
DWORD dwReserved1;
|
||||
CHAR cFileName[ MAX_PATH ];
|
||||
CHAR cAlternateFileName[ 14 ];
|
||||
} WIN32_FIND_DATA_ASCII, *PWIN32_FIND_DATA_ASCII;
|
||||
|
||||
|
||||
WINBOOL
|
||||
STDCALL
|
||||
FindClose(
|
||||
HANDLE hFind
|
||||
)
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
WINBOOL STDCALL InternalFindNextFile(HANDLE hFindFile,
|
||||
LPWIN32_FIND_DATA lpFindFileData)
|
||||
{
|
||||
IO_STATUS_BLOCK IoStatusBlock;
|
||||
NTSTATUS Status;
|
||||
PKERNEL32_FIND_FILE_DATA IData;
|
||||
|
||||
if ( hFind == NULL)
|
||||
return FALSE;
|
||||
if ( hFind == (HANDLE)-1)
|
||||
return FALSE;
|
||||
IData = (PKERNEL32_FIND_FILE_DATA)hFindFile;
|
||||
|
||||
HeapFree(GetProcessHeap(),0,((FIND_FILE_INFO *)hFind)->FileDirectory);
|
||||
HeapFree(GetProcessHeap(),0,hFind);
|
||||
return TRUE;
|
||||
Status = NtQueryDirectoryFile(IData->DirectoryHandle,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
&IoStatusBlock,
|
||||
(PVOID)&IData->FileInfo,
|
||||
sizeof(IData->FileInfo) +
|
||||
sizeof(IData->FileNameExtra),
|
||||
FileDirectoryInformation,
|
||||
TRUE,
|
||||
&(IData->PatternStr),
|
||||
FALSE);
|
||||
DPRINT("Found %w\n",IData->FileInfo.FileName);
|
||||
lpFindFileData->dwFileAttributes = IData->FileInfo.FileAttributes;
|
||||
if (Status != STATUS_SUCCESS)
|
||||
{
|
||||
return(FALSE);
|
||||
}
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
HANDLE
|
||||
STDCALL
|
||||
FindFirstFileA(
|
||||
LPCSTR lpFileName,
|
||||
LPWIN32_FIND_DATA lpFindFileData
|
||||
)
|
||||
HANDLE STDCALL InternalFindFirstFile(LPCWSTR lpFileName,
|
||||
LPWIN32_FIND_DATA lpFindFileData)
|
||||
{
|
||||
WIN32_FIND_DATAW FindFileDataW;
|
||||
WCHAR FileNameW[MAX_PATH];
|
||||
ULONG i;
|
||||
HANDLE hFind;
|
||||
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;
|
||||
|
||||
i = 0;
|
||||
while ((*lpFileName)!=0 && i < MAX_PATH)
|
||||
{
|
||||
FileNameW[i] = *lpFileName;
|
||||
lpFileName++;
|
||||
i++;
|
||||
}
|
||||
FileNameW[i] = 0;
|
||||
hFind = FindFirstFileW(FileNameW,(WIN32_FIND_DATA *)&FindFileDataW);
|
||||
DPRINT("FindFirstFileW(lpFileName %w, lpFindFileData %x)\n",
|
||||
lpFileName, lpFindFileData);
|
||||
|
||||
lpFindFileData->dwFileAttributes = FindFileDataW.dwFileAttributes;
|
||||
memcpy(&lpFindFileData->ftCreationTime,&FindFileDataW.ftCreationTime,sizeof(FILETIME));
|
||||
memcpy(&lpFindFileData->ftLastAccessTime,&FindFileDataW.ftLastAccessTime,sizeof(FILETIME));
|
||||
memcpy(&lpFindFileData->ftLastWriteTime,&FindFileDataW.ftLastWriteTime,sizeof(FILETIME));
|
||||
lpFindFileData->nFileSizeHigh = FindFileDataW.nFileSizeHigh;
|
||||
lpFindFileData->nFileSizeLow = FindFileDataW.nFileSizeLow;
|
||||
lpFindFileData->dwReserved0= FindFileDataW.dwReserved0;
|
||||
lpFindFileData->dwReserved1= FindFileDataW.dwReserved1;
|
||||
i = 0;
|
||||
while ((lpFindFileData->cFileName[i])!=0 && i < MAX_PATH)
|
||||
{
|
||||
lpFindFileData->cFileName[i] = (char)FindFileDataW.cFileName[i];
|
||||
i++;
|
||||
}
|
||||
lpFindFileData->cFileName[i] = 0;
|
||||
GetCurrentDirectoryW(MAX_PATH, CurrentDirectory);
|
||||
Directory[0] = '\\';
|
||||
Directory[1] = '?';
|
||||
Directory[2] = '?';
|
||||
Directory[3] = '\\';
|
||||
Directory[4] = 0;
|
||||
DPRINT("Directory %w\n",Directory);
|
||||
wcscat(Directory, CurrentDirectory);
|
||||
DPRINT("Directory %w\n",Directory);
|
||||
wcscat(Directory, lpFileName);
|
||||
DPRINT("Directory %w\n",Directory);
|
||||
End = wcsrchr(Directory, '\\');
|
||||
*End = 0;
|
||||
|
||||
i = 0;
|
||||
while ((lpFindFileData->cAlternateFileName[i])!=0 && i < 14)
|
||||
{
|
||||
lpFindFileData->cAlternateFileName[i] = (char)FindFileDataW.cAlternateFileName[i];
|
||||
i++;
|
||||
}
|
||||
lpFindFileData->cAlternateFileName[i] = 0;
|
||||
wcscpy(Pattern, End+1);
|
||||
*(End+1) = 0;
|
||||
*End = '\\';
|
||||
|
||||
DPRINT("Directory %w Pattern %w\n",Directory,Pattern);
|
||||
|
||||
return hFind;
|
||||
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_LIST_DIRECTORY,
|
||||
&ObjectAttributes,
|
||||
&IoStatusBlock,
|
||||
FILE_OPEN_IF,
|
||||
OPEN_EXISTING)!=STATUS_SUCCESS)
|
||||
{
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
RtlInitUnicodeString(&(IData->PatternStr), Pattern);
|
||||
|
||||
NtQueryDirectoryFile(IData->DirectoryHandle,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
&IoStatusBlock,
|
||||
(PVOID)&IData->FileInfo,
|
||||
sizeof(IData->FileInfo) +
|
||||
sizeof(IData->FileNameExtra),
|
||||
FileDirectoryInformation,
|
||||
TRUE,
|
||||
&(IData->PatternStr),
|
||||
FALSE);
|
||||
DPRINT("Found %w\n",IData->FileInfo.FileName);
|
||||
|
||||
lpFindFileData->dwFileAttributes = IData->FileInfo.FileAttributes;
|
||||
return(IData);
|
||||
}
|
||||
|
||||
HANDLE
|
||||
STDCALL
|
||||
FindFirstFileW(
|
||||
LPCWSTR lpFileName,
|
||||
LPWIN32_FIND_DATA lpFindFileData
|
||||
)
|
||||
HANDLE FindFirstFileA(LPCTSTR lpFileName, LPWIN32_FIND_DATA lpFindFileData)
|
||||
{
|
||||
NTSTATUS errCode;
|
||||
IO_STATUS_BLOCK IoStatusBlock;
|
||||
HANDLE FileHandle = NULL;
|
||||
FIND_FILE_INFO *hFind;
|
||||
WCHAR *FilePart;
|
||||
UNICODE_STRING FileNameString, PathNameString;
|
||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
WCHAR lpFileNameW[MAX_PATH];
|
||||
ULONG i;
|
||||
PKERNEL32_FIND_FILE_DATA IData;
|
||||
PWIN32_FIND_DATA_ASCII Ret;
|
||||
|
||||
DPRINT("FindFirstFileA(lpFileName %s, lpFindFileData %x)\n",
|
||||
lpFileName,lpFindFileData);
|
||||
|
||||
ACCESS_MASK DesiredAccess=FILE_READ_DATA;
|
||||
i = 0;
|
||||
while (lpFileName[i]!=0)
|
||||
{
|
||||
lpFileNameW[i] = lpFileName[i];
|
||||
i++;
|
||||
}
|
||||
lpFileNameW[i] = 0;
|
||||
|
||||
ULONG FileAttributes=FILE_ATTRIBUTE_DIRECTORY;
|
||||
ULONG ShareAccess=FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE;
|
||||
ULONG CreateDisposition=FILE_OPEN;
|
||||
ULONG CreateOptions=FILE_DIRECTORY_FILE;
|
||||
IData = InternalFindFirstFile(lpFileNameW,lpFindFileData);
|
||||
if (IData == NULL)
|
||||
{
|
||||
DPRINT("Failing request\n");
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
Ret = (PWIN32_FIND_DATA_ASCII)lpFindFileData;
|
||||
|
||||
hFind = HeapAlloc(GetProcessHeap(),HEAP_GENERATE_EXCEPTIONS|HEAP_ZERO_MEMORY,sizeof(FIND_FILE_INFO));
|
||||
for (i=0; i<IData->FileInfo.FileNameLength; i++)
|
||||
{
|
||||
Ret->cFileName[i] = IData->FileInfo.FileName[i];
|
||||
}
|
||||
Ret->cFileName[i] = 0;
|
||||
|
||||
hFind->FileDirectory = HeapAlloc(GetProcessHeap(),HEAP_GENERATE_EXCEPTIONS|HEAP_ZERO_MEMORY,8192);
|
||||
|
||||
|
||||
|
||||
/* Try to find a path and a filename in the passed filename */
|
||||
|
||||
lstrcpyW(hFind->PathName, lpFileName);
|
||||
FilePart = wcsrchr(hFind->PathName, '\\');
|
||||
|
||||
if (FilePart == NULL){
|
||||
GetCurrentDirectoryW(MAX_PATH, hFind->PathName);
|
||||
lstrcpyW(hFind->FileName, lpFileName);
|
||||
}
|
||||
else {
|
||||
lstrcpyW(hFind->FileName, &FilePart[1]);
|
||||
}
|
||||
|
||||
hFind->Offset = 0;
|
||||
|
||||
|
||||
PathNameString.Length = lstrlenW(hFind->PathName)*sizeof(WCHAR);
|
||||
PathNameString.Buffer = hFind->PathName;
|
||||
PathNameString.MaximumLength = FileNameString.Length+sizeof(WCHAR);
|
||||
|
||||
|
||||
FileNameString.Length = lstrlenW(hFind->FileName)*sizeof(WCHAR);
|
||||
FileNameString.Buffer = hFind->FileName;
|
||||
FileNameString.MaximumLength = FileNameString.Length+sizeof(WCHAR);
|
||||
|
||||
|
||||
ObjectAttributes.Length = sizeof(OBJECT_ATTRIBUTES);
|
||||
ObjectAttributes.RootDirectory = NULL;
|
||||
ObjectAttributes.ObjectName = &PathNameString;
|
||||
ObjectAttributes.Attributes = OBJ_CASE_INSENSITIVE| OBJ_INHERIT;
|
||||
ObjectAttributes.SecurityDescriptor = NULL;
|
||||
ObjectAttributes.SecurityQualityOfService = NULL;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
errCode = NtCreateFile(
|
||||
&FileHandle,
|
||||
DesiredAccess,
|
||||
&ObjectAttributes,
|
||||
&IoStatusBlock,
|
||||
NULL,
|
||||
FileAttributes,
|
||||
ShareAccess,
|
||||
CreateDisposition,
|
||||
CreateOptions,
|
||||
NULL,
|
||||
0); //
|
||||
|
||||
if ( !NT_SUCCESS(errCode) ) {
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
errCode = NtQueryDirectoryFile(
|
||||
FileHandle,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
&IoStatusBlock,
|
||||
hFind->FileDirectory,
|
||||
8192,
|
||||
FileDirectoryInformation,
|
||||
FALSE,
|
||||
&FileNameString,
|
||||
FALSE
|
||||
);
|
||||
if ( !NT_SUCCESS(errCode) ) {
|
||||
// printf("%x\n",errCode);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if ( FindNextFileW(hFind,lpFindFileData) )
|
||||
return hFind;
|
||||
else {
|
||||
FindClose(hFind);
|
||||
return NULL;
|
||||
}
|
||||
return NULL;
|
||||
return(IData);
|
||||
}
|
||||
|
||||
WINBOOL
|
||||
STDCALL
|
||||
FindNextFileA(
|
||||
HANDLE hFind,
|
||||
LPWIN32_FIND_DATA lpFindFileData
|
||||
)
|
||||
WINBOOL FindNextFileA(HANDLE hFindFile, LPWIN32_FIND_DATA lpFindFileData)
|
||||
{
|
||||
WIN32_FIND_DATAW FindFileDataW;
|
||||
ULONG i;
|
||||
PWIN32_FIND_DATA_ASCII Ret;
|
||||
PKERNEL32_FIND_FILE_DATA IData;
|
||||
ULONG i;
|
||||
|
||||
IData = (PKERNEL32_FIND_FILE_DATA)hFindFile;
|
||||
if (IData == NULL)
|
||||
{
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
hFind = FindNextFileW(hFind,(WIN32_FIND_DATA *)&FindFileDataW);
|
||||
if (!InternalFindNextFile(hFindFile, lpFindFileData))
|
||||
{
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
lpFindFileData->dwFileAttributes = FindFileDataW.dwFileAttributes;
|
||||
memcpy(&lpFindFileData->ftCreationTime,&FindFileDataW.ftCreationTime,sizeof(FILETIME));
|
||||
memcpy(&lpFindFileData->ftLastAccessTime,&FindFileDataW.ftLastAccessTime,sizeof(FILETIME));
|
||||
memcpy(&lpFindFileData->ftLastWriteTime,&FindFileDataW.ftLastWriteTime,sizeof(FILETIME));
|
||||
lpFindFileData->nFileSizeHigh = FindFileDataW.nFileSizeHigh;
|
||||
lpFindFileData->nFileSizeLow = FindFileDataW.nFileSizeLow;
|
||||
lpFindFileData->dwReserved0= FindFileDataW.dwReserved0;
|
||||
lpFindFileData->dwReserved1= FindFileDataW.dwReserved1;
|
||||
i = 0;
|
||||
while ((lpFindFileData->cFileName[i])!=0 && i < MAX_PATH)
|
||||
{
|
||||
lpFindFileData->cFileName[i] = (char)FindFileDataW.cFileName[i];
|
||||
i++;
|
||||
}
|
||||
lpFindFileData->cFileName[i] = 0;
|
||||
Ret = (PWIN32_FIND_DATA_ASCII)lpFindFileData;
|
||||
|
||||
i = 0;
|
||||
while ((lpFindFileData->cAlternateFileName[i])!=0 && i < 14)
|
||||
{
|
||||
lpFindFileData->cAlternateFileName[i] = (char)FindFileDataW.cAlternateFileName[i];
|
||||
i++;
|
||||
}
|
||||
lpFindFileData->cAlternateFileName[i] = 0;
|
||||
for (i=0; i<IData->FileInfo.FileNameLength; i++)
|
||||
{
|
||||
Ret->cFileName[i] = IData->FileInfo.FileName[i];
|
||||
}
|
||||
Ret->cFileName[i] = 0;
|
||||
|
||||
|
||||
return hFind;
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
WINBOOL
|
||||
STDCALL
|
||||
FindNextFileW(
|
||||
HANDLE hFind,
|
||||
LPWIN32_FIND_DATA lpFindFileData
|
||||
)
|
||||
BOOL FindClose(HANDLE hFindFile)
|
||||
{
|
||||
PKERNEL32_FIND_FILE_DATA IData;
|
||||
|
||||
dprintf("FindClose(hFindFile %x)\n",hFindFile);
|
||||
|
||||
LPWIN32_FIND_DATAW lpFindFileDataW = (LPWIN32_FIND_DATAW)lpFindFileData;
|
||||
|
||||
FIND_FILE_INFO *FindPtr = hFind;
|
||||
FILE_DIRECTORY_INFORMATION *FileDirectory=NULL;
|
||||
|
||||
if ( FindPtr == NULL )
|
||||
return FALSE;
|
||||
if ( FileDirectory->NextEntryOffset == 0 )
|
||||
return FALSE;
|
||||
|
||||
/* Try to find a file */
|
||||
FileDirectory = FindPtr->Offset + FindPtr->FileDirectory;
|
||||
|
||||
|
||||
|
||||
|
||||
FindPtr->Offset += FileDirectory->NextEntryOffset;
|
||||
|
||||
/* We found one! */
|
||||
if (FindPtr->PathName[0] != L'\0')
|
||||
{
|
||||
wcscpy(lpFindFileDataW->cFileName, FindPtr->PathName);
|
||||
wcscat(lpFindFileDataW->cFileName, L"\\");
|
||||
wcscat(lpFindFileDataW->cFileName, FileDirectory->FileName);
|
||||
}
|
||||
else
|
||||
wcscpy(lpFindFileDataW->cFileName, FileDirectory->FileName);
|
||||
|
||||
|
||||
|
||||
wcscpy(lpFindFileDataW->cAlternateFileName, L"");
|
||||
lpFindFileData->dwReserved0 = 0;
|
||||
lpFindFileData->dwReserved1 = 0;
|
||||
return TRUE;
|
||||
|
||||
IData = (PKERNEL32_FIND_FILE_DATA)hFindFile;
|
||||
NtClose(IData->DirectoryHandle);
|
||||
HeapFree(GetProcessHeap(), 0, IData);
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
HANDLE
|
||||
STDCALL
|
||||
FindFirstChangeNotificationA(
|
||||
LPCSTR lpPathName,
|
||||
WINBOOL bWatchSubtree,
|
||||
DWORD dwNotifyFilter
|
||||
)
|
||||
HANDLE STDCALL FindFirstFileW(LPCWSTR lpFileName,
|
||||
LPWIN32_FIND_DATA lpFindFileData)
|
||||
{
|
||||
ULONG i;
|
||||
PWIN32_FIND_DATA_UNICODE Ret;
|
||||
PKERNEL32_FIND_FILE_DATA IData;
|
||||
|
||||
WCHAR PathNameW[MAX_PATH];
|
||||
IData = InternalFindFirstFile(lpFileName,lpFindFileData);
|
||||
Ret = (PWIN32_FIND_DATA_UNICODE)lpFindFileData;
|
||||
|
||||
memcpy(Ret->cFileName, IData->FileInfo.FileName,
|
||||
IData->FileInfo.FileNameLength);
|
||||
memset(Ret->cAlternateFileName, 0, 14);
|
||||
|
||||
|
||||
|
||||
i = 0;
|
||||
while ((*lpPathName)!=0 && i < MAX_PATH)
|
||||
{
|
||||
PathNameW[i] = *lpPathName;
|
||||
lpPathName++;
|
||||
i++;
|
||||
}
|
||||
PathNameW[i] = 0;
|
||||
return FindFirstChangeNotificationW(PathNameW, bWatchSubtree, dwNotifyFilter );
|
||||
|
||||
return(IData);
|
||||
}
|
||||
|
||||
HANDLE
|
||||
STDCALL
|
||||
FindFirstChangeNotificationW(
|
||||
LPCWSTR lpPathName,
|
||||
WINBOOL bWatchSubtree,
|
||||
DWORD dwNotifyFilter
|
||||
)
|
||||
WINBOOL STDCALL FindNextFileW(HANDLE hFindFile,
|
||||
LPWIN32_FIND_DATA lpFindFileData)
|
||||
{
|
||||
NTSTATUS errCode;
|
||||
PWIN32_FIND_DATA_UNICODE Ret;
|
||||
PKERNEL32_FIND_FILE_DATA IData;
|
||||
|
||||
IData = (PKERNEL32_FIND_FILE_DATA)hFindFile;
|
||||
if (!InternalFindNextFile(hFindFile, lpFindFileData))
|
||||
{
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
IO_STATUS_BLOCK IoStatusBlock;
|
||||
NOTIFY_INFO *NotifyHandle;
|
||||
WCHAR Buffer[100];
|
||||
ULONG BufferSize = 100;
|
||||
Ret = (PWIN32_FIND_DATA_UNICODE)lpFindFileData;
|
||||
|
||||
NotifyHandle = HeapAlloc(GetProcessHeap(),0,sizeof(NOTIFY_INFO));
|
||||
memcpy(Ret->cFileName, IData->FileInfo.FileName,
|
||||
IData->FileInfo.FileNameLength);
|
||||
memset(Ret->cAlternateFileName, 0, 14);
|
||||
|
||||
NotifyHandle->Event = CreateEventW(NULL,FALSE,FALSE,NULL);
|
||||
NotifyHandle->FileHandle = CreateFileW(lpPathName,GENERIC_READ,FILE_SHARE_READ | FILE_SHARE_WRITE,NULL,OPEN_EXISTING,
|
||||
FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
|
||||
NotifyHandle->dwNotifyFilter = dwNotifyFilter;
|
||||
NotifyHandle->bWatchSubtree = bWatchSubtree;
|
||||
|
||||
errCode = NtNotifyChangeDirectoryFile(
|
||||
NotifyHandle->FileHandle,
|
||||
NotifyHandle->Event,
|
||||
NULL,
|
||||
NULL,
|
||||
&IoStatusBlock,
|
||||
Buffer,
|
||||
BufferSize,
|
||||
NotifyHandle->dwNotifyFilter,
|
||||
NotifyHandle->bWatchSubtree
|
||||
);
|
||||
return NotifyHandle;
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
WINBOOL
|
||||
STDCALL
|
||||
FindNextChangeNotification(
|
||||
HANDLE hChangeHandle
|
||||
)
|
||||
{
|
||||
NTSTATUS errCode;
|
||||
|
||||
|
||||
IO_STATUS_BLOCK IoStatusBlock;
|
||||
NOTIFY_INFO *NotifyHandle = hChangeHandle;
|
||||
|
||||
WCHAR Buffer[100];
|
||||
ULONG BufferSize = 100;
|
||||
EVENT_BASIC_INFORMATION EventBasic;
|
||||
ULONG ReturnLength;
|
||||
|
||||
|
||||
|
||||
NtQueryEvent(NotifyHandle->Event,EventBasicInformation,&EventBasic,sizeof(EVENT_BASIC_INFORMATION),&ReturnLength);
|
||||
|
||||
if ( EventBasic.Signaled == TRUE ) {
|
||||
ResetEvent(NotifyHandle->Event);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
errCode = NtNotifyChangeDirectoryFile(
|
||||
NotifyHandle->FileHandle,
|
||||
NotifyHandle->Event,
|
||||
NULL,
|
||||
NULL,
|
||||
&IoStatusBlock,
|
||||
Buffer,
|
||||
BufferSize,
|
||||
NotifyHandle->dwNotifyFilter,
|
||||
(BOOLEAN)NotifyHandle->bWatchSubtree
|
||||
);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
WINBOOL
|
||||
STDCALL
|
||||
FindCloseChangeNotification(
|
||||
HANDLE hChangeHandle
|
||||
)
|
||||
{
|
||||
HeapFree(GetProcessHeap(),0,hChangeHandle);
|
||||
return TRUE;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ OBJECTS = $(MISC_OBJECTS) $(FILE_OBJECTS) $(THREAD_OBJECTS) \
|
|||
|
||||
|
||||
kernel32.a: $(OBJECTS)
|
||||
$(AR) vrcs kernel32.a $(OBJECTS)
|
||||
$(AR) rcs kernel32.a $(OBJECTS)
|
||||
|
||||
dummy:
|
||||
|
||||
|
|
|
@ -26,8 +26,10 @@
|
|||
* Put the type definitions of the heap in a seperate header. Boudewijn Dekker
|
||||
*/
|
||||
|
||||
#include <kernel32/proc.h>
|
||||
#define NDEBUG
|
||||
#include <kernel32/kernel32.h>
|
||||
|
||||
#include <kernel32/proc.h>
|
||||
#include <kernel32/heap.h>
|
||||
#include <internal/string.h>
|
||||
|
||||
|
@ -72,7 +74,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)
|
||||
|
@ -91,7 +93,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();
|
||||
|
@ -117,7 +119,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);
|
||||
|
@ -239,7 +241,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;
|
||||
}
|
||||
|
@ -255,7 +257,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);
|
||||
|
@ -271,7 +273,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;
|
||||
|
@ -284,7 +286,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;
|
||||
|
||||
|
@ -308,7 +310,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);
|
||||
|
@ -595,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;
|
||||
|
@ -641,7 +643,7 @@ HANDLE STDCALL HeapCreate(DWORD flags, DWORD minsize, DWORD maxsize)
|
|||
{
|
||||
PHEAP pheap;
|
||||
|
||||
aprintf("HeapCreate( 0x%lX, 0x%lX, 0x%lX )\n", flags, minsize, maxsize);
|
||||
DPRINT("HeapCreate( 0x%lX, 0x%lX, 0x%lX )\n", flags, minsize, maxsize);
|
||||
|
||||
pheap = VirtualAlloc(NULL, minsize, MEM_TOP_DOWN, PAGE_READWRITE);
|
||||
VirtualAlloc(pheap, PAGESIZE, MEM_COMMIT, PAGE_READWRITE);
|
||||
|
@ -655,7 +657,7 @@ BOOL WINAPI HeapDestroy(HANDLE hheap)
|
|||
{
|
||||
PHEAP pheap=(PHEAP) hheap;
|
||||
|
||||
aprintf("HeapDestroy( 0x%lX )\n", (ULONG) hheap );
|
||||
DPRINT("HeapDestroy( 0x%lX )\n", (ULONG) hheap );
|
||||
|
||||
if(pheap->Magic!=MAGIC_HEAP)
|
||||
return __ErrorReturnFalse(ERROR_INVALID_PARAMETER);
|
||||
|
@ -675,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);
|
||||
|
@ -691,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;
|
||||
|
||||
|
||||
|
@ -707,7 +709,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);
|
||||
|
@ -740,8 +742,8 @@ WINBOOL STDCALL HeapFree(HANDLE hheap, DWORD flags, LPVOID ptr)
|
|||
PHEAP_BLOCK pfree=(PHEAP_BLOCK)((DWORD)ptr-HEAP_ADMIN_SIZE);
|
||||
BOOL retval;
|
||||
|
||||
aprintf("HeapFree( 0x%lX, 0x%lX, 0x%lX )\n",
|
||||
(ULONG) hheap, flags, (ULONG) ptr );
|
||||
DPRINT("HeapFree( 0x%lX, 0x%lX, 0x%lX )\n",
|
||||
(ULONG) hheap, flags, (ULONG) ptr );
|
||||
#ifdef NOT
|
||||
HeapValidate(hheap, 0, 0);
|
||||
#endif
|
||||
|
@ -773,7 +775,7 @@ WINBOOL STDCALL HeapFree(HANDLE hheap, DWORD flags, LPVOID ptr)
|
|||
*********************************************************************/
|
||||
HANDLE WINAPI GetProcessHeap(VOID)
|
||||
{
|
||||
aprintf("GetProcessHeap()\n");
|
||||
DPRINT("GetProcessHeap()\n");
|
||||
return (HANDLE) __ProcessHeap;
|
||||
}
|
||||
|
||||
|
@ -788,7 +790,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;
|
||||
|
@ -818,7 +820,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;
|
||||
|
@ -832,7 +834,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;
|
||||
|
@ -883,7 +885,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)
|
||||
|
@ -941,7 +943,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;
|
||||
|
|
|
@ -5,9 +5,6 @@ VOID CopyMemory(PVOID Destination, CONST VOID* Source, DWORD Length)
|
|||
{
|
||||
DWORD i;
|
||||
|
||||
dprintf("CopyMemory(Destination %x, Source %x, Length %d)\n",
|
||||
Destination,Source,Length);
|
||||
|
||||
for (i=0; i<Length; i++)
|
||||
{
|
||||
((PCH)Destination)[i] = ((PCH)Source)[i];
|
||||
|
|
|
@ -7,6 +7,9 @@
|
|||
* UPDATE HISTORY:
|
||||
* Created 01/11/98
|
||||
*/
|
||||
|
||||
/* INCLUDES ****************************************************************/
|
||||
|
||||
#define UNICODE
|
||||
#include <windows.h>
|
||||
#include <kernel32/proc.h>
|
||||
|
@ -16,27 +19,28 @@
|
|||
#include <ddk/rtl.h>
|
||||
#include <ddk/li.h>
|
||||
|
||||
NT_PEB CurrentPeb;
|
||||
#define NDEBUG
|
||||
#include <kernel32/kernel32.h>
|
||||
|
||||
/* GLOBALS *****************************************************************/
|
||||
|
||||
static NT_PEB *CurrentPeb;
|
||||
static NT_PEB Peb;
|
||||
|
||||
WaitForInputIdleType lpfnGlobalRegisterWaitForInputIdle;
|
||||
|
||||
VOID RegisterWaitForInputIdle(WaitForInputIdleType lpfnRegisterWaitForInputIdle);
|
||||
|
||||
wchar_t **CommandLineToArgvW(LPCWSTR lpCmdLine, int * pNumArgs );
|
||||
|
||||
WINBOOL
|
||||
STDCALL
|
||||
GetProcessId(HANDLE hProcess, LPDWORD lpProcessId );
|
||||
|
||||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
WINBOOL STDCALL GetProcessId(HANDLE hProcess, LPDWORD lpProcessId);
|
||||
|
||||
NT_PEB *GetCurrentPeb(VOID)
|
||||
{
|
||||
return &CurrentPeb;
|
||||
|
||||
if ( CurrentPeb != NULL )
|
||||
return CurrentPeb;
|
||||
else // hack to be able to return a process environment any time.
|
||||
return &Peb;
|
||||
}
|
||||
|
||||
HANDLE STDCALL GetCurrentProcess(VOID)
|
||||
|
@ -49,310 +53,334 @@ HANDLE STDCALL GetCurrentThread(VOID)
|
|||
return (HANDLE)NtCurrentThread();
|
||||
}
|
||||
|
||||
DWORD
|
||||
STDCALL
|
||||
GetCurrentProcessId(VOID)
|
||||
DWORD STDCALL GetCurrentProcessId(VOID)
|
||||
{
|
||||
|
||||
return (DWORD)(GetTeb()->Cid).UniqueProcess;
|
||||
|
||||
|
||||
}
|
||||
|
||||
unsigned char CommandLineA[MAX_PATH];
|
||||
|
||||
LPSTR
|
||||
STDCALL
|
||||
GetCommandLineA(
|
||||
VOID
|
||||
)
|
||||
WINBOOL STDCALL GetExitCodeProcess(HANDLE hProcess, LPDWORD lpExitCode )
|
||||
{
|
||||
WCHAR *CommandLineW;
|
||||
ULONG i = 0;
|
||||
NTSTATUS errCode;
|
||||
PROCESS_BASIC_INFORMATION ProcessBasic;
|
||||
ULONG BytesWritten;
|
||||
|
||||
CommandLineW = GetCommandLineW();
|
||||
while ((CommandLineW[i])!=0 && i < MAX_PATH)
|
||||
{
|
||||
CommandLineA[i] = (unsigned char)CommandLineW[i];
|
||||
i++;
|
||||
}
|
||||
CommandLineA[i] = 0;
|
||||
return CommandLineA;
|
||||
}
|
||||
LPWSTR
|
||||
STDCALL
|
||||
GetCommandLineW(
|
||||
VOID
|
||||
)
|
||||
{
|
||||
return GetCurrentPeb()->StartupInfo->CommandLine;
|
||||
errCode = NtQueryInformationProcess(hProcess,
|
||||
ProcessBasicInformation,
|
||||
&ProcessBasic,
|
||||
sizeof(PROCESS_BASIC_INFORMATION),
|
||||
&BytesWritten);
|
||||
if (!NT_SUCCESS(errCode))
|
||||
{
|
||||
SetLastError(RtlNtStatusToDosError(errCode));
|
||||
return FALSE;
|
||||
}
|
||||
memcpy( lpExitCode ,&ProcessBasic.ExitStatus,sizeof(DWORD));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
wchar_t **CommandLineToArgvW(LPCWSTR lpCmdLine, int * pNumArgs )
|
||||
WINBOOL STDCALL GetProcessId(HANDLE hProcess, LPDWORD lpProcessId )
|
||||
{
|
||||
NTSTATUS errCode;
|
||||
PROCESS_BASIC_INFORMATION ProcessBasic;
|
||||
ULONG BytesWritten;
|
||||
|
||||
errCode = NtQueryInformationProcess(hProcess,
|
||||
ProcessBasicInformation,
|
||||
&ProcessBasic,
|
||||
sizeof(PROCESS_BASIC_INFORMATION),
|
||||
&BytesWritten);
|
||||
if (!NT_SUCCESS(errCode))
|
||||
{
|
||||
SetLastError(RtlNtStatusToDosError(errCode));
|
||||
return FALSE;
|
||||
}
|
||||
memcpy( lpProcessId ,&ProcessBasic.UniqueProcessId,sizeof(DWORD));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
PWSTR InternalAnsiToUnicode(PWSTR Out, LPCSTR In, ULONG MaxLength)
|
||||
{
|
||||
ULONG i;
|
||||
|
||||
if (In == NULL)
|
||||
{
|
||||
return(NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
i = 0;
|
||||
while ((*In)!=0 && i < MaxLength)
|
||||
{
|
||||
Out[i] = *In;
|
||||
In++;
|
||||
i++;
|
||||
}
|
||||
Out[i] = 0;
|
||||
return(Out);
|
||||
}
|
||||
}
|
||||
|
||||
WINBOOL STDCALL CreateProcessA(LPCSTR lpApplicationName,
|
||||
LPSTR lpCommandLine,
|
||||
LPSECURITY_ATTRIBUTES lpProcessAttributes,
|
||||
LPSECURITY_ATTRIBUTES lpThreadAttributes,
|
||||
WINBOOL bInheritHandles,
|
||||
DWORD dwCreationFlags,
|
||||
LPVOID lpEnvironment,
|
||||
LPCSTR lpCurrentDirectory,
|
||||
LPSTARTUPINFO lpStartupInfo,
|
||||
LPPROCESS_INFORMATION lpProcessInformation)
|
||||
/*
|
||||
* FUNCTION: The CreateProcess function creates a new process and its
|
||||
* primary thread. The new process executes the specified executable file
|
||||
* ARGUMENTS:
|
||||
*
|
||||
* lpApplicationName = Pointer to name of executable module
|
||||
* lpCommandLine = Pointer to command line string
|
||||
* lpProcessAttributes = Process security attributes
|
||||
* lpThreadAttributes = Thread security attributes
|
||||
* bInheritHandles = Handle inheritance flag
|
||||
* dwCreationFlags = Creation flags
|
||||
* lpEnvironment = Pointer to new environment block
|
||||
* lpCurrentDirectory = Pointer to current directory name
|
||||
* lpStartupInfo = Pointer to startup info
|
||||
* lpProcessInformation = Pointer to process information
|
||||
*/
|
||||
{
|
||||
WCHAR ApplicationNameW[MAX_PATH];
|
||||
WCHAR CommandLineW[MAX_PATH];
|
||||
WCHAR CurrentDirectoryW[MAX_PATH];
|
||||
PWSTR PApplicationNameW;
|
||||
PWSTR PCommandLineW;
|
||||
PWSTR PCurrentDirectoryW;
|
||||
ULONG i;
|
||||
|
||||
DPRINT("CreateProcessA\n");
|
||||
|
||||
PApplicationNameW = InternalAnsiToUnicode(ApplicationNameW,
|
||||
lpApplicationName,
|
||||
MAX_PATH);
|
||||
PCommandLineW = InternalAnsiToUnicode(CommandLineW,
|
||||
lpCommandLine,
|
||||
MAX_PATH);
|
||||
PCurrentDirectoryW = InternalAnsiToUnicode(CurrentDirectoryW,
|
||||
lpCurrentDirectory,
|
||||
MAX_PATH);
|
||||
return CreateProcessW(PApplicationNameW,
|
||||
PCommandLineW,
|
||||
lpProcessAttributes,
|
||||
lpThreadAttributes,
|
||||
bInheritHandles,
|
||||
dwCreationFlags,
|
||||
lpEnvironment,
|
||||
PCurrentDirectoryW,
|
||||
lpStartupInfo,
|
||||
lpProcessInformation);
|
||||
}
|
||||
|
||||
|
||||
WINBOOL STDCALL CreateProcessW(LPCWSTR lpApplicationName,
|
||||
LPWSTR lpCommandLine,
|
||||
LPSECURITY_ATTRIBUTES lpProcessAttributes,
|
||||
LPSECURITY_ATTRIBUTES lpThreadAttributes,
|
||||
WINBOOL bInheritHandles,
|
||||
DWORD dwCreationFlags,
|
||||
LPVOID lpEnvironment,
|
||||
LPCWSTR lpCurrentDirectory,
|
||||
LPSTARTUPINFO lpStartupInfo,
|
||||
LPPROCESS_INFORMATION lpProcessInformation)
|
||||
{
|
||||
HANDLE hFile, hSection, hProcess, hThread;
|
||||
KPRIORITY PriorityClass;
|
||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
IO_STATUS_BLOCK IoStatusBlock;
|
||||
BOOLEAN CreateSuspended;
|
||||
NTSTATUS errCode;
|
||||
UNICODE_STRING ApplicationNameString;
|
||||
LPTHREAD_START_ROUTINE lpStartAddress = NULL;
|
||||
LPVOID lpParameter = NULL;
|
||||
PSECURITY_DESCRIPTOR SecurityDescriptor = NULL;
|
||||
WCHAR TempApplicationName[255];
|
||||
WCHAR TempFileName[255];
|
||||
WCHAR TempDirectoryName[255];
|
||||
ULONG i;
|
||||
ULONG BaseAddress;
|
||||
ULONG Size;
|
||||
LARGE_INTEGER SectionOffset;
|
||||
|
||||
DPRINT("CreateProcessW(lpApplicationName '%w', lpCommandLine '%w')\n",
|
||||
lpApplicationName,lpCommandLine);
|
||||
|
||||
hFile = NULL;
|
||||
|
||||
/*
|
||||
* Find the application name
|
||||
*/
|
||||
TempApplicationName[0] = '\\';
|
||||
TempApplicationName[1] = '?';
|
||||
TempApplicationName[2] = '?';
|
||||
TempApplicationName[3] = '\\';
|
||||
TempApplicationName[4] = 0;
|
||||
|
||||
DPRINT("TempApplicationName '%w'\n",TempApplicationName);
|
||||
|
||||
if (lpApplicationName != NULL)
|
||||
{
|
||||
wcscpy(TempFileName, lpApplicationName);
|
||||
|
||||
DPRINT("TempFileName '%w'\n",TempFileName);
|
||||
}
|
||||
else
|
||||
{
|
||||
wcscpy(TempFileName, lpCommandLine);
|
||||
|
||||
DPRINT("TempFileName '%w'\n",TempFileName);
|
||||
|
||||
for (i=0; TempFileName[i]!=' ' && TempFileName[i] != 0; i++);
|
||||
TempFileName[i]=0;
|
||||
|
||||
}
|
||||
if (TempFileName[1] != ':')
|
||||
{
|
||||
GetCurrentDirectoryW(MAX_PATH,TempDirectoryName);
|
||||
wcscat(TempApplicationName,TempDirectoryName);
|
||||
}
|
||||
wcscat(TempApplicationName,TempFileName);
|
||||
|
||||
RtlInitUnicodeString(&ApplicationNameString, TempApplicationName);
|
||||
|
||||
DPRINT("ApplicationName %w\n",ApplicationNameString.Buffer);
|
||||
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&ApplicationNameString,
|
||||
OBJ_CASE_INSENSITIVE,
|
||||
NULL,
|
||||
SecurityDescriptor);
|
||||
|
||||
/*
|
||||
* Try to open the executable
|
||||
*/
|
||||
|
||||
errCode = NtOpenFile(&hFile,
|
||||
SYNCHRONIZE|FILE_EXECUTE|FILE_READ_DATA,
|
||||
&ObjectAttributes,
|
||||
&IoStatusBlock,
|
||||
FILE_SHARE_DELETE|FILE_SHARE_READ,
|
||||
FILE_SYNCHRONOUS_IO_NONALERT|FILE_NON_DIRECTORY_FILE);
|
||||
|
||||
if ( !NT_SUCCESS(errCode) )
|
||||
{
|
||||
SetLastError(RtlNtStatusToDosError(errCode));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
errCode = NtCreateSection(&hSection,
|
||||
SECTION_ALL_ACCESS,
|
||||
NULL,
|
||||
NULL,
|
||||
PAGE_EXECUTE,
|
||||
SEC_IMAGE,
|
||||
hFile);
|
||||
NtClose(hFile);
|
||||
|
||||
if ( !NT_SUCCESS(errCode) )
|
||||
{
|
||||
SetLastError(RtlNtStatusToDosError(errCode));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
errCode = NtCreateProcess(&hProcess,
|
||||
PROCESS_ALL_ACCESS,
|
||||
NULL,
|
||||
NtCurrentProcess(),
|
||||
bInheritHandles,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
BaseAddress = (PVOID)0x10000;
|
||||
LARGE_INTEGER_QUAD_PART(SectionOffset) = 0;
|
||||
Size = 0x10000;
|
||||
NtMapViewOfSection(hSection,
|
||||
hProcess,
|
||||
&BaseAddress,
|
||||
0,
|
||||
Size,
|
||||
&SectionOffset,
|
||||
&Size,
|
||||
0,
|
||||
MEM_COMMIT,
|
||||
PAGE_READWRITE);
|
||||
|
||||
|
||||
NtClose(hSection);
|
||||
|
||||
if ( !NT_SUCCESS(errCode) )
|
||||
{
|
||||
SetLastError(RtlNtStatusToDosError(errCode));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#if 0
|
||||
PriorityClass = NORMAL_PRIORITY_CLASS;
|
||||
NtSetInformationProcess(hProcess,
|
||||
ProcessBasePriority,
|
||||
&PriorityClass,
|
||||
sizeof(KPRIORITY));
|
||||
#endif
|
||||
DPRINT("Creating thread for process\n");
|
||||
lpStartAddress = BaseAddress;
|
||||
hThread = CreateRemoteThread(hProcess,
|
||||
lpThreadAttributes,
|
||||
4096, // 1 page ??
|
||||
lpStartAddress,
|
||||
lpParameter,
|
||||
dwCreationFlags,
|
||||
&lpProcessInformation->dwThreadId);
|
||||
|
||||
if ( hThread == NULL )
|
||||
return FALSE;
|
||||
|
||||
lpProcessInformation->hProcess = hProcess;
|
||||
lpProcessInformation->hThread = hThread;
|
||||
|
||||
GetProcessId(hProcess,&lpProcessInformation->dwProcessId);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
HANDLE STDCALL OpenProcess(DWORD dwDesiredAccess,
|
||||
WINBOOL bInheritHandle,
|
||||
DWORD dwProcessId)
|
||||
{
|
||||
NTSTATUS errCode;
|
||||
HANDLE ProcessHandle;
|
||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
CLIENT_ID ClientId ;
|
||||
|
||||
ClientId.UniqueProcess = (HANDLE)dwProcessId;
|
||||
ObjectAttributes.Length = sizeof(OBJECT_ATTRIBUTES);
|
||||
ObjectAttributes.RootDirectory = (HANDLE)NULL;
|
||||
ObjectAttributes.SecurityDescriptor = NULL;
|
||||
ObjectAttributes.SecurityQualityOfService = NULL;
|
||||
|
||||
if ( bInheritHandle == TRUE )
|
||||
ObjectAttributes.Attributes = OBJ_INHERIT;
|
||||
else
|
||||
ObjectAttributes.Attributes = 0;
|
||||
|
||||
errCode = NtOpenProcess(&ProcessHandle,
|
||||
dwDesiredAccess,
|
||||
&ObjectAttributes,
|
||||
&ClientId);
|
||||
if (!NT_SUCCESS(errCode))
|
||||
{
|
||||
SetLastError(RtlNtStatusToDosError(errCode));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
WINBOOL
|
||||
STDCALL
|
||||
GetExitCodeProcess(
|
||||
HANDLE hProcess,
|
||||
LPDWORD lpExitCode
|
||||
)
|
||||
{
|
||||
NTSTATUS errCode;
|
||||
PROCESS_BASIC_INFORMATION ProcessBasic;
|
||||
ULONG BytesWritten;
|
||||
|
||||
errCode = NtQueryInformationProcess(hProcess,ProcessBasicInformation,&ProcessBasic,sizeof(PROCESS_BASIC_INFORMATION),&BytesWritten);
|
||||
if ( !NT_SUCCESS(errCode) ) {
|
||||
SetLastError(RtlNtStatusToDosError(errCode));
|
||||
return FALSE;
|
||||
}
|
||||
memcpy( lpExitCode ,&ProcessBasic.ExitStatus,sizeof(DWORD));
|
||||
return TRUE;
|
||||
|
||||
}
|
||||
|
||||
WINBOOL
|
||||
STDCALL
|
||||
GetProcessId(
|
||||
HANDLE hProcess,
|
||||
LPDWORD lpProcessId
|
||||
)
|
||||
{
|
||||
NTSTATUS errCode;
|
||||
PROCESS_BASIC_INFORMATION ProcessBasic;
|
||||
ULONG BytesWritten;
|
||||
|
||||
errCode = NtQueryInformationProcess(hProcess,ProcessBasicInformation,&ProcessBasic,sizeof(PROCESS_BASIC_INFORMATION),&BytesWritten);
|
||||
if ( !NT_SUCCESS(errCode) ) {
|
||||
SetLastError(RtlNtStatusToDosError(errCode));
|
||||
return FALSE;
|
||||
}
|
||||
memcpy( lpProcessId ,&ProcessBasic.UniqueProcessId,sizeof(DWORD));
|
||||
return TRUE;
|
||||
|
||||
}
|
||||
|
||||
WINBOOL
|
||||
STDCALL
|
||||
CreateProcessA(
|
||||
LPCSTR lpApplicationName,
|
||||
LPSTR lpCommandLine,
|
||||
LPSECURITY_ATTRIBUTES lpProcessAttributes,
|
||||
LPSECURITY_ATTRIBUTES lpThreadAttributes,
|
||||
WINBOOL bInheritHandles,
|
||||
DWORD dwCreationFlags,
|
||||
LPVOID lpEnvironment,
|
||||
LPCSTR lpCurrentDirectory,
|
||||
LPSTARTUPINFO lpStartupInfo,
|
||||
LPPROCESS_INFORMATION lpProcessInformation
|
||||
)
|
||||
{
|
||||
WCHAR ApplicationNameW[MAX_PATH];
|
||||
WCHAR CommandLineW[MAX_PATH];
|
||||
WCHAR CurrentDirectoryW[MAX_PATH];
|
||||
|
||||
|
||||
ULONG i;
|
||||
|
||||
i = 0;
|
||||
while ((*lpApplicationName)!=0 && i < MAX_PATH)
|
||||
{
|
||||
ApplicationNameW[i] = *lpApplicationName;
|
||||
lpApplicationName++;
|
||||
i++;
|
||||
}
|
||||
ApplicationNameW[i] = 0;
|
||||
|
||||
|
||||
i = 0;
|
||||
while ((*lpCommandLine)!=0 && i < MAX_PATH)
|
||||
{
|
||||
CommandLineW[i] = *lpCommandLine;
|
||||
lpCommandLine++;
|
||||
i++;
|
||||
}
|
||||
CommandLineW[i] = 0;
|
||||
|
||||
i = 0;
|
||||
while ((*lpCurrentDirectory)!=0 && i < MAX_PATH)
|
||||
{
|
||||
CurrentDirectoryW[i] = *lpCurrentDirectory;
|
||||
lpCurrentDirectory++;
|
||||
i++;
|
||||
}
|
||||
CurrentDirectoryW[i] = 0;
|
||||
|
||||
return CreateProcessW(ApplicationNameW,CommandLineW, lpProcessAttributes,lpThreadAttributes,
|
||||
bInheritHandles,dwCreationFlags,lpEnvironment,CurrentDirectoryW,lpStartupInfo,
|
||||
lpProcessInformation);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
WINBOOL
|
||||
STDCALL
|
||||
CreateProcessW(
|
||||
LPCWSTR lpApplicationName,
|
||||
LPWSTR lpCommandLine,
|
||||
LPSECURITY_ATTRIBUTES lpProcessAttributes,
|
||||
LPSECURITY_ATTRIBUTES lpThreadAttributes,
|
||||
WINBOOL bInheritHandles,
|
||||
DWORD dwCreationFlags,
|
||||
LPVOID lpEnvironment,
|
||||
LPCWSTR lpCurrentDirectory,
|
||||
LPSTARTUPINFO lpStartupInfo,
|
||||
LPPROCESS_INFORMATION lpProcessInformation
|
||||
)
|
||||
{
|
||||
HANDLE hFile, hSection, hProcess, hThread;
|
||||
KPRIORITY PriorityClass;
|
||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
IO_STATUS_BLOCK IoStatusBlock;
|
||||
BOOLEAN CreateSuspended;
|
||||
|
||||
NTSTATUS errCode;
|
||||
|
||||
UNICODE_STRING ApplicationNameString;
|
||||
|
||||
|
||||
|
||||
LPTHREAD_START_ROUTINE lpStartAddress = NULL;
|
||||
LPVOID lpParameter = NULL;
|
||||
|
||||
hFile = NULL;
|
||||
|
||||
ApplicationNameString.Length = lstrlenW(lpApplicationName)*sizeof(WCHAR);
|
||||
|
||||
ApplicationNameString.Buffer = (WCHAR *)lpApplicationName;
|
||||
ApplicationNameString.MaximumLength = ApplicationNameString.Length+sizeof(WCHAR);
|
||||
|
||||
|
||||
ObjectAttributes.Length = sizeof(OBJECT_ATTRIBUTES);
|
||||
ObjectAttributes.RootDirectory = NULL;
|
||||
|
||||
|
||||
|
||||
if ( lpProcessAttributes != NULL ) {
|
||||
if ( lpProcessAttributes->bInheritHandle )
|
||||
ObjectAttributes.Attributes = OBJ_INHERIT;
|
||||
else
|
||||
ObjectAttributes.Attributes = 0;
|
||||
ObjectAttributes.SecurityDescriptor = lpProcessAttributes->lpSecurityDescriptor;
|
||||
}
|
||||
ObjectAttributes.Attributes |= OBJ_CASE_INSENSITIVE;
|
||||
|
||||
errCode = NtOpenFile(&hFile,(SYNCHRONIZE|FILE_EXECUTE), &ObjectAttributes,
|
||||
&IoStatusBlock,(FILE_SHARE_DELETE|FILE_SHARE_READ),(FILE_SYNCHRONOUS_IO_NONALERT|FILE_NON_DIRECTORY_FILE));
|
||||
|
||||
if ( !NT_SUCCESS(errCode) ) {
|
||||
SetLastError(RtlNtStatusToDosError(errCode));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
errCode = NtCreateSection(&hSection,SECTION_ALL_ACCESS,NULL,NULL,PAGE_EXECUTE,SEC_IMAGE,hFile);
|
||||
NtClose(hFile);
|
||||
|
||||
if ( !NT_SUCCESS(errCode) ) {
|
||||
SetLastError(RtlNtStatusToDosError(errCode));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
if ( lpProcessAttributes != NULL ) {
|
||||
if ( lpProcessAttributes->bInheritHandle )
|
||||
ObjectAttributes.Attributes = OBJ_INHERIT;
|
||||
else
|
||||
ObjectAttributes.Attributes = 0;
|
||||
ObjectAttributes.SecurityDescriptor = lpProcessAttributes->lpSecurityDescriptor;
|
||||
}
|
||||
|
||||
errCode = NtCreateProcess(&hProcess,PROCESS_ALL_ACCESS, &ObjectAttributes,NtCurrentProcess(),bInheritHandles,hSection,NULL,NULL);
|
||||
NtClose(hSection);
|
||||
|
||||
if ( !NT_SUCCESS(errCode) ) {
|
||||
SetLastError(RtlNtStatusToDosError(errCode));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
PriorityClass = NORMAL_PRIORITY_CLASS;
|
||||
NtSetInformationProcess(hProcess,ProcessBasePriority,&PriorityClass,sizeof(KPRIORITY));
|
||||
|
||||
if ( ( dwCreationFlags & CREATE_SUSPENDED ) == CREATE_SUSPENDED)
|
||||
CreateSuspended = TRUE;
|
||||
else
|
||||
CreateSuspended = FALSE;
|
||||
|
||||
hThread = CreateRemoteThread(
|
||||
hProcess,
|
||||
lpThreadAttributes,
|
||||
4096, // 1 page ??
|
||||
lpStartAddress,
|
||||
lpParameter,
|
||||
CREATE_SUSPENDED,
|
||||
&lpProcessInformation->dwThreadId
|
||||
);
|
||||
|
||||
|
||||
if ( hThread == NULL )
|
||||
return FALSE;
|
||||
|
||||
|
||||
|
||||
lpProcessInformation->hProcess = hProcess;
|
||||
lpProcessInformation->hThread = hThread;
|
||||
|
||||
|
||||
|
||||
|
||||
GetProcessId(hProcess,&lpProcessInformation->dwProcessId);
|
||||
|
||||
|
||||
|
||||
return TRUE;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
HANDLE
|
||||
STDCALL
|
||||
OpenProcess(
|
||||
DWORD dwDesiredAccess,
|
||||
WINBOOL bInheritHandle,
|
||||
DWORD dwProcessId
|
||||
)
|
||||
{
|
||||
|
||||
|
||||
NTSTATUS errCode;
|
||||
HANDLE ProcessHandle;
|
||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
CLIENT_ID ClientId ;
|
||||
|
||||
ClientId.UniqueProcess = (HANDLE)dwProcessId;
|
||||
ObjectAttributes.Length = sizeof(OBJECT_ATTRIBUTES);
|
||||
ObjectAttributes.RootDirectory = (HANDLE)NULL;
|
||||
ObjectAttributes.SecurityDescriptor = NULL;
|
||||
ObjectAttributes.SecurityQualityOfService = NULL;
|
||||
|
||||
if ( bInheritHandle == TRUE )
|
||||
ObjectAttributes.Attributes = OBJ_INHERIT;
|
||||
else
|
||||
ObjectAttributes.Attributes = 0;
|
||||
|
||||
errCode = NtOpenProcess ( &ProcessHandle, dwDesiredAccess, &ObjectAttributes, &ClientId);
|
||||
if ( !NT_SUCCESS(errCode) ) {
|
||||
SetLastError(RtlNtStatusToDosError(errCode));
|
||||
return NULL;
|
||||
}
|
||||
return ProcessHandle;
|
||||
}
|
||||
return ProcessHandle;
|
||||
}
|
||||
|
||||
|
||||
|
@ -367,48 +395,51 @@ OpenProcess(
|
|||
|
||||
|
||||
|
||||
UINT WinExec ( LPCSTR lpCmdLine, UINT uCmdShow )
|
||||
UINT WinExec (LPCSTR lpCmdLine, UINT uCmdShow)
|
||||
{
|
||||
STARTUPINFO StartupInfo;
|
||||
PROCESS_INFORMATION ProcessInformation;
|
||||
STARTUPINFO StartupInfo;
|
||||
PROCESS_INFORMATION ProcessInformation;
|
||||
HINSTANCE hInst;
|
||||
DWORD dosErr;
|
||||
|
||||
HINSTANCE hInst;
|
||||
DWORD dosErr;
|
||||
|
||||
|
||||
|
||||
StartupInfo.cb = sizeof(STARTUPINFO);
|
||||
StartupInfo.wShowWindow = uCmdShow ;
|
||||
StartupInfo.dwFlags = 0;
|
||||
|
||||
hInst = (HINSTANCE)CreateProcessA(NULL,(PVOID)lpCmdLine,NULL,NULL,FALSE,0,NULL,NULL,&StartupInfo, &ProcessInformation);
|
||||
if ( hInst == NULL ) {
|
||||
dosErr = GetLastError();
|
||||
return dosErr;
|
||||
}
|
||||
if ( lpfnGlobalRegisterWaitForInputIdle != NULL )
|
||||
lpfnGlobalRegisterWaitForInputIdle(ProcessInformation.hProcess,10000);
|
||||
NtClose(ProcessInformation.hProcess);
|
||||
NtClose(ProcessInformation.hThread);
|
||||
return 0;
|
||||
StartupInfo.cb = sizeof(STARTUPINFO);
|
||||
StartupInfo.wShowWindow = uCmdShow ;
|
||||
StartupInfo.dwFlags = 0;
|
||||
|
||||
hInst = (HINSTANCE)CreateProcessA(NULL,
|
||||
(PVOID)lpCmdLine,
|
||||
NULL,
|
||||
NULL,
|
||||
FALSE,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
&StartupInfo,
|
||||
&ProcessInformation);
|
||||
if ( hInst == NULL )
|
||||
{
|
||||
dosErr = GetLastError();
|
||||
return dosErr;
|
||||
}
|
||||
if ( lpfnGlobalRegisterWaitForInputIdle != NULL )
|
||||
lpfnGlobalRegisterWaitForInputIdle(ProcessInformation.hProcess,10000);
|
||||
NtClose(ProcessInformation.hProcess);
|
||||
NtClose(ProcessInformation.hThread);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
VOID RegisterWaitForInputIdle(WaitForInputIdleType lpfnRegisterWaitForInputIdle)
|
||||
{
|
||||
lpfnGlobalRegisterWaitForInputIdle = lpfnRegisterWaitForInputIdle;
|
||||
return;
|
||||
}
|
||||
|
||||
DWORD
|
||||
STDCALL
|
||||
WaitForInputIdle(
|
||||
HANDLE hProcess,
|
||||
DWORD dwMilliseconds
|
||||
)
|
||||
DWORD STDCALL WaitForInputIdle(HANDLE hProcess,
|
||||
DWORD dwMilliseconds)
|
||||
{
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
VOID
|
||||
|
@ -428,10 +459,11 @@ SleepEx(
|
|||
BOOL bAlertable
|
||||
)
|
||||
{
|
||||
LARGE_INTEGER Interval;
|
||||
TIME Interval;
|
||||
NTSTATUS errCode;
|
||||
SET_LARGE_INTEGER_LOW_PART(Interval,dwMilliseconds*1000);
|
||||
|
||||
Interval.LowPart = dwMilliseconds * 1000;
|
||||
Interval.HighPart = 0;
|
||||
errCode = NtDelayExecution(bAlertable,&Interval);
|
||||
if ( !NT_SUCCESS(errCode) ) {
|
||||
SetLastError(RtlNtStatusToDosError(errCode));
|
||||
|
@ -458,8 +490,8 @@ GetStartupInfoW(
|
|||
}
|
||||
|
||||
lpStartupInfo->cb = sizeof(STARTUPINFO);
|
||||
lstrcpyW(lpStartupInfo->lpDesktop,(WCHAR *) pPeb->StartupInfo->Desktop);
|
||||
lstrcpyW(lpStartupInfo->lpTitle, (WCHAR *)pPeb->StartupInfo->Title);
|
||||
lstrcpyW(lpStartupInfo->lpDesktop, pPeb->StartupInfo->Desktop);
|
||||
lstrcpyW(lpStartupInfo->lpTitle, pPeb->StartupInfo->Title);
|
||||
lpStartupInfo->dwX = pPeb->StartupInfo->dwX;
|
||||
lpStartupInfo->dwY = pPeb->StartupInfo->dwY;
|
||||
lpStartupInfo->dwXSize = pPeb->StartupInfo->dwXSize;
|
||||
|
@ -505,7 +537,7 @@ GetStartupInfoA(
|
|||
|
||||
while ((pPeb->StartupInfo->Desktop[i])!=0 && i < MAX_PATH)
|
||||
{
|
||||
lpStartupInfo->lpDesktop[i] = (char)pPeb->StartupInfo->Desktop[i];
|
||||
lpStartupInfo->lpDesktop[i] = (unsigned char)pPeb->StartupInfo->Desktop[i];
|
||||
i++;
|
||||
}
|
||||
lpStartupInfo->lpDesktop[i] = 0;
|
||||
|
@ -513,7 +545,7 @@ GetStartupInfoA(
|
|||
i = 0;
|
||||
while ((pPeb->StartupInfo->Title[i])!=0 && i < MAX_PATH)
|
||||
{
|
||||
lpStartupInfo->lpTitle[i] = (char)pPeb->StartupInfo->Title[i];
|
||||
lpStartupInfo->lpTitle[i] = (unsigned char)pPeb->StartupInfo->Title[i];
|
||||
i++;
|
||||
}
|
||||
lpStartupInfo->lpTitle[i] = 0;
|
||||
|
@ -557,18 +589,9 @@ FlushInstructionCache(
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
VOID
|
||||
STDCALL
|
||||
ExitProcess(
|
||||
UINT uExitCode
|
||||
)
|
||||
VOID STDCALL ExitProcess(UINT uExitCode)
|
||||
{
|
||||
|
||||
NtTerminateProcess(
|
||||
NtCurrentProcess() ,
|
||||
uExitCode
|
||||
);
|
||||
|
||||
NtTerminateProcess(NtCurrentProcess() ,uExitCode);
|
||||
}
|
||||
|
||||
VOID
|
||||
|
@ -594,44 +617,9 @@ FatalAppExitA(
|
|||
|
||||
|
||||
|
||||
VOID
|
||||
STDCALL
|
||||
FatalAppExitW(
|
||||
UINT uAction,
|
||||
LPCWSTR lpMessageText
|
||||
)
|
||||
VOID STDCALL FatalAppExitW(UINT uAction, LPCWSTR lpMessageText)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
HMODULE
|
||||
STDCALL
|
||||
GetModuleHandleA(
|
||||
LPCSTR lpModuleName
|
||||
)
|
||||
{
|
||||
if ( lpModuleName == NULL )
|
||||
return 0x00010000; // starting address of current module
|
||||
else
|
||||
return NULL; // should return the address of the specified module
|
||||
|
||||
return NULL;
|
||||
|
||||
}
|
||||
|
||||
HMODULE
|
||||
STDCALL
|
||||
GetModuleHandleW(
|
||||
LPCWSTR lpModuleName
|
||||
)
|
||||
{
|
||||
if ( lpModuleName == NULL )
|
||||
return 0x00010000; // starting address of current module
|
||||
else
|
||||
return NULL; // should return the address of the specified module
|
||||
|
||||
return NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#include <kernel32/thread.h>
|
||||
#include <ddk/ntddk.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <internal/i386/segment.h>
|
||||
|
||||
HANDLE
|
||||
STDCALL
|
||||
|
@ -45,47 +45,64 @@ CreateRemoteThread(
|
|||
LPDWORD lpThreadId
|
||||
)
|
||||
{
|
||||
NTSTATUS errCode;
|
||||
HANDLE ThreadHandle;
|
||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
CLIENT_ID ClientId;
|
||||
CONTEXT ThreadContext;
|
||||
INITIAL_TEB InitialTeb;
|
||||
BOOLEAN CreateSuspended = FALSE;
|
||||
NTSTATUS errCode;
|
||||
HANDLE ThreadHandle;
|
||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
CLIENT_ID ClientId;
|
||||
CONTEXT ThreadContext;
|
||||
INITIAL_TEB InitialTeb;
|
||||
BOOLEAN CreateSuspended = FALSE;
|
||||
ULONG BaseAddress;
|
||||
|
||||
ObjectAttributes.Length = sizeof(OBJECT_ATTRIBUTES);
|
||||
ObjectAttributes.RootDirectory = NULL;
|
||||
ObjectAttributes.ObjectName = NULL;
|
||||
ObjectAttributes.Attributes = 0;
|
||||
if ( lpThreadAttributes != NULL ) {
|
||||
if ( lpThreadAttributes->bInheritHandle )
|
||||
ObjectAttributes.Attributes = OBJ_INHERIT;
|
||||
ObjectAttributes.SecurityDescriptor = lpThreadAttributes->lpSecurityDescriptor;
|
||||
}
|
||||
ObjectAttributes.SecurityQualityOfService = NULL;
|
||||
ObjectAttributes.Length = sizeof(OBJECT_ATTRIBUTES);
|
||||
ObjectAttributes.RootDirectory = NULL;
|
||||
ObjectAttributes.ObjectName = NULL;
|
||||
ObjectAttributes.Attributes = 0;
|
||||
if ( lpThreadAttributes != NULL ) {
|
||||
if ( lpThreadAttributes->bInheritHandle )
|
||||
ObjectAttributes.Attributes = OBJ_INHERIT;
|
||||
ObjectAttributes.SecurityDescriptor = lpThreadAttributes->lpSecurityDescriptor;
|
||||
}
|
||||
ObjectAttributes.SecurityQualityOfService = NULL;
|
||||
|
||||
if ( ( dwCreationFlags & CREATE_SUSPENDED ) == CREATE_SUSPENDED )
|
||||
if ( ( dwCreationFlags & CREATE_SUSPENDED ) == CREATE_SUSPENDED )
|
||||
CreateSuspended = TRUE;
|
||||
else
|
||||
CreateSuspended = FALSE;
|
||||
// fix context
|
||||
GetThreadContext(NtCurrentThread(),&ThreadContext);
|
||||
// fix teb [ stack context ] --> check the image file
|
||||
else
|
||||
CreateSuspended = FALSE;
|
||||
|
||||
errCode = NtCreateThread(
|
||||
&ThreadHandle,
|
||||
THREAD_ALL_ACCESS,
|
||||
&ObjectAttributes,
|
||||
hProcess,
|
||||
&ClientId,
|
||||
&ThreadContext,
|
||||
&InitialTeb,
|
||||
CreateSuspended
|
||||
);
|
||||
if ( lpThreadId != NULL )
|
||||
memcpy(lpThreadId, &ClientId.UniqueThread,sizeof(ULONG));
|
||||
BaseAddress = 0;
|
||||
ZwAllocateVirtualMemory(hProcess,
|
||||
&BaseAddress,
|
||||
0,
|
||||
&dwStackSize,
|
||||
MEM_COMMIT,
|
||||
PAGE_READWRITE);
|
||||
|
||||
return ThreadHandle;
|
||||
|
||||
memset(&ThreadContext,0,sizeof(CONTEXT));
|
||||
ThreadContext.Eip = lpStartAddress;
|
||||
ThreadContext.SegGs = USER_DS;
|
||||
ThreadContext.SegFs = USER_DS;
|
||||
ThreadContext.SegEs = USER_DS;
|
||||
ThreadContext.SegDs = USER_DS;
|
||||
ThreadContext.SegCs = USER_CS;
|
||||
ThreadContext.SegSs = USER_DS;
|
||||
ThreadContext.Esp = BaseAddress + dwStackSize;
|
||||
ThreadContext.EFlags = (1<<1) + (1<<9);
|
||||
|
||||
|
||||
errCode = NtCreateThread(&ThreadHandle,
|
||||
THREAD_ALL_ACCESS,
|
||||
&ObjectAttributes,
|
||||
hProcess,
|
||||
&ClientId,
|
||||
&ThreadContext,
|
||||
&InitialTeb,
|
||||
CreateSuspended);
|
||||
if ( lpThreadId != NULL )
|
||||
memcpy(lpThreadId, &ClientId.UniqueThread,sizeof(ULONG));
|
||||
|
||||
return ThreadHandle;
|
||||
}
|
||||
|
||||
NT_TEB *GetTeb(VOID)
|
||||
|
@ -93,27 +110,20 @@ NT_TEB *GetTeb(VOID)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
WINBOOL STDCALL
|
||||
SwitchToThread(VOID )
|
||||
WINBOOL STDCALL SwitchToThread(VOID )
|
||||
{
|
||||
NTSTATUS errCode;
|
||||
errCode = NtYieldExecution();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
DWORD
|
||||
STDCALL
|
||||
GetCurrentThreadId()
|
||||
DWORD STDCALL GetCurrentThreadId()
|
||||
{
|
||||
|
||||
return (DWORD)(GetTeb()->Cid).UniqueThread;
|
||||
}
|
||||
|
||||
VOID
|
||||
STDCALL
|
||||
ExitThread(
|
||||
UINT uExitCode
|
||||
)
|
||||
VOID STDCALL ExitThread(UINT uExitCode)
|
||||
{
|
||||
NTSTATUS errCode;
|
||||
|
||||
|
|
|
@ -18,17 +18,22 @@
|
|||
|
||||
/* TYPES *********************************************************************/
|
||||
|
||||
#define CACHE_SEGMENT_INVALID (0) // Isn't valid
|
||||
#define CACHE_SEGMENT_WRITTEN (1) // Written
|
||||
#define CACHE_SEGMENT_READ (2)
|
||||
|
||||
typedef struct _CACHE_SEGMENT
|
||||
{
|
||||
ULONG Type;
|
||||
ULONG Type; // Debugging
|
||||
ULONG Size;
|
||||
LIST_ENTRY ListEntry;
|
||||
PVOID BaseAddress;
|
||||
ULONG Length;
|
||||
ULONG State;
|
||||
MEMORY_AREA* MemoryArea;
|
||||
ULONG FileOffset;
|
||||
ULONG InternalOffset;
|
||||
LIST_ENTRY ListEntry; // Entry in the per-open list of segments
|
||||
PVOID BaseAddress; // Base address of the mapping
|
||||
ULONG Length; // Length of the mapping
|
||||
ULONG State; // Information
|
||||
MEMORY_AREA* MemoryArea; // Memory area for the mapping
|
||||
ULONG FileOffset; // Offset within the file of the mapping
|
||||
KEVENT Event;
|
||||
BOOLEAN Dirty; // Contains dirty data
|
||||
} CACHE_SEGMENT, *PCACHE_SEGMENT;
|
||||
|
||||
typedef struct _CC1_CCB
|
||||
|
@ -36,35 +41,36 @@ typedef struct _CC1_CCB
|
|||
ULONG Type;
|
||||
ULONG Size;
|
||||
LIST_ENTRY CacheSegmentListHead;
|
||||
KSPIN_LOCK CacheSegmentListLock;
|
||||
LIST_ENTRY ListEntry;
|
||||
} CC1_CCB, PCC1_CCB;
|
||||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
PVOID Cc1FlushView(PFILE_OBJECT FileObject,
|
||||
PVOID Cc1FlushView(PCC1_CCB CacheDesc,
|
||||
ULONG FileOffset,
|
||||
ULONG Length)
|
||||
{
|
||||
}
|
||||
|
||||
PVOID Cc1PurgeView(PFILE_OBJECT FileObject,
|
||||
PVOID Cc1PurgeView(PCC1_CCB CacheDesc,
|
||||
ULONG FileOffset,
|
||||
ULONG Length)
|
||||
{
|
||||
}
|
||||
|
||||
VOID Cc1ViewIsUpdated(PFILE_OBJECT FileObject,
|
||||
ULONG FileOffset)
|
||||
BOOLEAN Cc1AcquireCacheSegment(PCACHE_SEGMENT CacheSegment,
|
||||
BOOLEAN AcquireForWrite,
|
||||
BOOLEAN Wait)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
typedef
|
||||
|
||||
BOOLEAN Cc1RequestView(PFILE_OBJECT FileObject,
|
||||
ULONG FileOffset,
|
||||
ULONG Length,
|
||||
BOOLEAN Wait,
|
||||
BOOLEAN AcquireForWrite)
|
||||
PVOID Cc1RequestView(PCC1_CCB CacheDesc,
|
||||
ULONG FileOffset,
|
||||
ULONG Length,
|
||||
BOOLEAN Wait,
|
||||
BOOLEAN AcquireForWrite)
|
||||
/*
|
||||
* FUNCTION: Request a view for caching data
|
||||
* ARGUMENTS:
|
||||
|
@ -79,11 +85,41 @@ BOOLEAN Cc1RequestView(PFILE_OBJECT FileObject,
|
|||
* False otherwise
|
||||
*/
|
||||
{
|
||||
PLIST_ENTRY current_entry;
|
||||
PCACHE_SEGMENT current;
|
||||
|
||||
KeAcquireSpinLock(&CacheDesc->CacheSegmentListLock);
|
||||
|
||||
current_entry = CacheDesc->CacheSegmentListHead.Flink;
|
||||
while (current_entry != &CacheDesc->CacheSegmentListHead)
|
||||
{
|
||||
current = CONTAING_RECORD(current_entry, CACHE_SEGMENT, ListEntry);
|
||||
|
||||
if (current->FileOffset <= FileOffset &&
|
||||
(current->FileOffset + current->length) >= (FileOffset + Length))
|
||||
{
|
||||
if (!Cc1AcquireCacheSegment(AcquireForWrite, Wait))
|
||||
{
|
||||
return(NULL);
|
||||
}
|
||||
return(current->BaseAddress + (FileOffset - current->FileOffset));
|
||||
}
|
||||
current_entry = current_entry->Flink;
|
||||
}
|
||||
|
||||
KeReleaseSpinLock(&CacheDesc->CacheSegmentListLock);
|
||||
}
|
||||
|
||||
BOOLEAN Cc1InitializeFileCache(PFILE_OBJECT FileObject)
|
||||
PCC1_CCB Cc1InitializeFileCache(PFILE_OBJECT FileObject)
|
||||
/*
|
||||
* FUNCTION: Initialize caching for a file
|
||||
*/
|
||||
{
|
||||
PCC1_CCB CacheDesc;
|
||||
|
||||
CacheDesc = ExAllocatePool(NonPagedPool, sizeof(CC1_CCB));
|
||||
InitializeListHead(&CacheDesc->CacheSegmentListHead);
|
||||
KeAcquireSpinLock(&CacheDesc->CacheSegmentListLock);
|
||||
|
||||
return(CacheDesc);
|
||||
}
|
||||
|
|
|
@ -263,7 +263,7 @@ VOID KeDumpStackFrames(ULONG DummyArg)
|
|||
Stack = (PVOID)(((ULONG)Stack) & (~0x3));
|
||||
|
||||
DbgPrint("Frames:\n");
|
||||
for (i=0; i<1024; i++)
|
||||
for (i=0; i<32; i++)
|
||||
{
|
||||
if (Stack[i] > KERNEL_BASE && Stack[i] < ((ULONG)&etext))
|
||||
{
|
||||
|
|
|
@ -155,6 +155,17 @@ NTSTATUS KeValidateUserContext(PCONTEXT Context)
|
|||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
NTSTATUS HalReleaseTask(PETHREAD Thread)
|
||||
{
|
||||
gdt[Thread->Tcb.Context.nr/8].a=0;
|
||||
gdt[Thread->Tcb.Context.nr/8].b=0;
|
||||
ExFreePool(Thread->Tcb.Context.KernelStackBase);
|
||||
if (Thread->Tcb.Context.SavedKernelStackBase != NULL)
|
||||
{
|
||||
ExFreePool(Thread->Tcb.Context.KernelStackBase);
|
||||
}
|
||||
}
|
||||
|
||||
NTSTATUS HalInitTaskWithContext(PETHREAD Thread, PCONTEXT Context)
|
||||
/*
|
||||
* FUNCTION: Initialize a task with a user mode context
|
||||
|
@ -182,6 +193,11 @@ NTSTATUS HalInitTaskWithContext(PETHREAD Thread, PCONTEXT Context)
|
|||
}
|
||||
|
||||
desc = allocate_tss_descriptor();
|
||||
if (desc == 0)
|
||||
{
|
||||
return(STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
|
||||
length = sizeof(hal_thread_state) - 1;
|
||||
base = (unsigned int)(&(Thread->Tcb.Context));
|
||||
kernel_stack = ExAllocatePool(NonPagedPool,PAGESIZE);
|
||||
|
@ -203,7 +219,7 @@ NTSTATUS HalInitTaskWithContext(PETHREAD Thread, PCONTEXT 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 = stack_start;
|
||||
Thread->Tcb.Context.esp0 = (ULONG)stack_start;
|
||||
Thread->Tcb.Context.ss0 = KERNEL_DS;
|
||||
Thread->Tcb.Context.esp = stack_start;
|
||||
Thread->Tcb.Context.ss = KERNEL_DS;
|
||||
|
@ -218,7 +234,9 @@ NTSTATUS HalInitTaskWithContext(PETHREAD Thread, PCONTEXT Context)
|
|||
Thread->Tcb.Context.gs = KERNEL_DS;
|
||||
|
||||
Thread->Tcb.Context.nr = desc * 8;
|
||||
DPRINT("Allocated %x\n",desc*8);
|
||||
Thread->Tcb.Context.KernelStackBase = kernel_stack;
|
||||
Thread->Tcb.Context.SavedKernelEsp = 0;
|
||||
Thread->Tcb.Context.SavedKernelStackBase = NULL;
|
||||
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
@ -236,7 +254,7 @@ BOOLEAN HalInitTask(PETHREAD thread, PKSTART_ROUTINE fn, PVOID StartContext)
|
|||
unsigned int desc = allocate_tss_descriptor();
|
||||
unsigned int length = sizeof(hal_thread_state) - 1;
|
||||
unsigned int base = (unsigned int)(&(thread->Tcb.Context));
|
||||
unsigned int* kernel_stack = ExAllocatePool(NonPagedPool,4096);
|
||||
PULONG kernel_stack = ExAllocatePool(NonPagedPool,4096);
|
||||
|
||||
DPRINT("HalInitTask(Thread %x, fn %x, StartContext %x)\n",
|
||||
thread,fn,StartContext);
|
||||
|
@ -290,6 +308,9 @@ BOOLEAN HalInitTask(PETHREAD thread, PKSTART_ROUTINE fn, PVOID StartContext)
|
|||
thread->Tcb.Context.fs = KERNEL_DS;
|
||||
thread->Tcb.Context.gs = KERNEL_DS;
|
||||
thread->Tcb.Context.nr = desc * 8;
|
||||
thread->Tcb.Context.KernelStackBase = kernel_stack;
|
||||
thread->Tcb.Context.SavedKernelEsp = 0;
|
||||
thread->Tcb.Context.SavedKernelStackBase = NULL;
|
||||
DPRINT("Allocated %x\n",desc*8);
|
||||
|
||||
|
||||
|
|
|
@ -125,16 +125,14 @@ NTSTATUS ZwCreateFile(PHANDLE FileHandle,
|
|||
|
||||
|
||||
DeviceObject = (PDEVICE_OBJECT)Object;
|
||||
DPRINT("DeviceObject %x\n",DeviceObject);
|
||||
DeviceObject = IoGetAttachedDevice(DeviceObject);
|
||||
DPRINT("DeviceObject %x\n",DeviceObject);
|
||||
|
||||
if (Status == STATUS_SUCCESS)
|
||||
{
|
||||
CHECKPOINT;
|
||||
FileObject->Flags = FileObject->Flags | FO_DIRECT_DEVICE_OPEN;
|
||||
FileObject->FileName.Buffer = ExAllocatePool(NonPagedPool,
|
||||
ObjectAttributes->ObjectName->Length);
|
||||
(ObjectAttributes->ObjectName->Length+1)*2);
|
||||
FileObject->FileName.Length = ObjectAttributes->ObjectName->Length;
|
||||
FileObject->FileName.MaximumLength =
|
||||
ObjectAttributes->ObjectName->MaximumLength;
|
||||
|
@ -197,7 +195,6 @@ NTSTATUS ZwCreateFile(PHANDLE FileHandle,
|
|||
Irp = IoAllocateIrp(DeviceObject->StackSize, FALSE);
|
||||
if (Irp==NULL)
|
||||
{
|
||||
ExFreePool(FileObject->FileName.Buffer);
|
||||
ObDereferenceObject(FileObject);
|
||||
ZwClose(*FileHandle);
|
||||
*FileHandle=0;
|
||||
|
@ -223,13 +220,14 @@ 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;
|
||||
return(Status);
|
||||
}
|
||||
|
||||
DPRINT("*FileHandle %x\n",*FileHandle);
|
||||
ObDereferenceObject(FileObject);
|
||||
|
||||
return(Status);
|
||||
|
||||
|
|
|
@ -141,11 +141,12 @@ NTSTATUS STDCALL ZwQueryDirectoryFile(
|
|||
FILE_LIST_DIRECTORY,
|
||||
IoFileType,
|
||||
UserMode,
|
||||
(PVOID *)&FileObject,
|
||||
(PVOID *)&FileObject,
|
||||
NULL);
|
||||
|
||||
if (Status != STATUS_SUCCESS)
|
||||
{
|
||||
ObDereferenceObject(FileObject);
|
||||
return(Status);
|
||||
}
|
||||
KeInitializeEvent(&Event,NotificationEvent,FALSE);
|
||||
|
@ -153,7 +154,10 @@ NTSTATUS STDCALL ZwQueryDirectoryFile(
|
|||
|
||||
Irp = IoAllocateIrp(DeviceObject->StackSize, TRUE);
|
||||
if (Irp==NULL)
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
{
|
||||
ObDereferenceObject(FileObject);
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
|
||||
|
||||
Irp->UserIosb = IoStatusBlock;
|
||||
|
@ -203,6 +207,7 @@ NTSTATUS STDCALL ZwQueryDirectoryFile(
|
|||
}
|
||||
Status = IoStatusBlock->Status;
|
||||
}
|
||||
ObDereferenceObject(FileObject);
|
||||
return(Status);
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#include <ddk/ntddk.h>
|
||||
#include <internal/io.h>
|
||||
|
||||
//#define NDEBUG
|
||||
#define NDEBUG
|
||||
#include <internal/debug.h>
|
||||
|
||||
/* TYPES *******************************************************************/
|
||||
|
|
|
@ -26,6 +26,16 @@ POBJECT_TYPE IoFileType = NULL;
|
|||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
VOID IopCloseFile(PVOID ObjectBody)
|
||||
{
|
||||
PFILE_OBJECT FileObject = (PFILE_OBJECT)ObjectBody;
|
||||
|
||||
if (FileObject->FileName.Buffer != NULL)
|
||||
{
|
||||
ExFreePool(FileObject->FileName.Buffer);
|
||||
}
|
||||
}
|
||||
|
||||
VOID IoInit(VOID)
|
||||
{
|
||||
OBJECT_ATTRIBUTES attr;
|
||||
|
@ -66,7 +76,7 @@ VOID IoInit(VOID)
|
|||
IoFileType->NonpagedPoolCharge = sizeof(FILE_OBJECT);
|
||||
IoFileType->Dump = NULL;
|
||||
IoFileType->Open = NULL;
|
||||
IoFileType->Close = NULL;
|
||||
IoFileType->Close = IopCloseFile;
|
||||
IoFileType->Delete = NULL;
|
||||
IoFileType->Parse = NULL;
|
||||
IoFileType->Security = NULL;
|
||||
|
|
|
@ -61,7 +61,7 @@ VOID KeDeliverKernelApc(PKAPC Apc)
|
|||
Stack[1] = TargetThread->Context.eip;
|
||||
Stack[2] = TargetThread->Context.cs;
|
||||
Stack[3] = TargetThread->Context.eflags;
|
||||
TargetThread->Context.eip = KeApcProlog;
|
||||
TargetThread->Context.eip = (ULONG)KeApcProlog;
|
||||
TargetThread->Context.eax = (ULONG)Apc;
|
||||
}
|
||||
else
|
||||
|
@ -78,7 +78,7 @@ VOID KeDeliverKernelApc(PKAPC Apc)
|
|||
Stack[2] = TargetThread->Context.cs;
|
||||
Stack[1] = TargetThread->Context.eip;
|
||||
Stack[0] = TargetThread->Context.eax;
|
||||
TargetThread->Context.eip = KeApcProlog;
|
||||
TargetThread->Context.eip = (ULONG)KeApcProlog;
|
||||
TargetThread->Context.eax = (ULONG)Apc;
|
||||
}
|
||||
|
||||
|
|
|
@ -46,8 +46,7 @@ LONG KeSetEvent(PKEVENT Event, KPRIORITY Increment, BOOLEAN Wait)
|
|||
|
||||
DPRINT("KeSetEvent(Event %x, Wait %x)\n",Event,Wait);
|
||||
KeAcquireDispatcherDatabaseLock(Wait);
|
||||
// ret = InterlockedExchange(&(Event->Header.SignalState),1);
|
||||
Event->Header.SignalState=1;
|
||||
ret = InterlockedExchange(&(Event->Header.SignalState),1);
|
||||
KeDispatcherObjectWake((DISPATCHER_HEADER *)Event);
|
||||
KeReleaseDispatcherDatabaseLock(Wait);
|
||||
}
|
||||
|
|
|
@ -532,9 +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);
|
||||
// sprintf(str,"%.8u %.8u",PiNrThreads,KiTimerTicks);
|
||||
for (i=0;i<17;i++)
|
||||
{
|
||||
*vidmem=str[i];
|
||||
|
|
|
@ -177,9 +177,9 @@ NTSTATUS ZwQueryDirectoryObject(IN HANDLE DirObjHandle,
|
|||
current = CONTAINING_RECORD(current_entry,OBJECT_HEADER,Entry);
|
||||
DPRINT("Scanning %w\n",current->Name.Buffer);
|
||||
DirObjInformation[i].ObjectName.Buffer =
|
||||
ExAllocatePool(NonPagedPool, current->Name.Length + sizeof(WCHAR));
|
||||
ExAllocatePool(NonPagedPool,(current->Name.Length+1)*2);
|
||||
DirObjInformation[i].ObjectName.Length = current->Name.Length;
|
||||
DirObjInformation[i].ObjectName.MaximumLength = current->Name.Length + sizeof(WCHAR);
|
||||
DirObjInformation[i].ObjectName.MaximumLength = current->Name.Length;
|
||||
DPRINT("DirObjInformation[i].ObjectName.Buffer %x\n",
|
||||
DirObjInformation[i].ObjectName.Buffer);
|
||||
RtlCopyUnicodeString(&DirObjInformation[i].ObjectName,
|
||||
|
@ -552,4 +552,3 @@ NTSTATUS ObLookupObject(HANDLE rootdir, PWSTR string, PVOID* Object,
|
|||
return(Status);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -61,6 +61,14 @@ NTSTATUS STDCALL ZwQueryObject(IN HANDLE ObjectHandle,
|
|||
UNIMPLEMENTED
|
||||
}
|
||||
|
||||
VOID ObMakeTemporaryObject(PVOID ObjectBody)
|
||||
{
|
||||
POBJECT_HEADER ObjectHeader;
|
||||
|
||||
ObjectHeader = BODY_TO_HEADER(ObjectBody);
|
||||
ObjectHeader->Permanent = FALSE;
|
||||
}
|
||||
|
||||
NTSTATUS NtMakeTemporaryObject(HANDLE Handle)
|
||||
{
|
||||
return(ZwMakeTemporaryObject(Handle));
|
||||
|
@ -148,14 +156,13 @@ PVOID ObGenericCreateObject(PHANDLE Handle,
|
|||
// DbgPrint("ObjectAttributes->ObjectName->MaximumLength %d\n",
|
||||
// ObjectAttributes->ObjectName->MaximumLength);
|
||||
Buffer = ExAllocatePool(NonPagedPool,
|
||||
((ObjectAttributes->ObjectName->Length + 1) *
|
||||
sizeof(WCHAR)));
|
||||
((ObjectAttributes->ObjectName->Length+1)*2));
|
||||
if (Buffer==NULL)
|
||||
{
|
||||
return(NULL);
|
||||
}
|
||||
memcpy(Buffer, ObjectAttributes->ObjectName->Buffer,
|
||||
(ObjectAttributes->ObjectName->Length + 1) * sizeof(WCHAR));
|
||||
(ObjectAttributes->ObjectName->Length+1)*2);
|
||||
|
||||
/*
|
||||
* Seperate the name into a path and name
|
||||
|
@ -255,13 +262,27 @@ NTSTATUS ObReferenceObjectByPointer(PVOID ObjectBody,
|
|||
|
||||
NTSTATUS ObPerformRetentionChecks(POBJECT_HEADER Header)
|
||||
{
|
||||
DPRINT("ObPerformRetentionChecks(Header %x), RefCount %d, HandleCount %d\n",
|
||||
Header,Header->RefCount,Header->HandleCount);
|
||||
|
||||
if (Header->RefCount < 0 || Header->HandleCount < 0)
|
||||
{
|
||||
KeBugCheck(0);
|
||||
}
|
||||
|
||||
if (Header->RefCount == 0 && Header->HandleCount == 0 &&
|
||||
!Header->Permanent)
|
||||
{
|
||||
if (Header->ObjectType != NULL &&
|
||||
Header->ObjectType->Close != NULL)
|
||||
{
|
||||
Header->ObjectType->Close(HEADER_TO_BODY(Header));
|
||||
}
|
||||
if (Header->Name.Buffer != NULL)
|
||||
{
|
||||
ObRemoveEntry(Header);
|
||||
}
|
||||
DPRINT("ObPerformRetentionChecks() = Freeing object\n");
|
||||
ExFreePool(Header);
|
||||
}
|
||||
return(STATUS_SUCCESS);
|
||||
|
@ -304,6 +325,8 @@ NTSTATUS ZwClose(HANDLE Handle)
|
|||
|
||||
assert_irql(PASSIVE_LEVEL);
|
||||
|
||||
DPRINT("ZwClose(Handle %x)\n",Handle);
|
||||
|
||||
HandleRep = ObTranslateHandle(KeGetCurrentProcess(),Handle);
|
||||
if (HandleRep == NULL)
|
||||
{
|
||||
|
@ -386,4 +409,3 @@ NTSTATUS ObReferenceObjectByHandle(HANDLE Handle,
|
|||
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,31 @@ extern ULONG PiNrThreads;
|
|||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
VOID PsTerminateCurrentThread(NTSTATUS ExitStatus)
|
||||
{
|
||||
KIRQL oldlvl;
|
||||
PETHREAD CurrentThread;
|
||||
|
||||
PiNrThreads--;
|
||||
|
||||
CurrentThread = PsGetCurrentThread();
|
||||
|
||||
CurrentThread->ExitStatus = ExitStatus;
|
||||
|
||||
DPRINT("terminating %x\n",CurrentThread);
|
||||
ObDereferenceObject(CurrentThread->ThreadsProcess);
|
||||
KeRaiseIrql(DISPATCH_LEVEL,&oldlvl);
|
||||
CurrentThread->Tcb.ThreadState = THREAD_STATE_TERMINATED;
|
||||
ZwYieldExecution();
|
||||
for(;;);
|
||||
}
|
||||
|
||||
VOID PsTerminateOtherThread(PETHREAD Thread, NTSTATUS ExitStatus)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS STDCALL NtTerminateProcess(IN HANDLE ProcessHandle,
|
||||
IN NTSTATUS ExitStatus)
|
||||
{
|
||||
|
@ -54,7 +79,7 @@ NTSTATUS STDCALL ZwTerminateProcess(IN HANDLE ProcessHandle,
|
|||
if (PsGetCurrentThread()->ThreadsProcess == Process)
|
||||
{
|
||||
KeLowerIrql(oldlvl);
|
||||
PsTerminateSystemThread(ExitStatus);
|
||||
PsTerminateCurrentThread(ExitStatus);
|
||||
}
|
||||
KeLowerIrql(oldlvl);
|
||||
return(STATUS_SUCCESS);
|
||||
|
@ -84,18 +109,13 @@ NTSTATUS STDCALL ZwTerminateThread(IN HANDLE ThreadHandle,
|
|||
return(Status);
|
||||
}
|
||||
|
||||
PsTerminateThread(Thread);
|
||||
}
|
||||
|
||||
VOID PsTerminateThread(PETHREAD Thread, NTSTATUS ExitStatus)
|
||||
{
|
||||
if (Thread == PsGetCurrentThread())
|
||||
{
|
||||
PsTerminateSystemThread(ExitStatus);
|
||||
PsTerminateCurrentThread(ExitStatus);
|
||||
}
|
||||
else
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
PsTerminateOtherThread(Thread, ExitStatus);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -104,6 +124,7 @@ VOID PsReleaseThread(PETHREAD Thread)
|
|||
DPRINT("PsReleaseThread(Thread %x)\n",Thread);
|
||||
|
||||
RemoveEntryList(&Thread->Tcb.Entry);
|
||||
HalReleaseTask(Thread);
|
||||
ObDereferenceObject(Thread);
|
||||
}
|
||||
|
||||
|
@ -116,21 +137,7 @@ NTSTATUS PsTerminateSystemThread(NTSTATUS ExitStatus)
|
|||
* RETURNS: Doesn't
|
||||
*/
|
||||
{
|
||||
KIRQL oldlvl;
|
||||
PETHREAD CurrentThread;
|
||||
|
||||
PiNrThreads--;
|
||||
|
||||
CurrentThread = PsGetCurrentThread();
|
||||
|
||||
CurrentThread->ExitStatus = ExitStatus;
|
||||
|
||||
DPRINT("terminating %x\n",CurrentThread);
|
||||
ObDereferenceObject(CurrentThread->ThreadsProcess);
|
||||
KeRaiseIrql(DISPATCH_LEVEL,&oldlvl);
|
||||
CurrentThread->Tcb.ThreadState = THREAD_STATE_TERMINATED;
|
||||
ZwYieldExecution();
|
||||
for(;;);
|
||||
PsTerminateCurrentThread(ExitStatus);
|
||||
}
|
||||
|
||||
NTSTATUS STDCALL NtRegisterThreadTerminatePort(HANDLE TerminationPort)
|
||||
|
|
|
@ -310,4 +310,3 @@ NTSTATUS STDCALL ZwSetInformationProcess(IN HANDLE ProcessHandle,
|
|||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ VOID PiTerminateProcessThreads(PEPROCESS Process, NTSTATUS ExitStatus)
|
|||
if (current->ThreadsProcess == Process &&
|
||||
current != PsGetCurrentThread())
|
||||
{
|
||||
PsTerminateThread(current, ExitStatus);
|
||||
PsTerminateOtherThread(current, ExitStatus);
|
||||
}
|
||||
current_entry = current_entry->Flink;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue