ReactOS 0.4.16-dev-125-g798ea90
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 DWORD(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 (_In_ HANDLE hProcess, _In_opt_ SIZE_T StackCommit, _In_opt_ SIZE_T StackReserve, _Out_ PINITIAL_TEB InitialTeb)
 
VOID WINAPI BaseFreeThreadStack (_In_ HANDLE hProcess, _In_ 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 (_In_ LPTHREAD_START_ROUTINE lpStartAddress, _In_ LPVOID lpParameter)
 
DECLSPEC_NORETURN VOID WINAPI BaseFiberStartup (VOID)
 
DECLSPEC_NORETURN VOID WINAPI BaseProcessStartup (_In_ 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
 
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

WDF_DMA_PROFILE profile   206

Definition at line 12 of file kernel32.h.

Referenced by AssociateColorProfileWithDeviceA(), AssociateColorProfileWithDeviceW(), CloseColorProfile(), ColorContext_InitializeFromFilename(), ColorContext_InitializeFromMemory(), compile_pixel_shader9(), CicBridge::ConfigureGeneral(), CicBridge::ConfigureRegisterWord(), ConvertColorNameToIndex(), ConvertIndexToColorName(), CreateColorTransformW(), CreateMultiProfileTransform(), d3dx9_fragment_linker_LinkPixelShader(), d3dx9_fragment_linker_LinkShader(), d3dx9_fragment_linker_LinkVertexShader(), D3DXCompileShader(), D3DXCompileShaderFromFileA(), D3DXCompileShaderFromFileW(), D3DXCompileShaderFromResourceA(), D3DXCompileShaderFromResourceW(), DECLARE_INTERFACE_(), DelOld(), DisassociateColorProfileFromDeviceA(), DisassociateColorProfileFromDeviceW(), EnumTfInputProcessorProfiles_Next(), fw_policy_get_CurrentProfile(), fw_policy_GetProfileByType(), fwpolicy2_get_CurrentProfileTypes(), get_active_textservice(), GetColorProfileElement(), GetColorProfileElementTag(), GetColorProfileFromHandle(), GetColorProfileHeader(), GetCountColorProfileElements(), GetNamedProfileInfo(), GetPS2ColorRenderingDictionary(), GetPS2ColorRenderingIntent(), GetPS2ColorSpaceArray(), GetStandardColorSpaceProfileA(), GetStandardColorSpaceProfileW(), header_from_file(), InputProcessorProfiles_GetActiveLanguageProfile(), InsNew(), InstallColorProfileA(), InstallColorProfileW(), is_firewall_enabled(), IsColorProfileTagPresent(), IsColorProfileValid(), load_profile(), MAPILogon(), MAPILogonEx(), next_LanguageProfile(), OpenColorProfileA(), OpenColorProfileW(), set_firewall(), set_profile_device_key(), SetColorProfileElement(), SetColorProfileElementReference(), SetColorProfileElementSize(), SetColorProfileHeader(), SetStandardColorSpaceProfileA(), SetStandardColorSpaceProfileW(), test_AssociateColorProfileWithDeviceA(), test_CreateMultiProfileTransform(), test_EnumLanguageProfiles(), test_GetColorProfileElement(), test_GetColorProfileElementTag(), test_GetColorProfileFromHandle(), test_GetColorProfileHeader(), test_GetCountColorProfileElements(), test_IsColorProfileTagPresent(), test_OpenColorProfileA(), test_OpenColorProfileW(), test_profile_manager_interfaces(), test_SetColorProfileElement(), test_SetColorProfileHeader(), test_SetICMProfileA(), test_SetICMProfileW(), test_wmreader_interfaces(), test_wmsyncreader_interfaces(), UninstallColorProfileA(), UninstallColorProfileW(), WMProfileManager_LoadProfileByData(), WMProfileManager_SaveProfile(), WMWriter_SetProfile(), xsltApplyStylesheetInternal(), xsltApplyStylesheetUser(), and xsltRunStylesheetUser().

◆ 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 ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:102
#define SetLastError(x)
Definition: compat.h:752
#define __FUNCTION__
Definition: types.h:116

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 376 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 370 of file kernel32.h.

◆ PCODEPAGE_ENTRY

◆ PPROCESS_START_ROUTINE

typedef DWORD(WINAPI * PPROCESS_START_ROUTINE) (VOID)

Definition at line 249 of file kernel32.h.

◆ PRTL_CONVERT_STRING

Definition at line 275 of file kernel32.h.

◆ PRTL_CONVERT_STRINGA

Definition at line 281 of file kernel32.h.

◆ PRTL_COUNT_STRING

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

Definition at line 279 of file kernel32.h.

◆ PRTL_COUNT_STRINGA

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

Definition at line 285 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 381 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 114 of file kernel32.h.

Enumeration Type Documentation

◆ _BASE_CURRENT_DIR_PLACEMENT

Enumerator
BaseCurrentDirPlacementInvalid 
BaseCurrentDirPlacementDefault 
BaseCurrentDirPlacementSafe 
BaseCurrentDirPlacementMax 

Definition at line 91 of file kernel32.h.

92{
@ BaseCurrentDirPlacementSafe
Definition: kernel32.h:95
@ BaseCurrentDirPlacementMax
Definition: kernel32.h:96
@ BaseCurrentDirPlacementInvalid
Definition: kernel32.h:93
@ BaseCurrentDirPlacementDefault
Definition: kernel32.h:94
enum _BASE_CURRENT_DIR_PLACEMENT BASE_CURRENT_DIR_PLACEMENT

◆ _BASE_SEARCH_PATH_TYPE

Enumerator
BaseSearchPathInvalid 
BaseSearchPathDll 
BaseSearchPathApp 
BaseSearchPathDefault 
BaseSearchPathEnv 
BaseSearchPathCurrent 
BaseSearchPathMax 

Definition at line 80 of file kernel32.h.

81{
enum _BASE_SEARCH_PATH_TYPE BASE_SEARCH_PATH_TYPE
enum _BASE_SEARCH_PATH_TYPE * PBASE_SEARCH_PATH_TYPE
@ BaseSearchPathMax
Definition: kernel32.h:88
@ BaseSearchPathDll
Definition: kernel32.h:83
@ BaseSearchPathInvalid
Definition: kernel32.h:82
@ BaseSearchPathApp
Definition: kernel32.h:84
@ BaseSearchPathDefault
Definition: kernel32.h:85
@ BaseSearchPathCurrent
Definition: kernel32.h:87
@ BaseSearchPathEnv
Definition: kernel32.h:86

Function Documentation

◆ BaseComputeProcessDllPath()

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

Definition at line 420 of file path.c.

422{
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 CHAR PartialInfoBuffer[FIELD_OFFSET(KEY_VALUE_PARTIAL_INFORMATION, Data) + sizeof(ULONG)];
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 PartialInfoBuffer,
465 sizeof(PartialInfoBuffer),
466 &ResultLength);
467 if (NT_SUCCESS(Status))
468 {
469 /* Read the value if the size is OK */
470 if (ResultLength == sizeof(PartialInfoBuffer))
471 {
472 PKEY_VALUE_PARTIAL_INFORMATION PartialInfo = (PKEY_VALUE_PARTIAL_INFORMATION)PartialInfoBuffer;
473 CurrentDirPlacement = *(PULONG)PartialInfo->Data;
474 }
475 }
476
477 /* Close the handle */
479
480 /* Validate the registry value */
481 if ((CurrentDirPlacement <= BaseCurrentDirPlacementInvalid) ||
482 (CurrentDirPlacement >= BaseCurrentDirPlacementMax))
483 {
484 /* Default to safe search */
485 CurrentDirPlacement = BaseCurrentDirPlacementSafe;
486 }
487 }
488
489 /* Update the placement and read the old one */
491 CurrentDirPlacement,
493 if (OldCurrentDirPlacement != BaseCurrentDirPlacementInvalid)
494 {
495 /* If there already was a placement, use it */
496 CurrentDirPlacement = OldCurrentDirPlacement;
497 }
498 }
499
500 /* Check if the placement is invalid or not set */
501 if ((CurrentDirPlacement <= BaseCurrentDirPlacementInvalid) ||
502 (CurrentDirPlacement >= BaseCurrentDirPlacementMax))
503 {
504 /* Default to safe search */
505 CurrentDirPlacement = BaseCurrentDirPlacementSafe;
506 }
507
508 /* Compute the process path using either normal or safe search */
510 FullPath,
512
513 /* Return dll path */
514 return DllPath;
515}
LONG NTSTATUS
Definition: precomp.h:26
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
RTL_CRITICAL_SECTION BaseDllDirectoryLock
Definition: dllmain.c:32
BASE_SEARCH_PATH_TYPE BaseDllOrderNoCurrent[BaseSearchPathMax]
Definition: path.c:63
BASE_CURRENT_DIR_PLACEMENT BasepDllCurrentDirPlacement
Definition: path.c:81
LPWSTR WINAPI BasepComputeProcessPath(IN PBASE_SEARCH_PATH_TYPE PathOrder, IN LPWSTR AppName, IN LPVOID Environment)
Definition: path.c:116
UNICODE_STRING BaseDllDirectory
Definition: path.c:21
BASE_SEARCH_PATH_TYPE BaseDllOrderCurrent[BaseCurrentDirPlacementMax][BaseSearchPathMax]
Definition: path.c:36
Status
Definition: gdiplustypes.h:25
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define InterlockedCompareExchange
Definition: interlocked.h:104
PVOID PVOID PWCHAR PVOID Environment
Definition: env.c:47
static const char const char * DllPath
Definition: image.c:34
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4715
NTSYSAPI NTSTATUS NTAPI RtlEnterCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
NTSYSAPI NTSTATUS NTAPI RtlLeaveCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
NTSYSAPI NTSTATUS NTAPI NtOpenKey(OUT PHANDLE KeyHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes)
Definition: ntapi.c:336
@ KeyValuePartialInformation
Definition: nt_native.h:1182
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 KEY_QUERY_VALUE
Definition: nt_native.h:1016
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3402
struct _KEY_VALUE_PARTIAL_INFORMATION * PKEY_VALUE_PARTIAL_INFORMATION
#define RTL_CONSTANT_OBJECT_ATTRIBUTES(n, a)
#define L(x)
Definition: ntvdm.h:50
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
uint32_t * PULONG
Definition: typedefs.h:59
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
int32_t * PLONG
Definition: typedefs.h:58
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG _Out_ PULONG ResultLength
Definition: wdfdevice.h:3776
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
Definition: wdfdevice.h:2699
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING ValueName
Definition: wdfregistry.h:243
WCHAR * LPWSTR
Definition: xmlstorage.h:184
char CHAR
Definition: xmlstorage.h:175

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 BaseProcessOrder[BaseSearchPathMax]
Definition: path.c:72
BASE_SEARCH_PATH_TYPE BaseProcessOrderNoCurrent[BaseSearchPathMax]
Definition: path.c:54
BOOL WINAPI NeedCurrentDirectoryForExePathW(IN LPCWSTR ExeName)
Definition: path.c:957
#define DPRINT
Definition: sndvol32.h:73

Referenced by CreateProcessInternalW().

◆ BaseCreateStack()

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

Definition at line 354 of file utils.c.

359{
361 PIMAGE_NT_HEADERS Headers;
363 BOOLEAN UseGuard;
364 ULONG PageSize, AllocationGranularity, Dummy;
365 SIZE_T MinimumStackCommit, GuardPageSize;
366
367 DPRINT("BaseCreateStack(hProcess: 0x%p, Max: 0x%lx, Current: 0x%lx)\n",
368 hProcess, StackReserve, StackCommit);
369
370 /* Read page size */
372 AllocationGranularity = BaseStaticServerData->SysInfo.AllocationGranularity;
373
374 /* Get the Image Headers */
375 Headers = RtlImageNtHeader(NtCurrentPeb()->ImageBaseAddress);
376 if (!Headers) return STATUS_INVALID_IMAGE_FORMAT;
377
378 if (StackReserve == 0)
379 StackReserve = Headers->OptionalHeader.SizeOfStackReserve;
380
381 if (StackCommit == 0)
382 {
383 StackCommit = Headers->OptionalHeader.SizeOfStackCommit;
384 }
385 /* Check if the commit is higher than the reserve */
386 else if (StackCommit >= StackReserve)
387 {
388 /* Grow the reserve beyond the commit, up to 1MB alignment */
389 StackReserve = ROUND_UP(StackCommit, 1024 * 1024);
390 }
391
392 /* Align everything to Page Size */
393 StackCommit = ROUND_UP(StackCommit, PageSize);
394 StackReserve = ROUND_UP(StackReserve, AllocationGranularity);
395
396 MinimumStackCommit = NtCurrentPeb()->MinimumStackCommit;
397 if ((MinimumStackCommit != 0) && (StackCommit < MinimumStackCommit))
398 {
399 StackCommit = MinimumStackCommit;
400 }
401
402 /* Check if the commit is higher than the reserve */
403 if (StackCommit >= StackReserve)
404 {
405 /* Grow the reserve beyond the commit, up to 1MB alignment */
406 StackReserve = ROUND_UP(StackCommit, 1024 * 1024);
407 }
408
409 /* Align everything to Page Size */
410 StackCommit = ROUND_UP(StackCommit, PageSize);
411 StackReserve = ROUND_UP(StackReserve, AllocationGranularity);
412
413 /* Reserve memory for the stack */
414 Stack = 0;
416 (PVOID*)&Stack,
417 0,
418 &StackReserve,
421 if (!NT_SUCCESS(Status))
422 {
423 DPRINT1("Failure to reserve stack: %lx\n", Status);
424 return Status;
425 }
426
427 /* Now set up some basic Initial TEB Parameters */
428 InitialTeb->AllocatedStackBase = (PVOID)Stack;
429 InitialTeb->StackBase = (PVOID)(Stack + StackReserve);
430 InitialTeb->PreviousStackBase = NULL;
431 InitialTeb->PreviousStackLimit = NULL;
432
433 /* Update the stack position */
434 Stack += StackReserve - StackCommit;
435
436 /* Check if we can add a guard page */
437 if (StackReserve >= StackCommit + PageSize)
438 {
439 Stack -= PageSize;
440 StackCommit += PageSize;
441 UseGuard = TRUE;
442 }
443 else
444 {
445 UseGuard = FALSE;
446 }
447
448 /* Allocate memory for the stack */
450 (PVOID*)&Stack,
451 0,
452 &StackCommit,
455 if (!NT_SUCCESS(Status))
456 {
457 DPRINT1("Failure to allocate stack\n");
458 GuardPageSize = 0;
459 NtFreeVirtualMemory(hProcess, (PVOID*)&Stack, &GuardPageSize, MEM_RELEASE);
460 return Status;
461 }
462
463 /* Now set the current Stack Limit */
464 InitialTeb->StackLimit = (PVOID)Stack;
465
466 /* Create a guard page if needed */
467 if (UseGuard)
468 {
469 GuardPageSize = PageSize;
471 (PVOID*)&Stack,
472 &GuardPageSize,
474 &Dummy);
475 if (!NT_SUCCESS(Status))
476 {
477 DPRINT1("Failure to set guard page\n");
478 return Status;
479 }
480
481 /* Update the Stack Limit keeping in mind the Guard Page */
482 InitialTeb->StackLimit = (PVOID)((ULONG_PTR)InitialTeb->StackLimit +
483 GuardPageSize);
484 }
485
486 /* We are done! */
487 return STATUS_SUCCESS;
488}
#define NtCurrentPeb()
Definition: FLS.c:22
unsigned char BOOLEAN
#define DPRINT1
Definition: precomp.h:8
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define RtlImageNtHeader
Definition: compat.h:806
PBASE_STATIC_SERVER_DATA BaseStaticServerData
Definition: dllmain.c:19
#define ROUND_UP(n, align)
Definition: eventvwr.h:34
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:71
#define PAGE_READWRITE
Definition: nt_native.h:1304
#define MEM_RESERVE
Definition: nt_native.h:1314
#define MEM_RELEASE
Definition: nt_native.h:1316
#define MEM_COMMIT
Definition: nt_native.h:1313
#define PAGE_GUARD
Definition: nt_native.h:1310
NTSTATUS NTAPI NtFreeVirtualMemory(IN HANDLE ProcessHandle, IN PVOID *UBaseAddress, IN PSIZE_T URegionSize, IN ULONG FreeType)
Definition: virtual.c:5230
NTSTATUS NTAPI NtProtectVirtualMemory(IN HANDLE ProcessHandle, IN OUT PVOID *UnsafeBaseAddress, IN OUT SIZE_T *UnsafeNumberOfBytesToProtect, IN ULONG NewAccessProtection, OUT PULONG UnsafeOldAccessProtection)
Definition: virtual.c:3111
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:4492
#define STATUS_INVALID_IMAGE_FORMAT
Definition: ntstatus.h:359
#define STATUS_SUCCESS
Definition: shellext.h:65
SYSTEM_BASIC_INFORMATION SysInfo
Definition: base.h:130
IMAGE_OPTIONAL_HEADER32 OptionalHeader
Definition: ntddk_ex.h:184
void * PVOID
Definition: typedefs.h:50
ULONG_PTR SIZE_T
Definition: typedefs.h:80
uint32_t ULONG_PTR
Definition: typedefs.h:65
_In_ WDFREQUEST _In_ PIO_STACK_LOCATION Stack
Definition: wdfrequest.h:639

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

◆ BaseDllInitializeMemoryManager()

VOID NTAPI BaseDllInitializeMemoryManager ( VOID  )

Definition at line 26 of file heapmem.c.

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

Referenced by DllMain().

◆ BaseFiberStartup()

DECLSPEC_NORETURN VOID WINAPI BaseFiberStartup ( VOID  )

Referenced by BaseInitializeContext().

◆ 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 */
343 DPRINT("Attributes: %lx, RootDirectory: %p, SecurityDescriptor: %p\n",
345 return ObjectAttributes;
346}
WCHAR RootDirectory[MAX_PATH]
Definition: format.c:74
HANDLE WINAPI BaseGetNamedObjectDirectory(VOID)
Definition: utils.c:63
#define OBJ_OPENIF
Definition: winternl.h:229
#define OBJ_INHERIT
Definition: winternl.h:225
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
_Must_inspect_result_ _In_ WDFDMAENABLER _In_ _In_opt_ PWDF_OBJECT_ATTRIBUTES Attributes
_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:191
_In_ PVOID _Out_opt_ PULONG_PTR _Outptr_opt_ PCUNICODE_STRING * ObjectName
Definition: cmfuncs.h:64

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 INFINITE
Definition: serial.h:102
static ULONG Timeout
Definition: ping.c:61

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

◆ BaseFreeThreadStack()

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

Definition at line 495 of file utils.c.

498{
499 SIZE_T Dummy = 0;
500
501 /* Free the Stack */
503 &InitialTeb->AllocatedStackBase,
504 &Dummy,
506}

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 {
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
136
137Quickie:
138
140
141 if (Token)
142 {
145 &Token,
146 sizeof(Token));
147
148 NtClose(Token);
149 }
150
152}
@ ThreadImpersonationToken
Definition: compat.h:940
HANDLE BaseNamedObjectDirectory
Definition: dllmain.c:24
UNICODE_STRING Restricted
Definition: utils.c:24
NTSYSAPI void WINAPI RtlReleasePebLock(void)
Definition: libsupp.c:84
NTSYSAPI void WINAPI RtlAcquirePebLock(void)
Definition: libsupp.c:74
#define NtCurrentTeb
#define DIRECTORY_CREATE_OBJECT
Definition: nt_native.h:1256
#define DIRECTORY_QUERY
Definition: nt_native.h:1254
#define DIRECTORY_TRAVERSE
Definition: nt_native.h:1255
#define DIRECTORY_CREATE_SUBDIRECTORY
Definition: nt_native.h:1257
NTSTATUS NTAPI NtSetInformationThread(IN HANDLE ThreadHandle, IN THREADINFOCLASS ThreadInformationClass, IN PVOID ThreadInformation, IN ULONG ThreadInformationLength)
Definition: query.c:2018
NTSTATUS NTAPI NtOpenThreadToken(_In_ HANDLE ThreadHandle, _In_ ACCESS_MASK DesiredAccess, _In_ BOOLEAN OpenAsSelf, _Out_ PHANDLE TokenHandle)
Opens a token that is tied to a thread handle.
Definition: token.c:2474
NTSTATUS NTAPI NtOpenDirectoryObject(OUT PHANDLE DirectoryHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes)
Definition: obdir.c:393
UNICODE_STRING NamedObjectDirectory
Definition: base.h:123
#define TOKEN_IMPERSONATE
Definition: setypes.h:927
#define NtCurrentThread()

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 513 of file utils.c.

518{
519#ifdef _M_IX86
520 ULONG ContextFlags;
521 DPRINT("BaseInitializeContext: %p\n", Context);
522
523 /* Setup the Initial Win32 Thread Context */
524 Context->Eax = (ULONG)StartAddress;
525 Context->Ebx = (ULONG)Parameter;
526 Context->Esp = (ULONG)StackAddress;
527 /* The other registers are undefined */
528
529 /* Setup the Segments */
530 Context->SegFs = KGDT_R3_TEB;
531 Context->SegEs = KGDT_R3_DATA;
532 Context->SegDs = KGDT_R3_DATA;
533 Context->SegCs = KGDT_R3_CODE;
534 Context->SegSs = KGDT_R3_DATA;
535 Context->SegGs = 0;
536
537 /* Set the Context Flags */
538 ContextFlags = Context->ContextFlags;
539 Context->ContextFlags = CONTEXT_FULL;
540
541 /* Give it some room for the Parameter */
542 Context->Esp -= sizeof(PVOID);
543
544 /* Set the EFLAGS */
545 Context->EFlags = 0x3000; /* IOPL 3 */
546
547 /* What kind of context is being created? */
548 if (ContextType == 1)
549 {
550 /* For Threads */
552 }
553 else if (ContextType == 2)
554 {
555 /* This is a fiber: make space for the return address */
556 Context->Esp -= sizeof(PVOID);
557 *((PVOID*)Context->Esp) = BaseFiberStartup;
558
559 /* Is FPU state required? */
560 Context->ContextFlags |= ContextFlags;
561 if ((ContextFlags & CONTEXT_FLOATING_POINT) == CONTEXT_FLOATING_POINT)
562 {
563 /* Set an initial state */
564 Context->FloatSave.ControlWord = 0x27F;
565 Context->FloatSave.StatusWord = 0;
566 Context->FloatSave.TagWord = 0xFFFF;
567 Context->FloatSave.ErrorOffset = 0;
568 Context->FloatSave.ErrorSelector = 0;
569 Context->FloatSave.DataOffset = 0;
570 Context->FloatSave.DataSelector = 0;
571 if (SharedUserData->ProcessorFeatures[PF_XMMI_INSTRUCTIONS_AVAILABLE])
572 Context->Dr6 = 0x1F80;
573 }
574 }
575 else
576 {
577 /* For first thread in a Process */
579 }
580
581#elif defined(_M_AMD64)
582 DPRINT("BaseInitializeContext: %p\n", Context);
583 ASSERT(((ULONG_PTR)StackAddress & 15) == 0);
584
585 RtlZeroMemory(Context, sizeof(*Context));
586
587 /* Setup the Initial Win32 Thread Context */
588 Context->Rcx = (ULONG_PTR)StartAddress;
590 Context->Rsp = (ULONG_PTR)StackAddress - 5 * sizeof(PVOID);
591
592 /* Setup the Segments */
599
600 /* Set the EFLAGS */
601 Context->EFlags = 0x3000 | EFLAGS_INTERRUPT_MASK; /* IOPL 3 */
602
603 /* Set MXCSR */
604 Context->MxCsr = INITIAL_MXCSR;
605
606 if (ContextType == 1) /* For Threads */
607 {
609 }
610 else if (ContextType == 2) /* For Fibers */
611 {
613 }
614 else /* For first thread in a Process */
615 {
617 }
618
619 /* Set the Context Flags */
620 Context->ContextFlags = CONTEXT_FULL;
621#elif defined(_M_ARM)
622 DPRINT("BaseInitializeContext: %p\n", Context);
623
624 // FIXME: check if this is correct!
625 /* Setup the Initial Win32 Thread Context */
626 Context->R0 = (ULONG_PTR)StartAddress;
628 Context->Sp = (ULONG_PTR)StackAddress;
629
630 if (ContextType == 1) /* For Threads */
631 {
633 }
634 else if (ContextType == 2) /* For Fibers */
635 {
637 }
638 else /* For first thread in a Process */
639 {
641 }
642
643 /* Set the Context Flags */
644 Context->ContextFlags = CONTEXT_FULL;
645
646 /* Give it some room for the Parameter */
647 Context->Sp -= sizeof(PVOID);
648#else
649#warning Unknown architecture
652#endif
653}
#define EFLAGS_INTERRUPT_MASK
Definition: SystemCall.c:11
#define UNIMPLEMENTED
Definition: debug.h:118
DECLSPEC_NORETURN VOID WINAPI BaseProcessStartup(_In_ PPROCESS_START_ROUTINE lpStartAddress)
Definition: proc.c:451
DECLSPEC_NORETURN VOID WINAPI BaseThreadStartup(_In_ LPTHREAD_START_ROUTINE lpStartAddress, _In_ LPVOID lpParameter)
Definition: thread.c:56
#define ULONG_PTR
Definition: config.h:101
_Must_inspect_result_ _In_ FLT_CONTEXT_TYPE ContextType
Definition: fltkernel.h:1443
NTSYSAPI void WINAPI DbgBreakPoint(void)
VOID WINAPI BaseThreadStartupThunk(VOID)
DECLSPEC_NORETURN VOID WINAPI BaseFiberStartup(VOID)
VOID WINAPI BaseProcessStartThunk(VOID)
#define ASSERT(a)
Definition: mode.c:44
#define KGDT64_R3_CODE
Definition: ketypes.h:137
#define KGDT64_R3_DATA
Definition: ketypes.h:136
#define KGDT64_R3_CMTEB
Definition: ketypes.h:139
#define RPL_MASK
Definition: ketypes.h:130
#define KGDT_R3_DATA
Definition: ketypes.h:126
#define KGDT_R3_CODE
Definition: ketypes.h:125
#define KGDT_R3_TEB
Definition: ketypes.h:129
#define CONTEXT_FLOATING_POINT
Definition: nt_native.h:1372
#define CONTEXT_FULL
Definition: nt_native.h:1375
#define SharedUserData
#define INITIAL_MXCSR
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define PF_XMMI_INSTRUCTIONS_AVAILABLE
Definition: ketypes.h:130
_Inout_opt_ PVOID Parameter
Definition: rtltypes.h:336

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 BaseDotComSuffixName
Definition: vdm.c:58
static UNICODE_STRING BaseDotExeSuffixName
Definition: vdm.c:60
static UNICODE_STRING BaseDotPifSuffixName
Definition: vdm.c:59
NTSYSAPI BOOLEAN NTAPI RtlEqualUnicodeString(PUNICODE_STRING String1, PUNICODE_STRING String2, BOOLEAN CaseInSensitive)
#define BINARY_TYPE_EXE
Definition: vdm.h:35
#define BINARY_TYPE_PIF
Definition: vdm.h:37
#define BINARY_TYPE_COM
Definition: vdm.h:36
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2433
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by CreateProcessInternalW().

◆ BaseMarkFileForDelete()

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

Definition at line 876 of file utils.c.

878{
880 FILE_BASIC_INFORMATION FileBasicInfo;
881 FILE_DISPOSITION_INFORMATION FileDispositionInfo;
882
883 /* If no attributes were given, get them */
884 if (!FileAttributes)
885 {
886 FileBasicInfo.FileAttributes = 0;
889 &FileBasicInfo,
890 sizeof(FileBasicInfo),
892 FileAttributes = FileBasicInfo.FileAttributes;
893 }
894
895 /* If file is marked as RO, reset its attributes */
897 {
898 RtlZeroMemory(&FileBasicInfo, sizeof(FileBasicInfo));
902 &FileBasicInfo,
903 sizeof(FileBasicInfo),
905 }
906
907 /* Finally, mark the file for deletion */
908 FileDispositionInfo.DeleteFile = TRUE;
911 &FileDispositionInfo,
912 sizeof(FileDispositionInfo),
914}
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
_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:1236
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE FileHandle
Definition: fltkernel.h:1231
@ FileBasicInformation
Definition: from_kernel.h:65
@ FileDispositionInformation
Definition: from_kernel.h:74
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define FILE_ATTRIBUTE_READONLY
Definition: nt_native.h:702
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:3096
NTSYSAPI NTSTATUS NTAPI NtQueryInformationFile(IN HANDLE hFile, OUT PIO_STATUS_BLOCK pIoStatusBlock, OUT PVOID FileInformationBuffer, IN ULONG FileInformationBufferLength, IN FILE_INFORMATION_CLASS FileInfoClass)

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}
PRTL_CONVERT_STRING Basep8BitStringToUnicodeString
Definition: utils.c:26
@ AnsiString
Definition: dnslib.h:19
NTSYSAPI NTSTATUS WINAPI RtlInitAnsiStringEx(PANSI_STRING, PCSZ)
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:167
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
#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()

◆ 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
128Quickie:
129 /* Failure or success path, return to caller and free on failure */
130 if (ContextInfo.hActCtx) RtlReleaseActivationContext(ContextInfo.hActCtx);
131 return Status;
132}
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:590
NTSYSAPI void WINAPI RtlReleaseActivationContext(HANDLE)
Definition: actctx.c:5415
NTSYSAPI NTSTATUS WINAPI RtlQueryInformationActivationContext(ULONG, HANDLE, PVOID, ULONG, PVOID, SIZE_T, SIZE_T *)
Definition: actctx.c:5605
#define RTL_QUERY_ACTIVATION_CONTEXT_FLAG_USE_ACTIVE_ACTIVATION_CONTEXT
Definition: rtltypes.h:116
#define STATUS_INVALID_PARAMETER_4
Definition: ntstatus.h:478
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
#define STATUS_INVALID_PARAMETER_1
Definition: ntstatus.h:475
_In_ WDFREQUEST _In_opt_ PFN_WDF_REQUEST_COMPLETION_ROUTINE _In_opt_ __drv_aliasesMem WDFCONTEXT CompletionContext
Definition: wdfrequest.h:898
_In_ WDFREQUEST _In_opt_ PFN_WDF_REQUEST_COMPLETION_ROUTINE CompletionRoutine
Definition: wdfrequest.h:895
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170

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
275 &AnsiTemp,
276 TRUE)))
277 {
278 *UnicodeString = UnicodeTemp.Buffer;
279 }
280 else
281 {
283 }
284}
NTSYSAPI NTSTATUS NTAPI RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString, PANSI_STRING SourceString, BOOLEAN AllocateDestinationString)
NTSYSAPI VOID NTAPI RtlInitAnsiString(PANSI_STRING DestinationString, PCSZ SourceString)

Referenced by CreateProcessInternalA().

◆ BasepAnsiStringToUnicodeSize()

ULONG NTAPI BasepAnsiStringToUnicodeSize ( IN PANSI_STRING  String)

Definition at line 56 of file utils.c.

57{
59}
#define RtlAnsiStringToUnicodeSize(STRING)
Definition: nt_native.h:404

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 374 of file appcache.c.

383{
385 ULONG Reason = 0;
386
387 /* Is shimming enabled by group policy? */
389 {
390 /* Nothing to worry about */
392 }
393 else
394 {
395 /* It is, check if we know about this app */
399 &Reason))
400 {
403 {
405 }
406 }
407 }
408
409 /* Return caller the status */
410 return Status;
411}
BOOL WINAPI BaseCheckAppcompatCache(_In_ PCWSTR ApplicationName, _In_ HANDLE FileHandle, _In_opt_ PCWSTR Environment, _Out_opt_ PULONG pdwReason)
Definition: appcache.c:229
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:295
BOOLEAN WINAPI IsShimInfrastructureDisabled(VOID)
Definition: appcache.c:37
PVOID PVOID PWCHAR PVOID USHORT ExeType
Definition: env.c:47
PVOID PVOID PWCHAR PVOID USHORT PULONG Reason
Definition: env.c:47
PVOID PVOID PWCHAR PVOID USHORT PULONG PVOID * SdbQueryAppCompatData
Definition: env.c:48
PVOID PVOID PWCHAR PVOID USHORT PULONG PVOID PULONG PVOID PULONG SxsDataSize
Definition: env.c:48
PVOID PVOID PWCHAR PVOID USHORT PULONG PVOID PULONG PVOID * SxsData
Definition: env.c:48
PVOID PVOID PWCHAR PVOID USHORT PULONG PVOID PULONG PVOID PULONG PULONG FusionFlags
Definition: env.c:49
PVOID PVOID PWCHAR PVOID USHORT PULONG PVOID PULONG SdbQueryAppCompatDataSize
Definition: env.c:48
PVOID PVOID PWCHAR ApplicationName
Definition: env.c:47
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145

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 921 of file utils.c.

927{
929
930 /* Validate that there's a name */
932 {
933 /* Validate that the required output parameters are there */
934 if ((InJob) && (NewToken) && (JobHandle))
935 {
936 /* Do the work (one day...) */
937 DPRINT("BasepCheckWinSaferRestrictions is UNIMPLEMENTED\n");
939 }
940 else
941 {
942 /* Act as if SEH hit this */
944 }
945 }
946 else
947 {
948 /* Input is invalid */
950 }
951
952 /* Return the status */
953 return Status;
954}
#define STATUS_ACCESS_VIOLATION
Definition: ntstatus.h:242
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135

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_ GUID _In_ PVOID ValueData
Definition: hubbusif.h:312

◆ 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,
224 NULL,
227 NULL);
228 if (INVALID_HANDLE_VALUE != FileHandleSource)
229 {
230 errCode = NtQueryInformationFile(FileHandleSource,
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,
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}
#define WARN(fmt,...)
Definition: precomp.h:61
#define OPEN_EXISTING
Definition: compat.h:775
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define GENERIC_READ
Definition: compat.h:135
#define CreateFileW
Definition: compat.h:741
#define FILE_SHARE_READ
Definition: compat.h:136
static NTSTATUS CopyLoop(HANDLE FileHandleSource, HANDLE FileHandleDest, LARGE_INTEGER SourceFileSize, LPPROGRESS_ROUTINE lpProgressRoutine, LPVOID lpData, BOOL *pbCancel, BOOL *KeepDest)
Definition: copy.c:26
static NTSTATUS SetLastWriteTime(HANDLE FileHandle, LARGE_INTEGER LastWriteTime)
Definition: copy.c:166
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
BOOL WINAPI SetFileAttributesW(LPCWSTR lpFileName, DWORD dwFileAttributes)
Definition: fileinfo.c:794
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLdouble GLdouble t
Definition: gl.h:2047
#define CREATE_ALWAYS
Definition: disk.h:72
#define FILE_FLAG_NO_BUFFERING
Definition: disk.h:45
#define CREATE_NEW
Definition: disk.h:69
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define GENERIC_WRITE
Definition: nt_native.h:90
#define FileStandardInformation
Definition: propsheet.cpp:61
#define TRACE(s)
Definition: solgame.cpp:4
LARGE_INTEGER LastWriteTime
Definition: nt_native.h:941
LONGLONG QuadPart
Definition: typedefs.h:114
static const char * SystemError(DWORD err)
Definition: vfdcmd.c:3368
DWORD WINAPI GetLastError(void)
Definition: except.c:1042

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:608

Referenced by BasepIoCompletion(), and ReadDirectoryChangesW().

◆ BasepFreeAppCompatData()

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

Definition at line 444 of file appcache.c.

446{
447 /* Free the input pointers if present */
448 if (AppCompatData) RtlFreeHeap(RtlGetProcessHeap(), 0, AppCompatData);
449 if (AppCompatSxsData) RtlFreeHeap(RtlGetProcessHeap(), 0, AppCompatSxsData);
450}

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}
static BOOL GetVolumeNameForRoot(IN LPCWSTR lpszRootPath, OUT LPWSTR lpszVolumeName, IN DWORD cchBufferLength)
Definition: mntpoint.c:17
BOOL BasepGetVolumeNameFromReparsePoint(IN LPCWSTR lpszMountPoint, OUT LPWSTR lpszVolumeName, IN DWORD cchBufferLength, OUT LPBOOL IsAMountPoint)
Definition: mntpoint.c:257
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define UNICODE_NULL
#define STATUS_OBJECT_NAME_INVALID
Definition: udferr_usr.h:148

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_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
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
#define CloseHandle
Definition: compat.h:739
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define FILE_FLAG_OPEN_REPARSE_POINT
Definition: disk.h:39
#define FILE_FLAG_BACKUP_SEMANTICS
Definition: disk.h:41
#define MOUNTMGR_IS_DOS_VOLUME_NAME_WB(s)
Definition: mountmgr.h:154
#define FSCTL_GET_REPARSE_POINT
Definition: winioctl.h:746
struct _REPARSE_DATA_BUFFER::@312::@315 MountPointReparseBuffer
USHORT MaximumLength
Definition: env_spec_w32.h:370
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_ ULONG _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_opt_ PULONG_PTR BytesReturned
Definition: wdfiotarget.h:1052
#define MAXIMUM_REPARSE_DATA_BUFFER_SIZE
Definition: iotypes.h:7213
#define IO_REPARSE_TAG_MOUNT_POINT
Definition: iotypes.h:7231

Referenced by BasepGetVolumeNameForVolumeMountPoint(), and GetDriveTypeW().

◆ BasepIsRealtimeAllowed()

PVOID WINAPI BasepIsRealtimeAllowed ( IN BOOLEAN  Keep)

Definition at line 665 of file utils.c.

666{
668 PVOID State;
670
672 if (!NT_SUCCESS(Status)) return NULL;
673
674 if (!Keep)
675 {
677 State = (PVOID)TRUE;
678 }
679
680 return State;
681}
#define SE_INC_BASE_PRIORITY_PRIVILEGE
Definition: security.c:668
NTSYSAPI NTSTATUS NTAPI RtlAcquirePrivilege(_In_ PULONG Privilege, _In_ ULONG NumPriv, _In_ ULONG Flags, _Out_ PVOID *ReturnedState)
NTSYSAPI VOID NTAPI RtlReleasePrivilege(_In_ PVOID ReturnedState)
BOOL Privilege(LPTSTR pszPrivilege, BOOL bEnable)
Definition: user_lib.cpp:531

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);
163 ASSERT(StopEnumeration);
164
165 /* If entry is already found - signal to stop */
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}
PLDR_DATA_TABLE_ENTRY BasepExeLdrEntry
Definition: proc.c:25
base of all file and directory entries
Definition: entries.h:83

Referenced by BasepComputeProcessPath(), and LoadLibraryExW().

◆ BasepMapFile()

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

Definition at line 688 of file utils.c.

691{
692 RTL_RELATIVE_NAME_U RelativeName;
695 HANDLE hFile = NULL;
697
698 DPRINT("BasepMapFile\n");
699
700 /* Zero out the Relative Directory */
701 RelativeName.ContainingDirectory = NULL;
702
703 /* Find the application name */
704 if (!RtlDosPathNameToNtPathName_U(lpApplicationName,
706 NULL,
707 &RelativeName))
708 {
710 }
711
712 DPRINT("ApplicationName %wZ\n", ApplicationName);
713 DPRINT("RelativeName %wZ\n", &RelativeName.RelativeName);
714
715 /* Did we get a relative name? */
716 if (RelativeName.RelativeName.Length)
717 {
718 ApplicationName = &RelativeName.RelativeName;
719 }
720
721 /* Initialize the Object Attributes */
725 RelativeName.ContainingDirectory,
726 NULL);
727
728 /* Try to open the executable */
735 if (!NT_SUCCESS(Status))
736 {
737 DPRINT1("Failed to open file\n");
739 return Status;
740 }
741
742 /* Create a section for this file */
745 NULL,
746 NULL,
748 SEC_IMAGE,
749 hFile);
750 NtClose(hFile);
751
752 /* Return status */
753 DPRINT("Section: %p for file: %p\n", *hSection, hFile);
754 return Status;
755}
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:3074
#define FILE_NON_DIRECTORY_FILE
Definition: constants.h:492
#define FILE_SYNCHRONOUS_IO_NONALERT
Definition: from_kernel.h:31
_In_ HANDLE hFile
Definition: mswsock.h:90
#define SEC_IMAGE
Definition: mmtypes.h:97
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)
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:3952
#define SYNCHRONIZE
Definition: nt_native.h:61
#define FILE_READ_DATA
Definition: nt_native.h:628
#define SECTION_ALL_ACCESS
Definition: nt_native.h:1293
#define PAGE_EXECUTE
Definition: nt_native.h:1306
#define FILE_SHARE_DELETE
Definition: nt_native.h:682
#define FILE_EXECUTE
Definition: nt_native.h:642
UNICODE_STRING RelativeName
Definition: rtltypes.h:1380
HANDLE ContainingDirectory
Definition: rtltypes.h:1381
#define STATUS_OBJECT_PATH_NOT_FOUND
Definition: udferr_usr.h:151
_In_ const BITMAPINFO _In_ UINT _In_opt_ HANDLE hSection
Definition: wingdi.h:3239

◆ 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;
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 */
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 LdrFindResource_U(_In_ PVOID BaseAddress, _In_ PLDR_RESOURCE_INFO ResourceInfo, _In_ ULONG Level, _Out_ PIMAGE_RESOURCE_DATA_ENTRY *ResourceDataEntry)
_In_ PCWSTR _Out_ PVOID * ActCtx
Definition: ldrtypes.h:247
_In_ PCWSTR FullDllName
Definition: ldrtypes.h:247
#define STATUS_SXS_INVALID_ACTCTXDATA_FORMAT
Definition: ntstatus.h:1384
#define STATUS_RESOURCE_DATA_NOT_FOUND
Definition: ntstatus.h:373
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:5204
Definition: pedump.c:458
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:690
#define RT_MANIFEST
Definition: winuser.h:621
#define ISOLATIONAWARE_MANIFEST_RESOURCE_ID
Definition: winuser.h:623
_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:409
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by DllMain().

◆ BaseProcessStartThunk()

VOID WINAPI BaseProcessStartThunk ( VOID  )

Referenced by BaseInitializeContext().

◆ BaseProcessStartup()

DECLSPEC_NORETURN VOID WINAPI BaseProcessStartup ( _In_ PPROCESS_START_ROUTINE  lpStartAddress)

Definition at line 451 of file proc.c.

453{
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}
@ ThreadQuerySetWin32StartAddress
Definition: compat.h:944
BOOLEAN BaseRunningInServerProcess
Definition: dllmain.c:20
LONG WINAPI UnhandledExceptionFilter(IN PEXCEPTION_POINTERS ExceptionInfo)
Definition: except.c:269
VOID WINAPI ExitProcess(IN UINT uExitCode)
Definition: proc.c:1487
VOID WINAPI ExitThread(IN DWORD uExitCode)
Definition: thread.c:365
#define _SEH2_END
Definition: filesup.c:22
#define _SEH2_TRY
Definition: filesup.c:19
DWORD(WINAPI * PPROCESS_START_ROUTINE)(VOID)
Definition: kernel32.h:249
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:165
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:66
#define _SEH2_GetExceptionInformation()
Definition: pseh2_64.h:164

Referenced by BaseInitializeContext().

◆ BasepUnicodeStringToAnsiSize()

ULONG NTAPI BasepUnicodeStringToAnsiSize ( IN PUNICODE_STRING  String)

Definition at line 49 of file utils.c.

50{
52}
#define RtlUnicodeStringToAnsiSize(String)
Definition: rtlfuncs.h:1019

Referenced by SetFileApisToANSI().

◆ BaseSetLastNTError()

DWORD WINAPI BaseSetLastNTError ( IN NTSTATUS  Status)

Definition at line 167 of file reactos.cpp.

168{
169 DWORD dwErrCode;
170 dwErrCode = RtlNtStatusToDosError(Status);
171 SetLastError(dwErrCode);
172 return dwErrCode;
173}
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)

Referenced by _Success_(), 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(), DefineDosDeviceA(), 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(), GetConsoleHistoryInfo(), 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(), GlobalMemoryStatusEx(), Heap32First(), Heap32ListFirst(), Heap32ListNext(), Heap32Next(), HeapExtend(), HeapQueryInformation(), HeapSetInformation(), HeapSummary(), HeapUsage(), InitializeCriticalSectionAndSpinCount(), InitOnceBeginInitialize(), InitOnceComplete(), IntAddConsoleAlias(), IntAllocConsole(), IntAttachConsole(), InternalAddAtom(), InternalDeleteAtom(), InternalFindAtom(), InternalGetAtomName(), IntExpungeConsoleCommandHistory(), IntFillConsoleOutputCode(), IntGetConsoleAlias(), IntGetConsoleAliases(), IntGetConsoleAliasesLength(), IntGetConsoleAliasExes(), IntGetConsoleAliasExesLength(), IntGetConsoleCommandHistory(), IntGetConsoleCommandHistoryLength(), IntGetConsoleInput(), IntGetConsoleKeyboardLayoutName(), IntGetConsoleTitle(), IntReadConsole(), IntReadConsoleOutput(), IntReadConsoleOutputCode(), IntRegisterConsoleIME(), IntScrollConsoleScreenBuffer(), IntSetConsoleNumberOfCommands(), IntSetConsoleTitle(), IntUnregisterConsoleIME(), 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(), QueryDosDeviceA(), QueryDosDeviceW(), QueryFullProcessImageNameA(), QueryFullProcessImageNameW(), QueryInformationJobObject(), QueryMemoryResourceNotification(), QueryPerformanceCounter(), QueryPerformanceFrequency(), QueueUserAPC(), QueueUserWorkItem(), ReadDirectoryChangesW(), ReadFile(), ReadFileEx(), ReadProcessMemory(), RegisterConsoleVDM(), RegisterWaitForSingleObject(), RegisterWaitForSingleObjectEx(), ReleaseMutex(), ReleaseSemaphore(), RemoveDirectoryW(), RequestDeviceWakeup(), RequestWakeupLatency(), ResetEvent(), ResetWriteWatch(), ResumeThread(), SearchPathA(), SearchPathW(), SetActiveComputerNameToRegistry(), SetComPlusPackageInstallStatus(), SetComputerNameToRegistry(), SetConsoleActiveScreenBuffer(), SetConsoleCommandHistoryMode(), SetConsoleCP(), SetConsoleCursor(), SetConsoleCursorInfo(), SetConsoleCursorPosition(), SetConsoleDisplayMode(), SetConsoleFont(), SetConsoleHandleInformation(), SetConsoleHardwareState(), SetConsoleHistoryInfo(), SetConsoleIcon(), SetConsoleMenuClose(), SetConsoleMode(), SetConsoleOutputCP(), SetConsolePalette(), SetConsoleScreenBufferSize(), SetConsoleTextAttribute(), SetConsoleWindowInfo(), SetCurrentDirectoryA(), SetCurrentDirectoryW(), SetDllDirectoryA(), SetEndOfFile(), SetEnvironmentVariableA(), SetEnvironmentVariableW(), SetEvent(), SetFileAttributesByHandle(), SetFileAttributesW(), SetFileCompletionNotificationModes(), SetFileInformationByHandle(), SetFilePointer(), SetFilePointerEx(), SetFileShortNameW(), SetFileTime(), SetFileValidData(), SetFirmwareEnvironmentVariableExA(), SetFirmwareEnvironmentVariableExW(), SetHandleInformation(), SetInformationJobObject(), SetLocalTime(), SetMailslotInfo(), SetNamedPipeHandleState(), SetPriorityClass(), SetProcessAffinityMask(), SetProcessPriorityBoost(), SetProcessShutdownParameters(), SetProcessWorkingSetSizeEx(), SetSystemPowerState(), SetSystemTime(), SetSystemTimeAdjustment(), SetThreadAffinityMask(), SetThreadContext(), SetThreadExecutionState(), SetThreadIdealProcessor(), SetThreadPriority(), SetThreadPriorityBoost(), SetThreadUILanguage(), 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().

◆ BaseThreadStartup()

DECLSPEC_NORETURN VOID WINAPI BaseThreadStartup ( _In_ LPTHREAD_START_ROUTINE  lpStartAddress,
_In_ LPVOID  lpParameter 
)

Definition at line 56 of file thread.c.

59{
60 /* Attempt to call the Thread Start Address */
62 {
63 /* Legacy check which is still used today for Win32 threads */
64 if (NtCurrentTeb()->NtTib.Version == (30 << 8)) // OS/2 V3.0 ("Cruiser")
65 {
66 /* This registers the termination port with CSRSS */
68 }
69
70 /* Get the exit code from the Thread Start */
71 ExitThread(lpStartAddress(lpParameter));
72 }
74 {
75 /* Get the Exit code from the SEH Handler */
77 {
78 /* Kill the whole process, usually */
80 }
81 else
82 {
83 /* If running inside CSRSS, kill just this thread */
85 }
86 }
88}
NTSTATUS NTAPI CsrNewThread(VOID)
Definition: api.c:26

Referenced by BaseInitializeContext().

◆ BaseThreadStartupThunk()

VOID WINAPI BaseThreadStartupThunk ( VOID  )

Referenced by BaseInitializeContext().

◆ FilenameA2W()

PWCHAR FilenameA2W ( LPCSTR  NameA,
BOOL  alloc 
)

Definition at line 18 of file fileutils.c.

19{
22 PUNICODE_STRING pstrW;
24
25 //ASSERT(NtCurrentTeb()->StaticUnicodeString.Buffer == NtCurrentTeb()->StaticUnicodeBuffer);
26 ASSERT(NtCurrentTeb()->StaticUnicodeString.MaximumLength == sizeof(NtCurrentTeb()->StaticUnicodeBuffer));
27
28 RtlInitAnsiString(&str, NameA);
29 pstrW = alloc ? &strW : &NtCurrentTeb()->StaticUnicodeString;
30
31 if (AreFileApisANSI())
33 else
35
36 if (NT_SUCCESS(Status))
37 return pstrW->Buffer;
38
41 else
43
44 return NULL;
45}
WCHAR strW[12]
Definition: clipboard.c:2029
NTSYSAPI NTSTATUS NTAPI RtlOemStringToUnicodeString(PUNICODE_STRING DestinationString, PCOEM_STRING SourceString, BOOLEAN AllocateDestinationString)
#define alloc
Definition: rosglue.h:13
const WCHAR * str
BOOL WINAPI AreFileApisANSI(void)
Definition: utils.c:866

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

◆ FilenameU2A_FitOrFail()

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

Definition at line 56 of file fileutils.c.

61{
62 DWORD ret;
63
64 /* destLen should never exceed MAX_PATH */
65 if (destLen > MAX_PATH) destLen = MAX_PATH;
66
68 /* ret incl. nullchar */
69
70 if (DestA && (INT)ret <= destLen)
71 {
73
74 str.Buffer = DestA;
75 str.MaximumLength = (USHORT)destLen;
76
77
78 if (AreFileApisANSI())
80 else
82
83 ret = str.Length; /* SUCCESS: length without terminating 0 */
84 }
85
86 return ret;
87}
#define MAX_PATH
Definition: compat.h:34
NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToOemString(POEM_STRING DestinationString, PCUNICODE_STRING SourceString, BOOLEAN AllocateDestinationString)
NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToAnsiString(PANSI_STRING DestinationString, PUNICODE_STRING SourceString, BOOLEAN AllocateDestinationString)
unsigned short USHORT
Definition: pedump.c:61
int32_t INT
Definition: typedefs.h:58
int ret
#define RtlUnicodeStringToOemSize(STRING)

Referenced by FilenameW2A_FitOrFail(), and GetFinalPathNameByHandleA().

◆ FilenameW2A_FitOrFail()

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

Definition at line 98 of file fileutils.c.

104{
106
107 if (sourceLen < 0) sourceLen = wcslen(SourceW) + 1;
108
109 strW.Buffer = (PWCHAR)SourceW;
110 strW.MaximumLength = sourceLen * sizeof(WCHAR);
111 strW.Length = strW.MaximumLength - sizeof(WCHAR);
112
113 return FilenameU2A_FitOrFail(DestA, destLen, &strW);
114}
DWORD FilenameU2A_FitOrFail(LPSTR DestA, INT destLen, PUNICODE_STRING SourceU)
Definition: fileutils.c:56
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
uint16_t * PWCHAR
Definition: typedefs.h:56

Referenced by GetTempPathA().

◆ FilenameW2A_N()

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

Definition at line 146 of file fileutils.c.

152{
153 DWORD ret;
154
155 if (srclen < 0) srclen = wcslen( src ) + 1;
156
157 if (AreFileApisANSI())
158 RtlUnicodeToMultiByteN( dest, destlen, &ret, (LPWSTR) src, srclen * sizeof(WCHAR));
159 else
160 RtlUnicodeToOemN( dest, destlen, &ret, (LPWSTR) src, srclen * sizeof(WCHAR) );
161
162 if (ret) dest[ret-1]=0;
163
164 return ret;
165}
GLenum src
Definition: glext.h:6340
static DWORD LPDWORD LPCSTR DWORD srclen
Definition: directory.c:52
static char * dest
Definition: rtl.c:135
_Use_decl_annotations_ NTSTATUS NTAPI RtlUnicodeToOemN(_Out_ PCHAR OemString, _In_ ULONG OemSize, _Out_opt_ PULONG ResultSize, _In_ PCWCH UnicodeString, _In_ ULONG UnicodeSize)
Definition: nlsboot.c:263
_Use_decl_annotations_ NTSTATUS NTAPI RtlUnicodeToMultiByteN(_Out_ PCHAR MbString, _In_ ULONG MbSize, _Out_opt_ PULONG ResultSize, _In_ PCWCH UnicodeString, _In_ ULONG UnicodeSize)
Definition: nlsboot.c:107

◆ GetTeb()

PTEB GetTeb ( VOID  )

Definition at line 438 of file thread.c.

439{
440 return NtCurrentTeb();
441}

◆ InitCommandLines()

VOID WINAPI InitCommandLines ( VOID  )

Definition at line 842 of file proc.c.

843{
845
846 /* Read the UNICODE_STRING from the PEB */
847 BaseUnicodeCommandLine = NtCurrentPeb()->ProcessParameters->CommandLine;
848
849 /* Convert to ANSI_STRING for the *A callers */
852 TRUE);
853 if (!NT_SUCCESS(Status)) RtlInitEmptyAnsiString(&BaseAnsiCommandLine, 0, 0);
854}
UNICODE_STRING BaseUnicodeCommandLine
Definition: proc.c:21
ANSI_STRING BaseAnsiCommandLine
Definition: proc.c:22

Referenced by DllMain().

◆ IntGetCodePageEntry()

PCODEPAGE_ENTRY FASTCALL IntGetCodePageEntry ( UINT  CodePage)

Definition at line 293 of file nls.c.

294{
296 CHAR SectionName[40];
297 HANDLE SectionHandle = INVALID_HANDLE_VALUE, FileHandle;
298 PBYTE SectionMapping;
301 ANSI_STRING AnsiName;
304 UINT FileNamePos;
305 PCODEPAGE_ENTRY CodePageEntry;
306
307 if (CodePage == CP_ACP)
308 {
309 return &AnsiCodePage;
310 }
311 else if (CodePage == CP_OEMCP)
312 {
313 return &OemCodePage;
314 }
315 else if (CodePage == CP_THREAD_ACP)
316 {
318 LOCALE_IDEFAULTANSICODEPAGE | LOCALE_RETURN_NUMBER,
319 (WCHAR *)&CodePage,
320 sizeof(CodePage) / sizeof(WCHAR)))
321 {
322 /* Last error is set by GetLocaleInfoW. */
323 return NULL;
324 }
325 if (CodePage == 0)
326 return &AnsiCodePage;
327 }
328 else if (CodePage == CP_MACCP)
329 {
331 LOCALE_IDEFAULTMACCODEPAGE | LOCALE_RETURN_NUMBER,
332 (WCHAR *)&CodePage,
333 sizeof(CodePage) / sizeof(WCHAR)))
334 {
335 /* Last error is set by GetLocaleInfoW. */
336 return NULL;
337 }
338 }
339
340 /* Try searching for loaded page first. */
341 CodePageEntry = IntGetLoadedCodePageEntry(CodePage);
342 if (CodePageEntry != NULL)
343 {
344 return CodePageEntry;
345 }
346
347 /*
348 * Yes, we really want to lock here. Otherwise it can happen that
349 * two parallel requests will try to get the entry for the same
350 * code page and we would load it twice.
351 */
353
354 /* Generate the section name. */
355 if (!GetNlsSectionName(CodePage,
356 10,
357 0,
358 "\\Nls\\NlsSectionCP",
359 SectionName,
360 sizeof(SectionName)))
361 {
363 return NULL;
364 }
365
366 RtlInitAnsiString(&AnsiName, SectionName);
368
369 /*
370 * FIXME: IntGetCodePageEntry should not create any security
371 * descriptor here but instead this responsibility should be
372 * assigned to Base Server API (aka basesrv.dll). That is,
373 * kernel32 must instruct basesrv.dll on creating NLS section
374 * names that do not exist through API message communication.
375 * However since we do not do that, let the kernel32 do the job
376 * by assigning security to NLS section names for the time being...
377 */
379 sizeof(SecurityDescriptor),
381 if (!NT_SUCCESS(Status))
382 {
383 DPRINT1("CreateNlsSecurityDescriptor FAILED! (Status 0x%08x)\n", Status);
385 return NULL;
386 }
387
391 NULL,
393
394 /* Try to open the section first */
395 Status = NtOpenSection(&SectionHandle,
398
399 /* If the section doesn't exist, try to create it. */
403 {
404 FileNamePos = GetSystemDirectoryW(FileName, MAX_PATH);
405 if (GetCPFileNameFromRegistry(CodePage,
406 FileName + FileNamePos + 1,
407 MAX_PATH - FileNamePos - 1))
408 {
409 FileName[FileNamePos] = L'\\';
410 FileName[MAX_PATH] = 0;
414 NULL,
416 0,
417 NULL);
418
419 Status = NtCreateSection(&SectionHandle,
422 NULL,
425 FileHandle);
426
427 /* HACK: Check if another process was faster
428 * and already created this section. See bug 3626 for details */
430 {
431 /* Close the file then */
433
434 /* And open the section */
435 Status = NtOpenSection(&SectionHandle,
438 }
439 }
440 }
442
443 if (!NT_SUCCESS(Status))
444 {
446 return NULL;
447 }
448
449 SectionMapping = MapViewOfFile(SectionHandle, FILE_MAP_READ, 0, 0, 0);
450 if (SectionMapping == NULL)
451 {
452 NtClose(SectionHandle);
454 return NULL;
455 }
456
457 CodePageEntry = HeapAlloc(GetProcessHeap(), 0, sizeof(CODEPAGE_ENTRY));
458 if (CodePageEntry == NULL)
459 {
460 NtClose(SectionHandle);
462 return NULL;
463 }
464
465 CodePageEntry->CodePage = CodePage;
466 CodePageEntry->SectionHandle = SectionHandle;
467 CodePageEntry->SectionMapping = SectionMapping;
468
469 RtlInitCodePageTable((PUSHORT)SectionMapping, &CodePageEntry->CodePageTable);
470
471 /* Insert the new entry to list and unlock. Uff. */
472 InsertTailList(&CodePageListHead, &CodePageEntry->Entry);
474
475 return CodePageEntry;
476}
NTSTATUS NTAPI NtOpenSection(OUT PHANDLE SectionHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes)
Definition: section.c:3202
#define NLS_SECTION_SECURITY_DESCRIPTOR_SIZE
Definition: base.h:31
#define GetProcessHeap()
Definition: compat.h:736
#define PAGE_READONLY
Definition: compat.h:138
#define SECTION_MAP_READ
Definition: compat.h:139
#define CP_ACP
Definition: compat.h:109
#define HeapAlloc
Definition: compat.h:733
#define FILE_MAP_READ
Definition: compat.h:776
#define MapViewOfFile
Definition: compat.h:745
UINT WINAPI GetSystemDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2313
LCID WINAPI GetThreadLocale(void)
Definition: locale.c:2800
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
Definition: locale.c:1665
PCODEPAGE_ENTRY FASTCALL IntGetLoadedCodePageEntry(UINT CodePage)
Definition: nls.c:257
static CODEPAGE_ENTRY AnsiCodePage
Definition: nls.c:46
BOOL WINAPI GetNlsSectionName(UINT CodePage, UINT Base, ULONG Unknown, LPSTR BaseName, LPSTR Result, ULONG ResultSize)
Definition: nls.c:1483
NTSTATUS WINAPI CreateNlsSecurityDescriptor(_Out_ PSECURITY_DESCRIPTOR SecurityDescriptor, _In_ SIZE_T DescriptorSize, _In_ ULONG AccessMask)
Creates a security descriptor for each NLS section. Typically used by BASESRV to give Everyone (World...
Definition: nls.c:2393
static RTL_CRITICAL_SECTION CodePageListLock
Definition: nls.c:48
BOOL WINAPI GetCPFileNameFromRegistry(UINT CodePage, LPWSTR FileName, ULONG FileNameSize)
Definition: nls.c:1528
static CODEPAGE_ENTRY OemCodePage
Definition: nls.c:47
static LIST_ENTRY CodePageListHead
Definition: nls.c:45
#define InsertTailList(ListHead, Entry)
IN PDCB IN POEM_STRING IN PUNICODE_STRING UnicodeName
Definition: fatprocs.h:1306
unsigned int UINT
Definition: ndis.h:50
#define SEC_COMMIT
Definition: mmtypes.h:100
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define FILE_GENERIC_READ
Definition: nt_native.h:653
#define LOCALE_SYSTEM_DEFAULT
BYTE * PBYTE
Definition: pedump.c:66
VOID NTAPI RtlInitCodePageTable(IN PUSHORT TableBase, OUT PCPTABLEINFO CodePageTable)
Definition: nls.c:155
Definition: kernel32.h:63
UINT CodePage
Definition: kernel32.h:65
LIST_ENTRY Entry
Definition: kernel32.h:64
HANDLE SectionHandle
Definition: kernel32.h:66
CPTABLEINFO CodePageTable
Definition: kernel32.h:68
PBYTE SectionMapping
Definition: kernel32.h:67
uint16_t * PUSHORT
Definition: typedefs.h:56
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define STATUS_OBJECT_NAME_COLLISION
Definition: udferr_usr.h:150
#define STATUS_OBJECT_NAME_NOT_FOUND
Definition: udferr_usr.h:149
#define CP_THREAD_ACP
Definition: winnls.h:233
#define CP_OEMCP
Definition: winnls.h:231
#define CP_MACCP
Definition: winnls.h:232
#define LOCALE_IDEFAULTANSICODEPAGE
Definition: winnls.h:38
#define LOCALE_IDEFAULTMACCODEPAGE
Definition: winnls.h:39
unsigned char UCHAR
Definition: xmlstorage.h:181

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),
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),
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}
ULONG g_ShimsDisabled
Definition: appcache.c:18
#define REG_DWORD
Definition: sdbapi.c:596
OBJECT_ATTRIBUTES AppCompatKeyAttributes
Definition: shimdbg.c:228

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;
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_ ULONG _In_ BATTERY_QUERY_INFORMATION_LEVEL _In_ LONG _In_ ULONG _Out_ PULONG ReturnedLength
Definition: batclass.h:188
Definition: bufpool.h:45
_Must_inspect_result_ _Out_ PHANDLE VolumeHandle
Definition: fltkernel.h:2283
@ FileNameInformation
Definition: from_kernel.h:70
struct _FILE_NAME_INFORMATION FILE_NAME_INFORMATION
#define SYMBOLIC_LINK_QUERY
Definition: nt_native.h:1265
_Inout_ PUNICODE_STRING LinkTarget
Definition: zwfuncs.h:292

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

Variable Documentation

◆ BaseCachedSysInfo

SYSTEM_BASIC_INFORMATION BaseCachedSysInfo
extern

◆ BaseDefaultPath

UNICODE_STRING BaseDefaultPath
extern

Definition at line 21 of file path.c.

Referenced by BasepComputeProcessPath(), and DllMain().

◆ BaseDefaultPathAppend

UNICODE_STRING BaseDefaultPathAppend
extern

Definition at line 21 of file path.c.

Referenced by DllMain().

◆ BaseDllDirectory

◆ BaseDllDirectoryLock

◆ BaseNamedObjectDirectory

HANDLE BaseNamedObjectDirectory
extern

Definition at line 24 of file dllmain.c.

Referenced by BaseGetNamedObjectDirectory().

◆ Basep8BitStringToUnicodeSize

PRTL_COUNT_STRINGA Basep8BitStringToUnicodeSize
extern

Definition at line 29 of file utils.c.

Referenced by SetFileApisToANSI(), and SetFileApisToOEM().

◆ Basep8BitStringToUnicodeString

◆ BasepAppCertDllsList

LIST_ENTRY BasepAppCertDllsList
extern

Definition at line 28 of file proc.c.

Referenced by BasepIsProcessAllowed(), and DllMain().

◆ BasepExeLdrEntry

PLDR_DATA_TABLE_ENTRY BasepExeLdrEntry
extern

Definition at line 25 of file proc.c.

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

◆ BasepUnicodeStringTo8BitSize

PRTL_COUNT_STRING BasepUnicodeStringTo8BitSize
extern

Definition at line 28 of file utils.c.

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

◆ BasepUnicodeStringTo8BitString

◆ BaseRunningInServerProcess

BOOLEAN BaseRunningInServerProcess
extern

◆ BaseStaticServerData

PBASE_STATIC_SERVER_DATA BaseStaticServerData
extern

Definition at line 19 of file dllmain.c.

◆ BaseWindowsDirectory

UNICODE_STRING BaseWindowsDirectory
extern

◆ BaseWindowsSystemDirectory

UNICODE_STRING BaseWindowsSystemDirectory

Definition at line 300 of file kernel32.h.

◆ bIsFileApiAnsi

BOOL bIsFileApiAnsi
extern

Definition at line 25 of file utils.c.

Referenced by CheckNameLegalDOS8Dot3A(), OpenFile(), SetFileApisToANSI(), and SetFileApisToOEM().

◆ gcsAppCert

RTL_CRITICAL_SECTION gcsAppCert
extern

Definition at line 29 of file proc.c.

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

◆ GlobalTopLevelExceptionFilter

LPTOP_LEVEL_EXCEPTION_FILTER GlobalTopLevelExceptionFilter
extern

Definition at line 165 of file except.c.

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

◆ hCurrentModule

HMODULE hCurrentModule
extern

Definition at line 25 of file dllmain.c.

Referenced by DllMain(), and GetLocalisedText().

◆ UserWaitForInputIdleRoutine

WaitForInputIdleType UserWaitForInputIdleRoutine
extern

Definition at line 20 of file proc.c.

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