78{
79 BOOL bResult, bResultTemp, bIsUEFI;
85
86
87
88
89
90
91
95 0);
98
100 test_GetFirmwareType(bIsUEFI);
101 if (!bIsUEFI)
102 {
103 skip(
"Skipping tests that require UEFI environment.\n");
104 return;
105 }
106
107
111 0);
113 ok(dwLengthTemp ==
dwLength && dwErrorTemp == dwError,
114 "dwLength = %lu, LastError = %lu, expected bResult = %lu, LastError = %lu\n",
115 dwLengthTemp,
116 dwErrorTemp,
118 dwError);
119
120
122 EfiVariableValue =
RtlRandom(&RandomSeed);
123
124
125
128 &EfiVariableValue,
129 sizeof(EfiVariableValue));
132 "bResult = %d, LastError = %lu, expected bResult = 0, LastError = ERROR_PRIVILEGE_NOT_HELD\n",
133 bResult,
134 dwError);
135
136
139 &EfiVariableValue,
140 sizeof(EfiVariableValue));
142 ok(bResultTemp == bResult && dwErrorTemp == dwError,
143 "bResult = %d, LastError = %lu, expected bResult = %d, LastError = %lu\n",
144 bResultTemp,
145 dwErrorTemp,
146 bResult,
147 dwError);
148
149
151 if (!bResult)
152 {
153 skip(
"OpenProcessToken failed with error: 0x%08lX, aborting.\n",
GetLastError());
154 return;
155 }
161 {
162 skip(
"NtAdjustPrivilegesToken failed with status: 0x%08lX, aborting.\n",
Status);
164 return;
165 }
166
167
170 &EfiVariableValue,
171 sizeof(EfiVariableValue));
173 "SetFirmwareEnvironmentVariableW failed with error: 0x%08lX\n",
175 if (bResult)
176 {
177
180 &dwValue,
181 sizeof(dwValue));
183 "GetFirmwareEnvironmentVariableW failed with error: 0x%08lX\n",
186 {
187 ok(
dwLength ==
sizeof(EfiVariableValue) && dwValue == EfiVariableValue,
188 "Retrieved variable different from what we set, "
189 "dwLength = %lu, dwValue = %lu, expected dwLength = %u, dwValue = %lu",
191 dwValue,
192 sizeof(EfiVariableValue),
193 EfiVariableValue);
194 }
195 }
196
197
198 EfiVariableValue =
RtlRandom(&RandomSeed);
201 &EfiVariableValue,
202 sizeof(EfiVariableValue));
204 "SetFirmwareEnvironmentVariableA failed with error: 0x%08lX\n",
206 if (bResult)
207 {
208
211 &dwValue,
212 sizeof(dwValue));
214 "GetFirmwareEnvironmentVariableA failed with error: 0x%08lX\n",
217 {
218 ok(
dwLength ==
sizeof(EfiVariableValue) && dwValue == EfiVariableValue,
219 "Retrieved variable different from what we set, "
220 "dwLength = %lu, dwValue = %lu, expected dwLength = %u, dwValue = %lu",
222 dwValue,
223 sizeof(EfiVariableValue),
224 EfiVariableValue);
225 }
226 }
227
228
232 0);
234 "SetFirmwareEnvironmentVariableW failed with error: 0x%08lX\n",
236 if (bResult)
237 {
240 &dwValue,
241 sizeof(dwValue));
242 ok(
dwLength == 0,
"SetFirmwareEnvironmentVariableW didn't delete the variable!\n");
243 }
244
245
248 &EfiVariableValue,
249 sizeof(EfiVariableValue));
250 if (!bResult)
251 {
252 skip(
"SetFirmwareEnvironmentVariableW failed to restore variable with error: 0x%08lX\n",
255 }
259 0);
261 "SetFirmwareEnvironmentVariableA failed with error: 0x%08lX\n",
263 if (bResult)
264 {
267 &dwValue,
268 sizeof(dwValue));
269 ok(
dwLength == 0,
"SetFirmwareEnvironmentVariableA didn't delete the variable!\n");
270 }
271
273
278}
#define EFI_DUMMY_NAMESPACE_GUID_STRING
#define EFI_TEST_VARIABLE_NAME
#define EFI_TEST_GUID_STRING
#define EFI_DUMMY_VARIABLE_NAME
#define ERROR_INVALID_FUNCTION
BOOL WINAPI OpenProcessToken(HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle)
#define GetCurrentProcess()
static DWORD DWORD * dwLength
BOOL WINAPI SetFirmwareEnvironmentVariableA(_In_ LPCSTR lpName, _In_ LPCSTR lpGuid, _In_reads_bytes_opt_(nSize) PVOID pValue, _In_ DWORD nSize)
BOOL WINAPI SetFirmwareEnvironmentVariableW(_In_ LPCWSTR lpName, _In_ LPCWSTR lpGuid, _In_reads_bytes_opt_(nSize) PVOID pValue, _In_ DWORD nSize)
DWORD WINAPI GetTickCount(VOID)
IN CINT OUT PVOID IN ULONG OUT PULONG ReturnLength
#define SE_SYSTEM_ENVIRONMENT_PRIVILEGE
NTSYSAPI ULONG NTAPI RtlRandom(_Inout_ PULONG Seed)
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
_Must_inspect_result_ __kernel_entry NTSTATUS NTAPI NtAdjustPrivilegesToken(_In_ HANDLE TokenHandle, _In_ BOOLEAN DisableAllPrivileges, _In_opt_ PTOKEN_PRIVILEGES NewState, _In_ ULONG BufferLength, _Out_writes_bytes_to_opt_(BufferLength, *ReturnLength) PTOKEN_PRIVILEGES PreviousState, _When_(PreviousState!=NULL, _Out_) PULONG ReturnLength)
Removes a certain amount of privileges of a token based upon the request by the caller.
BOOL Privilege(LPTSTR pszPrivilege, BOOL bEnable)
#define ERROR_PRIVILEGE_NOT_HELD
FORCEINLINE LUID NTAPI_INLINE RtlConvertUlongToLuid(_In_ ULONG Val)
#define TOKEN_ADJUST_PRIVILEGES
#define SE_PRIVILEGE_ENABLED