ReactOS  0.4.15-dev-2155-g06f57e1
utils.c File Reference
#include <k32.h>
#include <debug.h>
Include dependency graph for utils.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

ULONG NTAPI BasepUnicodeStringToOemSize (IN PUNICODE_STRING String)
 
ULONG NTAPI BasepOemStringToUnicodeSize (IN PANSI_STRING String)
 
ULONG NTAPI BasepUnicodeStringToAnsiSize (IN PUNICODE_STRING String)
 
ULONG NTAPI BasepAnsiStringToUnicodeSize (IN PANSI_STRING String)
 
HANDLE WINAPI BaseGetNamedObjectDirectory (VOID)
 
VOID NTAPI BasepLocateExeLdrEntry (IN PLDR_DATA_TABLE_ENTRY Entry, IN PVOID Context, OUT BOOLEAN *StopEnumeration)
 
PUNICODE_STRING WINAPI Basep8BitStringToStaticUnicodeString (IN LPCSTR String)
 
BOOLEAN WINAPI Basep8BitStringToDynamicUnicodeString (OUT PUNICODE_STRING UnicodeString, IN LPCSTR String)
 
VOID WINAPI BasepAnsiStringToHeapUnicodeString (IN LPCSTR AnsiString, OUT LPWSTR *UnicodeString)
 
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)
 
PVOID WINAPI BasepIsRealtimeAllowed (IN BOOLEAN Keep)
 
NTSTATUS WINAPI BasepMapFile (IN LPCWSTR lpApplicationName, OUT PHANDLE hSection, IN PUNICODE_STRING ApplicationName)
 
BOOLEAN WINAPI Wow64EnableWow64FsRedirection (IN BOOLEAN Wow64EnableWow64FsRedirection)
 
BOOL WINAPI Wow64DisableWow64FsRedirection (IN PVOID *OldValue)
 
BOOL WINAPI Wow64RevertWow64FsRedirection (IN PVOID OldValue)
 
VOID WINAPI SetFileApisToOEM (VOID)
 
VOID WINAPI SetFileApisToANSI (VOID)
 
BOOL WINAPI AreFileApisANSI (VOID)
 
VOID WINAPI BaseMarkFileForDelete (IN HANDLE FileHandle, IN ULONG FileAttributes)
 
NTSTATUS WINAPI BasepCheckWinSaferRestrictions (IN HANDLE UserToken, IN LPWSTR ApplicationName, IN HANDLE FileHandle, OUT PBOOLEAN InJob, OUT PHANDLE NewToken, OUT PHANDLE JobHandle)
 

Variables

UNICODE_STRING Restricted = RTL_CONSTANT_STRING(L"Restricted")
 
BOOL bIsFileApiAnsi = TRUE
 
PRTL_CONVERT_STRING Basep8BitStringToUnicodeString = RtlAnsiStringToUnicodeString
 
PRTL_CONVERT_STRINGA BasepUnicodeStringTo8BitString = RtlUnicodeStringToAnsiString
 
PRTL_COUNT_STRING BasepUnicodeStringTo8BitSize = BasepUnicodeStringToAnsiSize
 
PRTL_COUNT_STRINGA Basep8BitStringToUnicodeSize = BasepAnsiStringToUnicodeSize
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 19 of file utils.c.

Function Documentation

◆ AreFileApisANSI()

BOOL WINAPI AreFileApisANSI ( VOID  )

Definition at line 863 of file utils.c.

864 {
866 }
NTSYSAPI NTSTATUS NTAPI RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString, PANSI_STRING SourceString, BOOLEAN AllocateDestinationString)
PRTL_CONVERT_STRING Basep8BitStringToUnicodeString
Definition: utils.c:26

Referenced by cmpStrAW(), FilenameA2W(), FilenameA2W_N(), FilenameU2A_FitOrFail(), and FilenameW2A_N().

◆ 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,
419  MEM_RESERVE,
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,
453  MEM_COMMIT,
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 ROUND_UP(n, align)
Definition: eventvwr.h:31
PBASE_STATIC_SERVER_DATA BaseStaticServerData
Definition: dllmain.c:19
#define TRUE
Definition: types.h:120
#define PAGE_GUARD
Definition: nt_native.h:1310
NTSTATUS NTAPI NtProtectVirtualMemory(IN HANDLE ProcessHandle, IN OUT PVOID *UnsafeBaseAddress, IN OUT SIZE_T *UnsafeNumberOfBytesToProtect, IN ULONG NewAccessProtection, OUT PULONG UnsafeOldAccessProtection)
Definition: virtual.c:3022
LONG NTSTATUS
Definition: precomp.h:26
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
#define MEM_COMMIT
Definition: nt_native.h:1313
uint32_t ULONG_PTR
Definition: typedefs.h:65
_In_ WDFREQUEST _In_ PIO_STACK_LOCATION Stack
Definition: wdfrequest.h:636
#define FALSE
Definition: types.h:117
#define MEM_RESERVE
Definition: nt_native.h:1314
unsigned char BOOLEAN
void * PVOID
Definition: retypes.h:9
SYSTEM_BASIC_INFORMATION SysInfo
Definition: base.h:122
Status
Definition: gdiplustypes.h:24
#define STATUS_INVALID_IMAGE_FORMAT
Definition: ntstatus.h:359
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
IMAGE_OPTIONAL_HEADER32 OptionalHeader
Definition: ntddk_ex.h:184
ULONG_PTR SIZE_T
Definition: typedefs.h:80
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:4403
#define NtCurrentPeb()
Definition: FLS.c:20
#define NULL
Definition: types.h:112
#define DPRINT1
Definition: precomp.h:8
#define RtlImageNtHeader
Definition: compat.h:665
#define MEM_RELEASE
Definition: nt_native.h:1316
unsigned int ULONG
Definition: retypes.h:1
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:71
#define PAGE_READWRITE
Definition: nt_native.h:1304
NTSTATUS NTAPI NtFreeVirtualMemory(IN HANDLE ProcessHandle, IN PVOID *UBaseAddress, IN PSIZE_T URegionSize, IN ULONG FreeType)
Definition: virtual.c:5126

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

◆ BaseFormatObjectAttributes()

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

Definition at line 304 of file utils.c.

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

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

◆ BaseFormatTimeOut()

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

Definition at line 288 of file utils.c.

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

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

◆ BaseFreeThreadStack()

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

Definition at line 495 of file utils.c.

498 {
499  SIZE_T Dummy = 0;
500 
501  /* Free the Stack */
503  &InitialTeb->AllocatedStackBase,
504  &Dummy,
505  MEM_RELEASE);
506 }
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define MEM_RELEASE
Definition: nt_native.h:1316
NTSTATUS NTAPI NtFreeVirtualMemory(IN HANDLE ProcessHandle, IN PVOID *UBaseAddress, IN PSIZE_T URegionSize, IN ULONG FreeType)
Definition: virtual.c:5126

Referenced by CreateRemoteThread().

◆ BaseGetNamedObjectDirectory()

HANDLE WINAPI BaseGetNamedObjectDirectory ( VOID  )

Definition at line 63 of file utils.c.

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

Referenced by BaseFormatObjectAttributes(), and OpenFileMappingW().

◆ BaseInitializeContext()

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

Definition at line 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;
589  Context->Rdx = (ULONG_PTR)Parameter;
590  Context->Rsp = (ULONG_PTR)StackAddress - 5 * sizeof(PVOID);
591 
592  /* Setup the Segments */
593  Context->SegGs = KGDT64_R3_DATA | RPL_MASK;
594  Context->SegEs = KGDT64_R3_DATA | RPL_MASK;
595  Context->SegDs = KGDT64_R3_DATA | RPL_MASK;
596  Context->SegCs = KGDT64_R3_CODE | RPL_MASK;
597  Context->SegSs = KGDT64_R3_DATA | RPL_MASK;
598  Context->SegFs = KGDT64_R3_CMTEB | RPL_MASK;
599 
600  /* Set the EFLAGS */
601  Context->EFlags = 0x3000 | EFLAGS_INTERRUPT_MASK; /* IOPL 3 */
602 
603  if (ContextType == 1) /* For Threads */
604  {
605  Context->Rip = (ULONG_PTR)BaseThreadStartup;
606  }
607  else if (ContextType == 2) /* For Fibers */
608  {
609  Context->Rip = (ULONG_PTR)BaseFiberStartup;
610  }
611  else /* For first thread in a Process */
612  {
614  }
615 
616  /* Set the Context Flags */
617  Context->ContextFlags = CONTEXT_FULL;
618 #elif defined(_M_ARM)
619  DPRINT("BaseInitializeContext: %p\n", Context);
620 
621  // FIXME: check if this is correct!
622  /* Setup the Initial Win32 Thread Context */
623  Context->R0 = (ULONG_PTR)StartAddress;
624  Context->R1 = (ULONG_PTR)Parameter;
625  Context->Sp = (ULONG_PTR)StackAddress;
626 
627  if (ContextType == 1) /* For Threads */
628  {
630  }
631  else if (ContextType == 2) /* For Fibers */
632  {
633  Context->Pc = (ULONG_PTR)BaseFiberStartup;
634  }
635  else /* For first thread in a Process */
636  {
638  }
639 
640  /* Set the Context Flags */
641  Context->ContextFlags = CONTEXT_FULL;
642 
643  /* Give it some room for the Parameter */
644  Context->Sp -= sizeof(PVOID);
645 #else
646 #warning Unknown architecture
648  DbgBreakPoint();
649 #endif
650 }
#define KGDT64_R3_CODE
Definition: ketypes.h:76
#define CONTEXT_FLOATING_POINT
Definition: nt_native.h:1372
#define KGDT64_R3_CMTEB
Definition: ketypes.h:78
_In_ PVOID Parameter
Definition: ldrtypes.h:241
void DbgBreakPoint()
Definition: mach.c:553
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define KGDT64_R3_DATA
Definition: ketypes.h:75
#define PF_XMMI_INSTRUCTIONS_AVAILABLE
#define RPL_MASK
Definition: ketypes.h:69
#define KGDT_R3_DATA
Definition: ketypes.h:78
void * PVOID
Definition: retypes.h:9
#define CONTEXT_FULL
Definition: nt_native.h:1375
#define ASSERT(a)
Definition: mode.c:45
#define KGDT_R3_TEB
Definition: ketypes.h:81
#define SharedUserData
VOID WINAPI BaseProcessStartup(PPROCESS_START_ROUTINE lpStartAddress)
Definition: proc.c:450
#define KGDT_R3_CODE
Definition: ketypes.h:77
VOID WINAPI BaseProcessStartThunk(VOID)
unsigned int ULONG
Definition: retypes.h:1
_Must_inspect_result_ _In_ FLT_CONTEXT_TYPE ContextType
Definition: fltkernel.h:1444
#define UNIMPLEMENTED
Definition: debug.h:115
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define ULONG_PTR
Definition: config.h:101
#define DPRINT
Definition: sndvol32.h:71
VOID WINAPI BaseThreadStartupThunk(VOID)
#define EFLAGS_INTERRUPT_MASK
Definition: ketypes.h:126

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

◆ BaseMarkFileForDelete()

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

Definition at line 873 of file utils.c.

875 {
877  FILE_BASIC_INFORMATION FileBasicInfo;
878  FILE_DISPOSITION_INFORMATION FileDispositionInfo;
879 
880  /* If no attributes were given, get them */
881  if (!FileAttributes)
882  {
883  FileBasicInfo.FileAttributes = 0;
885  &IoStatusBlock,
886  &FileBasicInfo,
887  sizeof(FileBasicInfo),
889  FileAttributes = FileBasicInfo.FileAttributes;
890  }
891 
892  /* If file is marked as RO, reset its attributes */
894  {
895  RtlZeroMemory(&FileBasicInfo, sizeof(FileBasicInfo));
896  FileBasicInfo.FileAttributes = FILE_ATTRIBUTE_NORMAL;
898  &IoStatusBlock,
899  &FileBasicInfo,
900  sizeof(FileBasicInfo),
902  }
903 
904  /* Finally, mark the file for deletion */
905  FileDispositionInfo.DeleteFile = TRUE;
907  &IoStatusBlock,
908  &FileDispositionInfo,
909  sizeof(FileDispositionInfo),
911 }
NTSTATUS NTAPI NtSetInformationFile(HANDLE hFile, PIO_STATUS_BLOCK io, PVOID ptr, ULONG len, FILE_INFORMATION_CLASS FileInformationClass)
#define TRUE
Definition: types.h:120
HANDLE FileHandle
Definition: stats.c:38
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE _In_ ACCESS_MASK _In_ POBJECT_ATTRIBUTES _Out_ PIO_STATUS_BLOCK _In_opt_ PLARGE_INTEGER _In_ ULONG FileAttributes
Definition: fltkernel.h:1230
#define FILE_ATTRIBUTE_READONLY
Definition: nt_native.h:702
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
NTSTATUS NTAPI NtQueryInformationFile(HANDLE hFile, PIO_STATUS_BLOCK io, PVOID ptr, ULONG len, FILE_INFORMATION_CLASS FileInformationClass)
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262

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 }
NTSYSAPI NTSTATUS WINAPI RtlInitAnsiStringEx(PANSI_STRING, PCSZ)
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2430
#define FALSE
Definition: types.h:117
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define SetLastError(x)
Definition: compat.h:611
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
PRTL_CONVERT_STRING Basep8BitStringToUnicodeString
Definition: utils.c:26
#define ERROR_FILENAME_EXCED_RANGE
Definition: winerror.h:263

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

◆ Basep8BitStringToStaticUnicodeString()

PUNICODE_STRING WINAPI Basep8BitStringToStaticUnicodeString ( IN LPCSTR  String)

Definition at line 188 of file utils.c.

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

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

◆ BasepAnsiStringToHeapUnicodeString()

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

Definition at line 263 of file utils.c.

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

Referenced by CreateProcessInternalA().

◆ BasepAnsiStringToUnicodeSize()

ULONG NTAPI BasepAnsiStringToUnicodeSize ( IN PANSI_STRING  String)

Definition at line 56 of file utils.c.

57 {
59 }
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2430
NTSYSAPI DWORD WINAPI RtlAnsiStringToUnicodeSize(const STRING *)

Referenced by SetFileApisToANSI().

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

924 {
926 
927  /* Validate that there's a name */
928  if ((ApplicationName) && *(ApplicationName))
929  {
930  /* Validate that the required output parameters are there */
931  if ((InJob) && (NewToken) && (JobHandle))
932  {
933  /* Do the work (one day...) */
934  DPRINT("BasepCheckWinSaferRestrictions is UNIMPLEMENTED\n");
936  }
937  else
938  {
939  /* Act as if SEH hit this */
941  }
942  }
943  else
944  {
945  /* Input is invalid */
947  }
948 
949  /* Return the status */
950  return Status;
951 }
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
Status
Definition: gdiplustypes.h:24
PVOID PVOID PWCHAR ApplicationName
Definition: env.c:45
#define STATUS_ACCESS_VIOLATION
Definition: ntstatus.h:242
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:71

Referenced by CreateProcessInternalW().

◆ BasepIsRealtimeAllowed()

PVOID WINAPI BasepIsRealtimeAllowed ( IN BOOLEAN  Keep)

Definition at line 662 of file utils.c.

663 {
665  PVOID State;
667 
669  if (!NT_SUCCESS(Status)) return NULL;
670 
671  if (!Keep)
672  {
674  State = (PVOID)TRUE;
675  }
676 
677  return State;
678 }
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
_In_ ULONG _In_ ULONG State
Definition: potypes.h:516
NTSYSAPI VOID NTAPI RtlReleasePrivilege(_In_ PVOID ReturnedState)
void * PVOID
Definition: retypes.h:9
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
BOOL Privilege(LPTSTR pszPrivilege, BOOL bEnable)
Definition: user_lib.cpp:531
#define SE_INC_BASE_PRIORITY_PRIVILEGE
Definition: security.c:668
#define NULL
Definition: types.h:112
NTSYSAPI NTSTATUS NTAPI RtlAcquirePrivilege(_In_ PULONG Privilege, _In_ ULONG NumPriv, _In_ ULONG Flags, _Out_ PVOID *ReturnedState)
unsigned int ULONG
Definition: retypes.h:1

Referenced by CreateProcessInternalW(), and SetPriorityClass().

◆ BasepLocateExeLdrEntry()

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

Definition at line 156 of file utils.c.

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

Referenced by BasepComputeProcessPath(), and LoadLibraryExW().

◆ BasepMapFile()

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

Definition at line 685 of file utils.c.

688 {
689  RTL_RELATIVE_NAME_U RelativeName;
692  HANDLE hFile = NULL;
694 
695  DPRINT("BasepMapFile\n");
696 
697  /* Zero out the Relative Directory */
698  RelativeName.ContainingDirectory = NULL;
699 
700  /* Find the application name */
701  if (!RtlDosPathNameToNtPathName_U(lpApplicationName,
703  NULL,
704  &RelativeName))
705  {
707  }
708 
709  DPRINT("ApplicationName %wZ\n", ApplicationName);
710  DPRINT("RelativeName %wZ\n", &RelativeName.RelativeName);
711 
712  /* Did we get a relative name? */
713  if (RelativeName.RelativeName.Length)
714  {
715  ApplicationName = &RelativeName.RelativeName;
716  }
717 
718  /* Initialize the Object Attributes */
722  RelativeName.ContainingDirectory,
723  NULL);
724 
725  /* Try to open the executable */
729  &IoStatusBlock,
732  if (!NT_SUCCESS(Status))
733  {
734  DPRINT1("Failed to open file\n");
736  return Status;
737  }
738 
739  /* Create a section for this file */
742  NULL,
743  NULL,
744  PAGE_EXECUTE,
745  SEC_IMAGE,
746  hFile);
747  NtClose(hFile);
748 
749  /* Return status */
750  DPRINT("Section: %p for file: %p\n", *hSection, hFile);
751  return Status;
752 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
NTSTATUS NTAPI NtCreateSection(OUT PHANDLE SectionHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, IN PLARGE_INTEGER MaximumSize OPTIONAL, IN ULONG SectionPageProtection OPTIONAL, IN ULONG AllocationAttributes, IN HANDLE FileHandle OPTIONAL)
Definition: section.c:3430
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
HANDLE ContainingDirectory
Definition: rtltypes.h:1379
LONG NTSTATUS
Definition: precomp.h:26
#define FILE_SHARE_READ
Definition: compat.h:136
#define SECTION_ALL_ACCESS
Definition: nt_native.h:1293
#define FILE_READ_DATA
Definition: nt_native.h:628
#define PAGE_EXECUTE
Definition: nt_native.h:1306
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
Status
Definition: gdiplustypes.h:24
NTSYSAPI NTSTATUS NTAPI NtOpenFile(OUT PHANDLE phFile, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN ULONG ShareMode, IN ULONG OpenMode)
Definition: file.c:3951
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_OBJECT_PATH_NOT_FOUND
Definition: udferr_usr.h:151
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3399
#define FILE_SHARE_DELETE
Definition: nt_native.h:682
#define FILE_EXECUTE
Definition: nt_native.h:642
#define FILE_NON_DIRECTORY_FILE
Definition: constants.h:492
#define SYNCHRONIZE
Definition: nt_native.h:61
_In_ HANDLE hFile
Definition: mswsock.h:90
PVOID PVOID PWCHAR ApplicationName
Definition: env.c:45
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define NULL
Definition: types.h:112
#define DPRINT1
Definition: precomp.h:8
#define FILE_SYNCHRONOUS_IO_NONALERT
Definition: from_kernel.h:31
#define SEC_IMAGE
Definition: mmtypes.h:96
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
UNICODE_STRING RelativeName
Definition: rtltypes.h:1378
#define DPRINT
Definition: sndvol32.h:71
_In_ const BITMAPINFO _In_ UINT _In_opt_ HANDLE hSection
Definition: wingdi.h:3238
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)

◆ BasepOemStringToUnicodeSize()

ULONG NTAPI BasepOemStringToUnicodeSize ( IN PANSI_STRING  String)

Definition at line 42 of file utils.c.

43 {
45 }
NTSYSAPI UINT WINAPI RtlOemStringToUnicodeSize(const STRING *)
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2430

Referenced by SetFileApisToOEM().

◆ BasepUnicodeStringToAnsiSize()

ULONG NTAPI BasepUnicodeStringToAnsiSize ( IN PUNICODE_STRING  String)

Definition at line 49 of file utils.c.

50 {
52 }
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2430
NTSYSAPI DWORD WINAPI RtlUnicodeStringToAnsiSize(const UNICODE_STRING *)

Referenced by SetFileApisToANSI().

◆ BasepUnicodeStringToOemSize()

ULONG NTAPI BasepUnicodeStringToOemSize ( IN PUNICODE_STRING  String)

Definition at line 35 of file utils.c.

36 {
38 }
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2430
NTSYSAPI DWORD WINAPI RtlUnicodeStringToOemSize(const UNICODE_STRING *)

Referenced by SetFileApisToOEM().

◆ SetFileApisToANSI()

VOID WINAPI SetFileApisToANSI ( VOID  )

Definition at line 846 of file utils.c.

847 {
848  /* Set the correct Base Api */
853 
854  /* FIXME: Old, deprecated way */
856 }
BOOL bIsFileApiAnsi
Definition: utils.c:25
#define TRUE
Definition: types.h:120
PRTL_CONVERT_STRINGA BasepUnicodeStringTo8BitString
Definition: utils.c:27
ULONG NTAPI BasepAnsiStringToUnicodeSize(IN PANSI_STRING String)
Definition: utils.c:56
PRTL_COUNT_STRINGA Basep8BitStringToUnicodeSize
Definition: utils.c:29
NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToAnsiString(PANSI_STRING DestinationString, PUNICODE_STRING SourceString, BOOLEAN AllocateDestinationString)
ULONG NTAPI BasepUnicodeStringToAnsiSize(IN PUNICODE_STRING String)
Definition: utils.c:49
PRTL_COUNT_STRING BasepUnicodeStringTo8BitSize
Definition: utils.c:28
NTSYSAPI NTSTATUS NTAPI RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString, PANSI_STRING SourceString, BOOLEAN AllocateDestinationString)
PRTL_CONVERT_STRING Basep8BitStringToUnicodeString
Definition: utils.c:26

◆ SetFileApisToOEM()

VOID WINAPI SetFileApisToOEM ( VOID  )

Definition at line 828 of file utils.c.

829 {
830  /* Set the correct Base Api */
835 
836  /* FIXME: Old, deprecated way */
838 }
BOOL bIsFileApiAnsi
Definition: utils.c:25
PRTL_CONVERT_STRINGA BasepUnicodeStringTo8BitString
Definition: utils.c:27
NTSTATUS(NTAPI * PRTL_CONVERT_STRING)(IN PUNICODE_STRING UnicodeString, IN PANSI_STRING AnsiString, IN BOOLEAN AllocateMemory)
Definition: kernel32.h:272
#define FALSE
Definition: types.h:117
PRTL_COUNT_STRINGA Basep8BitStringToUnicodeSize
Definition: utils.c:29
ULONG NTAPI BasepUnicodeStringToOemSize(IN PUNICODE_STRING String)
Definition: utils.c:35
NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToOemString(POEM_STRING DestinationString, PCUNICODE_STRING SourceString, BOOLEAN AllocateDestinationString)
NTSYSAPI NTSTATUS NTAPI RtlOemStringToUnicodeString(PUNICODE_STRING DestinationString, PCOEM_STRING SourceString, BOOLEAN AllocateDestinationString)
PRTL_COUNT_STRING BasepUnicodeStringTo8BitSize
Definition: utils.c:28
ULONG NTAPI BasepOemStringToUnicodeSize(IN PANSI_STRING String)
Definition: utils.c:42
PRTL_CONVERT_STRING Basep8BitStringToUnicodeString
Definition: utils.c:26

Referenced by _tmain().

◆ Wow64DisableWow64FsRedirection()

BOOL WINAPI Wow64DisableWow64FsRedirection ( IN PVOID OldValue)

Definition at line 782 of file utils.c.

783 {
785  BOOL Result;
786 
788  if (NT_SUCCESS(Status))
789  {
790  Result = TRUE;
791  }
792  else
793  {
795  Result = FALSE;
796  }
797  return Result;
798 }
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSYSAPI NTSTATUS NTAPI RtlWow64EnableFsRedirectionEx(IN PVOID Wow64FsEnableRedirection, OUT PVOID *OldFsRedirectionLevel)
Definition: libsupp.c:1014

Referenced by get_systemdirectory(), and run_winemenubuilder().

◆ Wow64EnableWow64FsRedirection()

BOOLEAN WINAPI Wow64EnableWow64FsRedirection ( IN BOOLEAN  Wow64EnableWow64FsRedirection)

Definition at line 759 of file utils.c.

760 {
762  BOOL Result;
763 
765  if (NT_SUCCESS(Status))
766  {
767  Result = TRUE;
768  }
769  else
770  {
772  Result = FALSE;
773  }
774  return Result;
775 }
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
NTSYSAPI NTSTATUS NTAPI RtlWow64EnableFsRedirection(IN BOOLEAN Wow64FsEnableRedirection)
Definition: libsupp.c:1002
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
BOOLEAN WINAPI Wow64EnableWow64FsRedirection(IN BOOLEAN Wow64EnableWow64FsRedirection)
Definition: utils.c:759

◆ Wow64RevertWow64FsRedirection()

BOOL WINAPI Wow64RevertWow64FsRedirection ( IN PVOID  OldValue)

Definition at line 805 of file utils.c.

806 {
808  BOOL Result;
809 
810  Status = RtlWow64EnableFsRedirectionEx(OldValue, &OldValue);
811  if (NT_SUCCESS(Status))
812  {
813  Result = TRUE;
814  }
815  else
816  {
818  Result = FALSE;
819  }
820  return Result;
821 }
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSYSAPI NTSTATUS NTAPI RtlWow64EnableFsRedirectionEx(IN PVOID Wow64FsEnableRedirection, OUT PVOID *OldFsRedirectionLevel)
Definition: libsupp.c:1014

Referenced by get_systemdirectory(), and run_winemenubuilder().

Variable Documentation

◆ Basep8BitStringToUnicodeSize

PRTL_COUNT_STRINGA Basep8BitStringToUnicodeSize = BasepAnsiStringToUnicodeSize

Definition at line 29 of file utils.c.

Referenced by SetFileApisToANSI(), and SetFileApisToOEM().

◆ Basep8BitStringToUnicodeString

◆ BasepUnicodeStringTo8BitSize

PRTL_COUNT_STRING BasepUnicodeStringTo8BitSize = BasepUnicodeStringToAnsiSize

Definition at line 28 of file utils.c.

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

◆ BasepUnicodeStringTo8BitString

◆ bIsFileApiAnsi

BOOL bIsFileApiAnsi = TRUE

Definition at line 25 of file utils.c.

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

◆ Restricted

UNICODE_STRING Restricted = RTL_CONSTANT_STRING(L"Restricted")

Definition at line 24 of file utils.c.

Referenced by BaseGetNamedObjectDirectory(), SepCompareTokens(), and SepSidInTokenEx().