mirror of
https://github.com/reactos/reactos.git
synced 2024-12-29 02:25:17 +00:00
Rolled in various changes from others
svn path=/trunk/; revision=108
This commit is contained in:
parent
159ee3800d
commit
37af92952e
61 changed files with 7805 additions and 658 deletions
|
@ -1,8 +1,9 @@
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS version of ntdll
|
* PROJECT: ReactOS version of ntdll
|
||||||
* FILE: lib/ntdll/genntdll.c
|
* FILE: iface/native/genntdll.c
|
||||||
* PURPOSE: Generates the system call stubs in ntdll
|
* PURPOSE: Generates the system call stubs in ntdll
|
||||||
|
* CHANGE HISTORY: Added a '@xx' to deal with stdcall [ Ariadne ]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* INCLUDE ******************************************************************/
|
/* INCLUDE ******************************************************************/
|
||||||
|
@ -29,6 +30,7 @@ int process(FILE* in, FILE* out, FILE *out2)
|
||||||
fprintf(out,"; Machine generated, don't edit\n");
|
fprintf(out,"; Machine generated, don't edit\n");
|
||||||
fprintf(out,"\n\n");
|
fprintf(out,"\n\n");
|
||||||
fprintf(out,"SECTION .text\n\n");
|
fprintf(out,"SECTION .text\n\n");
|
||||||
|
fprintf(out,"BITS 32\n\n");
|
||||||
|
|
||||||
fprintf(out2,"// Machine generated, don't edit\n");
|
fprintf(out2,"// Machine generated, don't edit\n");
|
||||||
fprintf(out2,"\n\n");
|
fprintf(out2,"\n\n");
|
||||||
|
@ -41,12 +43,12 @@ int process(FILE* in, FILE* out, FILE *out2)
|
||||||
while (!feof(in) && fgets(line,255,in) != NULL)
|
while (!feof(in) && fgets(line,255,in) != NULL)
|
||||||
{
|
{
|
||||||
// fgets(line,255,in);
|
// fgets(line,255,in);
|
||||||
if ((s=(char *)strchr(line,'\n'))!=NULL)
|
if ((s=(char *)strchr(line,13))!=NULL)
|
||||||
{
|
{
|
||||||
*s=0;
|
*s=0;
|
||||||
}
|
}
|
||||||
s=&line[0];
|
s=&line[0];
|
||||||
if ((*s)!='#')
|
if ((*s)!='#' && (*s) != 0)
|
||||||
{
|
{
|
||||||
name = (char *)strtok(s," \t");
|
name = (char *)strtok(s," \t");
|
||||||
name2 = (char *)strtok(NULL," \t");
|
name2 = (char *)strtok(NULL," \t");
|
||||||
|
@ -54,10 +56,10 @@ int process(FILE* in, FILE* out, FILE *out2)
|
||||||
nr_args = (char *)strtok(NULL," \t");
|
nr_args = (char *)strtok(NULL," \t");
|
||||||
|
|
||||||
// printf("name %s value %d\n",name,value);
|
// printf("name %s value %d\n",name,value);
|
||||||
fprintf(out,"GLOBAL _%s\n",name);
|
fprintf(out,"GLOBAL _%s@%s\n",name,nr_args);
|
||||||
fprintf(out,"GLOBAL _%s\n",name2);
|
fprintf(out,"GLOBAL _%s@%s\n",name2,nr_args);
|
||||||
fprintf(out,"_%s:\n",name);
|
fprintf(out,"_%s@%s:\n",name,nr_args);
|
||||||
fprintf(out,"_%s:\n",name2);
|
fprintf(out,"_%s@%s:\n",name2,nr_args);
|
||||||
fprintf(out,"\tmov\teax,%d\n",value);
|
fprintf(out,"\tmov\teax,%d\n",value);
|
||||||
fprintf(out,"\tlea\tedx,[esp+4]\n");
|
fprintf(out,"\tlea\tedx,[esp+4]\n");
|
||||||
fprintf(out,"\tint\t2Eh\n");
|
fprintf(out,"\tint\t2Eh\n");
|
||||||
|
|
|
@ -6,7 +6,7 @@ all: genntdll$(EXE_POSTFIX) ../../lib/ntdll/napi.asm
|
||||||
../../include/ntdll/napi.h: dummy
|
../../include/ntdll/napi.h: dummy
|
||||||
|
|
||||||
genntdll$(EXE_POSTFIX): genntdll.c
|
genntdll$(EXE_POSTFIX): genntdll.c
|
||||||
$(NATIVE_CC) -g genntdll.c -o genntdll$(EXE_POSTFIX)
|
$(NATIVE_CC) -If:\gnu\mingw32\include -g genntdll.c -o genntdll$(EXE_POSTFIX)
|
||||||
|
|
||||||
sysfuncs.lst: dummy
|
sysfuncs.lst: dummy
|
||||||
|
|
||||||
|
|
|
@ -208,3 +208,4 @@ NtReplyWaitSendChannel ZwReplyWaitSendChannel 12
|
||||||
NtSendWaitReplyChannel ZwSendWaitReplyChannel 16
|
NtSendWaitReplyChannel ZwSendWaitReplyChannel 16
|
||||||
NtSetContextChannel ZwSetContextChannel 4
|
NtSetContextChannel ZwSetContextChannel 4
|
||||||
NtYieldExecution ZwYieldExecution 0
|
NtYieldExecution ZwYieldExecution 0
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,19 @@
|
||||||
#ifndef __INCLUDE_DDK_PSTYPES_H
|
#ifndef __INCLUDE_DDK_PSTYPES_H
|
||||||
#define __INCLUDE_DDK_PSTYPES_H
|
#define __INCLUDE_DDK_PSTYPES_H
|
||||||
|
|
||||||
|
#undef WIN32_LEAN_AND_MEAN
|
||||||
|
#include <windows.h> // might be redundant
|
||||||
#include <kernel32/heap.h>
|
#include <kernel32/heap.h>
|
||||||
|
#include <kernel32/atom.h>
|
||||||
#include <internal/hal.h>
|
#include <internal/hal.h>
|
||||||
|
|
||||||
|
#ifndef TLS_MINIMUM_AVAILABLE
|
||||||
|
#define TLS_MINIMUM_AVAILABLE (64)
|
||||||
|
#endif
|
||||||
|
#ifndef MAX_PATH
|
||||||
|
#define MAX_PATH (260)
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef NTSTATUS (*PKSTART_ROUTINE)(PVOID StartContext);
|
typedef NTSTATUS (*PKSTART_ROUTINE)(PVOID StartContext);
|
||||||
|
|
||||||
typedef struct _STACK_INFORMATION
|
typedef struct _STACK_INFORMATION
|
||||||
|
@ -39,17 +49,34 @@ typedef struct linux_sigcontext {
|
||||||
|
|
||||||
typedef ULONG THREADINFOCLASS;
|
typedef ULONG THREADINFOCLASS;
|
||||||
|
|
||||||
typedef void* ATOMTABLE;
|
typedef struct _STARTUPINFOW {
|
||||||
|
DWORD cb;
|
||||||
|
WCHAR WindowTitle[MAX_PATH];
|
||||||
|
WCHAR ImageFile[MAX_PATH];
|
||||||
|
WCHAR CommandLine[MAX_PATH];
|
||||||
|
WCHAR DllPath[MAX_PATH];
|
||||||
|
LPWSTR Reserved[MAX_PATH];
|
||||||
|
LPWSTR Desktop[MAX_PATH];
|
||||||
|
LPWSTR Title[MAX_PATH];
|
||||||
|
DWORD dwX;
|
||||||
|
DWORD dwY;
|
||||||
|
DWORD dwXSize;
|
||||||
|
DWORD dwYSize;
|
||||||
|
DWORD dwXCountChars;
|
||||||
|
DWORD dwYCountChars;
|
||||||
|
DWORD dwFillAttribute;
|
||||||
|
DWORD dwFlags;
|
||||||
|
WORD wShowWindow;
|
||||||
|
WORD cbReserved2;
|
||||||
|
unsigned char * lpReserved2;
|
||||||
|
HANDLE hStdInput;
|
||||||
|
HANDLE hStdOutput;
|
||||||
|
HANDLE hStdError;
|
||||||
|
} PROCESSINFOW, *PPROCESSINFOW;
|
||||||
|
|
||||||
typedef struct _pPebInfo {
|
|
||||||
WCHAR* WindowTitle;
|
|
||||||
WCHAR* ImageFile;
|
|
||||||
WCHAR* CommandLine;
|
|
||||||
WCHAR* DllPath;
|
|
||||||
// STARTUPINFOW StartupInfo;
|
|
||||||
} PEBINFO;
|
|
||||||
|
|
||||||
typedef struct _LDR_ {
|
|
||||||
|
typedef struct _LDR {
|
||||||
UCHAR Initialized;
|
UCHAR Initialized;
|
||||||
UCHAR InInitializationOrderModuleList;
|
UCHAR InInitializationOrderModuleList;
|
||||||
PVOID InLoadOrderModuleList;
|
PVOID InLoadOrderModuleList;
|
||||||
|
@ -64,15 +91,11 @@ typedef struct _NT_PEB
|
||||||
UCHAR BeingDebugged;
|
UCHAR BeingDebugged;
|
||||||
LONG ImageBaseAddress;
|
LONG ImageBaseAddress;
|
||||||
LDR Ldr;
|
LDR Ldr;
|
||||||
DWORD dwTlsBits[2]; // tls in use bits
|
|
||||||
WORD NumberOfProcessors;
|
WORD NumberOfProcessors;
|
||||||
WORD NtGlobalFlag;
|
WORD NtGlobalFlag;
|
||||||
DWORD HeapReserve;
|
|
||||||
DWORD HeapCommit;
|
PPROCESSINFOW StartupInfo;
|
||||||
DWORD HeapDecommitFreeBlockThreshold;
|
|
||||||
DWORD NumberOfHeaps;
|
|
||||||
DWORD MaxiumNumberOfHeaps;
|
|
||||||
PEBINFO* PebInfo;
|
|
||||||
PHEAP ProcessHeap;
|
PHEAP ProcessHeap;
|
||||||
ATOMTABLE LocalAtomTable;
|
ATOMTABLE LocalAtomTable;
|
||||||
LPCRITICAL_SECTION CriticalSection;
|
LPCRITICAL_SECTION CriticalSection;
|
||||||
|
@ -108,8 +131,9 @@ typedef struct _NT_TEB
|
||||||
NT_TIB Tib;
|
NT_TIB Tib;
|
||||||
CLIENT_ID Cid;
|
CLIENT_ID Cid;
|
||||||
HANDLE RPCHandle;
|
HANDLE RPCHandle;
|
||||||
PVOID TlsData;
|
PVOID TlsData[TLS_MINIMUM_AVAILABLE];
|
||||||
NT_PEB *pPeb;
|
DWORD dwTlsIndex;
|
||||||
|
NT_PEB *Peb;
|
||||||
DWORD LastErrorCode;
|
DWORD LastErrorCode;
|
||||||
NTSTATUS LastStatusValue;
|
NTSTATUS LastStatusValue;
|
||||||
DWORD LockCount;
|
DWORD LockCount;
|
||||||
|
@ -154,61 +178,19 @@ typedef struct _KTHREAD
|
||||||
|
|
||||||
|
|
||||||
// According to documentation the stack should have a commited [ 1 page ] and
|
// According to documentation the stack should have a commited [ 1 page ] and
|
||||||
// a reserved part [ 1 M ].
|
// a reserved part [ 1 M ] but can be specified otherwise in the image file.
|
||||||
|
|
||||||
typedef struct _INITIAL_TEB {
|
typedef struct _INITIAL_TEB {
|
||||||
|
PVOID StackBase;
|
||||||
|
PVOID StackLimit;
|
||||||
PVOID StackCommit;
|
PVOID StackCommit;
|
||||||
|
PVOID StackCommitMax;
|
||||||
PVOID StackReserved;
|
PVOID StackReserved;
|
||||||
} INITIAL_TEB, *PINITIAL_TEB;
|
} INITIAL_TEB, *PINITIAL_TEB;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//ThreadState defines the current state of a thread
|
|
||||||
//FIXME I am allready defined in psmgr.h as a enum
|
|
||||||
/*
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
THREAD_STATE_INITIALIZED = 0,
|
|
||||||
THREAD_STATE_READY,
|
|
||||||
THREAD_STATE_RUNNING,
|
|
||||||
THREAD_STATE_STANDBY,
|
|
||||||
THREAD_STATE_TERMINATED,
|
|
||||||
THREAD_STATE_WAIT,
|
|
||||||
THREAD_STATE_TRANSITION,
|
|
||||||
THREAD_STATE_RESERVED
|
|
||||||
};
|
|
||||||
*/
|
|
||||||
|
|
||||||
// wait reason only applies for threads in a wait state
|
|
||||||
// part of this enum is double ????
|
|
||||||
|
|
||||||
/*
|
|
||||||
typedef _KWAIT_REASON
|
|
||||||
{
|
|
||||||
WAIT_EXCECUTIVE1 = 0,
|
|
||||||
WAIT_FREE_PAGE1,
|
|
||||||
WAIT_PAGE_IN1,
|
|
||||||
WAIT_POOL_ALLOCATION1,
|
|
||||||
WAIT_EXECUTION_DELAY1,
|
|
||||||
WAIT_SUSPENDED_CONDITION1,
|
|
||||||
WAIT_USER_REQUEST1,
|
|
||||||
WAIT_EXCECUTIVE2,
|
|
||||||
WAIT_FREE_PAGE2,
|
|
||||||
WAIT_PAGE_IN2,
|
|
||||||
WAIT_POOL_ALLOCATION2,
|
|
||||||
WAIT_EXECUTION_DELAY2,
|
|
||||||
WAIT_SUSPENDED_CONDITION2,
|
|
||||||
WAIT_USER_REQUEST2,
|
|
||||||
WAIT_EVENT_PAIR_HIGH,
|
|
||||||
WAIT_EVENT_PAIR_LOW,
|
|
||||||
WAIT_LPC_RECEIVE,
|
|
||||||
WAIT_LPC_REPLY,
|
|
||||||
WAIT_VIRTUAL_MEMORY,
|
|
||||||
WAIT_PAGE_OUT
|
|
||||||
} KWAIT_REASON;
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
// TopLevelIrp can be one of the following values:
|
// TopLevelIrp can be one of the following values:
|
||||||
|
@ -263,7 +245,8 @@ typedef struct _KPROCESS
|
||||||
TIME ElapsedTime;
|
TIME ElapsedTime;
|
||||||
TIME KernelTime;
|
TIME KernelTime;
|
||||||
TIME UserTime;
|
TIME UserTime;
|
||||||
LIST_ENTRY InOutSwap; // ??
|
LIST_ENTRY InMemoryList;
|
||||||
|
LIST_ENTRY SwappedOutList;
|
||||||
KSPIN_LOCK SpinLock;
|
KSPIN_LOCK SpinLock;
|
||||||
KAFFINITY Affinity;
|
KAFFINITY Affinity;
|
||||||
ULONG StackCount;
|
ULONG StackCount;
|
||||||
|
|
|
@ -153,6 +153,8 @@ LONG RtlCompareString(PSTRING String1, PSTRING String2,
|
||||||
LONG RtlCompareUnicodeString(PUNICODE_STRING String1,
|
LONG RtlCompareUnicodeString(PUNICODE_STRING String1,
|
||||||
PUNICODE_STRING String2,
|
PUNICODE_STRING String2,
|
||||||
BOOLEAN BaseInsensitive);
|
BOOLEAN BaseInsensitive);
|
||||||
|
LARGE_INTEGER RtlConvertLongToLargeInteger(LONG SignedInteger);
|
||||||
|
LARGE_INTEGER RtlConvertUlongToLargeInteger(ULONG UnsignedInteger);
|
||||||
VOID RtlCopyBytes(PVOID Destination, CONST VOID* Source, ULONG Length);
|
VOID RtlCopyBytes(PVOID Destination, CONST VOID* Source, ULONG Length);
|
||||||
VOID RtlCopyMemory(VOID* Destination, VOID* Source, ULONG Length);
|
VOID RtlCopyMemory(VOID* Destination, VOID* Source, ULONG Length);
|
||||||
VOID RtlCopyString(PSTRING DestinationString, PSTRING SourceString);
|
VOID RtlCopyString(PSTRING DestinationString, PSTRING SourceString);
|
||||||
|
@ -165,12 +167,27 @@ NTSTATUS RtlCreateSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor,
|
||||||
NTSTATUS RtlDeleteRegistryValue(ULONG RelativeTo,
|
NTSTATUS RtlDeleteRegistryValue(ULONG RelativeTo,
|
||||||
PWSTR Path,
|
PWSTR Path,
|
||||||
PWSTR ValueName);
|
PWSTR ValueName);
|
||||||
|
LARGE_INTEGER RtlEnlargedIntegerMultiply(LONG Multiplicand,
|
||||||
|
LONG Multiplier);
|
||||||
|
ULONG RtlEnlargedUnsignedDivide(ULARGE_INTEGER Dividend,
|
||||||
|
ULONG Divisor,
|
||||||
|
PULONG Remainder);
|
||||||
|
LARGE_INTEGER RtlEnlargedUnsignedMultiply(ULONG Multiplicand,
|
||||||
|
ULONG Multiplier);
|
||||||
BOOLEAN RtlEqualString(PSTRING String1,
|
BOOLEAN RtlEqualString(PSTRING String1,
|
||||||
PSTRING String2,
|
PSTRING String2,
|
||||||
BOOLEAN CaseInSensitive);
|
BOOLEAN CaseInSensitive);
|
||||||
BOOLEAN RtlEqualUnicodeString(PUNICODE_STRING String1,
|
BOOLEAN RtlEqualUnicodeString(PUNICODE_STRING String1,
|
||||||
PUNICODE_STRING String2,
|
PUNICODE_STRING String2,
|
||||||
BOOLEAN CaseInSensitive);
|
BOOLEAN CaseInSensitive);
|
||||||
|
LARGE_INTEGER RtlExtendedIntegerMultiply(LARGE_INTEGER Multiplicand,
|
||||||
|
LONG Multiplier);
|
||||||
|
LARGE_INTEGER RtlExtendedLargeIntegerDivide(LARGE_INTEGER Dividend,
|
||||||
|
ULONG Divisor,
|
||||||
|
PULONG Remainder);
|
||||||
|
LARGE_INTEGER RtlExtendedMagicDivide(LARGE_INTEGER Dividend,
|
||||||
|
LARGE_INTEGER MagicDivisor,
|
||||||
|
CCHAR ShiftCount);
|
||||||
VOID RtlFillMemory(PVOID Destination, ULONG Length, UCHAR Fill);
|
VOID RtlFillMemory(PVOID Destination, ULONG Length, UCHAR Fill);
|
||||||
VOID RtlFreeAnsiString(PANSI_STRING AnsiString);
|
VOID RtlFreeAnsiString(PANSI_STRING AnsiString);
|
||||||
VOID RtlFreeUnicodeString(PUNICODE_STRING UnicodeString);
|
VOID RtlFreeUnicodeString(PUNICODE_STRING UnicodeString);
|
||||||
|
@ -182,8 +199,13 @@ VOID RtlInitUnicodeString(PUNICODE_STRING DestinationString,
|
||||||
NTSTATUS RtlIntegerToUnicodeString(ULONG Value,
|
NTSTATUS RtlIntegerToUnicodeString(ULONG Value,
|
||||||
ULONG Base,
|
ULONG Base,
|
||||||
PUNICODE_STRING String);
|
PUNICODE_STRING String);
|
||||||
|
LARGE_INTEGER RtlLargeIntegerAdd(LARGE_INTEGER Addend1,
|
||||||
|
LARGE_INTEGER Addend2);
|
||||||
|
VOID RtlLargeIntegerAnd(PLARGE_INTEGER Result,
|
||||||
|
LARGE_INTEGER Source,
|
||||||
|
LARGE_INTEGER Mask);
|
||||||
|
|
||||||
/** LARGE_INTEGER Functions *******************************************/
|
/* MISSING FUNCTIONS GO HERE */
|
||||||
LARGE_INTEGER RtlConvertLongToLargeInteger(LONG SignedInteger);
|
LARGE_INTEGER RtlConvertLongToLargeInteger(LONG SignedInteger);
|
||||||
LARGE_INTEGER RtlConvertUlongToLargeInteger(ULONG UnsignedInteger);
|
LARGE_INTEGER RtlConvertUlongToLargeInteger(ULONG UnsignedInteger);
|
||||||
LARGE_INTEGER RtlEnlargedIntegerMultiply(LONG Multiplicand,
|
LARGE_INTEGER RtlEnlargedIntegerMultiply(LONG Multiplicand,
|
||||||
|
@ -240,8 +262,6 @@ LARGE_INTEGER RtlLargeIntegerShiftRight(LARGE_INTEGER LargeInteger,
|
||||||
LARGE_INTEGER RtlLargeIntegerSubtract(LARGE_INTEGER Minuend,
|
LARGE_INTEGER RtlLargeIntegerSubtract(LARGE_INTEGER Minuend,
|
||||||
LARGE_INTEGER Subtrahend);
|
LARGE_INTEGER Subtrahend);
|
||||||
|
|
||||||
/* MISSING FUNCTIONS GO HERE */
|
|
||||||
|
|
||||||
ULONG RtlLengthSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor);
|
ULONG RtlLengthSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor);
|
||||||
VOID RtlMoveMemory(PVOID Destination, CONST VOID* Source, ULONG Length);
|
VOID RtlMoveMemory(PVOID Destination, CONST VOID* Source, ULONG Length);
|
||||||
NTSTATUS RtlQueryRegistryValues(ULONG RelativeTo,
|
NTSTATUS RtlQueryRegistryValues(ULONG RelativeTo,
|
||||||
|
@ -324,5 +344,10 @@ VOID RtlStoreUlong(PULONG Address,
|
||||||
ULONG Value);
|
ULONG Value);
|
||||||
|
|
||||||
|
|
||||||
|
DWORD RtlNtStatusToDosError(NTSTATUS StatusCode);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* __DDK_RTL_H */
|
#endif /* __DDK_RTL_H */
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -265,8 +265,8 @@ typedef struct _OBJECT_NAME_INFORMATION
|
||||||
|
|
||||||
typedef struct _OBJECT_DATA_INFORMATION
|
typedef struct _OBJECT_DATA_INFORMATION
|
||||||
{
|
{
|
||||||
BOOL bInheritHanlde;
|
BOOLEAN bInheritHandle;
|
||||||
BOOL bProtectFromClose;
|
BOOLEAN bProtectFromClose;
|
||||||
} OBJECT_DATA_INFORMATION, *POBJECT_DATA_INFORMATION;
|
} OBJECT_DATA_INFORMATION, *POBJECT_DATA_INFORMATION;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,12 @@
|
||||||
|
/*
|
||||||
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
|
* PROJECT: ReactOS system libraries
|
||||||
|
* FILE: include/kernel32/atom.h
|
||||||
|
* PURPOSE: Include file for lib/kernel32/atom.c
|
||||||
|
* PROGRAMMER: Ariadne ( ariadne@xs4all.nl)
|
||||||
|
* UPDATE HISTORY:
|
||||||
|
* Created 01/11/98
|
||||||
|
*/
|
||||||
/********************************************************************
|
/********************************************************************
|
||||||
|
|
||||||
|
|
||||||
|
@ -24,7 +32,7 @@ Cambridge, MA 02139, USA.
|
||||||
#define Atoms__h
|
#define Atoms__h
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <ctype.h>
|
//#include <ctype.h>
|
||||||
//#include <types.h>
|
//#include <types.h>
|
||||||
|
|
||||||
|
|
||||||
|
@ -40,18 +48,11 @@ typedef ATOMENTRY *LPATOMENTRY;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
ATOMENTRY *AtomTable; /* pointer to table data */
|
ATOMENTRY *AtomTable; /* pointer to table data */
|
||||||
wchar_t *AtomData; /* pointer to name data */
|
WCHAR *AtomData; /* pointer to name data */
|
||||||
unsigned long TableSize; /* number items in this table */
|
unsigned long TableSize; /* number items in this table */
|
||||||
unsigned long DataSize; /* space used by string data */
|
unsigned long DataSize; /* space used by string data */
|
||||||
LPVOID lpDrvData;
|
LPVOID lpDrvData;
|
||||||
} ATOMTABLE;
|
} ATOMTABLE;
|
||||||
typedef ATOMTABLE *LPATOMTABLE;
|
typedef ATOMTABLE *LPATOMTABLE;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* Atoms__h */
|
#endif /* Atoms__h */
|
||||||
|
|
20
reactos/include/kernel32/li.h
Normal file
20
reactos/include/kernel32/li.h
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
/*
|
||||||
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
|
* PROJECT: ReactOS system libraries
|
||||||
|
* FILE: include/kernel32/li.h
|
||||||
|
* PURPOSE: Include file for lib/kernel32 to discard large integers
|
||||||
|
* PROGRAMMER: Ariadne ( ariadne@xs4all.nl)
|
||||||
|
* UPDATE HISTORY:
|
||||||
|
* Created 01/11/98
|
||||||
|
*/
|
||||||
|
#ifdef COMPILER_LARGE_INTEGERS
|
||||||
|
#define GET_LARGE_INTEGER_HIGH_PART(LargeInteger) ( ( LargeInteger >> 32) )
|
||||||
|
#define GET_LARGE_INTEGER_LOW_PART(LargeInteger) ( (LargeInteger & 0xFFFFFFFF) )
|
||||||
|
#define SET_LARGE_INTEGER_HIGH_PART(LargeInteger,Signed_Long) ( LargeInteger |= ( ((LARGE_INTEGER)Signed_Long) << 32 ) )
|
||||||
|
#define SET_LARGE_INTEGER_LOW_PART(LargeInteger,Unsigned_Long) ( LargeInteger |= Unsigned_Long )
|
||||||
|
#else
|
||||||
|
#define GET_LARGE_INTEGER_HIGH_PART(LargeInteger) ( ( LargeInteger.HighPart) )
|
||||||
|
#define GET_LARGE_INTEGER_LOW_PART(LargeInteger) ( (LargeInteger.LowPart) )
|
||||||
|
#define SET_LARGE_INTEGER_HIGH_PART(LargeInteger,Signed_Long) ( LargeInteger.HighPart= Signed_Long )
|
||||||
|
#define SET_LARGE_INTEGER_LOW_PART(LargeInteger,Unsigned_Long) ( LargeInteger.LowPart = Unsigned_Long )
|
||||||
|
#endif
|
25
reactos/include/kernel32/proc.h
Normal file
25
reactos/include/kernel32/proc.h
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
/*
|
||||||
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
|
* PROJECT: ReactOS system libraries
|
||||||
|
* FILE: include/kernel32/process.h
|
||||||
|
* PURPOSE: Include file for lib/kernel32/proc.c
|
||||||
|
* PROGRAMMER: Ariadne ( ariadne@xs4all.nl)
|
||||||
|
* UPDATE HISTORY:
|
||||||
|
* Created 01/11/98
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
#include <ddk/ntddk.h>
|
||||||
|
|
||||||
|
|
||||||
|
NT_PEB *GetCurrentPeb(VOID);
|
||||||
|
|
||||||
|
typedef
|
||||||
|
DWORD
|
||||||
|
(*WaitForInputIdleType)(
|
||||||
|
HANDLE hProcess,
|
||||||
|
DWORD dwMilliseconds);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,56 +1,15 @@
|
||||||
/*
|
/*
|
||||||
This file contains a proposal for Thread Environment Block.
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
|
* PROJECT: ReactOS system libraries
|
||||||
|
* FILE: include/kernel32/thread.h
|
||||||
|
* PURPOSE: Include file for lib/kernel32/thread.c
|
||||||
|
* PROGRAMMER: Ariadne ( ariadne@xs4all.nl)
|
||||||
|
* UPDATE HISTORY:
|
||||||
|
* Created 01/11/98
|
||||||
*/
|
*/
|
||||||
#ifndef __TEB_DEFINED
|
#include <windows.h>
|
||||||
#define __TEB_DEFINED
|
#include <ddk/ntddk.h>
|
||||||
|
NT_TEB *GetTeb(VOID);
|
||||||
|
|
||||||
typedef struct _NT_TIB {
|
|
||||||
|
|
||||||
struct _EXCEPTION_REGISTRATION_RECORD *ExceptionList;
|
|
||||||
|
|
||||||
void *StackBase;
|
|
||||||
void *StackLimit;
|
|
||||||
void *SubSystemTib;
|
|
||||||
union {
|
|
||||||
void *FiberData;
|
|
||||||
DWORD Version;
|
|
||||||
};
|
|
||||||
void *ArbitraryUserPointer;
|
|
||||||
struct _NT_TIB *Self;
|
|
||||||
|
|
||||||
} NT_TIB;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct _NT_TEB
|
|
||||||
{
|
|
||||||
|
|
||||||
NT_TIB Tib;
|
|
||||||
DWORD dwProcessId;
|
|
||||||
DWORD dwThreadId;
|
|
||||||
HANDLE hRPC;
|
|
||||||
NT_PEB *pPeb;
|
|
||||||
DWORD dwErrCode;
|
|
||||||
WORD nMutexCount;
|
|
||||||
LCID Locale;
|
|
||||||
//HQUEUE MessageQueue
|
|
||||||
DWORD dwTlsIndex ;
|
|
||||||
LPVOID TlsData[512];
|
|
||||||
|
|
||||||
|
|
||||||
} NT_TEB;
|
|
||||||
|
|
||||||
|
|
||||||
// should be an inline asm macro
|
|
||||||
|
|
||||||
NT_TEB *GetTeb()
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
19
reactos/lib/advapi32/makefile
Normal file
19
reactos/lib/advapi32/makefile
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
all: advapi32.a
|
||||||
|
|
||||||
|
TOKEN_OBJECTS = token/access.o
|
||||||
|
|
||||||
|
REGISTRY_OBJECTS = reg/reg.o
|
||||||
|
|
||||||
|
SEC_OBJECTS = sec/sec.o sec/rtlsec.o
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
OBJECTS = $(TOKEN_OBJECTS) $(REGISTRY_OBJECTS) $(SEC_OBJECTS)
|
||||||
|
|
||||||
|
|
||||||
|
advapi32.a: $(OBJECTS)
|
||||||
|
$(AR) vrcs advapi32.a $(OBJECTS)
|
||||||
|
|
||||||
|
dummy:
|
||||||
|
|
||||||
|
include ../../rules.mak
|
42
reactos/lib/advapi32/reg/reg.c
Normal file
42
reactos/lib/advapi32/reg/reg.c
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
/*
|
||||||
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
|
* PROJECT: ReactOS system libraries
|
||||||
|
* FILE: lib/advapi32/sec/rtlsec.c
|
||||||
|
* PURPOSE: Registry functions
|
||||||
|
* PROGRAMMER: Ariadne ( ariadne@xs4all.nl)
|
||||||
|
* UPDATE HISTORY:
|
||||||
|
* Created 01/11/98
|
||||||
|
*/
|
||||||
|
#include <windows.h>
|
||||||
|
#include <wstring.h>
|
||||||
|
#undef WIN32_LEAN_AND_MEAN
|
||||||
|
|
||||||
|
LONG
|
||||||
|
STDCALL
|
||||||
|
RegOpenKeyW (
|
||||||
|
HKEY hKey,
|
||||||
|
LPCWSTR lpSubKey,
|
||||||
|
PHKEY phkResult
|
||||||
|
)
|
||||||
|
{
|
||||||
|
NTSTATUS errCode;
|
||||||
|
UNICODE_STRING SubKeyString;
|
||||||
|
|
||||||
|
SubKeyString.Buffer = lpSubKey;
|
||||||
|
SubKeyString.Length = wcslen(lpSubKey);
|
||||||
|
SubKeyString.MaximumLength = SubKeyString.Length;
|
||||||
|
|
||||||
|
ObjectAttributes.RootDirectory = hKey;
|
||||||
|
ObjectAttributes.ObjectName = &SubKeyString;
|
||||||
|
ObjectAttributes.Attributes = OBJ_CASE_INSENSITIVE;
|
||||||
|
errCode = NtOpenKey(
|
||||||
|
phkResult,
|
||||||
|
GENERIC_ALL,
|
||||||
|
&ObjectAttributes
|
||||||
|
);
|
||||||
|
if ( !NT_SUCCESS(errCode) ) {
|
||||||
|
SetLastError(RtlNtStatusToDosError(errCode));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
417
reactos/lib/advapi32/sec/rtlsec.c
Normal file
417
reactos/lib/advapi32/sec/rtlsec.c
Normal file
|
@ -0,0 +1,417 @@
|
||||||
|
/*
|
||||||
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
|
* PROJECT: ReactOS system libraries
|
||||||
|
* FILE: lib/advapi32/reg/reg.c
|
||||||
|
* PURPOSE: Registry functions
|
||||||
|
* PROGRAMMER: Ariadne ( ariadne@xs4all.nl)
|
||||||
|
Modified form Wine [ Marcus Meissner ]
|
||||||
|
* UPDATE HISTORY:
|
||||||
|
* Created 01/11/98
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#undef WIN32_LEAN_AND_MEAN
|
||||||
|
#include <windows.h>
|
||||||
|
#include <ddk/ntddk.h>
|
||||||
|
#include "rtlsec.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
STDCALL
|
||||||
|
RtlLengthSid(LPSID Sid)
|
||||||
|
{
|
||||||
|
return sizeof(DWORD)*Sid->SubAuthorityCount+sizeof(SID);
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
STDCALL
|
||||||
|
RtlCreateAcl(LPACL Acl,DWORD Size,DWORD Revision) {
|
||||||
|
if (Revision!=ACL_REVISION)
|
||||||
|
return STATUS_INVALID_PARAMETER;
|
||||||
|
if (size<sizeof(ACL))
|
||||||
|
return STATUS_BUFFER_TOO_SMALL;
|
||||||
|
if (size>0xFFFF)
|
||||||
|
return STATUS_INVALID_PARAMETER; 52
|
||||||
|
memset(Acl,'\0',sizeof(ACL));
|
||||||
|
Acl->AclRevision = Revision;
|
||||||
|
Acl->AclSize = Size;
|
||||||
|
Acl->AceCount = 0;
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**************************************************************************
|
||||||
|
* RtlFirstFreeAce [NTDLL]
|
||||||
|
* looks for the AceCount+1 ACE, and if it is still within the alloced
|
||||||
|
* ACL, return a pointer to it
|
||||||
|
*/
|
||||||
|
BOOLEAN
|
||||||
|
STDCALL
|
||||||
|
RtlFirstFreeAce(LPACL Acl,LPACE_HEADER *AceHeader)
|
||||||
|
{
|
||||||
|
LPACE_HEADER Ace;
|
||||||
|
int i;
|
||||||
|
*AceHeader = 0;
|
||||||
|
Ace = (LPACE_HEADER)(Acl+1);
|
||||||
|
for (i=0;i<Acl->AceCount;i++) {
|
||||||
|
if ((DWORD)Ace>=(((DWORD)Acl)+Acl->AclSize))
|
||||||
|
return 0;
|
||||||
|
Ace = (LPACE_HEADER)(((BYTE*)Ace)+Ace->AceSize);
|
||||||
|
}
|
||||||
|
if ((DWORD)Ace>=(((DWORD)Acl)+Acl->AclSize))
|
||||||
|
return 0;
|
||||||
|
*AceHeader = Ace;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
/**************************************************************************
|
||||||
|
* RtlAddAce [NTDLL]
|
||||||
|
*/
|
||||||
|
NTSTATUS
|
||||||
|
STDCALL
|
||||||
|
RtlAddAce(LPACL Acl,DWORD Revision,DWORD xnrofaces, LPACE_HEADER AceStart,DWORD AceLen)
|
||||||
|
{
|
||||||
|
LPACE_HEADER ace,targetace;
|
||||||
|
int nrofaces;
|
||||||
|
if (Acl->AclRevision != ACL_REVISION)
|
||||||
|
return STATUS_INVALID_PARAMETER;
|
||||||
|
if (!RtlFirstFreeAce(Acl,&targetace))
|
||||||
|
return STATUS_INVALID_PARAMETER;
|
||||||
|
nrofaces=0;
|
||||||
|
ace=AceStart;
|
||||||
|
while (((DWORD)ace-(DWORD)AceStart)<AceLen) {
|
||||||
|
nrofaces++;
|
||||||
|
ace = (LPACE_HEADER)(((BYTE*)ace)+ace->AceSize);
|
||||||
|
}
|
||||||
|
if ((DWORD)targetace+AceLen>(DWORD)Acl+Acl->AclSize) /* too much aces */
|
||||||
|
return STATUS_INVALID_PARAMETER;
|
||||||
|
memcpy((LPBYTE)targetace,AceStart,AceLen);
|
||||||
|
Acl->AceCount+=nrofaces;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/**************************************************************************
|
||||||
|
* RtlCreateSecurityDescriptor [NTDLL]
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Win32: InitializeSecurityDescriptor
|
||||||
|
NTSTATUS
|
||||||
|
STDCALL
|
||||||
|
RtlCreateSecurityDescriptor(LPSECURITY_DESCRIPTOR SecurityDescriptor ,ULONG Revision)
|
||||||
|
{
|
||||||
|
if (Revision !=SECURITY_DESCRIPTOR_REVISION)
|
||||||
|
return STATUS_UNKNOWN_REVISION;
|
||||||
|
memset(SecurityDescriptor,'\0',sizeof(*SecurityDescriptor));
|
||||||
|
SecurityDescriptor->Revision = SECURITY_DESCRIPTOR_REVISION;
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Win32: IsValidSecurityDescriptor
|
||||||
|
BOOLEAN
|
||||||
|
NTAPI
|
||||||
|
RtlValidSecurityDescriptor(
|
||||||
|
PSECURITY_DESCRIPTOR SecurityDescriptor
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if ( SecurityDescriptor == NULL )
|
||||||
|
return FALSE;
|
||||||
|
if ( SecurityDescriptor->Revision != SECURITY_DESCRIPTOR_REVISION )
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Win32: GetSecurityDescriptorLength
|
||||||
|
ULONG
|
||||||
|
NTAPI
|
||||||
|
RtlLengthSecurityDescriptor(
|
||||||
|
PSECURITY_DESCRIPTOR SecurityDescriptor
|
||||||
|
)
|
||||||
|
{
|
||||||
|
ULONG Size;
|
||||||
|
Size = SECURITY_DESCRIPTOR_MIN_LENGTH;
|
||||||
|
if ( SecurityDescriptor == NULL )
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if ( SecurityDescriptor->Owner != NULL )
|
||||||
|
Size += SecurityDescriptor->Owner->SubAuthorityCount;
|
||||||
|
if ( SecurityDescriptor->Group != NULL )
|
||||||
|
Size += SecurityDescriptor->Group->SubAuthorityCount;
|
||||||
|
|
||||||
|
|
||||||
|
if ( SecurityDescriptor->Sacl != NULL )
|
||||||
|
Size += SecurityDescriptor->Sacl->AclSize;
|
||||||
|
if ( SecurityDescriptor->Dacl != NULL )
|
||||||
|
Size += SecurityDescriptor->Dacl->AclSize;
|
||||||
|
|
||||||
|
return Size;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**************************************************************************
|
||||||
|
* RtlSetDaclSecurityDescriptor [NTDLL]
|
||||||
|
*/
|
||||||
|
// Win32: SetSecurityDescriptorDacl
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
RtlSetDaclSecurityDescriptor(
|
||||||
|
PSECURITY_DESCRIPTOR SecurityDescriptor,
|
||||||
|
BOOLEAN DaclPresent,
|
||||||
|
PACL Dacl,
|
||||||
|
BOOLEAN DaclDefaulted
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (SecurityDescriptor->Revision!=SECURITY_DESCRIPTOR_REVISION)
|
||||||
|
return STATUS_UNKNOWN_REVISION;
|
||||||
|
if (SecurityDescriptor->Control & SE_SELF_RELATIVE)
|
||||||
|
return STATUS_INVALID_SECURITY_DESCR;
|
||||||
|
if (!DaclPresent) {
|
||||||
|
SecurityDescriptor->Control &= ~SE_DACL_PRESENT;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
SecurityDescriptor->Control |= SE_DACL_PRESENT;
|
||||||
|
SecurityDescriptor->Dacl = Dacl;
|
||||||
|
if (DaclDefaulted)
|
||||||
|
SecurityDescriptor->Control |= SE_DACL_DEFAULTED;
|
||||||
|
else
|
||||||
|
SecurityDescriptor->Control &= ~SE_DACL_DEFAULTED;
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Win32: GetSecurityDescriptorDacl
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
RtlGetDaclSecurityDescriptor(
|
||||||
|
PSECURITY_DESCRIPTOR SecurityDescriptor,
|
||||||
|
PBOOLEAN DaclPresent,
|
||||||
|
PACL *Dacl,
|
||||||
|
PBOOLEAN DaclDefaulted
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if ( SecurityDescriptor == NULL || DaclPresent == NULL || Dacl == NULL || DaclDefaulted == NULL )
|
||||||
|
return STATUS_INVALID_PARAMETER;
|
||||||
|
if ( SecurityDescriptor->Dacl != NULL ) {
|
||||||
|
Dacl = SecurityDescriptor->Dacl;
|
||||||
|
if ( Dacl->AceCount > 0 )
|
||||||
|
*DaclPresent = TRUE;
|
||||||
|
else
|
||||||
|
*DaclPresent = FALSE;
|
||||||
|
if ( SecurityDescriptor->Control & SE_DACL_DEFAULTED ==
|
||||||
|
SE_DACL_DEFAULTED ) {
|
||||||
|
*OwnerDefaulted = TRUE;
|
||||||
|
else
|
||||||
|
*OwnerDefaulted = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**************************************************************************
|
||||||
|
* RtlSetSaclSecurityDescriptor [NTDLL]147 */
|
||||||
|
// Win32: SetSecurityDescriptorSacl
|
||||||
|
// NOTE: NT does not export RtlGetSaclSecurityDescriptor!
|
||||||
|
NTSTATUS
|
||||||
|
STDCALL
|
||||||
|
RtlSetSaclSecurityDescriptor (
|
||||||
|
LPSECURITY_DESCRIPTOR SecurityDescriptor,BOOLEAN SaclPresent,LPACL Sacl,BOOLEAN SaclDefaulted)
|
||||||
|
{
|
||||||
|
if (SecurityDescriptor->Revision!=SECURITY_DESCRIPTOR_REVISION)
|
||||||
|
return STATUS_UNKNOWN_REVISION;
|
||||||
|
if (SecurityDescriptor->Control & SE_SELF_RELATIVE)
|
||||||
|
return STATUS_INVALID_SECURITY_DESCR;
|
||||||
|
if (!SaclPresent) {
|
||||||
|
SecurityDescriptor->Control &= ~SE_SACL_PRESENT;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
SecurityDescriptor->Control |= SE_SACL_PRESENT;
|
||||||
|
SecurityDescriptor->Sacl = Sacl;
|
||||||
|
if (SaclDefaulted)
|
||||||
|
SecurityDescriptor->Control |= SE_SACL_DEFAULTED;
|
||||||
|
else
|
||||||
|
SecurityDescriptor->Control &= ~SE_SACL_DEFAULTED;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
/**************************************************************************
|
||||||
|
* RtlSetOwnerSecurityDescriptor [NTDLL]
|
||||||
|
*/
|
||||||
|
NTSTATUS
|
||||||
|
STDCALL
|
||||||
|
RtlSetOwnerSecurityDescriptor (LPSECURITY_DESCRIPTOR SecurityDescriptor,LPSID Owner,BOOLEAN OwnerDefaulted)
|
||||||
|
{
|
||||||
|
if (SecurityDescriptor->Revision!=SECURITY_DESCRIPTOR_REVISION)
|
||||||
|
return STATUS_UNKNOWN_REVISION;
|
||||||
|
if (SecurityDescriptor->Control & SE_SELF_RELATIVE)
|
||||||
|
return STATUS_INVALID_SECURITY_DESCR;180
|
||||||
|
SecurityDescriptor->Owner = Owner;
|
||||||
|
if (OwnerDefaulted)
|
||||||
|
SecurityDescriptor->Control |= SE_OWNER_DEFAULTED;
|
||||||
|
else
|
||||||
|
SecurityDescriptor->Control &= ~SE_OWNER_DEFAULTED;
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Win32: GetSecurityDescriptorOwner
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
RtlGetOwnerSecurityDescriptor(
|
||||||
|
PSECURITY_DESCRIPTOR SecurityDescriptor,
|
||||||
|
PSID *Owner,
|
||||||
|
PBOOLEAN OwnerDefaulted
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if ( SecurityDescriptor == NULL || Owner == NULL || OwnerDefaulted == NULL )
|
||||||
|
return STATUS_INVALID_PARAMETER;
|
||||||
|
Owner = SecurityDescriptor->Owner;
|
||||||
|
if ( Owner != NULL ) {
|
||||||
|
if ( SecurityDescriptor->Control & SE_OWNER_DEFAULTED ==
|
||||||
|
SE_OWNER_DEFAULTED ) {
|
||||||
|
*OwnerDefaulted = TRUE;
|
||||||
|
else
|
||||||
|
*OwnerDefaulted = FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**************************************************************************
|
||||||
|
* RtlSetOwnerSecurityDescriptor [NTDLL]
|
||||||
|
*/
|
||||||
|
// Win32: SetSecurityDescriptorGroup
|
||||||
|
NTSTATUS
|
||||||
|
STDCALL
|
||||||
|
RtlSetGroupSecurityDescriptor (LPSECURITY_DESCRIPTOR SecurityDescriptor,LPSID Group,BOOLEAN GroupDefaulted)
|
||||||
|
{
|
||||||
|
if (SecurityDescriptor->Revision!=SECURITY_DESCRIPTOR_REVISION)
|
||||||
|
return STATUS_UNKNOWN_REVISION;
|
||||||
|
if (SecurityDescriptor->Control & SE_SELF_RELATIVE)
|
||||||
|
return STATUS_INVALID_SECURITY_DESCR;
|
||||||
|
SecurityDescriptor->Group = Group;
|
||||||
|
if (GroupDefaulted)
|
||||||
|
SecurityDescriptor->Control |= SE_GROUP_DEFAULTED;
|
||||||
|
else
|
||||||
|
SecurityDescriptor->Control &= ~SE_GROUP_DEFAULTED;
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Win32: GetSecurityDescriptorGroup
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
RtlGetGroupSecurityDescriptor(
|
||||||
|
PSECURITY_DESCRIPTOR SecurityDescriptor,
|
||||||
|
PSID *Group,
|
||||||
|
PBOOLEAN GroupDefaulted
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if ( SecurityDescriptor == NULL || Group == NULL || GroupDefaulted == NULL )
|
||||||
|
return STATUS_INVALID_PARAMETER;
|
||||||
|
Group = SecurityDescriptor->Group;
|
||||||
|
if ( Group != NULL ) {
|
||||||
|
if ( SecurityDescriptor->Control & SE_GROUP_DEFAULTED ==
|
||||||
|
SE_GROUP_DEFAULTED ) {
|
||||||
|
*GroupDefaulted = TRUE;
|
||||||
|
else
|
||||||
|
*GroupDefaulted = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Win32: GetSidLengthRequired
|
||||||
|
ULONG
|
||||||
|
NTAPI
|
||||||
|
RtlLengthRequiredSid(
|
||||||
|
UCHAR SubAuthorityCount
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return sizeof(DWORD)*SubAuthorityCount+sizeof(SID);
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
STDCALL
|
||||||
|
RtlInitializeSid(LPSID Sid,LPSID_IDENTIFIER_AUTHORITY SidIdentifierAuthority, DWORD nSubAuthorityCount)
|
||||||
|
{
|
||||||
|
BYTE a = c&0xff;
|
||||||
|
if (a>=SID_MAX_SUB_AUTHORITIES)
|
||||||
|
return a;
|
||||||
|
Sid->SubAuthorityCount = nSubAuthorityCount;
|
||||||
|
Sid->Revision = SID_REVISION;
|
||||||
|
memcpy(&(Sid->IdentifierAuthority),SidIdentifierAuthority,sizeof(SID_IDENTIFIER_AUTHORITY));
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Win32: GetSidSubAuthority
|
||||||
|
PULONG
|
||||||
|
NTAPI
|
||||||
|
RtlSubAuthoritySid(
|
||||||
|
PSID pSid,
|
||||||
|
ULONG nSubAuthority
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return &(pSid->SubAuthority[nSubAuthority]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Win32: IsEqualSid
|
||||||
|
BOOLEAN
|
||||||
|
NTAPI
|
||||||
|
RtlEqualSid(
|
||||||
|
PSID Sid1,
|
||||||
|
PSID Sid2
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if ( Sid1 == NULL || Sid2 == NULL )
|
||||||
|
return STATUS_INVALID_PARAMETER;
|
||||||
|
|
||||||
|
if ( Sid1 == Sid2 )
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Win32: MakeSelfRelativeSD
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
RtlAbsoluteToSelfRelativeSD(
|
||||||
|
PSECURITY_DESCRIPTOR AbsoluteSecurityDescriptor,
|
||||||
|
PSECURITY_DESCRIPTOR SelfRelativeSecurityDescriptor,
|
||||||
|
PULONG BufferLength
|
||||||
|
)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
RtlValidSid(
|
||||||
|
PSID Sid
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if ( Sid == NULL )
|
||||||
|
return STATUS_INVALID_PARAMETER;
|
||||||
|
|
||||||
|
if ( Sid->Revision == SID_REVISION )
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
LPBYTE STDCALL RtlSubAuthorityCountSid(LPSID Sid)
|
||||||
|
{
|
||||||
|
return ((LPBYTE)Sid)+1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
DWORD STDCALL RtlCopySid(DWORD Length,LPSID DestinationSid,LPSID SourceSid)
|
||||||
|
{
|
||||||
|
if (Length<(SourceSid->SubAuthorityCount*4+8))
|
||||||
|
return STATUS_BUFFER_TOO_SMALL;
|
||||||
|
memmove(DestinationSid,SourceSid,SourceSid->SubAuthorityCount*4+8);
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
133
reactos/lib/advapi32/sec/rtlsec.h
Normal file
133
reactos/lib/advapi32/sec/rtlsec.h
Normal file
|
@ -0,0 +1,133 @@
|
||||||
|
/*
|
||||||
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
|
* PROJECT: ReactOS system libraries
|
||||||
|
* FILE: lib/advapi32/sec/rtlsec.h
|
||||||
|
* PURPOSE: Registry functions
|
||||||
|
* PROGRAMMER: Ariadne ( ariadne@xs4all.nl)
|
||||||
|
* UPDATE HISTORY:
|
||||||
|
* Created 01/11/98
|
||||||
|
*/
|
||||||
|
NTSTATUS
|
||||||
|
STDCALL
|
||||||
|
RtlLengthSid(LPSID Sid);
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
STDCALL
|
||||||
|
RtlCreateAcl(LPACL Acl,DWORD Size,DWORD Revision);
|
||||||
|
|
||||||
|
BOOLEAN
|
||||||
|
STDCALL
|
||||||
|
RtlFirstFreeAce(LPACL Acl,LPACE_HEADER *AceHeader);
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
STDCALL
|
||||||
|
RtlAddAce(LPACL Acl,DWORD Revision,DWORD xnrofaces, LPACE_HEADER AceStart,DWORD AceLen)
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
STDCALL
|
||||||
|
RtlCreateSecurityDescriptor(LPSECURITY_DESCRIPTOR SecurityDescriptor ,ULONG Revision);
|
||||||
|
|
||||||
|
BOOLEAN
|
||||||
|
NTAPI
|
||||||
|
RtlValidSecurityDescriptor(
|
||||||
|
PSECURITY_DESCRIPTOR SecurityDescriptor
|
||||||
|
);
|
||||||
|
|
||||||
|
ULONG
|
||||||
|
NTAPI
|
||||||
|
RtlLengthSecurityDescriptor(
|
||||||
|
PSECURITY_DESCRIPTOR SecurityDescriptor
|
||||||
|
);
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
RtlSetDaclSecurityDescriptor(
|
||||||
|
PSECURITY_DESCRIPTOR SecurityDescriptor,
|
||||||
|
BOOLEAN DaclPresent,
|
||||||
|
PACL Dacl,
|
||||||
|
BOOLEAN DaclDefaulted
|
||||||
|
);
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
RtlGetDaclSecurityDescriptor(
|
||||||
|
PSECURITY_DESCRIPTOR SecurityDescriptor,
|
||||||
|
PBOOLEAN DaclPresent,
|
||||||
|
PACL *Dacl,
|
||||||
|
PBOOLEAN DaclDefaulted
|
||||||
|
);
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
STDCALL
|
||||||
|
RtlSetSaclSecurityDescriptor (
|
||||||
|
LPSECURITY_DESCRIPTOR SecurityDescriptor,BOOLEAN SaclPresent,LPACL Sacl,BOOLEAN SaclDefaulted);
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
STDCALL
|
||||||
|
RtlSetOwnerSecurityDescriptor (LPSECURITY_DESCRIPTOR SecurityDescriptor,LPSID Owner,BOOLEAN OwnerDefaulted);
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
RtlGetOwnerSecurityDescriptor(
|
||||||
|
PSECURITY_DESCRIPTOR SecurityDescriptor,
|
||||||
|
PSID *Owner,
|
||||||
|
PBOOLEAN OwnerDefaulted
|
||||||
|
);
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
STDCALL
|
||||||
|
RtlSetGroupSecurityDescriptor (LPSECURITY_DESCRIPTOR SecurityDescriptor,LPSID Group,BOOLEAN GroupDefaulted);
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
RtlGetGroupSecurityDescriptor(
|
||||||
|
PSECURITY_DESCRIPTOR SecurityDescriptor,
|
||||||
|
PSID *Group,
|
||||||
|
PBOOLEAN GroupDefaulted
|
||||||
|
);
|
||||||
|
|
||||||
|
ULONG
|
||||||
|
NTAPI
|
||||||
|
RtlLengthRequiredSid(
|
||||||
|
UCHAR SubAuthorityCount
|
||||||
|
);
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
STDCALL
|
||||||
|
RtlInitializeSid(LPSID Sid,LPSID_IDENTIFIER_AUTHORITY SidIdentifierAuthority, DWORD nSubAuthorityCount);
|
||||||
|
|
||||||
|
PULONG
|
||||||
|
NTAPI
|
||||||
|
RtlSubAuthoritySid(
|
||||||
|
PSID pSid,
|
||||||
|
ULONG nSubAuthority
|
||||||
|
);
|
||||||
|
|
||||||
|
BOOLEAN
|
||||||
|
NTAPI
|
||||||
|
RtlEqualSid(
|
||||||
|
PSID Sid1,
|
||||||
|
PSID Sid2
|
||||||
|
);
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
RtlAbsoluteToSelfRelativeSD(
|
||||||
|
PSECURITY_DESCRIPTOR AbsoluteSecurityDescriptor,
|
||||||
|
PSECURITY_DESCRIPTOR SelfRelativeSecurityDescriptor,
|
||||||
|
PULONG BufferLength
|
||||||
|
);
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
RtlValidSid(
|
||||||
|
PSID Sid
|
||||||
|
);
|
||||||
|
|
||||||
|
LPBYTE STDCALL RtlSubAuthorityCountSid(LPSID Sid);
|
||||||
|
|
||||||
|
DWORD STDCALL RtlCopySid(DWORD Length,LPSID DestinationSid,LPSID SourceSid);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
17
reactos/lib/advapi32/sec/sec.c
Normal file
17
reactos/lib/advapi32/sec/sec.c
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
/*
|
||||||
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
|
* PROJECT: ReactOS system libraries
|
||||||
|
* FILE: lib/advapi32/sec/sec.c
|
||||||
|
* PURPOSE: Registry functions
|
||||||
|
* PROGRAMMER: Ariadne ( ariadne@xs4all.nl)
|
||||||
|
* UPDATE HISTORY:
|
||||||
|
* Created 01/11/98
|
||||||
|
*/
|
||||||
|
DWORD
|
||||||
|
STDCALL
|
||||||
|
GetSecurityDescriptorLength (
|
||||||
|
PSECURITY_DESCRIPTOR pSecurityDescriptor
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return RtlSetSecurityDescriptorLength(pSecurityDescriptor);
|
||||||
|
}
|
159
reactos/lib/advapi32/token/token.c
Normal file
159
reactos/lib/advapi32/token/token.c
Normal file
|
@ -0,0 +1,159 @@
|
||||||
|
/*
|
||||||
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
|
* PROJECT: ReactOS system libraries
|
||||||
|
* FILE: lib/advapi32/token/token.c
|
||||||
|
* PURPOSE: Registry functions
|
||||||
|
* PROGRAMMER: Ariadne ( ariadne@xs4all.nl)
|
||||||
|
* UPDATE HISTORY:
|
||||||
|
* Created 01/11/98
|
||||||
|
*/
|
||||||
|
WINBOOL
|
||||||
|
STDCALL
|
||||||
|
AdjustTokenGroups (
|
||||||
|
HANDLE TokenHandle,
|
||||||
|
WINBOOL ResetToDefault,
|
||||||
|
PTOKEN_GROUPS NewState,
|
||||||
|
DWORD BufferLength,
|
||||||
|
PTOKEN_GROUPS PreviousState,
|
||||||
|
PDWORD ReturnLength
|
||||||
|
)
|
||||||
|
{
|
||||||
|
NTSTATUS errCode;
|
||||||
|
errCode = NtAdjustGroupsToken(TokenHandle,ResetToDefault,NewState,
|
||||||
|
BufferLength, PreviousState, ReturnLength );
|
||||||
|
if ( !NT_SUCCESS(errCode) ) {
|
||||||
|
SetLastError(RtlNtStatusToDosError(errCode));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
WINBOOL
|
||||||
|
STDCALL
|
||||||
|
AdjustTokenPrivileges (
|
||||||
|
HANDLE TokenHandle,
|
||||||
|
WINBOOL DisableAllPrivileges,
|
||||||
|
PTOKEN_PRIVILEGES NewState,
|
||||||
|
DWORD BufferLength,
|
||||||
|
PTOKEN_PRIVILEGES PreviousState,
|
||||||
|
PDWORD ReturnLength
|
||||||
|
)
|
||||||
|
{ NTSTATUS errCode;
|
||||||
|
errCode = NtAdjustPrivilegesToken(TokenHandle,ResetToDefault,NewState,
|
||||||
|
BufferLength, PreviousState, ReturnLength );
|
||||||
|
if ( !NT_SUCCESS(errCode) ) {
|
||||||
|
SetLastError(RtlNtStatusToDosError(errCode));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
WINBOOL
|
||||||
|
STDCALL
|
||||||
|
GetTokenInformation (
|
||||||
|
HANDLE TokenHandle,
|
||||||
|
TOKEN_INFORMATION_CLASS TokenInformationClass,
|
||||||
|
LPVOID TokenInformation,
|
||||||
|
DWORD TokenInformationLength,
|
||||||
|
PDWORD ReturnLength
|
||||||
|
)
|
||||||
|
{
|
||||||
|
NTSTATUS errCode;
|
||||||
|
errCode = NtQueryInformationToken(TokenHandle,TokenInformationClass,TokenInformation,
|
||||||
|
TokenInformationLength, ReturnLength);
|
||||||
|
if ( !NT_SUCCESS(errCode) ) {
|
||||||
|
SetLastError(RtlNtStatusToDosError(errCode));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
WINBOOL
|
||||||
|
STDCALL
|
||||||
|
SetTokenInformation (
|
||||||
|
HANDLE TokenHandle,
|
||||||
|
TOKEN_INFORMATION_CLASS TokenInformationClass,
|
||||||
|
LPVOID TokenInformation,
|
||||||
|
DWORD TokenInformationLength
|
||||||
|
)
|
||||||
|
{
|
||||||
|
NTSTATUS errCode;
|
||||||
|
errCode = NtSetnformationToken(TokenHandle,TokenInformationClass,TokenInformation,
|
||||||
|
TokenInformationLength);
|
||||||
|
if ( !NT_SUCCESS(errCode) ) {
|
||||||
|
SetLastError(RtlNtStatusToDosError(errCode));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
WINBOOL
|
||||||
|
STDCALL
|
||||||
|
AccessCheck (
|
||||||
|
PSECURITY_DESCRIPTOR pSecurityDescriptor,
|
||||||
|
HANDLE ClientToken,
|
||||||
|
DWORD DesiredAccess,
|
||||||
|
PGENERIC_MAPPING GenericMapping,
|
||||||
|
PPRIVILEGE_SET PrivilegeSet,
|
||||||
|
LPDWORD PrivilegeSetLength,
|
||||||
|
LPDWORD GrantedAccess,
|
||||||
|
LPBOOL AccessStatus
|
||||||
|
)
|
||||||
|
{
|
||||||
|
NTSTATUS errCode;
|
||||||
|
errCode = NtAccessCheck( pSecurityDescriptor,
|
||||||
|
ClientToken,
|
||||||
|
DesiredAccess,
|
||||||
|
GenericMapping,
|
||||||
|
PrivilegeSet,
|
||||||
|
PrivilegeSetLength,
|
||||||
|
GrantedAccess,
|
||||||
|
AccessStatus);
|
||||||
|
if ( !NT_SUCCESS(errCode) ) {
|
||||||
|
SetLastError(RtlNtStatusToDosError(errCode));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
WINBOOL
|
||||||
|
STDCALL
|
||||||
|
OpenProcessToken (
|
||||||
|
HANDLE ProcessHandle,
|
||||||
|
DWORD DesiredAccess,
|
||||||
|
PHANDLE TokenHandle
|
||||||
|
)
|
||||||
|
{
|
||||||
|
NTSTATUS errCode;
|
||||||
|
errCode = NtOpenProcessToken(ProcessHandle,DesiredAccess,TokenHandle);
|
||||||
|
if ( !NT_SUCCESS(errCode) ) {
|
||||||
|
SetLastError(RtlNtStatusToDosError(errCode));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
WINBOOL
|
||||||
|
STDCALL
|
||||||
|
OpenThreadToken (
|
||||||
|
HANDLE ThreadHandle,
|
||||||
|
DWORD DesiredAccess,
|
||||||
|
WINBOOL OpenAsSelf,
|
||||||
|
PHANDLE TokenHandle
|
||||||
|
)
|
||||||
|
{
|
||||||
|
NTSTATUS errCode;
|
||||||
|
errCode = NtOpenThreadToken(ThreadHandle,DesiredAccess,OpenAsSelf,TokenHandle);
|
||||||
|
if ( !NT_SUCCESS(errCode) ) {
|
||||||
|
SetLastError(RtlNtStatusToDosError(errCode));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
626
reactos/lib/kernel32/except/except.c
Normal file
626
reactos/lib/kernel32/except/except.c
Normal file
|
@ -0,0 +1,626 @@
|
||||||
|
/*
|
||||||
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
|
* PROJECT: ReactOS system libraries
|
||||||
|
* FILE: lib/kernel32/misc/except.c
|
||||||
|
* PURPOSE: Exception functions
|
||||||
|
* PROGRAMMER: Ariadne ( ariadne@xs4all.nl)
|
||||||
|
modified from WINE [ Onno Hovers, (onno@stack.urc.tue.nl) ]
|
||||||
|
* UPDATE HISTORY:
|
||||||
|
* Created 01/11/98
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
#include <ddk/ntddk.h>
|
||||||
|
|
||||||
|
|
||||||
|
typedef LONG (STDCALL *LPTOP_LEVEL_EXCEPTION_FILTER)(
|
||||||
|
struct _EXCEPTION_POINTERS *ExceptionInfo
|
||||||
|
);
|
||||||
|
|
||||||
|
UINT GlobalErrMode;
|
||||||
|
LPTOP_LEVEL_EXCEPTION_FILTER GlobalTopLevelExceptionFilter;
|
||||||
|
|
||||||
|
UINT GetErrorMode(void);
|
||||||
|
|
||||||
|
//FIXME Please remove comments in funcs.h
|
||||||
|
LPTOP_LEVEL_EXCEPTION_FILTER
|
||||||
|
STDCALL
|
||||||
|
SetUnhandledExceptionFilter(
|
||||||
|
LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelExceptionFilter
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// these are in various flavors
|
||||||
|
|
||||||
|
|
||||||
|
typedef enum _EXCEPTION_DISPOSITION
|
||||||
|
{
|
||||||
|
ExceptionContinueExecution,
|
||||||
|
ExceptionContinueSearch,
|
||||||
|
ExceptionNestedException,
|
||||||
|
ExceptionCollidedUnwind
|
||||||
|
} EXCEPTION_DISPOSITION;
|
||||||
|
|
||||||
|
|
||||||
|
#define DISPOSITION_DISMISS 0
|
||||||
|
#define DISPOSITION_CONTINUE_SEARCH 1
|
||||||
|
#define DISPOSITION_NESTED_EXCEPTION 2
|
||||||
|
#define DISPOSITION_COLLIDED_UNWIND 3
|
||||||
|
|
||||||
|
// following values can be returned by exception filters
|
||||||
|
// in a try{} except() block.
|
||||||
|
|
||||||
|
//#define EXCEPTION_EXECUTE_HANDLER 1
|
||||||
|
//#define EXCEPTION_CONTINUE_SEARCH 0
|
||||||
|
//#define EXCEPTION_CONTINUE_EXECUTION -1
|
||||||
|
|
||||||
|
// OS/2 filter return codes
|
||||||
|
#define FILTER_ACCEPT 1
|
||||||
|
#define FILTER_DISMISS -1
|
||||||
|
#define FILTER_CONTINUE_SEARCH 0
|
||||||
|
|
||||||
|
|
||||||
|
#define TRYLEVEL_NONE -1
|
||||||
|
#define TRYLEVEL_INVALID -2
|
||||||
|
|
||||||
|
//callback interface codes (mimimal required set)
|
||||||
|
|
||||||
|
#define CB_GET_MAX_CODE 0
|
||||||
|
#define CB_DO_LOCAL_UNWIND 1
|
||||||
|
#define CB_GET_FRAME_EBP 2
|
||||||
|
#define CB_GET_SCOPE_INDEX 3
|
||||||
|
#define CB_GET_SCOPE_DATA 4
|
||||||
|
#define MAX_CALLBACK_CODE 4
|
||||||
|
|
||||||
|
|
||||||
|
#define EH_NONCONTINUABLE 1
|
||||||
|
#define EH_UNWINDING 2
|
||||||
|
#define EH_EXIT_UNWIND 4
|
||||||
|
#define EH_STACK_INVALID 8
|
||||||
|
#define EH_NESTED_CALL 16
|
||||||
|
|
||||||
|
//#define FACILITY_RPC_RUNTIME 2
|
||||||
|
//#define FACILITY_RPC_STUBS 3
|
||||||
|
//#define FACILITY_IO_ERROR_CODE 4
|
||||||
|
|
||||||
|
//#define SEVERITY_CODE_SUCCESS 0
|
||||||
|
//#define SEVERITY_CODE_INFORMATIONAL 1
|
||||||
|
//#define SEVERITY_CODE_WARNING 2
|
||||||
|
//#define SEVERITY_CODE_ERROR 3
|
||||||
|
|
||||||
|
|
||||||
|
#define XCPT_FATAL_EXCEPTION (0xC0000000)
|
||||||
|
#define XCPT_SEVERITY_CODE (0xC0000000)
|
||||||
|
#define XCPT_CUSTOMER_CODE (0x20000000)
|
||||||
|
#define XCPT_FACILITY_CODE (0x1FFF0000)
|
||||||
|
#define XCPT_EXCEPTION_CODE (0x0000FFFF)
|
||||||
|
|
||||||
|
|
||||||
|
// this is the definition of NTSTATUS
|
||||||
|
|
||||||
|
// definition of NTSTATUS
|
||||||
|
|
||||||
|
typedef struct _NTSTATUSDEF
|
||||||
|
{
|
||||||
|
USHORT Code;
|
||||||
|
USHORT Facility :12;
|
||||||
|
UCHAR Reserved : 1;
|
||||||
|
UCHAR CstCodeFlag : 1;
|
||||||
|
UCHAR Severity : 2;
|
||||||
|
} NTSTATUSDEF;
|
||||||
|
|
||||||
|
// Violation flags in ExceptionInfo
|
||||||
|
|
||||||
|
#define XCPT_UNKNOWN_ACCESS 0x00000000
|
||||||
|
#define XCPT_READ_ACCESS 0x00000001
|
||||||
|
#define XCPT_WRITE_ACCESS 0x00000002
|
||||||
|
#define XCPT_EXECUTE_ACCESS 0x00000004
|
||||||
|
#define XCPT_SPACE_ACCESS 0x00000008 // address space access violation
|
||||||
|
#define XCPT_LIMIT_ACCESS 0x00000010 // out of bounds
|
||||||
|
#define XCPT_DATA_UNKNOWN 0xFFFFFFFF
|
||||||
|
|
||||||
|
|
||||||
|
// some status values with corresponding ExceptionInfo values
|
||||||
|
|
||||||
|
//#define STATUS_GUARD_PAGE_VIOLATION 0x80000001
|
||||||
|
// ExceptionInfo[ 0 ] - Access Code: XCPT_READ_ACCESS | XCPT_WRITE_ACCESS
|
||||||
|
// ExceptionInfo[ 1 ] - FaultAddr
|
||||||
|
|
||||||
|
|
||||||
|
//#define STATUS_DATATYPE_MISALIGNMENT 0x80000002
|
||||||
|
// OS/2 XCPT is at 0xC000009E
|
||||||
|
// ExceptionInfo[ 0 ] - Access Code: XCPT_READ_ACCESS | XCPT_WRITE_ACCESS
|
||||||
|
// ExceptionInfo[ 1 ] - Alignment
|
||||||
|
// ExceptionInfo[ 2 ] - FaultAddr
|
||||||
|
|
||||||
|
|
||||||
|
//#define STATUS_ACCESS_VIOLATION 0xC0000005
|
||||||
|
// ExceptionInfo[ 0 ] - Access Code: XCPT_READ_ACCESS | XCPT_WRITE_ACCESS
|
||||||
|
// ExceptionInfo[ 1 ] - FaultAddr
|
||||||
|
|
||||||
|
|
||||||
|
//#define STATUS_IN_PAGE_ERROR 0xC0000006
|
||||||
|
// ExceptionInfo[ 0 ] - FaultAddr
|
||||||
|
|
||||||
|
//#define STATUS_NONCONTINUABLE_EXCEPTION 0xC0000025
|
||||||
|
//#define STATUS_INVALID_DISPOSITION 0xC0000026
|
||||||
|
|
||||||
|
|
||||||
|
// Exceptions generated by the exception handler
|
||||||
|
|
||||||
|
#define STATUS_UNWIND 0xC0000027
|
||||||
|
#define STATUS_BAD_STACK 0xC0000028
|
||||||
|
#define STATUS_INVALID_UNWIND_TARGET 0xC0000029
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct _EXCEPTION_REGISTRATION;
|
||||||
|
|
||||||
|
typedef EXCEPTION_DISPOSITION
|
||||||
|
(STDCALL *ExceptionHandlerType)(
|
||||||
|
struct _EXCEPTION_RECORD *ExceptionRecord,
|
||||||
|
struct _EXCEPTION_REGISTRATION *EstablisherFrame,
|
||||||
|
struct _CONTEXT *Context,
|
||||||
|
struct _EXCEPTION_RECORD *DispatcherContext
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct _SCOPE_TABLE {
|
||||||
|
DWORD prevTryLevel;
|
||||||
|
LPTOP_LEVEL_EXCEPTION_FILTER lpfnFilter;
|
||||||
|
ExceptionHandlerType lpfnHandler;
|
||||||
|
} SCOPE_TABLE , *PSCOPE_TABLE;
|
||||||
|
|
||||||
|
typedef struct _EXCEPTION_REGISTRATION {
|
||||||
|
struct _EXCEPTION_REGISTRATION *Prev;
|
||||||
|
ExceptionHandlerType Handler;
|
||||||
|
PSCOPE_TABLE ScopeTable;
|
||||||
|
unsigned int TryLevel;
|
||||||
|
unsigned int _ebp;
|
||||||
|
PEXCEPTION_POINTERS *Pointers;
|
||||||
|
} EXCEPTION_REGISTRATION, *PEXCEPTION_REGISTRATION;
|
||||||
|
|
||||||
|
#define END_OF_CHAIN ((PEXCEPTION_REGISTRATION) -1)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
EXCEPTION_DISPOSITION
|
||||||
|
CDECL
|
||||||
|
ExceptionHandler(
|
||||||
|
struct _EXCEPTION_RECORD *ExceptionRecord,
|
||||||
|
struct _EXCEPTION_REGISTRATION *RegistrationFrame,
|
||||||
|
CONTEXT *Context,
|
||||||
|
struct _EXCEPTION_RECORD *DispatcherContext
|
||||||
|
);
|
||||||
|
|
||||||
|
void KiUserExceptionDispatcher(
|
||||||
|
struct _EXCEPTION_RECORD *ExceptionRecord,
|
||||||
|
CONTEXT *Context);
|
||||||
|
|
||||||
|
NTSTATUS RtlDispatchException(
|
||||||
|
struct _EXCEPTION_RECORD *ExceptionRecord,
|
||||||
|
CONTEXT *Context);
|
||||||
|
|
||||||
|
struct _EXCEPTION_REGISTRATION *RtlpGetRegistrationHead(VOID);
|
||||||
|
|
||||||
|
void RtlpCaptureContext(CONTEXT *Context);
|
||||||
|
void RtlpGetStackLimits(void *StackBase, void *StackLimit);
|
||||||
|
void RtlpUnlinkHandler(struct _EXCEPTION_REGISTRATION *__head);
|
||||||
|
void RtlpLinkHandler(struct _EXCEPTION_REGISTRATION *__head);
|
||||||
|
void RtlUnwind(struct _EXCEPTION_REGISTRATION *RegistratonFrame,
|
||||||
|
VOID *ReturnAddress, // Unused
|
||||||
|
struct _EXCEPTION_RECORD *ExceptionRecord,
|
||||||
|
DWORD _eax);
|
||||||
|
|
||||||
|
void RtlRaiseException(struct _EXCEPTION_RECORD *ExceptionRecord);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
UINT GetErrorMode(void)
|
||||||
|
{
|
||||||
|
return GlobalErrMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
UINT
|
||||||
|
STDCALL
|
||||||
|
SetErrorMode( UINT uMode )
|
||||||
|
{
|
||||||
|
UINT OldErrMode = GetErrorMode();
|
||||||
|
GlobalErrMode = uMode;
|
||||||
|
return OldErrMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
LPTOP_LEVEL_EXCEPTION_FILTER
|
||||||
|
STDCALL
|
||||||
|
SetUnhandledExceptionFilter(
|
||||||
|
LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelExceptionFilter
|
||||||
|
)
|
||||||
|
{
|
||||||
|
LPTOP_LEVEL_EXCEPTION_FILTER OldTopLevelExceptionFilter =
|
||||||
|
GlobalTopLevelExceptionFilter;
|
||||||
|
lpTopLevelExceptionFilter = GlobalTopLevelExceptionFilter;
|
||||||
|
return OldTopLevelExceptionFilter;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
LONG
|
||||||
|
STDCALL
|
||||||
|
ExceptionFilter (
|
||||||
|
PEXCEPTION_POINTERS ExceptionInfo
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
EXCEPTION_DISPOSITION
|
||||||
|
CDECL
|
||||||
|
ExceptionHandler(
|
||||||
|
struct _EXCEPTION_RECORD *ExceptionRecord,
|
||||||
|
struct _EXCEPTION_REGISTRATION *RegistrationFrame,
|
||||||
|
CONTEXT *Context,
|
||||||
|
struct _EXCEPTION_RECORD *DispatcherContext
|
||||||
|
)
|
||||||
|
{
|
||||||
|
int FilterRet;
|
||||||
|
unsigned int TryLevel;
|
||||||
|
EXCEPTION_POINTERS ExceptionPointers;
|
||||||
|
SCOPE_TABLE *ScopeTable;
|
||||||
|
unsigned int _ebp;
|
||||||
|
|
||||||
|
|
||||||
|
// __asm { cld };
|
||||||
|
|
||||||
|
if ( ExceptionRecord->ExceptionFlags != EH_UNWINDING &&
|
||||||
|
ExceptionRecord->ExceptionFlags != EH_EXIT_UNWIND )
|
||||||
|
{
|
||||||
|
ExceptionPointers.ExceptionRecord= ExceptionRecord;
|
||||||
|
ExceptionPointers.ContextRecord = Context;
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
|
TryLevel = RegistrationFrame->TryLevel;
|
||||||
|
|
||||||
|
ScopeTable = RegistrationFrame->ScopeTable;
|
||||||
|
|
||||||
|
if ( RegistrationFrame->TryLevel != TRYLEVEL_NONE )
|
||||||
|
{
|
||||||
|
if ( RegistrationFrame->ScopeTable[TryLevel].lpfnFilter != NULL)
|
||||||
|
{
|
||||||
|
_ebp = RegistrationFrame->_ebp;
|
||||||
|
//__asm { push ebp
|
||||||
|
// mov ebp, _ebp
|
||||||
|
//}
|
||||||
|
FilterRet = ScopeTable->lpfnFilter(NULL);
|
||||||
|
//__asm { pop ebp }
|
||||||
|
|
||||||
|
if ( FilterRet < 0 )
|
||||||
|
return ExceptionContinueExecution;
|
||||||
|
|
||||||
|
if ( FilterRet == EXCEPTION_EXECUTE_HANDLER )
|
||||||
|
{
|
||||||
|
ScopeTable = RegistrationFrame->ScopeTable;
|
||||||
|
RtlUnwind(RegistrationFrame,NULL,ExceptionRecord,0);
|
||||||
|
//__asm { mov ebp, _ebp }
|
||||||
|
// local unwind
|
||||||
|
// nlg
|
||||||
|
|
||||||
|
RegistrationFrame->TryLevel = ScopeTable->prevTryLevel;
|
||||||
|
RegistrationFrame->ScopeTable[TryLevel].lpfnHandler(ExceptionRecord,RegistrationFrame,Context, DispatcherContext);
|
||||||
|
NtContinue(Context,PASSIVE_LEVEL);
|
||||||
|
//return;
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ScopeTable = RegistrationFrame->ScopeTable;
|
||||||
|
TryLevel = ScopeTable->prevTryLevel;
|
||||||
|
// search for handler
|
||||||
|
return DISPOSITION_CONTINUE_SEARCH;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
} else { // TRYLEVEL_NONE
|
||||||
|
return DISPOSITION_CONTINUE_SEARCH;
|
||||||
|
}
|
||||||
|
} else { // EXCEPTION_UNWINDING or EXCEPTION_EXIT_UNWIND
|
||||||
|
//
|
||||||
|
return DISPOSITION_CONTINUE_SEARCH;
|
||||||
|
}
|
||||||
|
return DISPOSITION_CONTINUE_SEARCH;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
LONG
|
||||||
|
STDCALL
|
||||||
|
UnhandledExceptionFilter(struct _EXCEPTION_POINTERS *ExceptionInfo)
|
||||||
|
{
|
||||||
|
char message[80];
|
||||||
|
DWORD dbgRet;
|
||||||
|
HANDLE DebugPort;
|
||||||
|
NTSTATUS errCode;
|
||||||
|
|
||||||
|
DWORD DebuggerPresent;
|
||||||
|
|
||||||
|
|
||||||
|
if(ExceptionInfo->ExceptionRecord->ExceptionCode == STATUS_ACCESS_VIOLATION) {
|
||||||
|
// might check read only resource
|
||||||
|
// Is there a debugger running ?
|
||||||
|
errCode = NtQueryInformationProcess(NtCurrentProcess(),ProcessDebugPort,&DebugPort,sizeof(HANDLE),NULL);
|
||||||
|
if ( !NT_SUCCESS(errCode) ) {
|
||||||
|
SetLastError(RtlNtStatusToDosError(errCode));
|
||||||
|
return EXCEPTION_EXECUTE_HANDLER;
|
||||||
|
}
|
||||||
|
if ( DebugPort ) {
|
||||||
|
//return EXCEPTION_CONTINUE_SEARCH;
|
||||||
|
}
|
||||||
|
if(GlobalTopLevelExceptionFilter != NULL) {
|
||||||
|
dbgRet = GlobalTopLevelExceptionFilter(ExceptionInfo);
|
||||||
|
if(dbgRet == EXCEPTION_EXECUTE_HANDLER)
|
||||||
|
return EXCEPTION_EXECUTE_HANDLER;
|
||||||
|
else if(dbgRet == EXCEPTION_CONTINUE_EXECUTION)
|
||||||
|
return EXCEPTION_CONTINUE_EXECUTION;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//if ( GetErrorMode() & SEM_NOGPFAULTERRORBOX == SEM_NOGPFAULTERRORBOX ) {
|
||||||
|
// produce a stack trace or pop a message
|
||||||
|
//sprintf( message, "Unhandled exception 0x%08lx at address 0x%08lx.",
|
||||||
|
// ExceptionInfo->ExceptionRecord->ExceptionCode,
|
||||||
|
// (DWORD)ExceptionInfo->ExceptionRecord->ExceptionAddress );
|
||||||
|
//MessageBoxA( 0, message, "Error", MB_OK | MB_ICONHAND );
|
||||||
|
|
||||||
|
//}
|
||||||
|
// Returning EXCEPTION_EXECUTE_HANDLER means that the code in
|
||||||
|
// the __execept block will be executed. Normally this will end up in a
|
||||||
|
// Terminate process.
|
||||||
|
|
||||||
|
return EXCEPTION_EXECUTE_HANDLER;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void KiUserExceptionDispatcher(PEXCEPTION_RECORD ExceptionRecord, PCONTEXT Context)
|
||||||
|
{
|
||||||
|
NTSTATUS errCode;
|
||||||
|
|
||||||
|
if ( RtlDispatchException(ExceptionRecord,Context) )
|
||||||
|
errCode = NtContinue(Context,PASSIVE_LEVEL);
|
||||||
|
else
|
||||||
|
errCode = NtRaiseException(ExceptionRecord,Context,(BOOLEAN)FALSE);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
NTSTATUS RtlDispatchException(PEXCEPTION_RECORD ExceptionRecord, PCONTEXT Context)
|
||||||
|
{
|
||||||
|
NTSTATUS errCode;
|
||||||
|
ULONG StackBase, StackLimit;
|
||||||
|
PEXCEPTION_REGISTRATION RegistrationFrame;
|
||||||
|
EXCEPTION_RECORD DispatcherContext;
|
||||||
|
EXCEPTION_RECORD FatalExceptionRecord;
|
||||||
|
|
||||||
|
//RtlpGetStackLimits(&StackBase,&StackTop);
|
||||||
|
RegistrationFrame = RtlpGetRegistrationHead();
|
||||||
|
|
||||||
|
while( RegistrationFrame != END_OF_CHAIN ) {
|
||||||
|
|
||||||
|
//FIXME Check the stack
|
||||||
|
RtlpGetStackLimits(&StackBase, &StackLimit);
|
||||||
|
|
||||||
|
errCode = RegistrationFrame->Handler(
|
||||||
|
ExceptionRecord,
|
||||||
|
RegistrationFrame,
|
||||||
|
Context,
|
||||||
|
&DispatcherContext);
|
||||||
|
|
||||||
|
//errCode = RtlpExecuteHandlerForException(ExceptionRecord, RegistrationFrame,
|
||||||
|
// Context, &DispatcherContext);
|
||||||
|
|
||||||
|
if ( RegistrationFrame == NULL )
|
||||||
|
ExceptionRecord->ExceptionFlags &= ~EH_NESTED_CALL;
|
||||||
|
|
||||||
|
switch( errCode ) {
|
||||||
|
case DISPOSITION_DISMISS:
|
||||||
|
if ( ExceptionRecord->ExceptionFlags & EH_NONCONTINUABLE ) {
|
||||||
|
FatalExceptionRecord.ExceptionRecord = ExceptionRecord;
|
||||||
|
FatalExceptionRecord.ExceptionCode = STATUS_NONCONTINUABLE_EXCEPTION;
|
||||||
|
FatalExceptionRecord.ExceptionFlags = EH_NONCONTINUABLE;
|
||||||
|
FatalExceptionRecord.NumberParameters = 0;
|
||||||
|
RtlRaiseException(&FatalExceptionRecord);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return DISPOSITION_CONTINUE_SEARCH;
|
||||||
|
break;
|
||||||
|
case DISPOSITION_CONTINUE_SEARCH:
|
||||||
|
break;
|
||||||
|
case DISPOSITION_NESTED_EXCEPTION:
|
||||||
|
ExceptionRecord->ExceptionFlags |= EH_EXIT_UNWIND;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
FatalExceptionRecord.ExceptionRecord = ExceptionRecord;
|
||||||
|
FatalExceptionRecord.ExceptionCode = STATUS_NONCONTINUABLE_EXCEPTION;
|
||||||
|
FatalExceptionRecord.ExceptionFlags = EH_NONCONTINUABLE;
|
||||||
|
FatalExceptionRecord.NumberParameters = 0;
|
||||||
|
RtlRaiseException(&FatalExceptionRecord);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
RegistrationFrame = RegistrationFrame->Prev;
|
||||||
|
}
|
||||||
|
return DISPOSITION_DISMISS;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
PEXCEPTION_REGISTRATION RtlpGetRegistrationHead(VOID)
|
||||||
|
{
|
||||||
|
PEXCEPTION_REGISTRATION __head;
|
||||||
|
/*
|
||||||
|
__asm {
|
||||||
|
mov eax, fs:[0]
|
||||||
|
mov __head,eax
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
return __head;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void RtlUnwind(PEXCEPTION_REGISTRATION RegistrationFrame,
|
||||||
|
PVOID ReturnAddress, // Unused
|
||||||
|
PEXCEPTION_RECORD ExceptionRecord,
|
||||||
|
DWORD _eax)
|
||||||
|
{
|
||||||
|
NTSTATUS errCode, retval;
|
||||||
|
DWORD StackBase;
|
||||||
|
DWORD StackTop;
|
||||||
|
CONTEXT Context;
|
||||||
|
PEXCEPTION_REGISTRATION TraversingFrame;
|
||||||
|
EXCEPTION_RECORD TraversingRecord;
|
||||||
|
EXCEPTION_RECORD DispatcherContext;
|
||||||
|
|
||||||
|
|
||||||
|
/* build an exception record, if we do not have one */
|
||||||
|
if(ExceptionRecord != NULL)
|
||||||
|
{
|
||||||
|
ExceptionRecord->ExceptionCode = (DWORD)STATUS_UNWIND; //STATUS_INVALID_DISPOSITION;
|
||||||
|
ExceptionRecord->ExceptionFlags = 0;
|
||||||
|
ExceptionRecord->ExceptionRecord = NULL;
|
||||||
|
//ExceptionRecord->ExceptionAddress = (LPVOID)pcontext->Eip;
|
||||||
|
ExceptionRecord->NumberParameters = 0;
|
||||||
|
ExceptionRecord->ExceptionInformation[0] =0;
|
||||||
|
|
||||||
|
|
||||||
|
if ( RegistrationFrame != NULL )
|
||||||
|
ExceptionRecord->ExceptionFlags |= EH_UNWINDING;
|
||||||
|
else
|
||||||
|
ExceptionRecord->ExceptionFlags |=
|
||||||
|
(EH_UNWINDING|EH_EXIT_UNWIND);
|
||||||
|
}
|
||||||
|
Context.ContextFlags |=
|
||||||
|
(CONTEXT_i386|CONTEXT_FULL);
|
||||||
|
RtlpCaptureContext(&Context);
|
||||||
|
Context.Esp += 0x10;
|
||||||
|
Context.Eax = _eax;
|
||||||
|
|
||||||
|
TraversingFrame = RtlpGetRegistrationHead();
|
||||||
|
|
||||||
|
while( ( TraversingFrame != NULL ) && ( TraversingFrame != END_OF_CHAIN ) && ( TraversingFrame != RegistrationFrame ) )
|
||||||
|
{
|
||||||
|
|
||||||
|
errCode = TraversingFrame->Handler(
|
||||||
|
ExceptionRecord,
|
||||||
|
TraversingFrame,
|
||||||
|
&Context,
|
||||||
|
&DispatcherContext);
|
||||||
|
if ( (retval == ExceptionCollidedUnwind) && (TraversingFrame != (LPVOID)&DispatcherContext) )
|
||||||
|
TraversingFrame = (LPVOID)&DispatcherContext;
|
||||||
|
else if ((TraversingFrame != RegistrationFrame) && (TraversingFrame != TraversingFrame->Prev) ) {
|
||||||
|
RtlpUnlinkHandler(TraversingFrame);
|
||||||
|
TraversingFrame = TraversingFrame->Prev;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void RtlpUnlinkHandler(PEXCEPTION_REGISTRATION __head)
|
||||||
|
{
|
||||||
|
PEXCEPTION_REGISTRATION theHead;
|
||||||
|
PEXCEPTION_REGISTRATION theLast;
|
||||||
|
theHead = RtlpGetRegistrationHead();
|
||||||
|
|
||||||
|
/*
|
||||||
|
if ( __head == NULL )
|
||||||
|
return;
|
||||||
|
|
||||||
|
if ( theHead == __head ) {
|
||||||
|
theHead = theHead->Prev;
|
||||||
|
__asm {
|
||||||
|
mov eax, theHead
|
||||||
|
mov fs:[0], eax
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
do {
|
||||||
|
theLast = theHead;
|
||||||
|
theHead = theHead->Prev;
|
||||||
|
if ( theHead == __head ) {
|
||||||
|
theLast->Prev = theHead->Prev;
|
||||||
|
}
|
||||||
|
} while ( theHead != NULL && theHead != END_OF_CHAIN );
|
||||||
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RtlpLinkHandler(PEXCEPTION_REGISTRATION __head)
|
||||||
|
{
|
||||||
|
PEXCEPTION_REGISTRATION theHead;
|
||||||
|
if (__head == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
theHead = RtlpGetRegistrationHead();
|
||||||
|
__head->Prev = theHead;
|
||||||
|
/*
|
||||||
|
__asm {
|
||||||
|
mov eax, __head
|
||||||
|
mov fs:[0], eax
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void RtlpCaptureContext(PCONTEXT Context)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RtlpGetStackLimits(void *StackBase, void *StackLimit)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
__asm{ mov eax, fs:[4]
|
||||||
|
mov StackBase, eax }
|
||||||
|
__asm{ mov eax, fs:[5]
|
||||||
|
mov StackLimit, eax }
|
||||||
|
*/
|
||||||
|
return;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void RtlRaiseException(struct _EXCEPTION_RECORD *ExceptionRecord)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -15,19 +15,209 @@
|
||||||
|
|
||||||
/* GLOBALS *******************************************************************/
|
/* GLOBALS *******************************************************************/
|
||||||
|
|
||||||
static unsigned char CurrentDirectory[255];
|
|
||||||
|
static unsigned short CurrentDirectoryW[MAX_PATH];
|
||||||
|
|
||||||
|
static unsigned short SystemDirectoryW[MAX_PATH];
|
||||||
|
|
||||||
|
static unsigned short WindowsDirectoryW[MAX_PATH];
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
DWORD GetCurrentDirectoryA(DWORD nBufferLength, LPSTR lpBuffer)
|
DWORD
|
||||||
|
STDCALL
|
||||||
|
GetCurrentDirectoryA(DWORD nBufferLength, LPSTR lpBuffer)
|
||||||
{
|
{
|
||||||
nBufferLength = min(nBufferLength, lstrlenA(CurrentDirectory));
|
UINT uSize,i;
|
||||||
lstrncpyA(lpBuffer,CurrentDirectory,nBufferLength);
|
if ( lpBuffer == NULL )
|
||||||
return(nBufferLength);
|
return 0;
|
||||||
|
uSize = lstrlenW(CurrentDirectoryW);
|
||||||
|
if ( nBufferLength > uSize ) {
|
||||||
|
i = 0;
|
||||||
|
while ((CurrentDirectoryW[i])!=0 && i < MAX_PATH)
|
||||||
|
{
|
||||||
|
lpBuffer[i] = (unsigned char)CurrentDirectoryW[i];
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
lpBuffer[i] = 0;
|
||||||
|
}
|
||||||
|
return uSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL SetCurrentDirectoryA(LPCSTR lpPathName)
|
DWORD
|
||||||
|
STDCALL
|
||||||
|
GetCurrentDirectoryW(
|
||||||
|
DWORD nBufferLength,
|
||||||
|
LPWSTR lpBuffer
|
||||||
|
)
|
||||||
{
|
{
|
||||||
lstrcpyA(CurrentDirectory,lpPathName);
|
UINT uSize;
|
||||||
|
if ( lpBuffer == NULL )
|
||||||
|
return 0;
|
||||||
|
uSize = lstrlenW(CurrentDirectoryW);
|
||||||
|
if ( nBufferLength > uSize )
|
||||||
|
lstrcpynW(lpBuffer,CurrentDirectoryW,uSize);
|
||||||
|
|
||||||
|
return uSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL
|
||||||
|
STDCALL
|
||||||
|
SetCurrentDirectoryA(LPCSTR lpPathName)
|
||||||
|
{
|
||||||
|
UINT i;
|
||||||
|
|
||||||
|
if ( lpPathName == NULL );
|
||||||
|
return FALSE;
|
||||||
|
if ( lstrlenA(lpPathName) > MAX_PATH );
|
||||||
|
return FALSE;
|
||||||
|
i = 0;
|
||||||
|
while ((lpPathName[i])!=0 && i < MAX_PATH)
|
||||||
|
{
|
||||||
|
CurrentDirectoryW[i] = (unsigned short)lpPathName[i];
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
CurrentDirectoryW[i] = 0;
|
||||||
|
|
||||||
return(TRUE);
|
return(TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
WINBOOL
|
||||||
|
STDCALL
|
||||||
|
SetCurrentDirectoryW(
|
||||||
|
LPCWSTR lpPathName
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if ( lpPathName == NULL );
|
||||||
|
return FALSE;
|
||||||
|
if ( lstrlenW(lpPathName) > MAX_PATH );
|
||||||
|
return FALSE;
|
||||||
|
lstrcpyW(CurrentDirectoryW,lpPathName);
|
||||||
|
return(TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD
|
||||||
|
STDCALL
|
||||||
|
GetTempPathA(
|
||||||
|
DWORD nBufferLength,
|
||||||
|
LPSTR lpBuffer
|
||||||
|
)
|
||||||
|
{
|
||||||
|
WCHAR BufferW[MAX_PATH];
|
||||||
|
DWORD retCode;
|
||||||
|
UINT i;
|
||||||
|
retCode = GetTempPathW(nBufferLength,BufferW);
|
||||||
|
i = 0;
|
||||||
|
while ((BufferW[i])!=0 && i < MAX_PATH)
|
||||||
|
{
|
||||||
|
lpBuffer[i] = (unsigned char)BufferW[i];
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
lpBuffer[i] = 0;
|
||||||
|
return retCode;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD
|
||||||
|
STDCALL
|
||||||
|
GetTempPathW(
|
||||||
|
DWORD nBufferLength,
|
||||||
|
LPWSTR lpBuffer
|
||||||
|
)
|
||||||
|
{
|
||||||
|
|
||||||
|
WCHAR EnvironmentBufferW[MAX_PATH];
|
||||||
|
UINT i;
|
||||||
|
|
||||||
|
EnvironmentBufferW[0] = 0;
|
||||||
|
i = GetEnvironmentVariableW(L"TMP",EnvironmentBufferW,MAX_PATH);
|
||||||
|
if ( i==0 )
|
||||||
|
i = GetEnvironmentVariableW(L"TEMP",EnvironmentBufferW,MAX_PATH);
|
||||||
|
if ( i==0 )
|
||||||
|
i = GetCurrentDirectoryW(MAX_PATH,EnvironmentBufferW);
|
||||||
|
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
UINT
|
||||||
|
STDCALL
|
||||||
|
GetSystemDirectoryA(
|
||||||
|
LPSTR lpBuffer,
|
||||||
|
UINT uSize
|
||||||
|
)
|
||||||
|
{
|
||||||
|
UINT uPathSize,i;
|
||||||
|
if ( lpBuffer == NULL )
|
||||||
|
return 0;
|
||||||
|
uPathSize = lstrlenW(SystemDirectoryW);
|
||||||
|
if ( uSize > uPathSize ) {
|
||||||
|
i = 0;
|
||||||
|
while ((SystemDirectoryW[i])!=0 && i < uSize)
|
||||||
|
{
|
||||||
|
lpBuffer[i] = (unsigned char)SystemDirectoryW[i];
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
lpBuffer[i] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return uPathSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
UINT
|
||||||
|
STDCALL
|
||||||
|
GetWindowsDirectoryA(
|
||||||
|
LPSTR lpBuffer,
|
||||||
|
UINT uSize
|
||||||
|
)
|
||||||
|
{
|
||||||
|
UINT uPathSize,i;
|
||||||
|
if ( lpBuffer == NULL )
|
||||||
|
return 0;
|
||||||
|
uPathSize = lstrlenW(WindowsDirectoryW);
|
||||||
|
if ( uSize > uPathSize ) {
|
||||||
|
i = 0;
|
||||||
|
while ((WindowsDirectoryW[i])!=0 && i < uSize)
|
||||||
|
{
|
||||||
|
lpBuffer[i] = (unsigned char)WindowsDirectoryW[i];
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
lpBuffer[i] = 0;
|
||||||
|
}
|
||||||
|
return uPathSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
UINT
|
||||||
|
STDCALL
|
||||||
|
GetSystemDirectoryW(
|
||||||
|
LPWSTR lpBuffer,
|
||||||
|
UINT uSize
|
||||||
|
)
|
||||||
|
{
|
||||||
|
UINT uPathSize;
|
||||||
|
if ( lpBuffer == NULL )
|
||||||
|
return 0;
|
||||||
|
uPathSize = lstrlenW(SystemDirectoryW);
|
||||||
|
if ( uSize > uPathSize )
|
||||||
|
lstrcpynW(lpBuffer,SystemDirectoryW,uPathSize);
|
||||||
|
|
||||||
|
|
||||||
|
return uPathSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
UINT
|
||||||
|
STDCALL
|
||||||
|
GetWindowsDirectoryW(
|
||||||
|
LPWSTR lpBuffer,
|
||||||
|
UINT uSize
|
||||||
|
)
|
||||||
|
{
|
||||||
|
UINT uPathSize;
|
||||||
|
if ( lpBuffer == NULL )
|
||||||
|
return 0;
|
||||||
|
uPathSize = lstrlenW(WindowsDirectoryW);
|
||||||
|
if ( uSize > uPathSize );
|
||||||
|
lstrcpynW(lpBuffer,WindowsDirectoryW,uPathSize);
|
||||||
|
|
||||||
|
return uPathSize;
|
||||||
|
}
|
127
reactos/lib/kernel32/file/deviceio.c
Normal file
127
reactos/lib/kernel32/file/deviceio.c
Normal file
|
@ -0,0 +1,127 @@
|
||||||
|
/*
|
||||||
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
|
* PROJECT: ReactOS system libraries
|
||||||
|
* FILE: lib/kernel32/file/deviceio.c
|
||||||
|
* PURPOSE: Device I/O and Overlapped Result functions
|
||||||
|
* PROGRAMMER: Ariadne (ariadne@xs4all.nl)
|
||||||
|
* UPDATE HISTORY:
|
||||||
|
* Created 01/11/98
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
#include <ddk/ntddk.h>
|
||||||
|
|
||||||
|
WINBOOL
|
||||||
|
STDCALL
|
||||||
|
DeviceIoControl(
|
||||||
|
HANDLE hDevice,
|
||||||
|
DWORD dwIoControlCode,
|
||||||
|
LPVOID lpInBuffer,
|
||||||
|
DWORD nInBufferSize,
|
||||||
|
LPVOID lpOutBuffer,
|
||||||
|
DWORD nOutBufferSize,
|
||||||
|
LPDWORD lpBytesReturned,
|
||||||
|
LPOVERLAPPED lpOverlapped
|
||||||
|
)
|
||||||
|
{
|
||||||
|
|
||||||
|
NTSTATUS errCode = 0;
|
||||||
|
HANDLE hEvent = NULL;
|
||||||
|
PIO_STATUS_BLOCK IoStatusBlock;
|
||||||
|
IO_STATUS_BLOCK IIosb;
|
||||||
|
|
||||||
|
WINBOOL bFsIoControlCode = FALSE;
|
||||||
|
|
||||||
|
if ( lpBytesReturned == NULL ) {
|
||||||
|
SetLastError(RtlNtStatusToDosError(STATUS_INVALID_PARAMETER));
|
||||||
|
return FALSE;;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( ( ( dwIoControlCode >> 16 ) & FILE_DEVICE_FILE_SYSTEM ) == FILE_DEVICE_FILE_SYSTEM )
|
||||||
|
bFsIoControlCode = TRUE;
|
||||||
|
else
|
||||||
|
bFsIoControlCode = FALSE;
|
||||||
|
|
||||||
|
if(lpOverlapped != NULL) {
|
||||||
|
hEvent = lpOverlapped->hEvent;
|
||||||
|
lpOverlapped->Internal = STATUS_PENDING;
|
||||||
|
IoStatusBlock = (PIO_STATUS_BLOCK)lpOverlapped;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
IoStatusBlock = &IIosb;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(bFsIoControlCode == TRUE) {
|
||||||
|
errCode = NtFsControlFile(hDevice,hEvent,NULL,NULL,IoStatusBlock,dwIoControlCode,lpInBuffer, nInBufferSize, lpOutBuffer, nOutBufferSize );
|
||||||
|
} else {
|
||||||
|
errCode = NtDeviceIoControlFile(hDevice,hEvent,NULL,NULL,IoStatusBlock,dwIoControlCode, lpInBuffer, nInBufferSize, lpOutBuffer, nOutBufferSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(errCode == STATUS_PENDING ) {
|
||||||
|
|
||||||
|
if(NtWaitForSingleObject(hDevice,FALSE,NULL) < 0) {
|
||||||
|
*lpBytesReturned = IoStatusBlock->Information;
|
||||||
|
SetLastError(RtlNtStatusToDosError(errCode));
|
||||||
|
return FALSE;;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if ( !NT_SUCCESS(errCode) ) {
|
||||||
|
SetLastError(RtlNtStatusToDosError(errCode));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
*lpBytesReturned = lpOverlapped->InternalHigh;
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
WINBOOL
|
||||||
|
STDCALL
|
||||||
|
GetOverlappedResult(
|
||||||
|
HANDLE hFile,
|
||||||
|
LPOVERLAPPED lpOverlapped,
|
||||||
|
LPDWORD lpNumberOfBytesTransferred,
|
||||||
|
WINBOOL bWait
|
||||||
|
)
|
||||||
|
{
|
||||||
|
DWORD WaitStatus;
|
||||||
|
|
||||||
|
if ( lpOverlapped == NULL ) {
|
||||||
|
SetLastError(RtlNtStatusToDosError(STATUS_INVALID_PARAMETER));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
if ( lpOverlapped ->Internal == STATUS_PENDING) {
|
||||||
|
if ( lpNumberOfBytesTransferred == 0 ) {
|
||||||
|
SetLastError(RtlNtStatusToDosError(STATUS_PENDING));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
else if ( bWait == TRUE ) {
|
||||||
|
if ( lpOverlapped->hEvent != NULL ) {
|
||||||
|
WaitStatus = WaitForSingleObject(lpOverlapped->hEvent,-1);
|
||||||
|
if ( WaitStatus == STATUS_TIMEOUT ) {
|
||||||
|
SetLastError(ERROR_IO_INCOMPLETE);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return GetOverlappedResult(hFile,lpOverlapped,lpNumberOfBytesTransferred,FALSE);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*lpNumberOfBytesTransferred = lpOverlapped->InternalHigh;
|
||||||
|
if ( lpOverlapped->Internal < 0 ) {
|
||||||
|
SetLastError(RtlNtStatusToDosError(lpOverlapped->Internal));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
396
reactos/lib/kernel32/file/dir.c
Normal file
396
reactos/lib/kernel32/file/dir.c
Normal file
|
@ -0,0 +1,396 @@
|
||||||
|
/*
|
||||||
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
|
* PROJECT: ReactOS system libraries
|
||||||
|
* FILE: lib/kernel32/file/dir.c
|
||||||
|
* PURPOSE: Directory functions
|
||||||
|
* PROGRAMMER: Ariadne ( ariadne@xs4all.nl)
|
||||||
|
* UPDATE HISTORY:
|
||||||
|
* Created 01/11/98
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
#include <ddk/ntddk.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <wstring.h>
|
||||||
|
#include <ddk/rtl.h>
|
||||||
|
|
||||||
|
|
||||||
|
WINBOOL
|
||||||
|
STDCALL
|
||||||
|
CreateDirectoryA(
|
||||||
|
LPCSTR lpPathName,
|
||||||
|
LPSECURITY_ATTRIBUTES lpSecurityAttributes
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return CreateDirectoryExA(NULL,lpPathName,lpSecurityAttributes);
|
||||||
|
}
|
||||||
|
|
||||||
|
WINBOOL
|
||||||
|
STDCALL
|
||||||
|
CreateDirectoryExA(
|
||||||
|
LPCSTR lpTemplateDirectory,
|
||||||
|
LPCSTR lpNewDirectory,
|
||||||
|
LPSECURITY_ATTRIBUTES lpSecurityAttributes
|
||||||
|
)
|
||||||
|
{
|
||||||
|
WCHAR TemplateDirectoryW[MAX_PATH];
|
||||||
|
WCHAR NewDirectoryW[MAX_PATH];
|
||||||
|
ULONG i;
|
||||||
|
i = 0;
|
||||||
|
while ((*lpTemplateDirectory)!=0 && i < MAX_PATH)
|
||||||
|
{
|
||||||
|
TemplateDirectoryW[i] = *lpTemplateDirectory;
|
||||||
|
lpTemplateDirectory++;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
TemplateDirectoryW[i] = 0;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
while ((*lpNewDirectory)!=0 && i < MAX_PATH)
|
||||||
|
{
|
||||||
|
NewDirectoryW[i] = *lpNewDirectory;
|
||||||
|
lpNewDirectory++;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
NewDirectoryW[i] = 0;
|
||||||
|
return CreateDirectoryExW(TemplateDirectoryW,NewDirectoryW,lpSecurityAttributes);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
WINBOOL
|
||||||
|
STDCALL
|
||||||
|
CreateDirectoryW(
|
||||||
|
LPCWSTR lpPathName,
|
||||||
|
LPSECURITY_ATTRIBUTES lpSecurityAttributes
|
||||||
|
)
|
||||||
|
{
|
||||||
|
|
||||||
|
return CreateDirectoryExW(NULL,lpPathName,lpSecurityAttributes);
|
||||||
|
}
|
||||||
|
|
||||||
|
WINBOOL
|
||||||
|
STDCALL
|
||||||
|
CreateDirectoryExW(
|
||||||
|
LPCWSTR lpTemplateDirectory,
|
||||||
|
LPCWSTR lpNewDirectory,
|
||||||
|
LPSECURITY_ATTRIBUTES lpSecurityAttributes
|
||||||
|
)
|
||||||
|
{
|
||||||
|
NTSTATUS errCode;
|
||||||
|
HANDLE DirectoryHandle;
|
||||||
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||||
|
UNICODE_STRING DirectoryNameString;
|
||||||
|
|
||||||
|
if ( lpTemplateDirectory != NULL ) {
|
||||||
|
// get object attributes from template directory
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
DirectoryNameString.Length = lstrlenW(lpNewDirectory)*sizeof(WCHAR);
|
||||||
|
DirectoryNameString.Buffer = (WCHAR *)lpNewDirectory;
|
||||||
|
DirectoryNameString.MaximumLength = DirectoryNameString.Length;
|
||||||
|
|
||||||
|
ObjectAttributes.Length = sizeof(OBJECT_ATTRIBUTES);
|
||||||
|
ObjectAttributes.RootDirectory = NULL;
|
||||||
|
ObjectAttributes.ObjectName = &DirectoryNameString;
|
||||||
|
ObjectAttributes.Attributes = OBJ_CASE_INSENSITIVE| OBJ_INHERIT;
|
||||||
|
ObjectAttributes.SecurityDescriptor = NULL;
|
||||||
|
ObjectAttributes.SecurityQualityOfService = NULL;
|
||||||
|
|
||||||
|
|
||||||
|
errCode = NtCreateDirectoryObject(
|
||||||
|
&DirectoryHandle,
|
||||||
|
GENERIC_ALL,
|
||||||
|
&ObjectAttributes
|
||||||
|
);
|
||||||
|
if (!NT_SUCCESS(errCode) ) {
|
||||||
|
SetLastError(RtlNtStatusToDosError(errCode));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
WINBOOL
|
||||||
|
STDCALL
|
||||||
|
RemoveDirectoryA(
|
||||||
|
LPCSTR lpPathName
|
||||||
|
)
|
||||||
|
{
|
||||||
|
WCHAR PathNameW[MAX_PATH];
|
||||||
|
ULONG i;
|
||||||
|
i = 0;
|
||||||
|
while ((*lpPathName)!=0 && i < MAX_PATH)
|
||||||
|
{
|
||||||
|
PathNameW[i] = *lpPathName;
|
||||||
|
lpPathName++;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
PathNameW[i] = 0;
|
||||||
|
return RemoveDirectoryW(PathNameW);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
WINBOOL
|
||||||
|
STDCALL
|
||||||
|
RemoveDirectoryW(
|
||||||
|
LPCWSTR lpPathName
|
||||||
|
)
|
||||||
|
{
|
||||||
|
NTSTATUS errCode;
|
||||||
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||||
|
UNICODE_STRING PathNameString;
|
||||||
|
|
||||||
|
PathNameString.Length = lstrlenW(lpPathName)*sizeof(WCHAR);
|
||||||
|
PathNameString.Buffer = (WCHAR *)lpPathName;
|
||||||
|
PathNameString.MaximumLength = PathNameString.Length;
|
||||||
|
|
||||||
|
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 = NtDeleteFile(
|
||||||
|
&ObjectAttributes
|
||||||
|
);
|
||||||
|
if (!NT_SUCCESS(errCode) ) {
|
||||||
|
SetLastError(RtlNtStatusToDosError(errCode));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD
|
||||||
|
STDCALL
|
||||||
|
GetFullPathNameA(
|
||||||
|
LPCSTR lpFileName,
|
||||||
|
DWORD nBufferLength,
|
||||||
|
LPSTR lpBuffer,
|
||||||
|
LPSTR *lpFilePart
|
||||||
|
)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
DWORD
|
||||||
|
STDCALL
|
||||||
|
GetFullPathNameW(
|
||||||
|
LPCWSTR lpFileName,
|
||||||
|
DWORD nBufferLength,
|
||||||
|
LPWSTR lpBuffer,
|
||||||
|
LPWSTR *lpFilePart
|
||||||
|
)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD
|
||||||
|
STDCALL
|
||||||
|
GetShortPathNameA(
|
||||||
|
LPCSTR lpszLongPath,
|
||||||
|
LPSTR lpszShortPath,
|
||||||
|
DWORD cchBuffer
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//1 remove unicode chars and spaces
|
||||||
|
//2 remove preceding and trailing periods.
|
||||||
|
//3 remove embedded periods except the last one
|
||||||
|
|
||||||
|
//4 Split the string in two parts before and after the period
|
||||||
|
// truncate the part before the period to 6 chars and add ~1
|
||||||
|
// truncate the part after the period to 3 chars
|
||||||
|
//3 Put the new name in uppercase
|
||||||
|
|
||||||
|
//4 Increment the ~1 string if the resulting name allready exists
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD
|
||||||
|
STDCALL
|
||||||
|
GetShortPathNameW(
|
||||||
|
LPCWSTR lpszLongPath,
|
||||||
|
LPWSTR lpszShortPath,
|
||||||
|
DWORD cchBuffer
|
||||||
|
)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD
|
||||||
|
STDCALL
|
||||||
|
SearchPathA(
|
||||||
|
LPCSTR lpPath,
|
||||||
|
LPCSTR lpFileName,
|
||||||
|
LPCSTR lpExtension,
|
||||||
|
DWORD nBufferLength,
|
||||||
|
LPSTR lpBuffer,
|
||||||
|
LPSTR *lpFilePart
|
||||||
|
)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD
|
||||||
|
STDCALL
|
||||||
|
SearchPathW(
|
||||||
|
LPCWSTR lpPath,
|
||||||
|
LPCWSTR lpFileName,
|
||||||
|
LPCWSTR lpExtension,
|
||||||
|
DWORD nBufferLength,
|
||||||
|
LPWSTR lpBuffer,
|
||||||
|
LPWSTR *lpFilePart
|
||||||
|
)
|
||||||
|
{
|
||||||
|
|
||||||
|
//1. The directory from which the application loaded.
|
||||||
|
//2. The current directory.
|
||||||
|
//3. Windows NT: The 32-bit Windows system directory. Use the GetSystemDirectory function to get the path of this directory. The name of this directory is SYSTEM32.
|
||||||
|
//4. Windows NT only: The 16-bit Windows system directory. There is no Win32 function that obtains the path of this directory, but it is searched. The name of this directory is SYSTEM.
|
||||||
|
//5. The Windows directory. Use the GetWindowsDirectory function to get the path of this directory.
|
||||||
|
//6. The directories that are listed in the PATH environment variable.
|
||||||
|
NTSTATUS errCode;
|
||||||
|
DWORD retCode = 0;
|
||||||
|
HANDLE FileHandle = NULL;
|
||||||
|
|
||||||
|
ULONG i,j;
|
||||||
|
|
||||||
|
WCHAR BufferW[MAX_PATH];
|
||||||
|
WCHAR FileAndExtensionW[MAX_PATH];
|
||||||
|
WCHAR *EnvironmentBufferW = NULL;
|
||||||
|
|
||||||
|
UNICODE_STRING PathString;
|
||||||
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||||
|
IO_STATUS_BLOCK IoStatusBlock;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if ( lpPath == NULL ) {
|
||||||
|
|
||||||
|
// check the directory from which the application loaded
|
||||||
|
|
||||||
|
if ( GetCurrentDirectoryW( MAX_PATH, BufferW ) > 0 ) {
|
||||||
|
retCode = SearchPathW(BufferW,lpFileName, lpExtension, nBufferLength, lpBuffer, lpFilePart );
|
||||||
|
if ( retCode != 0 )
|
||||||
|
return retCode;
|
||||||
|
}
|
||||||
|
if ( GetSystemDirectoryW( BufferW, MAX_PATH ) > 0 ) {
|
||||||
|
retCode = SearchPathW(BufferW,lpFileName, lpExtension, nBufferLength, lpBuffer, lpFilePart );
|
||||||
|
if ( retCode != 0 )
|
||||||
|
return retCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( GetWindowsDirectoryW( BufferW, MAX_PATH ) > 0 ) {
|
||||||
|
retCode = SearchPathW(BufferW,lpFileName, lpExtension, nBufferLength, lpBuffer, lpFilePart );
|
||||||
|
if ( retCode != 0 )
|
||||||
|
return retCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
j = GetEnvironmentVariableW(L"Path",EnvironmentBufferW,0);
|
||||||
|
EnvironmentBufferW = (WCHAR *) HeapAlloc(GetProcessHeap(),HEAP_GENERATE_EXCEPTIONS|HEAP_ZERO_MEMORY,(j+1)*sizeof(WCHAR));
|
||||||
|
|
||||||
|
j = GetEnvironmentVariableW(L"Path",EnvironmentBufferW,j+1);
|
||||||
|
|
||||||
|
for(i=0;i<j;i++) {
|
||||||
|
if ( EnvironmentBufferW[i] == L';' )
|
||||||
|
EnvironmentBufferW[i] = 0;
|
||||||
|
}
|
||||||
|
i = 0;
|
||||||
|
while ( retCode == 0 && i < j ) {
|
||||||
|
if ( EnvironmentBufferW[i] != 0 )
|
||||||
|
retCode = SearchPathW(&EnvironmentBufferW[i],lpFileName, lpExtension, nBufferLength, lpBuffer, lpFilePart );
|
||||||
|
i += lstrlenW(&EnvironmentBufferW[i]) + 1;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
HeapFree(GetProcessHeap(),0,EnvironmentBufferW);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return retCode;
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
FileAndExtensionW[0] = 0;
|
||||||
|
lpBuffer[0] = 0;
|
||||||
|
i = lstrlenW(lpFileName);
|
||||||
|
j = lstrlenW(lpPath);
|
||||||
|
|
||||||
|
if ( i + j + 8 < nBufferLength )
|
||||||
|
return i + j + 9;
|
||||||
|
|
||||||
|
if ( lpExtension != NULL ) {
|
||||||
|
if ( lpFileName[i-4] != L'.' ) {
|
||||||
|
memcpy(FileAndExtensionW,lpFileName,(i+1)*sizeof(WCHAR));
|
||||||
|
lstrcatW(FileAndExtensionW,lpExtension);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
memcpy(FileAndExtensionW,lpFileName,(i+1)*sizeof(WCHAR));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
memcpy(FileAndExtensionW,lpFileName,(i+1)*sizeof(WCHAR));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if ( lpPath[0] == L'\\' )
|
||||||
|
lstrcatW(lpBuffer,lpPath);
|
||||||
|
else {
|
||||||
|
lstrcatW(lpBuffer,L"\\??\\");
|
||||||
|
lstrcatW(lpBuffer,lpPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
//printf("%S\n",FileAndExtensionW);
|
||||||
|
|
||||||
|
|
||||||
|
i = lstrlenW(lpBuffer);
|
||||||
|
if ( lpBuffer[i-1] != L'\\' ) {
|
||||||
|
lpBuffer[i] = L'\\';
|
||||||
|
lpBuffer[i+1] = 0;
|
||||||
|
}
|
||||||
|
if ( lpFilePart != NULL )
|
||||||
|
*lpFilePart = &lpBuffer[lstrlenW(lpBuffer)+1];
|
||||||
|
lstrcatW(lpBuffer,FileAndExtensionW);
|
||||||
|
//printf("%S\n",lpBuffer);
|
||||||
|
|
||||||
|
PathString.Buffer = lpBuffer;
|
||||||
|
PathString.Length = lstrlenW(PathString.Buffer)*sizeof(WCHAR);
|
||||||
|
PathString.MaximumLength = PathString.Length;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ObjectAttributes.Length = sizeof(OBJECT_ATTRIBUTES);
|
||||||
|
ObjectAttributes.RootDirectory = NULL;
|
||||||
|
ObjectAttributes.ObjectName = &PathString;
|
||||||
|
ObjectAttributes.Attributes = OBJ_CASE_INSENSITIVE| OBJ_INHERIT;
|
||||||
|
ObjectAttributes.SecurityDescriptor = NULL;
|
||||||
|
ObjectAttributes.SecurityQualityOfService = NULL;
|
||||||
|
|
||||||
|
errCode = NtOpenFile(
|
||||||
|
&FileHandle,
|
||||||
|
GENERIC_ALL|FILE_LIST_DIRECTORY,
|
||||||
|
&ObjectAttributes,
|
||||||
|
&IoStatusBlock,
|
||||||
|
FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
|
||||||
|
0
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if ( !NT_SUCCESS(errCode) ) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return lstrlenW(lpBuffer);
|
||||||
|
|
||||||
|
}
|
110
reactos/lib/kernel32/file/dosdev.c
Normal file
110
reactos/lib/kernel32/file/dosdev.c
Normal file
|
@ -0,0 +1,110 @@
|
||||||
|
/*
|
||||||
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
|
* PROJECT: ReactOS system libraries
|
||||||
|
* FILE: lib/kernel32/file/dosdev.c
|
||||||
|
* PURPOSE: Dos device functions
|
||||||
|
* PROGRAMMER: Ariadne ( ariadne@xs4all.nl)
|
||||||
|
* UPDATE HISTORY:
|
||||||
|
* Created 01/11/98
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
#include <ddk/ntddk.h>
|
||||||
|
|
||||||
|
|
||||||
|
WINBOOL
|
||||||
|
STDCALL
|
||||||
|
DefineDosDeviceA(
|
||||||
|
DWORD dwFlags,
|
||||||
|
LPCSTR lpDeviceName,
|
||||||
|
LPCSTR lpTargetPath
|
||||||
|
)
|
||||||
|
{
|
||||||
|
ULONG i;
|
||||||
|
|
||||||
|
WCHAR DeviceNameW[MAX_PATH];
|
||||||
|
WCHAR TargetPathW[MAX_PATH];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
while ((*lpDeviceName)!=0 && i < MAX_PATH)
|
||||||
|
{
|
||||||
|
DeviceNameW[i] = *lpDeviceName;
|
||||||
|
lpDeviceName++;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
DeviceNameW[i] = 0;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
while ((*lpTargetPath)!=0 && i < MAX_PATH)
|
||||||
|
{
|
||||||
|
TargetPathW[i] = *lpTargetPath;
|
||||||
|
lpTargetPath++;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
TargetPathW[i] = 0;
|
||||||
|
return DefineDosDeviceW(dwFlags,DeviceNameW,TargetPathW);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
DWORD
|
||||||
|
STDCALL
|
||||||
|
QueryDosDeviceA(
|
||||||
|
LPCSTR lpDeviceName,
|
||||||
|
LPSTR lpTargetPath,
|
||||||
|
DWORD ucchMax
|
||||||
|
)
|
||||||
|
{
|
||||||
|
ULONG i;
|
||||||
|
|
||||||
|
WCHAR DeviceNameW[MAX_PATH];
|
||||||
|
WCHAR TargetPathW[MAX_PATH];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
while ((*lpDeviceName)!=0 && i < MAX_PATH)
|
||||||
|
{
|
||||||
|
DeviceNameW[i] = *lpDeviceName;
|
||||||
|
lpDeviceName++;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
DeviceNameW[i] = 0;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
while ((*lpTargetPath)!=0 && i < MAX_PATH)
|
||||||
|
{
|
||||||
|
TargetPathW[i] = *lpTargetPath;
|
||||||
|
lpTargetPath++;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
TargetPathW[i] = 0;
|
||||||
|
return QueryDosDeviceW(DeviceNameW,TargetPathW,ucchMax);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
WINBOOL
|
||||||
|
STDCALL
|
||||||
|
DefineDosDeviceW(
|
||||||
|
DWORD dwFlags,
|
||||||
|
LPCWSTR lpDeviceName,
|
||||||
|
LPCWSTR lpTargetPath
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD
|
||||||
|
STDCALL
|
||||||
|
QueryDosDeviceW(
|
||||||
|
LPCWSTR lpDeviceName,
|
||||||
|
LPWSTR lpTargetPath,
|
||||||
|
DWORD ucchMax
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load diff
521
reactos/lib/kernel32/file/find.c
Normal file
521
reactos/lib/kernel32/file/find.c
Normal file
|
@ -0,0 +1,521 @@
|
||||||
|
/*
|
||||||
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
|
* PROJECT: ReactOS system libraries
|
||||||
|
* FILE: lib/kernel32/file/find.c
|
||||||
|
* PURPOSE: Find functions
|
||||||
|
* PROGRAMMER: Ariadne ( ariadne@xs4all.nl)
|
||||||
|
* UPDATE HISTORY:
|
||||||
|
* Created 01/11/98
|
||||||
|
*/
|
||||||
|
#include <windows.h>
|
||||||
|
#include <wstring.h>
|
||||||
|
|
||||||
|
typedef enum _FINDEX_INFO_LEVELS
|
||||||
|
{
|
||||||
|
FindExSearchNameMatch,
|
||||||
|
FindExSearchLimitToDirectories,
|
||||||
|
FindExSearchLimitToDevices,
|
||||||
|
|
||||||
|
} FINDEX_INFO_LEVELS ;
|
||||||
|
|
||||||
|
typedef enum _FINDEX_SEARCH_OPS
|
||||||
|
{
|
||||||
|
FindExInfoStandard
|
||||||
|
|
||||||
|
} FINDEX_SEARCH_OPS;
|
||||||
|
|
||||||
|
int wcharicmp ( WCHAR char1, WCHAR char2 );
|
||||||
|
|
||||||
|
WINBOOL
|
||||||
|
mfs_regexp(LPCWSTR lpFileName,LPCWSTR lpFilter);
|
||||||
|
|
||||||
|
HANDLE
|
||||||
|
STDCALL
|
||||||
|
FindFirstFileW(
|
||||||
|
LPWSTR lpFileName,
|
||||||
|
LPWIN32_FIND_DATA lpFindFileData
|
||||||
|
);
|
||||||
|
|
||||||
|
WINBOOL
|
||||||
|
STDCALL
|
||||||
|
FindNextFileW(
|
||||||
|
HANDLE hFind,
|
||||||
|
LPWIN32_FIND_DATA lpFindFileData
|
||||||
|
);
|
||||||
|
|
||||||
|
HANDLE
|
||||||
|
STDCALL
|
||||||
|
FindFirstFileExA(
|
||||||
|
LPCSTR lpFileName,
|
||||||
|
FINDEX_INFO_LEVELS fInfoLevelId,
|
||||||
|
LPVOID lpFindFileData,
|
||||||
|
FINDEX_SEARCH_OPS fSearchOp,
|
||||||
|
LPVOID lpSearchFilter,
|
||||||
|
DWORD dwAdditionalFlags
|
||||||
|
);
|
||||||
|
|
||||||
|
HANDLE
|
||||||
|
STDCALL
|
||||||
|
FindFirstFileExW(
|
||||||
|
LPCWSTR lpFileName,
|
||||||
|
FINDEX_INFO_LEVELS fInfoLevelId,
|
||||||
|
LPVOID lpFindFileData,
|
||||||
|
FINDEX_SEARCH_OPS fSearchOp,
|
||||||
|
LPVOID lpSearchFilter,
|
||||||
|
DWORD dwAdditionalFlags
|
||||||
|
);
|
||||||
|
|
||||||
|
typedef struct _FIND_FILE_INFO
|
||||||
|
{
|
||||||
|
ULONG Offset;
|
||||||
|
PVOID SearchFilter;
|
||||||
|
WCHAR FileName[MAX_PATH];
|
||||||
|
WCHAR PathName[MAX_PATH];
|
||||||
|
FILE_DIRECTORY_INFORMATION *FileDirectory;
|
||||||
|
} FIND_FILE_INFO;
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
typedef struct _WIN32_FIND_DATAW {
|
||||||
|
DWORD dwFileAttributes;
|
||||||
|
FILETIME ftCreationTime;
|
||||||
|
FILETIME ftLastAccessTime;
|
||||||
|
FILETIME ftLastWriteTime;
|
||||||
|
DWORD nFileSizeHigh;
|
||||||
|
DWORD nFileSizeLow;
|
||||||
|
DWORD dwReserved0;
|
||||||
|
DWORD dwReserved1;
|
||||||
|
WCHAR cFileName[ MAX_PATH ];
|
||||||
|
WCHAR cAlternateFileName[ 14 ];
|
||||||
|
} WIN32_FIND_DATAW, *LPWIN32_FIND_DATAW, *PWIN32_FIND_DATAW;
|
||||||
|
*/
|
||||||
|
|
||||||
|
WINBOOL
|
||||||
|
STDCALL
|
||||||
|
FindClose(
|
||||||
|
HANDLE hFind
|
||||||
|
)
|
||||||
|
{
|
||||||
|
|
||||||
|
if ( hFind == NULL)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
|
||||||
|
HeapFree(GetProcessHeap(),0,((FIND_FILE_INFO *)hFind)->FileDirectory);
|
||||||
|
HeapFree(GetProcessHeap(),0,hFind);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
HANDLE
|
||||||
|
STDCALL
|
||||||
|
FindFirstFileA(
|
||||||
|
LPCSTR lpFileName,
|
||||||
|
LPWIN32_FIND_DATA lpFindFileData
|
||||||
|
)
|
||||||
|
{
|
||||||
|
WIN32_FIND_DATA FindFileDataW;
|
||||||
|
WCHAR FileNameW[MAX_PATH];
|
||||||
|
ULONG i;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
while ((*lpFileName)!=0 && i < MAX_PATH)
|
||||||
|
{
|
||||||
|
FileNameW[i] = *lpFileName;
|
||||||
|
lpFileName++;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
FileNameW[i] = 0;
|
||||||
|
FindFirstFileW(FileNameW,&FindFileDataW);
|
||||||
|
|
||||||
|
// converteer FindFileDataW
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
HANDLE
|
||||||
|
STDCALL
|
||||||
|
FindFirstFileW(
|
||||||
|
LPWSTR lpFileName,
|
||||||
|
LPWIN32_FIND_DATA lpFindFileData
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return FindFirstFileExW(lpFileName,FindExInfoStandard,lpFindFileData,FindExSearchNameMatch,NULL,0);
|
||||||
|
}
|
||||||
|
|
||||||
|
WINBOOL
|
||||||
|
STDCALL
|
||||||
|
FindNextFileA(
|
||||||
|
HANDLE hFind,
|
||||||
|
LPWIN32_FIND_DATA lpFindFileData
|
||||||
|
)
|
||||||
|
{
|
||||||
|
WIN32_FIND_DATA FindFileDataW;
|
||||||
|
FindNextFileW(hFind,&FindFileDataW);
|
||||||
|
// converteer FindFileDataW
|
||||||
|
}
|
||||||
|
|
||||||
|
WINBOOL
|
||||||
|
STDCALL
|
||||||
|
FindNextFileW(
|
||||||
|
HANDLE hFind,
|
||||||
|
LPWIN32_FIND_DATA lpFindFileData
|
||||||
|
)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
WCHAR *pNameRead;
|
||||||
|
WCHAR FileName[MAX_PATH];
|
||||||
|
|
||||||
|
FIND_FILE_INFO *FindPtr = hFind;
|
||||||
|
FILE_DIRECTORY_INFORMATION *FileDirectory;
|
||||||
|
|
||||||
|
if ( FindPtr == NULL )
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
/* Try to find a file */
|
||||||
|
FileDirectory = FindPtr->Offset + FindPtr->FileDirectory;
|
||||||
|
while ( FileDirectory->NextEntryOffset != 0 ) {
|
||||||
|
|
||||||
|
pNameRead = FileDirectory->FileName;
|
||||||
|
FindPtr->Offset += FileDirectory->NextEntryOffset;
|
||||||
|
for(i=0;i<FileDirectory->FileNameLength;i++)
|
||||||
|
printf("%c\n",(char)pNameRead[i]);
|
||||||
|
if (mfs_regexp(pNameRead, FindPtr->FileName))
|
||||||
|
{
|
||||||
|
/* We found one! */
|
||||||
|
if (FindPtr->PathName[0] != L'\0')
|
||||||
|
{
|
||||||
|
lstrcpyW(lpFindFileData->cFileName, FindPtr->PathName);
|
||||||
|
lstrcatW(lpFindFileData->cFileName, L"/");
|
||||||
|
lstrcatW(lpFindFileData->cFileName, pNameRead);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
|
||||||
|
lstrcpyW(lpFindFileData->cFileName, pNameRead);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
lstrcpyW(lpFindFileData->cAlternateFileName, L"");
|
||||||
|
lpFindFileData->dwReserved0 = 0;
|
||||||
|
lpFindFileData->dwReserved1 = 0;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
FileDirectory = FindPtr->Offset + FindPtr->FileDirectory;
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
HANDLE
|
||||||
|
STDCALL
|
||||||
|
FindFirstFileExA(
|
||||||
|
LPCSTR lpFileName,
|
||||||
|
FINDEX_INFO_LEVELS fInfoLevelId,
|
||||||
|
LPVOID lpFindFileData,
|
||||||
|
FINDEX_SEARCH_OPS fSearchOp,
|
||||||
|
LPVOID lpSearchFilter,
|
||||||
|
DWORD dwAdditionalFlags
|
||||||
|
)
|
||||||
|
{
|
||||||
|
WCHAR FileNameW[MAX_PATH];
|
||||||
|
WIN32_FIND_DATAW FindFileDataW;
|
||||||
|
FindFirstFileExW(FileNameW,fInfoLevelId,&FindFileDataW,fSearchOp,lpSearchFilter,dwAdditionalFlags);
|
||||||
|
// conerteer FindFileDataW
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
HANDLE
|
||||||
|
STDCALL
|
||||||
|
FindFirstFileExW(
|
||||||
|
LPCWSTR lpFileName,
|
||||||
|
FINDEX_INFO_LEVELS fInfoLevelId,
|
||||||
|
LPVOID lpFindFileData,
|
||||||
|
FINDEX_SEARCH_OPS fSearchOp,
|
||||||
|
LPVOID lpSearchFilter,
|
||||||
|
DWORD dwAdditionalFlags
|
||||||
|
)
|
||||||
|
{
|
||||||
|
NTSTATUS errCode;
|
||||||
|
IO_STATUS_BLOCK IoStatusBlock;
|
||||||
|
HANDLE FileHandle = NULL;
|
||||||
|
FIND_FILE_INFO *hFind;
|
||||||
|
WCHAR *FilePart;
|
||||||
|
UNICODE_STRING FileNameString, PathNameString;
|
||||||
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||||
|
|
||||||
|
|
||||||
|
ACCESS_MASK DesiredAccess=FILE_READ_DATA;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
|
||||||
|
hFind = HeapAlloc(GetProcessHeap(),HEAP_GENERATE_EXCEPTIONS|HEAP_ZERO_MEMORY,sizeof(FIND_FILE_INFO));
|
||||||
|
|
||||||
|
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){
|
||||||
|
GetCurrentDirectory(MAX_PATH, hFind->PathName);
|
||||||
|
lstrcpyW(hFind->FileName, lpFileName);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
FilePart[0] = L'\0';
|
||||||
|
lstrcpyW(hFind->FileName, &FilePart[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
hFind->Offset = 0;
|
||||||
|
|
||||||
|
|
||||||
|
PathNameString.Length = lstrlenW(hFind->PathName)*sizeof(WCHAR);
|
||||||
|
PathNameString.Buffer = hFind->PathName;
|
||||||
|
PathNameString.MaximumLength = FileNameString.Length;
|
||||||
|
|
||||||
|
|
||||||
|
FileNameString.Length = lstrlenW(hFind->FileName)*sizeof(WCHAR);
|
||||||
|
FileNameString.Buffer = hFind->FileName;
|
||||||
|
FileNameString.MaximumLength = FileNameString.Length;
|
||||||
|
|
||||||
|
|
||||||
|
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, // AllocationSize
|
||||||
|
FileAttributes,
|
||||||
|
ShareAccess,
|
||||||
|
CreateDisposition,
|
||||||
|
CreateOptions,
|
||||||
|
NULL, // EaBuffer
|
||||||
|
0); //
|
||||||
|
|
||||||
|
if ( !NT_SUCCESS(errCode) ) {
|
||||||
|
printf("%x\n",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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
WINBOOL
|
||||||
|
FindCloseChangeNotification(
|
||||||
|
HANDLE hChangeHandle
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
HANDLE
|
||||||
|
STDCALL
|
||||||
|
FindFirstChangeNotificationA(
|
||||||
|
LPCSTR lpPathName,
|
||||||
|
WINBOOL bWatchSubtree,
|
||||||
|
DWORD dwNotifyFilter
|
||||||
|
)
|
||||||
|
{
|
||||||
|
ULONG i;
|
||||||
|
|
||||||
|
WCHAR PathNameW[MAX_PATH];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
while ((*lpPathName)!=0 && i < MAX_PATH)
|
||||||
|
{
|
||||||
|
PathNameW[i] = *lpPathName;
|
||||||
|
lpPathName++;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
PathNameW[i] = 0;
|
||||||
|
return FindFirstChangeNotificationW(PathNameW, bWatchSubtree, dwNotifyFilter );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
HANDLE
|
||||||
|
STDCALL
|
||||||
|
FindFirstChangeNotificationW(
|
||||||
|
LPCWSTR lpPathName,
|
||||||
|
WINBOOL bWatchSubtree,
|
||||||
|
DWORD dwNotifyFilter
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
WINBOOL
|
||||||
|
STDCALL
|
||||||
|
FindNextChangeNotification(
|
||||||
|
HANDLE hChangeHandle
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/************************************************************************/
|
||||||
|
WINBOOL
|
||||||
|
mfs_regexp(LPCWSTR lpFileName,LPCWSTR lpFilter)
|
||||||
|
{
|
||||||
|
/* The following code is provided by Tarang and I trust him...
|
||||||
|
*/
|
||||||
|
LPWSTR lpTempFileName = (LPWSTR)lpFileName;
|
||||||
|
LPWSTR lpTempFilter = (LPWSTR)lpFilter;
|
||||||
|
WCHAR TempToken [ 2 ];
|
||||||
|
WCHAR TempFilter [ 2 ];
|
||||||
|
WINBOOL Matched = FALSE;
|
||||||
|
|
||||||
|
if ( ( ! (LPWSTR)lpFileName ) || ( ! *(LPWSTR)lpFileName ) ||
|
||||||
|
( ! (LPWSTR)lpFilter ) || ( ! *(LPWSTR)lpFilter ) )
|
||||||
|
return 0L;
|
||||||
|
|
||||||
|
if ( ! lstrcmpW ( ( LPSTR )lpFilter, "*.*" ) )
|
||||||
|
{
|
||||||
|
wsprintf ( TempFilter, "*" );
|
||||||
|
lpTempFilter = TempFilter;
|
||||||
|
lpFilter = TempFilter;
|
||||||
|
}
|
||||||
|
|
||||||
|
while ( ( lpTempFilter ) && ( *lpTempFilter ) && ( ! Matched ) )
|
||||||
|
{
|
||||||
|
memset ( TempToken, 0, sizeof ( TempToken ) );
|
||||||
|
switch ( *lpTempFilter )
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
if ( wcharicmp ( *lpTempFileName, *lpTempFilter ) )
|
||||||
|
{
|
||||||
|
lpTempFileName = (LPWSTR)lpFileName;
|
||||||
|
lpTempFilter = wcspbrk ( lpTempFilter, L" ,;" );
|
||||||
|
if ( lpTempFilter )
|
||||||
|
lpTempFilter+=sizeof(WCHAR);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lpTempFilter+=sizeof(WCHAR);
|
||||||
|
lpTempFileName+=sizeof(WCHAR);
|
||||||
|
switch ( *lpTempFilter )
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case L'\0':
|
||||||
|
case L' ':
|
||||||
|
case L',':
|
||||||
|
case L';':
|
||||||
|
if ( ! *lpTempFileName )
|
||||||
|
Matched = TRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case L'?':
|
||||||
|
lpTempFilter+=sizeof(WCHAR);
|
||||||
|
lpTempFileName+=sizeof(WCHAR);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case L'*':
|
||||||
|
lpTempFilter += sizeof(WCHAR);
|
||||||
|
if ( ! ( TempToken [ 0 ] = *( lpTempFilter ) ) )
|
||||||
|
Matched = TRUE;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lpTempFilter+=sizeof(WCHAR);
|
||||||
|
while ( ( lpTempFileName = wcspbrk ( lpTempFileName, TempToken ) ) &&
|
||||||
|
( ! Matched ) ) {
|
||||||
|
lpTempFileName+= sizeof(WCHAR);
|
||||||
|
Matched = mfs_regexp ( lpTempFileName, lpTempFilter );
|
||||||
|
}
|
||||||
|
if ( ( ! lpTempFileName ) && ( ! Matched ) )
|
||||||
|
{
|
||||||
|
lpTempFileName = (LPWSTR)lpFileName;
|
||||||
|
lpTempFilter = wcspbrk ( lpTempFilter, L" ,;" );
|
||||||
|
if ( lpTempFilter )
|
||||||
|
lpTempFilter+=sizeof(WCHAR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case L'\0':
|
||||||
|
case L' ':
|
||||||
|
case L',':
|
||||||
|
case L';':
|
||||||
|
Matched = TRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (DWORD)Matched;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int wcharicmp ( WCHAR char1, WCHAR char2 )
|
||||||
|
{
|
||||||
|
WCHAR Char1 = ( L'a' <= char1 ) && ( char1 <= L'z' ) ?
|
||||||
|
char1 - L'a' + L'A' : char1;
|
||||||
|
WCHAR Char2 = ( L'a' <= char2 ) && ( char2 <= L'z' ) ?
|
||||||
|
char2 - L'a' + L'A' : char2;
|
||||||
|
return ( Char2 - Char1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
149
reactos/lib/kernel32/file/iocompl.c
Normal file
149
reactos/lib/kernel32/file/iocompl.c
Normal file
|
@ -0,0 +1,149 @@
|
||||||
|
/*
|
||||||
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
|
* PROJECT: ReactOS system libraries
|
||||||
|
* FILE: lib/kernel32/file/iocompl.c
|
||||||
|
* PURPOSE: Io Completion functions
|
||||||
|
* PROGRAMMER: Ariadne ( ariadne@xs4all.nl)
|
||||||
|
* UPDATE HISTORY:
|
||||||
|
* Created 01/11/98
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
#include <ddk/ntddk.h>
|
||||||
|
#include <wstring.h>
|
||||||
|
#include <ddk/rtl.h>
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct _FILE_COMPLETION_INFORMATION {
|
||||||
|
HANDLE CompletionPort;
|
||||||
|
ULONG CompletionKey;
|
||||||
|
} FILE_COMPLETION_INFORMATION;
|
||||||
|
typedef FILE_COMPLETION_INFORMATION *PFILE_COMPLETION_INFORMATION;
|
||||||
|
|
||||||
|
|
||||||
|
VOID
|
||||||
|
STDCALL
|
||||||
|
FileIOCompletionRoutine(
|
||||||
|
DWORD dwErrorCode,
|
||||||
|
DWORD dwNumberOfBytesTransfered,
|
||||||
|
LPOVERLAPPED lpOverlapped
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
HANDLE
|
||||||
|
STDCALL
|
||||||
|
CreateIoCompletionPort(
|
||||||
|
HANDLE FileHandle,
|
||||||
|
HANDLE ExistingCompletionPort,
|
||||||
|
DWORD CompletionKey,
|
||||||
|
DWORD NumberOfConcurrentThreads
|
||||||
|
)
|
||||||
|
{
|
||||||
|
HANDLE CompletionPort = NULL;
|
||||||
|
NTSTATUS errCode;
|
||||||
|
FILE_COMPLETION_INFORMATION CompletionInformation;
|
||||||
|
IO_STATUS_BLOCK IoStatusBlock;
|
||||||
|
|
||||||
|
if ( ExistingCompletionPort == NULL && FileHandle == INVALID_HANDLE_VALUE ) {
|
||||||
|
SetLastError(RtlNtStatusToDosError(STATUS_INVALID_PARAMETER));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ExistingCompletionPort != NULL ) {
|
||||||
|
CompletionPort = ExistingCompletionPort;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
errCode = NtCreateIoCompletion(&CompletionPort,GENERIC_ALL,&IoStatusBlock,NumberOfConcurrentThreads);
|
||||||
|
if (!NT_SUCCESS(errCode) ) {
|
||||||
|
SetLastError(RtlNtStatusToDosError(errCode));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
if ( FileHandle != INVALID_HANDLE_VALUE ) {
|
||||||
|
|
||||||
|
CompletionInformation.CompletionPort = CompletionPort;
|
||||||
|
CompletionInformation.CompletionKey = CompletionKey;
|
||||||
|
|
||||||
|
errCode = NtSetInformationFile(FileHandle, &IoStatusBlock,&CompletionInformation,sizeof(FILE_COMPLETION_INFORMATION),FileCompletionInformation);
|
||||||
|
if ( !NT_SUCCESS(errCode) ) {
|
||||||
|
if ( ExistingCompletionPort == NULL )
|
||||||
|
NtClose(CompletionPort);
|
||||||
|
SetLastError(RtlNtStatusToDosError(errCode));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return CompletionPort;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
WINBOOL
|
||||||
|
STDCALL
|
||||||
|
GetQueuedCompletionStatus(
|
||||||
|
HANDLE CompletionPort,
|
||||||
|
LPDWORD lpNumberOfBytesTransferred,
|
||||||
|
LPDWORD lpCompletionKey,
|
||||||
|
LPOVERLAPPED *lpOverlapped,
|
||||||
|
DWORD dwMilliseconds
|
||||||
|
)
|
||||||
|
{
|
||||||
|
|
||||||
|
NTSTATUS errCode;
|
||||||
|
ULONG CompletionStatus;
|
||||||
|
LARGE_INTEGER TimeToWait;
|
||||||
|
|
||||||
|
errCode = NtRemoveIoCompletion(CompletionPort,(PULONG)lpCompletionKey,(PIO_STATUS_BLOCK)lpOverlapped,&CompletionStatus,&TimeToWait);
|
||||||
|
if (!NT_SUCCESS(errCode) ) {
|
||||||
|
SetLastError(RtlNtStatusToDosError(errCode));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
WINBOOL
|
||||||
|
STDCALL
|
||||||
|
PostQueuedCompletionStatus(
|
||||||
|
HANDLE CompletionPort,
|
||||||
|
DWORD dwNumberOfBytesTransferred,
|
||||||
|
DWORD dwCompletionKey,
|
||||||
|
LPOVERLAPPED lpOverlapped
|
||||||
|
)
|
||||||
|
{
|
||||||
|
|
||||||
|
NTSTATUS errCode;
|
||||||
|
errCode = NtSetIoCompletion(CompletionPort, dwCompletionKey, (PIO_STATUS_BLOCK)lpOverlapped , 0, (PULONG)&dwNumberOfBytesTransferred );
|
||||||
|
|
||||||
|
|
||||||
|
if ( !NT_SUCCESS(errCode) ) {
|
||||||
|
SetLastError(RtlNtStatusToDosError(errCode));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// this should be a place holder ??????????????????
|
||||||
|
VOID
|
||||||
|
STDCALL
|
||||||
|
FileIOCompletionRoutine(
|
||||||
|
DWORD dwErrorCode,
|
||||||
|
DWORD dwNumberOfBytesTransfered,
|
||||||
|
LPOVERLAPPED lpOverlapped
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,18 @@
|
||||||
/*
|
/*
|
||||||
* created: Boudewijn Dekker
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* org. source: WINE
|
* PROJECT: ReactOS system libraries
|
||||||
* date: june 1998
|
* FILE: lib/kernel32/file/lfile.c
|
||||||
* todo: check the _lopen for correctness
|
* PURPOSE: Find functions
|
||||||
|
* PROGRAMMER: Ariadne ( ariadne@xs4all.nl)
|
||||||
|
* UPDATE HISTORY:
|
||||||
|
* Created 01/11/98
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#undef WIN32_LEAN_AND_MEAN
|
#undef WIN32_LEAN_AND_MEAN
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <wstring.h>
|
#include <wstring.h>
|
||||||
#include <fcntl.h>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,7 +23,7 @@ long _hread(
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
DWORD NumberOfBytesRead;
|
DWORD NumberOfBytesRead;
|
||||||
if ( ReadFile((HANDLE)hFile,(LPCVOID)lpBuffer,(DWORD)lBytes,&NumberOfBytesRead, NULL) == FALSE )
|
if ( ReadFile((HANDLE)hFile,(LPVOID)lpBuffer,(DWORD)lBytes,&NumberOfBytesRead, NULL) == FALSE )
|
||||||
return -1;
|
return -1;
|
||||||
else
|
else
|
||||||
return NumberOfBytesRead;
|
return NumberOfBytesRead;
|
||||||
|
@ -47,7 +50,7 @@ long _hwrite(
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if ( WriteFile((HANDLE)hFile,(LPCVOID)lpBuffer,(DWORD)lBytes, &NumberOfBytesWritten,NULL) == FALSE )
|
if ( WriteFile((HANDLE)hFile,(LPVOID)lpBuffer,(DWORD)lBytes, &NumberOfBytesWritten,NULL) == FALSE )
|
||||||
return -1;
|
return -1;
|
||||||
else
|
else
|
||||||
return NumberOfBytesWritten;
|
return NumberOfBytesWritten;
|
||||||
|
@ -65,55 +68,65 @@ _lwrite(
|
||||||
return _hwrite(hFile,lpBuffer,uBytes);
|
return _hwrite(hFile,lpBuffer,uBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define OF_OPENMASK (OF_READ|OF_READWRITE|OF_WRITE|OF_CREATE)
|
|
||||||
#define OF_FILEMASK (OF_DELETE|OF_PARSE)
|
|
||||||
#define OF_MASK (OF_OPENMASK|OF_FILEMASK)
|
|
||||||
|
|
||||||
HFILE _open( LPCSTR lpPathName, int iReadWrite )
|
|
||||||
|
|
||||||
|
|
||||||
|
HFILE _lopen( LPCSTR lpPathName, int iReadWrite )
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
HFILE fd;
|
DWORD dwAccessMask = 0;
|
||||||
int nFunction;
|
DWORD dwShareMode = 0;
|
||||||
|
|
||||||
|
if ( (iReadWrite & OF_READWRITE ) == OF_READWRITE )
|
||||||
|
dwAccessMask = GENERIC_READ | GENERIC_WRITE;
|
||||||
|
else if ( (iReadWrite & OF_READ ) == OF_READ )
|
||||||
|
dwAccessMask = GENERIC_READ;
|
||||||
|
else if ( (iReadWrite & OF_WRITE ) == OF_WRITE )
|
||||||
|
dwAccessMask = GENERIC_WRITE;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Don't assume a 1:1 relationship between OF_* modes and O_* modes */
|
|
||||||
/* Here we translate the read/write permission bits (which had better */
|
|
||||||
/* be the low 2 bits. If not, we're in trouble. Other bits are */
|
|
||||||
/* passed through unchanged */
|
|
||||||
|
|
||||||
nFunction = wFunction & 3;
|
if ((iReadWrite & OF_SHARE_COMPAT) == OF_SHARE_COMPAT )
|
||||||
|
dwShareMode = FILE_SHARE_WRITE | FILE_SHARE_READ | FILE_SHARE_DELETE;
|
||||||
|
else if ((iReadWrite & OF_SHARE_DENY_NONE) == OF_SHARE_DENY_NONE)
|
||||||
|
dwShareMode = FILE_SHARE_WRITE | FILE_SHARE_READ | FILE_SHARE_DELETE;
|
||||||
|
else if ((iReadWrite & OF_SHARE_DENY_READ) == OF_SHARE_DENY_READ)
|
||||||
|
dwShareMode = FILE_SHARE_WRITE | FILE_SHARE_DELETE;
|
||||||
|
else if ((iReadWrite & OF_SHARE_DENY_WRITE) == OF_SHARE_DENY_WRITE )
|
||||||
|
dwShareMode = FILE_SHARE_READ | FILE_SHARE_DELETE;
|
||||||
|
else if ((iReadWrite & OF_SHARE_EXCLUSIVE) == OF_SHARE_EXCLUSIVE)
|
||||||
|
dwShareMode = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
switch (wFunction & 3) {
|
|
||||||
case OF_READ:
|
|
||||||
nFunction |= O_RDONLY;
|
|
||||||
break;
|
|
||||||
case OF_READWRITE:
|
|
||||||
nFunction |= O_RDWR;
|
|
||||||
break;
|
|
||||||
case OF_WRITE:
|
|
||||||
nFunction |= O_WRONLY;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
//ERRSTR((LF_ERROR, "_lopen: bad file open mode %x\n", wFunction));
|
|
||||||
return HFILE_ERROR;
|
|
||||||
}
|
|
||||||
SetLastError(0);
|
SetLastError(0);
|
||||||
fd = CreateFileA( filename,nFunction,OPEN_EXISTING,
|
return (HFILE) CreateFileA( lpPathName,dwAccessMask,dwShareMode,
|
||||||
NULL,OPEN_EXISTING,NULL,NULL);
|
NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
|
||||||
if (fd == INVALID_HANDLE_VALUE )
|
|
||||||
return HFILE_ERROR;
|
|
||||||
return fd;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int _creat(const char *filename, int pmode)
|
|
||||||
|
HFILE _lcreat( LPCSTR lpPathName, int iAttribute )
|
||||||
{
|
{
|
||||||
SetLastError(0);
|
|
||||||
return CreateFileA( filename,GENERIC_READ & GENERIC_WRITE,FILE_SHARE_WRITE,
|
DWORD FileAttributes = 0;
|
||||||
NULL,CREATE_ALWAYS,pmode & 0x00003FB7,NULL);
|
|
||||||
|
if ( iAttribute == 1 )
|
||||||
|
FileAttributes |= FILE_ATTRIBUTE_NORMAL;
|
||||||
|
else if ( iAttribute == 2 )
|
||||||
|
FileAttributes |= FILE_ATTRIBUTE_READONLY;
|
||||||
|
else if ( iAttribute == 3 )
|
||||||
|
FileAttributes |= FILE_ATTRIBUTE_HIDDEN;
|
||||||
|
else if ( iAttribute == 4 )
|
||||||
|
FileAttributes |= FILE_ATTRIBUTE_SYSTEM;
|
||||||
|
|
||||||
|
return(HFILE) CreateFileA( lpPathName,GENERIC_ALL,FILE_SHARE_READ|FILE_SHARE_WRITE,
|
||||||
|
NULL,CREATE_ALWAYS,iAttribute ,NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
273
reactos/lib/kernel32/file/volume.c
Normal file
273
reactos/lib/kernel32/file/volume.c
Normal file
|
@ -0,0 +1,273 @@
|
||||||
|
/*
|
||||||
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
|
* PROJECT: ReactOS system libraries
|
||||||
|
* FILE: lib/kernel32/file/volume.c
|
||||||
|
* PURPOSE: File volume functions
|
||||||
|
* PROGRAMMER: Ariadne ( ariadne@xs4all.nl)
|
||||||
|
* UPDATE HISTORY:
|
||||||
|
* Created 01/11/98
|
||||||
|
*/
|
||||||
|
#undef WIN32_LEAN_AND_MEAN
|
||||||
|
#include <windows.h>
|
||||||
|
#include <ddk/ntddk.h>
|
||||||
|
#include <wstring.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <ddk/li.h>
|
||||||
|
|
||||||
|
DWORD
|
||||||
|
STDCALL
|
||||||
|
GetLogicalDrives(VOID)
|
||||||
|
{
|
||||||
|
return (DWORD)-1;
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD
|
||||||
|
STDCALL
|
||||||
|
GetLogicalDriveStringsA(
|
||||||
|
DWORD nBufferLength,
|
||||||
|
LPSTR lpBuffer
|
||||||
|
)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD
|
||||||
|
STDCALL
|
||||||
|
GetLogicalDriveStringsW(
|
||||||
|
DWORD nBufferLength,
|
||||||
|
LPWSTR lpBuffer
|
||||||
|
)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
WINBOOL
|
||||||
|
STDCALL
|
||||||
|
GetDiskFreeSpaceA(
|
||||||
|
LPCSTR lpRootPathName,
|
||||||
|
LPDWORD lpSectorsPerCluster,
|
||||||
|
LPDWORD lpBytesPerSector,
|
||||||
|
LPDWORD lpNumberOfFreeClusters,
|
||||||
|
LPDWORD lpTotalNumberOfClusters
|
||||||
|
)
|
||||||
|
{
|
||||||
|
ULONG i;
|
||||||
|
WCHAR RootPathNameW[MAX_PATH];
|
||||||
|
i = 0;
|
||||||
|
while ((*lpRootPathName)!=0 && i < MAX_PATH)
|
||||||
|
{
|
||||||
|
RootPathNameW[i] = *lpRootPathName;
|
||||||
|
lpRootPathName++;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
RootPathNameW[i] = 0;
|
||||||
|
return GetDiskFreeSpaceW(RootPathNameW,lpSectorsPerCluster, lpBytesPerSector, lpNumberOfFreeClusters, lpTotalNumberOfClusters );
|
||||||
|
}
|
||||||
|
|
||||||
|
WINBOOL
|
||||||
|
STDCALL
|
||||||
|
GetDiskFreeSpaceW(
|
||||||
|
LPCWSTR lpRootPathName,
|
||||||
|
LPDWORD lpSectorsPerCluster,
|
||||||
|
LPDWORD lpBytesPerSector,
|
||||||
|
LPDWORD lpNumberOfFreeClusters,
|
||||||
|
LPDWORD lpTotalNumberOfClusters
|
||||||
|
)
|
||||||
|
{
|
||||||
|
FILE_FS_SIZE_INFORMATION FileFsSize;
|
||||||
|
IO_STATUS_BLOCK IoStatusBlock;
|
||||||
|
HANDLE hFile;
|
||||||
|
NTSTATUS errCode;
|
||||||
|
|
||||||
|
hFile = CreateFileW(
|
||||||
|
lpRootPathName,
|
||||||
|
GENERIC_READ,
|
||||||
|
FILE_SHARE_READ,
|
||||||
|
NULL,
|
||||||
|
OPEN_EXISTING,
|
||||||
|
FILE_ATTRIBUTE_NORMAL,
|
||||||
|
NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
errCode = NtQueryVolumeInformationFile(hFile,&IoStatusBlock,&FileFsSize, sizeof(FILE_FS_SIZE_INFORMATION),FileFsSizeInformation);
|
||||||
|
if ( !NT_SUCCESS(errCode) ) {
|
||||||
|
CloseHandle(hFile);
|
||||||
|
SetLastError(RtlNtStatusToDosError(errCode));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(lpBytesPerSector,&FileFsSize.BytesPerSector,sizeof(DWORD));;
|
||||||
|
memcpy(lpSectorsPerCluster,&FileFsSize.SectorsPerAllocationUnit,sizeof(DWORD));
|
||||||
|
memcpy(lpNumberOfFreeClusters,&GET_LARGE_INTEGER_LOW_PART(FileFsSize.AvailableAllocationUnits),sizeof(DWORD));
|
||||||
|
memcpy(lpTotalNumberOfClusters,&GET_LARGE_INTEGER_LOW_PART(FileFsSize.TotalAllocationUnits),sizeof(DWORD));
|
||||||
|
CloseHandle(hFile);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
UINT
|
||||||
|
STDCALL
|
||||||
|
GetDriveTypeA(
|
||||||
|
LPCSTR lpRootPathName
|
||||||
|
)
|
||||||
|
{
|
||||||
|
ULONG i;
|
||||||
|
WCHAR RootPathNameW[MAX_PATH];
|
||||||
|
i = 0;
|
||||||
|
while ((*lpRootPathName)!=0 && i < MAX_PATH)
|
||||||
|
{
|
||||||
|
RootPathNameW[i] = *lpRootPathName;
|
||||||
|
lpRootPathName++;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
RootPathNameW[i] = 0;
|
||||||
|
return GetDriveTypeW(RootPathNameW);
|
||||||
|
}
|
||||||
|
|
||||||
|
UINT
|
||||||
|
STDCALL
|
||||||
|
GetDriveTypeW(
|
||||||
|
LPCWSTR lpRootPathName
|
||||||
|
)
|
||||||
|
{
|
||||||
|
FILE_FS_DEVICE_INFORMATION FileFsDevice;
|
||||||
|
IO_STATUS_BLOCK IoStatusBlock;
|
||||||
|
|
||||||
|
HANDLE hFile;
|
||||||
|
NTSTATUS errCode;
|
||||||
|
|
||||||
|
hFile = CreateFileW(
|
||||||
|
lpRootPathName,
|
||||||
|
GENERIC_ALL,
|
||||||
|
FILE_SHARE_READ|FILE_SHARE_WRITE,
|
||||||
|
NULL,
|
||||||
|
OPEN_EXISTING,
|
||||||
|
FILE_ATTRIBUTE_NORMAL,
|
||||||
|
NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
errCode = NtQueryVolumeInformationFile(hFile,&IoStatusBlock,&FileFsDevice, sizeof(FILE_FS_DEVICE_INFORMATION),FileFsDeviceInformation);
|
||||||
|
if ( !NT_SUCCESS(errCode) ) {
|
||||||
|
CloseHandle(hFile);
|
||||||
|
SetLastError(RtlNtStatusToDosError(errCode));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
CloseHandle(hFile);
|
||||||
|
return (UINT)FileFsDevice.DeviceType;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
WINBOOL
|
||||||
|
STDCALL
|
||||||
|
GetVolumeInformationA(
|
||||||
|
LPCSTR lpRootPathName,
|
||||||
|
LPSTR lpVolumeNameBuffer,
|
||||||
|
DWORD nVolumeNameSize,
|
||||||
|
LPDWORD lpVolumeSerialNumber,
|
||||||
|
LPDWORD lpMaximumComponentLength,
|
||||||
|
LPDWORD lpFileSystemFlags,
|
||||||
|
LPSTR lpFileSystemNameBuffer,
|
||||||
|
DWORD nFileSystemNameSize
|
||||||
|
)
|
||||||
|
{
|
||||||
|
ULONG i;
|
||||||
|
WCHAR RootPathNameW[MAX_PATH];
|
||||||
|
WCHAR VolumeNameBufferW[MAX_PATH];
|
||||||
|
WCHAR FileSystemNameBufferW[MAX_PATH];
|
||||||
|
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
while ((*lpRootPathName)!=0 && i < MAX_PATH)
|
||||||
|
{
|
||||||
|
RootPathNameW[i] = *lpRootPathName;
|
||||||
|
lpRootPathName++;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
RootPathNameW[i] = 0;
|
||||||
|
|
||||||
|
if ( GetVolumeInformationW(RootPathNameW,
|
||||||
|
VolumeNameBufferW,
|
||||||
|
nVolumeNameSize,
|
||||||
|
lpVolumeSerialNumber,
|
||||||
|
lpMaximumComponentLength,
|
||||||
|
lpFileSystemFlags,
|
||||||
|
FileSystemNameBufferW,
|
||||||
|
nFileSystemNameSize ) ) {
|
||||||
|
for(i=0;i<nVolumeNameSize;i++)
|
||||||
|
lpVolumeNameBuffer[i] = (CHAR)VolumeNameBufferW[i];
|
||||||
|
|
||||||
|
for(i=0;i<nFileSystemNameSize;i++)
|
||||||
|
lpFileSystemNameBuffer[i] = (CHAR)FileSystemNameBufferW[i];
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#define FS_VOLUME_BUFFER_SIZE (MAX_PATH + sizeof(FILE_FS_VOLUME_INFORMATION))
|
||||||
|
|
||||||
|
#define FS_ATTRIBUTE_BUFFER_SIZE (MAX_PATH + sizeof(FILE_FS_ATTRIBUTE_INFORMATION))
|
||||||
|
|
||||||
|
|
||||||
|
WINBOOL
|
||||||
|
STDCALL
|
||||||
|
GetVolumeInformationW(
|
||||||
|
LPCWSTR lpRootPathName,
|
||||||
|
LPWSTR lpVolumeNameBuffer,
|
||||||
|
DWORD nVolumeNameSize,
|
||||||
|
LPDWORD lpVolumeSerialNumber,
|
||||||
|
LPDWORD lpMaximumComponentLength,
|
||||||
|
LPDWORD lpFileSystemFlags,
|
||||||
|
LPWSTR lpFileSystemNameBuffer,
|
||||||
|
DWORD nFileSystemNameSize
|
||||||
|
)
|
||||||
|
{
|
||||||
|
FILE_FS_VOLUME_INFORMATION *FileFsVolume;
|
||||||
|
FILE_FS_ATTRIBUTE_INFORMATION *FileFsAttribute;
|
||||||
|
IO_STATUS_BLOCK IoStatusBlock;
|
||||||
|
USHORT Buffer[FS_VOLUME_BUFFER_SIZE];
|
||||||
|
USHORT Buffer2[FS_ATTRIBUTE_BUFFER_SIZE];
|
||||||
|
|
||||||
|
HANDLE hFile;
|
||||||
|
NTSTATUS errCode;
|
||||||
|
|
||||||
|
FileFsVolume = (FILE_FS_VOLUME_INFORMATION *)Buffer;
|
||||||
|
FileFsAttribute = (FILE_FS_VOLUME_INFORMATION *)Buffer2;
|
||||||
|
|
||||||
|
hFile = CreateFileW(
|
||||||
|
lpRootPathName,
|
||||||
|
GENERIC_ALL,
|
||||||
|
FILE_SHARE_READ|FILE_SHARE_WRITE,
|
||||||
|
NULL,
|
||||||
|
OPEN_EXISTING,
|
||||||
|
FILE_ATTRIBUTE_NORMAL,
|
||||||
|
NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
errCode = NtQueryVolumeInformationFile(hFile,&IoStatusBlock,FileFsVolume, FS_VOLUME_BUFFER_SIZE,FileFsVolumeInformation);
|
||||||
|
if ( !NT_SUCCESS(errCode) ) {
|
||||||
|
CloseHandle(hFile);
|
||||||
|
SetLastError(RtlNtStatusToDosError(errCode));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(lpVolumeSerialNumber, &FileFsVolume->VolumeSerialNumber, sizeof(DWORD));
|
||||||
|
memcpy(lpVolumeNameBuffer, FileFsVolume->VolumeLabel,min(nVolumeNameSize,MAX_PATH));
|
||||||
|
|
||||||
|
errCode = NtQueryVolumeInformationFile(hFile,&IoStatusBlock,FileFsAttribute, FS_ATTRIBUTE_BUFFER_SIZE,FileFsAttributeInformation);
|
||||||
|
if ( !NT_SUCCESS(errCode) ) {
|
||||||
|
CloseHandle(hFile);
|
||||||
|
SetLastError(RtlNtStatusToDosError(errCode));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
memcpy(lpFileSystemFlags,&FileFsAttribute->FileSystemAttributes,sizeof(DWORD));
|
||||||
|
memcpy(lpMaximumComponentLength, &FileFsAttribute->MaximumComponentNameLength, sizeof(DWORD));
|
||||||
|
memcpy(lpFileSystemNameBuffer, FileFsAttribute->FileSystemName,min(nFileSystemNameSize,MAX_PATH));
|
||||||
|
CloseHandle(hFile);
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -1,9 +1,42 @@
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#include <ddk/ntddk.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
VOID STDCALL OutputDebugStringA(LPCSTR lpOutputString)
|
VOID STDCALL OutputDebugStringA(LPCSTR lpOutputString)
|
||||||
{
|
{
|
||||||
NtDisplayString(lpOutputString);
|
WCHAR DebugStringW[161];
|
||||||
|
int i,j;
|
||||||
|
i = 0;
|
||||||
|
j = 0;
|
||||||
|
while ( lpOutputString[i] != 0 )
|
||||||
|
{
|
||||||
|
while ( j < 160 && lpOutputString[i] != 0 )
|
||||||
|
{
|
||||||
|
DebugStringW[j] = (WCHAR)lpOutputString[i];
|
||||||
|
i++;
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
DebugStringW[j] = 0;
|
||||||
|
OutputDebugStringW(DebugStringW);
|
||||||
|
j = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID
|
||||||
|
STDCALL
|
||||||
|
OutputDebugStringW(
|
||||||
|
LPCWSTR lpOutputString
|
||||||
|
)
|
||||||
|
{
|
||||||
|
UNICODE_STRING UnicodeOutput;
|
||||||
|
|
||||||
|
UnicodeOutput.Buffer = (WCHAR *)lpOutputString;
|
||||||
|
UnicodeOutput.Length = lstrlenW(lpOutputString)*sizeof(WCHAR);
|
||||||
|
UnicodeOutput.MaximumLength = UnicodeOutput.Length;
|
||||||
|
|
||||||
|
NtDisplayString(&UnicodeOutput);
|
||||||
}
|
}
|
||||||
|
|
||||||
void dprintf(char* fmt, ...)
|
void dprintf(char* fmt, ...)
|
||||||
|
|
|
@ -338,3 +338,42 @@ int sprintf(char * buf, const char *fmt, ...)
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int wsprintfA(char * buf, const char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
va_start(args, fmt);
|
||||||
|
i=vsprintf(buf,fmt,args);
|
||||||
|
va_end(args);
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
int wsprintfW(unsigned short * buf, const unsigned short *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
va_start(args, fmt);
|
||||||
|
//i=vsprintf(buf,fmt,args);
|
||||||
|
va_end(args);
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
unsigned short towupper(unsigned short w)
|
||||||
|
{
|
||||||
|
if ( w < L'A' )
|
||||||
|
return w + 'A';
|
||||||
|
else
|
||||||
|
return w;
|
||||||
|
}
|
||||||
|
|
||||||
|
char iswlower(unsigned short w)
|
||||||
|
{
|
||||||
|
if ( w < L'A' )
|
||||||
|
return 1;
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -330,7 +330,6 @@ GetTempFileNameW@16
|
||||||
GetTempPathA@8
|
GetTempPathA@8
|
||||||
GetTempPathW@8
|
GetTempPathW@8
|
||||||
GetThreadContext@8
|
GetThreadContext@8
|
||||||
_imp__GetThreadContext@8
|
|
||||||
GetThreadLocale@0
|
GetThreadLocale@0
|
||||||
GetThreadPriority@4
|
GetThreadPriority@4
|
||||||
GetThreadSelectorEntry@12
|
GetThreadSelectorEntry@12
|
||||||
|
|
|
@ -1,16 +1,14 @@
|
||||||
all: kernel32.a
|
all: kernel32.a
|
||||||
|
|
||||||
SYNCH_OBJECTS = synch/critical.o
|
SYNCH_OBJECTS = synch/critical.o synch/event.o synch/wait.o
|
||||||
|
|
||||||
#MISC_OBJECTS = misc/atom.o
|
MISC_OBJECTS = misc/error.o misc/atom.o misc/handle.o misc/env.o misc/dllmain.o
|
||||||
MISC_OBJECTS = misc/error.o
|
|
||||||
|
|
||||||
#FILE_OBJECTS = file/file.o file/lfile.o
|
FILE_OBJECTS = file/file.o file/curdir.o file/lfile.o file/dir.o file/iocompl.o file/volume.o file/deviceio.o file/dosdev.o
|
||||||
FILE_OBJECTS = file/file.o file/curdir.o
|
|
||||||
|
|
||||||
MEM_OBJECTS = mem/virtual.o mem/heap.o mem/utils.o
|
MEM_OBJECTS = mem/virtual.o mem/heap.o mem/utils.o
|
||||||
|
|
||||||
#THREAD_OBJECTS = thread/thread.o
|
THREAD_OBJECTS = thread/thread.o
|
||||||
|
|
||||||
PROCESS_OBJECTS = process/proc.o
|
PROCESS_OBJECTS = process/proc.o
|
||||||
|
|
||||||
|
@ -18,9 +16,14 @@ STRING_OBJECTS = string/lstring.o
|
||||||
|
|
||||||
INTERNAL_OBJECTS = internal/dprintf.o internal/vsprintf.o
|
INTERNAL_OBJECTS = internal/dprintf.o internal/vsprintf.o
|
||||||
|
|
||||||
|
EXCEPT_OBJECTS = except/except.o
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
OBJECTS = $(MISC_OBJECTS) $(FILE_OBJECTS) $(THREAD_OBJECTS) \
|
OBJECTS = $(MISC_OBJECTS) $(FILE_OBJECTS) $(THREAD_OBJECTS) \
|
||||||
$(PROCESS_OBJECTS) $(STRING_OBJECTS) $(MEM_OBJECTS) \
|
$(PROCESS_OBJECTS) $(STRING_OBJECTS) $(MEM_OBJECTS) \
|
||||||
$(INTERNAL_OBJECTS) $(SYNCH_OBJECTS)
|
$(INTERNAL_OBJECTS) $(SYNCH_OBJECTS) $(EXCEPT_OBJECTS)
|
||||||
|
|
||||||
|
|
||||||
kernel32.a: $(OBJECTS)
|
kernel32.a: $(OBJECTS)
|
||||||
|
|
|
@ -156,7 +156,7 @@ HGLOBAL WINAPI GlobalReAlloc(HGLOBAL hmem, DWORD size, UINT flags)
|
||||||
palloc=GlobalLock(hnew);
|
palloc=GlobalLock(hnew);
|
||||||
memcpy(palloc, (LPVOID) hmem, size);
|
memcpy(palloc, (LPVOID) hmem, size);
|
||||||
GlobalUnlock(hnew);
|
GlobalUnlock(hnew);
|
||||||
GlobalFree(hmem);
|
GlobalHeapFree(GetProcessHeap(),0,hmem);
|
||||||
}
|
}
|
||||||
else if((((ULONG)hmem%8) != 0)&&(flags & GMEM_DISCARDABLE))
|
else if((((ULONG)hmem%8) != 0)&&(flags & GMEM_DISCARDABLE))
|
||||||
{
|
{
|
||||||
|
@ -205,7 +205,7 @@ HGLOBAL WINAPI GlobalReAlloc(HGLOBAL hmem, DWORD size, UINT flags)
|
||||||
{
|
{
|
||||||
if(phandle->Pointer)
|
if(phandle->Pointer)
|
||||||
{
|
{
|
||||||
HeapFree(__ProcessHeap, 0, phandle->Pointer-sizeof(HANDLE));
|
HeapHeapFree(GetProcessHeap(),0,__ProcessHeap, 0, phandle->Pointer-sizeof(HANDLE));
|
||||||
phandle->Pointer=NULL;
|
phandle->Pointer=NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -218,15 +218,15 @@ HGLOBAL WINAPI GlobalReAlloc(HGLOBAL hmem, DWORD size, UINT flags)
|
||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
* GlobalFree -- KERNEL32 *
|
* GlobalFree -- KERNEL32 *
|
||||||
*********************************************************************/
|
*********************************************************************/
|
||||||
HGLOBAL WINAPI GlobalFree(HGLOBAL hmem)
|
HGLOBAL WINAPI GlobalHeapFree(GetProcessHeap(),0,HGLOBAL hmem)
|
||||||
{
|
{
|
||||||
PGLOBAL_HANDLE phandle;
|
PGLOBAL_HANDLE phandle;
|
||||||
|
|
||||||
aprintf("GlobalFree( 0x%lX )\n", (ULONG) hmem );
|
aprintf("GlobalHeapFree(GetProcessHeap(),0, 0x%lX )\n", (ULONG) hmem );
|
||||||
|
|
||||||
if(((ULONG)hmem%4)==0) /* POINTER */
|
if(((ULONG)hmem%4)==0) /* POINTER */
|
||||||
{
|
{
|
||||||
HeapFree(__ProcessHeap, 0, (LPVOID) hmem);
|
HeapHeapFree(GetProcessHeap(),0,__ProcessHeap, 0, (LPVOID) hmem);
|
||||||
}
|
}
|
||||||
else /* HANDLE */
|
else /* HANDLE */
|
||||||
{
|
{
|
||||||
|
@ -238,7 +238,7 @@ HGLOBAL WINAPI GlobalFree(HGLOBAL hmem)
|
||||||
if(phandle->LockCount!=0)
|
if(phandle->LockCount!=0)
|
||||||
SetLastError(ERROR_INVALID_HANDLE);
|
SetLastError(ERROR_INVALID_HANDLE);
|
||||||
if(phandle->Pointer)
|
if(phandle->Pointer)
|
||||||
HeapFree(__ProcessHeap, 0, phandle->Pointer-sizeof(HANDLE));
|
HeapHeapFree(GetProcessHeap(),0,__ProcessHeap, 0, phandle->Pointer-sizeof(HANDLE));
|
||||||
__HeapFreeFragment(__ProcessHeap, 0, phandle);
|
__HeapFreeFragment(__ProcessHeap, 0, phandle);
|
||||||
}
|
}
|
||||||
HeapUnlock(__ProcessHeap);
|
HeapUnlock(__ProcessHeap);
|
||||||
|
|
|
@ -26,10 +26,12 @@
|
||||||
* Put the type definitions of the heap in a seperate header. Boudewijn Dekker
|
* Put the type definitions of the heap in a seperate header. Boudewijn Dekker
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <kernel32/proc.h>
|
||||||
#include <kernel32/kernel32.h>
|
#include <kernel32/kernel32.h>
|
||||||
#include <kernel32/heap.h>
|
#include <kernel32/heap.h>
|
||||||
#include <internal/string.h>
|
#include <internal/string.h>
|
||||||
|
|
||||||
|
|
||||||
static HEAP_BUCKET __HeapDefaultBuckets[]=
|
static HEAP_BUCKET __HeapDefaultBuckets[]=
|
||||||
{
|
{
|
||||||
{ NULL, 16, 18, 504 },
|
{ NULL, 16, 18, 504 },
|
||||||
|
|
|
@ -101,9 +101,9 @@ HLOCAL WINAPI LocalReAlloc(HLOCAL hmem, UINT size, UINT flags)
|
||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
* LocalFree -- KERNEL32 *
|
* LocalFree -- KERNEL32 *
|
||||||
*********************************************************************/
|
*********************************************************************/
|
||||||
HLOCAL WINAPI LocalFree(HLOCAL hmem)
|
HLOCAL WINAPI LocalHeapFree(GetProcessHeap(),0,HLOCAL hmem)
|
||||||
{
|
{
|
||||||
return (HLOCAL) GlobalFree( (HGLOBAL) hmem );
|
return (HLOCAL) GlobalHeapFree(GetProcessHeap(),0, (HGLOBAL) hmem );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
|
|
|
@ -22,13 +22,14 @@ LPVOID STDCALL VirtualAllocEx(HANDLE hProcess,
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
Status = ZwAllocateVirtualMemory(hProcess,
|
Status = ZwAllocateVirtualMemory(hProcess,
|
||||||
&lpAddress,
|
(PVOID *)&lpAddress,
|
||||||
0,
|
0,
|
||||||
dwSize,
|
(PULONG)&dwSize,
|
||||||
flAllocationType,
|
flAllocationType,
|
||||||
flProtect);
|
flProtect);
|
||||||
if (Status != STATUS_SUCCESS)
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
|
SetLastError(RtlNtStatusToDosError(Status));
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
return(lpAddress);
|
return(lpAddress);
|
||||||
|
@ -51,11 +52,12 @@ WINBOOL STDCALL VirtualFreeEx(HANDLE hProcess,
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
Status = ZwFreeVirtualMemory(hProcess,
|
Status = ZwFreeVirtualMemory(hProcess,
|
||||||
&lpAddress,
|
(PVOID *)&lpAddress,
|
||||||
dwSize,
|
(PULONG)&dwSize,
|
||||||
dwFreeType);
|
dwFreeType);
|
||||||
if (Status != STATUS_SUCCESS)
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
|
SetLastError(RtlNtStatusToDosError(Status));
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
return(TRUE);
|
return(TRUE);
|
||||||
|
@ -88,12 +90,13 @@ WINBOOL STDCALL VirtualProtectEx(HANDLE hProcess,
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
Status = ZwProtectVirtualMemory(hProcess,
|
Status = ZwProtectVirtualMemory(hProcess,
|
||||||
lpAddress,
|
(PVOID)lpAddress,
|
||||||
dwSize,
|
(PULONG)dwSize,
|
||||||
flNewProtect,
|
flNewProtect,
|
||||||
lpflOldProtect);
|
lpflOldProtect);
|
||||||
if (Status != STATUS_SUCCESS)
|
if (Status != STATUS_SUCCESS)
|
||||||
{
|
{
|
||||||
|
SetLastError(RtlNtStatusToDosError(Status));
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
return(TRUE);
|
return(TRUE);
|
||||||
|
|
|
@ -1,24 +1,25 @@
|
||||||
|
|
||||||
|
|
||||||
#include <Atom.h>
|
|
||||||
#include <process.h>
|
|
||||||
#include <thread.h>
|
|
||||||
#include <wstring.h>
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
title: atom.c
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
author: Boudewijn Dekker
|
* PROJECT: ReactOS system libraries
|
||||||
hsitory:copied from twin wine source
|
* FILE: lib/kernel32/misc/atom.c
|
||||||
modified: -- add wide char support
|
* PURPOSE: Atom functions
|
||||||
-- removed ex functions
|
* PROGRAMMER: Ariadne ( ariadne@xs4all.nl)
|
||||||
-- use a per process local atom table
|
modified from WINE [ Onno Hovers, (onno@stack.urc.tue.nl) ]
|
||||||
todo :
|
* UPDATE HISTORY:
|
||||||
check initatomtable
|
* Created 01/11/98
|
||||||
check if not calling down to ntdll conflicts with anything
|
|
||||||
check anis2unicode procedure
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <kernel32\atom.h>
|
||||||
|
#include <kernel32\proc.h>
|
||||||
|
#include <kernel32\thread.h>
|
||||||
|
#include <wstring.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* system global and local atom tables */
|
/* system global and local atom tables */
|
||||||
|
|
||||||
|
@ -26,15 +27,17 @@ static ATOMTABLE GlobalAtomTable;
|
||||||
|
|
||||||
/* internal functions */
|
/* internal functions */
|
||||||
ATOM GLDeleteAtom(ATOMTABLE *at, ATOM nAtom);
|
ATOM GLDeleteAtom(ATOMTABLE *at, ATOM nAtom);
|
||||||
ATOM AWGLAddAtom( ATOMTABLE *at, const wchar_t *lpString);
|
ATOM AWGLAddAtom( ATOMTABLE *at, const WCHAR *lpString);
|
||||||
ATOM AWGLFindAtom(ATOMTABLE *at, const wchar_t *lpString);
|
ATOM AWGLFindAtom(ATOMTABLE *at, const WCHAR *lpString);
|
||||||
UINT AWGLGetAtomName(ATOMTABLE *at,ATOM atom, wchar_t *lpString, int nSize);
|
UINT AWGLGetAtomName(ATOMTABLE *at,ATOM atom, WCHAR *lpString, int nSize);
|
||||||
|
|
||||||
static ATOMENTRY *GetAtomPointer(ATOMTABLE *,int);
|
static ATOMENTRY *GetAtomPointer(ATOMTABLE *,int);
|
||||||
static ATOMID AtomHashString(const wchar_t *,int *);
|
static ATOMID AtomHashString(const WCHAR *,int *);
|
||||||
|
|
||||||
#define ATOMBASE 0xcc00
|
#define ATOMBASE 0xcc00
|
||||||
|
|
||||||
|
int unicode2ansi( char *ansi,const WCHAR *uni, int s);
|
||||||
|
int ansi2unicode( WCHAR *uni,const char *ansi, int s);
|
||||||
|
|
||||||
|
|
||||||
ATOM
|
ATOM
|
||||||
|
@ -58,13 +61,12 @@ InitAtomTable(
|
||||||
if ( nSize < 4 || nSize >= 512 ) {
|
if ( nSize < 4 || nSize >= 512 ) {
|
||||||
nSize = 37;
|
nSize = 37;
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
if ( GetTeb()->pPeb->LocalAtomTable == NULL ) {
|
if ( (GetCurrentPeb()->LocalAtomTable).lpDrvData == NULL ) {
|
||||||
GetTeb()->pPeb->LocalAtomTable = (ATOMTABLE *)malloc(nSize*sizeof(ATOMTABLE));
|
(GetCurrentPeb()->LocalAtomTable).lpDrvData = HeapAlloc(GetProcessHeap(),HEAP_GENERATE_EXCEPTIONS|HEAP_ZERO_MEMORY,nSize*sizeof(ATOMENTRY));
|
||||||
}
|
}
|
||||||
|
|
||||||
GetTeb()->pPeb->LocalAtomTable->TableSize = nSize;
|
|
||||||
*/
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,7 +77,7 @@ DeleteAtom(
|
||||||
ATOM nAtom
|
ATOM nAtom
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return GLDeleteAtom(&GetTeb()->pPeb->LocalAtomTable, nAtom);
|
return GLDeleteAtom(&GetCurrentPeb()->LocalAtomTable, nAtom);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,16 +87,16 @@ DeleteAtom(
|
||||||
ATOM
|
ATOM
|
||||||
STDCALL
|
STDCALL
|
||||||
GlobalAddAtomA(
|
GlobalAddAtomA(
|
||||||
const char *lpString
|
LPCSTR lpString
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
|
||||||
UINT BufLen = strlen(lpString);
|
UINT BufLen = strlen(lpString);
|
||||||
wchar_t *lpBuffer = (wchar_t *)malloc(BufLen*sizeof(wchar_t));
|
WCHAR *lpBuffer = (WCHAR *)HeapAlloc(GetProcessHeap(),HEAP_GENERATE_EXCEPTIONS|HEAP_ZERO_MEMORY,BufLen*sizeof(WCHAR));
|
||||||
ATOM atom;
|
ATOM atom;
|
||||||
ansi2unicode(lpBuffer, lpString,BufLen);
|
ansi2unicode(lpBuffer, lpString,BufLen);
|
||||||
atom = AWGLAddAtom(&GlobalAtomTable,lpBuffer );
|
atom = AWGLAddAtom(&GlobalAtomTable,lpBuffer );
|
||||||
free(lpBuffer);
|
HeapFree(GetProcessHeap(),0,lpBuffer);
|
||||||
return atom;
|
return atom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,7 +107,7 @@ GlobalAddAtomA(
|
||||||
ATOM
|
ATOM
|
||||||
STDCALL
|
STDCALL
|
||||||
GlobalAddAtomW(
|
GlobalAddAtomW(
|
||||||
const wchar_t *lpString
|
LPCWSTR lpString
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return AWGLAddAtom(&GlobalAtomTable, lpString);
|
return AWGLAddAtom(&GlobalAtomTable, lpString);
|
||||||
|
@ -115,15 +117,15 @@ GlobalAddAtomW(
|
||||||
ATOM
|
ATOM
|
||||||
STDCALL
|
STDCALL
|
||||||
GlobalFindAtomA(
|
GlobalFindAtomA(
|
||||||
const char *lpString
|
LPCSTR lpString
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ATOM a;
|
ATOM a;
|
||||||
UINT BufLen = strlen(lpString);
|
UINT BufLen = strlen(lpString);
|
||||||
wchar_t *lpBuffer = (wchar_t *)malloc(BufLen*sizeof(wchar_t));
|
WCHAR *lpBuffer = (WCHAR *)HeapAlloc(GetProcessHeap(),HEAP_GENERATE_EXCEPTIONS|HEAP_ZERO_MEMORY,BufLen*sizeof(WCHAR));
|
||||||
ansi2unicode(lpBuffer, lpString,BufLen);
|
ansi2unicode(lpBuffer, lpString,BufLen);
|
||||||
a = AWGLFindAtom(&GlobalAtomTable, lpBuffer);
|
a = AWGLFindAtom(&GlobalAtomTable, lpBuffer);
|
||||||
free(lpBuffer);
|
HeapFree(GetProcessHeap(),0,lpBuffer);
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,7 +133,7 @@ GlobalFindAtomA(
|
||||||
ATOM
|
ATOM
|
||||||
STDCALL
|
STDCALL
|
||||||
GlobalFindAtomW(
|
GlobalFindAtomW(
|
||||||
const wchar_t *lpString
|
const WCHAR *lpString
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return AWGLFindAtom(&GlobalAtomTable, lpString);
|
return AWGLFindAtom(&GlobalAtomTable, lpString);
|
||||||
|
@ -148,10 +150,10 @@ GlobalGetAtomNameA(
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
|
||||||
wchar_t *lpUnicode = (wchar_t *)malloc(nSize *sizeof(wchar_t));
|
WCHAR *lpUnicode = (WCHAR *)HeapAlloc(GetProcessHeap(),HEAP_GENERATE_EXCEPTIONS|HEAP_ZERO_MEMORY,nSize *sizeof(WCHAR));
|
||||||
UINT x = AWGLGetAtomName(&GlobalAtomTable,nAtom, lpUnicode,nSize);
|
UINT x = AWGLGetAtomName(&GlobalAtomTable,nAtom, lpUnicode,nSize);
|
||||||
unicode2ansi(lpBuffer,lpUnicode,nSize);
|
unicode2ansi(lpBuffer,lpUnicode,nSize);
|
||||||
free(lpUnicode);
|
HeapFree(GetProcessHeap(),0,lpUnicode);
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,7 +162,7 @@ UINT
|
||||||
STDCALL
|
STDCALL
|
||||||
GlobalGetAtomNameW(
|
GlobalGetAtomNameW(
|
||||||
ATOM nAtom,
|
ATOM nAtom,
|
||||||
wchar_t * lpBuffer,
|
WCHAR * lpBuffer,
|
||||||
int nSize
|
int nSize
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
@ -175,11 +177,11 @@ AddAtomA(
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
UINT BufLen = strlen(lpString);
|
UINT BufLen = strlen(lpString);
|
||||||
wchar_t *lpBuffer = (wchar_t*)malloc(BufLen*2);
|
WCHAR *lpBuffer = (WCHAR*)HeapAlloc(GetProcessHeap(),HEAP_GENERATE_EXCEPTIONS|HEAP_ZERO_MEMORY,BufLen*2);
|
||||||
ATOM a;
|
ATOM a;
|
||||||
ansi2unicode(lpBuffer, lpString,BufLen);
|
ansi2unicode(lpBuffer, lpString,BufLen);
|
||||||
a = AWGLAddAtom(&GetTeb()->pPeb->LocalAtomTable, lpBuffer);
|
a = AWGLAddAtom(&GetCurrentPeb()->LocalAtomTable, lpBuffer);
|
||||||
free(lpBuffer);
|
HeapFree(GetProcessHeap(),0,lpBuffer);
|
||||||
return a;
|
return a;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -188,10 +190,10 @@ AddAtomA(
|
||||||
ATOM
|
ATOM
|
||||||
STDCALL
|
STDCALL
|
||||||
AddAtomW(
|
AddAtomW(
|
||||||
const wchar_t * lpString
|
const WCHAR * lpString
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return AWGLAddAtom(&GetTeb()->pPeb->LocalAtomTable, lpString);
|
return AWGLAddAtom(&GetCurrentPeb()->LocalAtomTable, lpString);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -204,11 +206,11 @@ FindAtomA(
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
UINT BufLen = strlen(lpString);
|
UINT BufLen = strlen(lpString);
|
||||||
wchar_t *lpBuffer = (wchar_t *)malloc(BufLen*2);
|
WCHAR *lpBuffer = (WCHAR *)HeapAlloc(GetProcessHeap(),HEAP_GENERATE_EXCEPTIONS|HEAP_ZERO_MEMORY,BufLen*2);
|
||||||
ATOM a;
|
ATOM a;
|
||||||
ansi2unicode(lpBuffer, lpString,BufLen);
|
ansi2unicode(lpBuffer, lpString,BufLen);
|
||||||
a = AWGLFindAtom(&GetTeb()->pPeb->LocalAtomTable, lpBuffer);
|
a = AWGLFindAtom(&GetCurrentPeb()->LocalAtomTable, lpBuffer);
|
||||||
free(lpBuffer);
|
HeapFree(GetProcessHeap(),0,lpBuffer);
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -216,10 +218,10 @@ FindAtomA(
|
||||||
ATOM
|
ATOM
|
||||||
STDCALL
|
STDCALL
|
||||||
FindAtomW(
|
FindAtomW(
|
||||||
const wchar_t * lpString
|
const WCHAR * lpString
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return AWGLFindAtom(&GetTeb()->pPeb->LocalAtomTable, lpString);
|
return AWGLFindAtom(&GetCurrentPeb()->LocalAtomTable, lpString);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -232,10 +234,10 @@ GetAtomNameA(
|
||||||
int nSize
|
int nSize
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
LPWSTR lpUnicode = (wchar_t *)malloc(nSize *2);
|
LPWSTR lpUnicode = (WCHAR *)HeapAlloc(GetProcessHeap(),HEAP_GENERATE_EXCEPTIONS|HEAP_ZERO_MEMORY,nSize *2);
|
||||||
UINT x = AWGLGetAtomName(&GlobalAtomTable, nAtom,lpUnicode,nSize);
|
UINT x = AWGLGetAtomName(&GlobalAtomTable, nAtom,lpUnicode,nSize);
|
||||||
unicode2ansi(lpBuffer,lpUnicode,nSize);
|
unicode2ansi(lpBuffer,lpUnicode,nSize);
|
||||||
free(lpUnicode);
|
HeapFree(GetProcessHeap(),0,lpUnicode);
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -244,11 +246,11 @@ UINT
|
||||||
STDCALL
|
STDCALL
|
||||||
GetAtomNameW(
|
GetAtomNameW(
|
||||||
ATOM nAtom,
|
ATOM nAtom,
|
||||||
wchar_t * lpBuffer,
|
WCHAR * lpBuffer,
|
||||||
int nSize
|
int nSize
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return AWGLGetAtomName(&GetTeb()->pPeb->LocalAtomTable,nAtom,lpBuffer, nSize);
|
return AWGLGetAtomName(&GetCurrentPeb()->LocalAtomTable,nAtom,lpBuffer, nSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
ATOM
|
ATOM
|
||||||
|
@ -265,9 +267,9 @@ GLDeleteAtom(
|
||||||
lp->refcnt--;
|
lp->refcnt--;
|
||||||
|
|
||||||
if(lp->refcnt == 0) {
|
if(lp->refcnt == 0) {
|
||||||
free(at->AtomTable);
|
HeapFree(GetProcessHeap(),0,at->AtomTable);
|
||||||
at->AtomTable = NULL;
|
at->AtomTable = NULL;
|
||||||
free(at->AtomData);
|
HeapFree(GetProcessHeap(),0,at->AtomData);
|
||||||
at->AtomData = NULL;
|
at->AtomData = NULL;
|
||||||
return lp->q = 0;
|
return lp->q = 0;
|
||||||
}
|
}
|
||||||
|
@ -281,7 +283,7 @@ GLDeleteAtom(
|
||||||
|
|
||||||
ATOM
|
ATOM
|
||||||
AWGLAddAtom(
|
AWGLAddAtom(
|
||||||
ATOMTABLE *at, const wchar_t *lpString
|
ATOMTABLE *at, const WCHAR *lpString
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ATOM atom;
|
ATOM atom;
|
||||||
|
@ -329,13 +331,13 @@ AWGLAddAtom(
|
||||||
/* no space was available, or we have an INTATOM */
|
/* no space was available, or we have an INTATOM */
|
||||||
/* so expand or create the table */
|
/* so expand or create the table */
|
||||||
if(at->AtomTable == 0) {
|
if(at->AtomTable == 0) {
|
||||||
at->AtomTable = (ATOMENTRY *) malloc(sizeof(ATOMENTRY));
|
at->AtomTable = (ATOMENTRY *) HeapAlloc(GetProcessHeap(),HEAP_GENERATE_EXCEPTIONS|HEAP_ZERO_MEMORY,sizeof(ATOMENTRY));
|
||||||
at->TableSize = 1;
|
at->TableSize = 1;
|
||||||
lp = at->AtomTable;
|
lp = at->AtomTable;
|
||||||
index = 0;
|
index = 0;
|
||||||
} else {
|
} else {
|
||||||
at->TableSize++;
|
at->TableSize++;
|
||||||
at->AtomTable = (ATOMENTRY *) realloc(
|
at->AtomTable = (ATOMENTRY *) HeapReAlloc(GetProcessHeap(),0,
|
||||||
(LPVOID) at->AtomTable,
|
(LPVOID) at->AtomTable,
|
||||||
at->TableSize * sizeof(ATOMENTRY));
|
at->TableSize * sizeof(ATOMENTRY));
|
||||||
lp = &at->AtomTable[at->TableSize - 1];
|
lp = &at->AtomTable[at->TableSize - 1];
|
||||||
|
@ -352,15 +354,15 @@ AWGLAddAtom(
|
||||||
newlen = at->DataSize + atomlen;
|
newlen = at->DataSize + atomlen;
|
||||||
|
|
||||||
if(at->AtomData == 0) {
|
if(at->AtomData == 0) {
|
||||||
at->AtomData = (wchar_t *) malloc(newlen*2);
|
at->AtomData = (WCHAR *) HeapAlloc(GetProcessHeap(),HEAP_GENERATE_EXCEPTIONS|HEAP_ZERO_MEMORY,newlen*2);
|
||||||
lp->idx = 0;
|
lp->idx = 0;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
at->AtomData = (wchar_t *) realloc(at->AtomData,newlen*2);
|
at->AtomData = (WCHAR *) HeapReAlloc(GetProcessHeap(),0,at->AtomData,newlen*2);
|
||||||
lp->idx = at->DataSize;
|
lp->idx = at->DataSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
wcscpy(&at->AtomData[lp->idx],lpString);
|
lstrcpyW(&at->AtomData[lp->idx],lpString);
|
||||||
at->DataSize = newlen;
|
at->DataSize = newlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -378,7 +380,7 @@ AWGLAddAtom(
|
||||||
|
|
||||||
ATOM
|
ATOM
|
||||||
AWGLFindAtom(
|
AWGLFindAtom(
|
||||||
ATOMTABLE *at, const wchar_t *lpString
|
ATOMTABLE *at, const WCHAR *lpString
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -408,11 +410,11 @@ AWGLFindAtom(
|
||||||
|
|
||||||
|
|
||||||
UINT
|
UINT
|
||||||
AWGLGetAtomName(ATOMTABLE *at, ATOM atom, wchar_t *lpString,int len)
|
AWGLGetAtomName(ATOMTABLE *at, ATOM atom, WCHAR *lpString,int len)
|
||||||
{
|
{
|
||||||
|
|
||||||
ATOMENTRY *lp;
|
ATOMENTRY *lp;
|
||||||
wchar_t *atomstr;
|
WCHAR *atomstr;
|
||||||
int atomlen;
|
int atomlen;
|
||||||
|
|
||||||
|
|
||||||
|
@ -420,17 +422,17 @@ AWGLGetAtomName(ATOMTABLE *at, ATOM atom, wchar_t *lpString,int len)
|
||||||
/* return the atom name, or create the INTATOM */
|
/* return the atom name, or create the INTATOM */
|
||||||
if((lp = GetAtomPointer(at,atom - ATOMBASE))) {
|
if((lp = GetAtomPointer(at,atom - ATOMBASE))) {
|
||||||
if(lp->idsize) {
|
if(lp->idsize) {
|
||||||
atomlen = wcslen(atomstr = &at->AtomData[lp->idx]);
|
atomlen = lstrlenW(atomstr = &at->AtomData[lp->idx]);
|
||||||
if (atomlen < len)
|
if (atomlen < len)
|
||||||
wcscpy(lpString,atomstr);
|
lstrcpyW(lpString,atomstr);
|
||||||
else {
|
else {
|
||||||
wcsncpy(lpString,atomstr,len-1);
|
wcsncpy(lpString,atomstr,len-1);
|
||||||
lpString[len-1] = '\0';
|
lpString[len-1] = '\0';
|
||||||
}
|
}
|
||||||
return (UINT)wcslen(lpString);
|
return (UINT)lstrlenW(lpString);
|
||||||
} else {
|
} else {
|
||||||
//wsprintf((wchar *)lpString,"#%d",lp->q);
|
//wsprintf((wchar *)lpString,"#%d",lp->q);
|
||||||
return (UINT)wcslen(lpString);
|
return (UINT)lstrlenW(lpString);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -444,10 +446,10 @@ AWGLGetAtomName(ATOMTABLE *at, ATOM atom, wchar_t *lpString,int len)
|
||||||
/********************************************************/
|
/********************************************************/
|
||||||
|
|
||||||
static ATOMID
|
static ATOMID
|
||||||
AtomHashString(const wchar_t * lp,int *lplen)
|
AtomHashString(const WCHAR * lp,int *lplen)
|
||||||
{
|
{
|
||||||
ATOMID q;
|
ATOMID q;
|
||||||
wchar_t *p,ch;
|
WCHAR *p,ch;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
/* if we have an intatom... */
|
/* if we have an intatom... */
|
||||||
|
@ -457,7 +459,7 @@ AtomHashString(const wchar_t * lp,int *lplen)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* convert the string to an internal representation */
|
/* convert the string to an internal representation */
|
||||||
for(p=(wchar_t *)lp,q=0,len=0;(p++,ch=*p++);len++)
|
for(p=(WCHAR *)lp,q=0,len=0;(p++,ch=*p++);len++)
|
||||||
q = (q<<1) + iswlower(ch)?towupper(ch):ch;
|
q = (q<<1) + iswlower(ch)?towupper(ch):ch;
|
||||||
|
|
||||||
/* 0 is reserved for empty slots */
|
/* 0 is reserved for empty slots */
|
||||||
|
@ -503,22 +505,22 @@ GetAtomPointer(ATOMTABLE *at,int index)
|
||||||
return lp;
|
return lp;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ansi2unicode( wchar_t *uni, char *ansi, int s)
|
int ansi2unicode( WCHAR *uni,const char *ansi, int s)
|
||||||
{
|
{
|
||||||
register int i;
|
register int i;
|
||||||
|
|
||||||
for(i=0;i<=s;i++)
|
for(i=0;i<=s;i++)
|
||||||
uni[i] = (wchar_t)ansi[i];
|
uni[i] = (WCHAR)ansi[i];
|
||||||
return;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
int unicode2ansi( char *ansi, wchar_t *uni, int s)
|
int unicode2ansi( char *ansi,const WCHAR *uni, int s)
|
||||||
{
|
{
|
||||||
register int i;
|
register int i;
|
||||||
|
|
||||||
for(i=0;i<=s;i++)
|
for(i=0;i<=s;i++)
|
||||||
ansi[i] = (char)uni[i];
|
ansi[i] = (char)uni[i];
|
||||||
return;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
75
reactos/lib/kernel32/misc/dllmain.c
Normal file
75
reactos/lib/kernel32/misc/dllmain.c
Normal file
|
@ -0,0 +1,75 @@
|
||||||
|
/*
|
||||||
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
|
* PROJECT: ReactOS system libraries
|
||||||
|
* FILE: lib/kernel32/misc/dllmain.c
|
||||||
|
* PURPOSE: Initialization
|
||||||
|
* PROGRAMMER: Ariadne ( ariadne@xs4all.nl)
|
||||||
|
* UPDATE HISTORY:
|
||||||
|
* Created 01/11/98
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
#include <ddk/ntddk.h>
|
||||||
|
#include <kernel32/proc.h>
|
||||||
|
|
||||||
|
WINBOOL
|
||||||
|
STDCALL
|
||||||
|
DllMain (
|
||||||
|
HANDLE hInst,
|
||||||
|
ULONG ul_reason_for_call,
|
||||||
|
LPVOID lpReserved );
|
||||||
|
|
||||||
|
|
||||||
|
NT_PEB Peb;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
NT_PEB *CurrentPeb;
|
||||||
|
NT_TEB *Teb;
|
||||||
|
PROCESSINFOW ProcessInfo;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
WINBOOL
|
||||||
|
STDCALL
|
||||||
|
DllMain (
|
||||||
|
HANDLE hInst,
|
||||||
|
ULONG ul_reason_for_call,
|
||||||
|
LPVOID lpReserved )
|
||||||
|
{
|
||||||
|
switch( ul_reason_for_call ) {
|
||||||
|
case DLL_PROCESS_ATTACH:
|
||||||
|
{
|
||||||
|
CurrentPeb = &Peb;
|
||||||
|
CurrentPeb->ProcessHeap = HeapCreate(HEAP_GENERATE_EXCEPTIONS,8192,0);
|
||||||
|
InitAtomTable(13);
|
||||||
|
}
|
||||||
|
case DLL_THREAD_ATTACH:
|
||||||
|
{
|
||||||
|
Teb = HeapAlloc(GetProcessHeap(),0,sizeof(NT_TEB));
|
||||||
|
Teb->Peb = GetCurrentPeb();
|
||||||
|
Teb->HardErrorMode = SEM_NOGPFAULTERRORBOX;
|
||||||
|
Teb->dwTlsIndex=0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DLL_PROCESS_DETACH:
|
||||||
|
{
|
||||||
|
HeapFree(GetProcessHeap(),0,Teb);
|
||||||
|
HeapDestroy(GetCurrentPeb()->ProcessHeap);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DLL_THREAD_DETACH:
|
||||||
|
{
|
||||||
|
HeapFree(GetProcessHeap(),0,Teb);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
161
reactos/lib/kernel32/misc/env.c
Normal file
161
reactos/lib/kernel32/misc/env.c
Normal file
|
@ -0,0 +1,161 @@
|
||||||
|
/*
|
||||||
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
|
* PROJECT: ReactOS system libraries
|
||||||
|
* FILE: lib/kernel32/misc/env.c
|
||||||
|
* PURPOSE: Environment functions
|
||||||
|
* PROGRAMMER: Ariadne ( ariadne@xs4all.nl)
|
||||||
|
* UPDATE HISTORY:
|
||||||
|
* Created 01/11/98
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
#include <ddk/ntddk.h>
|
||||||
|
#include <wstring.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#define MAX_ENVIRONMENT_VARS 255
|
||||||
|
|
||||||
|
typedef struct _ENV_ELEMENT
|
||||||
|
{
|
||||||
|
UNICODE_STRING Name;
|
||||||
|
UNICODE_STRING Value;
|
||||||
|
} ENV_ELEMENT;
|
||||||
|
|
||||||
|
ENV_ELEMENT Environment[MAX_ENVIRONMENT_VARS+1];
|
||||||
|
UINT nEnvVar = 0;
|
||||||
|
|
||||||
|
int wcsncmp2(CONST WCHAR *s, CONST WCHAR *t,UINT n);
|
||||||
|
|
||||||
|
DWORD
|
||||||
|
STDCALL
|
||||||
|
GetEnvironmentVariableW(
|
||||||
|
LPCWSTR lpName,
|
||||||
|
LPWSTR lpBuffer,
|
||||||
|
DWORD nSize
|
||||||
|
)
|
||||||
|
{
|
||||||
|
UINT NameLen;
|
||||||
|
UINT i;
|
||||||
|
NameLen = lstrlenW(lpName);
|
||||||
|
i = 0;
|
||||||
|
|
||||||
|
while (i < nEnvVar)
|
||||||
|
{
|
||||||
|
if ( wcsncmp2(Environment[i].Name.Buffer,lpName,min(NameLen,Environment[i].Name.Length)) != 0 ) {
|
||||||
|
lstrcpynW(lpBuffer,Environment[i].Value.Buffer,min(nSize,Environment[i].Value.Length));
|
||||||
|
|
||||||
|
return lstrlenW(lpBuffer);
|
||||||
|
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int wcsncmp2(CONST WCHAR *s, CONST WCHAR *t,UINT n)
|
||||||
|
{
|
||||||
|
for(;towupper(*s) == towupper(*t) && n > 0; s++, t++, n--)
|
||||||
|
if ( *s == 0 )
|
||||||
|
return 0;
|
||||||
|
return *s - *t;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
WINBOOL
|
||||||
|
STDCALL
|
||||||
|
SetEnvironmentVariableW(
|
||||||
|
LPCWSTR lpName,
|
||||||
|
LPCWSTR lpValue
|
||||||
|
)
|
||||||
|
{
|
||||||
|
UINT NameLen, ValueLen;
|
||||||
|
UINT i;
|
||||||
|
WCHAR *NameBuffer;
|
||||||
|
WCHAR *ValueBuffer;
|
||||||
|
NameLen = lstrlenW(lpName);
|
||||||
|
ValueLen = lstrlenW(lpValue);
|
||||||
|
i = 0;
|
||||||
|
|
||||||
|
while (i < nEnvVar)
|
||||||
|
{
|
||||||
|
if ( wcsncmp2(Environment[i].Name.Buffer,lpName,min(NameLen,Environment[i].Name.Length)) != 0 ) {
|
||||||
|
lstrcpynW(Environment[i].Value.Buffer,lpValue,min(ValueLen,Environment[i].Value.MaximumLength));
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( nEnvVar > MAX_ENVIRONMENT_VARS )
|
||||||
|
return FALSE;
|
||||||
|
NameBuffer = (WCHAR *)HeapAlloc(GetProcessHeap(),HEAP_GENERATE_EXCEPTIONS|HEAP_ZERO_MEMORY,MAX_PATH*sizeof(WCHAR));
|
||||||
|
ValueBuffer = (WCHAR *)HeapAlloc(GetProcessHeap(),HEAP_GENERATE_EXCEPTIONS|HEAP_ZERO_MEMORY,1024*sizeof(WCHAR));
|
||||||
|
|
||||||
|
Environment[i].Name.Buffer = NameBuffer;
|
||||||
|
Environment[i].Name.MaximumLength = MAX_PATH;
|
||||||
|
lstrcpynW(Environment[i].Name.Buffer,lpValue,min(NameLen,Environment[i].Name.MaximumLength));
|
||||||
|
Environment[i].Name.Length = NameLen;
|
||||||
|
|
||||||
|
Environment[i].Value.Buffer = ValueBuffer;
|
||||||
|
Environment[i].Value.MaximumLength = 1024;
|
||||||
|
lstrcpynW(Environment[i].Value.Buffer,lpValue,min(ValueLen,Environment[i].Value.MaximumLength));
|
||||||
|
Environment[i].Value.Length = ValueLen;
|
||||||
|
|
||||||
|
|
||||||
|
nEnvVar++;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD
|
||||||
|
STDCALL
|
||||||
|
GetVersion(VOID)
|
||||||
|
{
|
||||||
|
DWORD Version = 0;
|
||||||
|
OSVERSIONINFO VersionInformation;
|
||||||
|
GetVersionExW(&VersionInformation);
|
||||||
|
|
||||||
|
Version |= ( VersionInformation.dwMajorVersion << 8 );
|
||||||
|
Version |= VersionInformation.dwMinorVersion;
|
||||||
|
|
||||||
|
Version |= ( VersionInformation.dwPlatformId << 16 );
|
||||||
|
|
||||||
|
return Version;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
WINBOOL
|
||||||
|
STDCALL
|
||||||
|
GetVersionExW(
|
||||||
|
LPOSVERSIONINFO lpVersionInformation
|
||||||
|
)
|
||||||
|
{
|
||||||
|
lpVersionInformation->dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
||||||
|
lpVersionInformation->dwMajorVersion = 4;
|
||||||
|
lpVersionInformation->dwMinorVersion = 0;
|
||||||
|
lpVersionInformation->dwBuildNumber = 12;
|
||||||
|
lpVersionInformation->dwPlatformId = VER_PLATFORM_WIN32_NT;
|
||||||
|
lstrcpyW((WCHAR *)lpVersionInformation->szCSDVersion,L"ReactOs Pre-Alpha 12");
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
WINBOOL
|
||||||
|
STDCALL
|
||||||
|
GetVersionExA(
|
||||||
|
LPOSVERSIONINFO lpVersionInformation
|
||||||
|
)
|
||||||
|
{
|
||||||
|
lpVersionInformation->dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
||||||
|
lpVersionInformation->dwMajorVersion = 4;
|
||||||
|
lpVersionInformation->dwMinorVersion = 0;
|
||||||
|
lpVersionInformation->dwBuildNumber = 12;
|
||||||
|
lpVersionInformation->dwPlatformId = VER_PLATFORM_WIN32_NT;
|
||||||
|
lstrcpyA((char *)lpVersionInformation->szCSDVersion,"ReactOs Pre-Alpha 12");
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
133
reactos/lib/kernel32/misc/handle.c
Normal file
133
reactos/lib/kernel32/misc/handle.c
Normal file
|
@ -0,0 +1,133 @@
|
||||||
|
/*
|
||||||
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
|
* PROJECT: ReactOS system libraries
|
||||||
|
* FILE: lib/kernel32/misc/handle.c
|
||||||
|
* PURPOSE: Object functions
|
||||||
|
* PROGRAMMER: Ariadne ( ariadne@xs4all.nl)
|
||||||
|
* UPDATE HISTORY:
|
||||||
|
* Created 01/11/98
|
||||||
|
*/
|
||||||
|
#include <windows.h>
|
||||||
|
#include <ddk\ntddk.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
WINBOOL
|
||||||
|
WINAPI
|
||||||
|
GetHandleInformation(
|
||||||
|
HANDLE hObject,
|
||||||
|
LPDWORD lpdwFlags
|
||||||
|
)
|
||||||
|
{
|
||||||
|
OBJECT_DATA_INFORMATION HandleInfo;
|
||||||
|
ULONG BytesWritten;
|
||||||
|
NTSTATUS errCode;
|
||||||
|
|
||||||
|
errCode = NtQueryObject(hObject,ObjectDataInformation, &HandleInfo, sizeof(OBJECT_DATA_INFORMATION),&BytesWritten);
|
||||||
|
if (!NT_SUCCESS(errCode) ) {
|
||||||
|
SetLastError(RtlNtStatusToDosError(errCode));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
if ( HandleInfo.bInheritHandle )
|
||||||
|
*lpdwFlags &= HANDLE_FLAG_INHERIT;
|
||||||
|
if ( HandleInfo.bProtectFromClose )
|
||||||
|
*lpdwFlags &= HANDLE_FLAG_PROTECT_FROM_CLOSE;
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
WINBOOL
|
||||||
|
STDCALL
|
||||||
|
SetHandleInformation(
|
||||||
|
HANDLE hObject,
|
||||||
|
DWORD dwMask,
|
||||||
|
DWORD dwFlags
|
||||||
|
)
|
||||||
|
{
|
||||||
|
OBJECT_DATA_INFORMATION HandleInfo;
|
||||||
|
NTSTATUS errCode;
|
||||||
|
ULONG BytesWritten;
|
||||||
|
|
||||||
|
errCode = NtQueryObject(hObject,ObjectDataInformation,&HandleInfo,sizeof(OBJECT_DATA_INFORMATION),&BytesWritten);
|
||||||
|
if (!NT_SUCCESS(errCode) ) {
|
||||||
|
SetLastError(RtlNtStatusToDosError(errCode));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
if ( (dwMask & HANDLE_FLAG_INHERIT)== HANDLE_FLAG_INHERIT) {
|
||||||
|
HandleInfo.bInheritHandle = (BOOLEAN)((dwFlags & HANDLE_FLAG_INHERIT) == HANDLE_FLAG_INHERIT);
|
||||||
|
}
|
||||||
|
if ( (dwMask & HANDLE_FLAG_PROTECT_FROM_CLOSE) == HANDLE_FLAG_PROTECT_FROM_CLOSE ) {
|
||||||
|
HandleInfo.bProtectFromClose = (BOOLEAN)((dwFlags & HANDLE_FLAG_PROTECT_FROM_CLOSE) == HANDLE_FLAG_PROTECT_FROM_CLOSE ) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
errCode = NtSetInformationObject(hObject,ObjectDataInformation,&HandleInfo,sizeof(OBJECT_DATA_INFORMATION));
|
||||||
|
if (!NT_SUCCESS(errCode) ) {
|
||||||
|
SetLastError(RtlNtStatusToDosError(errCode));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
WINBOOL
|
||||||
|
STDCALL
|
||||||
|
CloseHandle( HANDLE hObject )
|
||||||
|
{
|
||||||
|
|
||||||
|
NTSTATUS errCode;
|
||||||
|
|
||||||
|
errCode = NtClose(hObject);
|
||||||
|
if(!NT_SUCCESS(errCode)) {
|
||||||
|
SetLastError(RtlNtStatusToDosError(errCode));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
WINBOOL
|
||||||
|
STDCALL
|
||||||
|
DuplicateHandle(
|
||||||
|
HANDLE hSourceProcessHandle,
|
||||||
|
HANDLE hSourceHandle,
|
||||||
|
HANDLE hTargetProcessHandle,
|
||||||
|
LPHANDLE lpTargetHandle,
|
||||||
|
DWORD dwDesiredAccess,
|
||||||
|
BOOL bInheritHandle,
|
||||||
|
DWORD dwOptions
|
||||||
|
)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
NTSTATUS errCode;
|
||||||
|
|
||||||
|
errCode = NtDuplicateObject(hSourceProcessHandle,hSourceHandle,hTargetProcessHandle,lpTargetHandle, dwDesiredAccess, (BOOLEAN)bInheritHandle,dwOptions);
|
||||||
|
if ( !NT_SUCCESS(errCode) ) {
|
||||||
|
SetLastError(RtlNtStatusToDosError(errCode));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
UINT STDCALL
|
||||||
|
SetHandleCount(UINT nCount)
|
||||||
|
{
|
||||||
|
return nCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,83 +1,440 @@
|
||||||
#include <windows.h>
|
|
||||||
#include <process.h>
|
|
||||||
/*
|
/*
|
||||||
* Win32 Process Api functions
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* Author: Boudewijn Dekker
|
* PROJECT: ReactOS system libraries
|
||||||
* to do: many more to add ..
|
* FILE: lib/kernel32/proc/proc.c
|
||||||
* open matters: ProcessInformation should be per process
|
* PURPOSE: Process functions
|
||||||
and part of larger structure.
|
* PROGRAMMER: Ariadne ( ariadne@xs4all.nl)
|
||||||
|
* UPDATE HISTORY:
|
||||||
|
* Created 01/11/98
|
||||||
*/
|
*/
|
||||||
|
#define UNICODE
|
||||||
|
#include <windows.h>
|
||||||
|
#include <kernel32/proc.h>
|
||||||
|
#include <kernel32/thread.h>
|
||||||
|
#include <wstring.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <ddk/rtl.h>
|
||||||
|
#include <ddk/li.h>
|
||||||
|
|
||||||
|
extern NT_PEB *CurrentPeb;
|
||||||
|
extern NT_PEB Peb;
|
||||||
|
|
||||||
|
WaitForInputIdleType lpfnGlobalRegisterWaitForInputIdle;
|
||||||
|
|
||||||
|
VOID RegisterWaitForInputIdle(WaitForInputIdleType lpfnRegisterWaitForInputIdle);
|
||||||
|
|
||||||
|
WINBOOL
|
||||||
|
STDCALL
|
||||||
|
GetProcessId(HANDLE hProcess, LPDWORD lpProcessId );
|
||||||
|
|
||||||
|
|
||||||
|
NT_PEB *GetCurrentPeb(VOID)
|
||||||
|
{
|
||||||
#define NT_CURRENT_PROCESS 0xFFFFFFFF
|
if ( CurrentPeb != NULL )
|
||||||
#define NT_CURRENT_THREAD 0xFFFFFFFE
|
return CurrentPeb;
|
||||||
|
else // hack to be able to return a process environment any time.
|
||||||
|
return &Peb;
|
||||||
|
}
|
||||||
|
|
||||||
HANDLE STDCALL GetCurrentProcess(VOID)
|
HANDLE STDCALL GetCurrentProcess(VOID)
|
||||||
{
|
{
|
||||||
return NT_CURRENT_PROCESS;
|
return (HANDLE)NtCurrentProcess();
|
||||||
}
|
}
|
||||||
|
|
||||||
HANDLE STDCALL GetCurrentThread()
|
HANDLE STDCALL GetCurrentThread(VOID)
|
||||||
{
|
{
|
||||||
return NT_CURRENT_PROCESS;
|
return (HANDLE)NtCurrentThread();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
|
|
||||||
WINBASEAPI
|
|
||||||
DWORD
|
DWORD
|
||||||
WINAPI
|
STDCALL
|
||||||
GetCurrentProcessId()
|
GetCurrentProcessId(VOID)
|
||||||
{
|
{
|
||||||
return GetTeb()->dwProcessId;
|
|
||||||
|
return (DWORD)(GetTeb()->Cid).UniqueProcess;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned char CommandLineA[MAX_PATH];
|
||||||
|
|
||||||
|
LPSTR
|
||||||
|
STDCALL
|
||||||
|
GetCommandLineA(
|
||||||
|
VOID
|
||||||
|
)
|
||||||
|
{
|
||||||
|
WCHAR *CommandLineW;
|
||||||
|
ULONG i = 0;
|
||||||
|
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
WINBASEAPI
|
WINBOOL
|
||||||
DWORD
|
STDCALL
|
||||||
WINAPI
|
GetExitCodeProcess(
|
||||||
GetCurrentThreadId()
|
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;
|
||||||
|
|
||||||
|
|
||||||
|
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
|
||||||
|
)
|
||||||
{
|
{
|
||||||
|
|
||||||
return GetTeb()->dwThreadId;
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
UINT WinExec ( LPCSTR lpCmdLine, UINT uCmdShow )
|
UINT WinExec ( LPCSTR lpCmdLine, UINT uCmdShow )
|
||||||
{
|
{
|
||||||
STARTUPINFO StartUpInfo;
|
STARTUPINFO StartupInfo;
|
||||||
StartupInfo.wShowWindow = uCmdShow ;
|
|
||||||
PROCESS_INFORMATION ProcessInformation;
|
PROCESS_INFORMATION ProcessInformation;
|
||||||
|
|
||||||
|
HINSTANCE hInst;
|
||||||
|
DWORD dosErr;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
StartupInfo.cb = sizeof(STARTUPINFO);
|
StartupInfo.cb = sizeof(STARTUPINFO);
|
||||||
|
StartupInfo.wShowWindow = uCmdShow ;
|
||||||
StartupInfo.dwFlags = 0;
|
StartupInfo.dwFlags = 0;
|
||||||
|
|
||||||
HINSTANCE hInst = CreateProcess(NULL,lpCmdLine,NULL,NULL,FALSE,NULL,NULL,NULL,&StartupInfo, &ProcessInformation);
|
hInst = (HINSTANCE)CreateProcessA(NULL,(PVOID)lpCmdLine,NULL,NULL,FALSE,0,NULL,NULL,&StartupInfo, &ProcessInformation);
|
||||||
if ( hInst == NULL ) {
|
if ( hInst == NULL ) {
|
||||||
dosErr = GetLastError();
|
dosErr = GetLastError();
|
||||||
if ( dosErr == 0x000000C1 )
|
|
||||||
return 0; // out of resources
|
|
||||||
else
|
|
||||||
return dosErr;
|
return dosErr;
|
||||||
}
|
}
|
||||||
if ( lpfuncGlobalRegisterWaitForInputIdle != NULL )
|
if ( lpfnGlobalRegisterWaitForInputIdle != NULL )
|
||||||
lpfuncGlobalRegisterWaitForInputIdle(0x00007530,ProcessInformation->hProcess);
|
lpfnGlobalRegisterWaitForInputIdle(ProcessInformation.hProcess,10000);
|
||||||
NtClose(ProcessInformation->hProcess);
|
NtClose(ProcessInformation.hProcess);
|
||||||
NtClose(ProcessInformation->hThread);
|
NtClose(ProcessInformation.hThread);
|
||||||
return;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
VOID RegisterWaitForInputIdle(lpfuncRegisterWaitForInputIdle)
|
VOID RegisterWaitForInputIdle(WaitForInputIdleType lpfnRegisterWaitForInputIdle)
|
||||||
{
|
{
|
||||||
lpfuncGlobalRegisterWaitForInputIdle = lpfuncRegisterWaitForInputIdle; //77F450C8
|
lpfnGlobalRegisterWaitForInputIdle = lpfnRegisterWaitForInputIdle;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD
|
||||||
|
STDCALL
|
||||||
|
WaitForInputIdle(
|
||||||
|
HANDLE hProcess,
|
||||||
|
DWORD dwMilliseconds
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID
|
||||||
|
STDCALL
|
||||||
|
Sleep(
|
||||||
|
DWORD dwMilliseconds
|
||||||
|
)
|
||||||
|
{
|
||||||
|
SleepEx(dwMilliseconds,FALSE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD
|
||||||
|
STDCALL
|
||||||
|
SleepEx(
|
||||||
|
DWORD dwMilliseconds,
|
||||||
|
BOOL bAlertable
|
||||||
|
)
|
||||||
|
{
|
||||||
|
TIME Interval;
|
||||||
|
NTSTATUS errCode;
|
||||||
|
SET_LARGE_INTEGER_LOW_PART(Interval,dwMilliseconds*1000);
|
||||||
|
|
||||||
|
errCode = NtDelayExecution(bAlertable,&Interval);
|
||||||
|
if ( !NT_SUCCESS(errCode) ) {
|
||||||
|
SetLastError(RtlNtStatusToDosError(errCode));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#define STARTF_IO 0x00000700
|
|
||||||
|
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
STDCALL
|
STDCALL
|
||||||
|
@ -85,40 +442,97 @@ GetStartupInfoW(
|
||||||
LPSTARTUPINFO lpStartupInfo
|
LPSTARTUPINFO lpStartupInfo
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
NT_PEB *pPeb = GetTeb()->pPeb;
|
NT_PEB *pPeb = GetCurrentPeb();
|
||||||
|
|
||||||
if (lpStartupInfo == NULL ) {
|
if (lpStartupInfo == NULL ) {
|
||||||
SetLastError(-1);
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
lpStartupInfo->cb = sizeof(STARTUPINFO);
|
||||||
|
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;
|
||||||
|
lpStartupInfo->dwYSize = pPeb->StartupInfo->dwYSize;
|
||||||
|
lpStartupInfo->dwXCountChars = pPeb->StartupInfo->dwXCountChars;
|
||||||
|
lpStartupInfo->dwYCountChars = pPeb->StartupInfo->dwYCountChars;
|
||||||
|
lpStartupInfo->dwFillAttribute = pPeb->StartupInfo->dwFillAttribute;
|
||||||
|
lpStartupInfo->dwFlags = pPeb->StartupInfo->dwFlags;
|
||||||
|
lpStartupInfo->wShowWindow = pPeb->StartupInfo->wShowWindow;
|
||||||
|
//lpStartupInfo->cbReserved2 = pPeb->StartupInfo->cbReserved;
|
||||||
|
//lpStartupInfo->lpReserved = pPeb->StartupInfo->lpReserved1;
|
||||||
|
//lpStartupInfo->lpReserved2 = pPeb->StartupInfo->lpReserved2;
|
||||||
|
|
||||||
|
lpStartupInfo->hStdInput = pPeb->StartupInfo->hStdInput;
|
||||||
|
lpStartupInfo->hStdOutput = pPeb->StartupInfo->hStdOutput;
|
||||||
|
lpStartupInfo->hStdError = pPeb->StartupInfo->hStdError;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
VOID
|
||||||
|
STDCALL
|
||||||
|
GetStartupInfoA(
|
||||||
|
LPSTARTUPINFO lpStartupInfo
|
||||||
|
)
|
||||||
|
{
|
||||||
|
NT_PEB *pPeb = GetCurrentPeb();
|
||||||
|
ULONG i = 0;
|
||||||
|
if (lpStartupInfo == NULL ) {
|
||||||
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
lpStartupInfo->cb = pPeb->pPebInfo->cb;
|
lpStartupInfo->cb = sizeof(STARTUPINFO);
|
||||||
lpStartupInfo->lpReserved = pPeb->pPebInfo->lpReserved1;
|
i = 0;
|
||||||
lpStartupInfo->lpDesktop = pPeb->pPebInfo->lpDesktop;
|
|
||||||
lpStartupInfo->lpTitle = pPeb->pPebInfo->lpTitle;
|
while ((pPeb->StartupInfo->Desktop[i])!=0 && i < MAX_PATH)
|
||||||
lpStartupInfo->dwX = pPeb->pPebInfo->dwX;
|
{
|
||||||
lpStartupInfo->dwY = pPeb->pPebInfo->dwY;
|
lpStartupInfo->lpDesktop[i] = (unsigned char)pPeb->StartupInfo->Desktop[i];
|
||||||
lpStartupInfo->dwXSize = pPeb->pPebInfo->dwXSize;
|
i++;
|
||||||
lpStartupInfo->dwYSize = pPeb->pPebInfo->dwYSize;
|
}
|
||||||
lpStartupInfo->dwXCountChars = pPeb->pPebInfo->dwXCountChars;
|
lpStartupInfo->lpDesktop[i] = 0;
|
||||||
lpStartupInfo->dwYCountChars = pPeb->pPebInfo->dwYCountChars;
|
|
||||||
lpStartupInfo->dwFillAttribute = pPeb->pPebInfo->dwFillAttribute;
|
i = 0;
|
||||||
lpStartupInfo->dwFlags = pPeb->pPebInfo->dwFlags;
|
while ((pPeb->StartupInfo->Title[i])!=0 && i < MAX_PATH)
|
||||||
lpStartupInfo->wShowWindow = pPeb->pPebInfo->wShowWindow;
|
{
|
||||||
lpStartupInfo->cbReserved2 = pPeb->pPebInfo->cbReserved;
|
lpStartupInfo->lpTitle[i] = (unsigned char)pPeb->StartupInfo->Title[i];
|
||||||
lpStartupInfo->lpReserved2 = pPeb->pPebInfo->lpReserved2;
|
i++;
|
||||||
if ( lpStartupInfo.dwFlags == STARTF_IO ) {
|
}
|
||||||
lpStartupInfo->hStdInput = pPeb->pPebInfo->hStdInput;
|
lpStartupInfo->lpTitle[i] = 0;
|
||||||
lpStartupInfo->hStdOutput = pPeb->pPebInfo->hStdOutput;
|
|
||||||
lpStartupInfo->hStdError = pPeb->pPebInfo->hStdError;
|
lpStartupInfo->dwX = pPeb->StartupInfo->dwX;
|
||||||
|
lpStartupInfo->dwY = pPeb->StartupInfo->dwY;
|
||||||
|
lpStartupInfo->dwXSize = pPeb->StartupInfo->dwXSize;
|
||||||
|
lpStartupInfo->dwYSize = pPeb->StartupInfo->dwYSize;
|
||||||
|
lpStartupInfo->dwXCountChars = pPeb->StartupInfo->dwXCountChars;
|
||||||
|
lpStartupInfo->dwYCountChars = pPeb->StartupInfo->dwYCountChars;
|
||||||
|
lpStartupInfo->dwFillAttribute = pPeb->StartupInfo->dwFillAttribute;
|
||||||
|
lpStartupInfo->dwFlags = pPeb->StartupInfo->dwFlags;
|
||||||
|
lpStartupInfo->wShowWindow = pPeb->StartupInfo->wShowWindow;
|
||||||
|
//lpStartupInfo->cbReserved2 = pPeb->StartupInfo->cbReserved;
|
||||||
|
//lpStartupInfo->lpReserved = pPeb->StartupInfo->lpReserved1;
|
||||||
|
//lpStartupInfo->lpReserved2 = pPeb->StartupInfo->lpReserved2;
|
||||||
|
|
||||||
|
lpStartupInfo->hStdInput = pPeb->StartupInfo->hStdInput;
|
||||||
|
lpStartupInfo->hStdOutput = pPeb->StartupInfo->hStdOutput;
|
||||||
|
lpStartupInfo->hStdError = pPeb->StartupInfo->hStdError;
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOL
|
||||||
}
|
STDCALL
|
||||||
|
FlushInstructionCache(
|
||||||
|
|
||||||
BOOL FlushInstructionCache(
|
|
||||||
|
|
||||||
|
|
||||||
HANDLE hProcess,
|
HANDLE hProcess,
|
||||||
|
@ -126,11 +540,61 @@ BOOL FlushInstructionCache(
|
||||||
DWORD dwSize
|
DWORD dwSize
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
errCode = NtFlushInstructionCache(hProcess,lpBaseAddress,dwSize);
|
NTSTATUS errCode;
|
||||||
if ( errCode < 0 ) {
|
errCode = NtFlushInstructionCache(hProcess,(PVOID)lpBaseAddress,dwSize);
|
||||||
CompatibleError(errCode);
|
if ( !NT_SUCCESS(errCode) ) {
|
||||||
|
SetLastError(RtlNtStatusToDosError(errCode));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
VOID
|
||||||
|
STDCALL
|
||||||
|
ExitProcess(
|
||||||
|
UINT uExitCode
|
||||||
|
)
|
||||||
|
{
|
||||||
|
|
||||||
|
NtTerminateProcess(
|
||||||
|
NtCurrentProcess() ,
|
||||||
|
uExitCode
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID
|
||||||
|
STDCALL
|
||||||
|
FatalAppExitA(
|
||||||
|
UINT uAction,
|
||||||
|
LPCSTR lpMessageText
|
||||||
|
)
|
||||||
|
{
|
||||||
|
WCHAR MessageTextW[MAX_PATH];
|
||||||
|
UINT i;
|
||||||
|
i = 0;
|
||||||
|
while ((*lpMessageText)!=0 && i < 35)
|
||||||
|
{
|
||||||
|
MessageTextW[i] = *lpMessageText;
|
||||||
|
lpMessageText++;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
MessageTextW[i] = 0;
|
||||||
|
|
||||||
|
return FatalAppExitW(uAction,MessageTextW);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
VOID
|
||||||
|
STDCALL
|
||||||
|
FatalAppExitW(
|
||||||
|
UINT uAction,
|
||||||
|
LPCWSTR lpMessageText
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,18 @@
|
||||||
|
/*
|
||||||
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
|
* PROJECT: ReactOS system libraries
|
||||||
|
* FILE: lib/kernel32/file/lstring.c
|
||||||
|
* PURPOSE: Local string functions
|
||||||
|
* PROGRAMMER: Ariadne ( ariadne@xs4all.nl)
|
||||||
|
* UPDATE HISTORY:
|
||||||
|
* Created 01/11/98
|
||||||
|
*/
|
||||||
#undef WIN32_LEAN_AND_MEAN
|
#undef WIN32_LEAN_AND_MEAN
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <wstring.h>
|
#include <wstring.h>
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
STDCALL
|
STDCALL
|
||||||
lstrcmpA(
|
lstrcmpA(
|
||||||
|
@ -122,4 +131,12 @@ lstrlenW(
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return wcslen(lpString);
|
return wcslen(lpString);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,7 @@ VOID LeaveCriticalSection(LPCRITICAL_SECTION lpCriticalSection)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL TryEntryCriticalSection(LPCRITICAL_SECTION lpCriticalSection)
|
WINBOOL TryEntryCriticalSection(LPCRITICAL_SECTION lpCriticalSection)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
198
reactos/lib/kernel32/synch/event.c
Normal file
198
reactos/lib/kernel32/synch/event.c
Normal file
|
@ -0,0 +1,198 @@
|
||||||
|
/*
|
||||||
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
|
* PROJECT: ReactOS system libraries
|
||||||
|
* FILE: lib/kernel32/synch/event.c
|
||||||
|
* PURPOSE: Local string functions
|
||||||
|
* PROGRAMMER: Ariadne ( ariadne@xs4all.nl)
|
||||||
|
* UPDATE HISTORY:
|
||||||
|
* Created 01/11/98
|
||||||
|
*/
|
||||||
|
#undef WIN32_LEAN_AND_MEAN
|
||||||
|
#include <windows.h>
|
||||||
|
#include <ddk/ntddk.h>
|
||||||
|
#include <ddk/rtl.h>
|
||||||
|
#include <wstring.h>
|
||||||
|
|
||||||
|
|
||||||
|
WINBOOL
|
||||||
|
STDCALL
|
||||||
|
SetEvent(
|
||||||
|
HANDLE hEvent
|
||||||
|
)
|
||||||
|
{
|
||||||
|
NTSTATUS errCode;
|
||||||
|
ULONG Count;
|
||||||
|
errCode = NtSetEvent(hEvent,&Count);
|
||||||
|
if ( !NT_SUCCESS(errCode) ) {
|
||||||
|
SetLastError(RtlNtStatusToDosError(errCode));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
WINBOOL
|
||||||
|
STDCALL
|
||||||
|
ResetEvent(
|
||||||
|
HANDLE hEvent
|
||||||
|
)
|
||||||
|
{
|
||||||
|
NTSTATUS errCode;
|
||||||
|
ULONG Count;
|
||||||
|
errCode = NtResetEvent(hEvent, &Count);
|
||||||
|
if ( !NT_SUCCESS(errCode) ) {
|
||||||
|
SetLastError(RtlNtStatusToDosError(errCode));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
HANDLE
|
||||||
|
STDCALL
|
||||||
|
CreateEventW(
|
||||||
|
LPSECURITY_ATTRIBUTES lpEventAttributes,
|
||||||
|
WINBOOL bManualReset,
|
||||||
|
WINBOOL bInitialState,
|
||||||
|
LPCWSTR lpName
|
||||||
|
)
|
||||||
|
{
|
||||||
|
NTSTATUS errCode;
|
||||||
|
HANDLE hEvent;
|
||||||
|
UNICODE_STRING EventNameString;
|
||||||
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||||
|
ObjectAttributes.Attributes = 0;
|
||||||
|
if ( lpEventAttributes != NULL ) {
|
||||||
|
ObjectAttributes.SecurityDescriptor = lpEventAttributes->lpSecurityDescriptor;
|
||||||
|
if ( lpEventAttributes->bInheritHandle == TRUE )
|
||||||
|
ObjectAttributes.Attributes |= OBJ_INHERIT;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(lpName != NULL) {
|
||||||
|
EventNameString.Buffer = (WCHAR *)lpName;
|
||||||
|
EventNameString.Length = lstrlenW(lpName)*sizeof(WCHAR);
|
||||||
|
EventNameString.MaximumLength = EventNameString.Length;
|
||||||
|
ObjectAttributes.ObjectName = &EventNameString;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ObjectAttributes.ObjectName = NULL;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
errCode = NtCreateEvent(&hEvent,STANDARD_RIGHTS_ALL|EVENT_READ_ACCESS|EVENT_WRITE_ACCESS,&ObjectAttributes,bManualReset,bInitialState);
|
||||||
|
if(!NT_SUCCESS(errCode)) {
|
||||||
|
SetLastError(RtlNtStatusToDosError(errCode));
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return hEvent;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
HANDLE
|
||||||
|
STDCALL
|
||||||
|
OpenEventW(
|
||||||
|
DWORD dwDesiredAccess,
|
||||||
|
WINBOOL bInheritHandle,
|
||||||
|
LPCWSTR lpName
|
||||||
|
)
|
||||||
|
{
|
||||||
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||||
|
UNICODE_STRING EventNameString;
|
||||||
|
NTSTATUS errCode;
|
||||||
|
HANDLE hEvent = NULL;
|
||||||
|
|
||||||
|
if(lpName == NULL) {
|
||||||
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
ObjectAttributes.Attributes = 0;
|
||||||
|
ObjectAttributes.SecurityDescriptor = NULL;
|
||||||
|
EventNameString.Buffer = (WCHAR *)lpName;
|
||||||
|
EventNameString.Length = lstrlenW(lpName)*sizeof(WCHAR);
|
||||||
|
EventNameString.MaximumLength = EventNameString.Length;
|
||||||
|
ObjectAttributes.ObjectName = &EventNameString;
|
||||||
|
|
||||||
|
if (bInheritHandle == TRUE )
|
||||||
|
ObjectAttributes.Attributes |= OBJ_INHERIT;
|
||||||
|
|
||||||
|
|
||||||
|
errCode = NtOpenEvent(hEvent,dwDesiredAccess,&ObjectAttributes);
|
||||||
|
if ( !NT_SUCCESS(errCode) ) {
|
||||||
|
SetLastError(RtlNtStatusToDosError(errCode));
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return hEvent;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
HANDLE
|
||||||
|
STDCALL
|
||||||
|
CreateEventA(
|
||||||
|
LPSECURITY_ATTRIBUTES lpEventAttributes,
|
||||||
|
WINBOOL bManualReset,
|
||||||
|
WINBOOL bInitialState,
|
||||||
|
LPCSTR lpName
|
||||||
|
)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
WCHAR EventNameW[MAX_PATH];
|
||||||
|
i = 0;
|
||||||
|
while ((*lpName)!=0 && i < MAX_PATH)
|
||||||
|
{
|
||||||
|
EventNameW[i] = *lpName;
|
||||||
|
lpName++;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
EventNameW[i] = 0;
|
||||||
|
|
||||||
|
return CreateEventW(lpEventAttributes,bManualReset,bInitialState,EventNameW);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
HANDLE
|
||||||
|
STDCALL
|
||||||
|
OpenEventA(
|
||||||
|
DWORD dwDesiredAccess,
|
||||||
|
WINBOOL bInheritHandle,
|
||||||
|
LPCSTR lpName
|
||||||
|
)
|
||||||
|
{
|
||||||
|
ULONG i;
|
||||||
|
WCHAR EventNameW[MAX_PATH];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
while ((*lpName)!=0 && i < MAX_PATH)
|
||||||
|
{
|
||||||
|
EventNameW[i] = *lpName;
|
||||||
|
lpName++;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
EventNameW[i] = 0;
|
||||||
|
|
||||||
|
|
||||||
|
return OpenEventW(dwDesiredAccess,bInheritHandle,EventNameW);
|
||||||
|
}
|
||||||
|
|
||||||
|
WINBOOL
|
||||||
|
STDCALL
|
||||||
|
PulseEvent(
|
||||||
|
HANDLE hEvent
|
||||||
|
)
|
||||||
|
{
|
||||||
|
ULONG Count;
|
||||||
|
NTSTATUS errCode;
|
||||||
|
errCode = NtPulseEvent(hEvent,&Count);
|
||||||
|
if ( !NT_SUCCESS(errCode) ) {
|
||||||
|
SetLastError(RtlNtStatusToDosError(errCode));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
246
reactos/lib/kernel32/synch/wait.c
Normal file
246
reactos/lib/kernel32/synch/wait.c
Normal file
|
@ -0,0 +1,246 @@
|
||||||
|
/*
|
||||||
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
|
* PROJECT: ReactOS system libraries
|
||||||
|
* FILE: lib/kernel32/synch/wait.c
|
||||||
|
* PURPOSE: Wait functions
|
||||||
|
* PROGRAMMER: Ariadne ( ariadne@xs4all.nl)
|
||||||
|
* UPDATE HISTORY:
|
||||||
|
* Created 01/11/98
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
#include <wstring.h>
|
||||||
|
#include <ddk/ntddk.h>
|
||||||
|
#include <ddk/li.h>
|
||||||
|
|
||||||
|
HANDLE
|
||||||
|
STDCALL
|
||||||
|
CreateSemaphoreA(
|
||||||
|
LPSECURITY_ATTRIBUTES lpSemaphoreAttributes,
|
||||||
|
LONG lInitialCount,
|
||||||
|
LONG lMaximumCount,
|
||||||
|
LPCSTR lpName
|
||||||
|
)
|
||||||
|
{
|
||||||
|
WCHAR NameW[MAX_PATH];
|
||||||
|
ULONG i = 0;
|
||||||
|
|
||||||
|
while ((*lpName)!=0 && i < MAX_PATH)
|
||||||
|
{
|
||||||
|
NameW[i] = *lpName;
|
||||||
|
lpName++;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
NameW[i] = 0;
|
||||||
|
return CreateSemaphoreW(
|
||||||
|
lpSemaphoreAttributes,
|
||||||
|
lInitialCount,
|
||||||
|
lMaximumCount,
|
||||||
|
NameW
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
HANDLE
|
||||||
|
STDCALL
|
||||||
|
CreateSemaphoreW(
|
||||||
|
LPSECURITY_ATTRIBUTES lpSemaphoreAttributes,
|
||||||
|
LONG lInitialCount,
|
||||||
|
LONG lMaximumCount,
|
||||||
|
LPCWSTR lpName
|
||||||
|
)
|
||||||
|
{
|
||||||
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||||
|
NTSTATUS errCode;
|
||||||
|
UNICODE_STRING NameString;
|
||||||
|
HANDLE SemaphoreHandle;
|
||||||
|
|
||||||
|
NameString.Length = lstrlenW(lpName)*sizeof(WCHAR);
|
||||||
|
NameString.Buffer = (WCHAR *)lpName;
|
||||||
|
NameString.MaximumLength = NameString.Length;
|
||||||
|
|
||||||
|
ObjectAttributes.Length = sizeof(OBJECT_ATTRIBUTES);
|
||||||
|
ObjectAttributes.RootDirectory = NULL;
|
||||||
|
ObjectAttributes.ObjectName = &NameString;
|
||||||
|
ObjectAttributes.Attributes = OBJ_CASE_INSENSITIVE;
|
||||||
|
ObjectAttributes.SecurityDescriptor = NULL;
|
||||||
|
ObjectAttributes.SecurityQualityOfService = NULL;
|
||||||
|
|
||||||
|
if ( lpSemaphoreAttributes != NULL ) {
|
||||||
|
ObjectAttributes.SecurityDescriptor = lpSemaphoreAttributes->lpSecurityDescriptor;
|
||||||
|
if ( lpSemaphoreAttributes->bInheritHandle == TRUE )
|
||||||
|
ObjectAttributes.Attributes |= OBJ_INHERIT;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
errCode = NtCreateSemaphore(
|
||||||
|
&SemaphoreHandle,
|
||||||
|
GENERIC_ALL,
|
||||||
|
&ObjectAttributes,
|
||||||
|
lInitialCount,
|
||||||
|
lMaximumCount
|
||||||
|
);
|
||||||
|
if (!NT_SUCCESS(errCode))
|
||||||
|
{
|
||||||
|
SetLastError(RtlNtStatusToDosError(errCode));
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return SemaphoreHandle;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
HANDLE
|
||||||
|
STDCALL
|
||||||
|
CreateMutexA(
|
||||||
|
LPSECURITY_ATTRIBUTES lpMutexAttributes,
|
||||||
|
WINBOOL bInitialOwner,
|
||||||
|
LPCSTR lpName
|
||||||
|
)
|
||||||
|
{
|
||||||
|
WCHAR NameW[MAX_PATH];
|
||||||
|
ULONG i = 0;
|
||||||
|
|
||||||
|
while ((*lpName)!=0 && i < MAX_PATH)
|
||||||
|
{
|
||||||
|
NameW[i] = *lpName;
|
||||||
|
lpName++;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
NameW[i] = 0;
|
||||||
|
|
||||||
|
return CreateMutexW(
|
||||||
|
lpMutexAttributes,
|
||||||
|
bInitialOwner,
|
||||||
|
NameW
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
HANDLE
|
||||||
|
STDCALL
|
||||||
|
CreateMutexW(
|
||||||
|
LPSECURITY_ATTRIBUTES lpMutexAttributes,
|
||||||
|
WINBOOL bInitialOwner,
|
||||||
|
LPCWSTR lpName
|
||||||
|
)
|
||||||
|
{
|
||||||
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||||
|
NTSTATUS errCode;
|
||||||
|
UNICODE_STRING NameString;
|
||||||
|
HANDLE MutantHandle;
|
||||||
|
|
||||||
|
NameString.Length = lstrlenW(lpName)*sizeof(WCHAR);
|
||||||
|
NameString.Buffer = (WCHAR *)lpName;
|
||||||
|
NameString.MaximumLength = NameString.Length;
|
||||||
|
|
||||||
|
ObjectAttributes.Length = sizeof(OBJECT_ATTRIBUTES);
|
||||||
|
ObjectAttributes.RootDirectory = NULL;
|
||||||
|
ObjectAttributes.ObjectName = &NameString;
|
||||||
|
ObjectAttributes.Attributes = OBJ_CASE_INSENSITIVE;
|
||||||
|
ObjectAttributes.SecurityDescriptor = NULL;
|
||||||
|
ObjectAttributes.SecurityQualityOfService = NULL;
|
||||||
|
|
||||||
|
if ( lpMutexAttributes != NULL ) {
|
||||||
|
ObjectAttributes.SecurityDescriptor = lpMutexAttributes->lpSecurityDescriptor;
|
||||||
|
if ( lpMutexAttributes->bInheritHandle == TRUE )
|
||||||
|
ObjectAttributes.Attributes |= OBJ_INHERIT;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
errCode = NtCreateMutant(&MutantHandle,GENERIC_ALL, &ObjectAttributes,(BOOLEAN)bInitialOwner);
|
||||||
|
if (!NT_SUCCESS(errCode))
|
||||||
|
{
|
||||||
|
SetLastError(RtlNtStatusToDosError(errCode));
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return MutantHandle;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
DWORD
|
||||||
|
STDCALL
|
||||||
|
WaitForSingleObject(
|
||||||
|
HANDLE hHandle,
|
||||||
|
DWORD dwMilliseconds
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return WaitForSingleObjectEx(hHandle,dwMilliseconds,FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD
|
||||||
|
STDCALL
|
||||||
|
WaitForSingleObjectEx(
|
||||||
|
HANDLE hHandle,
|
||||||
|
DWORD dwMilliseconds,
|
||||||
|
BOOL bAlertable
|
||||||
|
)
|
||||||
|
{
|
||||||
|
|
||||||
|
NTSTATUS errCode;
|
||||||
|
LARGE_INTEGER Time;
|
||||||
|
DWORD retCode;
|
||||||
|
|
||||||
|
SET_LARGE_INTEGER_LOW_PART(Time,dwMilliseconds);
|
||||||
|
|
||||||
|
errCode = NtWaitForSingleObject(
|
||||||
|
hHandle,
|
||||||
|
(BOOLEAN) bAlertable,
|
||||||
|
&Time
|
||||||
|
);
|
||||||
|
|
||||||
|
retCode = RtlNtStatusToDosError(errCode);
|
||||||
|
SetLastError(retCode);
|
||||||
|
return retCode;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD
|
||||||
|
STDCALL
|
||||||
|
WaitForMultipleObjects(
|
||||||
|
DWORD nCount,
|
||||||
|
CONST HANDLE * lpHandles,
|
||||||
|
BOOL bWaitAll,
|
||||||
|
DWORD dwMilliseconds
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return WaitForMultipleObjectsEx(nCount,lpHandles,bWaitAll,dwMilliseconds,FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD
|
||||||
|
STDCALL
|
||||||
|
WaitForMultipleObjectsEx(
|
||||||
|
DWORD nCount,
|
||||||
|
CONST HANDLE * lpHandles,
|
||||||
|
BOOL bWaitAll,
|
||||||
|
DWORD dwMilliseconds,
|
||||||
|
BOOL bAlertable
|
||||||
|
)
|
||||||
|
{
|
||||||
|
NTSTATUS errCode;
|
||||||
|
LARGE_INTEGER Time;
|
||||||
|
DWORD retCode;
|
||||||
|
|
||||||
|
SET_LARGE_INTEGER_LOW_PART(Time,dwMilliseconds);
|
||||||
|
|
||||||
|
|
||||||
|
errCode = NtWaitForMultipleObjects (
|
||||||
|
nCount,
|
||||||
|
(PHANDLE)lpHandles,
|
||||||
|
(CINT)bWaitAll,
|
||||||
|
(BOOLEAN)bAlertable,
|
||||||
|
&Time
|
||||||
|
);
|
||||||
|
|
||||||
|
retCode = RtlNtStatusToDosError(errCode);
|
||||||
|
SetLastError(retCode);
|
||||||
|
return retCode;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -1,27 +1,314 @@
|
||||||
|
|
||||||
/*
|
/*
|
||||||
author: Boudewijn Dekker
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
original source : wine
|
* PROJECT: ReactOS system libraries
|
||||||
todo: improve debug info
|
* FILE: lib/kernel32/thread/thread.c
|
||||||
|
* PURPOSE: Thread functions
|
||||||
|
* PROGRAMMER: Ariadne ( ariadne@xs4all.nl)
|
||||||
|
Tls functions are modified from WINE
|
||||||
|
* UPDATE HISTORY:
|
||||||
|
* Created 01/11/98
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <thread.h>
|
#include <windows.h>
|
||||||
|
#include <kernel32/thread.h>
|
||||||
|
#include <ddk/ntddk.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
|
||||||
WINBASEAPI BOOL WINAPI SwitchToThread(VOID )
|
HANDLE
|
||||||
|
STDCALL
|
||||||
|
CreateThread(
|
||||||
|
LPSECURITY_ATTRIBUTES lpThreadAttributes,
|
||||||
|
DWORD dwStackSize,
|
||||||
|
LPTHREAD_START_ROUTINE lpStartAddress,
|
||||||
|
LPVOID lpParameter,
|
||||||
|
DWORD dwCreationFlags,
|
||||||
|
LPDWORD lpThreadId
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return NtYieldExecution();
|
return CreateRemoteThread(NtCurrentProcess(),lpThreadAttributes,dwStackSize,
|
||||||
|
lpStartAddress,lpParameter,dwCreationFlags,lpThreadId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
HANDLE
|
||||||
|
STDCALL
|
||||||
|
CreateRemoteThread(
|
||||||
|
HANDLE hProcess,
|
||||||
|
LPSECURITY_ATTRIBUTES lpThreadAttributes,
|
||||||
|
DWORD dwStackSize,
|
||||||
|
LPTHREAD_START_ROUTINE lpStartAddress,
|
||||||
|
LPVOID lpParameter,
|
||||||
|
DWORD dwCreationFlags,
|
||||||
|
LPDWORD lpThreadId
|
||||||
|
)
|
||||||
|
{
|
||||||
|
NTSTATUS errCode;
|
||||||
|
HANDLE ThreadHandle;
|
||||||
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||||
|
CLIENT_ID ClientId;
|
||||||
|
CONTEXT ThreadContext;
|
||||||
|
INITIAL_TEB InitialTeb;
|
||||||
|
BOOLEAN CreateSuspended = FALSE;
|
||||||
|
|
||||||
|
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 )
|
||||||
|
CreateSuspended = TRUE;
|
||||||
|
else
|
||||||
|
CreateSuspended = FALSE;
|
||||||
|
// fix context
|
||||||
|
GetThreadContext(NtCurrentThread(),&ThreadContext);
|
||||||
|
// fix teb [ stack context ] --> check the image file
|
||||||
|
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
WINBOOL STDCALL
|
||||||
|
SwitchToThread(VOID )
|
||||||
|
{
|
||||||
|
NTSTATUS errCode;
|
||||||
|
errCode = NtYieldExecution();
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD
|
||||||
|
STDCALL
|
||||||
|
GetCurrentThreadId()
|
||||||
|
{
|
||||||
|
|
||||||
|
return (DWORD)(GetTeb()->Cid).UniqueThread;
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID
|
||||||
|
STDCALL
|
||||||
|
ExitThread(
|
||||||
|
UINT uExitCode
|
||||||
|
)
|
||||||
|
{
|
||||||
|
NTSTATUS errCode;
|
||||||
|
|
||||||
|
errCode = NtTerminateThread(
|
||||||
|
NtCurrentThread() ,
|
||||||
|
uExitCode
|
||||||
|
);
|
||||||
|
if ( !NT_SUCCESS(errCode) ) {
|
||||||
|
SetLastError(RtlNtStatusToDosError(errCode));
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
WINBOOL
|
||||||
|
STDCALL
|
||||||
|
GetThreadTimes(
|
||||||
|
HANDLE hThread,
|
||||||
|
LPFILETIME lpCreationTime,
|
||||||
|
LPFILETIME lpExitTime,
|
||||||
|
LPFILETIME lpKernelTime,
|
||||||
|
LPFILETIME lpUserTime
|
||||||
|
)
|
||||||
|
{
|
||||||
|
NTSTATUS errCode;
|
||||||
|
KERNEL_USER_TIMES KernelUserTimes;
|
||||||
|
ULONG ReturnLength;
|
||||||
|
errCode = NtQueryInformationThread(hThread,ThreadTimes,&KernelUserTimes,sizeof(KERNEL_USER_TIMES),&ReturnLength);
|
||||||
|
if ( !NT_SUCCESS(errCode) ) {
|
||||||
|
SetLastError(RtlNtStatusToDosError(errCode));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
memcpy(lpCreationTime, &KernelUserTimes.CreateTime, sizeof(FILETIME));
|
||||||
|
memcpy(lpExitTime, &KernelUserTimes.ExitTime, sizeof(FILETIME));
|
||||||
|
memcpy(lpKernelTime, &KernelUserTimes.KernelTime, sizeof(FILETIME));
|
||||||
|
memcpy(lpUserTime, &KernelUserTimes.UserTime, sizeof(FILETIME));
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
WINBOOL
|
||||||
|
STDCALL GetThreadContext(
|
||||||
|
HANDLE hThread,
|
||||||
|
LPCONTEXT lpContext
|
||||||
|
)
|
||||||
|
{
|
||||||
|
NTSTATUS errCode;
|
||||||
|
errCode = NtGetContextThread(hThread,lpContext);
|
||||||
|
if ( !NT_SUCCESS(errCode) ) {
|
||||||
|
SetLastError(RtlNtStatusToDosError(errCode));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
WINBOOL
|
||||||
|
STDCALL
|
||||||
|
SetThreadContext(
|
||||||
|
HANDLE hThread,
|
||||||
|
CONST CONTEXT *lpContext
|
||||||
|
)
|
||||||
|
{
|
||||||
|
NTSTATUS errCode;
|
||||||
|
|
||||||
|
errCode = NtSetContextThread(hThread,(void *)lpContext);
|
||||||
|
if (!NT_SUCCESS(errCode) ) {
|
||||||
|
SetLastError(RtlNtStatusToDosError(errCode));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
WINBOOL
|
||||||
|
STDCALL
|
||||||
|
GetExitCodeThread(
|
||||||
|
HANDLE hThread,
|
||||||
|
LPDWORD lpExitCode
|
||||||
|
)
|
||||||
|
{
|
||||||
|
NTSTATUS errCode;
|
||||||
|
THREAD_BASIC_INFORMATION ThreadBasic;
|
||||||
|
ULONG DataWritten;
|
||||||
|
errCode = NtQueryInformationThread(hThread,ThreadBasicInformation,&ThreadBasic,sizeof(THREAD_BASIC_INFORMATION),&DataWritten);
|
||||||
|
if ( !NT_SUCCESS(errCode) ) {
|
||||||
|
SetLastError(RtlNtStatusToDosError(errCode));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
memcpy( lpExitCode ,&ThreadBasic.ExitStatus,sizeof(DWORD));
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
DWORD
|
||||||
|
STDCALL
|
||||||
|
ResumeThread(
|
||||||
|
HANDLE hThread
|
||||||
|
)
|
||||||
|
{
|
||||||
|
NTSTATUS errCode;
|
||||||
|
ULONG PreviousResumeCount;
|
||||||
|
|
||||||
|
errCode = NtResumeThread(hThread,&PreviousResumeCount );
|
||||||
|
if ( !NT_SUCCESS(errCode) ) {
|
||||||
|
SetLastError(RtlNtStatusToDosError(errCode));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return PreviousResumeCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD
|
||||||
|
STDCALL
|
||||||
|
SuspendThread(
|
||||||
|
HANDLE hThread
|
||||||
|
)
|
||||||
|
{
|
||||||
|
NTSTATUS errCode;
|
||||||
|
ULONG PreviousSuspendCount;
|
||||||
|
|
||||||
|
errCode = NtSuspendThread(hThread,&PreviousSuspendCount );
|
||||||
|
if ( !NT_SUCCESS(errCode) ) {
|
||||||
|
SetLastError(RtlNtStatusToDosError(errCode));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return PreviousSuspendCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
DWORD
|
||||||
|
STDCALL
|
||||||
|
SetThreadAffinityMask(
|
||||||
|
HANDLE hThread,
|
||||||
|
DWORD dwThreadAffinityMask
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
WINBOOL
|
||||||
|
STDCALL
|
||||||
|
SetThreadPriority(
|
||||||
|
HANDLE hThread,
|
||||||
|
int nPriority
|
||||||
|
)
|
||||||
|
{
|
||||||
|
NTSTATUS errCode;
|
||||||
|
THREAD_BASIC_INFORMATION ThreadBasic;
|
||||||
|
ULONG DataWritten;
|
||||||
|
errCode = NtQueryInformationThread(hThread,ThreadBasicInformation,&ThreadBasic,sizeof(THREAD_BASIC_INFORMATION),&DataWritten);
|
||||||
|
if ( !NT_SUCCESS(errCode) ) {
|
||||||
|
SetLastError(RtlNtStatusToDosError(errCode));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
ThreadBasic.BasePriority = nPriority;
|
||||||
|
errCode = NtSetInformationThread(hThread,ThreadBasicInformation,&ThreadBasic,sizeof(THREAD_BASIC_INFORMATION));
|
||||||
|
if ( !NT_SUCCESS(errCode) ) {
|
||||||
|
SetLastError(RtlNtStatusToDosError(errCode));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
STDCALL
|
||||||
|
GetThreadPriority(
|
||||||
|
HANDLE hThread
|
||||||
|
)
|
||||||
|
{
|
||||||
|
NTSTATUS errCode;
|
||||||
|
THREAD_BASIC_INFORMATION ThreadBasic;
|
||||||
|
ULONG DataWritten;
|
||||||
|
errCode = NtQueryInformationThread(hThread,ThreadBasicInformation,&ThreadBasic,sizeof(THREAD_BASIC_INFORMATION),&DataWritten);
|
||||||
|
if ( !NT_SUCCESS(errCode) ) {
|
||||||
|
SetLastError(RtlNtStatusToDosError(errCode));
|
||||||
|
return THREAD_PRIORITY_ERROR_RETURN;
|
||||||
|
}
|
||||||
|
return ThreadBasic.BasePriority;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* (WIN32) Thread Local Storage ******************************************** */
|
/* (WIN32) Thread Local Storage ******************************************** */
|
||||||
|
|
||||||
DWORD WINAPI
|
DWORD STDCALL
|
||||||
TlsAlloc(VOID)
|
TlsAlloc(VOID)
|
||||||
{
|
{
|
||||||
DWORD dwTlsIndex = GetTeb()->dwTlsIndex;
|
DWORD dwTlsIndex = GetTeb()->dwTlsIndex;
|
||||||
|
|
||||||
|
|
||||||
void **TlsData = GetTeb()->TlsData;
|
void **TlsData = GetTeb()->TlsData;
|
||||||
|
|
||||||
APISTR((LF_API, "TlsAlloc: (API)\n"));
|
|
||||||
if (dwTlsIndex < sizeof(TlsData) / sizeof(TlsData[0]))
|
if (dwTlsIndex < sizeof(TlsData) / sizeof(TlsData[0]))
|
||||||
{
|
{
|
||||||
TlsData[dwTlsIndex] = NULL;
|
TlsData[dwTlsIndex] = NULL;
|
||||||
|
@ -30,45 +317,42 @@ TlsAlloc(VOID)
|
||||||
return (0xFFFFFFFFUL);
|
return (0xFFFFFFFFUL);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL WINAPI
|
WINBOOL STDCALL
|
||||||
TlsFree(DWORD dwTlsIndex)
|
TlsFree(DWORD dwTlsIndex)
|
||||||
{
|
{
|
||||||
APISTR((LF_APISTUB, "TlsFree(DWORD=%ld)\n", dwTlsIndex));
|
|
||||||
return (TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
LPVOID WINAPI
|
LPVOID STDCALL
|
||||||
TlsGetValue(DWORD dwTlsIndex)
|
TlsGetValue(DWORD dwTlsIndex)
|
||||||
{
|
{
|
||||||
|
|
||||||
DWORD dwTlsIndex = GetTeb()->dwTlsIndex;
|
|
||||||
void **TlsData = GetTeb()->TlsData;
|
void **TlsData = GetTeb()->TlsData;
|
||||||
|
|
||||||
APISTR((LF_API, "TlsGetValue: (API) dwTlsIndex %ld\n", dwTlsIndex));
|
|
||||||
if (dwTlsIndex < sizeof(TlsData) / sizeof(TlsData[0]))
|
if (dwTlsIndex < sizeof(TlsData) / sizeof(TlsData[0]))
|
||||||
{
|
{
|
||||||
LOGSTR((LF_LOG, "TlsGetValue: (LOG) [%ld] = %p\n",
|
|
||||||
dwTlsIndex, TlsData[dwTlsIndex]));
|
|
||||||
SetLastError(NO_ERROR);
|
SetLastError(NO_ERROR);
|
||||||
return (TlsData[dwTlsIndex]);
|
return (TlsData[dwTlsIndex]);
|
||||||
}
|
}
|
||||||
SetLastErrorEx(1, 0);
|
SetLastError(1);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL WINAPI
|
WINBOOL STDCALL
|
||||||
TlsSetValue(DWORD dwTlsIndex, LPVOID lpTlsValue)
|
TlsSetValue(DWORD dwTlsIndex, LPVOID lpTlsValue)
|
||||||
{
|
{
|
||||||
|
|
||||||
DWORD dwTlsIndex = GetTeb()->dwTlsIndex;
|
|
||||||
void **TlsData = GetTeb()->TlsData;
|
void **TlsData = GetTeb()->TlsData;
|
||||||
|
|
||||||
APISTR((LF_API, "TlsSetValue: (API) dwTlsIndex %ld lpTlsValue %p\n",
|
|
||||||
dwTlsIndex, lpTlsValue));
|
|
||||||
if (dwTlsIndex < sizeof(TlsData) / sizeof(TlsData[0]))
|
if (dwTlsIndex < sizeof(TlsData) / sizeof(TlsData[0]))
|
||||||
{
|
{
|
||||||
LOGSTR((LF_LOG, "TlsSetValue: (LOG) [%ld] = %p\n",
|
|
||||||
dwTlsIndex, lpTlsValue));
|
|
||||||
TlsData[dwTlsIndex] = lpTlsValue;
|
TlsData[dwTlsIndex] = lpTlsValue;
|
||||||
return (TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -384,6 +384,7 @@ last_addr dw 0
|
||||||
; Generic error message
|
; Generic error message
|
||||||
;
|
;
|
||||||
err_msg db 'Error during operation',0
|
err_msg db 'Error during operation',0
|
||||||
|
rostitle db '',0
|
||||||
|
|
||||||
;
|
;
|
||||||
;
|
;
|
||||||
|
@ -453,6 +454,50 @@ _to_pmode:
|
||||||
;
|
;
|
||||||
; Save cursor position
|
; Save cursor position
|
||||||
;
|
;
|
||||||
|
mov ax,3 ;! Reset video mode
|
||||||
|
int 10h
|
||||||
|
|
||||||
|
|
||||||
|
mov bl,10
|
||||||
|
mov ah,12
|
||||||
|
int 10h
|
||||||
|
|
||||||
|
mov ax,1112h ;! Use 8x8 font
|
||||||
|
xor bl,bl
|
||||||
|
int 10h
|
||||||
|
mov ax,1200h ;! Use alternate print screen
|
||||||
|
mov bl,20h
|
||||||
|
int 10h
|
||||||
|
mov ah,1h ;! Define cursor (scan lines 6 to 7)
|
||||||
|
mov cx,0607h
|
||||||
|
int 10h
|
||||||
|
|
||||||
|
mov ah,1
|
||||||
|
mov cx,0600h
|
||||||
|
int 10h
|
||||||
|
|
||||||
|
MOV AH,6 ;SCROLL ACTIVE PAGE UP
|
||||||
|
MOV AL,32H ;CLEAR 25 LINES
|
||||||
|
MOV CX,0H ;UPPER LEFT OF SCROLL
|
||||||
|
MOV DX,314FH ;LOWER RIGHT OF SCROLL
|
||||||
|
MOV BH,1*10h+1 ;USE NORMAL ATTRIBUTE ON BLANKED LINE
|
||||||
|
INT 10H ;VIDEO-IO
|
||||||
|
|
||||||
|
|
||||||
|
mov dx,0
|
||||||
|
mov dh,0
|
||||||
|
|
||||||
|
mov ah,02h
|
||||||
|
mov bh,0
|
||||||
|
int 10h
|
||||||
|
|
||||||
|
mov dx,0
|
||||||
|
mov dh,0
|
||||||
|
|
||||||
|
mov ah,02h
|
||||||
|
mov bh,0
|
||||||
|
int 010h
|
||||||
|
|
||||||
mov ah,03h
|
mov ah,03h
|
||||||
mov bh,0h
|
mov bh,0h
|
||||||
int 010h
|
int 010h
|
||||||
|
@ -461,7 +506,6 @@ _to_pmode:
|
||||||
movzx eax,dh
|
movzx eax,dh
|
||||||
mov [_cursory],eax
|
mov [_cursory],eax
|
||||||
|
|
||||||
|
|
||||||
mov bx,ds
|
mov bx,ds
|
||||||
movzx eax,bx
|
movzx eax,bx
|
||||||
shl eax,4
|
shl eax,4
|
||||||
|
|
|
@ -132,7 +132,7 @@ VOID Hal_bios32_probe()
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
DbgPrint("BIOS32 detected at %x\n",i);
|
DbgPrint("ReactOS: BIOS32 detected at %x\n",i);
|
||||||
bios32_indirect.address = service_entry->entry;
|
bios32_indirect.address = service_entry->entry;
|
||||||
bios32_detected=TRUE;
|
bios32_detected=TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,10 +66,12 @@ static unsigned int cursorx=0, cursory=0;
|
||||||
|
|
||||||
static unsigned int lines_seen = 0;
|
static unsigned int lines_seen = 0;
|
||||||
|
|
||||||
#define NR_ROWS 25
|
//#define NR_ROWS 25
|
||||||
|
#define NR_ROWS 50
|
||||||
#define NR_COLUMNS 80
|
#define NR_COLUMNS 80
|
||||||
#define VIDMEM_BASE 0xb8000
|
#define VIDMEM_BASE 0xb8000
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* PURPOSE: Points to the base of text mode video memory
|
* PURPOSE: Points to the base of text mode video memory
|
||||||
*/
|
*/
|
||||||
|
@ -189,7 +191,7 @@ static void putchar(char c)
|
||||||
|
|
||||||
default:
|
default:
|
||||||
vidmem[(cursorx*2) + (cursory*80*2)]=c;
|
vidmem[(cursorx*2) + (cursory*80*2)]=c;
|
||||||
vidmem[(cursorx*2) + (cursory*80*2)+1]=0x7;
|
vidmem[(cursorx*2) + (cursory*80*2)+1]=0x17;
|
||||||
cursorx++;
|
cursorx++;
|
||||||
if (cursorx>=NR_COLUMNS)
|
if (cursorx>=NR_COLUMNS)
|
||||||
{
|
{
|
||||||
|
@ -208,7 +210,7 @@ static void putchar(char c)
|
||||||
for (i=0;str[i]!=0;i++)
|
for (i=0;str[i]!=0;i++)
|
||||||
{
|
{
|
||||||
vidmem[NR_COLUMNS*(NR_ROWS-1)*2+i*2]=str[i];
|
vidmem[NR_COLUMNS*(NR_ROWS-1)*2+i*2]=str[i];
|
||||||
vidmem[NR_COLUMNS*(NR_ROWS-1)*2+i*2+1]=0x7;
|
vidmem[NR_COLUMNS*(NR_ROWS-1)*2+i*2+1]=0x37; // 17 for white on blue 37
|
||||||
}
|
}
|
||||||
|
|
||||||
while (inb_p(0x60)!=0x81);
|
while (inb_p(0x60)!=0x81);
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* FILE: ntoskrnl/ke/bug.c
|
* FILE: ntoskrnl/ke/iocomp.c
|
||||||
* PURPOSE: Graceful system shutdown if a bug is detected
|
* PURPOSE:
|
||||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
* PROGRAMMER: David Welch (welch@mcmail.com)
|
||||||
* UPDATE HISTORY:
|
* UPDATE HISTORY:
|
||||||
* Created 22/05/98
|
* Created 22/05/98
|
||||||
|
Changed NtQueryIoCompletion
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* INCLUDES *****************************************************************/
|
/* INCLUDES *****************************************************************/
|
||||||
|
@ -58,10 +59,30 @@ ZwOpenIoCompletion(
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS STDCALL NtQueryIoCompletion(VOID)
|
NTSTATUS
|
||||||
|
STDCALL
|
||||||
|
NtQueryIoCompletion(
|
||||||
|
IN HANDLE CompletionPort,
|
||||||
|
IN ULONG CompletionKey,
|
||||||
|
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||||
|
OUT PULONG NumberOfBytesTransferred
|
||||||
|
)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
return ZwQueryIoCompletion(CompletionPort,CompletionKey,IoStatusBlock,NumberOfBytesTransferred);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
STDCALL
|
||||||
|
ZwQueryIoCompletion(
|
||||||
|
IN HANDLE CompletionPort,
|
||||||
|
IN ULONG CompletionKey,
|
||||||
|
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||||
|
OUT PULONG NumberOfBytesTransferred
|
||||||
|
)
|
||||||
|
{
|
||||||
|
}
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
STDCALL
|
STDCALL
|
||||||
NtRemoveIoCompletion(
|
NtRemoveIoCompletion(
|
||||||
|
@ -69,7 +90,7 @@ NtRemoveIoCompletion(
|
||||||
OUT PULONG CompletionKey,
|
OUT PULONG CompletionKey,
|
||||||
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||||
OUT PULONG CompletionStatus,
|
OUT PULONG CompletionStatus,
|
||||||
ULONG WaitTime
|
PLARGE_INTEGER WaitTime
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -81,7 +102,7 @@ ZwRemoveIoCompletion(
|
||||||
OUT PULONG CompletionKey,
|
OUT PULONG CompletionKey,
|
||||||
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||||
OUT PULONG CompletionStatus,
|
OUT PULONG CompletionStatus,
|
||||||
ULONG WaitTime
|
PLARGE_INTEGER WaitTime
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,8 +55,8 @@ NTSTATUS STDCALL ZwLockFile(IN HANDLE FileHandle,
|
||||||
|
|
||||||
NTSTATUS STDCALL NtUnlockFile(IN HANDLE FileHandle,
|
NTSTATUS STDCALL NtUnlockFile(IN HANDLE FileHandle,
|
||||||
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||||
IN LARGE_INTEGER ByteOffset,
|
IN PLARGE_INTEGER ByteOffset,
|
||||||
IN LARGE_INTEGER Length,
|
IN PLARGE_INTEGER Length,
|
||||||
OUT PULONG Key OPTIONAL)
|
OUT PULONG Key OPTIONAL)
|
||||||
{
|
{
|
||||||
return(ZwUnlockFile(FileHandle,
|
return(ZwUnlockFile(FileHandle,
|
||||||
|
@ -68,8 +68,8 @@ NTSTATUS STDCALL NtUnlockFile(IN HANDLE FileHandle,
|
||||||
|
|
||||||
NTSTATUS STDCALL ZwUnlockFile(IN HANDLE FileHandle,
|
NTSTATUS STDCALL ZwUnlockFile(IN HANDLE FileHandle,
|
||||||
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||||
IN LARGE_INTEGER ByteOffset,
|
IN PLARGE_INTEGER ByteOffset,
|
||||||
IN LARGE_INTEGER Length,
|
IN PLARGE_INTEGER Length,
|
||||||
OUT PULONG Key OPTIONAL)
|
OUT PULONG Key OPTIONAL)
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED;
|
UNIMPLEMENTED;
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
* PROGRAMMER: David Welch (welch@mcmail.com)
|
||||||
* UPDATE HISTORY:
|
* UPDATE HISTORY:
|
||||||
* Created 22/05/98
|
* Created 22/05/98
|
||||||
|
Changed NtCreateMailslotFile
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* INCLUDES *****************************************************************/
|
/* INCLUDES *****************************************************************/
|
||||||
|
@ -16,6 +17,32 @@
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
NTSTATUS STDCALL NtCreateMailslotFile(VOID)
|
NTSTATUS
|
||||||
|
STDCALL
|
||||||
|
NtCreateMailslotFile(
|
||||||
|
OUT PHANDLE MailSlotFileHandle,
|
||||||
|
IN ACCESS_MASK DesiredAccess,
|
||||||
|
IN POBJECT_ATTRIBUTES ObjectAttributes,
|
||||||
|
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||||
|
IN ULONG FileAttributes,
|
||||||
|
IN ULONG ShareAccess,
|
||||||
|
IN ULONG MaxMessageSize,
|
||||||
|
IN PLARGE_INTEGER TimeOut
|
||||||
|
)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
STDCALL
|
||||||
|
ZwCreateMailslotFile(
|
||||||
|
OUT PHANDLE MailSlotFileHandle,
|
||||||
|
IN ACCESS_MASK DesiredAccess,
|
||||||
|
IN POBJECT_ATTRIBUTES ObjectAttributes,
|
||||||
|
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||||
|
IN ULONG FileAttributes,
|
||||||
|
IN ULONG ShareAccess,
|
||||||
|
IN ULONG MaxMessageSize,
|
||||||
|
IN PLARGE_INTEGER TimeOut
|
||||||
|
)
|
||||||
{
|
{
|
||||||
}
|
}
|
|
@ -16,6 +16,44 @@
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
NTSTATUS STDCALL NtCreateNamedPipeFile(VOID)
|
NTSTATUS
|
||||||
|
STDCALL
|
||||||
|
NtCreateNamedPipeFile(
|
||||||
|
OUT PHANDLE NamedPipeFileHandle,
|
||||||
|
IN ACCESS_MASK DesiredAccess,
|
||||||
|
IN POBJECT_ATTRIBUTES ObjectAttributes,
|
||||||
|
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||||
|
IN ULONG FileAttributes,
|
||||||
|
IN ULONG ShareAccess,
|
||||||
|
IN ULONG OpenMode,
|
||||||
|
IN ULONG PipeType,
|
||||||
|
IN ULONG PipeRead,
|
||||||
|
IN ULONG PipeWait,
|
||||||
|
IN ULONG MaxInstances,
|
||||||
|
IN ULONG InBufferSize,
|
||||||
|
IN ULONG OutBufferSize,
|
||||||
|
IN PLARGE_INTEGER TimeOut
|
||||||
|
)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
STDCALL
|
||||||
|
ZwCreateNamedPipeFile(
|
||||||
|
OUT PHANDLE NamedPipeFileHandle,
|
||||||
|
IN ACCESS_MASK DesiredAccess,
|
||||||
|
IN POBJECT_ATTRIBUTES ObjectAttributes,
|
||||||
|
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||||
|
IN ULONG FileAttributes,
|
||||||
|
IN ULONG ShareAccess,
|
||||||
|
IN ULONG OpenMode,
|
||||||
|
IN ULONG PipeType,
|
||||||
|
IN ULONG PipeRead,
|
||||||
|
IN ULONG PipeWait,
|
||||||
|
IN ULONG MaxInstances,
|
||||||
|
IN ULONG InBufferSize,
|
||||||
|
IN ULONG OutBufferSize,
|
||||||
|
IN PLARGE_INTEGER TimeOut
|
||||||
|
)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,7 +93,7 @@ NTSTATUS STDCALL NtQueryVolumeInformationFile(
|
||||||
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||||
OUT PVOID FSInformation,
|
OUT PVOID FSInformation,
|
||||||
IN ULONG Length,
|
IN ULONG Length,
|
||||||
IN CINT FSInformationClass)
|
IN FS_INFORMATION_CLASS FSInformationClass)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* FUNCTION: Queries the volume information
|
* FUNCTION: Queries the volume information
|
||||||
|
@ -129,7 +129,7 @@ ZwQueryVolumeInformationFile(
|
||||||
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||||
OUT PVOID FSInformation,
|
OUT PVOID FSInformation,
|
||||||
IN ULONG Length,
|
IN ULONG Length,
|
||||||
IN CINT FSInformationClass)
|
IN FS_INFORMATION_CLASS FSInformationClass)
|
||||||
{
|
{
|
||||||
PFILE_OBJECT FileObject;
|
PFILE_OBJECT FileObject;
|
||||||
PDEVICE_OBJECT DeviceObject;
|
PDEVICE_OBJECT DeviceObject;
|
||||||
|
|
|
@ -50,6 +50,10 @@ NTSTATUS STDCALL NtRaiseHardError(VOID)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS STDCALL NtSetDefaultHardErrorPort(VOID)
|
NTSTATUS
|
||||||
|
STDCALL
|
||||||
|
NtSetDefaultHardErrorPort(
|
||||||
|
IN HANDLE PortHandle
|
||||||
|
)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -197,7 +197,7 @@ VOID KeInitializeDispatcher(VOID)
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS STDCALL NtWaitForMultipleObjects (IN ULONG Count,
|
NTSTATUS STDCALL NtWaitForMultipleObjects (IN ULONG Count,
|
||||||
IN PHANDLE Object[],
|
IN HANDLE Object[],
|
||||||
IN CINT WaitType,
|
IN CINT WaitType,
|
||||||
IN BOOLEAN Alertable,
|
IN BOOLEAN Alertable,
|
||||||
IN PLARGE_INTEGER Time)
|
IN PLARGE_INTEGER Time)
|
||||||
|
@ -210,7 +210,7 @@ NTSTATUS STDCALL NtWaitForMultipleObjects (IN ULONG Count,
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS STDCALL ZwWaitForMultipleObjects (IN ULONG Count,
|
NTSTATUS STDCALL ZwWaitForMultipleObjects (IN ULONG Count,
|
||||||
IN PHANDLE Object[],
|
IN HANDLE Object[],
|
||||||
IN CINT WaitType,
|
IN CINT WaitType,
|
||||||
IN BOOLEAN Alertable,
|
IN BOOLEAN Alertable,
|
||||||
IN PLARGE_INTEGER Time)
|
IN PLARGE_INTEGER Time)
|
||||||
|
@ -218,7 +218,7 @@ NTSTATUS STDCALL ZwWaitForMultipleObjects (IN ULONG Count,
|
||||||
UNIMPLEMENTED;
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS STDCALL NtWaitForSingleObject (IN PHANDLE Object,
|
NTSTATUS STDCALL NtWaitForSingleObject (IN HANDLE Object,
|
||||||
IN BOOLEAN Alertable,
|
IN BOOLEAN Alertable,
|
||||||
IN PLARGE_INTEGER Time)
|
IN PLARGE_INTEGER Time)
|
||||||
{
|
{
|
||||||
|
@ -227,7 +227,7 @@ NTSTATUS STDCALL NtWaitForSingleObject (IN PHANDLE Object,
|
||||||
Time));
|
Time));
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS STDCALL ZwWaitForSingleObject (IN PHANDLE Object,
|
NTSTATUS STDCALL ZwWaitForSingleObject (IN HANDLE Object,
|
||||||
IN BOOLEAN Alertable,
|
IN BOOLEAN Alertable,
|
||||||
IN PLARGE_INTEGER Time)
|
IN PLARGE_INTEGER Time)
|
||||||
{
|
{
|
||||||
|
|
|
@ -247,12 +247,16 @@ BOOLEAN MmIsAddressValid(PVOID VirtualAddress)
|
||||||
return(TRUE);
|
return(TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS STDCALL NtAllocateVirtualMemory(IN HANDLE ProcessHandle,
|
NTSTATUS
|
||||||
OUT PVOID *BaseAddress,
|
STDCALL
|
||||||
|
NtAllocateVirtualMemory(
|
||||||
|
IN HANDLE ProcessHandle,
|
||||||
|
IN OUT PVOID *BaseAddress,
|
||||||
IN ULONG ZeroBits,
|
IN ULONG ZeroBits,
|
||||||
IN ULONG RegionSize,
|
IN OUT PULONG RegionSize,
|
||||||
IN ULONG AllocationType,
|
IN ULONG AllocationType,
|
||||||
IN ULONG Protect)
|
IN ULONG Protect
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return(ZwAllocateVirtualMemory(ProcessHandle,
|
return(ZwAllocateVirtualMemory(ProcessHandle,
|
||||||
BaseAddress,
|
BaseAddress,
|
||||||
|
@ -262,12 +266,16 @@ NTSTATUS STDCALL NtAllocateVirtualMemory(IN HANDLE ProcessHandle,
|
||||||
Protect));
|
Protect));
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS STDCALL ZwAllocateVirtualMemory(IN HANDLE ProcessHandle,
|
NTSTATUS
|
||||||
OUT PVOID *BaseAddress,
|
STDCALL
|
||||||
|
ZwAllocateVirtualMemory(
|
||||||
|
IN HANDLE ProcessHandle,
|
||||||
|
IN OUT PVOID *BaseAddress,
|
||||||
IN ULONG ZeroBits,
|
IN ULONG ZeroBits,
|
||||||
IN ULONG RegionSize,
|
IN OUT PULONG RegionSize,
|
||||||
IN ULONG AllocationType,
|
IN ULONG AllocationType,
|
||||||
IN ULONG Protect)
|
IN ULONG Protect
|
||||||
|
)
|
||||||
/*
|
/*
|
||||||
* FUNCTION: Allocates a block of virtual memory in the process address space
|
* FUNCTION: Allocates a block of virtual memory in the process address space
|
||||||
* ARGUMENTS:
|
* ARGUMENTS:
|
||||||
|
@ -300,7 +308,6 @@ NTSTATUS STDCALL ZwAllocateVirtualMemory(IN HANDLE ProcessHandle,
|
||||||
PEPROCESS Process;
|
PEPROCESS Process;
|
||||||
MEMORY_AREA* MemoryArea;
|
MEMORY_AREA* MemoryArea;
|
||||||
ULONG Type;
|
ULONG Type;
|
||||||
ULONG i;
|
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
DbgPrint("ZwAllocateVirtualMemory(ProcessHandle %x, *BaseAddress %x, "
|
DbgPrint("ZwAllocateVirtualMemory(ProcessHandle %x, *BaseAddress %x, "
|
||||||
|
@ -336,7 +343,7 @@ NTSTATUS STDCALL ZwAllocateVirtualMemory(IN HANDLE ProcessHandle,
|
||||||
if (MemoryArea != NULL)
|
if (MemoryArea != NULL)
|
||||||
{
|
{
|
||||||
if (MemoryArea->BaseAddress == (*BaseAddress) &&
|
if (MemoryArea->BaseAddress == (*BaseAddress) &&
|
||||||
MemoryArea->Length == RegionSize)
|
MemoryArea->Length == *RegionSize)
|
||||||
{
|
{
|
||||||
MemoryArea->Type = Type;
|
MemoryArea->Type = Type;
|
||||||
MemoryArea->Attributes =Protect;
|
MemoryArea->Attributes =Protect;
|
||||||
|
@ -347,7 +354,7 @@ NTSTATUS STDCALL ZwAllocateVirtualMemory(IN HANDLE ProcessHandle,
|
||||||
MemoryArea = MmSplitMemoryArea(Process,
|
MemoryArea = MmSplitMemoryArea(Process,
|
||||||
MemoryArea,
|
MemoryArea,
|
||||||
*BaseAddress,
|
*BaseAddress,
|
||||||
RegionSize,
|
*RegionSize,
|
||||||
Type,
|
Type,
|
||||||
Protect);
|
Protect);
|
||||||
DbgPrint("*BaseAddress %x\n",*BaseAddress);
|
DbgPrint("*BaseAddress %x\n",*BaseAddress);
|
||||||
|
@ -355,11 +362,14 @@ NTSTATUS STDCALL ZwAllocateVirtualMemory(IN HANDLE ProcessHandle,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//FIXME RegionSize should be passed as pointer
|
||||||
|
|
||||||
|
|
||||||
Status = MmCreateMemoryArea(UserMode,
|
Status = MmCreateMemoryArea(UserMode,
|
||||||
Process,
|
Process,
|
||||||
Type,
|
Type,
|
||||||
(PULONG)BaseAddress,
|
BaseAddress,
|
||||||
RegionSize,
|
*RegionSize,
|
||||||
Protect,
|
Protect,
|
||||||
&MemoryArea);
|
&MemoryArea);
|
||||||
|
|
||||||
|
@ -406,7 +416,7 @@ NTSTATUS STDCALL ZwFlushVirtualMemory(IN HANDLE ProcessHandle,
|
||||||
|
|
||||||
NTSTATUS STDCALL NtFreeVirtualMemory(IN HANDLE ProcessHandle,
|
NTSTATUS STDCALL NtFreeVirtualMemory(IN HANDLE ProcessHandle,
|
||||||
IN PVOID *BaseAddress,
|
IN PVOID *BaseAddress,
|
||||||
IN ULONG RegionSize,
|
IN PULONG RegionSize,
|
||||||
IN ULONG FreeType)
|
IN ULONG FreeType)
|
||||||
{
|
{
|
||||||
return(ZwFreeVirtualMemory(ProcessHandle,
|
return(ZwFreeVirtualMemory(ProcessHandle,
|
||||||
|
@ -417,7 +427,7 @@ NTSTATUS STDCALL NtFreeVirtualMemory(IN HANDLE ProcessHandle,
|
||||||
|
|
||||||
NTSTATUS STDCALL ZwFreeVirtualMemory(IN HANDLE ProcessHandle,
|
NTSTATUS STDCALL ZwFreeVirtualMemory(IN HANDLE ProcessHandle,
|
||||||
IN PVOID *BaseAddress,
|
IN PVOID *BaseAddress,
|
||||||
IN ULONG RegionSize,
|
IN PULONG RegionSize,
|
||||||
IN ULONG FreeType)
|
IN ULONG FreeType)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
STDCALL
|
STDCALL
|
||||||
NtCreateEventPair(
|
NtCreateEventPair(
|
||||||
OUT PHANDLE FileHandle,
|
OUT PHANDLE EventPairHandle,
|
||||||
IN ACCESS_MASK DesiredAccess,
|
IN ACCESS_MASK DesiredAccess,
|
||||||
IN POBJECT_ATTRIBUTES ObjectAttributes
|
IN POBJECT_ATTRIBUTES ObjectAttributes
|
||||||
)
|
)
|
||||||
|
@ -29,7 +29,7 @@ NtCreateEventPair(
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
STDCALL
|
STDCALL
|
||||||
ZwCreateEventPair(
|
ZwCreateEventPair(
|
||||||
OUT PHANDLE FileHandle,
|
OUT PHANDLE EventPairHandle,
|
||||||
IN ACCESS_MASK DesiredAccess,
|
IN ACCESS_MASK DesiredAccess,
|
||||||
IN POBJECT_ATTRIBUTES ObjectAttributes
|
IN POBJECT_ATTRIBUTES ObjectAttributes
|
||||||
)
|
)
|
||||||
|
@ -40,7 +40,7 @@ ZwCreateEventPair(
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
STDCALL
|
STDCALL
|
||||||
NtSetHighEventPair(
|
NtSetHighEventPair(
|
||||||
IN HANDLE EventPair
|
IN HANDLE EventPairHandle
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ NtSetHighEventPair(
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
STDCALL
|
STDCALL
|
||||||
ZwSetHighEventPair(
|
ZwSetHighEventPair(
|
||||||
IN HANDLE EventPair
|
IN HANDLE EventPairHandle
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ ZwSetHighEventPair(
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
STDCALL
|
STDCALL
|
||||||
NtSetHighWaitLowEventPair(
|
NtSetHighWaitLowEventPair(
|
||||||
IN HANDLE EventPair
|
IN HANDLE EventPairHandle
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ NtSetHighWaitLowEventPair(
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
STDCALL
|
STDCALL
|
||||||
ZwSetHighWaitLowEventPair(
|
ZwSetHighWaitLowEventPair(
|
||||||
IN HANDLE EventPair
|
IN HANDLE EventPairHandle
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ ZwSetHighWaitLowEventPair(
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
STDCALL
|
STDCALL
|
||||||
NtSetLowEventPair(
|
NtSetLowEventPair(
|
||||||
HANDLE EventPair
|
HANDLE EventPairHandle
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,7 @@ NtSetLowEventPair(
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
STDCALL
|
STDCALL
|
||||||
ZwSetLowEventPair(
|
ZwSetLowEventPair(
|
||||||
HANDLE EventPair
|
HANDLE EventPairHandle
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -90,7 +90,7 @@ ZwSetLowEventPair(
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
STDCALL
|
STDCALL
|
||||||
NtSetLowWaitHighEventPair(
|
NtSetLowWaitHighEventPair(
|
||||||
HANDLE EventPair
|
HANDLE EventPairHandle
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,7 @@ NtSetLowWaitHighEventPair(
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
STDCALL
|
STDCALL
|
||||||
ZwSetLowWaitHighEventPair(
|
ZwSetLowWaitHighEventPair(
|
||||||
HANDLE EventPair
|
HANDLE EventPairHandle
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -106,7 +106,7 @@ ZwSetLowWaitHighEventPair(
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
STDCALL
|
STDCALL
|
||||||
NtWaitLowEventPair(
|
NtWaitLowEventPair(
|
||||||
IN HANDLE EventHandle
|
IN HANDLE EventPairHandle
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -114,15 +114,43 @@ NtWaitLowEventPair(
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
STDCALL
|
STDCALL
|
||||||
ZwWaitLowEventPair(
|
ZwWaitLowEventPair(
|
||||||
IN HANDLE EventHandle
|
IN HANDLE EventPairHandle
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS STDCALL NtOpenEventPair(VOID)
|
NTSTATUS
|
||||||
|
STDCALL
|
||||||
|
NtOpenEventPair(
|
||||||
|
OUT PHANDLE EventPairHandle,
|
||||||
|
IN ACCESS_MASK DesiredAccess,
|
||||||
|
IN POBJECT_ATTRIBUTES ObjectAttributes
|
||||||
|
)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS STDCALL NtWaitHighEventPair(VOID)
|
NTSTATUS
|
||||||
|
STDCALL
|
||||||
|
ZwOpenEventPair(
|
||||||
|
OUT PHANDLE EventPairHandle,
|
||||||
|
IN ACCESS_MASK DesiredAccess,
|
||||||
|
IN POBJECT_ATTRIBUTES ObjectAttributes
|
||||||
|
)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
STDCALL
|
||||||
|
NtWaitHighEventPair(
|
||||||
|
IN HANDLE EventPairHandle
|
||||||
|
)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
STDCALL
|
||||||
|
ZwWaitHighEventPair(
|
||||||
|
IN HANDLE EventPairHandle
|
||||||
|
)
|
||||||
{
|
{
|
||||||
}
|
}
|
|
@ -21,7 +21,7 @@ STDCALL
|
||||||
NtCreateMutant(
|
NtCreateMutant(
|
||||||
OUT PHANDLE MutantHandle,
|
OUT PHANDLE MutantHandle,
|
||||||
IN ACCESS_MASK DesiredAccess,
|
IN ACCESS_MASK DesiredAccess,
|
||||||
IN OBJECT_ATTRIBUTES ObjectAttributes,
|
IN POBJECT_ATTRIBUTES ObjectAttributes,
|
||||||
IN BOOLEAN InitialOwner
|
IN BOOLEAN InitialOwner
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
@ -32,7 +32,7 @@ STDCALL
|
||||||
ZwCreateMutant(
|
ZwCreateMutant(
|
||||||
OUT PHANDLE MutantHandle,
|
OUT PHANDLE MutantHandle,
|
||||||
IN ACCESS_MASK DesiredAccess,
|
IN ACCESS_MASK DesiredAccess,
|
||||||
IN OBJECT_ATTRIBUTES ObjectAttributes,
|
IN POBJECT_ATTRIBUTES ObjectAttributes,
|
||||||
IN BOOLEAN InitialOwner
|
IN BOOLEAN InitialOwner
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* FILE: ntoskrnl/ke/bug.c
|
* FILE: ntoskrnl/nt/Profile.c
|
||||||
* PURPOSE: Graceful system shutdown if a bug is detected
|
* PURPOSE:
|
||||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
* PROGRAMMER:
|
||||||
* UPDATE HISTORY:
|
* UPDATE HISTORY:
|
||||||
* Created 22/05/98
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* INCLUDES *****************************************************************/
|
/* INCLUDES *****************************************************************/
|
||||||
|
@ -16,22 +16,52 @@
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
NTSTATUS STDCALL NtCreateProfile(VOID)
|
NTSTATUS
|
||||||
|
STDCALL
|
||||||
|
NtCreateProfile(
|
||||||
|
OUT PHANDLE ProfileHandle,
|
||||||
|
IN POBJECT_ATTRIBUTES ObjectAttributes,
|
||||||
|
IN ULONG ImageBase,
|
||||||
|
IN ULONG ImageSize,
|
||||||
|
IN ULONG Granularity,
|
||||||
|
OUT PVOID Buffer,
|
||||||
|
IN ULONG ProfilingSize,
|
||||||
|
IN ULONG ClockSource,
|
||||||
|
IN ULONG ProcessorMask
|
||||||
|
)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS STDCALL NtQueryIntervalProfile(VOID)
|
NTSTATUS
|
||||||
|
STDCALL
|
||||||
|
NtQueryIntervalProfile(
|
||||||
|
OUT PULONG Interval,
|
||||||
|
OUT PULONG ClockSource
|
||||||
|
)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS STDCALL NtSetIntervalProfile(VOID)
|
NTSTATUS
|
||||||
|
STDCALL
|
||||||
|
NtSetIntervalProfile(
|
||||||
|
IN ULONG Interval,
|
||||||
|
IN ULONG ClockSource
|
||||||
|
)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS STDCALL NtStartProfile(VOID)
|
NTSTATUS
|
||||||
|
STDCALL
|
||||||
|
NtStartProfile(
|
||||||
|
IN HANDLE ProfileHandle
|
||||||
|
)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS STDCALL NtStopProfile(VOID)
|
NTSTATUS
|
||||||
|
STDCALL
|
||||||
|
NtStopProfile(
|
||||||
|
IN HANDLE ProfileHandle
|
||||||
|
)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,7 @@ wchar_t* wcsrchr(const wchar_t* str, wchar_t ch)
|
||||||
{
|
{
|
||||||
if (str[len-1]==ch)
|
if (str[len-1]==ch)
|
||||||
{
|
{
|
||||||
return(&str[len-1]);
|
return((wchar_t*)&str[len-1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return(NULL);
|
return(NULL);
|
||||||
|
@ -92,23 +92,41 @@ wchar_t * wcscpy(wchar_t * str1,const wchar_t * str2)
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return( (*str1) - (*str2) );
|
return(wchar_t *)( (*str1) - (*str2) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
unsigned long wstrlen(PWSTR s)
|
unsigned long wstrlen(PWSTR s)
|
||||||
{
|
{
|
||||||
WCHAR c=' ';
|
return wcslen(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef __MACHINE_STRING_FUNCTIONS
|
||||||
|
|
||||||
|
size_t wcslen(const wchar_t * s)
|
||||||
|
{
|
||||||
|
|
||||||
unsigned int len=0;
|
unsigned int len=0;
|
||||||
|
|
||||||
while(c!=0) {
|
while(s[len]!=0) {
|
||||||
c=*s;
|
|
||||||
s++;
|
|
||||||
len++;
|
len++;
|
||||||
};
|
};
|
||||||
s-=len;
|
return len;
|
||||||
|
|
||||||
return len-1;
|
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
size_t wcslen(const wchar_t * s)
|
||||||
|
{
|
||||||
|
register int __res;
|
||||||
|
__asm__ __volatile__(
|
||||||
|
"cld\n\t"
|
||||||
|
"repne\n\t"
|
||||||
|
"scasw\n\t"
|
||||||
|
"notl %0\n\t"
|
||||||
|
"decl %0"
|
||||||
|
:"=c" (__res):"D" (s),"a" (0),"0" (0xffffffff):"edi");
|
||||||
|
return __res;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
inline int wcscmp(const wchar_t* cs,const wchar_t * ct)
|
inline int wcscmp(const wchar_t* cs,const wchar_t * ct)
|
||||||
{
|
{
|
||||||
|
@ -129,6 +147,64 @@ __asm__ __volatile__(
|
||||||
return __res;
|
return __res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int wcsicmp(const wchar_t* cs,const wchar_t * ct)
|
||||||
|
{
|
||||||
|
register int __res;
|
||||||
|
|
||||||
|
|
||||||
|
__asm__ __volatile__(
|
||||||
|
"cld\n"
|
||||||
|
"1:\tmovw (%%esi), %%eax\n\t"
|
||||||
|
"movw (%%edi), %%edx \n\t"
|
||||||
|
"cmpw $0x5A, %%eax\n\t"
|
||||||
|
"ja 2f\t\n"
|
||||||
|
"cmpw $0x40, %%eax\t\n"
|
||||||
|
"jbe 2f\t\n"
|
||||||
|
"addw $0x20, %%eax\t\n"
|
||||||
|
"2:\t cmpw $0x5A, %%edx\t\n"
|
||||||
|
"ja 3f\t\n"
|
||||||
|
"cmpw $0x40, %%edx\t\n"
|
||||||
|
"jbe 3f\t\n"
|
||||||
|
"addw $0x20, %%edx\t\n"
|
||||||
|
"3:\t inc %%esi\t\n"
|
||||||
|
"inc %%esi\t\n"
|
||||||
|
"inc %%edi\t\n"
|
||||||
|
"inc %%edi\t\n"
|
||||||
|
"cmpw %%eax, %%edx\t\n"
|
||||||
|
"jne 4f\n\t"
|
||||||
|
"cmpw $00, %%eax\n\t"
|
||||||
|
"jne 1b\n\t"
|
||||||
|
"xorl %%eax,%%eax\n\t"
|
||||||
|
"jmp 5f\n"
|
||||||
|
"4:\tsbbl %%eax,%%eax\n\t"
|
||||||
|
"orw $1,%%eax\n"
|
||||||
|
"5:"
|
||||||
|
:"=a" (__res):"S" (cs),"D" (ct):"esi","edi");
|
||||||
|
|
||||||
|
return __res;
|
||||||
|
}
|
||||||
|
|
||||||
|
wchar_t * wcscat(wchar_t * dest,const wchar_t * src)
|
||||||
|
{
|
||||||
|
__asm__ __volatile__(
|
||||||
|
"cld\n\t"
|
||||||
|
"repnz\n\t"
|
||||||
|
"scasw\n\t"
|
||||||
|
"decl %1\n"
|
||||||
|
"decl %1\n\t"
|
||||||
|
"1:\tlodsw\n\t"
|
||||||
|
"stosw\n\t"
|
||||||
|
"testw %%eax,%%eax\n\t"
|
||||||
|
"jne 1b"
|
||||||
|
: // no output
|
||||||
|
:"S" (src),"D" (dest),"a" (0),"c" (0xffffffff):"esi","edi","eax","ecx");
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __MACHINE_STRING_FUNCTIONS
|
#ifdef __MACHINE_STRING_FUNCTIONS
|
||||||
/*
|
/*
|
||||||
* Include machine specific inline routines
|
* Include machine specific inline routines
|
||||||
|
@ -196,7 +272,7 @@ __asm__ __volatile__(
|
||||||
:"S" (src),"D" (dest),"c" (count):"esi","edi","eax","ecx","memory");
|
:"S" (src),"D" (dest),"c" (count):"esi","edi","eax","ecx","memory");
|
||||||
return dest;
|
return dest;
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
#define __HAVE_ARCH_WCSCAT
|
#define __HAVE_ARCH_WCSCAT
|
||||||
inline wchar_t * wcscat(wchar_t * dest,const wchar_t * src)
|
inline wchar_t * wcscat(wchar_t * dest,const wchar_t * src)
|
||||||
{
|
{
|
||||||
|
@ -210,11 +286,11 @@ __asm__ __volatile__(
|
||||||
"stosw\n\t"
|
"stosw\n\t"
|
||||||
"testw %%eax,%%eax\n\t"
|
"testw %%eax,%%eax\n\t"
|
||||||
"jne 1b"
|
"jne 1b"
|
||||||
: /* no output */
|
: // no output
|
||||||
:"S" (src),"D" (dest),"a" (0),"c" (0xffffffff):"esi","edi","eax","ecx");
|
:"S" (src),"D" (dest),"a" (0),"c" (0xffffffff):"esi","edi","eax","ecx");
|
||||||
return dest;
|
return dest;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
#define __HAVE_ARCH_WCSNCAT
|
#define __HAVE_ARCH_WCSNCAT
|
||||||
inline wchar_t * wcsncat(wchar_t * dest,const wchar_t * src,size_t count)
|
inline wchar_t * wcsncat(wchar_t * dest,const wchar_t * src,size_t count)
|
||||||
{
|
{
|
||||||
|
@ -410,7 +486,7 @@ __asm__ __volatile__(
|
||||||
return __res;
|
return __res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
#define __HAVE_ARCH_WCSLEN
|
#define __HAVE_ARCH_WCSLEN
|
||||||
inline size_t wcslen(const wchar_t * s)
|
inline size_t wcslen(const wchar_t * s)
|
||||||
{
|
{
|
||||||
|
@ -425,7 +501,7 @@ __asm__ __volatile__(
|
||||||
return __res;
|
return __res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
#define __HAVE_ARCH_WCSTOK
|
#define __HAVE_ARCH_WCSTOK
|
||||||
|
|
||||||
|
@ -499,7 +575,7 @@ return __res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#define __HAVE_ARCH_WCSNNLEN
|
#define __HAVE_ARCH_WCSNLEN
|
||||||
inline size_t wcsnlen(const wchar_t * s, size_t count)
|
inline size_t wcsnlen(const wchar_t * s, size_t count)
|
||||||
{
|
{
|
||||||
register int __res;
|
register int __res;
|
||||||
|
@ -520,7 +596,7 @@ return __res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
#define __HAVE_ARCH_WCSICMP
|
#define __HAVE_ARCH_WCSICMP
|
||||||
inline int wcsicmp(const wchar_t* cs,const wchar_t * ct)
|
inline int wcsicmp(const wchar_t* cs,const wchar_t * ct)
|
||||||
{
|
{
|
||||||
|
@ -559,7 +635,7 @@ __asm__ __volatile__(
|
||||||
return __res;
|
return __res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
#define __HAVE_ARCH_WCSNICMP
|
#define __HAVE_ARCH_WCSNICMP
|
||||||
inline int wcsnicmp(const wchar_t* cs,const wchar_t * ct, size_t count)
|
inline int wcsnicmp(const wchar_t* cs,const wchar_t * ct, size_t count)
|
||||||
{
|
{
|
||||||
|
|
|
@ -16,55 +16,149 @@
|
||||||
|
|
||||||
/* FUNCTIONS ***************************************************************/
|
/* FUNCTIONS ***************************************************************/
|
||||||
|
|
||||||
NTSTATUS STDCALL NtQueryInformationToken(VOID)
|
NTSTATUS
|
||||||
|
STDCALL
|
||||||
|
NtQueryInformationToken(
|
||||||
|
IN HANDLE TokenHandle,
|
||||||
|
IN TOKEN_INFORMATION_CLASS TokenInformationClass,
|
||||||
|
OUT PVOID TokenInformation,
|
||||||
|
IN ULONG TokenInformationLength,
|
||||||
|
OUT PULONG ReturnLength
|
||||||
|
)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS STDCALL NtQuerySecurityObject(VOID)
|
NTSTATUS
|
||||||
|
STDCALL
|
||||||
|
NtQuerySecurityObject(
|
||||||
|
IN HANDLE Object,
|
||||||
|
IN CINT SecurityObjectInformationClass,
|
||||||
|
OUT PVOID SecurityObjectInformation,
|
||||||
|
IN ULONG Length,
|
||||||
|
OUT PULONG ReturnLength
|
||||||
|
)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS STDCALL NtSetSecurityObject(VOID)
|
NTSTATUS
|
||||||
|
STDCALL
|
||||||
|
NtSetSecurityObject(
|
||||||
|
IN HANDLE Handle,
|
||||||
|
IN SECURITY_INFORMATION SecurityInformation,
|
||||||
|
IN PSECURITY_DESCRIPTOR SecurityDescriptor
|
||||||
|
)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS STDCALL NtSetInformationToken(VOID)
|
NTSTATUS
|
||||||
|
STDCALL
|
||||||
|
NtSetInformationToken(
|
||||||
|
IN HANDLE TokenHandle,
|
||||||
|
IN TOKEN_INFORMATION_CLASS TokenInformationClass,
|
||||||
|
OUT PVOID TokenInformation,
|
||||||
|
IN ULONG TokenInformationLength
|
||||||
|
)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS STDCALL NtPrivilegeCheck(VOID)
|
NTSTATUS
|
||||||
|
STDCALL
|
||||||
|
NtPrivilegeCheck(
|
||||||
|
IN HANDLE ClientToken,
|
||||||
|
IN PPRIVILEGE_SET RequiredPrivileges,
|
||||||
|
IN PBOOLEAN Result
|
||||||
|
)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS STDCALL NtPrivilegedServiceAuditAlarm(VOID)
|
NTSTATUS
|
||||||
|
STDCALL
|
||||||
|
NtPrivilegedServiceAuditAlarm(
|
||||||
|
IN PUNICODE_STRING SubsystemName,
|
||||||
|
IN PUNICODE_STRING ServiceName,
|
||||||
|
IN HANDLE ClientToken,
|
||||||
|
IN PPRIVILEGE_SET Privileges,
|
||||||
|
IN BOOLEAN AccessGranted
|
||||||
|
)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS STDCALL NtPrivilegeObjectAuditAlarm(VOID)
|
NTSTATUS
|
||||||
|
STDCALL
|
||||||
|
NtPrivilegeObjectAuditAlarm(
|
||||||
|
IN PUNICODE_STRING SubsystemName,
|
||||||
|
IN PVOID HandleId,
|
||||||
|
IN HANDLE ClientToken,
|
||||||
|
IN ULONG DesiredAccess,
|
||||||
|
IN PPRIVILEGE_SET Privileges,
|
||||||
|
IN BOOLEAN AccessGranted
|
||||||
|
)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS STDCALL NtOpenObjectAuditAlarm(VOID)
|
NTSTATUS
|
||||||
|
STDCALL
|
||||||
|
NtOpenObjectAuditAlarm(
|
||||||
|
IN PUNICODE_STRING SubsystemName,
|
||||||
|
IN PVOID HandleId,
|
||||||
|
IN POBJECT_ATTRIBUTES ObjectAttributes,
|
||||||
|
IN HANDLE ClientToken,
|
||||||
|
IN ULONG DesiredAccess,
|
||||||
|
IN ULONG GrantedAccess,
|
||||||
|
IN PPRIVILEGE_SET Privileges,
|
||||||
|
IN BOOLEAN ObjectCreation,
|
||||||
|
IN BOOLEAN AccessGranted,
|
||||||
|
OUT PBOOLEAN GenerateOnClose
|
||||||
|
)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS STDCALL NtOpenProcessToken(VOID)
|
NTSTATUS
|
||||||
|
STDCALL
|
||||||
|
NtOpenProcessToken(
|
||||||
|
IN HANDLE ProcessHandle,
|
||||||
|
IN ACCESS_MASK DesiredAccess,
|
||||||
|
OUT PHANDLE TokenHandle
|
||||||
|
)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS STDCALL NtOpenThreadToken(VOID)
|
NTSTATUS
|
||||||
|
STDCALL
|
||||||
|
NtOpenThreadToken(
|
||||||
|
IN HANDLE ThreadHandle,
|
||||||
|
IN ACCESS_MASK DesiredAccess,
|
||||||
|
IN BOOLEAN OpenAsSelf,
|
||||||
|
OUT PHANDLE TokenHandle
|
||||||
|
)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS STDCALL NtDuplicateToken(VOID)
|
NTSTATUS
|
||||||
|
STDCALL
|
||||||
|
NtDuplicateToken(
|
||||||
|
IN HANDLE ExistingToken,
|
||||||
|
IN ACCESS_MASK DesiredAccess,
|
||||||
|
IN POBJECT_ATTRIBUTES ObjectAttributes,
|
||||||
|
IN SECURITY_IMPERSONATION_LEVEL ImpersonationLevel,
|
||||||
|
IN TOKEN_TYPE TokenType,
|
||||||
|
OUT PHANDLE NewToken
|
||||||
|
)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS STDCALL NtImpersonateClientOfPort(VOID)
|
NTSTATUS STDCALL NtImpersonateClientOfPort(VOID)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS STDCALL NtImpersonateThread(VOID)
|
NTSTATUS
|
||||||
|
STDCALL
|
||||||
|
NtImpersonateThread(
|
||||||
|
IN HANDLE ThreadHandle,
|
||||||
|
IN HANDLE ThreadToImpersonate,
|
||||||
|
IN PSECURITY_QUALITY_OF_SERVICE SecurityQualityOfService
|
||||||
|
)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,7 +166,13 @@ NTSTATUS STDCALL NtCreateToken(VOID)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS STDCALL NtDeleteObjectAuditAlarm(VOID)
|
NTSTATUS
|
||||||
|
STDCALL
|
||||||
|
NtDeleteObjectAuditAlarm (
|
||||||
|
IN PUNICODE_STRING SubsystemName,
|
||||||
|
IN PVOID HandleId,
|
||||||
|
IN BOOLEAN GenerateOnClose
|
||||||
|
)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,7 +180,7 @@ NTSTATUS STDCALL NtDeleteObjectAuditAlarm(VOID)
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
STDCALL
|
STDCALL
|
||||||
NtAllocateLocallyUniqueId(
|
NtAllocateLocallyUniqueId(
|
||||||
OUT PVOID LocallyUniqueId
|
OUT LUID *LocallyUniqueId
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -88,28 +188,92 @@ NtAllocateLocallyUniqueId(
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
STDCALL
|
STDCALL
|
||||||
ZwAllocateLocallyUniqueId(
|
ZwAllocateLocallyUniqueId(
|
||||||
OUT PVOID LocallyUniqueId
|
OUT LUID *LocallyUniqueId
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS STDCALL NtAccessCheckAndAuditAlarm(VOID)
|
NTSTATUS
|
||||||
|
STDCALL
|
||||||
|
NtAccessCheckAndAuditAlarm(
|
||||||
|
IN PUNICODE_STRING SubsystemName,
|
||||||
|
IN PHANDLE ObjectHandle,
|
||||||
|
IN POBJECT_ATTRIBUTES ObjectAttributes,
|
||||||
|
IN ACCESS_MASK DesiredAccess,
|
||||||
|
IN PGENERIC_MAPPING GenericMapping,
|
||||||
|
IN BOOLEAN ObjectCreation,
|
||||||
|
OUT PULONG GrantedAccess,
|
||||||
|
OUT PBOOLEAN AccessStatus,
|
||||||
|
OUT PBOOLEAN GenerateOnClose
|
||||||
|
)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS STDCALL NtAdjustGroupsToken(VOID)
|
NTSTATUS
|
||||||
|
STDCALL
|
||||||
|
NtAdjustGroupsToken(
|
||||||
|
IN HANDLE TokenHandle,
|
||||||
|
IN BOOLEAN ResetToDefault,
|
||||||
|
IN PTOKEN_GROUPS NewState,
|
||||||
|
IN ULONG BufferLength,
|
||||||
|
OUT PTOKEN_GROUPS PreviousState OPTIONAL,
|
||||||
|
OUT PULONG ReturnLength
|
||||||
|
)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS STDCALL NtAdjustPrivilegesToken(VOID)
|
NTSTATUS
|
||||||
|
STDCALL
|
||||||
|
NtAdjustPrivilegesToken(
|
||||||
|
IN HANDLE TokenHandle,
|
||||||
|
IN BOOLEAN DisableAllPrivileges,
|
||||||
|
IN PTOKEN_PRIVILEGES NewState,
|
||||||
|
IN ULONG BufferLength,
|
||||||
|
OUT PTOKEN_PRIVILEGES PreviousState,
|
||||||
|
OUT PULONG ReturnLength
|
||||||
|
)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
NTSTATUS
|
||||||
|
STDCALL
|
||||||
|
ZwAdjustPrivilegesToken(
|
||||||
|
IN HANDLE TokenHandle,
|
||||||
|
IN BOOLEAN DisableAllPrivileges,
|
||||||
|
IN PTOKEN_PRIVILEGES NewState,
|
||||||
|
IN ULONG BufferLength,
|
||||||
|
OUT PTOKEN_PRIVILEGES PreviousState,
|
||||||
|
OUT PULONG ReturnLength
|
||||||
|
)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS STDCALL NtAllocateUuids(VOID)
|
NTSTATUS
|
||||||
|
STDCALL
|
||||||
|
NtAllocateUuids(
|
||||||
|
PLARGE_INTEGER Time,
|
||||||
|
PULONG Version, // ???
|
||||||
|
PULONG ClockCycle
|
||||||
|
)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS STDCALL NtCloseObjectAuditAlarm(VOID)
|
NTSTATUS
|
||||||
|
STDCALL
|
||||||
|
ZwAllocateUuids(
|
||||||
|
PLARGE_INTEGER Time,
|
||||||
|
PULONG Version, // ???
|
||||||
|
PULONG ClockCycle
|
||||||
|
)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
STDCALL
|
||||||
|
NtCloseObjectAuditAlarm(
|
||||||
|
IN PUNICODE_STRING SubsystemName,
|
||||||
|
IN PVOID HandleId,
|
||||||
|
IN BOOLEAN GenerateOnClose
|
||||||
|
)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,12 +282,12 @@ STDCALL
|
||||||
NtAccessCheck(
|
NtAccessCheck(
|
||||||
IN PSECURITY_DESCRIPTOR SecurityDescriptor,
|
IN PSECURITY_DESCRIPTOR SecurityDescriptor,
|
||||||
IN HANDLE ClientToken,
|
IN HANDLE ClientToken,
|
||||||
IN ULONG DesiredAcces,
|
IN ACCESS_MASK DesiredAcces,
|
||||||
IN PGENERIC_MAPPING GenericMapping,
|
IN PGENERIC_MAPPING GenericMapping,
|
||||||
OUT PRIVILEGE_SET PrivilegeSet,
|
OUT PRIVILEGE_SET PrivilegeSet,
|
||||||
OUT PULONG ReturnLength,
|
OUT PULONG ReturnLength,
|
||||||
OUT PULONG GrantedAccess,
|
OUT PULONG GrantedAccess,
|
||||||
OUT PULONG AccessStatus
|
OUT PBOOLEAN AccessStatus
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -133,12 +297,12 @@ STDCALL
|
||||||
ZwAccessCheck(
|
ZwAccessCheck(
|
||||||
IN PSECURITY_DESCRIPTOR SecurityDescriptor,
|
IN PSECURITY_DESCRIPTOR SecurityDescriptor,
|
||||||
IN HANDLE ClientToken,
|
IN HANDLE ClientToken,
|
||||||
IN ULONG DesiredAcces,
|
IN ACCESS_MASK DesiredAcces,
|
||||||
IN PGENERIC_MAPPING GenericMapping,
|
IN PGENERIC_MAPPING GenericMapping,
|
||||||
OUT PRIVILEGE_SET PrivilegeSet,
|
OUT PRIVILEGE_SET PrivilegeSet,
|
||||||
OUT PULONG ReturnLength,
|
OUT PULONG ReturnLength,
|
||||||
OUT PULONG GrantedAccess,
|
OUT PULONG GrantedAccess,
|
||||||
OUT PULONG AccessStatus
|
OUT PBOOLEAN AccessStatus
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue