@@ -31,12 +31,6 @@ EXTERN_DLL_EXPORT VOID __stdcall Initialize(RequestFunctionPtrCallback requestCa
3131 requestFunction = requestCallback;
3232}
3333
34- DWORD lastError = 0 ;
35- EXTERN_DLL_EXPORT DWORD __stdcall GetLastErrorCode ()
36- {
37- return lastError;
38- }
39-
4034EXTERN_DLL_EXPORT BOOL __stdcall IsProcessValid (HANDLE process)
4135{
4236 if (!process)
@@ -64,15 +58,12 @@ EXTERN_DLL_EXPORT VOID __stdcall CloseRemoteProcess(HANDLE process)
6458
6559EXTERN_DLL_EXPORT BOOL __stdcall ReadRemoteMemory (HANDLE process, LPCVOID address, LPVOID buffer, SIZE_T size)
6660{
67- if (ReadProcessMemory (process, address, buffer, size, nullptr ))
61+ SIZE_T numberOfBytesRead;
62+ if (ReadProcessMemory (process, address, buffer, size, &numberOfBytesRead) && size == numberOfBytesRead)
6863 {
69- lastError = 0 ;
70-
7164 return TRUE ;
7265 }
7366
74- lastError = GetLastError ();
75-
7667 return FALSE ;
7768}
7869
@@ -81,18 +72,18 @@ EXTERN_DLL_EXPORT BOOL __stdcall WriteRemoteMemory(HANDLE process, LPVOID addres
8172 DWORD oldProtect;
8273 if (VirtualProtectEx (process, address, size, PAGE_EXECUTE_READWRITE, &oldProtect))
8374 {
84- if (WriteProcessMemory (process, address, buffer, size, nullptr ))
75+ SIZE_T numberOfBytesWritten;
76+ if (WriteProcessMemory (process, address, buffer, size, &numberOfBytesWritten))
8577 {
8678 VirtualProtectEx (process, address, size, oldProtect, nullptr );
8779
88- lastError = 0 ;
89-
90- return TRUE ;
80+ if (size == numberOfBytesWritten)
81+ {
82+ return TRUE ;
83+ }
9184 }
9285 }
9386
94- lastError = GetLastError ();
95-
9687 return FALSE ;
9788}
9889
@@ -182,13 +173,7 @@ EXTERN_DLL_EXPORT VOID __stdcall EnumerateProcesses(EnumerateProcessCallback cal
182173 }
183174
184175 CloseHandle (handle);
185-
186- lastError = 0 ;
187-
188- return ;
189176 }
190-
191- lastError = GetLastError ();
192177}
193178
194179typedef VOID (__stdcall EnumerateRemoteSectionsCallback)(LPVOID baseAddress, SIZE_T regionSize, WCHAR name[IMAGE_SIZEOF_SHORT_NAME + 1 ], DWORD state, DWORD protection, DWORD type, WCHAR modulePath[PATH_MAXIMUM_LENGTH]);
@@ -297,13 +282,7 @@ EXTERN_DLL_EXPORT VOID __stdcall EnumerateRemoteSectionsAndModules(HANDLE proces
297282 callbackSection (section.BaseAddress , section.RegionSize , section.Name , section.State , section.Protection , section.Type , section.ModulePath );
298283 }
299284 }
300-
301- lastError = 0 ;
302-
303- return ;
304285 }
305-
306- lastError = GetLastError ();
307286}
308287
309288typedef VOID (__stdcall DisassembleRemoteCodeCallback)(LPVOID address, DWORD length, CHAR instruction[64 ]);
0 commit comments