Skip to content

Commit a67a67b

Browse files
authored
Merge pull request #35 from KokerZhou/master
Update Injector.cpp
2 parents 0b5c085 + 9e2028d commit a67a67b

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

Injector/Injector.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,10 @@ BYTE* Injector::GetModuleBaseAddress(HANDLE Process, const std::wstring& Path) {
5151
DWORD SizeNeeded = 0;
5252
do
5353
{
54-
Modules.reserve(SizeNeeded / sizeof(HMODULE));
55-
if (!EnumProcessModules(Process, Modules.data(), Modules.capacity() * sizeof(HMODULE), &SizeNeeded))
54+
Modules.resize(SizeNeeded / sizeof(HMODULE));
55+
if (!EnumProcessModules(Process, Modules.data(), Modules.size() * sizeof(HMODULE), &SizeNeeded))
5656
throw std::runtime_error("Could not get module snapshot for remote process.");
57-
} while (SizeNeeded > Modules.capacity() * sizeof(HMODULE));
58-
// Make capacity into size
59-
Modules = std::vector<HMODULE>(Modules.begin(), Modules.begin() + SizeNeeded / sizeof(HMODULE));
57+
} while (SizeNeeded > Modules.size() * sizeof(HMODULE));
6058

6159
// Get the HMODULE of the desired library
6260
bool Found = false;

0 commit comments

Comments
 (0)