Answer the question
In order to leave comments, you need to log in
How to read array of dynamic length data?
Hello, I have a read function in my library
template <typename type>
static type readMemory(uintptr_t offset) {
type value;
isLastSuccessful = ReadProcessMemory(targetHandle, (LPVOID)offset, &value, sizeof(type), 0);
return value;
}
wchar_t* readWcharArray(uintptr_t adrArray, int length) {
wchar_t* str = new wchar_t[length];
for (int i = 0; i < length; i++) {
str[i] = readMemory<wchar_t>(adrArray + sizeof(wchar_t) * i);
}
return str;
}
but without the loop, is it possible without changing the library itself...
Answer the question
In order to leave comments, you need to log in
You will have to rewrite the function readMemory
to accept length
and read length*sizeof(type)
. Or call ReadProcessMemory directly in your function.
The current implementation doesn't suit your purpose at all. The template type must be known at compile time. And you want to somehow transfer the dynamic length in it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question