MCPcopy Create free account
hub / github.com/NtQuery/Scylla / readMemoryPartlyFromProcess

Method readMemoryPartlyFromProcess

Scylla/ProcessAccessHelp.cpp:109–177  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

107}
108
109bool ProcessAccessHelp::readMemoryPartlyFromProcess(DWORD_PTR address, SIZE_T size, LPVOID dataBuffer)
110{
111 DWORD_PTR addressPart = 0;
112 DWORD_PTR readBytes = 0;
113 DWORD_PTR bytesToRead = 0;
114 MEMORY_BASIC_INFORMATION memBasic = {0};
115 bool returnValue = false;
116
117 if (!hProcess)
118 {
119#ifdef DEBUG_COMMENTS
120 Scylla::debugLog.log(L"readMemoryPartlyFromProcess :: hProcess == NULL");
121#endif
122 return returnValue;
123 }
124
125 if (!readMemoryFromProcess(address, size, dataBuffer))
126 {
127 addressPart = address;
128
129 do
130 {
131 if (!VirtualQueryEx(ProcessAccessHelp::hProcess,(LPCVOID)addressPart,&memBasic,sizeof(memBasic)))
132 {
133#ifdef DEBUG_COMMENTS
134 Scylla::debugLog.log(L"readMemoryPartlyFromProcess :: Error VirtualQueryEx %X %X err: %u", addressPart,size, GetLastError());
135#endif
136 break;
137 }
138
139 bytesToRead = memBasic.RegionSize;
140
141 if ( (readBytes+bytesToRead) > size)
142 {
143 bytesToRead = size - readBytes;
144 }
145
146 if (memBasic.State == MEM_COMMIT)
147 {
148 if (!readMemoryFromProcess(addressPart, bytesToRead, (LPVOID)((DWORD_PTR)dataBuffer + readBytes)))
149 {
150 break;
151 }
152 }
153 else
154 {
155 ZeroMemory((LPVOID)((DWORD_PTR)dataBuffer + readBytes),bytesToRead);
156 }
157
158
159 readBytes += bytesToRead;
160
161 addressPart += memBasic.RegionSize;
162
163 } while (readBytes < size);
164
165 if (readBytes == size)
166 {

Callers

nothing calls this directly

Calls 1

logMethod · 0.80

Tested by

no test coverage detected