30#define ok_w(res, format, szString) \
32 WideCharToMultiByte(CP_ACP, 0, szString, -1, string, MAX_PATH, NULL, NULL); \
33 ok(res, format, string);
48 pOpenProcessToken = (
void *)
GetProcAddress(hadvapi32,
"OpenProcessToken");
50 "GetUserProfileDirectoryA");
66 if (pOpenProcessToken ==
NULL || pGetUserProfileDirectoryA ==
NULL)
68 skip(
"Skipping USERPROFILE check\n");
75 ok(NoErr,
"Failed to get user profile dir, error %u\n",
GetLastError());
80 "Failed to retrieve environment variable USERPROFILE, error %u\n",
83 "USERPROFILE env var %s doesn't match GetUserProfileDirectory %s\n",
87 skip(
"Skipping USERPROFILE check, can't get user profile dir\n");
97 static const char name[] =
"SomeWildName";
98 static const char name_cased[] =
"sOMEwILDnAME";
99 static const char value[] =
"SomeWildValue";
103 "unexpected error in SetEnvironmentVariableA, GetLastError=%d\n",
109 "should return length with terminating 0 ret_size=%d\n", ret_size);
113 ok(
lstrcmpA(
buf,
"foo") == 0,
"should not touch the buffer\n");
115 "should return length with terminating 0 ret_size=%d\n", ret_size);
121 "should return length without terminating 0 ret_size=%d\n", ret_size);
127 "should return length without terminating 0 ret_size=%d\n", ret_size);
131 ok(
ret ==
TRUE,
"should erase existing variable\n");
135 ok(
lstrcmpA(
buf,
"foo") == 0,
"should not touch the buffer\n");
137 "should not find variable but ret_size=%d GetLastError=%d\n",
143 "unexpected error in SetEnvironmentVariableA, GetLastError=%d\n",
150 "should return length without terminating 0 ret_size=%d\n", ret_size);
154 "should not fail with empty value but GetLastError=%d\n",
GetLastError());
162 "%s should be set to \"\" (NT) or removed (Win9x) but ret_size=%d GetLastError=%d and buf=%s\n",
168 "should not find variable but ret_size=%d GetLastError=%d\n",
173 "should not find variable but ret_size=%d GetLastError=%d\n",
178 "should not find variable but ret_size=%d GetLastError=%d\n",
187 static const WCHAR name[] = {
'S',
'o',
'm',
'e',
'W',
'i',
'l',
'd',
'N',
'a',
'm',
'e',0};
188 static const WCHAR value[] = {
'S',
'o',
'm',
'e',
'W',
'i',
'l',
'd',
'V',
'a',
'l',
'u',
'e',0};
189 static const WCHAR name_cased[] = {
's',
'O',
'M',
'E',
'w',
'I',
'L',
'D',
'n',
'A',
'M',
'E',0};
190 static const WCHAR empty_strW[] = { 0 };
191 static const WCHAR fooW[] = {
'f',
'o',
'o',0};
197 win_skip(
"SetEnvironmentVariableW is not implemented\n");
201 "unexpected error in SetEnvironmentVariableW, GetLastError=%d\n",
207 "should return length with terminating 0 ret_size=%d\n",
214 "Expected untouched or empty buffer, got \"%s\"\n",
buf);
217 "should return length with terminating 0 ret_size=%d\n", ret_size);
223 "should return length without terminating 0 ret_size=%d\n", ret_size);
229 "should return length without terminating 0 ret_size=%d\n", ret_size);
233 ok(
ret ==
TRUE,
"should erase existing variable\n");
239 "should not find variable but ret_size=%d GetLastError=%d\n",
245 "unexpected error in SetEnvironmentVariableW, GetLastError=%d\n",
252 "should return length without terminating 0 ret_size=%d\n", ret_size);
260 "should not find variable but ret_size=%d GetLastError=%d\n",
262 ok(
lstrcmpW(
buf, empty_strW) == 0,
"should copy an empty string\n");
267 "should not find variable but ret_size=%d GetLastError=%d\n",
274 "should not find variable but ret_size=%d GetLastError=%d\n",
279 "should fail with NULL, NULL but ret=%d and GetLastError=%d\n",
286 const char*
value=
"Long long value";
287 const char* not_an_env_var=
"%NotAnEnvVar%";
288 char buf[256], buf1[256], buf2[0x8000];
289 DWORD ret_size, ret_size1;
294 ok(ret_size == 1 || ret_size == 0 || ret_size == 2 ,
295 "ExpandEnvironmentStrings returned %d\n", ret_size);
304 "ExpandEnvironmentStrings returned %d instead of %d, %d or %d\n",
312 "ExpandEnvironmentStrings returned %d instead of %d\n",
320 "ExpandEnvironmentStrings returned %d instead of %d\n",
328 "ExpandEnvironmentStrings returned %d instead of %d\n",
330 ok(!
strcmp(buf1,
value),
"ExpandEnvironmentStrings returned [%s]\n", buf1);
335 ok(ret_size ==
strlen(not_an_env_var)+1 ||
336 ret_size == (
strlen(not_an_env_var)+1)*2 ,
337 "ExpandEnvironmentStrings returned %d instead of %d\n", ret_size,
lstrlenA(not_an_env_var)+1);
338 ok(!
strcmp(buf1, not_an_env_var),
"ExpandEnvironmentStrings returned [%s]\n", buf1);
343 ok(!
strcmp(
buf, buf2),
"ExpandEnvironmentStrings failed %s vs %s. ret_size = %d\n",
buf, buf2, ret_size);
346 ok ((ret_size1 >0) && (ret_size1<256),
"GetWindowsDirectory Failed\n");
350 ok(!
strcmp(
buf, buf1),
"ExpandEnvironmentStrings failed %s vs %s. ret_size = %d\n",
buf, buf1, ret_size);
355 strcpy(
buf,
"Indirect-%IndirectVar%-Indirect");
356 strcpy(buf2,
"Indirect-Foo%EnvVar%Bar-Indirect");
359 ret_size == (
strlen(buf2)+1)*2 ,
360 "ExpandEnvironmentStrings returned %d instead of %d\n", ret_size,
lstrlenA(buf2)+1);
361 ok(!
strcmp(buf1, buf2),
"ExpandEnvironmentStrings returned [%s]\n", buf1);
397 trace(
"computer name is \"%s\"\n",
name);
399 ok(
size == name_len,
"size should be same as length, name_len=%d, size=%d\n", name_len,
size);
407 win_skip(
"GetComputerNameW is not implemented\n");
427 static const int MAX_COMP_NAME = 32767;
429 if (!pGetComputerNameExA)
431 win_skip(
"GetComputerNameExA function not implemented\n");
436 ret = pGetComputerNameExA(ComputerNameDnsDomain, (
LPSTR)0xdeadbeef, &
size);
438 ok(
ret == 0,
"Expected 0, got %d\n",
ret);
444 win_skip(
"Win2k doesn't set the size\n");
445 size = MAX_COMP_NAME;
449 ret = pGetComputerNameExA(ComputerNameDnsDomain,
name, &
size);
450 ok(
ret,
"GetComputerNameExA(ComputerNameDnsDomain) failed with error %d\n",
GetLastError());
455 ret = pGetComputerNameExA(ComputerNameDnsFullyQualified, (
LPSTR)0xdeadbeef, &
size);
457 ok(
ret == 0,
"Expected 0, got %d\n",
ret);
462 size = MAX_COMP_NAME;
465 ret = pGetComputerNameExA(ComputerNameDnsFullyQualified,
name, &
size);
466 ok(
ret,
"GetComputerNameExA(ComputerNameDnsFullyQualified) failed with error %d\n",
GetLastError());
467 trace(
"fully qualified hostname is \"%s\"\n",
name);
471 ret = pGetComputerNameExA(ComputerNameDnsHostname, (
LPSTR)0xdeadbeef, &
size);
473 ok(
ret == 0,
"Expected 0, got %d\n",
ret);
478 size = MAX_COMP_NAME;
481 ret = pGetComputerNameExA(ComputerNameDnsHostname,
name, &
size);
482 ok(
ret,
"GetComputerNameExA(ComputerNameDnsHostname) failed with error %d\n",
GetLastError());
487 ret = pGetComputerNameExA(ComputerNameNetBIOS, (
LPSTR)0xdeadbeef, &
size);
489 ok(
ret == 0,
"Expected 0, got %d\n",
ret);
494 size = MAX_COMP_NAME;
497 ret = pGetComputerNameExA(ComputerNameNetBIOS,
name, &
size);
498 ok(
ret,
"GetComputerNameExA(ComputerNameNetBIOS) failed with error %d\n",
GetLastError());
510 if (!pGetComputerNameExW)
512 win_skip(
"GetComputerNameExW function not implemented\n");
517 ret = pGetComputerNameExW(ComputerNameDnsDomain, (
LPWSTR)0xdeadbeef, &
size);
522 ret = pGetComputerNameExW(ComputerNameDnsDomain,
nameW, &
size);
523 ok(
ret,
"GetComputerNameExW(ComputerNameDnsDomain) failed with error %d\n",
GetLastError());
527 ret = pGetComputerNameExW(ComputerNameDnsFullyQualified, (
LPWSTR)0xdeadbeef, &
size);
532 ret = pGetComputerNameExW(ComputerNameDnsFullyQualified,
nameW, &
size);
533 ok(
ret,
"GetComputerNameExW(ComputerNameDnsFullyQualified) failed with error %d\n",
GetLastError());
537 ret = pGetComputerNameExW(ComputerNameDnsHostname, (
LPWSTR)0xdeadbeef, &
size);
542 ret = pGetComputerNameExW(ComputerNameDnsHostname,
nameW, &
size);
543 ok(
ret,
"GetComputerNameExW(ComputerNameDnsHostname) failed with error %d\n",
GetLastError());
547 ret = pGetComputerNameExW(ComputerNameNetBIOS, (
LPWSTR)0xdeadbeef, &
size);
552 ret = pGetComputerNameExW(ComputerNameNetBIOS,
nameW, &
size);
553 ok(
ret,
"GetComputerNameExW(ComputerNameNetBIOS) failed with error %d\n",
GetLastError());
int strcmp(const char *String1, const char *String2)
ACPI_SIZE strlen(const char *String)
char * strcpy(char *DstString, const char *SrcString)
static const WCHAR nameW[]
BOOL WINAPI GetComputerNameW(LPWSTR lpBuffer, LPDWORD lpnSize)
#define ERROR_CALL_NOT_IMPLEMENTED
#define ERROR_INVALID_PARAMETER
#define GetEnvironmentVariableW(x, y, z)
#define GetProcAddress(x, y)
#define GetCurrentProcess()
#define HeapFree(x, y, z)
#define GetEnvironmentVariableA(x, y, z)
DWORD WINAPI ExpandEnvironmentStringsA(IN LPCSTR lpSrc, IN LPSTR lpDst, IN DWORD nSize)
BOOL WINAPI DECLSPEC_HOTPATCH SetEnvironmentVariableW(IN LPCWSTR lpName, IN LPCWSTR lpValue)
BOOL WINAPI DECLSPEC_HOTPATCH SetEnvironmentVariableA(IN LPCSTR lpName, IN LPCSTR lpValue)
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
UINT WINAPI GetWindowsDirectoryA(OUT LPSTR lpBuffer, IN UINT uSize)
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
int WINAPI lstrcmpA(LPCSTR str1, LPCSTR str2)
GLenum GLuint GLenum GLsizei const GLchar * buf
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
int WINAPI lstrlenA(LPCSTR lpString)
static void test_Predefined(void)
#define ok_w(res, format, szString)
static void test_GetComputerNameExA(void)
static void test_ExpandEnvironmentStringsA(void)
static void test_GetComputerNameExW(void)
static void test_GetSetEnvironmentVariableW(void)
static void init_functionpointers(void)
static void test_GetComputerName(void)
static void test_GetSetEnvironmentVariableA(void)
static const WCHAR fooW[]
static HINSTANCE hkernel32
_In_ NDIS_STATUS _In_ ULONG _In_ USHORT _In_opt_ PVOID _In_ ULONG DataSize
BOOL WINAPI SHIM_OBJ_NAME() GetComputerNameA(LPSTR lpBuffer, LPDWORD lpnSize)
DWORD WINAPI GetLastError(void)
#define MAX_COMPUTERNAME_LENGTH
#define ERROR_BUFFER_OVERFLOW
#define ERROR_ENVVAR_NOT_FOUND