- Some more PSDK compatibility fixes

- Misc cleanup...

svn path=/trunk/; revision=16792
This commit is contained in:
Alex Ionescu 2005-07-27 06:18:52 +00:00
parent b12a9db3c1
commit ad3464c9a6
10 changed files with 147 additions and 155 deletions

View file

@ -51,7 +51,7 @@ typedef long (__stdcall * _SEHFilter_t)
struct __SEHPortableFrame *
);
typedef __declspec(noreturn) void (__stdcall * _SEHHandler_t)
typedef void (__stdcall * _SEHHandler_t)
(
struct __SEHPortableTryLevel *
);

View file

@ -59,6 +59,9 @@
#define SYMBOLIC_LINK_QUERY 0x0001
#define SYMBOLIC_LINK_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 0x1)
/* Duplication Flags */
#define DUPLICATE_SAME_ATTRIBUTES 0x00000004
/* I/O Control Codes for communicating with Mailslots */
#define FSCTL_MAILSLOT_PEEK \
CTL_CODE(FILE_DEVICE_MAILSLOT, 0, METHOD_NEITHER, FILE_READ_DATA)

View file

@ -13,6 +13,7 @@
#include "lpctypes.h"
#include "zwtypes.h"
#include "kdtypes.h"
#define _WMIKM_
#include <evntrace.h>
/* FUNCTION TYPES ************************************************************/

View file

@ -1,118 +1,118 @@
#ifndef _HELPER_H
#define _HELPER_H
#define ROUNDUP(a,b) ((((a)+(b)-1)/(b))*(b))
#define ROUNDDOWN(a,b) (((a)/(b))*(b))
#define ROUND_UP ROUNDUP
#define ROUND_DOWN ROUNDDOWN
#define PAGE_ROUND_DOWN(x) (((ULONG)x)&(~(PAGE_SIZE-1)))
#define PAGE_ROUND_UP(x) ( (((ULONG)x)%PAGE_SIZE) ? ((((ULONG)x)&(~(PAGE_SIZE-1)))+PAGE_SIZE) : ((ULONG)x) )
#define ABS_VALUE(V) (((V) < 0) ? -(V) : (V))
#define RtlRosMin(X,Y) (((X) < (Y))? (X) : (Y))
#define RtlRosMin3(X,Y,Z) (((X) < (Y)) ? RtlRosMin(X,Z) : RtlRosMin(Y,Z))
#define KEBUGCHECKEX(a,b,c,d,e) DbgPrint("KeBugCheckEx at %s:%i\n",__FILE__,__LINE__), KeBugCheckEx(a,b,c,d,e)
#define KEBUGCHECK(a) DbgPrint("KeBugCheck at %s:%i\n",__FILE__,__LINE__), KeBugCheck(a)
#define EXPORTED __declspec(dllexport)
#define IMPORTED __declspec(dllimport)
#define LIST_FOR_EACH(entry, head) \
for(entry = (head)->Flink; entry != (head); entry = entry->Flink)
#define LIST_FOR_EACH_SAFE(tmp_entry, head, ptr, type, field) \
for ((tmp_entry)=(head)->Flink; (tmp_entry)!=(head) && \
((ptr) = CONTAINING_RECORD(tmp_entry,type,field)) && \
((tmp_entry) = (tmp_entry)->Flink); )
#define OPTHDROFFSET(a) ((LPVOID)((BYTE *)a + \
((PIMAGE_DOS_HEADER)a)->e_lfanew + \
sizeof (IMAGE_NT_SIGNATURE) + \
sizeof (IMAGE_FILE_HEADER)))
#define TAG(A, B, C, D) (ULONG)(((A)<<0) + ((B)<<8) + ((C)<<16) + ((D)<<24))
#define RVA(m, b) ((PVOID)((ULONG_PTR)(b) + (ULONG_PTR)(m)))
#define NTSTAT_SEVERITY_SHIFT 30
#define NTSTAT_SEVERITY_MASK 0x00000003
#define NTSTAT_FACILITY_SHIFT 16
#define NTSTAT_FACILITY_MASK 0x00000FFF
#define NTSTAT_CUSTOMER_MASK 0x20000000
#define NT_SEVERITY(StatCode) (((StatCode) >> NTSTAT_SEVERITY_SHIFT) & NTSTAT_SEVERITY_MASK)
#define NT_FACILITY(StatCode) (((StatCode) >> NTSTAT_FACILITY_SHIFT) & NTSTAT_FACILITY_MASK)
#define NT_CUSTOMER(StatCode) ((StatCode) & NTSTAT_CUSTOMER_MASK)
#define RELATIVE_TIME(wait) (-(wait))
#define NANOS_TO_100NS(nanos) (((LONGLONG)(nanos)) / 100)
#define MICROS_TO_100NS(micros) (((LONGLONG)(micros)) * NANOS_TO_100NS(1000))
#define MILLIS_TO_100NS(milli) (((LONGLONG)(milli)) * MICROS_TO_100NS(1000))
#define SECONDS_TO_100NS(seconds) (((LONGLONG)(seconds)) * MILLIS_TO_100NS(1000))
#define MINUTES_TO_100NS(minutes) (((LONGLONG)(minutes)) * SECONDS_TO_100NS(60))
#define HOURS_TO_100NS(hours) (((LONGLONG)(hours)) * MINUTES_TO_100NS(60))
#ifndef _HELPER_H
#define _HELPER_H
#define ROUNDUP(a,b) ((((a)+(b)-1)/(b))*(b))
#define ROUNDDOWN(a,b) (((a)/(b))*(b))
#define ROUND_UP ROUNDUP
#define ROUND_DOWN ROUNDDOWN
#define PAGE_ROUND_DOWN(x) (((ULONG)x)&(~(PAGE_SIZE-1)))
#define PAGE_ROUND_UP(x) ( (((ULONG)x)%PAGE_SIZE) ? ((((ULONG)x)&(~(PAGE_SIZE-1)))+PAGE_SIZE) : ((ULONG)x) )
#define ABS_VALUE(V) (((V) < 0) ? -(V) : (V))
#define RtlRosMin(X,Y) (((X) < (Y))? (X) : (Y))
#define RtlRosMin3(X,Y,Z) (((X) < (Y)) ? RtlRosMin(X,Z) : RtlRosMin(Y,Z))
#define KEBUGCHECKEX(a,b,c,d,e) DbgPrint("KeBugCheckEx at %s:%i\n",__FILE__,__LINE__), KeBugCheckEx(a,b,c,d,e)
#define KEBUGCHECK(a) DbgPrint("KeBugCheck at %s:%i\n",__FILE__,__LINE__), KeBugCheck(a)
#define EXPORTED __declspec(dllexport)
#define IMPORTED __declspec(dllimport)
#define LIST_FOR_EACH(entry, head) \
for(entry = (head)->Flink; entry != (head); entry = entry->Flink)
#define LIST_FOR_EACH_SAFE(tmp_entry, head, ptr, type, field) \
for ((tmp_entry)=(head)->Flink; (tmp_entry)!=(head) && \
((ptr) = CONTAINING_RECORD(tmp_entry,type,field)) && \
((tmp_entry) = (tmp_entry)->Flink); )
#define OPTHDROFFSET(a) ((LPVOID)((BYTE *)a + \
((PIMAGE_DOS_HEADER)a)->e_lfanew + \
sizeof (IMAGE_NT_SIGNATURE) + \
sizeof (IMAGE_FILE_HEADER)))
#define TAG(A, B, C, D) (ULONG)(((A)<<0) + ((B)<<8) + ((C)<<16) + ((D)<<24))
#define RVA(m, b) ((PVOID)((ULONG_PTR)(b) + (ULONG_PTR)(m)))
#define NTSTAT_SEVERITY_SHIFT 30
#define NTSTAT_SEVERITY_MASK 0x00000003
#define NTSTAT_FACILITY_SHIFT 16
#define NTSTAT_FACILITY_MASK 0x00000FFF
#define NTSTAT_CUSTOMER_MASK 0x20000000
#define NT_SEVERITY(StatCode) (((StatCode) >> NTSTAT_SEVERITY_SHIFT) & NTSTAT_SEVERITY_MASK)
#define NT_FACILITY(StatCode) (((StatCode) >> NTSTAT_FACILITY_SHIFT) & NTSTAT_FACILITY_MASK)
#define NT_CUSTOMER(StatCode) ((StatCode) & NTSTAT_CUSTOMER_MASK)
#define RELATIVE_TIME(wait) (-(wait))
#define NANOS_TO_100NS(nanos) (((LONGLONG)(nanos)) / 100)
#define MICROS_TO_100NS(micros) (((LONGLONG)(micros)) * NANOS_TO_100NS(1000))
#define MILLIS_TO_100NS(milli) (((LONGLONG)(milli)) * MICROS_TO_100NS(1000))
#define SECONDS_TO_100NS(seconds) (((LONGLONG)(seconds)) * MILLIS_TO_100NS(1000))
#define MINUTES_TO_100NS(minutes) (((LONGLONG)(minutes)) * SECONDS_TO_100NS(60))
#define HOURS_TO_100NS(hours) (((LONGLONG)(hours)) * MINUTES_TO_100NS(60))
#define UNICODIZE1(x) L##x
#define UNICODIZE(x) UNICODIZE1(x)
#define InsertAscendingListFIFO(ListHead, Type, ListEntryField, NewEntry, SortField)\
{\
PLIST_ENTRY current;\
\
current = (ListHead)->Flink;\
while (current != (ListHead))\
{\
if (CONTAINING_RECORD(current, Type, ListEntryField)->SortField >\
(NewEntry)->SortField)\
{\
break;\
}\
current = current->Flink;\
}\
\
InsertTailList(current, &((NewEntry)->ListEntryField));\
}
#define InsertDescendingListFIFO(ListHead, Type, ListEntryField, NewEntry, SortField)\
{\
PLIST_ENTRY current;\
\
current = (ListHead)->Flink;\
while (current != (ListHead))\
{\
if (CONTAINING_RECORD(current, Type, ListEntryField)->SortField <\
(NewEntry)->SortField)\
{\
break;\
}\
current = current->Flink;\
}\
\
InsertTailList(current, &((NewEntry)->ListEntryField));\
}
#define InsertAscendingList(ListHead, Type, ListEntryField, NewEntry, SortField)\
{\
PLIST_ENTRY current;\
\
current = (ListHead)->Flink;\
while (current != (ListHead))\
{\
if (CONTAINING_RECORD(current, Type, ListEntryField)->SortField >=\
(NewEntry)->SortField)\
{\
break;\
}\
current = current->Flink;\
}\
\
InsertTailList(current, &((NewEntry)->ListEntryField));\
}
#define InsertDescendingList(ListHead, Type, ListEntryField, NewEntry, SortField)\
{\
PLIST_ENTRY current;\
\
current = (ListHead)->Flink;\
while (current != (ListHead))\
{\
if (CONTAINING_RECORD(current, Type, ListEntryField)->SortField <=\
(NewEntry)->SortField)\
{\
break;\
}\
current = current->Flink;\
}\
\
InsertTailList(current, &((NewEntry)->ListEntryField));\
}
#endif
#define UNICODIZE(x) UNICODIZE1(x)
#define InsertAscendingListFIFO(ListHead, Type, ListEntryField, NewEntry, SortField)\
{\
PLIST_ENTRY current;\
\
current = (ListHead)->Flink;\
while (current != (ListHead))\
{\
if (CONTAINING_RECORD(current, Type, ListEntryField)->SortField >\
(NewEntry)->SortField)\
{\
break;\
}\
current = current->Flink;\
}\
\
InsertTailList(current, &((NewEntry)->ListEntryField));\
}
#define InsertDescendingListFIFO(ListHead, Type, ListEntryField, NewEntry, SortField)\
{\
PLIST_ENTRY current;\
\
current = (ListHead)->Flink;\
while (current != (ListHead))\
{\
if (CONTAINING_RECORD(current, Type, ListEntryField)->SortField <\
(NewEntry)->SortField)\
{\
break;\
}\
current = current->Flink;\
}\
\
InsertTailList(current, &((NewEntry)->ListEntryField));\
}
#define InsertAscendingList(ListHead, Type, ListEntryField, NewEntry, SortField)\
{\
PLIST_ENTRY current;\
\
current = (ListHead)->Flink;\
while (current != (ListHead))\
{\
if (CONTAINING_RECORD(current, Type, ListEntryField)->SortField >=\
(NewEntry)->SortField)\
{\
break;\
}\
current = current->Flink;\
}\
\
InsertTailList(current, &((NewEntry)->ListEntryField));\
}
#define InsertDescendingList(ListHead, Type, ListEntryField, NewEntry, SortField)\
{\
PLIST_ENTRY current;\
\
current = (ListHead)->Flink;\
while (current != (ListHead))\
{\
if (CONTAINING_RECORD(current, Type, ListEntryField)->SortField <=\
(NewEntry)->SortField)\
{\
break;\
}\
current = current->Flink;\
}\
\
InsertTailList(current, &((NewEntry)->ListEntryField));\
}
#endif

View file

@ -11,7 +11,6 @@
/* PSDK/NDK Headers */
#define NTOS_MODE_USER
#define _KERNEL32_
#define _WMIKM_
#include <windows.h>
#include <ndk/ntndk.h>

View file

@ -574,7 +574,7 @@ COMMDCB_PARAM_HANDLER(xon)
/* FUNCTIONS */
#define COMMDCB_PARAM(__P__) \
{ \
RTL_CONSTANT_STRING(L""#__P__ ), \
RTL_CONSTANT_STRING(L""UNICODIZE(#__P__ )), \
(ULONG_PTR)&COMMDCB_ ## __P__ ## Param \
}

View file

@ -12,7 +12,7 @@
#include <k32.h>
#define NDEBUG
#include <debug.h>
#include "../include/debug.h"
#define CMD_STRING L"cmd /c "
@ -648,9 +648,7 @@ CreateProcessA(LPCSTR lpApplicationName,
lpStartupInfo, lpProcessInformation);
/* Copy Startup Info */
DPRINT("Foo\n");
RtlMoveMemory(&StartupInfo, lpStartupInfo, sizeof(*lpStartupInfo));
DPRINT("Foo\n");
/* Initialize all strings to nothing */
LiveCommandLine.Buffer = NULL;
@ -664,26 +662,22 @@ CreateProcessA(LPCSTR lpApplicationName,
/* Convert the Command line */
if (lpCommandLine)
{
DPRINT("Foo\n");
/* If it's too long, then we'll have a problem */
if ((strlen(lpCommandLine) + 1) * sizeof(WCHAR) <
NtCurrentTeb()->StaticUnicodeString.MaximumLength)
{
/* Cache it in the TEB */
DPRINT("Foo\n");
CommandLine = Basep8BitStringToCachedUnicodeString(lpCommandLine);
}
else
{
/* Use a dynamic version */
DPRINT("Foo\n");
Basep8BitStringToLiveUnicodeString(&LiveCommandLine,
lpCommandLine);
}
}
else
{
DPRINT("Foo\n");
/* The logic below will use CommandLine, so we must make it valid */
CommandLine = &DummyString;
}
@ -691,13 +685,11 @@ CreateProcessA(LPCSTR lpApplicationName,
/* Convert the Name and Directory */
if (lpApplicationName)
{
DPRINT("Foo\n");
Basep8BitStringToLiveUnicodeString(&ApplicationName,
lpApplicationName);
}
if (lpCurrentDirectory)
{
DPRINT("Foo\n");
Basep8BitStringToLiveUnicodeString(&CurrentDirectory,
lpCurrentDirectory);
}
@ -705,19 +697,16 @@ CreateProcessA(LPCSTR lpApplicationName,
/* Now convert Startup Strings */
if (lpStartupInfo->lpReserved)
{
DPRINT("Foo\n");
BasepAnsiStringToHeapUnicodeString(lpStartupInfo->lpReserved,
&StartupInfo.lpReserved);
}
if (lpStartupInfo->lpDesktop)
{
DPRINT("Foo\n");
BasepAnsiStringToHeapUnicodeString(lpStartupInfo->lpDesktop,
&StartupInfo.lpDesktop);
}
if (lpStartupInfo->lpTitle)
{
DPRINT("Foo\n");
BasepAnsiStringToHeapUnicodeString(lpStartupInfo->lpTitle,
&StartupInfo.lpTitle);
}
@ -778,6 +767,11 @@ CreateProcessW(LPCWSTR lpApplicationName,
PROCESS_BASIC_INFORMATION ProcessBasicInfo;
STARTUPINFOW StartupInfo;
ULONG Dummy;
LPWSTR BatchCommandLine;
ULONG CmdLineLength;
UNICODE_STRING CommandLineString;
LPWSTR TempBuffer;
PWCHAR Extension;
LPWSTR QuotedCmdLine = NULL;
LPWSTR ScanString;
LPWSTR NullBuffer;
@ -811,7 +805,7 @@ CreateProcessW(LPCWSTR lpApplicationName,
}
/* Fail on this flag, it's only valid with the WithLogonW function */
if (dwCreationFlags & CREATE_WITH_USERPROFILE)
if (dwCreationFlags & CREATE_PRESERVE_CODE_AUTHZ_LEVEL)
{
DPRINT1("Invalid flag used\n");
SetLastError(ERROR_INVALID_PARAMETER);
@ -835,13 +829,13 @@ CreateProcessW(LPCWSTR lpApplicationName,
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
DPRINT("Foo\n");
/*
* We're going to modify and mask out flags and stuff in lpStartupInfo,
* so we'll use our own local copy for that.
*/
StartupInfo = *lpStartupInfo;
DPRINT("Foo\n");
/* FIXME: Use default Separate/Shared VDM Flag */
/* If we are inside a Job, use Separate VDM so it won't escape the Job */
@ -854,7 +848,7 @@ CreateProcessW(LPCWSTR lpApplicationName,
CREATE_SEPARATE_WOW_VDM;
}
}
DPRINT("Foo\n");
/*
* According to some sites, ShellExecuteEx uses an undocumented flag to
* send private handle data (such as HMONITOR or HICON). See:
@ -866,21 +860,21 @@ CreateProcessW(LPCWSTR lpApplicationName,
{
StartupInfo.dwFlags &= ~STARTF_USESTDHANDLES;
}
DPRINT("Foo\n");
/* Start by zeroing out the fields */
RtlZeroMemory(lpProcessInformation, sizeof(PROCESS_INFORMATION));
DPRINT("Foo\n");
/* Easy stuff first, convert the process priority class */
PriorityClass.Foreground = FALSE;
PriorityClass.PriorityClass = BasepConvertPriorityClass(dwCreationFlags);
DPRINT("Foo\n");
/* Convert the environment */
if(lpEnvironment && !(dwCreationFlags & CREATE_UNICODE_ENVIRONMENT))
{
lpEnvironment = BasepConvertUnicodeEnvironment(lpEnvironment);
if (!lpEnvironment) return FALSE;
}
DPRINT("Foo\n");
/* Get the application name and do all the proper formating necessary */
GetAppName:
/* See if we have an application name (oh please let us have one!) */
@ -907,7 +901,7 @@ GetAppName:
/* Advance past quote */
ScanString++;
lpApplicationName = ScanString;
DPRINT("Foo\n");
/* Find the closing quote */
while (*ScanString)
{
@ -918,7 +912,7 @@ GetAppName:
FoundQuotes = TRUE;
break;
}
DPRINT("Foo\n");
/* Keep looking */
ScanString++;
NullBuffer = ScanString;
@ -930,7 +924,7 @@ GetAppName:
WhiteScan:
/* Reset the pointer */
lpApplicationName = lpCommandLine;
DPRINT("Foo\n");
/* Find whitespace of Tab */
while (*ScanString)
{
@ -940,7 +934,7 @@ GetAppName:
NullBuffer = ScanString;
break;
}
DPRINT("Foo\n");
/* Keep looking */
ScanString++;
NullBuffer = ScanString;
@ -1078,8 +1072,8 @@ GetAppName:
case STATUS_INVALID_IMAGE_PROTECT:
case STATUS_INVALID_IMAGE_NOT_MZ:
/* If it's a DOS app, use VDM */
//if ((BasepCheckDosApp(&ApplicationName)))
/* If it's a DOS app, use VDM
if ((BasepCheckDosApp(&ApplicationName))) */
{
DPRINT1("Launching VDM...\n");
RtlFreeHeap(GetProcessHeap(), 0, NameBuffer);
@ -1097,12 +1091,8 @@ GetAppName:
}
/* It's a batch file */
LPWSTR BatchCommandLine;
ULONG CmdLineLength;
UNICODE_STRING CommandLineString;
LPWSTR TempBuffer;
PWCHAR Extension =
&ApplicationName.Buffer[ApplicationName.Length / sizeof(WCHAR) - 4];
Extension = &ApplicationName.Buffer[ApplicationName.Length /
sizeof(WCHAR) - 4];
/* Make sure the extensions are correct */
if (_wcsnicmp(Extension, L".bat", 4) && _wcsnicmp(Extension, L".cmd", 4))

View file

@ -68,7 +68,7 @@ void __stdcall _SEHLocalUnwind
}
}
__declspec(noreturn) void __cdecl _SEHCallHandler
void __cdecl _SEHCallHandler
(
_SEHPortableFrame_t * frame,
_SEHPortableTryLevel_t * trylevel

View file

@ -172,7 +172,7 @@ extern "C" {
#define BELOW_NORMAL_PRIORITY_CLASS 0x00004000
#define ABOVE_NORMAL_PRIORITY_CLASS 0x00008000
#define CREATE_BREAKAWAY_FROM_JOB 0x01000000
#define CREATE_WITH_USERPROFILE 0x02000000
#define CREATE_PRESERVE_CODE_AUTHZ_LEVEL 0x02000000
#define CREATE_DEFAULT_ERROR_MODE 0x04000000
#define CREATE_NO_WINDOW 0x08000000
#define PROFILE_USER 0x10000000

View file

@ -355,7 +355,6 @@ typedef DWORD FLONG;
/* also in ddk/winddk.h */
#define DUPLICATE_CLOSE_SOURCE 0x00000001
#define DUPLICATE_SAME_ACCESS 0x00000002
#define DUPLICATE_SAME_ATTRIBUTES 0x00000004
/* end winddk.k */
#define MAILSLOT_NO_MESSAGE ((DWORD)-1)