ReactOS  0.4.13-dev-99-g7e18b6d
kernel32.h File Reference
#include "wine/unicode.h"
#include "baseheap.h"
Include dependency graph for kernel32.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _CODEPAGE_ENTRY
 
struct  tagLOADPARMS32
 
struct  _BASEP_ACTCTX_BLOCK
 
struct  _BASEP_APPCERT_ENTRY
 
struct  _BASE_MSG_SXS_HANDLES
 
struct  _SXS_WIN32_NT_PATH_PAIR
 
struct  _SXS_OVERRIDE_MANIFEST
 

Macros

#define kernel32file   200
 
#define kernel32ver   201
 
#define actctx   202
 
#define resource   203
 
#define kernel32session   204
 
#define comm   205
 
#define profile   206
 
#define nls   207
 
#define DEBUG_CHANNEL(ch)
 
#define TRACE(fmt, ...)   TRACE__(gDebugChannel, fmt, ##__VA_ARGS__)
 
#define WARN(fmt, ...)   WARN__(gDebugChannel, fmt, ##__VA_ARGS__)
 
#define FIXME(fmt, ...)   WARN__(gDebugChannel, fmt,## __VA_ARGS__)
 
#define ERR(fmt, ...)   ERR__(gDebugChannel, fmt, ##__VA_ARGS__)
 
#define STUB
 
#define debugstr_a
 
#define debugstr_w
 
#define debugstr_wn
 
#define wine_dbgstr_w
 
#define debugstr_guid
 
#define MAGIC(c1, c2, c3, c4)   ((c1) + ((c2)<<8) + ((c3)<<16) + ((c4)<<24))
 
#define MAGIC_HEAP   MAGIC( 'H','E','A','P' )
 
#define ROUNDUP(a, b)   ((((a)+(b)-1)/(b))*(b))
 
#define ROUNDDOWN(a, b)   (((a)/(b))*(b))
 
#define ROUND_DOWN(n, align)   (((ULONG)n) & ~((align) - 1l))
 
#define ROUND_UP(n, align)   ROUND_DOWN(((ULONG)n) + (align) - 1, (align))
 
#define ARRAY_SIZE(a)   (sizeof(a)/sizeof((a)[0]))
 
#define __TRY   _SEH2_TRY
 
#define __EXCEPT_PAGE_FAULT   _SEH2_EXCEPT(_SEH2_GetExceptionCode() == STATUS_ACCESS_VIOLATION)
 
#define __ENDTRY   _SEH2_END
 
#define STARTF_SHELLPRIVATE   0x400
 
#define BASEP_GET_MODULE_HANDLE_EX_PARAMETER_VALIDATION_ERROR   1
 
#define BASEP_GET_MODULE_HANDLE_EX_PARAMETER_VALIDATION_SUCCESS   2
 
#define BASEP_GET_MODULE_HANDLE_EX_PARAMETER_VALIDATION_CONTINUE   3
 
#define BASEP_COPY_METADATA   0x10
 
#define BASEP_COPY_SACL   0x20
 
#define BASEP_COPY_OWNER_AND_GROUP   0x40
 
#define BASEP_COPY_DIRECTORY   0x80
 
#define BASEP_COPY_BACKUP_SEMANTICS   0x100
 
#define BASEP_COPY_REPLACE   0x200
 
#define BASEP_COPY_SKIP_DACL   0x400
 
#define BASEP_COPY_PUBLIC_MASK   0xF
 
#define BASEP_COPY_BASEP_MASK   0xFFFFFFF0
 
#define PRIV_DELETE_ON_SUCCESS   0x1
 
#define PRIV_ALLOW_NON_TRACKABLE   0x2
 
#define HeapAlloc   RtlAllocateHeap
 
#define HeapReAlloc   RtlReAllocateHeap
 
#define HeapFree   RtlFreeHeap
 
#define _lread(a, b, c)   (long)(_hread(a, b, (long)c))
 

Typedefs

typedef struct _CODEPAGE_ENTRY CODEPAGE_ENTRY
 
typedef struct _CODEPAGE_ENTRYPCODEPAGE_ENTRY
 
typedef struct tagLOADPARMS32 LOADPARMS32
 
typedef enum _BASE_SEARCH_PATH_TYPE BASE_SEARCH_PATH_TYPE
 
typedef enum _BASE_SEARCH_PATH_TYPEPBASE_SEARCH_PATH_TYPE
 
typedef enum _BASE_CURRENT_DIR_PLACEMENT BASE_CURRENT_DIR_PLACEMENT
 
typedef struct _BASEP_ACTCTX_BLOCK BASEP_ACTCTX_BLOCK
 
typedef struct _BASEP_ACTCTX_BLOCKPBASEP_ACTCTX_BLOCK
 
typedef DWORD(* WaitForInputIdleType) (HANDLE hProcess, DWORD dwMilliseconds)
 
typedef UINT(WINAPIPPROCESS_START_ROUTINE) (VOID)
 
typedef NTSTATUS(NTAPIPRTL_CONVERT_STRING) (IN PUNICODE_STRING UnicodeString, IN PANSI_STRING AnsiString, IN BOOLEAN AllocateMemory)
 
typedef ULONG(NTAPIPRTL_COUNT_STRING) (IN PUNICODE_STRING UnicodeString)
 
typedef NTSTATUS(NTAPIPRTL_CONVERT_STRINGA) (IN PANSI_STRING AnsiString, IN PCUNICODE_STRING UnicodeString, IN BOOLEAN AllocateMemory)
 
typedef ULONG(NTAPIPRTL_COUNT_STRINGA) (IN PANSI_STRING UnicodeString)
 
typedef NTSTATUS(NTAPIPBASEP_APPCERT_PLUGIN_FUNC) (IN LPWSTR ApplicationName, IN ULONG CertFlag)
 
typedef NTSTATUS(NTAPIPBASEP_APPCERT_EMBEDDED_FUNC) (IN LPWSTR ApplicationName)
 
typedef NTSTATUS(NTAPIPSAFER_REPLACE_PROCESS_THREAD_TOKENS) (IN HANDLE Token, IN HANDLE Process, IN HANDLE Thread)
 
typedef struct _BASEP_APPCERT_ENTRY BASEP_APPCERT_ENTRY
 
typedef struct _BASEP_APPCERT_ENTRYPBASEP_APPCERT_ENTRY
 
typedef struct _BASE_MSG_SXS_HANDLES BASE_MSG_SXS_HANDLES
 
typedef struct _BASE_MSG_SXS_HANDLESPBASE_MSG_SXS_HANDLES
 
typedef struct _SXS_WIN32_NT_PATH_PAIR SXS_WIN32_NT_PATH_PAIR
 
typedef struct _SXS_WIN32_NT_PATH_PAIRPSXS_WIN32_NT_PATH_PAIR
 
typedef struct _SXS_OVERRIDE_MANIFEST SXS_OVERRIDE_MANIFEST
 
typedef struct _SXS_OVERRIDE_MANIFESTPSXS_OVERRIDE_MANIFEST
 

Enumerations

enum  _BASE_SEARCH_PATH_TYPE {
  BaseSearchPathInvalid, BaseSearchPathDll, BaseSearchPathApp, BaseSearchPathDefault,
  BaseSearchPathEnv, BaseSearchPathCurrent, BaseSearchPathMax
}
 
enum  _BASE_CURRENT_DIR_PLACEMENT { BaseCurrentDirPlacementInvalid = -1, BaseCurrentDirPlacementDefault, BaseCurrentDirPlacementSafe, BaseCurrentDirPlacementMax }
 

Functions

VOID NTAPI BaseDllInitializeMemoryManager (VOID)
 
PTEB GetTeb (VOID)
 
PWCHAR FilenameA2W (LPCSTR NameA, BOOL alloc)
 
DWORD FilenameW2A_N (LPSTR dest, INT destlen, LPCWSTR src, INT srclen)
 
DWORD FilenameW2A_FitOrFail (LPSTR DestA, INT destLen, LPCWSTR SourceW, INT sourceLen)
 
DWORD FilenameU2A_FitOrFail (LPSTR DestA, INT destLen, PUNICODE_STRING SourceU)
 
PLARGE_INTEGER WINAPI BaseFormatTimeOut (OUT PLARGE_INTEGER Timeout, IN DWORD dwMilliseconds)
 
POBJECT_ATTRIBUTES WINAPI BaseFormatObjectAttributes (OUT POBJECT_ATTRIBUTES ObjectAttributes, IN PSECURITY_ATTRIBUTES SecurityAttributes OPTIONAL, IN PUNICODE_STRING ObjectName)
 
NTSTATUS WINAPI BaseCreateStack (HANDLE hProcess, SIZE_T StackReserve, SIZE_T StackCommit, PINITIAL_TEB InitialTeb)
 
VOID WINAPI BaseInitializeContext (IN PCONTEXT Context, IN PVOID Parameter, IN PVOID StartAddress, IN PVOID StackAddress, IN ULONG ContextType)
 
VOID WINAPI BaseThreadStartupThunk (VOID)
 
VOID WINAPI BaseProcessStartThunk (VOID)
 
VOID NTAPI BasepFreeActivationContextActivationBlock (IN PBASEP_ACTCTX_BLOCK ActivationBlock)
 
NTSTATUS NTAPI BasepAllocateActivationContextActivationBlock (IN DWORD Flags, IN PVOID CompletionRoutine, IN PVOID CompletionContext, OUT PBASEP_ACTCTX_BLOCK *ActivationBlock)
 
NTSTATUS NTAPI BasepProbeForDllManifest (IN PVOID DllHandle, IN PCWSTR FullDllName, OUT PVOID *ActCtx)
 
 __declspec (noreturn) VOID WINAPI BaseThreadStartup(LPTHREAD_START_ROUTINE lpStartAddress
 
VOID WINAPI BaseFreeThreadStack (IN HANDLE hProcess, IN PINITIAL_TEB InitialTeb)
 
VOID WINAPI BaseProcessStartup (PPROCESS_START_ROUTINE lpStartAddress)
 
PVOID WINAPI BasepIsRealtimeAllowed (IN BOOLEAN Keep)
 
VOID WINAPI BasepAnsiStringToHeapUnicodeString (IN LPCSTR AnsiString, OUT LPWSTR *UnicodeString)
 
PUNICODE_STRING WINAPI Basep8BitStringToStaticUnicodeString (IN LPCSTR AnsiString)
 
BOOLEAN WINAPI Basep8BitStringToDynamicUnicodeString (OUT PUNICODE_STRING UnicodeString, IN LPCSTR String)
 
ULONG NTAPI BasepUnicodeStringToAnsiSize (IN PUNICODE_STRING String)
 
ULONG NTAPI BasepAnsiStringToUnicodeSize (IN PANSI_STRING String)
 
HANDLE WINAPI BaseGetNamedObjectDirectory (VOID)
 
NTSTATUS WINAPI BasepMapFile (IN LPCWSTR lpApplicationName, OUT PHANDLE hSection, IN PUNICODE_STRING ApplicationName)
 
PCODEPAGE_ENTRY FASTCALL IntGetCodePageEntry (UINT CodePage)
 
LPWSTR WINAPI BaseComputeProcessDllPath (IN LPWSTR FullPath, IN PVOID Environment)
 
LPWSTR WINAPI BaseComputeProcessExePath (IN LPWSTR FullPath)
 
ULONG WINAPI BaseIsDosApplication (IN PUNICODE_STRING PathName, IN NTSTATUS Status)
 
NTSTATUS WINAPI BasepCheckBadapp (IN HANDLE FileHandle, IN PWCHAR ApplicationName, IN PWCHAR Environment, IN USHORT ExeType, IN PVOID *SdbQueryAppCompatData, IN PULONG SdbQueryAppCompatDataSize, IN PVOID *SxsData, IN PULONG SxsDataSize, OUT PULONG FusionFlags)
 
BOOLEAN WINAPI IsShimInfrastructureDisabled (VOID)
 
VOID WINAPI InitCommandLines (VOID)
 
DWORD WINAPI BaseSetLastNTError (IN NTSTATUS Status)
 
VOID NTAPI BasepLocateExeLdrEntry (IN PLDR_DATA_TABLE_ENTRY Entry, IN PVOID Context, OUT BOOLEAN *StopEnumeration)
 
NTSTATUS NTAPI BasepConfigureAppCertDlls (IN PWSTR ValueName, IN ULONG ValueType, IN PVOID ValueData, IN ULONG ValueLength, IN PVOID Context, IN PVOID EntryContext)
 
VOID WINAPI BaseMarkFileForDelete (IN HANDLE FileHandle, IN ULONG FileAttributes)
 
BOOL BasepCopyFileExW (IN LPCWSTR lpExistingFileName, IN LPCWSTR lpNewFileName, IN LPPROGRESS_ROUTINE lpProgressRoutine OPTIONAL, IN LPVOID lpData OPTIONAL, IN LPBOOL pbCancel OPTIONAL, IN DWORD dwCopyFlags, IN DWORD dwBasepFlags, OUT LPHANDLE lpExistingHandle, OUT LPHANDLE lpNewHandle)
 
BOOL BasepGetVolumeNameForVolumeMountPoint (IN LPCWSTR lpszMountPoint, OUT LPWSTR lpszVolumeName, IN DWORD cchBufferLength, OUT LPBOOL IsAMountPoint)
 
BOOL BasepGetVolumeNameFromReparsePoint (IN LPCWSTR lpszMountPoint, OUT LPWSTR lpszVolumeName, IN DWORD cchBufferLength, OUT LPBOOL IsAMountPoint)
 
BOOL IsThisARootDirectory (IN HANDLE VolumeHandle, IN PUNICODE_STRING NtPathName)
 
VOID WINAPI BasepFreeAppCompatData (IN PVOID AppCompatData, IN PVOID AppCompatSxsData)
 
NTSTATUS WINAPI BasepCheckWinSaferRestrictions (IN HANDLE UserToken, IN LPWSTR ApplicationName, IN HANDLE FileHandle, OUT PBOOLEAN InJob, OUT PHANDLE NewToken, OUT PHANDLE JobHandle)
 

Variables

PBASE_STATIC_SERVER_DATA BaseStaticServerData
 
WaitForInputIdleType UserWaitForInputIdleRoutine
 
BOOL bIsFileApiAnsi
 
HMODULE hCurrentModule
 
RTL_CRITICAL_SECTION BaseDllDirectoryLock
 
UNICODE_STRING BaseDllDirectory
 
UNICODE_STRING BaseDefaultPath
 
UNICODE_STRING BaseDefaultPathAppend
 
PLDR_DATA_TABLE_ENTRY BasepExeLdrEntry
 
LPTOP_LEVEL_EXCEPTION_FILTER GlobalTopLevelExceptionFilter
 
SYSTEM_BASIC_INFORMATION BaseCachedSysInfo
 
BOOLEAN BaseRunningInServerProcess
 
LPVOID lpParameter
 
PRTL_CONVERT_STRING Basep8BitStringToUnicodeString
 
PRTL_CONVERT_STRINGA BasepUnicodeStringTo8BitString
 
PRTL_COUNT_STRING BasepUnicodeStringTo8BitSize
 
PRTL_COUNT_STRINGA Basep8BitStringToUnicodeSize
 
UNICODE_STRING BaseWindowsDirectory
 
UNICODE_STRING BaseWindowsSystemDirectory
 
HANDLE BaseNamedObjectDirectory
 
LIST_ENTRY BasepAppCertDllsList
 
RTL_CRITICAL_SECTION gcsAppCert
 

Macro Definition Documentation

◆ __ENDTRY

#define __ENDTRY   _SEH2_END

Definition at line 57 of file kernel32.h.

◆ __EXCEPT_PAGE_FAULT

Definition at line 56 of file kernel32.h.

◆ __TRY

#define __TRY   _SEH2_TRY

Definition at line 55 of file kernel32.h.

◆ _lread

#define _lread (   a,
  b,
  c 
)    (long)(_hread(a, b, (long)c))

Definition at line 171 of file kernel32.h.

◆ actctx

#define actctx   202

Definition at line 8 of file kernel32.h.

◆ ARRAY_SIZE

#define ARRAY_SIZE (   a)    (sizeof(a)/sizeof((a)[0]))

Definition at line 53 of file kernel32.h.

◆ BASEP_COPY_BACKUP_SEMANTICS

#define BASEP_COPY_BACKUP_SEMANTICS   0x100

Definition at line 126 of file kernel32.h.

◆ BASEP_COPY_BASEP_MASK

#define BASEP_COPY_BASEP_MASK   0xFFFFFFF0

Definition at line 130 of file kernel32.h.

◆ BASEP_COPY_DIRECTORY

#define BASEP_COPY_DIRECTORY   0x80

Definition at line 125 of file kernel32.h.

◆ BASEP_COPY_METADATA

#define BASEP_COPY_METADATA   0x10

Definition at line 122 of file kernel32.h.

◆ BASEP_COPY_OWNER_AND_GROUP

#define BASEP_COPY_OWNER_AND_GROUP   0x40

Definition at line 124 of file kernel32.h.

◆ BASEP_COPY_PUBLIC_MASK

#define BASEP_COPY_PUBLIC_MASK   0xF

Definition at line 129 of file kernel32.h.

◆ BASEP_COPY_REPLACE

#define BASEP_COPY_REPLACE   0x200

Definition at line 127 of file kernel32.h.

◆ BASEP_COPY_SACL

#define BASEP_COPY_SACL   0x20

Definition at line 123 of file kernel32.h.

◆ BASEP_COPY_SKIP_DACL

#define BASEP_COPY_SKIP_DACL   0x400

Definition at line 128 of file kernel32.h.

◆ BASEP_GET_MODULE_HANDLE_EX_PARAMETER_VALIDATION_CONTINUE

#define BASEP_GET_MODULE_HANDLE_EX_PARAMETER_VALIDATION_CONTINUE   3

Definition at line 109 of file kernel32.h.

◆ BASEP_GET_MODULE_HANDLE_EX_PARAMETER_VALIDATION_ERROR

#define BASEP_GET_MODULE_HANDLE_EX_PARAMETER_VALIDATION_ERROR   1

Definition at line 107 of file kernel32.h.

◆ BASEP_GET_MODULE_HANDLE_EX_PARAMETER_VALIDATION_SUCCESS

#define BASEP_GET_MODULE_HANDLE_EX_PARAMETER_VALIDATION_SUCCESS   2

Definition at line 108 of file kernel32.h.

◆ comm

#define comm   205

Definition at line 11 of file kernel32.h.

◆ DEBUG_CHANNEL

#define DEBUG_CHANNEL (   ch)

Definition at line 19 of file kernel32.h.

◆ debugstr_a

#define debugstr_a

Definition at line 31 of file kernel32.h.

◆ debugstr_guid

#define debugstr_guid

Definition at line 35 of file kernel32.h.

◆ debugstr_w

#define debugstr_w

Definition at line 32 of file kernel32.h.

◆ debugstr_wn

#define debugstr_wn

Definition at line 33 of file kernel32.h.

◆ ERR

#define ERR (   fmt,
  ... 
)    ERR__(gDebugChannel, fmt, ##__VA_ARGS__)

Definition at line 25 of file kernel32.h.

◆ FIXME

#define FIXME (   fmt,
  ... 
)    WARN__(gDebugChannel, fmt,## __VA_ARGS__)

Definition at line 24 of file kernel32.h.

◆ HeapAlloc

#define HeapAlloc   RtlAllocateHeap

Definition at line 168 of file kernel32.h.

◆ HeapFree

#define HeapFree   RtlFreeHeap

Definition at line 170 of file kernel32.h.

◆ HeapReAlloc

#define HeapReAlloc   RtlReAllocateHeap

Definition at line 169 of file kernel32.h.

◆ kernel32file

#define kernel32file   200

Definition at line 6 of file kernel32.h.

◆ kernel32session

#define kernel32session   204

Definition at line 10 of file kernel32.h.

◆ kernel32ver

#define kernel32ver   201

Definition at line 7 of file kernel32.h.

◆ MAGIC

#define MAGIC (   c1,
  c2,
  c3,
  c4 
)    ((c1) + ((c2)<<8) + ((c3)<<16) + ((c4)<<24))

Definition at line 40 of file kernel32.h.

◆ MAGIC_HEAP

#define MAGIC_HEAP   MAGIC( 'H','E','A','P' )

Definition at line 42 of file kernel32.h.

◆ nls

#define nls   207

Definition at line 13 of file kernel32.h.

◆ PRIV_ALLOW_NON_TRACKABLE

#define PRIV_ALLOW_NON_TRACKABLE   0x2

Definition at line 134 of file kernel32.h.

◆ PRIV_DELETE_ON_SUCCESS

#define PRIV_DELETE_ON_SUCCESS   0x1

Definition at line 133 of file kernel32.h.

◆ profile

#define profile   206

Definition at line 12 of file kernel32.h.

◆ resource

#define resource   203

Definition at line 9 of file kernel32.h.

◆ ROUND_DOWN

#define ROUND_DOWN (   n,
  align 
)    (((ULONG)n) & ~((align) - 1l))

Definition at line 47 of file kernel32.h.

◆ ROUND_UP

#define ROUND_UP (   n,
  align 
)    ROUND_DOWN(((ULONG)n) + (align) - 1, (align))

Definition at line 50 of file kernel32.h.

◆ ROUNDDOWN

#define ROUNDDOWN (   a,
  b 
)    (((a)/(b))*(b))

Definition at line 45 of file kernel32.h.

◆ ROUNDUP

#define ROUNDUP (   a,
  b 
)    ((((a)+(b)-1)/(b))*(b))

Definition at line 44 of file kernel32.h.

◆ STARTF_SHELLPRIVATE

#define STARTF_SHELLPRIVATE   0x400

Definition at line 60 of file kernel32.h.

◆ STUB

#define STUB
Value:
DPRINT1("%s() is UNIMPLEMENTED!\n", __FUNCTION__)
#define SetLastError(x)
Definition: compat.h:409
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:92
#define __FUNCTION__
Definition: types.h:112

Definition at line 27 of file kernel32.h.

◆ TRACE

#define TRACE (   fmt,
  ... 
)    TRACE__(gDebugChannel, fmt, ##__VA_ARGS__)

Definition at line 22 of file kernel32.h.

◆ WARN

#define WARN (   fmt,
  ... 
)    WARN__(gDebugChannel, fmt, ##__VA_ARGS__)

Definition at line 23 of file kernel32.h.

◆ wine_dbgstr_w

#define wine_dbgstr_w

Definition at line 34 of file kernel32.h.

Typedef Documentation

◆ BASE_CURRENT_DIR_PLACEMENT

◆ BASE_MSG_SXS_HANDLES

◆ BASE_SEARCH_PATH_TYPE

◆ BASEP_ACTCTX_BLOCK

◆ BASEP_APPCERT_ENTRY

◆ CODEPAGE_ENTRY

◆ LOADPARMS32

◆ PBASE_MSG_SXS_HANDLES

◆ PBASE_SEARCH_PATH_TYPE

◆ PBASEP_ACTCTX_BLOCK

◆ PBASEP_APPCERT_EMBEDDED_FUNC

typedef NTSTATUS(NTAPI * PBASEP_APPCERT_EMBEDDED_FUNC) (IN LPWSTR ApplicationName)

Definition at line 372 of file kernel32.h.

◆ PBASEP_APPCERT_ENTRY

◆ PBASEP_APPCERT_PLUGIN_FUNC

typedef NTSTATUS(NTAPI * PBASEP_APPCERT_PLUGIN_FUNC) (IN LPWSTR ApplicationName, IN ULONG CertFlag)

Definition at line 366 of file kernel32.h.

◆ PCODEPAGE_ENTRY

◆ PPROCESS_START_ROUTINE

typedef UINT(WINAPI * PPROCESS_START_ROUTINE) (VOID)

Definition at line 246 of file kernel32.h.

◆ PRTL_CONVERT_STRING

Definition at line 270 of file kernel32.h.

◆ PRTL_CONVERT_STRINGA

Definition at line 276 of file kernel32.h.

◆ PRTL_COUNT_STRING

typedef ULONG(NTAPI * PRTL_COUNT_STRING) (IN PUNICODE_STRING UnicodeString)

Definition at line 274 of file kernel32.h.

◆ PRTL_COUNT_STRINGA

typedef ULONG(NTAPI * PRTL_COUNT_STRINGA) (IN PANSI_STRING UnicodeString)

Definition at line 280 of file kernel32.h.

◆ PSAFER_REPLACE_PROCESS_THREAD_TOKENS

typedef NTSTATUS(NTAPI * PSAFER_REPLACE_PROCESS_THREAD_TOKENS) (IN HANDLE Token, IN HANDLE Process, IN HANDLE Thread)

Definition at line 377 of file kernel32.h.

◆ PSXS_OVERRIDE_MANIFEST

◆ PSXS_WIN32_NT_PATH_PAIR

◆ SXS_OVERRIDE_MANIFEST

◆ SXS_WIN32_NT_PATH_PAIR

◆ WaitForInputIdleType

typedef DWORD(* WaitForInputIdleType) (HANDLE hProcess, DWORD dwMilliseconds)

Definition at line 115 of file kernel32.h.

Enumeration Type Documentation

◆ _BASE_CURRENT_DIR_PLACEMENT

Enumerator
BaseCurrentDirPlacementInvalid 
BaseCurrentDirPlacementDefault 
BaseCurrentDirPlacementSafe 
BaseCurrentDirPlacementMax 

Definition at line 91 of file kernel32.h.

◆ _BASE_SEARCH_PATH_TYPE

Enumerator
BaseSearchPathInvalid 
BaseSearchPathDll 
BaseSearchPathApp 
BaseSearchPathDefault 
BaseSearchPathEnv 
BaseSearchPathCurrent 
BaseSearchPathMax 

Definition at line 80 of file kernel32.h.

Function Documentation

◆ __declspec()

__declspec ( noreturn  )

Definition at line 29 of file thread.c.

34 {
35  /* Attempt to call the Thread Start Address */
36  _SEH2_TRY
37  {
38  /* Legacy check which is still used today for Win32 threads */
39  if (NtCurrentTeb()->NtTib.Version == (30 << 8)) // OS/2 V3.0 ("Cruiser")
40  {
41  /* This registers the termination port with CSRSS */
43  }
44 
45  /* Get the exit code from the Thread Start */
46  ExitThread((lpStartAddress)((PVOID)lpParameter));
47  }
49  {
50  /* Get the Exit code from the SEH Handler */
52  {
53  /* Kill the whole process, usually */
55  }
56  else
57  {
58  /* If running inside CSRSS, kill just this thread */
60  }
61  }
62  _SEH2_END;
63 }
VOID WINAPI ExitProcess(IN UINT uExitCode)
Definition: proc.c:1517
_SEH2_TRY
Definition: create.c:4250
LONG WINAPI UnhandledExceptionFilter(IN PEXCEPTION_POINTERS ExceptionInfo)
Definition: except.c:262
#define _SEH2_GetExceptionInformation()
Definition: pseh2_64.h:11
VOID WINAPI ExitThread(IN DWORD uExitCode)
Definition: thread.c:327
BOOLEAN BaseRunningInServerProcess
Definition: dllmain.c:20
LPVOID lpParameter
Definition: kernel32.h:234
NTSTATUS NTAPI CsrNewThread(VOID)
Definition: api.c:27
_SEH2_END
Definition: create.c:4424
FORCEINLINE struct _TEB * NtCurrentTeb(VOID)
Definition: psfuncs.h:420
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12

◆ BaseComputeProcessDllPath()

LPWSTR WINAPI BaseComputeProcessDllPath ( IN LPWSTR  FullPath,
IN PVOID  Environment 
)

Definition at line 420 of file path.c.

422 {
423  LPWSTR DllPath = NULL;
424  UNICODE_STRING KeyName = RTL_CONSTANT_STRING(L"\\Registry\\MACHINE\\System\\CurrentControlSet\\Control\\Session Manager");
425  UNICODE_STRING ValueName = RTL_CONSTANT_STRING(L"SafeDllSearchMode");
427  KEY_VALUE_PARTIAL_INFORMATION PartialInfo;
431  BASE_CURRENT_DIR_PLACEMENT CurrentDirPlacement, OldCurrentDirPlacement;
432 
433  /* Acquire DLL directory lock */
435 
436  /* Check if we have a base dll directory */
438  {
439  /* Then compute the process path using DLL order (without curdir) */
441 
442  /* Release DLL directory lock */
444 
445  /* Return dll path */
446  return DllPath;
447  }
448 
449  /* Release DLL directory lock */
451 
452  /* Read the current placement */
453  CurrentDirPlacement = BasepDllCurrentDirPlacement;
454  if (CurrentDirPlacement == BaseCurrentDirPlacementInvalid)
455  {
456  /* Open the configuration key */
458  if (NT_SUCCESS(Status))
459  {
460  /* Query if safe search is enabled */
462  &ValueName,
464  &PartialInfo,
465  sizeof(PartialInfo),
466  &ResultLength);
467  if (NT_SUCCESS(Status))
468  {
469  /* Read the value if the size is OK */
470  if (ResultLength == sizeof(PartialInfo))
471  {
472  CurrentDirPlacement = *(PULONG)PartialInfo.Data;
473  }
474  }
475 
476  /* Close the handle */
478 
479  /* Validate the registry value */
480  if ((CurrentDirPlacement <= BaseCurrentDirPlacementInvalid) ||
481  (CurrentDirPlacement >= BaseCurrentDirPlacementMax))
482  {
483  /* Default to safe search */
484  CurrentDirPlacement = BaseCurrentDirPlacementSafe;
485  }
486  }
487 
488  /* Update the placement and read the old one */
490  CurrentDirPlacement,
492  if (OldCurrentDirPlacement != BaseCurrentDirPlacementInvalid)
493  {
494  /* If there already was a placement, use it */
495  CurrentDirPlacement = OldCurrentDirPlacement;
496  }
497  }
498 
499  /* Check if the placement is invalid or not set */
500  if ((CurrentDirPlacement <= BaseCurrentDirPlacementInvalid) ||
501  (CurrentDirPlacement >= BaseCurrentDirPlacementMax))
502  {
503  /* Default to safe search */
504  CurrentDirPlacement = BaseCurrentDirPlacementSafe;
505  }
506 
507  /* Compute the process path using either normal or safe search */
508  DllPath = BasepComputeProcessPath(BaseDllOrderCurrent[CurrentDirPlacement],
509  FullPath,
510  Environment);
511 
512  /* Return dll path */
513  return DllPath;
514 }
IN CINT OUT PVOID IN ULONG OUT PULONG ResultLength
Definition: conport.c:47
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING KeyName
Definition: ndis.h:4693
PVOID PVOID PWCHAR PVOID Environment
Definition: env.c:45
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4693
LONG NTSTATUS
Definition: precomp.h:26
NTSYSAPI NTSTATUS NTAPI RtlEnterCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
#define InterlockedCompareExchange
Definition: interlocked.h:104
UNICODE_STRING BaseDllDirectory
Definition: path.c:21
_In_ PUNICODE_STRING ValueName
Definition: cmfuncs.h:264
NTSYSAPI NTSTATUS NTAPI RtlLeaveCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
smooth NULL
Definition: ftsmooth.c:416
NTSYSAPI NTSTATUS NTAPI NtQueryValueKey(IN HANDLE KeyHandle, IN PUNICODE_STRING ValueName, IN KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass, IN PVOID KeyValueInformation, IN ULONG Length, IN PULONG ResultLength)
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3399
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
BASE_CURRENT_DIR_PLACEMENT BasepDllCurrentDirPlacement
Definition: path.c:81
static const WCHAR L[]
Definition: oid.c:1250
Status
Definition: gdiplustypes.h:24
RTL_CRITICAL_SECTION BaseDllDirectoryLock
Definition: dllmain.c:32
#define RTL_CONSTANT_OBJECT_ATTRIBUTES(n, a)
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
static const char const char * DllPath
Definition: image.c:34
unsigned int * PULONG
Definition: retypes.h:1
NTSYSAPI NTSTATUS NTAPI NtOpenKey(OUT PHANDLE KeyHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes)
Definition: ntapi.c:336
unsigned int ULONG
Definition: retypes.h:1
enum _BASE_CURRENT_DIR_PLACEMENT BASE_CURRENT_DIR_PLACEMENT
WCHAR * LPWSTR
Definition: xmlstorage.h:184
signed int * PLONG
Definition: retypes.h:5
BASE_SEARCH_PATH_TYPE BaseDllOrderCurrent[BaseCurrentDirPlacementMax][BaseSearchPathMax]
Definition: path.c:36
LPWSTR WINAPI BasepComputeProcessPath(IN PBASE_SEARCH_PATH_TYPE PathOrder, IN LPWSTR AppName, IN LPVOID Environment)
Definition: path.c:116
BASE_SEARCH_PATH_TYPE BaseDllOrderNoCurrent[BaseSearchPathMax]
Definition: path.c:63
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14

Referenced by BasePushProcessParameters(), GetModuleHandleForUnicodeString(), and LoadLibraryExW().

◆ BaseComputeProcessExePath()

LPWSTR WINAPI BaseComputeProcessExePath ( IN LPWSTR  FullPath)

Definition at line 405 of file path.c.

406 {
407  PBASE_SEARCH_PATH_TYPE PathOrder;
408  DPRINT("Computing EXE path: %S\n", FullPath);
409 
410  /* Check if we should use the current directory */
411  PathOrder = NeedCurrentDirectoryForExePathW(FullPath) ?
413 
414  /* And now compute the path */
415  return BasepComputeProcessPath(PathOrder, NULL, NULL);
416 }
BASE_SEARCH_PATH_TYPE BaseProcessOrderNoCurrent[BaseSearchPathMax]
Definition: path.c:54
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
BOOL WINAPI NeedCurrentDirectoryForExePathW(IN LPCWSTR ExeName)
Definition: path.c:956
enum _BASE_SEARCH_PATH_TYPE * PBASE_SEARCH_PATH_TYPE
BASE_SEARCH_PATH_TYPE BaseProcessOrder[BaseSearchPathMax]
Definition: path.c:72
LPWSTR WINAPI BasepComputeProcessPath(IN PBASE_SEARCH_PATH_TYPE PathOrder, IN LPWSTR AppName, IN LPVOID Environment)
Definition: path.c:116

Referenced by CreateProcessInternalW().

◆ BaseCreateStack()

NTSTATUS WINAPI BaseCreateStack ( HANDLE  hProcess,
SIZE_T  StackReserve,
SIZE_T  StackCommit,
PINITIAL_TEB  InitialTeb 
)

Definition at line 353 of file utils.c.

357 {
359  PIMAGE_NT_HEADERS Headers;
360  ULONG_PTR Stack;
361  BOOLEAN UseGuard;
362  ULONG PageSize, Dummy, AllocationGranularity;
363  SIZE_T StackReserveHeader, StackCommitHeader, GuardPageSize, GuaranteedStackCommit;
364  DPRINT("BaseCreateStack (hProcess: %p, Max: %lx, Current: %lx)\n",
365  hProcess, StackReserve, StackCommit);
366 
367  /* Read page size */
369  AllocationGranularity = BaseStaticServerData->SysInfo.AllocationGranularity;
370 
371  /* Get the Image Headers */
372  Headers = RtlImageNtHeader(NtCurrentPeb()->ImageBaseAddress);
373  if (!Headers) return STATUS_INVALID_IMAGE_FORMAT;
374 
375  StackCommitHeader = Headers->OptionalHeader.SizeOfStackCommit;
376  StackReserveHeader = Headers->OptionalHeader.SizeOfStackReserve;
377 
378  if (!StackReserve) StackReserve = StackReserveHeader;
379 
380  if (!StackCommit)
381  {
382  StackCommit = StackCommitHeader;
383  }
384  else if (StackCommit >= StackReserve)
385  {
386  StackReserve = ROUND_UP(StackCommit, 1024 * 1024);
387  }
388 
389  StackCommit = ROUND_UP(StackCommit, PageSize);
390  StackReserve = ROUND_UP(StackReserve, AllocationGranularity);
391 
392  GuaranteedStackCommit = NtCurrentTeb()->GuaranteedStackBytes;
393  if ((GuaranteedStackCommit) && (StackCommit < GuaranteedStackCommit))
394  {
395  StackCommit = GuaranteedStackCommit;
396  }
397 
398  if (StackCommit >= StackReserve)
399  {
400  StackReserve = ROUND_UP(StackCommit, 1024 * 1024);
401  }
402 
403  StackCommit = ROUND_UP(StackCommit, PageSize);
404  StackReserve = ROUND_UP(StackReserve, AllocationGranularity);
405 
406  /* Reserve memory for the stack */
407  Stack = 0;
409  (PVOID*)&Stack,
410  0,
411  &StackReserve,
412  MEM_RESERVE,
414  if (!NT_SUCCESS(Status))
415  {
416  DPRINT1("Failure to reserve stack: %lx\n", Status);
417  return Status;
418  }
419 
420  /* Now set up some basic Initial TEB Parameters */
421  InitialTeb->AllocatedStackBase = (PVOID)Stack;
422  InitialTeb->StackBase = (PVOID)(Stack + StackReserve);
423  InitialTeb->PreviousStackBase = NULL;
424  InitialTeb->PreviousStackLimit = NULL;
425 
426  /* Update the Stack Position */
427  Stack += StackReserve - StackCommit;
428 
429  /* Check if we will need a guard page */
430  if (StackReserve > StackCommit)
431  {
432  Stack -= PageSize;
433  StackCommit += PageSize;
434  UseGuard = TRUE;
435  }
436  else
437  {
438  UseGuard = FALSE;
439  }
440 
441  /* Allocate memory for the stack */
443  (PVOID*)&Stack,
444  0,
445  &StackCommit,
446  MEM_COMMIT,
448  if (!NT_SUCCESS(Status))
449  {
450  DPRINT1("Failure to allocate stack\n");
451  GuardPageSize = 0;
452  NtFreeVirtualMemory(hProcess, (PVOID*)&Stack, &GuardPageSize, MEM_RELEASE);
453  return Status;
454  }
455 
456  /* Now set the current Stack Limit */
457  InitialTeb->StackLimit = (PVOID)Stack;
458 
459  /* Create a guard page */
460  if (UseGuard)
461  {
462  /* Set the guard page */
463  GuardPageSize = PAGE_SIZE;
465  (PVOID*)&Stack,
466  &GuardPageSize,
468  &Dummy);
469  if (!NT_SUCCESS(Status))
470  {
471  DPRINT1("Failure to set guard page\n");
472  return Status;
473  }
474 
475  /* Update the Stack Limit keeping in mind the Guard Page */
476  InitialTeb->StackLimit = (PVOID)((ULONG_PTR)InitialTeb->StackLimit +
477  GuardPageSize);
478  }
479 
480  /* We are done! */
481  return STATUS_SUCCESS;
482 }
#define TRUE
Definition: types.h:120
#define ROUND_UP(n, align)
Definition: eventvwr.h:31
PBASE_STATIC_SERVER_DATA BaseStaticServerData
Definition: dllmain.c:19
#define PAGE_GUARD
Definition: nt_native.h:1310
NTSTATUS NTAPI NtProtectVirtualMemory(IN HANDLE ProcessHandle, IN OUT PVOID *UnsafeBaseAddress, IN OUT SIZE_T *UnsafeNumberOfBytesToProtect, IN ULONG NewAccessProtection, OUT PULONG UnsafeOldAccessProtection)
Definition: virtual.c:2986
LONG NTSTATUS
Definition: precomp.h:26
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
#define MEM_COMMIT
Definition: nt_native.h:1313
IMAGE_OPTIONAL_HEADER32 OptionalHeader
Definition: ntddk_ex.h:184
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define MEM_RESERVE
Definition: nt_native.h:1314
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
PVOID StackBase
Definition: pstypes.h:678
void DPRINT(...)
Definition: polytest.cpp:61
void * PVOID
Definition: retypes.h:9
SYSTEM_BASIC_INFORMATION SysInfo
Definition: base.h:122
#define STATUS_INVALID_IMAGE_FORMAT
Definition: ntstatus.h:345
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
PVOID StackLimit
Definition: pstypes.h:679
PVOID AllocatedStackBase
Definition: pstypes.h:680
#define PAGE_SIZE
Definition: env_spec_w32.h:49
Status
Definition: gdiplustypes.h:24
ULONG_PTR SIZE_T
Definition: typedefs.h:78
NTSTATUS NTAPI NtAllocateVirtualMemory(IN HANDLE ProcessHandle, IN OUT PVOID *UBaseAddress, IN ULONG_PTR ZeroBits, IN OUT PSIZE_T URegionSize, IN ULONG AllocationType, IN ULONG Protect)
Definition: virtual.c:4367
FORCEINLINE struct _TEB * NtCurrentTeb(VOID)
Definition: psfuncs.h:420
#define NtCurrentPeb()
Definition: FLS.c:19
#define DPRINT1
Definition: precomp.h:8
#define RtlImageNtHeader
Definition: compat.h:457
#define MEM_RELEASE
Definition: nt_native.h:1316
unsigned int ULONG
Definition: retypes.h:1
PVOID PreviousStackBase
Definition: pstypes.h:676
PVOID PreviousStackLimit
Definition: pstypes.h:677
return STATUS_SUCCESS
Definition: btrfs.c:2725
#define PAGE_READWRITE
Definition: nt_native.h:1304
NTSTATUS NTAPI NtFreeVirtualMemory(IN HANDLE ProcessHandle, IN PVOID *UBaseAddress, IN PSIZE_T URegionSize, IN ULONG FreeType)
Definition: virtual.c:5090

Referenced by CreateFiberEx(), CreateProcessInternalW(), and CreateRemoteThread().

◆ BaseDllInitializeMemoryManager()

VOID NTAPI BaseDllInitializeMemoryManager ( VOID  )

Definition at line 26 of file heapmem.c.

27 {
28  BaseHeap = RtlGetProcessHeap();
30  sizeof(BASE_HEAP_HANDLE_ENTRY),
34  sizeof(SystemRangeStart),
35  NULL);
36 }
NTSYSAPI NTSTATUS NTAPI NtQuerySystemInformation(IN SYSTEM_INFORMATION_CLASS SystemInfoClass, OUT PVOID SystemInfoBuffer, IN ULONG SystemInfoBufferSize, OUT PULONG BytesReturned OPTIONAL)
ULONG_PTR SystemRangeStart
Definition: heapmem.c:20
NTSYSAPI VOID NTAPI RtlInitializeHandleTable(_In_ ULONG TableSize, _In_ ULONG HandleSize, _In_ PRTL_HANDLE_TABLE HandleTable)
RTL_HANDLE_TABLE BaseHeapHandleTable
Definition: heapmem.c:18
smooth NULL
Definition: ftsmooth.c:416
Definition: baseheap.h:68
HANDLE BaseHeap
Definition: heapmem.c:19

Referenced by DllMain().

◆ BaseFormatObjectAttributes()

POBJECT_ATTRIBUTES WINAPI BaseFormatObjectAttributes ( OUT POBJECT_ATTRIBUTES  ObjectAttributes,
IN PSECURITY_ATTRIBUTES SecurityAttributes  OPTIONAL,
IN PUNICODE_STRING  ObjectName 
)

Definition at line 304 of file utils.c.

307 {
311  DPRINT("BaseFormatObjectAttributes. Security: %p, Name: %p\n",
312  SecurityAttributes, ObjectName);
313 
314  /* Get the attributes if present */
315  if (SecurityAttributes)
316  {
317  Attributes = SecurityAttributes->bInheritHandle ? OBJ_INHERIT : 0;
318  SecurityDescriptor = SecurityAttributes->lpSecurityDescriptor;
319  }
320  else
321  {
322  if (!ObjectName) return NULL;
323  Attributes = 0;
325  }
326 
327  if (ObjectName)
328  {
331  }
332  else
333  {
335  }
336 
337  /* Create the Object Attributes */
339  ObjectName,
340  Attributes,
343  DPRINT("Attributes: %lx, RootDirectory: %p, SecurityDescriptor: %p\n",
345  return ObjectAttributes;
346 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
WCHAR RootDirectory[MAX_PATH]
Definition: format.c:74
_In_ USHORT _In_ ULONG _In_ PSOCKADDR _In_ PSOCKADDR _Reserved_ ULONG _In_opt_ PVOID _In_opt_ const WSK_CLIENT_CONNECTION_DISPATCH _In_opt_ PEPROCESS _In_opt_ PETHREAD _In_opt_ PSECURITY_DESCRIPTOR SecurityDescriptor
Definition: wsk.h:182
_In_ PVOID _Out_opt_ PULONG_PTR _Outptr_opt_ PCUNICODE_STRING * ObjectName
Definition: cmfuncs.h:62
#define OBJ_OPENIF
Definition: winternl.h:229
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
#define OBJ_INHERIT
Definition: winternl.h:225
HANDLE WINAPI BaseGetNamedObjectDirectory(VOID)
Definition: utils.c:63
_Must_inspect_result_ _In_ USHORT _In_ PHIDP_PREPARSED_DATA _Out_writes_to_ LengthAttributes PHIDP_EXTENDED_ATTRIBUTES Attributes
Definition: hidpi.h:348
unsigned int ULONG
Definition: retypes.h:1
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106

Referenced by CreateFileMappingW(), CreateProcessInternalW(), and CreateRemoteThread().

◆ BaseFormatTimeOut()

PLARGE_INTEGER WINAPI BaseFormatTimeOut ( OUT PLARGE_INTEGER  Timeout,
IN DWORD  dwMilliseconds 
)

Definition at line 288 of file utils.c.

290 {
291  /* Check if this is an infinite wait, which means no timeout argument */
292  if (dwMilliseconds == INFINITE) return NULL;
293 
294  /* Otherwise, convert the time to NT Format */
295  Timeout->QuadPart = dwMilliseconds * -10000LL;
296  return Timeout;
297 }
#define LL
Definition: tui.h:72
smooth NULL
Definition: ftsmooth.c:416
static ULONG Timeout
Definition: ping.c:61
#define INFINITE
Definition: serial.h:102

Referenced by GetQueuedCompletionStatus(), SignalObjectAndWait(), SleepEx(), WaitForDebugEvent(), WaitForMultipleObjectsEx(), and WaitForSingleObjectEx().

◆ BaseFreeThreadStack()

VOID WINAPI BaseFreeThreadStack ( IN HANDLE  hProcess,
IN PINITIAL_TEB  InitialTeb 
)

Definition at line 486 of file utils.c.

488 {
489  SIZE_T Dummy = 0;
490 
491  /* Free the Stack */
493  &InitialTeb->AllocatedStackBase,
494  &Dummy,
495  MEM_RELEASE);
496 }
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
ULONG_PTR SIZE_T
Definition: typedefs.h:78
#define MEM_RELEASE
Definition: nt_native.h:1316
NTSTATUS NTAPI NtFreeVirtualMemory(IN HANDLE ProcessHandle, IN PVOID *UBaseAddress, IN PSIZE_T URegionSize, IN ULONG FreeType)
Definition: virtual.c:5090

Referenced by CreateRemoteThread().

◆ BaseGetNamedObjectDirectory()

HANDLE WINAPI BaseGetNamedObjectDirectory ( VOID  )

Definition at line 63 of file utils.c.

64 {
67  HANDLE DirHandle, BnoHandle, Token, NewToken;
68 
70 
71  if (NtCurrentTeb()->IsImpersonating)
72  {
75  TRUE,
76  &Token);
78 
79  NewToken = NULL;
82  &NewToken,
83  sizeof(HANDLE));
84  if (!NT_SUCCESS (Status))
85  {
86  NtClose(Token);
88  }
89  }
90  else
91  {
92  Token = NULL;
93  }
94 
96  if (BaseNamedObjectDirectory) goto Quickie;
97 
101  NULL,
102  NULL);
103 
104  Status = NtOpenDirectoryObject(&BnoHandle,
110  if (!NT_SUCCESS(Status))
111  {
112  Status = NtOpenDirectoryObject(&DirHandle,
115 
116  if (NT_SUCCESS(Status))
117  {
121  DirHandle,
122  NULL);
123 
124  Status = NtOpenDirectoryObject(&BnoHandle,
130  NtClose(DirHandle);
131 
132  }
133  }
134 
135  if (NT_SUCCESS(Status)) BaseNamedObjectDirectory = BnoHandle;
136 
137 Quickie:
138 
140 
141  if (Token)
142  {
145  &Token,
146  sizeof(Token));
147 
148  NtClose(Token);
149  }
150 
152 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define TRUE
Definition: types.h:120
PBASE_STATIC_SERVER_DATA BaseStaticServerData
Definition: dllmain.c:19
#define DIRECTORY_CREATE_OBJECT
Definition: nt_native.h:1256
NTSTATUS NTAPI NtOpenDirectoryObject(OUT PHANDLE DirectoryHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes)
Definition: obdir.c:359
LONG NTSTATUS
Definition: precomp.h:26
_IRQL_requires_same_ _In_ PLSA_STRING _In_ SECURITY_LOGON_TYPE _In_ ULONG _In_ ULONG _In_opt_ PTOKEN_GROUPS _In_ PTOKEN_SOURCE _Out_ PVOID _Out_ PULONG _Inout_ PLUID _Out_ PHANDLE Token
#define NtCurrentThread()
VOID NTAPI RtlReleasePebLock(VOID)
Definition: libsupp.c:82
#define TOKEN_IMPERSONATE
Definition: setypes.h:873
UNICODE_STRING NamedObjectDirectory
Definition: base.h:115
smooth NULL
Definition: ftsmooth.c:416
NTSTATUS NTAPI NtSetInformationThread(IN HANDLE ThreadHandle, IN THREADINFOCLASS ThreadInformationClass, IN PVOID ThreadInformation, IN ULONG ThreadInformationLength)
Definition: query.c:1967
UNICODE_STRING Restricted
Definition: utils.c:24
#define DIRECTORY_TRAVERSE
Definition: nt_native.h:1255
HANDLE BaseNamedObjectDirectory
Definition: dllmain.c:24
#define DIRECTORY_CREATE_SUBDIRECTORY
Definition: nt_native.h:1257
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3399
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
Status
Definition: gdiplustypes.h:24
FORCEINLINE struct _TEB * NtCurrentTeb(VOID)
Definition: psfuncs.h:420
VOID NTAPI RtlAcquirePebLock(VOID)
Definition: libsupp.c:72
NTSTATUS NTAPI NtOpenThreadToken(IN HANDLE ThreadHandle, IN ACCESS_MASK DesiredAccess, IN BOOLEAN OpenAsSelf, OUT PHANDLE TokenHandle)
Definition: token.c:3858
#define DIRECTORY_QUERY
Definition: nt_native.h:1254
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106

Referenced by BaseFormatObjectAttributes(), and OpenFileMappingW().

◆ BaseInitializeContext()

VOID WINAPI BaseInitializeContext ( IN PCONTEXT  Context,
IN PVOID  Parameter,
IN PVOID  StartAddress,
IN PVOID  StackAddress,
IN ULONG  ContextType 
)

Definition at line 503 of file utils.c.

508 {
509 #ifdef _M_IX86
510  ULONG ContextFlags;
511  DPRINT("BaseInitializeContext: %p\n", Context);
512 
513  /* Setup the Initial Win32 Thread Context */
514  Context->Eax = (ULONG)StartAddress;
515  Context->Ebx = (ULONG)Parameter;
516  Context->Esp = (ULONG)StackAddress;
517  /* The other registers are undefined */
518 
519  /* Setup the Segments */
520  Context->SegFs = KGDT_R3_TEB;
521  Context->SegEs = KGDT_R3_DATA;
522  Context->SegDs = KGDT_R3_DATA;
523  Context->SegCs = KGDT_R3_CODE;
524  Context->SegSs = KGDT_R3_DATA;
525  Context->SegGs = 0;
526 
527  /* Set the Context Flags */
528  ContextFlags = Context->ContextFlags;
529  Context->ContextFlags = CONTEXT_FULL;
530 
531  /* Give it some room for the Parameter */
532  Context->Esp -= sizeof(PVOID);
533 
534  /* Set the EFLAGS */
535  Context->EFlags = 0x3000; /* IOPL 3 */
536 
537  /* What kind of context is being created? */
538  if (ContextType == 1)
539  {
540  /* For Threads */
542  }
543  else if (ContextType == 2)
544  {
545  /* This is a fiber: make space for the return address */
546  Context->Esp -= sizeof(PVOID);
547  *((PVOID*)Context->Esp) = BaseFiberStartup;
548 
549  /* Is FPU state required? */
550  Context->ContextFlags |= ContextFlags;
551  if ((ContextFlags & CONTEXT_FLOATING_POINT) == CONTEXT_FLOATING_POINT)
552  {
553  /* Set an initial state */
554  Context->FloatSave.ControlWord = 0x27F;
555  Context->FloatSave.StatusWord = 0;
556  Context->FloatSave.TagWord = 0xFFFF;
557  Context->FloatSave.ErrorOffset = 0;
558  Context->FloatSave.ErrorSelector = 0;
559  Context->FloatSave.DataOffset = 0;
560  Context->FloatSave.DataSelector = 0;
561  if (SharedUserData->ProcessorFeatures[PF_XMMI_INSTRUCTIONS_AVAILABLE])
562  Context->Dr6 = 0x1F80;
563  }
564  }
565  else
566  {
567  /* For first thread in a Process */
569  }
570 
571 #elif defined(_M_AMD64)
572  DPRINT("BaseInitializeContext: %p\n", Context);
573 
574  /* Setup the Initial Win32 Thread Context */
575  Context->Rax = (ULONG_PTR)StartAddress;
576  Context->Rbx = (ULONG_PTR)Parameter;
577  Context->Rsp = (ULONG_PTR)StackAddress;
578  /* The other registers are undefined */
579 
580  /* Setup the Segments */
581  Context->SegGs = KGDT64_R3_DATA | RPL_MASK;
582  Context->SegEs = KGDT64_R3_DATA | RPL_MASK;
583  Context->SegDs = KGDT64_R3_DATA | RPL_MASK;
584  Context->SegCs = KGDT64_R3_CODE | RPL_MASK;
585  Context->SegSs = KGDT64_R3_DATA | RPL_MASK;
586  Context->SegFs = KGDT64_R3_CMTEB | RPL_MASK;
587 
588  /* Set the EFLAGS */
589  Context->EFlags = 0x3000; /* IOPL 3 */
590 
591  if (ContextType == 1) /* For Threads */
592  {
594  }
595  else if (ContextType == 2) /* For Fibers */
596  {
597  Context->Rip = (ULONG_PTR)BaseFiberStartup;
598  }
599  else /* For first thread in a Process */
600  {
602  }
603 
604  /* Set the Context Flags */
605  Context->ContextFlags = CONTEXT_FULL;
606 
607  /* Give it some room for the Parameter */
608  Context->Rsp -= sizeof(PVOID);
609 #elif defined(_M_ARM)
610  DPRINT("BaseInitializeContext: %p\n", Context);
611 
612  // FIXME: check if this is correct!
613  /* Setup the Initial Win32 Thread Context */
614  Context->R0 = (ULONG_PTR)StartAddress;
615  Context->R1 = (ULONG_PTR)Parameter;
616  Context->Sp = (ULONG_PTR)StackAddress;
617 
618  if (ContextType == 1) /* For Threads */
619  {
621  }
622  else if (ContextType == 2) /* For Fibers */
623  {
624  Context->Pc = (ULONG_PTR)BaseFiberStartup;
625  }
626  else /* For first thread in a Process */
627  {
629  }
630 
631  /* Set the Context Flags */
632  Context->ContextFlags = CONTEXT_FULL;
633 
634  /* Give it some room for the Parameter */
635  Context->Sp -= sizeof(PVOID);
636 #else
637 #warning Unknown architecture
639  DbgBreakPoint();
640 #endif
641 }
#define KGDT64_R3_CODE
Definition: ketypes.h:76
#define KGDT64_R3_CMTEB
Definition: ketypes.h:78
#define CONTEXT_FULL
Definition: compat.h:270
_In_ PVOID Parameter
Definition: ldrtypes.h:240
void DbgBreakPoint()
Definition: mach.c:558
#define KGDT64_R3_DATA
Definition: ketypes.h:75
#define PF_XMMI_INSTRUCTIONS_AVAILABLE
#define RPL_MASK
Definition: ketypes.h:69
void DPRINT(...)
Definition: polytest.cpp:61
#define KGDT_R3_DATA
Definition: ketypes.h:77
void * PVOID
Definition: retypes.h:9
#define KGDT_R3_TEB
Definition: ketypes.h:80
#define SharedUserData
#define CONTEXT_FLOATING_POINT
Definition: compat.h:267
#define KGDT_R3_CODE
Definition: ketypes.h:76
VOID WINAPI BaseProcessStartThunk(VOID)
unsigned int ULONG
Definition: retypes.h:1
_Must_inspect_result_ _In_ FLT_CONTEXT_TYPE ContextType
Definition: fltkernel.h:1444
#define UNIMPLEMENTED
Definition: debug.h:114
#define ULONG_PTR
Definition: config.h:101
VOID WINAPI BaseThreadStartupThunk(VOID)

Referenced by CreateFiberEx(), CreateProcessInternalW(), and CreateRemoteThread().

◆ BaseIsDosApplication()

ULONG WINAPI BaseIsDosApplication ( IN PUNICODE_STRING  PathName,
IN NTSTATUS  Status 
)

Definition at line 66 of file vdm.c.

68 {
70 
71  /* Is it a .com? */
73  String.Buffer = &PathName->Buffer[(PathName->Length - String.Length) / sizeof(WCHAR)];
75 
76  /* Is it a .pif? */
78  String.Buffer = &PathName->Buffer[(PathName->Length - String.Length) / sizeof(WCHAR)];
80 
81  /* Is it an exe? */
83  String.Buffer = &PathName->Buffer[(PathName->Length - String.Length) / sizeof(WCHAR)];
85 
86  return 0;
87 }
static UNICODE_STRING BaseDotExeSuffixName
Definition: vdm.c:60
#define TRUE
Definition: types.h:120
static WCHAR String[]
Definition: stringtable.c:55
static UNICODE_STRING BaseDotComSuffixName
Definition: vdm.c:58
#define BINARY_TYPE_PIF
Definition: vdm.h:37
__wchar_t WCHAR
Definition: xmlstorage.h:180
static UNICODE_STRING BaseDotPifSuffixName
Definition: vdm.c:59
#define BINARY_TYPE_COM
Definition: vdm.h:36
NTSYSAPI BOOLEAN NTAPI RtlEqualUnicodeString(PUNICODE_STRING String1, PUNICODE_STRING String2, BOOLEAN CaseInSensitive)
#define BINARY_TYPE_EXE
Definition: vdm.h:35

Referenced by CreateProcessInternalW().

◆ BaseMarkFileForDelete()

VOID WINAPI BaseMarkFileForDelete ( IN HANDLE  FileHandle,
IN ULONG  FileAttributes 
)

Definition at line 864 of file utils.c.

866 {
868  FILE_BASIC_INFORMATION FileBasicInfo;
869  FILE_DISPOSITION_INFORMATION FileDispositionInfo;
870 
871  /* If no attributes were given, get them */
872  if (!FileAttributes)
873  {
874  FileBasicInfo.FileAttributes = 0;
876  &IoStatusBlock,
877  &FileBasicInfo,
878  sizeof(FileBasicInfo),
880  FileAttributes = FileBasicInfo.FileAttributes;
881  }
882 
883  /* If file is marked as RO, reset its attributes */
885  {
886  RtlZeroMemory(&FileBasicInfo, sizeof(FileBasicInfo));
887  FileBasicInfo.FileAttributes = FILE_ATTRIBUTE_NORMAL;
889  &IoStatusBlock,
890  &FileBasicInfo,
891  sizeof(FileBasicInfo),
893  }
894 
895  /* Finally, mark the file for deletion */
896  FileDispositionInfo.DeleteFile = TRUE;
898  &IoStatusBlock,
899  &FileDispositionInfo,
900  sizeof(FileDispositionInfo),
902 }
#define TRUE
Definition: types.h:120
HANDLE FileHandle
Definition: stats.c:38
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE _In_ ACCESS_MASK _In_ POBJECT_ATTRIBUTES _Out_ PIO_STATUS_BLOCK _In_opt_ PLARGE_INTEGER _In_ ULONG FileAttributes
Definition: fltkernel.h:1230
#define FILE_ATTRIBUTE_READONLY
Definition: nt_native.h:702
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
NTSTATUS NTAPI NtQueryInformationFile(HANDLE hFile, PIO_STATUS_BLOCK io, PVOID ptr, ULONG len, FILE_INFORMATION_CLASS FileInformationClass)
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
NTSYSAPI NTSTATUS NTAPI NtSetInformationFile(IN HANDLE hFile, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN PVOID FileInformationBuffer, IN ULONG FileInformationBufferLength, IN FILE_INFORMATION_CLASS FileInfoClass)
Definition: iofunc.c:3042

Referenced by CreateDirectoryExW().

◆ Basep8BitStringToDynamicUnicodeString()

BOOLEAN WINAPI Basep8BitStringToDynamicUnicodeString ( OUT PUNICODE_STRING  UnicodeString,
IN LPCSTR  String 
)

Definition at line 225 of file utils.c.

227 {
230 
231  /* Initialize an ANSI String */
233  if (!NT_SUCCESS(Status))
234  {
236  }
237  else
238  {
239  /* Convert it */
241  }
242 
243  if (NT_SUCCESS(Status)) return TRUE;
244 
246  {
248  }
249  else
250  {
252  }
253 
254  return FALSE;
255 }
#define TRUE
Definition: types.h:120
NTSYSAPI NTSTATUS WINAPI RtlInitAnsiStringEx(PANSI_STRING, PCSZ)
LONG NTSTATUS
Definition: precomp.h:26
static WCHAR String[]
Definition: stringtable.c:55
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define SetLastError(x)
Definition: compat.h:409
Status
Definition: gdiplustypes.h:24
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:61
PRTL_CONVERT_STRING Basep8BitStringToUnicodeString
Definition: utils.c:26
#define ERROR_FILENAME_EXCED_RANGE
Definition: winerror.h:263

Referenced by CopyFileA(), CopyFileExA(), CreateDirectoryExA(), CreateHardLinkA(), CreateProcessInternalA(), GetFullPathNameA(), GetLongPathNameA(), GetShortPathNameA(), GetTempFileNameA(), MoveFileWithProgressA(), ReplaceFileA(), SearchPathA(), SetVolumeLabelA(), and WaitNamedPipeA().

◆ Basep8BitStringToStaticUnicodeString()

PUNICODE_STRING WINAPI Basep8BitStringToStaticUnicodeString ( IN LPCSTR  AnsiString)

Definition at line 188 of file utils.c.

189 {
190  PUNICODE_STRING StaticString = &(NtCurrentTeb()->StaticUnicodeString);
193 
194  /* Initialize an ANSI String */
196  if (!NT_SUCCESS(Status))
197  {
199  }
200  else
201  {
202  /* Convert it */
204  }
205 
206  if (NT_SUCCESS(Status)) return StaticString;
207 
209  {
211  }
212  else
213  {
215  }
216 
217  return NULL;
218 }
NTSYSAPI NTSTATUS WINAPI RtlInitAnsiStringEx(PANSI_STRING, PCSZ)
LONG NTSTATUS
Definition: precomp.h:26
static WCHAR String[]
Definition: stringtable.c:55
smooth NULL
Definition: ftsmooth.c:416
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define SetLastError(x)
Definition: compat.h:409
Status
Definition: gdiplustypes.h:24
FORCEINLINE struct _TEB * NtCurrentTeb(VOID)
Definition: psfuncs.h:420
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:61
PRTL_CONVERT_STRING Basep8BitStringToUnicodeString
Definition: utils.c:26
IN PUNICODE_STRING StaticString
#define ERROR_FILENAME_EXCED_RANGE
Definition: winerror.h:263

Referenced by CopyFileA(), CopyFileExA(), CreateDirectoryA(), CreateDirectoryExA(), CreateHardLinkA(), DeleteFileA(), FindFirstFileA(), FindFirstFileExA(), GetDiskFreeSpaceA(), GetDiskFreeSpaceExA(), GetDriveTypeA(), GetModuleHandleA(), GetModuleHandleExA(), GetTempFileNameA(), GetVolumeInformationA(), GetVolumeNameForVolumeMountPointA(), GetVolumePathNameA(), GetVolumePathNamesForVolumeNameA(), LoadLibraryExA(), RemoveDirectoryA(), SearchPathA(), SetCurrentDirectoryA(), and SetVolumeLabelA().

◆ BasepAllocateActivationContextActivationBlock()

NTSTATUS NTAPI BasepAllocateActivationContextActivationBlock ( IN DWORD  Flags,
IN PVOID  CompletionRoutine,
IN PVOID  CompletionContext,
OUT PBASEP_ACTCTX_BLOCK ActivationBlock 
)

Definition at line 45 of file actctx.c.

49 {
51  ACTIVATION_CONTEXT_BASIC_INFORMATION ContextInfo;
52 
53  /* Clear the info structure */
54  ContextInfo.dwFlags = 0;
55  ContextInfo.hActCtx = NULL;
56 
57  /* Assume failure */
58  if (ActivationBlock) *ActivationBlock = NULL;
59 
60  /* Only support valid flags */
61  if (Flags & ~(1 | 2)) // FIXME: What are they? 2 looks like BASEP_ACTCTX_FORCE_BLOCK
62  {
63  /* Fail if unknown flags are passed in */
65  goto Quickie;
66  }
67 
68  /* Caller should have passed in an activation block */
69  if (!ActivationBlock)
70  {
71  /* Fail otherwise */
73  goto Quickie;
74  }
75 
76  /* Query RTL for information on the current activation context */
78  NULL,
79  NULL,
80  ActivationContextBasicInformation,
81  &ContextInfo,
82  sizeof(ContextInfo),
83  NULL);
84  if (!NT_SUCCESS(Status))
85  {
86  /* Failed -- bail out */
87  DPRINT1("SXS: %s - Failure getting active activation context; ntstatus %08lx\n",
89  goto Quickie;
90  }
91 
92  /* Check if the current one should be freed */
93  if (ContextInfo.dwFlags & 1)
94  {
95  /* Release and clear it */
96  RtlReleaseActivationContext(ContextInfo.hActCtx);
97  ContextInfo.hActCtx = NULL;
98  }
99 
100  /* Check if there's an active context, or if the caller is forcing one */
101  if (!(Flags & 2) || (ContextInfo.hActCtx))
102  {
103  /* Allocate the block */
104  *ActivationBlock = RtlAllocateHeap(RtlGetProcessHeap(),
105  0,
106  sizeof(BASEP_ACTCTX_BLOCK));
107  if (!(*ActivationBlock))
108  {
109  /* Ran out of memory, fail */
111  goto Quickie;
112  }
113 
114  /* Fill it out */
115  (*ActivationBlock)->ActivationContext = ContextInfo.hActCtx;
116  (*ActivationBlock)->Flags = 0;
117  if (Flags & 1) (*ActivationBlock)->Flags |= 1; // Not sure about this flag
118  (*ActivationBlock)->CompletionRoutine = CompletionRoutine;
119  (*ActivationBlock)->CompletionContext = CompletionContext;
120 
121  /* Tell Quickie below not to free anything, since this is success */
122  ContextInfo.hActCtx = NULL;
123  }
124 
125  /* Set success status */
127 
128 Quickie:
129  /* Failure or success path, return to caller and free on failure */
130  if (ContextInfo.hActCtx) RtlReleaseActivationContext(ContextInfo.hActCtx);
131  return Status;
132 }
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI RtlQueryInformationActivationContext(ULONG flags, HANDLE handle, PVOID subinst, ULONG class, PVOID buffer, SIZE_T bufsize, SIZE_T *retlen)
Definition: actctx.c:5438
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
_Unreferenced_parameter_ PVOID * CompletionContext
Definition: cdprocs.h:1130
smooth NULL
Definition: ftsmooth.c:416
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:585
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
VOID NTAPI RtlReleaseActivationContext(HANDLE handle)
Definition: actctx.c:5267
#define STATUS_INVALID_PARAMETER_1
Definition: ntstatus.h:461
Status
Definition: gdiplustypes.h:24
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
#define RTL_QUERY_ACTIVATION_CONTEXT_FLAG_USE_ACTIVE_ACTIVATION_CONTEXT
Definition: rtltypes.h:116
#define DPRINT1
Definition: precomp.h:8
_In_ PIRP _In_opt_ PVOID _In_opt_ POPLOCK_WAIT_COMPLETE_ROUTINE CompletionRoutine
Definition: fsrtlfuncs.h:673
#define STATUS_INVALID_PARAMETER_4
Definition: ntstatus.h:464
return STATUS_SUCCESS
Definition: btrfs.c:2725
#define __FUNCTION__
Definition: types.h:112

Referenced by ReadDirectoryChangesW().

◆ BasepAnsiStringToHeapUnicodeString()

VOID WINAPI BasepAnsiStringToHeapUnicodeString ( IN LPCSTR  AnsiString,
OUT LPWSTR UnicodeString 
)

Definition at line 263 of file utils.c.

265 {
266  ANSI_STRING AnsiTemp;
267  UNICODE_STRING UnicodeTemp;
268 
269  DPRINT("BasepAnsiStringToHeapUnicodeString\n");
270 
271  /* First create the ANSI_STRING */
272  RtlInitAnsiString(&AnsiTemp, AnsiString);
273 
274  if (NT_SUCCESS(RtlAnsiStringToUnicodeString(&UnicodeTemp,
275  &AnsiTemp,
276  TRUE)))
277  {
278  *UnicodeString = UnicodeTemp.Buffer;
279  }
280  else
281  {
282  *UnicodeString = NULL;
283  }
284 }
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlInitAnsiString(PANSI_STRING DestinationString, PCSZ SourceString)
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSYSAPI NTSTATUS NTAPI RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString, PANSI_STRING SourceString, BOOLEAN AllocateDestinationString)

Referenced by CreateProcessInternalA().

◆ BasepAnsiStringToUnicodeSize()

ULONG NTAPI BasepAnsiStringToUnicodeSize ( IN PANSI_STRING  String)

Definition at line 56 of file utils.c.

57 {
59 }
static WCHAR String[]
Definition: stringtable.c:55
NTSYSAPI DWORD WINAPI RtlAnsiStringToUnicodeSize(const STRING *)

Referenced by SetFileApisToANSI().

◆ BasepCheckBadapp()

NTSTATUS WINAPI BasepCheckBadapp ( IN HANDLE  FileHandle,
IN PWCHAR  ApplicationName,
IN PWCHAR  Environment,
IN USHORT  ExeType,
IN PVOID SdbQueryAppCompatData,
IN PULONG  SdbQueryAppCompatDataSize,
IN PVOID SxsData,
IN PULONG  SxsDataSize,
OUT PULONG  FusionFlags 
)

Definition at line 272 of file appcache.c.

281 {
283  ULONG Reason = 0;
284 
285  /* Is shimming enabled by group policy? */
287  {
288  /* Nothing to worry about */
290  }
291  else
292  {
293  /* It is, check if we know about this app */
295  FileHandle,
296  Environment,
297  &Reason))
298  {
301  {
303  }
304  }
305  }
306 
307  /* Return caller the status */
308  return Status;
309 }
PVOID PVOID PWCHAR PVOID Environment
Definition: env.c:45
BOOL WINAPI BaseCheckRunApp(IN HANDLE FileHandle, IN PWCHAR ApplicationName, IN PWCHAR Environment, IN USHORT ExeType, IN PULONG pReason, IN PVOID *SdbQueryAppCompatData, IN PULONG SdbQueryAppCompatDataSize, IN PVOID *SxsData, IN PULONG SxsDataSize, OUT PULONG FusionFlags)
Definition: appcache.c:193
PVOID PVOID PWCHAR PVOID USHORT PULONG PVOID PULONG PVOID PULONG PULONG FusionFlags
Definition: env.c:45
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN WINAPI IsShimInfrastructureDisabled(VOID)
Definition: appcache.c:37
HANDLE FileHandle
Definition: stats.c:38
BOOL WINAPI BaseCheckAppcompatCache(IN PWCHAR ApplicationName, IN HANDLE FileHandle, IN PWCHAR Environment, OUT PULONG Reason)
Definition: appcache.c:143
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
Status
Definition: gdiplustypes.h:24
PVOID PVOID PWCHAR ApplicationName
Definition: env.c:45
PVOID PVOID PWCHAR PVOID USHORT ExeType
Definition: env.c:45
PVOID PVOID PWCHAR PVOID USHORT PULONG PVOID PULONG PVOID PULONG SxsDataSize
Definition: env.c:45
unsigned int ULONG
Definition: retypes.h:1
PVOID PVOID PWCHAR PVOID USHORT PULONG PVOID PULONG PVOID * SxsData
Definition: env.c:45
return STATUS_SUCCESS
Definition: btrfs.c:2725
PVOID PVOID PWCHAR PVOID USHORT PULONG Reason
Definition: env.c:45
PVOID PVOID PWCHAR PVOID USHORT PULONG PVOID * SdbQueryAppCompatData
Definition: env.c:45
PVOID PVOID PWCHAR PVOID USHORT PULONG PVOID PULONG SdbQueryAppCompatDataSize
Definition: env.c:45

Referenced by CreateProcessInternalW().

◆ BasepCheckWinSaferRestrictions()

NTSTATUS WINAPI BasepCheckWinSaferRestrictions ( IN HANDLE  UserToken,
IN LPWSTR  ApplicationName,
IN HANDLE  FileHandle,
OUT PBOOLEAN  InJob,
OUT PHANDLE  NewToken,
OUT PHANDLE  JobHandle 
)

Definition at line 909 of file utils.c.

915 {
917 
918  /* Validate that there's a name */
919  if ((ApplicationName) && *(ApplicationName))
920  {
921  /* Validate that the required output parameters are there */
922  if ((InJob) && (NewToken) && (JobHandle))
923  {
924  /* Do the work (one day...) */
925  DPRINT("BasepCheckWinSaferRestrictions is UNIMPLEMENTED\n");
927  }
928  else
929  {
930  /* Act as if SEH hit this */
932  }
933  }
934  else
935  {
936  /* Input is invalid */
938  }
939 
940  /* Return the status */
941  return Status;
942 }
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
void DPRINT(...)
Definition: polytest.cpp:61
Status
Definition: gdiplustypes.h:24
PVOID PVOID PWCHAR ApplicationName
Definition: env.c:45
#define STATUS_ACCESS_VIOLATION
Definition: ntstatus.h:228
return STATUS_SUCCESS
Definition: btrfs.c:2725

Referenced by CreateProcessInternalW().

◆ BasepConfigureAppCertDlls()

NTSTATUS NTAPI BasepConfigureAppCertDlls ( IN PWSTR  ValueName,
IN ULONG  ValueType,
IN PVOID  ValueData,
IN ULONG  ValueLength,
IN PVOID  Context,
IN PVOID  EntryContext 
)

Definition at line 189 of file proc.c.

195 {
196  /* Add this to the certification list */
198 }
NTSTATUS NTAPI BasepSaveAppCertRegistryValue(IN PLIST_ENTRY List, IN PWCHAR ComponentName, IN PWCHAR DllName)
Definition: proc.c:178
_In_ PUNICODE_STRING ValueName
Definition: cmfuncs.h:264
_In_ GUID _In_ PVOID ValueData
Definition: hubbusif.h:311

◆ BasepCopyFileExW()

BOOL BasepCopyFileExW ( IN LPCWSTR  lpExistingFileName,
IN LPCWSTR  lpNewFileName,
IN LPPROGRESS_ROUTINE lpProgressRoutine  OPTIONAL,
IN LPVOID lpData  OPTIONAL,
IN LPBOOL pbCancel  OPTIONAL,
IN DWORD  dwCopyFlags,
IN DWORD  dwBasepFlags,
OUT LPHANDLE  lpExistingHandle,
OUT LPHANDLE  lpNewHandle 
)

Definition at line 202 of file copy.c.

211 {
212  NTSTATUS errCode;
213  HANDLE FileHandleSource, FileHandleDest;
215  FILE_STANDARD_INFORMATION FileStandard;
216  FILE_BASIC_INFORMATION FileBasic;
217  BOOL RC = FALSE;
218  BOOL KeepDestOnError = FALSE;
220 
221  FileHandleSource = CreateFileW(lpExistingFileName,
222  GENERIC_READ,
224  NULL,
227  NULL);
228  if (INVALID_HANDLE_VALUE != FileHandleSource)
229  {
230  errCode = NtQueryInformationFile(FileHandleSource,
231  &IoStatusBlock,
232  &FileStandard,
235  if (!NT_SUCCESS(errCode))
236  {
237  TRACE("Status 0x%08x obtaining FileStandardInformation for source\n", errCode);
238  BaseSetLastNTError(errCode);
239  }
240  else
241  {
242  errCode = NtQueryInformationFile(FileHandleSource,
243  &IoStatusBlock,&FileBasic,
244  sizeof(FILE_BASIC_INFORMATION),
246  if (!NT_SUCCESS(errCode))
247  {
248  TRACE("Status 0x%08x obtaining FileBasicInformation for source\n", errCode);
249  BaseSetLastNTError(errCode);
250  }
251  else
252  {
253  FileHandleDest = CreateFileW(lpNewFileName,
256  NULL,
257  dwCopyFlags ? CREATE_NEW : CREATE_ALWAYS,
258  FileBasic.FileAttributes,
259  NULL);
260  if (INVALID_HANDLE_VALUE != FileHandleDest)
261  {
262  errCode = CopyLoop(FileHandleSource,
263  FileHandleDest,
264  FileStandard.EndOfFile,
265  lpProgressRoutine,
266  lpData,
267  pbCancel,
268  &KeepDestOnError);
269  if (!NT_SUCCESS(errCode))
270  {
271  BaseSetLastNTError(errCode);
272  }
273  else
274  {
276 
277  t.QuadPart = FileBasic.LastWriteTime.QuadPart;
278  errCode = SetLastWriteTime(FileHandleDest, t);
279  if (!NT_SUCCESS(errCode))
280  {
281  BaseSetLastNTError(errCode);
282  }
283  else
284  {
285  RC = TRUE;
286  }
287  }
288  NtClose(FileHandleDest);
289  if (! RC && ! KeepDestOnError)
290  {
293  DeleteFileW(lpNewFileName);
295  }
296  }
297  else
298  {
299  WARN("Error %lu during opening of dest file\n", GetLastError());
300  }
301  }
302  }
303  NtClose(FileHandleSource);
304  }
305  else
306  {
307  WARN("Error %lu during opening of source file\n", GetLastError());
308  }
309 
310  return RC;
311 }
BOOL WINAPI SetFileAttributesW(LPCWSTR lpFileName, DWORD dwFileAttributes)
Definition: fileinfo.c:944
#define TRUE
Definition: types.h:120
#define WARN(fmt,...)
Definition: debug.h:111
LONG NTSTATUS
Definition: precomp.h:26
GLdouble GLdouble t
Definition: gl.h:2047
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define FILE_SHARE_READ
Definition: compat.h:125
static NTSTATUS CopyLoop(HANDLE FileHandleSource, HANDLE FileHandleDest, LARGE_INTEGER SourceFileSize, LPPROGRESS_ROUTINE lpProgressRoutine, LPVOID lpData, BOOL *pbCancel, BOOL *KeepDest)
Definition: copy.c:26
unsigned int BOOL
Definition: ntddk_ex.h:94
#define GENERIC_WRITE
Definition: nt_native.h:90
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
smooth NULL
Definition: ftsmooth.c:416
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define OPEN_EXISTING
Definition: compat.h:426
#define TRACE(s)
Definition: solgame.cpp:4
LARGE_INTEGER LastWriteTime
Definition: nt_native.h:941
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define FILE_FLAG_NO_BUFFERING
Definition: disk.h:45
unsigned long DWORD
Definition: ntddk_ex.h:95
static const char * SystemError(DWORD err)
Definition: vfdcmd.c:3368
#define SetLastError(x)
Definition: compat.h:409
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3399
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
#define GENERIC_READ
Definition: compat.h:124
NTSTATUS NTAPI NtQueryInformationFile(HANDLE hFile, PIO_STATUS_BLOCK io, PVOID ptr, ULONG len, FILE_INFORMATION_CLASS FileInformationClass)
#define CREATE_ALWAYS
Definition: disk.h:72
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define FileStandardInformation
Definition: propsheet.cpp:61
#define CreateFileW
Definition: compat.h:400
static NTSTATUS SetLastWriteTime(HANDLE FileHandle, LARGE_INTEGER LastWriteTime)
Definition: copy.c:166
#define CREATE_NEW
Definition: disk.h:69
LONGLONG QuadPart
Definition: typedefs.h:112

Referenced by CopyFileExW(), MoveFileWithProgressW(), and PrivCopyFileExW().

◆ BasepFreeActivationContextActivationBlock()

VOID NTAPI BasepFreeActivationContextActivationBlock ( IN PBASEP_ACTCTX_BLOCK  ActivationBlock)

Definition at line 26 of file actctx.c.

27 {
28  /* Exit if there was nothing passed in */
29  if (!ActivationBlock) return;
30 
31  /* Do we have a context? */
32  if (ActivationBlock->ActivationContext)
33  {
34  /* Release and clear it */
35  RtlReleaseActivationContext(ActivationBlock->ActivationContext);
36  ActivationBlock->ActivationContext = NULL;
37  }
38 
39  /* Free the block */
40  RtlFreeHeap(RtlGetProcessHeap(), 0, ActivationBlock);
41 }
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:603
smooth NULL
Definition: ftsmooth.c:416
VOID NTAPI RtlReleaseActivationContext(HANDLE handle)
Definition: actctx.c:5267

Referenced by BasepIoCompletion(), and ReadDirectoryChangesW().

◆ BasepFreeAppCompatData()

VOID WINAPI BasepFreeAppCompatData ( IN PVOID  AppCompatData,
IN PVOID  AppCompatSxsData 
)

Definition at line 342 of file appcache.c.

344 {
345  /* Free the input pointers if present */
346  if (AppCompatData) RtlFreeHeap(RtlGetProcessHeap(), 0, AppCompatData);
347  if (AppCompatSxsData) RtlFreeHeap(RtlGetProcessHeap(), 0, AppCompatSxsData);
348 }
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:603

Referenced by BaseCheckRunApp(), and CreateProcessInternalW().

◆ BasepGetVolumeNameForVolumeMountPoint()

BOOL BasepGetVolumeNameForVolumeMountPoint ( IN LPCWSTR  lpszMountPoint,
OUT LPWSTR  lpszVolumeName,
IN DWORD  cchBufferLength,
OUT LPBOOL  IsAMountPoint 
)

Definition at line 398 of file mntpoint.c.

402 {
403  BOOL Ret;
404  UNICODE_STRING MountPoint;
405 
406  /* Assume it's a mount point (likely for non reparse points) */
407  if (IsAMountPoint != NULL)
408  {
409  *IsAMountPoint = 1;
410  }
411 
412  /* Make a string with the mount point name */
413  RtlInitUnicodeString(&MountPoint, lpszMountPoint);
414  /* Not a root path? */
415  if (MountPoint.Buffer[(MountPoint.Length / sizeof(WCHAR)) - 1] != L'\\')
416  {
418  /* Zero output */
419  if (lpszVolumeName != NULL && cchBufferLength >= 1)
420  {
421  lpszVolumeName[0] = UNICODE_NULL;
422  }
423 
424  return FALSE;
425  }
426 
427  /* Does it look like <letter>:\? */
428  if (MountPoint.Length == 3 * sizeof(WCHAR))
429  {
430  /* Try to get volume name for root path */
431  Ret = GetVolumeNameForRoot(lpszMountPoint, lpszVolumeName, cchBufferLength);
432  /* It failed? */
433  if (!Ret)
434  {
435  /* If wasn't a drive letter, so maybe a reparse point? */
436  if (MountPoint.Buffer[1] != ':')
437  {
438  Ret = BasepGetVolumeNameFromReparsePoint(lpszMountPoint, lpszVolumeName, cchBufferLength, IsAMountPoint);
439  }
440  /* It was, so zero output */
441  else if (lpszVolumeName != NULL && cchBufferLength >= 1)
442  {
443  lpszVolumeName[0] = UNICODE_NULL;
444  }
445  }
446  }
447  else
448  {
449  /* Try to get volume name for root path */
450  Ret = GetVolumeNameForRoot(lpszMountPoint, lpszVolumeName, cchBufferLength);
451  /* It failed? */
452  if (!Ret)
453  {
454  /* It was a DOS volume as UNC name, so fail and zero output */
455  if (MountPoint.Length == 14 && MountPoint.Buffer[0] == '\\' && MountPoint.Buffer[1] == '\\' &&
456  (MountPoint.Buffer[2] == '.' || MountPoint.Buffer[2] == '?') && MountPoint.Buffer[3] == L'\\' &&
457  MountPoint.Buffer[5] == ':')
458  {
459  if (lpszVolumeName != NULL && cchBufferLength >= 1)
460  {
461  lpszVolumeName[0] = UNICODE_NULL;
462  }
463  }
464  /* Maybe it's a reparse point? */
465  else
466  {
467  Ret = BasepGetVolumeNameFromReparsePoint(lpszMountPoint, lpszVolumeName, cchBufferLength, IsAMountPoint);
468  }
469  }
470  }
471 
472  return Ret;
473 }
BOOL BasepGetVolumeNameFromReparsePoint(IN LPCWSTR lpszMountPoint, OUT LPWSTR lpszVolumeName, IN DWORD cchBufferLength, OUT LPBOOL IsAMountPoint)
Definition: mntpoint.c:257
#define UNICODE_NULL
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
__wchar_t WCHAR
Definition: xmlstorage.h:180
static const WCHAR L[]
Definition: oid.c:1250
#define STATUS_OBJECT_NAME_INVALID
Definition: udferr_usr.h:148
static BOOL GetVolumeNameForRoot(IN LPCWSTR lpszRootPath, OUT LPWSTR lpszVolumeName, IN DWORD cchBufferLength)
Definition: mntpoint.c:17
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)

Referenced by GetVolumeNameForVolumeMountPointW(), and GetVolumePathNameW().

◆ BasepGetVolumeNameFromReparsePoint()

BOOL BasepGetVolumeNameFromReparsePoint ( IN LPCWSTR  lpszMountPoint,
OUT LPWSTR  lpszVolumeName,
IN DWORD  cchBufferLength,
OUT LPBOOL  IsAMountPoint 
)

Definition at line 257 of file mntpoint.c.

261 {
262  WCHAR Old;
264  HANDLE ReparseHandle;
265  UNICODE_STRING SubstituteName;
266  PREPARSE_DATA_BUFFER ReparseBuffer;
267 
268  /* Try to open the reparse point */
269  ReparseHandle = CreateFileW(lpszMountPoint, 0,
274  /* It failed! */
275  if (ReparseHandle == INVALID_HANDLE_VALUE)
276  {
277  /* Report it's not a mount point (it's not a reparse point) */
278  if (IsAMountPoint != NULL)
279  {
280  *IsAMountPoint = FALSE;
281  }
282 
283  /* And zero output */
284  if (lpszVolumeName != NULL && cchBufferLength >= 1)
285  {
286  lpszVolumeName[0] = UNICODE_NULL;
287  }
288 
289  return FALSE;
290  }
291 
292  /* This is a mount point! */
293  if (IsAMountPoint != NULL)
294  {
295  *IsAMountPoint = TRUE;
296  }
297 
298  /* Prepare a buffer big enough to read its data */
299  ReparseBuffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, MAXIMUM_REPARSE_DATA_BUFFER_SIZE);
300  if (ReparseBuffer == NULL)
301  {
302  CloseHandle(ReparseHandle);
304 
305  /* Zero output */
306  if (lpszVolumeName != NULL && cchBufferLength >= 1)
307  {
308  lpszVolumeName[0] = UNICODE_NULL;
309  }
310 
311  return FALSE;
312  }
313 
314  /* Dump the reparse point data */
315  if (!DeviceIoControl(ReparseHandle, FSCTL_GET_REPARSE_POINT, NULL, 0,
317  NULL))
318  {
319  RtlFreeHeap(RtlGetProcessHeap(), 0, ReparseBuffer);
320  CloseHandle(ReparseHandle);
321 
322  /* Zero output */
323  if (lpszVolumeName != NULL && cchBufferLength >= 1)
324  {
325  lpszVolumeName[0] = UNICODE_NULL;
326  }
327 
328  return FALSE;
329  }
330 
331  /* We no longer need the reparse point */
332  CloseHandle(ReparseHandle);
333 
334  /* We only handle mount points */
335  if (ReparseBuffer->ReparseTag != IO_REPARSE_TAG_MOUNT_POINT)
336  {
337  RtlFreeHeap(RtlGetProcessHeap(), 0, ReparseBuffer);
338 
339  /* Zero output */
340  if (lpszVolumeName != NULL && cchBufferLength >= 1)
341  {
342  lpszVolumeName[0] = UNICODE_NULL;
343  }
344 
345  return FALSE;
346  }
347 
348  /* Do we have enough room for copying substitue name? */
349  if ((ReparseBuffer->MountPointReparseBuffer.SubstituteNameLength + sizeof(UNICODE_NULL)) > cchBufferLength * sizeof(WCHAR))
350  {
351  RtlFreeHeap(RtlGetProcessHeap(), 0, ReparseBuffer);
353 
354  /* Zero output */
355  if (lpszVolumeName != NULL && cchBufferLength >= 1)
356  {
357  lpszVolumeName[0] = UNICODE_NULL;
358  }
359 
360  return FALSE;
361  }
362 
363  /* Copy the link target */
364  RtlCopyMemory(lpszVolumeName,
365  &ReparseBuffer->MountPointReparseBuffer.PathBuffer[ReparseBuffer->MountPointReparseBuffer.SubstituteNameOffset / sizeof(WCHAR)],
366  ReparseBuffer->MountPointReparseBuffer.SubstituteNameLength);
367  /* Make it DOS valid */
368  Old = lpszVolumeName[1];
369  /* We want a root path */
370  lpszVolumeName[1] = L'\\';
371  /* And null terminate obviously */
372  lpszVolumeName[ReparseBuffer->MountPointReparseBuffer.SubstituteNameLength / sizeof(WCHAR)] = UNICODE_NULL;
373 
374  /* Make it a string to easily check it */
375  SubstituteName.Length = ReparseBuffer->MountPointReparseBuffer.SubstituteNameLength;
376  SubstituteName.MaximumLength = SubstituteName.Length;
377  SubstituteName.Buffer = lpszVolumeName;
378 
379  /* No longer need the data? */
380  RtlFreeHeap(RtlGetProcessHeap(), 0, ReparseBuffer);
381 
382  /* Is that a dos volume name with backslash? */
383  if (MOUNTMGR_IS_DOS_VOLUME_NAME_WB(&SubstituteName))
384  {
385  return TRUE;
386  }
387 
388  /* No, so restore previous name and return to the caller */
389  lpszVolumeName[1] = Old;
391  return FALSE;
392 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define CloseHandle
Definition: compat.h:398
USHORT MaximumLength
Definition: env_spec_w32.h:370
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:603
struct _REPARSE_DATA_BUFFER::@300::@303 MountPointReparseBuffer
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define FSCTL_GET_REPARSE_POINT
Definition: winioctl.h:97
#define FILE_SHARE_READ
Definition: compat.h:125
#define IO_REPARSE_TAG_MOUNT_POINT
Definition: iotypes.h:6874
#define UNICODE_NULL
smooth NULL
Definition: ftsmooth.c:416
#define OPEN_EXISTING
Definition: compat.h:426
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:585
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
static const WCHAR L[]
Definition: oid.c:1250
#define MOUNTMGR_IS_DOS_VOLUME_NAME_WB(s)
Definition: mountmgr.h:134
BOOL WINAPI DeviceIoControl(IN HANDLE hDevice, IN DWORD dwIoControlCode, IN LPVOID lpInBuffer OPTIONAL, IN DWORD nInBufferSize OPTIONAL, OUT LPVOID lpOutBuffer OPTIONAL, IN DWORD nOutBufferSize OPTIONAL, OUT LPDWORD lpBytesReturned OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: deviceio.c:136
_In_ FILTER_INFORMATION_CLASS _In_ ULONG _Out_ PULONG BytesReturned
Definition: fltkernel.h:1716
#define CreateFileW
Definition: compat.h:400
#define FILE_FLAG_BACKUP_SEMANTICS
Definition: disk.h:41
#define FILE_FLAG_OPEN_REPARSE_POINT
Definition: disk.h:39
#define MAXIMUM_REPARSE_DATA_BUFFER_SIZE
Definition: iotypes.h:6856
#define ERROR_FILENAME_EXCED_RANGE
Definition: winerror.h:263

Referenced by BasepGetVolumeNameForVolumeMountPoint(), and GetDriveTypeW().

◆ BasepIsRealtimeAllowed()

PVOID WINAPI BasepIsRealtimeAllowed ( IN BOOLEAN  Keep)

Definition at line 653 of file utils.c.

654 {
656  PVOID State;
658 
660  if (!NT_SUCCESS(Status)) return NULL;
661 
662  if (!Keep)
663  {
665  State = (PVOID)TRUE;
666  }
667 
668  return State;
669 }
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
smooth NULL
Definition: ftsmooth.c:416
NTSYSAPI VOID NTAPI RtlReleasePrivilege(_In_ PVOID ReturnedState)
void * PVOID
Definition: retypes.h:9
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
BOOL Privilege(LPTSTR pszPrivilege, BOOL bEnable)
Definition: user_lib.cpp:531
#define SE_INC_BASE_PRIORITY_PRIVILEGE
Definition: security.c:668
Status
Definition: gdiplustypes.h:24
enum State_ State
Definition: pofuncs.h:54
NTSYSAPI NTSTATUS NTAPI RtlAcquirePrivilege(_In_ PULONG Privilege, _In_ ULONG NumPriv, _In_ ULONG Flags, _Out_ PVOID *ReturnedState)
unsigned int ULONG
Definition: retypes.h:1

Referenced by CreateProcessInternalW(), and SetPriorityClass().

◆ BasepLocateExeLdrEntry()

VOID NTAPI BasepLocateExeLdrEntry ( IN PLDR_DATA_TABLE_ENTRY  Entry,
IN PVOID  Context,
OUT BOOLEAN StopEnumeration 
)

Definition at line 156 of file utils.c.

159 {
160  /* Make sure we get Entry, Context and valid StopEnumeration pointer */
161  ASSERT(Entry);
162  ASSERT(Context);
163  ASSERT(StopEnumeration);
164 
165  /* If entry is already found - signal to stop */
166  if (BasepExeLdrEntry)
167  {
168  *StopEnumeration = TRUE;
169  return;
170  }
171 
172  /* Otherwise keep enumerating until we find a match */
173  if (Entry->DllBase == Context)
174  {
175  /* It matches, so remember the ldr entry */
177 
178  /* And stop enumeration */
179  *StopEnumeration = TRUE;
180  }
181 }
#define TRUE
Definition: types.h:120
struct _Entry Entry
Definition: kefuncs.h:640
PLDR_DATA_TABLE_ENTRY BasepExeLdrEntry
Definition: proc.c:25
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
base of all file and directory entries
Definition: entries.h:82

Referenced by BasepComputeProcessPath(), and LoadLibraryExW().

◆ BasepMapFile()

NTSTATUS WINAPI BasepMapFile ( IN LPCWSTR  lpApplicationName,
OUT PHANDLE  hSection,
IN PUNICODE_STRING  ApplicationName 
)

Definition at line 676 of file utils.c.

679 {
680  RTL_RELATIVE_NAME_U RelativeName;
683  HANDLE hFile = NULL;
685 
686  DPRINT("BasepMapFile\n");
687 
688  /* Zero out the Relative Directory */
689  RelativeName.ContainingDirectory = NULL;
690 
691  /* Find the application name */
692  if (!RtlDosPathNameToNtPathName_U(lpApplicationName,
694  NULL,
695  &RelativeName))
696  {
698  }
699 
700  DPRINT("ApplicationName %wZ\n", ApplicationName);
701  DPRINT("RelativeName %wZ\n", &RelativeName.RelativeName);
702 
703  /* Did we get a relative name? */
704  if (RelativeName.RelativeName.Length)
705  {
706  ApplicationName = &RelativeName.RelativeName;
707  }
708 
709  /* Initialize the Object Attributes */
713  RelativeName.ContainingDirectory,
714  NULL);
715 
716  /* Try to open the executable */
720  &IoStatusBlock,
723  if (!NT_SUCCESS(Status))
724  {
725  DPRINT1("Failed to open file\n");
727  return Status;
728  }
729 
730  /* Create a section for this file */
733  NULL,
734  NULL,
735  PAGE_EXECUTE,
736  SEC_IMAGE,
737  hFile);
738  NtClose(hFile);
739 
740  /* Return status */
741  DPRINT("Section: %p for file: %p\n", *hSection, hFile);
742  return Status;
743 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
NTSTATUS NTAPI NtCreateSection(OUT PHANDLE SectionHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, IN PLARGE_INTEGER MaximumSize OPTIONAL, IN ULONG SectionPageProtection OPTIONAL, IN ULONG AllocationAttributes, IN HANDLE FileHandle OPTIONAL)
Definition: section.c:3371
HANDLE ContainingDirectory
Definition: rtltypes.h:1375
LONG NTSTATUS
Definition: precomp.h:26
#define FILE_SHARE_READ
Definition: compat.h:125
#define SECTION_ALL_ACCESS
Definition: nt_native.h:1293
#define FILE_READ_DATA
Definition: nt_native.h:628
smooth NULL
Definition: ftsmooth.c:416
#define PAGE_EXECUTE
Definition: nt_native.h:1306
void DPRINT(...)
Definition: polytest.cpp:61
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
NTSYSAPI NTSTATUS NTAPI NtOpenFile(OUT PHANDLE phFile, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN ULONG ShareMode, IN ULONG OpenMode)
Definition: file.c:3951
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_OBJECT_PATH_NOT_FOUND
Definition: udferr_usr.h:151
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3399
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define FILE_SHARE_DELETE
Definition: nt_native.h:682
#define FILE_EXECUTE
Definition: nt_native.h:642
#define FILE_NON_DIRECTORY_FILE
Definition: constants.h:492
#define SYNCHRONIZE
Definition: nt_native.h:61
_In_ HANDLE hFile
Definition: mswsock.h:90
Status
Definition: gdiplustypes.h:24
PVOID PVOID PWCHAR ApplicationName
Definition: env.c:45
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define DPRINT1
Definition: precomp.h:8
#define FILE_SYNCHRONOUS_IO_NONALERT
Definition: from_kernel.h:31
#define SEC_IMAGE
Definition: mmtypes.h:96
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
UNICODE_STRING RelativeName
Definition: rtltypes.h:1374
_In_ const BITMAPINFO _In_ UINT _In_opt_ HANDLE hSection
Definition: wingdi.h:3217
NTSYSAPI BOOLEAN NTAPI RtlDosPathNameToNtPathName_U(_In_opt_z_ PCWSTR DosPathName, _Out_ PUNICODE_STRING NtPathName, _Out_opt_ PCWSTR *NtFileNamePart, _Out_opt_ PRTL_RELATIVE_NAME_U DirectoryInfo)

◆ BasepProbeForDllManifest()

NTSTATUS NTAPI BasepProbeForDllManifest ( IN PVOID  DllHandle,
IN PCWSTR  FullDllName,
OUT PVOID ActCtx 
)

Definition at line 136 of file actctx.c.

139 {
143  ACTCTXW Context;
144  HANDLE Result;
145 
146  /* Check if activation context parameter is provided */
147  if (!ActCtx)
148  {
149  ASSERT(FALSE);
151  }
152 
153  /* Zero it out */
154  *ActCtx = NULL;
155 
156  /* Check whether the image has manifest resource associated with it */
157  Info.Type = (ULONG_PTR)RT_MANIFEST;
159  Info.Language = 0;
160  if (!(Status = LdrFindResource_U(DllHandle, &Info, 3, &Entry)))
161  {
162  /* Create the activation context */
163  Context.cbSize = sizeof(Context);
164  Context.lpSource = FullDllName;
165  Context.dwFlags = ACTCTX_FLAG_RESOURCE_NAME_VALID | ACTCTX_FLAG_HMODULE_VALID;
166  Context.hModule = DllHandle;
168 
170 
171  /* Store activation context pointer if it was created successfully */
172  if (NT_SUCCESS(Status)) *ActCtx = Result;
173 
174  /* CORE-10843: Windows always returns this since we pass the wrong struct */
176  {
177  /* Fake "Manifest not found" so the load doesn't fail */
178  static int Once;
179  if (Once++)
180  {
181  DPRINT1("HACK: Passed invalid ACTIVATION_CONTEXT_DATA!\n");
182  }
184  }
185  }
186 
187  return Status;
188 }
NTSTATUS NTAPI RtlCreateActivationContext(IN ULONG Flags, IN PACTIVATION_CONTEXT_DATA ActivationContextData, IN ULONG ExtraBytes, IN PVOID NotificationRoutine, IN PVOID NotificationContext, OUT PACTIVATION_CONTEXT *ActCtx)
Definition: actctx.c:5056
struct _Entry Entry
Definition: kefuncs.h:640
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
struct TraceInfo Info
#define ISOLATIONAWARE_MANIFEST_RESOURCE_ID
Definition: winuser.h:622
smooth NULL
Definition: ftsmooth.c:416
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
Definition: pedump.c:457
NTSTATUS NTAPI LdrFindResource_U(_In_ PVOID BaseAddress, _In_ PLDR_RESOURCE_INFO ResourceInfo, _In_ ULONG Level, _Out_ PIMAGE_RESOURCE_DATA_ENTRY *ResourceDataEntry)
_In_ PCWSTR FullDllName
Definition: ldrtypes.h:246
#define STATUS_SXS_INVALID_ACTCTXDATA_FORMAT
Definition: ntstatus.h:1165
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_In_ PCWSTR _Out_ PVOID * ActCtx
Definition: ldrtypes.h:246
static ULONG_PTR
Definition: actctx.c:35
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define STATUS_RESOURCE_DATA_NOT_FOUND
Definition: ntstatus.h:359
Status
Definition: gdiplustypes.h:24
#define DPRINT1
Definition: precomp.h:8
static const GUID LPCWSTR
Definition: actctx.c:37
#define RT_MANIFEST
Definition: winuser.h:620
struct tagContext Context
Definition: acpixf.h:1012
return STATUS_SUCCESS
Definition: btrfs.c:2725
base of all file and directory entries
Definition: entries.h:82

Referenced by DllMain().

◆ BaseProcessStartThunk()

VOID WINAPI BaseProcessStartThunk ( VOID  )

Referenced by BaseInitializeContext().

◆ BaseProcessStartup()

VOID WINAPI BaseProcessStartup ( PPROCESS_START_ROUTINE  lpStartAddress)

Definition at line 450 of file proc.c.

451 {
452  DPRINT("BaseProcessStartup(..) - setting up exception frame.\n");
453 
454  _SEH2_TRY
455  {
456  /* Set our Start Address */
459  &lpStartAddress,
460  sizeof(PPROCESS_START_ROUTINE));
461 
462  /* Call the Start Routine */
463  ExitThread(lpStartAddress());
464  }
466  {
467  /* Get the Exit code from the SEH Handler */
469  {
470  /* Kill the whole process, usually */
472  }
473  else
474  {
475  /* If running inside CSRSS, kill just this thread */
477  }
478  }
479  _SEH2_END;
480 }
#define NtCurrentThread()
VOID WINAPI ExitProcess(IN UINT uExitCode)
Definition: proc.c:1517
_SEH2_TRY
Definition: create.c:4250
LONG WINAPI UnhandledExceptionFilter(IN PEXCEPTION_POINTERS ExceptionInfo)
Definition: except.c:262
#define _SEH2_GetExceptionInformation()
Definition: pseh2_64.h:11
void DPRINT(...)
Definition: polytest.cpp:61
VOID WINAPI ExitThread(IN DWORD uExitCode)
Definition: thread.c:327
NTSTATUS NTAPI NtSetInformationThread(IN HANDLE ThreadHandle, IN THREADINFOCLASS ThreadInformationClass, IN PVOID ThreadInformation, IN ULONG ThreadInformationLength)
Definition: query.c:1967
BOOLEAN BaseRunningInServerProcess
Definition: dllmain.c:20
_SEH2_END
Definition: create.c:4424
UINT(WINAPI * PPROCESS_START_ROUTINE)(VOID)
Definition: kernel32.h:246
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12

◆ BasepUnicodeStringToAnsiSize()

ULONG NTAPI BasepUnicodeStringToAnsiSize ( IN PUNICODE_STRING  String)

Definition at line 49 of file utils.c.

50 {
52 }
NTSYSAPI DWORD WINAPI RtlUnicodeStringToAnsiSize(const UNICODE_STRING *)
static WCHAR String[]
Definition: stringtable.c:55

Referenced by SetFileApisToANSI().

◆ BaseSetLastNTError()

DWORD WINAPI BaseSetLastNTError ( IN NTSTATUS  Status)

Definition at line 166 of file reactos.cpp.

167 {
168  DWORD dwErrCode;
169  dwErrCode = RtlNtStatusToDosError(Status);
170  SetLastError(dwErrCode);
171  return dwErrCode;
172 }
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
Status
Definition: gdiplustypes.h:24
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)

Referenced by ActivateActCtx(), AllocateUserPhysicalPages(), AssignProcessToJobObject(), BaseCreateVDMEnvironment(), Basep8BitStringToDynamicUnicodeString(), Basep8BitStringToStaticUnicodeString(), BasepCopyFileExW(), BasepCreateDefaultTimerQueue(), BasepDoTapeOperation(), BasepGetModuleHandleExParameterValidation(), BasepGetModuleHandleExW(), BasepGetVolumeNameForVolumeMountPoint(), BasepMapFile(), BasePushProcessParameters(), BaseQuerySystemFirmware(), BaseUpdateVDMEntry(), Beep(), BindIoCompletionCallback(), BuildSubSysCommandLine(), CancelDeviceWakeupRequest(), CancelIo(), CancelTimerQueueTimer(), CancelWaitableTimer(), ChangeTimerQueueTimer(), CheckNameLegalDOS8Dot3A(), CheckRemoteDebuggerPresent(), CloseConsoleHandle(), CloseHandle(), ConnectConsole(), ConnectNamedPipe(), ContinueDebugEvent(), CreateConsoleScreenBuffer(), CreateDirectoryExW(), CreateDirectoryW(), CreateFiberEx(), CreateFileMappingW(), CreateFileW(), CreateHardLinkW(), CreateIoCompletionPort(), CreateJobSet(), CreateMailslotW(), CreateMemoryResourceNotification(), CreateNamedPipeW(), CreatePipe(), CreateProcessInternalW(), CreateRemoteThread(), CreateTimerQueue(), CreateTimerQueueTimer(), CreateToolhelp32Snapshot(), DeactivateActCtx(), DebugActiveProcess(), DebugBreakProcess(), DebugSetProcessKillOnExit(), DefineDosDeviceW(), DeleteFileW(), DeleteTimerQueueEx(), DeleteTimerQueueTimer(), DeviceIoControl(), DisableThreadLibraryCalls(), DisconnectNamedPipe(), DosDateTimeToFileTime(), DuplicateConsoleHandle(), DuplicateHandle(), ExpandEnvironmentStringsA(), ExpandEnvironmentStringsW(), FilenameA2W(), FileTimeToDosDateTime(), FindClose(), FindFirstChangeNotificationW(), FindFirstFileA(), FindFirstFileExA(), FindFirstFileExW(), FindFirstStreamW(), FindNextChangeNotification(), FindNextFileA(), FindNextFileW(), FlushConsoleInputBuffer(), FlushFileBuffers(), FlushInstructionCache(), FlushViewOfFile(), FreeConsole(), FreeLibrary(), FreeUserPhysicalPages(), GenerateConsoleCtrlEvent(), GetBinaryTypeA(), GetCompressedFileSizeW(), GetComputerNameFromRegistry(), GetConsoleCP(), GetConsoleCursorInfo(), GetConsoleDisplayMode(), GetConsoleFontInfo(), GetConsoleFontSize(), GetConsoleHandleInformation(), GetConsoleHardwareState(), GetConsoleMode(), GetConsoleOutputCP(), GetConsoleProcessList(), GetConsoleScreenBufferInfo(), GetConsoleSelectionInfo(), GetConsoleWindow(), GetCurrentActCtx(), GetCurrentConsoleFont(), GetCurrentDirectoryA(), GetDevicePowerState(), GetDiskFreeSpaceExW(), GetDiskFreeSpaceW(), GetDllDirectoryA(), GetEnvironmentStringsA(), GetEnvironmentStringsW(), GetEnvironmentVariableA(), GetEnvironmentVariableW(), GetErrorMode(), GetExitCodeProcess(), GetExitCodeThread(), GetFileAttributesByHandle(), GetFileAttributesExW(), GetFileAttributesW(), GetFileInformationByHandle(), GetFileSize(), GetFileSizeEx(), GetFileTime(), GetFileType(), GetFullPathNameA(), GetHandleInformation(), GetLargestConsoleWindowSize(), GetLogicalDrives(), GetLogicalProcessorInformation(), GetLongPathNameA(), GetMailslotInfo(), GetModuleFileNameA(), GetModuleFileNameW(), GetModuleHandleForUnicodeString(), GetNamedPipeHandleStateA(), GetNamedPipeHandleStateW(), GetNamedPipeInfo(), GetNextVDMCommand(), GetNumaAvailableMemoryNode(), GetNumaHighestNodeNumber(), GetNumaNodeProcessorMask(), GetNumaProcessorNode(), GetNumberOfConsoleFonts(), GetNumberOfConsoleInputEvents(), GetNumberOfConsoleMouseButtons(), GetOverlappedResult(), GetPriorityClass(), GetProcAddress(), GetProcessAffinityMask(), GetProcessHandleCount(), GetProcessId(), GetProcessIdOfThread(), GetProcessIoCounters(), GetProcessPriorityBoost(), GetProcessShutdownParameters(), GetProcessTimes(), GetProcessVersion(), GetProcessWorkingSetSizeEx(), GetQueuedCompletionStatus(), GetShortPathNameA(), GetSystemPowerStatus(), GetSystemRegistryQuota(), GetSystemTimeAdjustment(), GetSystemTimes(), GetTempFileNameA(), GetThreadContext(), GetThreadId(), GetThreadIOPendingFlag(), GetThreadPriority(), GetThreadPriorityBoost(), GetThreadSelectorEntry(), GetThreadTimes(), GetTimeZoneInformation(), GetVDMCurrentDirectories(), GetVolumeInformationA(), GetVolumeInformationW(), GetVolumeNameForRoot(), GetVolumeNameForVolumeMountPointA(), GetVolumePathNameA(), GetVolumePathNamesForVolumeNameA(), GetVolumePathNamesForVolumeNameW(), GetWriteWatch(), GlobalFlags(), GlobalFree(), GlobalHandle(), Heap32First(), Heap32ListFirst(), Heap32ListNext(), Heap32Next(), HeapExtend(), HeapQueryInformation(), HeapSetInformation(), HeapSummary(), HeapUsage(), InitializeCriticalSectionAndSpinCount(), IntAddConsoleAlias(), IntAllocConsole(), IntAttachConsole(), InternalAddAtom(), InternalDeleteAtom(), InternalFindAtom(), InternalGetAtomName(), IntExpungeConsoleCommandHistory(), IntFillConsoleOutputCode(), IntGetConsoleAlias(), IntGetConsoleAliases(), IntGetConsoleAliasesLength(), IntGetConsoleAliasExes(), IntGetConsoleAliasExesLength(), IntGetConsoleCommandHistory(), IntGetConsoleCommandHistoryLength(), IntGetConsoleInput(), IntGetConsoleKeyboardLayoutName(), IntGetConsoleTitle(), IntReadConsole(), IntReadConsoleOutput(), IntReadConsoleOutputCode(), IntScrollConsoleScreenBuffer(), IntSetConsoleNumberOfCommands(), IntSetConsoleTitle(), IntWriteConsole(), IntWriteConsoleInput(), IntWriteConsoleOutput(), IntWriteConsoleOutputCode(), InvalidateConsoleDIBits(), IsProcessInJob(), IsWow64Process(), LoadLibraryExW(), LoadModule(), LockFile(), LockFileEx(), MapUserPhysicalPages(), MapUserPhysicalPagesScatter(), MapViewOfFileEx(), Module32FirstW(), Module32NextW(), MoveFileWithProgressW(), NpGetUserNamep(), OpenConsoleW(), OpenFile(), OpenFileMappingW(), OpenProcess(), OpenThread(), PeekNamedPipe(), PostQueuedCompletionStatus(), PrivMoveFileIdentityW(), Process32FirstW(), Process32NextW(), ProcessIdToHandle(), ProcessIdToSessionId(), PulseEvent(), QueryActCtxW(), QueryDosDeviceW(), QueryInformationJobObject(), QueryMemoryResourceNotification(), QueryPerformanceCounter(), QueryPerformanceFrequency(), QueueUserAPC(), QueueUserWorkItem(), ReadDirectoryChangesW(), ReadFile(), ReadFileEx(), ReadProcessMemory(), RegisterConsoleVDM(), RegisterWaitForSingleObject(), RegisterWaitForSingleObjectEx(), ReleaseMutex(), ReleaseSemaphore(), RemoveDirectoryW(), RequestDeviceWakeup(), RequestWakeupLatency(), ResetEvent(), ResetWriteWatch(), ResumeThread(), SearchPathA(), SearchPathW(), SetActiveComputerNameToRegistry(), SetComputerNameToRegistry(), SetConsoleActiveScreenBuffer(), SetConsoleCommandHistoryMode(), SetConsoleCP(), SetConsoleCursor(), SetConsoleCursorInfo(), SetConsoleCursorPosition(), SetConsoleDisplayMode(), SetConsoleFont(), SetConsoleHandleInformation(), SetConsoleHardwareState(), SetConsoleIcon(), SetConsoleMenuClose(), SetConsoleMode(), SetConsoleOutputCP(), SetConsolePalette(), SetConsoleScreenBufferSize(), SetConsoleTextAttribute(), SetConsoleWindowInfo(), SetCurrentDirectoryA(), SetCurrentDirectoryW(), SetDllDirectoryA(), SetEndOfFile(), SetEnvironmentVariableA(), SetEnvironmentVariableW(), SetEvent(), SetFileAttributesByHandle(), SetFileAttributesW(), SetFileInformationByHandle(), SetFilePointer(), SetFilePointerEx(), SetFileShortNameW(), SetFileTime(), SetFileValidData(), SetHandleInformation(), SetInformationJobObject(), SetLocalTime(), SetMailslotInfo(), SetNamedPipeHandleState(), SetPriorityClass(), SetProcessAffinityMask(), SetProcessPriorityBoost(), SetProcessShutdownParameters(), SetProcessWorkingSetSizeEx(), SetSystemPowerState(), SetSystemTime(), SetSystemTimeAdjustment(), SetThreadAffinityMask(), SetThreadContext(), SetThreadExecutionState(), SetThreadIdealProcessor(), SetThreadPriority(), SetThreadPriorityBoost(), SetTimerQueueTimer(), SetTimeZoneInformation(), SetVDMCurrentDirectories(), SetVolumeLabelW(), SetWaitableTimer(), SignalObjectAndWait(), SuspendThread(), SystemTimeToFileTime(), TerminateJobObject(), TerminateProcess(), TerminateThread(), Thread32First(), Thread32Next(), TlsAlloc(), TlsFree(), TlsGetValue(), TlsSetValue(), TransactNamedPipe(), UnlockFile(), UnlockFileEx(), UnmapViewOfFile(), UnregisterWait(), UnregisterWaitEx(), VerifyConsoleIoHandle(), VirtualAllocEx(), VirtualFreeEx(), VirtualLock(), VirtualProtectEx(), VirtualQueryEx(), VirtualUnlock(), WaitForDebugEvent(), WaitForMultipleObjectsEx(), WaitForSingleObjectEx(), WaitNamedPipeW(), Wow64DisableWow64FsRedirection(), Wow64EnableWow64FsRedirection(), Wow64RevertWow64FsRedirection(), WriteFile(), WriteFileEx(), WriteProcessMemory(), and ZombifyActCtx().

◆ BaseThreadStartupThunk()

VOID WINAPI BaseThreadStartupThunk ( VOID  )

Referenced by BaseInitializeContext().

◆ FilenameA2W()

PWCHAR FilenameA2W ( LPCSTR  NameA,
BOOL  alloc 
)

Definition at line 22 of file fileinfo.c.

23 {
26  PUNICODE_STRING pstrW;
28 
29  //ASSERT(NtCurrentTeb()->StaticUnicodeString.Buffer == NtCurrentTeb()->StaticUnicodeBuffer);
30  ASSERT(NtCurrentTeb()->StaticUnicodeString.MaximumLength == sizeof(NtCurrentTeb()->StaticUnicodeBuffer));
31 
32  RtlInitAnsiString(&str, NameA);
33  pstrW = alloc ? &strW : &NtCurrentTeb()->StaticUnicodeString;
34 
35  if (bIsFileApiAnsi)
37  else
39 
40  if (NT_SUCCESS(Status))
41  return pstrW->Buffer;
42 
45  else
47 
48  return NULL;
49 }
BOOL bIsFileApiAnsi
Definition: utils.c:25
LONG NTSTATUS
Definition: precomp.h:26
NTSYSAPI VOID NTAPI RtlInitAnsiString(PANSI_STRING DestinationString, PCSZ SourceString)
WCHAR strW[12]
Definition: clipboard.c:2029
const WCHAR * str
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define SetLastError(x)
Definition: compat.h:409
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
NTSYSAPI NTSTATUS NTAPI RtlOemStringToUnicodeString(PUNICODE_STRING DestinationString, PCOEM_STRING SourceString, BOOLEAN AllocateDestinationString)
Status
Definition: gdiplustypes.h:24
FORCEINLINE struct _TEB * NtCurrentTeb(VOID)
Definition: psfuncs.h:420
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:61
NTSYSAPI NTSTATUS NTAPI RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString, PANSI_STRING SourceString, BOOLEAN AllocateDestinationString)
#define alloc
Definition: rosglue.h:13
#define ERROR_FILENAME_EXCED_RANGE
Definition: winerror.h:263

Referenced by CreateFileA(), GetCompressedFileSizeA(), GetFileAttributesA(), GetFileAttributesExA(), SetFileAttributesA(), and SetFileShortNameA().

◆ FilenameU2A_FitOrFail()

DWORD FilenameU2A_FitOrFail ( LPSTR  DestA,
INT  destLen,
PUNICODE_STRING  SourceU 
)

Definition at line 60 of file fileinfo.c.

65 {
66  DWORD ret;
67 
68  /* destLen should never exceed MAX_PATH */
69  if (destLen > MAX_PATH) destLen = MAX_PATH;
70 
72  /* ret incl. nullchar */
73 
74  if (DestA && (INT)ret <= destLen)
75  {
77 
78  str.Buffer = DestA;
79  str.MaximumLength = (USHORT)destLen;
80 
81 
82  if (bIsFileApiAnsi)
84  else
86 
87  ret = str.Length; /* SUCCESS: length without terminating 0 */
88  }
89 
90  return ret;
91 }
NTSYSAPI DWORD WINAPI RtlUnicodeStringToAnsiSize(const UNICODE_STRING *)
BOOL bIsFileApiAnsi
Definition: utils.c:25
NTSYSAPI DWORD WINAPI RtlUnicodeStringToOemSize(const UNICODE_STRING *)
int32_t INT
Definition: typedefs.h:56
const WCHAR * str
NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToAnsiString(PANSI_STRING DestinationString, PUNICODE_STRING SourceString, BOOLEAN AllocateDestinationString)
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToOemString(POEM_STRING DestinationString, PCUNICODE_STRING SourceString, BOOLEAN AllocateDestinationString)
unsigned short USHORT
Definition: pedump.c:61

Referenced by FilenameW2A_FitOrFail().

◆ FilenameW2A_FitOrFail()

DWORD FilenameW2A_FitOrFail ( LPSTR  DestA,
INT  destLen,
LPCWSTR  SourceW,
INT  sourceLen 
)

Definition at line 102 of file fileinfo.c.

108 {
110 
111  if (sourceLen < 0) sourceLen = wcslen(SourceW) + 1;
112 
113  strW.Buffer = (PWCHAR)SourceW;
114  strW.MaximumLength = sourceLen * sizeof(WCHAR);
115  strW.Length = strW.MaximumLength - sizeof(WCHAR);
116 
117  return FilenameU2A_FitOrFail(DestA, destLen, &strW);
118 }
uint16_t * PWCHAR
Definition: typedefs.h:54
DWORD FilenameU2A_FitOrFail(LPSTR DestA, INT destLen, PUNICODE_STRING SourceU)
Definition: fileinfo.c:60
WCHAR strW[12]
Definition: clipboard.c:2029
__wchar_t WCHAR
Definition: xmlstorage.h:180
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

Referenced by GetTempPathA().

◆ FilenameW2A_N()

DWORD FilenameW2A_N ( LPSTR  dest,
INT  destlen,
LPCWSTR  src,
INT  srclen 
)

Definition at line 150 of file fileinfo.c.

156 {
157  DWORD ret;
158 
159  if (srclen < 0) srclen = wcslen( src ) + 1;
160 
161  if (bIsFileApiAnsi)
162  RtlUnicodeToMultiByteN( dest, destlen, &ret, (LPWSTR) src, srclen * sizeof(WCHAR));
163  else
164  RtlUnicodeToOemN( dest, destlen, &ret, (LPWSTR) src, srclen * sizeof(WCHAR) );
165 
166  if (ret) dest[ret-1]=0;
167 
168  return ret;
169 }
BOOL bIsFileApiAnsi
Definition: utils.c:25
NTSYSAPI NTSTATUS NTAPI RtlUnicodeToOemN(PCHAR OemString, ULONG OemSize, PULONG ResultSize, PCWCH UnicodeString, ULONG UnicodeSize)
__wchar_t WCHAR
Definition: xmlstorage.h:180
static DWORD LPDWORD LPCSTR DWORD srclen
Definition: directory.c:51
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
NTSYSAPI NTSTATUS NTAPI RtlUnicodeToMultiByteN(PCHAR MbString, ULONG MbSize, PULONG ResultSize, PCWCH UnicodeString, ULONG UnicodeSize)
GLenum src
Definition: glext.h:6340
static char * dest
Definition: rtl.c:135
WCHAR * LPWSTR
Definition: xmlstorage.h:184
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

◆ GetTeb()

PTEB GetTeb ( VOID  )

Definition at line 400 of file thread.c.

401 {
402  return NtCurrentTeb();
403 }
FORCEINLINE struct _TEB * NtCurrentTeb(VOID)
Definition: psfuncs.h:420

◆ InitCommandLines()

VOID WINAPI InitCommandLines ( VOID  )

Definition at line 872 of file proc.c.

873 {
875 
876  /* Read the UNICODE_STRING from the PEB */
877  BaseUnicodeCommandLine = NtCurrentPeb()->ProcessParameters->CommandLine;
878 
879  /* Convert to ANSI_STRING for the *A callers */
882  TRUE);
883  if (!NT_SUCCESS(Status)) RtlInitEmptyAnsiString(&BaseAnsiCommandLine, 0, 0);
884 }
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
ANSI_STRING BaseAnsiCommandLine
Definition: proc.c:22
NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToAnsiString(PANSI_STRING DestinationString, PUNICODE_STRING SourceString, BOOLEAN AllocateDestinationString)
UNICODE_STRING BaseUnicodeCommandLine
Definition: proc.c:21
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
Status
Definition: gdiplustypes.h:24
#define NtCurrentPeb()
Definition: FLS.c:19

Referenced by DllMain().

◆ IntGetCodePageEntry()

PCODEPAGE_ENTRY FASTCALL IntGetCodePageEntry ( UINT  CodePage)

Definition at line 196 of file nls.c.

197 {
198  CHAR SectionName[40];
200  HANDLE SectionHandle = INVALID_HANDLE_VALUE, FileHandle;
201  PBYTE SectionMapping;
203  ANSI_STRING AnsiName;
205  WCHAR FileName[MAX_PATH + 1];
206  UINT FileNamePos;
207  PCODEPAGE_ENTRY CodePageEntry;
208  if (CodePage == CP_ACP)
209  {
210  return &AnsiCodePage;
211  }
212  else if (CodePage == CP_OEMCP)
213  {
214  return &OemCodePage;
215  }
216  else if (CodePage == CP_THREAD_ACP)
217  {
219  LOCALE_IDEFAULTANSICODEPAGE | LOCALE_RETURN_NUMBER,
220  (WCHAR *)&CodePage,
221  sizeof(CodePage) / sizeof(WCHAR)))
222  {
223  /* Last error is set by GetLocaleInfoW. */
224  return NULL;
225  }
226  if (CodePage == 0)
227  return &AnsiCodePage;
228  }
229  else if (CodePage == CP_MACCP)
230  {
232  LOCALE_IDEFAULTMACCODEPAGE | LOCALE_RETURN_NUMBER,
233  (WCHAR *)&CodePage,
234  sizeof(CodePage) / sizeof(WCHAR)))
235  {
236  /* Last error is set by GetLocaleInfoW. */
237  return NULL;
238  }
239  }
240 
241  /* Try searching for loaded page first. */
242  CodePageEntry = IntGetLoadedCodePageEntry(CodePage);
243  if (CodePageEntry != NULL)
244  {
245  return CodePageEntry;
246  }
247 
248  /*
249  * Yes, we really want to lock here. Otherwise it can happen that
250  * two parallel requests will try to get the entry for the same
251  * code page and we would load it twice.
252  */
254 
255  /* Generate the section name. */
256  if (!GetNlsSectionName(CodePage,
257  10,
258  0,
259  "\\Nls\\NlsSectionCP",
260  SectionName,
261  sizeof(SectionName)))
262  {
264  return NULL;
265  }
266 
267  RtlInitAnsiString(&AnsiName, SectionName);
269 
271 
272  /* Try to open the section first */
274 
275  /* If the section doesn't exist, try to create it. */
276  if (Status == STATUS_UNSUCCESSFUL ||
279  {
280  FileNamePos = GetSystemDirectoryW(FileName, MAX_PATH);
281  if (GetCPFileNameFromRegistry(CodePage,
282  FileName + FileNamePos + 1,
283  MAX_PATH - FileNamePos - 1))
284  {
285  FileName[FileNamePos] = L'\\';
286  FileName[MAX_PATH] = 0;
290  NULL,
292  0,
293  NULL);
294 
295  Status = NtCreateSection(&SectionHandle,
298  NULL,
300  SEC_COMMIT,
301  FileHandle);
302 
303  /* HACK: Check if another process was faster
304  * and already created this section. See bug 3626 for details */
306  {
307  /* Close the file then */
309 
310  /* And open the section */
311  Status = NtOpenSection(&SectionHandle,
314  }
315  }
316  }
318 
319  if (!NT_SUCCESS(Status))
320  {
322  return NULL;
323  }
324 
325  SectionMapping = MapViewOfFile(SectionHandle, FILE_MAP_READ, 0, 0, 0);
326  if (SectionMapping == NULL)
327  {
328  NtClose(SectionHandle);
330  return NULL;
331  }
332 
333  CodePageEntry = HeapAlloc(GetProcessHeap(), 0, sizeof(CODEPAGE_ENTRY));
334  if (CodePageEntry == NULL)
335  {
336  NtClose(SectionHandle);
338  return NULL;
339  }
340 
341  CodePageEntry->CodePage = CodePage;
342  CodePageEntry->SectionHandle = SectionHandle;
343  CodePageEntry->SectionMapping = SectionMapping;
344 
345  RtlInitCodePageTable((PUSHORT)SectionMapping, &CodePageEntry->CodePageTable);
346 
347  /* Insert the new entry to list and unlock. Uff. */
348  InsertTailList(&CodePageListHead, &CodePageEntry->Entry);
350 
351  return CodePageEntry;
352 }
#define STATUS_OBJECT_NAME_COLLISION
Definition: udferr_usr.h:150
#define FILE_GENERIC_READ
Definition: nt_native.h:653
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define LOCALE_IDEFAULTANSICODEPAGE
Definition: winnls.h:38
static CODEPAGE_ENTRY AnsiCodePage
Definition: nls.c:46
#define TRUE
Definition: types.h:120
#define MapViewOfFile
Definition: compat.h:402
NTSTATUS NTAPI NtCreateSection(OUT PHANDLE SectionHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, IN PLARGE_INTEGER MaximumSize OPTIONAL, IN ULONG SectionPageProtection OPTIONAL, IN ULONG AllocationAttributes, IN HANDLE FileHandle OPTIONAL)
Definition: section.c:3371
static LIST_ENTRY CodePageListHead
Definition: nls.c:45
#define CP_ACP
Definition: compat.h:99
char CHAR
Definition: xmlstorage.h:175
LONG NTSTATUS
Definition: precomp.h:26
IN PDCB IN POEM_STRING IN PUNICODE_STRING UnicodeName
Definition: fatprocs.h:1294
#define LOCALE_IDEFAULTMACCODEPAGE
Definition: winnls.h:39
NTSYSAPI NTSTATUS NTAPI RtlEnterCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
#define InsertTailList(ListHead, Entry)
PCODEPAGE_ENTRY FASTCALL IntGetLoadedCodePageEntry(UINT CodePage)
Definition: nls.c:160
#define FILE_SHARE_READ
Definition: compat.h:125
NTSYSAPI VOID NTAPI RtlInitAnsiString(PANSI_STRING DestinationString, PCSZ SourceString)
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
Definition: lang.c:1098
HANDLE FileHandle
Definition: stats.c:38
#define SEC_COMMIT
Definition: mmtypes.h:99
NTSYSAPI NTSTATUS NTAPI RtlLeaveCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
UINT CodePage
Definition: kernel32.h:65
NTSTATUS NTAPI NtOpenSection(OUT PHANDLE SectionHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes)
Definition: section.c:3499
smooth NULL
Definition: ftsmooth.c:416
#define FILE_MAP_READ
Definition: compat.h:427
#define OPEN_EXISTING
Definition: compat.h:426
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
LIST_ENTRY Entry
Definition: kernel32.h:64
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define MAX_PATH
Definition: compat.h:26
#define LOCALE_SYSTEM_DEFAULT
#define STATUS_OBJECT_PATH_NOT_FOUND
Definition: udferr_usr.h:151
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3399
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
static CODEPAGE_ENTRY OemCodePage
Definition: nls.c:47
static RTL_CRITICAL_SECTION CodePageListLock
Definition: nls.c:48
static const WCHAR L[]
Definition: oid.c:1250
#define SECTION_MAP_READ
Definition: compat.h:128
VOID NTAPI RtlInitCodePageTable(IN PUSHORT TableBase, OUT PCPTABLEINFO CodePageTable)
Definition: nls.c:155
BOOL WINAPI GetCPFileNameFromRegistry(UINT CodePage, LPWSTR FileName, ULONG FileNameSize)
Definition: nls.c:1392
BOOL WINAPI GetNlsSectionName(UINT CodePage, UINT Base, ULONG Unknown, LPSTR BaseName, LPSTR Result, ULONG ResultSize)
Definition: nls.c:1347
Status
Definition: gdiplustypes.h:24
#define STATUS_OBJECT_NAME_NOT_FOUND
Definition: udferr_usr.h:149
Definition: kernel32.h:62
NTSYSAPI NTSTATUS NTAPI RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString, PANSI_STRING SourceString, BOOLEAN AllocateDestinationString)
UINT WINAPI GetSystemDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2312
unsigned int UINT
Definition: ndis.h:50
#define PAGE_READONLY
Definition: compat.h:127
PBYTE SectionMapping
Definition: kernel32.h:67
#define CreateFileW
Definition: compat.h:400
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
HANDLE SectionHandle
Definition: kernel32.h:66
#define CP_THREAD_ACP
Definition: winnls.h:230
BYTE * PBYTE
Definition: pedump.c:66
#define CP_OEMCP
Definition: winnls.h:228
unsigned short * PUSHORT
Definition: retypes.h:2
CPTABLEINFO CodePageTable
Definition: kernel32.h:68
LCID WINAPI GetThreadLocale(void)
Definition: lang.c:1449
#define CP_MACCP
Definition: winnls.h:229

Referenced by GetCPInfo(), GetCPInfoExW(), IntMultiByteToWideCharCP(), IntWideCharToMultiByteCP(), and IsDBCSLeadByteEx().

◆ IsShimInfrastructureDisabled()

BOOLEAN WINAPI IsShimInfrastructureDisabled ( VOID  )

Definition at line 37 of file appcache.c.

38 {
43  UNICODE_STRING OptionKey = RTL_CONSTANT_STRING(L"\\Registry\\MACHINE\\System\\CurrentControlSet\\Control\\SafeBoot\\Option");
44  UNICODE_STRING AppCompatKey = RTL_CONSTANT_STRING(L"\\Registry\\MACHINE\\System\\CurrentControlSet\\Control\\Session Manager\\AppCompatibility");
45  UNICODE_STRING PolicyKey = RTL_CONSTANT_STRING(L"\\Registry\\MACHINE\\Software\\Policies\\Microsoft\\Windows\\AppCompat");
46  UNICODE_STRING OptionValue = RTL_CONSTANT_STRING(L"OptionValue");
47  UNICODE_STRING DisableAppCompat = RTL_CONSTANT_STRING(L"DisableAppCompat");
48  UNICODE_STRING DisableEngine = RTL_CONSTANT_STRING(L"DisableEngine");
52 
53  /*
54  * This is a TROOLEAN, -1 means we haven't yet figured it out.
55  * 0 means shims are enabled, and 1 means shims are disabled!
56  */
57  if (g_ShimsDisabled == -1)
58  {
59  ULONG DisableShims = FALSE;
60 
61  /* Open the safe mode key */
62  Status = NtOpenKey(&KeyHandle, KEY_QUERY_VALUE, &OptionKeyAttributes);
63  if (NT_SUCCESS(Status))
64  {
65  /* Check if this is safemode */
67  &OptionValue,
69  &KeyInfo,
70  sizeof(KeyInfo),
71  &ResultLength);
73  if ((NT_SUCCESS(Status)) &&
74  (KeyInfo.Type == REG_DWORD) &&
75  (KeyInfo.DataLength == sizeof(ULONG)) &&
76  (KeyInfo.Data[0] != FALSE))
77  {
78  /* It is, so disable shims! */
79  DisableShims = TRUE;
80  }
81  }
82 
83  if (!DisableShims)
84  {
85  /* Open the app compatibility engine settings key */
87  if (NT_SUCCESS(Status))
88  {
89  /* Check if the app compat engine is turned off */
91  &DisableAppCompat,
93  &KeyInfo,
94  sizeof(KeyInfo),
95  &ResultLength);
97  if ((NT_SUCCESS(Status)) &&
98  (KeyInfo.Type == REG_DWORD) &&
99  (KeyInfo.DataLength == sizeof(ULONG)) &&
100  (KeyInfo.Data[0] == TRUE))
101  {
102  /* It is, so disable shims! */
103  DisableShims = TRUE;
104  }
105  }
106  }
107  if (!DisableShims)
108  {
109  /* Finally, open the app compatibility policy key */
110  Status = NtOpenKey(&KeyHandle, KEY_QUERY_VALUE, &PolicyKeyAttributes);
111  if (NT_SUCCESS(Status))
112  {
113  /* Check if the system policy disables app compat */
115  &DisableEngine,
117  &KeyInfo,
118  sizeof(KeyInfo),
119  &ResultLength);
121  if ((NT_SUCCESS(Status)) &&
122  (KeyInfo.Type == REG_DWORD) &&
123  (KeyInfo.DataLength == sizeof(ULONG)) &&
124  (KeyInfo.Data[0] == TRUE))
125  {
126  /* It does, so disable shims! */
127  DisableShims = TRUE;
128  }
129  }
130  }
131  g_ShimsDisabled = DisableShims;
132  }
133 
134  /* Return if shims are disabled or not ("Enabled == 1" means disabled!) */
135  return g_ShimsDisabled ? TRUE : FALSE;
136 }
IN CINT OUT PVOID IN ULONG OUT PULONG ResultLength
Definition: conport.c:47
#define TRUE
Definition: types.h:120
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4693
OBJECT_ATTRIBUTES AppCompatKeyAttributes
Definition: shimdbg.c:228
LONG NTSTATUS
Definition: precomp.h:26
NTSYSAPI NTSTATUS NTAPI NtQueryValueKey(IN HANDLE KeyHandle, IN PUNICODE_STRING ValueName, IN KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass, IN PVOID KeyValueInformation, IN ULONG Length, IN PULONG ResultLength)
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3399
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
static const WCHAR L[]
Definition: oid.c:1250
ULONG g_ShimsDisabled
Definition: appcache.c:18
Status
Definition: gdiplustypes.h:24
#define RTL_CONSTANT_OBJECT_ATTRIBUTES(n, a)
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
NTSYSAPI NTSTATUS NTAPI NtOpenKey(OUT PHANDLE KeyHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes)
Definition: ntapi.c:336
unsigned int ULONG
Definition: retypes.h:1
#define REG_DWORD
Definition: sdbapi.c:596
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14

Referenced by BasepCheckBadapp().

◆ IsThisARootDirectory()

BOOL IsThisARootDirectory ( IN HANDLE  VolumeHandle,
IN PUNICODE_STRING  NtPathName 
)

Definition at line 154 of file volume.c.

156 {
159  struct
160  {
163  } FileNameInfo;
164 
165  /* If we have a handle, query the name */
166  if (VolumeHandle)
167  {
168  Status = NtQueryInformationFile(VolumeHandle, &IoStatusBlock, &FileNameInfo, sizeof(FileNameInfo), FileNameInformation);
169  if (!NT_SUCCESS(Status))
170  {
171  return FALSE;
172  }
173 
174  /* Check we properly end with a \ */
175  if (FileNameInfo.FileName[FileNameInfo.FileNameLength / sizeof(WCHAR) - 1] != L'\\')
176  {
177  return FALSE;
178  }
179  }
180 
181  /* If we have a path */
182  if (NtPathName != NULL)
183  {
184  HANDLE LinkHandle;
185  WCHAR Buffer[512];
189 
190  NtPathName->Length -= sizeof(WCHAR);
191 
194  NULL, NULL);
195 
196  /* Try to see whether that's a symbolic name */
198  NtPathName->Length += sizeof(WCHAR);
199  if (!NT_SUCCESS(Status))
200  {
201  return FALSE;
202  }
203 
204  /* If so, query the target */
206  LinkTarget.Length = 0;
207  LinkTarget.MaximumLength = sizeof(Buffer);
208 
210  NtClose(LinkHandle);
211  /* A root directory (NtName) is a symbolic link */
212  if (!NT_SUCCESS(Status))
213  {
214  return FALSE;
215  }
216  }
217 
218  return TRUE;
219 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define TRUE
Definition: types.h:120
USHORT MaximumLength
Definition: env_spec_w32.h:370
struct _FILE_NAME_INFORMATION FILE_NAME_INFORMATION
LONG NTSTATUS
Definition: precomp.h:26
_Inout_ PUNICODE_STRING LinkTarget
Definition: zwfuncs.h:292
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define MAX_PATH
Definition: compat.h:26
_Must_inspect_result_ _Out_ PHANDLE VolumeHandle
Definition: fltkernel.h:2284
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3399
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
static const WCHAR L[]
Definition: oid.c:1250
_In_ ULONG _In_ BATTERY_QUERY_INFORMATION_LEVEL _In_ LONG _In_ ULONG _Out_ PULONG ReturnedLength
Definition: batclass.h:187
NTSTATUS NTAPI NtQueryInformationFile(HANDLE hFile, PIO_STATUS_BLOCK io, PVOID ptr, ULONG len, FILE_INFORMATION_CLASS FileInformationClass)
Status
Definition: gdiplustypes.h:24
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
unsigned int ULONG
Definition: retypes.h:1
#define SYMBOLIC_LINK_QUERY
Definition: nt_native.h:1265
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34

Referenced by GetDriveTypeW(), GetVolumeInformationW(), and SetVolumeLabelW().

Variable Documentation

◆ BaseCachedSysInfo

SYSTEM_BASIC_INFORMATION BaseCachedSysInfo

◆ BaseDefaultPath

UNICODE_STRING BaseDefaultPath

Definition at line 21 of file path.c.

Referenced by BasepComputeProcessPath(), and DllMain().

◆ BaseDefaultPathAppend

UNICODE_STRING BaseDefaultPathAppend

Definition at line 21 of file path.c.

Referenced by DllMain().

◆ BaseDllDirectory

◆ BaseDllDirectoryLock

◆ BaseNamedObjectDirectory

HANDLE BaseNamedObjectDirectory

Definition at line 24 of file dllmain.c.

Referenced by BaseGetNamedObjectDirectory().

◆ Basep8BitStringToUnicodeSize

PRTL_COUNT_STRINGA Basep8BitStringToUnicodeSize

Definition at line 29 of file utils.c.

Referenced by SetFileApisToANSI(), and SetFileApisToOEM().

◆ Basep8BitStringToUnicodeString

◆ BasepAppCertDllsList

LIST_ENTRY BasepAppCertDllsList

Definition at line 28 of file proc.c.

Referenced by BasepIsProcessAllowed(), and DllMain().

◆ BasepExeLdrEntry

PLDR_DATA_TABLE_ENTRY BasepExeLdrEntry

Definition at line 25 of file proc.c.

Referenced by BasepComputeProcessPath(), BasepLocateExeLdrEntry(), and LoadLibraryExW().

◆ BasepUnicodeStringTo8BitSize

PRTL_COUNT_STRING BasepUnicodeStringTo8BitSize

Definition at line 28 of file utils.c.

Referenced by GetDllDirectoryA(), SetFileApisToANSI(), and SetFileApisToOEM().

◆ BasepUnicodeStringTo8BitString

◆ BaseRunningInServerProcess

BOOLEAN BaseRunningInServerProcess

◆ BaseStaticServerData

PBASE_STATIC_SERVER_DATA BaseStaticServerData

Definition at line 19 of file dllmain.c.

◆ BaseWindowsDirectory

UNICODE_STRING BaseWindowsDirectory

◆ BaseWindowsSystemDirectory

UNICODE_STRING BaseWindowsSystemDirectory

Definition at line 20 of file path.c.

Referenced by DllMain(), GetSystemDirectoryA(), and GetSystemDirectoryW().

◆ bIsFileApiAnsi

◆ gcsAppCert

Definition at line 29 of file proc.c.

Referenced by BasepIsProcessAllowed(), BasepReplaceProcessThreadTokens(), and DllMain().

◆ GlobalTopLevelExceptionFilter

LPTOP_LEVEL_EXCEPTION_FILTER GlobalTopLevelExceptionFilter

Definition at line 158 of file except.c.

Referenced by DllMain(), SetUnhandledExceptionFilter(), and UnhandledExceptionFilter().

◆ hCurrentModule

HMODULE hCurrentModule

Definition at line 25 of file dllmain.c.

Referenced by DllMain(), and GetLocalisedText().

◆ lpParameter

◆ UserWaitForInputIdleRoutine

WaitForInputIdleType UserWaitForInputIdleRoutine

Definition at line 20 of file proc.c.

Referenced by LoadModule(), RegisterWaitForInputIdle(), and WinExec().