Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
942 B
2
Indexable
Never
					printf("Error GetModuleHandleEx(0x00000004, ptr, &moduleToTheAddress) (error code %d)\n", GetLastError());
					
					/* Enumerating Modules Loaded */
					HANDLE processHandle = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, processId);
					if (processHandle == NULL) {
						printf("Failed to open process handle.\n");
						return 0;
					}

					HMODULE moduleHandles[1024];
					DWORD cbNeeded;
					if (EnumProcessModules(processHandle, moduleHandles, sizeof(moduleHandles), &cbNeeded)) {
						for (DWORD i = 0; i < (cbNeeded / sizeof(HMODULE)); i++) {
							TCHAR moduleName[MAX_PATH];
							if (GetModuleFileNameEx(processHandle, moduleHandles[i], moduleName, sizeof(moduleName) / sizeof(TCHAR))) {
								printf("%s cbNeeded %d\n", moduleName, cbNeeded);
							}
						}
					} else {
						printf("Failed to enumerate process modules.\n");
					}

					CloseHandle(processHandle);