ReactOS  0.4.13-dev-100-gc8611ae
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  _TZ_INFO
 
struct  _TIMEZONE_ENTRY
 
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 struct _TZ_INFO TZ_INFO
 
typedef struct _TZ_INFOPTZ_INFO
 
typedef struct _TIMEZONE_ENTRY TIMEZONE_ENTRY
 
typedef struct _TIMEZONE_ENTRYPTIMEZONE_ENTRY
 
typedef struct _SETUPDATA SETUPDATA
 
typedef struct _SETUPDATAPSETUPDATA
 

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 102 of file syssetup.h.

◆ LogItem

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

Definition at line 110 of file syssetup.h.

◆ TOWL1

#define TOWL1 (   p)    TOWL2(p)

Definition at line 103 of file syssetup.h.

◆ TOWL2

#define TOWL2 (   p)    L##p

Definition at line 104 of file syssetup.h.

Typedef Documentation

◆ PSETUPDATA

◆ PTIMEZONE_ENTRY

◆ PTZ_INFO

◆ SETUPDATA

◆ TIMEZONE_ENTRY

◆ TZ_INFO

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 LINE_BUFFER_SIZE
Definition: logfile.c:37
WORD wMonth
Definition: winbase.h:871
uint16_t * PWSTR
Definition: typedefs.h:54
NTSYSAPI NTSTATUS NTAPI RtlUnicodeToMultiByteSize(PULONG MbSize, PCWCH UnicodeString, ULONG UnicodeSize)
Definition: match.c:390
DWORD WINAPI DECLSPEC_HOTPATCH SetFilePointer(HANDLE hFile, LONG lDistanceToMove, PLONG lpDistanceToMoveHigh, DWORD dwMoveMethod)
Definition: fileinfo.c:204
WORD wYear
Definition: winbase.h:870
#define va_end(ap)
Definition: acmsvcex.h:90
WORD WORD PSZ PSZ pszFileName
Definition: vdmdbg.h:41
WORD wMinute
Definition: winbase.h:875
int _snwprintf(wchar_t *buffer, size_t count, const wchar_t *format,...)
smooth NULL
Definition: ftsmooth.c:416
char * va_list
Definition: acmsvcex.h:78
VOID WINAPI GetLocalTime(OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:276
#define FORMAT_BUFFER_SIZE
Definition: logfile.c:36
#define GetProcessHeap()
Definition: compat.h:395
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:930
unsigned long DWORD
Definition: ntddk_ex.h:95
HANDLE hLogFile
Definition: logfile.c:34
WORD wSecond
Definition: winbase.h:876
WORD wMilliseconds
Definition: winbase.h:877
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:873
signed char * PSTR
Definition: retypes.h:7
WORD wHour
Definition: winbase.h:874
#define va_start(ap, A)
Definition: acmsvcex.h:91
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
unsigned int ULONG
Definition: retypes.h:1
#define args
Definition: format.c:66
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define HeapFree(x, y, z)
Definition: compat.h:394

◆ SetAccountsDomainSid()

NTSTATUS WINAPI SetAccountsDomainSid ( PSID  DomainSid,
LPCWSTR  DomainName 
)

Definition at line 25 of file security.c.

28 {
32  LSA_HANDLE PolicyHandle;
33 
34  SAM_HANDLE ServerHandle = NULL;
35  SAM_HANDLE DomainHandle = NULL;
36  DOMAIN_NAME_INFORMATION DomainNameInfo;
37 
39 
40  DPRINT("SYSSETUP: SetAccountsDomainSid\n");
41 
44 
48  &PolicyHandle);
49  if (Status != STATUS_SUCCESS)
50  {
51  DPRINT("LsaOpenPolicy failed (Status: 0x%08lx)\n", Status);
52  return Status;
53  }
54 
55  Status = LsaQueryInformationPolicy(PolicyHandle,
57  (PVOID *)&OrigInfo);
58  if (Status == STATUS_SUCCESS && OrigInfo != NULL)
59  {
60  if (DomainName == NULL)
61  {
62  Info.DomainName.Buffer = OrigInfo->DomainName.Buffer;
63  Info.DomainName.Length = OrigInfo->DomainName.Length;
64  Info.DomainName.MaximumLength = OrigInfo->DomainName.MaximumLength;
65  }
66  else
67  {
68  Info.DomainName.Buffer = (LPWSTR)DomainName;
69  Info.DomainName.Length = wcslen(DomainName) * sizeof(WCHAR);
70  Info.DomainName.MaximumLength = Info.DomainName.Length + sizeof(WCHAR);
71  }
72 
73  if (DomainSid == NULL)
74  Info.DomainSid = OrigInfo->DomainSid;
75  else
76  Info.DomainSid = DomainSid;
77  }
78  else
79  {
80  Info.DomainName.Buffer = (LPWSTR)DomainName;
81  Info.DomainName.Length = wcslen(DomainName) * sizeof(WCHAR);
82  Info.DomainName.MaximumLength = Info.DomainName.Length + sizeof(WCHAR);
83  Info.DomainSid = DomainSid;
84  }
85 
86  Status = LsaSetInformationPolicy(PolicyHandle,
88  (PVOID)&Info);
89  if (Status != STATUS_SUCCESS)
90  {
91  DPRINT("LsaSetInformationPolicy failed (Status: 0x%08lx)\n", Status);
92  }
93 
94  if (OrigInfo != NULL)
95  LsaFreeMemory(OrigInfo);
96 
97  LsaClose(PolicyHandle);
98 
99  DomainNameInfo.DomainName.Length = wcslen(DomainName) * sizeof(WCHAR);
100  DomainNameInfo.DomainName.MaximumLength = (wcslen(DomainName) + 1) * sizeof(WCHAR);
101  DomainNameInfo.DomainName.Buffer = (LPWSTR)DomainName;
102 
104  &ServerHandle,
106  NULL);
107  if (NT_SUCCESS(Status))
108  {
109  Status = SamOpenDomain(ServerHandle,
111  Info.DomainSid,
112  &DomainHandle);
113  if (NT_SUCCESS(Status))
114  {
115  Status = SamSetInformationDomain(DomainHandle,
117  (PVOID)&DomainNameInfo);
118  if (!NT_SUCCESS(Status))
119  {
120  DPRINT1("SamSetInformationDomain failed (Status: 0x%08lx)\n", Status);
121  }
122 
123  SamCloseHandle(DomainHandle);
124  }
125  else
126  {
127  DPRINT1("SamOpenDomain failed (Status: 0x%08lx)\n", Status);
128  }
129 
130  SamCloseHandle(ServerHandle);
131  }
132 
133  return Status;
134 }
NTSTATUS NTAPI SamCloseHandle(IN SAM_HANDLE SamHandle)
Definition: samlib.c:476
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 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:1441
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
struct TraceInfo Info
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
smooth NULL
Definition: ftsmooth.c:416
#define SAM_SERVER_LOOKUP_DOMAIN
Definition: ntsam.h:104
void DPRINT(...)
Definition: polytest.cpp:61
NTSTATUS WINAPI LsaFreeMemory(IN PVOID Buffer)
Definition: lsa.c:699
UNICODE_STRING DomainName
Definition: ntsam.h:381
NTSTATUS NTAPI SamSetInformationDomain(IN SAM_HANDLE DomainHandle, IN DOMAIN_INFORMATION_CLASS DomainInformationClass, IN PVOID Buffer)
Definition: samlib.c:1910
__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
Status
Definition: gdiplustypes.h:24
USHORT MaximumLength
Definition: ntsecapi.h:164
LSA_UNICODE_STRING DomainName
Definition: ntsecapi.h:563
#define DPRINT1
Definition: precomp.h:8
WCHAR * LPWSTR
Definition: xmlstorage.h:184
return STATUS_SUCCESS
Definition: btrfs.c:2725
#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:498
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

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:398
smooth NULL
Definition: ftsmooth.c:416
HANDLE hLogFile
Definition: logfile.c:34

Referenced by InstallReactOS().