Newer
Older
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
ok(dos.e_magic == IMAGE_DOS_SIGNATURE, "Unexpected signature %x\n", dos.e_magic);
ret = ReadProcessMemory(hProc, (char*)(DWORD_PTR)(base + dos.e_lfanew), &signature, sizeof(signature), NULL);
ok(ret, "ReadProcessMemory failed: %lu\n", GetLastError());
ok(signature == IMAGE_NT_SIGNATURE, "Unexpected signature %lx\n", signature);
ret = ReadProcessMemory(hProc, (char*)(DWORD_PTR)(base + dos.e_lfanew + sizeof(signature) ), &fh, sizeof(fh), NULL);
ok(ret, "ReadProcessMemory failed: %lu\n", GetLastError());
return fh.Machine;
}
static void aggregation_push(struct loaded_module_aggregation* aggregation, DWORD64 base, const WCHAR* name, USHORT machine)
{
BOOL wow64;
switch (get_machine_bitness(machine))
{
case 32: aggregation->count_32bit++; break;
case 64: aggregation->count_64bit++; break;
default: break;
}
if (ends_withW(name, L".exe"))
aggregation->count_exe++;
if (ends_withW(name, L"ntdll.dll"))
aggregation->count_ntdll++;
if (!wcsnicmp(name, system_directory, wcslen(system_directory)))
aggregation->count_systemdir++;
if (IsWow64Process(aggregation->proc, &wow64) && wow64 &&
!wcsnicmp(name, wow64_directory, wcslen(wow64_directory)))
aggregation->count_wowdir++;
}
static BOOL CALLBACK aggregation_sym_cb(const WCHAR* name, DWORD64 base, void* usr)
{
struct loaded_module_aggregation* aggregation = usr;
IMAGEHLP_MODULEW64 module;
BOOL ret;
module.SizeOfStruct = sizeof(module);
ret = SymGetModuleInfoW64(aggregation->proc, base, &module);
ok(ret, "SymGetModuleInfoW64 failed: %lu\n", GetLastError());
aggregation_push(aggregation, base, module.LoadedImageName, module.MachineType);
return TRUE;
}
static BOOL CALLBACK aggregate_enum_cb(PCWSTR imagename, DWORD64 base, ULONG sz, PVOID usr)
{
struct loaded_module_aggregation* aggregation = usr;
aggregation_push(aggregation, base, imagename, pcs_get_loaded_module_machine(aggregation->proc, base));
return TRUE;
}
static BOOL pcs_fetch_module_name(HANDLE proc, void* str_addr, void* module_base, WCHAR* buffer, unsigned bufsize, BOOL unicode)
{
BOOL ret = FALSE;
if (str_addr)
{
void* tgt = NULL;
SIZE_T addr_size;
SIZE_T r;
BOOL is_wow64;
ret = IsWow64Process(proc, &is_wow64);
ok(ret, "IsWow64Process failed: %lu\n", GetLastError());
addr_size = is_win64 && is_wow64 ? 4 : sizeof(void*);
/* note: string is not always present */
/* assuming little endian CPU */
ret = ReadProcessMemory(proc, str_addr, &tgt, addr_size, &r) && r == addr_size;
if (ret)
{
if (unicode)
{
ret = ReadProcessMemory(proc, tgt, buffer, bufsize, &r);
if (ret)
buffer[r / sizeof(WCHAR)] = '\0';
/* Win11 starts exposing ntdll from the string indirection in DLL load event.
* So we won't fall back to the mapping's filename below, good!
* But the sent DLL name for the 32bit ntdll is now "ntdll32.dll" instead of "ntdll.dll".
* Replace it by "ntdll.dll" so we won't have to worry about it in the rest of the code.
*/
if (broken(!wcscmp(buffer, L"ntdll32.dll")))
wcscpy(buffer, L"ntdll.dll");
}
else
{
char *tmp = malloc(bufsize);
if (tmp)
{
ret = ReadProcessMemory(proc, tgt, tmp, bufsize, &r);
if (ret)
{
if (!r) tmp[0] = '\0';
else if (!memchr(tmp, '\0', r)) tmp[r - 1] = '\0';
MultiByteToWideChar(CP_ACP, 0, tmp, -1, buffer, bufsize);
buffer[bufsize - 1] = '\0';
}
free(tmp);
}
else ret = FALSE;
}
}
}
if (!ret)
{
WCHAR tmp[128];
WCHAR drv[3] = {L'A', L':', L'\0'};
ret = GetMappedFileNameW(proc, module_base, buffer, bufsize);
/* Win8 returns this error */
if (!broken(!ret && GetLastError() == ERROR_FILE_INVALID))
{
ok(ret, "GetMappedFileNameW failed: %lu\n", GetLastError());
if (!wcsncmp(buffer, L"\\??\\", 4))
memmove(buffer, buffer + 4, (wcslen(buffer) + 1 - 4) * sizeof(WCHAR));
while (drv[0] <= L'Z')
{
if (QueryDosDeviceW(drv, tmp, ARRAY_SIZE(tmp)))
{
size_t len = wcslen(tmp);
if (len >= 2 && !wcsnicmp(buffer, tmp, len))
{
memmove(buffer + 2, buffer + len, (wcslen(buffer) + 1 - len) * sizeof(WCHAR));
buffer[0] = drv[0];
buffer[1] = drv[1];
break;
}
}
drv[0]++;
}
}
}
return ret;
}
static void test_live_modules_proc(WCHAR* exename, BOOL with_32)
{
WCHAR buffer[MAX_PATH];
PROCESS_INFORMATION pi = {0};
STARTUPINFOW si = {0};
DEBUG_EVENT de;
BOOL ret;
BOOL is_wow64 = FALSE;
struct loaded_module_aggregation aggregation_event = {};
struct loaded_module_aggregation aggregation_enum = {};
struct loaded_module_aggregation aggregation_sym = {};
DWORD old_options = SymGetOptions();
enum process_kind pcskind;
ret = CreateProcessW(NULL, exename, NULL, NULL, FALSE, DEBUG_PROCESS, NULL, NULL, &si, &pi);
if (!ret)
{
if (GetLastError() == ERROR_FILE_NOT_FOUND)
skip("Skip wow64 test on non compatible platform\n");
else
ok(ret, "CreateProcess failed: %lu\n", GetLastError());
return;
}
ret = IsWow64Process(pi.hProcess, &is_wow64);
ok(ret, "IsWow64Process failed: %lu\n", GetLastError());
pcskind = get_process_kind(pi.hProcess);
ok(pcskind != PCSKIND_ERROR, "Unexpected error\n");
winetest_push_context("[%u/%u enum:%s %s]",
is_win64 ? 64 : 32, is_wow64 ? 32 : 64, with_32 ? "+32bit" : "default",
process_kind2string(pcskind));
memset(&aggregation_event, 0, sizeof(aggregation_event));
aggregation_event.proc = pi.hProcess;
while (WaitForDebugEvent(&de, 2000))
{
switch (de.dwDebugEventCode)
{
case CREATE_PROCESS_DEBUG_EVENT:
if (pcs_fetch_module_name(pi.hProcess, de.u.CreateProcessInfo.lpImageName, de.u.CreateProcessInfo.lpBaseOfImage,
buffer, ARRAY_SIZE(buffer), de.u.CreateProcessInfo.fUnicode))
aggregation_push(&aggregation_event, (ULONG_PTR)de.u.CreateProcessInfo.lpBaseOfImage, buffer,
pcs_get_loaded_module_machine(pi.hProcess, (ULONG_PTR)de.u.CreateProcessInfo.lpBaseOfImage));
break;
case LOAD_DLL_DEBUG_EVENT:
if (pcs_fetch_module_name(pi.hProcess, de.u.LoadDll.lpImageName, de.u.LoadDll.lpBaseOfDll, buffer, ARRAY_SIZE(buffer), de.u.LoadDll.fUnicode))
aggregation_push(&aggregation_event, (ULONG_PTR)de.u.LoadDll.lpBaseOfDll, buffer,
pcs_get_loaded_module_machine(pi.hProcess, (ULONG_PTR)de.u.LoadDll.lpBaseOfDll));
break;
case UNLOAD_DLL_DEBUG_EVENT:
/* FIXME: we should take of updating aggregation_event; as of today, doesn't trigger issue */
break;
case EXCEPTION_DEBUG_EVENT:
break;
}
ret = ContinueDebugEvent(de.dwProcessId, de.dwThreadId, DBG_CONTINUE);
ok(ret, "ContinueDebugEvent failed: %lu\n", GetLastError());
}
if (with_32)
SymSetOptions(old_options | SYMOPT_INCLUDE_32BIT_MODULES);
else
SymSetOptions(old_options & ~SYMOPT_INCLUDE_32BIT_MODULES);
memset(&aggregation_enum, 0, sizeof(aggregation_enum));
aggregation_enum.proc = pi.hProcess;
ret = wrapper_EnumerateLoadedModulesW64(pi.hProcess, aggregate_enum_cb, &aggregation_enum);
ok(ret, "SymEnumerateModulesW64 failed: %lu\n", GetLastError());
ret = SymInitialize(pi.hProcess, NULL, TRUE);
ok(ret, "SymInitialize failed: %lu\n", GetLastError());
/* .exe ntdll kernel32 kernelbase user32 gdi32 (all are in system or wow64 directory) */
#define MODCOUNT 6
/* when in wow64: wow64 wow64cpu wow64win ntdll (64bit) */
#define MODWOWCOUNT 4
/* .exe is reported twice in enum */
#define XTRAEXE (!!with_32)
/* ntdll is reported twice in enum */
#define XTRANTDLL (is_win64 && is_wow64 && (!!with_32))
memset(&aggregation_sym, 0, sizeof(aggregation_sym));
aggregation_sym.proc = pi.hProcess;
ret = SymEnumerateModulesW64(pi.hProcess, aggregation_sym_cb, &aggregation_sym);
ok(ret, "SymEnumerateModulesW64 failed: %lu\n", GetLastError());
if (pcskind == PCSKIND_64BIT) /* 64/64 */
{
ok(is_win64, "How come?\n");
ok(aggregation_event.count_exe == 1, "Unexpected event.count_exe %u\n", aggregation_event.count_exe);
ok(aggregation_event.count_32bit == 0, "Unexpected event.count_32bit %u\n", aggregation_event.count_32bit);
ok(aggregation_event.count_64bit >= MODCOUNT, "Unexpected event.count_64bit %u\n", aggregation_event.count_64bit);
ok(aggregation_event.count_systemdir >= MODCOUNT, "Unexpected event.count_systemdir %u\n", aggregation_event.count_systemdir);
ok(aggregation_event.count_wowdir == 0, "Unexpected event.count_wowdir %u\n", aggregation_event.count_wowdir);
ok(aggregation_event.count_ntdll == 1, "Unexpected event.count_ntdll %u\n", aggregation_event.count_ntdll);
ok(aggregation_enum.count_exe == 1, "Unexpected enum.count_exe %u\n", aggregation_enum.count_exe);
ok(aggregation_enum.count_32bit == 0, "Unexpected enum.count_32bit %u\n", aggregation_enum.count_32bit);
ok(aggregation_enum.count_64bit >= MODCOUNT, "Unexpected enum.count_64bit %u\n", aggregation_enum.count_64bit);
ok(aggregation_enum.count_systemdir >= MODCOUNT, "Unexpected enum.count_systemdir %u\n", aggregation_enum.count_systemdir);
ok(aggregation_enum.count_wowdir == 0, "Unexpected enum.count_wowdir %u\n", aggregation_enum.count_wowdir);
ok(aggregation_enum.count_ntdll == 1, "Unexpected enum.count_ntdll %u\n", aggregation_enum.count_ntdll);
ok(aggregation_sym.count_exe == 1, "Unexpected sym.count_exe %u\n", aggregation_sym.count_exe);
ok(aggregation_sym.count_32bit == 0, "Unexpected sym.count_32bit %u\n", aggregation_sym.count_32bit);
ok(aggregation_sym.count_64bit >= MODCOUNT, "Unexpected sym.count_64bit %u\n", aggregation_sym.count_64bit);
ok(aggregation_sym.count_systemdir >= MODCOUNT, "Unexpected sym.count_systemdir %u\n", aggregation_sym.count_systemdir);
ok(aggregation_sym.count_wowdir == 0, "Unexpected sym.count_wowdir %u\n", aggregation_sym.count_wowdir);
ok(aggregation_sym.count_ntdll == 1, "Unexpected sym.count_ntdll %u\n", aggregation_sym.count_ntdll);
}
else if (pcskind == PCSKIND_32BIT) /* 32/32 */
{
ok(!is_win64, "How come?\n");
ok(aggregation_event.count_exe == 1, "Unexpected event.count_exe %u\n", aggregation_event.count_exe);
ok(aggregation_event.count_32bit >= MODCOUNT, "Unexpected event.count_32bit %u\n", aggregation_event.count_32bit);
ok(aggregation_event.count_64bit == 0, "Unexpected event.count_64bit %u\n", aggregation_event.count_64bit);
ok(aggregation_event.count_systemdir >= MODCOUNT, "Unexpected event.count_systemdir %u\n", aggregation_event.count_systemdir);
ok(aggregation_event.count_wowdir == 0, "Unexpected event.count_wowdir %u\n", aggregation_event.count_wowdir);
ok(aggregation_event.count_ntdll == 1, "Unexpected event.count_ntdll %u\n", aggregation_event.count_ntdll);
ok(aggregation_enum.count_exe == 1, "Unexpected enum.count_exe %u\n", aggregation_enum.count_exe);
ok(aggregation_enum.count_32bit >= MODCOUNT, "Unexpected enum.count_32bit %u\n", aggregation_enum.count_32bit);
ok(aggregation_enum.count_64bit == 0, "Unexpected enum.count_64bit %u\n", aggregation_enum.count_64bit);
ok(aggregation_enum.count_systemdir >= MODCOUNT, "Unexpected enum.count_systemdir %u\n", aggregation_enum.count_systemdir);
ok(aggregation_enum.count_wowdir == 0, "Unexpected enum.count_wowdir %u\n", aggregation_enum.count_wowdir);
ok(aggregation_enum.count_ntdll == 1, "Unexpected enum.count_ntdll %u\n", aggregation_enum.count_ntdll);
ok(aggregation_sym.count_exe == 1, "Unexpected sym.count_exe %u\n", aggregation_sym.count_exe);
ok(aggregation_sym.count_32bit >= MODCOUNT, "Unexpected sym.count_32bit %u\n", aggregation_sym.count_32bit);
ok(aggregation_sym.count_64bit == 0, "Unexpected sym.count_64bit %u\n", aggregation_sym.count_64bit);
ok(aggregation_sym.count_systemdir >= MODCOUNT, "Unexpected sym.count_systemdir %u\n", aggregation_sym.count_systemdir);
ok(aggregation_sym.count_wowdir == 0, "Unexpected sym.count_wowdir %u\n", aggregation_sym.count_wowdir);
ok(aggregation_sym.count_ntdll == 1, "Unexpected sym.count_ntdll %u\n", aggregation_sym.count_ntdll);
}
else if (is_win64 && pcskind == PCSKIND_WOW64) /* 64/32 */
{
ok(aggregation_event.count_exe == 1, "Unexpected event.count_exe %u\n", aggregation_event.count_exe);
ok(aggregation_event.count_32bit >= MODCOUNT, "Unexpected event.count_32bit %u\n", aggregation_event.count_32bit);
ok(aggregation_event.count_64bit >= MODWOWCOUNT, "Unexpected event.count_64bit %u\n", aggregation_event.count_64bit);
ok(aggregation_event.count_systemdir >= MODWOWCOUNT, "Unexpected event.count_systemdir %u\n", aggregation_event.count_systemdir);
ok(aggregation_event.count_wowdir >= MODCOUNT, "Unexpected event.count_wowdir %u\n", aggregation_event.count_wowdir);
ok(aggregation_event.count_ntdll == 2 || broken(aggregation_event.count_ntdll == 3),
/* yes! with Win 864 and Win1064 v 1507... 2 ntdll:s ain't enuff <g>, 3 are reported! */
/* in fact the first ntdll is reported twice (at same address) in two consecutive events */
"Unexpected event.count_ntdll %u\n", aggregation_event.count_ntdll);
ok(aggregation_enum.count_exe == 1 + XTRAEXE, "Unexpected enum.count_exe %u\n", aggregation_enum.count_exe);
if (with_32)
ok(aggregation_enum.count_32bit >= MODCOUNT, "Unexpected enum.count_32bit %u\n", aggregation_enum.count_32bit);
else
ok(aggregation_enum.count_32bit == 1, "Unexpected enum.count_32bit %u\n", aggregation_enum.count_32bit);
ok(aggregation_enum.count_64bit >= MODWOWCOUNT, "Unexpected enum.count_64bit %u\n", aggregation_enum.count_64bit);
ok(aggregation_enum.count_systemdir >= MODWOWCOUNT, "Unexpected enum.count_systemdir %u\n", aggregation_enum.count_systemdir);
if (with_32)
ok(aggregation_enum.count_wowdir >= MODCOUNT, "Unexpected enum.count_wowdir %u\n", aggregation_enum.count_wowdir);
else
ok(aggregation_enum.count_wowdir == 1, "Unexpected enum.count_wowdir %u\n", aggregation_enum.count_wowdir);
ok(aggregation_enum.count_ntdll == 1 + XTRANTDLL, "Unexpected enum.count_ntdll %u\n", aggregation_enum.count_ntdll);
ok(aggregation_sym.count_exe == 1, "Unexpected sym.count_exe %u\n", aggregation_sym.count_exe);
if (with_32)
ok(aggregation_sym.count_32bit >= MODCOUNT, "Unexpected sym.count_32bit %u\n", aggregation_sym.count_32bit);
else
ok(aggregation_sym.count_32bit == 1, "Unexpected sym.count_32bit %u\n", aggregation_sym.count_32bit);
ok(aggregation_sym.count_64bit >= MODWOWCOUNT, "Unexpected sym.count_64bit %u\n", aggregation_sym.count_64bit);
ok(aggregation_sym.count_systemdir >= MODWOWCOUNT, "Unexpected sym.count_systemdir %u\n", aggregation_sym.count_systemdir);
if (with_32)
ok(aggregation_sym.count_wowdir >= MODCOUNT, "Unexpected sym.count_wowdir %u\n", aggregation_sym.count_wowdir);
else
ok(aggregation_sym.count_wowdir == 1, "Unexpected sym.count_wowdir %u\n", aggregation_sym.count_wowdir);
ok(aggregation_sym.count_ntdll == 1 + XTRANTDLL, "Unexpected sym.count_ntdll %u\n", aggregation_sym.count_ntdll);
}
else if (!is_win64 && pcskind == PCSKIND_WOW64) /* 32/32 */
{
ok(aggregation_event.count_exe == 1, "Unexpected event.count_exe %u\n", aggregation_event.count_exe);
ok(aggregation_event.count_32bit >= MODCOUNT, "Unexpected event.count_32bit %u\n", aggregation_event.count_32bit);
ok(aggregation_event.count_64bit == 0, "Unexpected event.count_64bit %u\n", aggregation_event.count_64bit);
ok(aggregation_event.count_systemdir == 0, "Unexpected event.count_systemdir %u\n", aggregation_event.count_systemdir);
ok(aggregation_event.count_wowdir >= MODCOUNT, "Unexpected event.count_wowdir %u\n", aggregation_event.count_wowdir);
ok(aggregation_event.count_ntdll == 1, "Unexpected event.count_ntdll %u\n", aggregation_event.count_ntdll);
ok(aggregation_enum.count_exe == 1 + XTRAEXE, "Unexpected enum.count_exe %u\n", aggregation_enum.count_exe);
ok(aggregation_enum.count_32bit >= MODCOUNT, "Unexpected enum.count_32bit %u\n", aggregation_enum.count_32bit);
ok(aggregation_enum.count_64bit == 0, "Unexpected enum.count_64bit %u\n", aggregation_enum.count_64bit);
/* yes that's different from event! */
todo_wine
ok(aggregation_enum.count_systemdir >= MODCOUNT - 1, "Unexpected enum.count_systemdir %u\n", aggregation_enum.count_systemdir);
/* .exe */
todo_wine
ok(aggregation_enum.count_wowdir == 1, "Unexpected enum.count_wowdir %u\n", aggregation_enum.count_wowdir);
ok(aggregation_enum.count_ntdll == 1, "Unexpected enum.count_ntdll %u\n", aggregation_enum.count_ntdll);
ok(aggregation_sym.count_exe == 1, "Unexpected sym.count_exe %u\n", aggregation_sym.count_exe);
ok(aggregation_sym.count_32bit >= MODCOUNT, "Unexpected sym.count_32bit %u\n", aggregation_sym.count_32bit);
ok(aggregation_sym.count_64bit == 0, "Unexpected sym.count_64bit %u\n", aggregation_sym.count_64bit);
todo_wine
ok(aggregation_sym.count_systemdir >= MODCOUNT - 1, "Unexpected sym.count_systemdir %u\n", aggregation_sym.count_systemdir);
/* .exe */
todo_wine
ok(aggregation_sym.count_wowdir == 1, "Unexpected sym.count_wowdir %u\n", aggregation_sym.count_wowdir);
ok(aggregation_sym.count_ntdll == 1 + XTRANTDLL, "Unexpected sym.count_ntdll %u\n", aggregation_sym.count_ntdll);
}
else if (is_win64 && pcskind == PCSKIND_WINE_OLD_WOW64) /* 64/32 */
{
ok(aggregation_event.count_exe == 1, "Unexpected event.count_exe %u\n", aggregation_event.count_exe);
ok(aggregation_event.count_32bit >= MODCOUNT, "Unexpected event.count_32bit %u\n", aggregation_event.count_32bit);
ok(aggregation_event.count_64bit == 0, "Unexpected event.count_64bit %u\n", aggregation_event.count_64bit);
ok(aggregation_event.count_systemdir >= 1, "Unexpected event.count_systemdir %u\n", aggregation_event.count_systemdir);
ok(aggregation_event.count_wowdir >= MODCOUNT - 1, "Unexpected event.count_wowdir %u\n", aggregation_event.count_wowdir);
ok(aggregation_event.count_ntdll == 1, "Unexpected event.count_ntdll %u\n", aggregation_event.count_ntdll);
ok(aggregation_enum.count_exe == 1 + XTRAEXE, "Unexpected enum.count_exe %u\n", aggregation_enum.count_exe);
if (with_32)
ok(aggregation_enum.count_32bit >= MODCOUNT, "Unexpected enum.count_32bit %u\n", aggregation_enum.count_32bit);
else
ok(aggregation_enum.count_32bit <= 1, "Unexpected enum.count_32bit %u\n", aggregation_enum.count_32bit);
ok(aggregation_enum.count_64bit == 0, "Unexpected enum.count_64bit %u\n", aggregation_enum.count_64bit);
ok(aggregation_enum.count_systemdir == 0, "Unexpected enum.count_systemdir %u\n", aggregation_enum.count_systemdir);
if (with_32)
ok(aggregation_enum.count_wowdir >= MODCOUNT, "Unexpected enum.count_wowdir %u\n", aggregation_enum.count_wowdir);
else
ok(aggregation_enum.count_wowdir <= 1, "Unexpected enum.count_wowdir %u\n", aggregation_enum.count_wowdir);
ok(aggregation_enum.count_ntdll == XTRANTDLL, "Unexpected enum.count_ntdll %u\n", aggregation_enum.count_ntdll);
ok(aggregation_sym.count_exe == 1, "Unexpected sym.count_exe %u\n", aggregation_sym.count_exe);
if (with_32)
ok(aggregation_sym.count_32bit >= MODCOUNT, "Unexpected sym.count_32bit %u\n", aggregation_sym.count_32bit);
else
ok(aggregation_sym.count_wowdir <= 1, "Unexpected sym.count_32bit %u\n", aggregation_sym.count_32bit);
ok(aggregation_sym.count_64bit == 0, "Unexpected sym.count_64bit %u\n", aggregation_sym.count_64bit);
ok(aggregation_sym.count_systemdir == 0, "Unexpected sym.count_systemdir %u\n", aggregation_sym.count_systemdir);
if (with_32)
ok(aggregation_sym.count_wowdir >= MODCOUNT, "Unexpected sym.count_wowdir %u\n", aggregation_sym.count_wowdir);
else
ok(aggregation_sym.count_wowdir <= 1, "Unexpected sym.count_wowdir %u\n", aggregation_sym.count_wowdir);
ok(aggregation_sym.count_ntdll == XTRANTDLL, "Unexpected sym.count_ntdll %u\n", aggregation_sym.count_ntdll);
}
else if (!is_win64 && pcskind == PCSKIND_WINE_OLD_WOW64) /* 32/32 */
{
ok(aggregation_event.count_exe == 1, "Unexpected event.count_exe %u\n", aggregation_event.count_exe);
ok(aggregation_event.count_32bit >= MODCOUNT, "Unexpected event.count_32bit %u\n", aggregation_event.count_32bit);
ok(aggregation_event.count_64bit == 0, "Unexpected event.count_64bit %u\n", aggregation_event.count_64bit);
ok(aggregation_event.count_systemdir == 1, "Unexpected event.count_systemdir %u\n", aggregation_event.count_systemdir);
ok(aggregation_event.count_wowdir >= MODCOUNT, "Unexpected event.count_wowdir %u\n", aggregation_event.count_wowdir);
ok(aggregation_event.count_ntdll == 1, "Unexpected event.count_ntdll %u\n", aggregation_event.count_ntdll);
ok(aggregation_enum.count_exe == 1 + XTRAEXE, "Unexpected enum.count_exe %u\n", aggregation_enum.count_exe);
ok(aggregation_enum.count_32bit >= MODCOUNT, "Unexpected enum.count_32bit %u\n", aggregation_enum.count_32bit);
ok(aggregation_enum.count_64bit == 0, "Unexpected enum.count_64bit %u\n", aggregation_enum.count_64bit);
todo_wine
ok(aggregation_enum.count_systemdir >= MODCOUNT, "Unexpected enum.count_systemdir %u\n", aggregation_enum.count_systemdir);
/* .exe */
todo_wine
ok(aggregation_enum.count_wowdir == 1, "Unexpected enum.count_wowdir %u\n", aggregation_enum.count_wowdir);
ok(aggregation_enum.count_ntdll == 1 + XTRANTDLL, "Unexpected enum.count_ntdll %u\n", aggregation_enum.count_ntdll);
ok(aggregation_sym.count_exe == 1, "Unexpected sym.count_exe %u\n", aggregation_sym.count_exe);
ok(aggregation_sym.count_32bit >= MODCOUNT, "Unexpected sym.count_32bit %u\n", aggregation_sym.count_32bit);
ok(aggregation_sym.count_64bit == 0, "Unexpected sym.count_64bit %u\n", aggregation_sym.count_64bit);
todo_wine
ok(aggregation_sym.count_systemdir >= MODCOUNT, "Unexpected sym.count_systemdir %u\n", aggregation_sym.count_systemdir);
/* .exe */
todo_wine
ok(aggregation_sym.count_wowdir == 1, "Unexpected sym.count_wowdir %u\n", aggregation_sym.count_wowdir);
ok(aggregation_sym.count_ntdll == 1 + XTRANTDLL, "Unexpected sym.count_ntdll %u\n", aggregation_sym.count_ntdll);
}
else
ok(0, "Unexpected process kind %u\n", pcskind);
/* main module is enumerated twice in enum when including 32bit modules */
ok(aggregation_sym.count_32bit + XTRAEXE == aggregation_enum.count_32bit, "Different sym/enum count32_bit (%u/%u)\n",
aggregation_sym.count_32bit, aggregation_enum.count_32bit);
ok(aggregation_sym.count_64bit == aggregation_enum.count_64bit, "Different sym/enum count64_bit (%u/%u)\n",
aggregation_sym.count_64bit, aggregation_enum.count_64bit);
ok(aggregation_sym.count_systemdir == aggregation_enum.count_systemdir, "Different sym/enum systemdir (%u/%u)\n",
aggregation_sym.count_systemdir, aggregation_enum.count_systemdir);
ok(aggregation_sym.count_wowdir + XTRAEXE == aggregation_enum.count_wowdir, "Different sym/enum wowdir (%u/%u)\n",
aggregation_sym.count_wowdir, aggregation_enum.count_wowdir);
ok(aggregation_sym.count_exe + XTRAEXE == aggregation_enum.count_exe, "Different sym/enum exe (%u/%u)\n",
aggregation_sym.count_exe, aggregation_enum.count_exe);
ok(aggregation_sym.count_ntdll == aggregation_enum.count_ntdll, "Different sym/enum exe (%u/%u)\n",
aggregation_sym.count_ntdll, aggregation_enum.count_ntdll);
#undef MODCOUNT
#undef MODWOWCOUNT
#undef XTRAEXE
#undef XTRANTDLL
TerminateProcess(pi.hProcess, 0);
winetest_pop_context();
SymSetOptions(old_options);
}
static void test_live_modules(void)
{
WCHAR buffer[200];
wcscpy(buffer, system_directory);
wcscat(buffer, L"\\msinfo32.exe");
test_live_modules_proc(buffer, FALSE);
if (is_win64)
{
wcscpy(buffer, wow64_directory);
wcscat(buffer, L"\\msinfo32.exe");
test_live_modules_proc(buffer, TRUE);
test_live_modules_proc(buffer, FALSE);
}
}
START_TEST(dbghelp)
{
BOOL ret;
/* Don't let the user's environment influence our symbol path */
SetEnvironmentVariableA("_NT_SYMBOL_PATH", NULL);
SetEnvironmentVariableA("_NT_ALT_SYMBOL_PATH", NULL);
pIsWow64Process2 = (void*)GetProcAddress(GetModuleHandleA("kernel32.dll"), "IsWow64Process2");
ret = SymInitialize(GetCurrentProcess(), NULL, TRUE);
ok(ret, "got error %lu\n", GetLastError());
test_stack_walk();
ret = SymCleanup(GetCurrentProcess());
ok(ret, "got error %lu\n", GetLastError());
ret = GetSystemDirectoryW(system_directory, ARRAY_SIZE(system_directory));
ok(ret, "GetSystemDirectoryW failed: %lu\n", GetLastError());
/* failure happens on a 32bit only wine setup */
if (!GetSystemWow64DirectoryW(wow64_directory, ARRAY_SIZE(wow64_directory)))
wow64_directory[0] = L'\0';
if (test_modules())
{
test_modules_overlap();
test_loaded_modules();
test_live_modules();
}