ReactOS  0.4.15-dev-2979-gfd8baca
syssetup.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _SETUPDATA
 

Macros

#define __WFILE__   TOWL1(__FILE__)
 
#define TOWL1(p)   TOWL2(p)
 
#define TOWL2(p)   L##p
 
#define LogItem(lpTag, lpMessageText...)   pSetupDebugPrint(__WFILE__, __LINE__, lpTag, lpMessageText)
 

Typedefs

typedef enum _PRODUCT_OPTION PRODUCT_OPTION
 
typedef enum _PRODUCT_OPTIONPPRODUCT_OPTION
 
typedef struct _SETUPDATA SETUPDATA
 
typedef struct _SETUPDATAPSETUPDATA
 

Enumerations

enum  _PRODUCT_OPTION { PRODUCT_OPTION_SERVER, PRODUCT_OPTION_WORKSTATION, PRODUCT_OPTION_DEFAULT = PRODUCT_OPTION_SERVER }
 

Functions

NTSTATUS WINAPI SetAccountsDomainSid (PSID DomainSid, LPCWSTR DomainName)
 
BOOL WINAPI InitializeSetupActionLog (IN BOOL bDeleteOldLogFile)
 
VOID WINAPI TerminateSetupActionLog (VOID)
 
VOID CDECL pSetupDebugPrint (IN PCWSTR pszFileName, IN INT nLineNumber, IN PCWSTR pszTag, IN PCWSTR pszMessage,...)
 

Macro Definition Documentation

◆ __WFILE__

#define __WFILE__   TOWL1(__FILE__)

Definition at line 90 of file syssetup.h.

◆ LogItem

#define LogItem (   lpTag,
  lpMessageText... 
)    pSetupDebugPrint(__WFILE__, __LINE__, lpTag, lpMessageText)

Definition at line 98 of file syssetup.h.

◆ TOWL1

#define TOWL1 (   p)    TOWL2(p)

Definition at line 91 of file syssetup.h.

◆ TOWL2

#define TOWL2 (   p)    L##p

Definition at line 92 of file syssetup.h.

Typedef Documentation

◆ PPRODUCT_OPTION

◆ PRODUCT_OPTION

◆ PSETUPDATA

◆ SETUPDATA

Enumeration Type Documentation

◆ _PRODUCT_OPTION

Enumerator
PRODUCT_OPTION_SERVER 
PRODUCT_OPTION_WORKSTATION 
PRODUCT_OPTION_DEFAULT 

Definition at line 26 of file syssetup.h.

Function Documentation

◆ InitializeSetupActionLog()

BOOL WINAPI InitializeSetupActionLog ( IN BOOL  bDeleteOldLogFile)

◆ pSetupDebugPrint()

VOID CDECL pSetupDebugPrint ( IN PCWSTR  pszFileName,
IN INT  nLineNumber,
IN PCWSTR  pszTag,
IN PCWSTR  pszMessage,
  ... 
)

Definition at line 94 of file logfile.c.

100 {
101  PWSTR pszFormatBuffer = NULL;
102  PWSTR pszLineBuffer = NULL;
103  PSTR pszOutputBuffer = NULL;
104  ULONG ulLineSize, ulOutputSize;
105  DWORD dwWritten;
106  SYSTEMTIME stTime;
107  va_list args;
108 
109  if (hLogFile == NULL)
110  return;
111 
112  GetLocalTime(&stTime);
113 
114  if (pszMessage)
115  {
116  pszFormatBuffer = HeapAlloc(GetProcessHeap(),
118  FORMAT_BUFFER_SIZE * sizeof(WCHAR));
119  if (pszFormatBuffer == NULL)
120  goto done;
121 
122  va_start(args, pszMessage);
123  vsnwprintf(pszFormatBuffer,
125  pszMessage,
126  args);
127  va_end(args);
128  }
129 
130  pszLineBuffer = HeapAlloc(GetProcessHeap(),
132  LINE_BUFFER_SIZE * sizeof(WCHAR));
133  if (pszLineBuffer == NULL)
134  goto done;
135 
136  _snwprintf(pszLineBuffer,
138  L"%02d/%02d/%04d %02d:%02d:%02d.%03d, %s, %d, %s, %s\r\n",
139  stTime.wMonth,
140  stTime.wDay,
141  stTime.wYear,
142  stTime.wHour,
143  stTime.wMinute,
144  stTime.wSecond,
145  stTime.wMilliseconds,
146  pszFileName ? pszFileName : L"",
147  nLineNumber,
148  pszTag ? pszTag : L"",
149  pszFormatBuffer ? pszFormatBuffer : L"");
150 
151  /* Get length of the converted ansi string */
152  ulLineSize = wcslen(pszLineBuffer) * sizeof(WCHAR);
153  RtlUnicodeToMultiByteSize(&ulOutputSize,
154  pszLineBuffer,
155  ulLineSize);
156 
157  /* Allocate message string buffer */
158  pszOutputBuffer = HeapAlloc(GetProcessHeap(),
160  ulOutputSize);
161  if (pszOutputBuffer == NULL)
162  goto done;
163 
164  /* Convert unicode to ansi */
165  RtlUnicodeToMultiByteN(pszOutputBuffer,
166  ulOutputSize,
167  NULL,
168  pszLineBuffer,
169  ulLineSize);
170 
171  /* Set file pointer to the end of the file */
173  0,
174  NULL,
175  FILE_END);
176 
178  pszOutputBuffer,
179  ulOutputSize,
180  &dwWritten,
181  NULL);
182 
183 done:
184  if (pszOutputBuffer)
185  HeapFree(GetProcessHeap(), 0, pszOutputBuffer);
186 
187  if (pszLineBuffer)
188  HeapFree(GetProcessHeap(), 0, pszLineBuffer);
189 
190  if (pszFormatBuffer)
191  HeapFree(GetProcessHeap(), 0, pszFormatBuffer);
192 }
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
#define args
Definition: format.c:66
#define LINE_BUFFER_SIZE
Definition: logfile.c:37
WORD wMonth
Definition: winbase.h:900
uint16_t * PWSTR
Definition: typedefs.h:56
NTSYSAPI NTSTATUS NTAPI RtlUnicodeToMultiByteSize(PULONG MbSize, PCWCH UnicodeString, ULONG UnicodeSize)
Definition: match.c:390
WORD wYear
Definition: winbase.h:899
#define va_end(ap)
Definition: acmsvcex.h:90
WORD WORD PSZ PSZ pszFileName
Definition: vdmdbg.h:41
WORD wMinute
Definition: winbase.h:904
int _snwprintf(wchar_t *buffer, size_t count, const wchar_t *format,...)
char * va_list
Definition: acmsvcex.h:78
VOID WINAPI GetLocalTime(OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:286
#define FORMAT_BUFFER_SIZE
Definition: logfile.c:36
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define FILE_END
Definition: winbase.h:114
__wchar_t WCHAR
Definition: xmlstorage.h:180
__CRT_INLINE int __cdecl vsnwprintf(wchar_t *s, size_t n, const wchar_t *format, va_list arg)
Definition: stdio.h:922
unsigned long DWORD
Definition: ntddk_ex.h:95
HANDLE hLogFile
Definition: logfile.c:34
va_start(ap, x)
WORD wSecond
Definition: winbase.h:905
WORD wMilliseconds
Definition: winbase.h:906
NTSYSAPI NTSTATUS NTAPI RtlUnicodeToMultiByteN(PCHAR MbString, ULONG MbSize, PULONG ResultSize, PCWCH UnicodeString, ULONG UnicodeSize)
static const WCHAR L[]
Definition: oid.c:1250
WORD wDay
Definition: winbase.h:902
signed char * PSTR
Definition: retypes.h:7
WORD wHour
Definition: winbase.h:903
#define NULL
Definition: types.h:112
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
unsigned int ULONG
Definition: retypes.h:1
#define HeapFree(x, y, z)
Definition: compat.h:594
#define SetFilePointer
Definition: compat.h:602

◆ SetAccountsDomainSid()

NTSTATUS WINAPI SetAccountsDomainSid ( PSID  DomainSid,
LPCWSTR  DomainName 
)

Definition at line 28 of file security.c.

31 {
35  LSA_HANDLE PolicyHandle;
36 
37  SAM_HANDLE ServerHandle = NULL;
38  SAM_HANDLE DomainHandle = NULL;
39  DOMAIN_NAME_INFORMATION DomainNameInfo;
40 
41  SIZE_T DomainNameLength = 0;
43 
44  DPRINT("SYSSETUP: SetAccountsDomainSid\n");
45 
46  if (DomainName != NULL)
47  {
48  DomainNameLength = wcslen(DomainName);
49  if (DomainNameLength > UNICODE_STRING_MAX_CHARS)
50  {
52  }
53  }
54 
57 
61  &PolicyHandle);
62  if (Status != STATUS_SUCCESS)
63  {
64  DPRINT("LsaOpenPolicy failed (Status: 0x%08lx)\n", Status);
65  return Status;
66  }
67 
68  Status = LsaQueryInformationPolicy(PolicyHandle,
70  (PVOID *)&OrigInfo);
71  if (Status == STATUS_SUCCESS && OrigInfo != NULL)
72  {
73  if (DomainName == NULL)
74  {
75  Info.DomainName.Buffer = OrigInfo->DomainName.Buffer;
76  Info.DomainName.Length = OrigInfo->DomainName.Length;
77  Info.DomainName.MaximumLength = OrigInfo->DomainName.MaximumLength;
78  }
79  else
80  {
81  Info.DomainName.Buffer = (LPWSTR)DomainName;
82  Info.DomainName.Length = DomainNameLength * sizeof(WCHAR);
83  Info.DomainName.MaximumLength = Info.DomainName.Length + sizeof(WCHAR);
84  }
85 
86  if (DomainSid == NULL)
87  Info.DomainSid = OrigInfo->DomainSid;
88  else
89  Info.DomainSid = DomainSid;
90  }
91  else
92  {
93  Info.DomainName.Buffer = (LPWSTR)DomainName;
94  Info.DomainName.Length = DomainNameLength * sizeof(WCHAR);
95  Info.DomainName.MaximumLength = Info.DomainName.Length + sizeof(WCHAR);
96  Info.DomainSid = DomainSid;
97  }
98 
99  Status = LsaSetInformationPolicy(PolicyHandle,
101  (PVOID)&Info);
102  if (Status != STATUS_SUCCESS)
103  {
104  DPRINT("LsaSetInformationPolicy failed (Status: 0x%08lx)\n", Status);
105  }
106 
107  if (OrigInfo != NULL)
108  LsaFreeMemory(OrigInfo);
109 
110  LsaClose(PolicyHandle);
111 
112  DomainNameInfo.DomainName.Length = DomainNameLength * sizeof(WCHAR);
113  DomainNameInfo.DomainName.MaximumLength = DomainNameInfo.DomainName.Length + sizeof(WCHAR);
114  DomainNameInfo.DomainName.Buffer = (LPWSTR)DomainName;
115 
117  &ServerHandle,
119  NULL);
120  if (NT_SUCCESS(Status))
121  {
122  Status = SamOpenDomain(ServerHandle,
124  Info.DomainSid,
125  &DomainHandle);
126  if (NT_SUCCESS(Status))
127  {
128  Status = SamSetInformationDomain(DomainHandle,
130  &DomainNameInfo);
131  if (!NT_SUCCESS(Status))
132  {
133  DPRINT1("SamSetInformationDomain failed (Status: 0x%08lx)\n", Status);
134  }
135 
136  SamCloseHandle(DomainHandle);
137  }
138  else
139  {
140  DPRINT1("SamOpenDomain failed (Status: 0x%08lx)\n", Status);
141  }
142 
143  SamCloseHandle(ServerHandle);
144  }
145 
146  return Status;
147 }
NTSTATUS NTAPI SamCloseHandle(IN SAM_HANDLE SamHandle)
Definition: samlib.c:497
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define SAM_SERVER_CONNECT
Definition: ntsam.h:99
NTSTATUS WINAPI LsaQueryInformationPolicy(IN LSA_HANDLE PolicyHandle, IN POLICY_INFORMATION_CLASS InformationClass, OUT PVOID *Buffer)
Definition: lsa.c:1471
USHORT MaximumLength
Definition: env_spec_w32.h:370
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define POLICY_VIEW_LOCAL_INFORMATION
Definition: ntsecapi.h:61
NTSTATUS NTAPI SamOpenDomain(IN SAM_HANDLE ServerHandle, IN ACCESS_MASK DesiredAccess, IN PSID DomainId, OUT PSAM_HANDLE DomainHandle)
Definition: samlib.c:1477
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS WINAPI LsaClose(IN LSA_HANDLE ObjectHandle)
Definition: lsa.c:192
NTSTATUS WINAPI LsaSetInformationPolicy(IN LSA_HANDLE PolicyHandle, IN POLICY_INFORMATION_CLASS InformationClass, IN PVOID Buffer)
Definition: lsa.c:1946
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:683
NTSTATUS WINAPI LsaOpenPolicy(IN PLSA_UNICODE_STRING SystemName OPTIONAL, IN PLSA_OBJECT_ATTRIBUTES ObjectAttributes, IN ACCESS_MASK DesiredAccess, OUT PLSA_HANDLE PolicyHandle)
Definition: lsa.c:1181
#define SAM_SERVER_LOOKUP_DOMAIN
Definition: ntsam.h:104
NTSTATUS WINAPI LsaFreeMemory(IN PVOID Buffer)
Definition: lsa.c:699
UNICODE_STRING DomainName
Definition: ntsam.h:409
Status
Definition: gdiplustypes.h:24
#define UNICODE_STRING_MAX_CHARS
NTSTATUS NTAPI SamSetInformationDomain(IN SAM_HANDLE DomainHandle, IN DOMAIN_INFORMATION_CLASS DomainInformationClass, IN PVOID Buffer)
Definition: samlib.c:1946
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define POLICY_TRUST_ADMIN
Definition: ntsecapi.h:64
#define DOMAIN_WRITE_OTHER_PARAMETERS
Definition: ntsam.h:36
struct _LSA_OBJECT_ATTRIBUTES LSA_OBJECT_ATTRIBUTES
ULONG_PTR SIZE_T
Definition: typedefs.h:80
USHORT MaximumLength
Definition: ntsecapi.h:164
#define NULL
Definition: types.h:112
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
LSA_UNICODE_STRING DomainName
Definition: ntsecapi.h:566
#define DPRINT1
Definition: precomp.h:8
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:71
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define memset(x, y, z)
Definition: compat.h:39
NTSTATUS NTAPI SamConnect(IN OUT PUNICODE_STRING ServerName OPTIONAL, OUT PSAM_HANDLE ServerHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes)
Definition: samlib.c:519

Referenced by WriteComputerSettings().

◆ TerminateSetupActionLog()

VOID WINAPI TerminateSetupActionLog ( VOID  )

Definition at line 82 of file logfile.c.

83 {
84  if (hLogFile != NULL)
85  {
87  hLogFile = NULL;
88  }
89 }
#define CloseHandle
Definition: compat.h:598
HANDLE hLogFile
Definition: logfile.c:34
#define NULL
Definition: types.h:112

Referenced by InstallReactOS().