convert tabs to spaces to make it readable with tabs != 8 spaces
authorThomas Bluemel <thomas@reactsoft.com>
Mon, 24 Oct 2005 17:54:55 +0000 (17:54 +0000)
committerThomas Bluemel <thomas@reactsoft.com>
Mon, 24 Oct 2005 17:54:55 +0000 (17:54 +0000)
svn path=/trunk/; revision=18753

reactos/lib/kernel32/mem/procmem.c

index 9c14eec..1cd502b 100644 (file)
 BOOL
 STDCALL
 ReadProcessMemory (
-       HANDLE  hProcess,
-       LPCVOID lpBaseAddress,
-       LPVOID  lpBuffer,
-       DWORD   nSize,
-       LPDWORD lpNumberOfBytesRead
-       )
+        HANDLE        hProcess,
+        LPCVOID        lpBaseAddress,
+        LPVOID        lpBuffer,
+        DWORD        nSize,
+        LPDWORD        lpNumberOfBytesRead
+        )
 {
 
-       NTSTATUS Status;
+        NTSTATUS Status;
 
-       Status = NtReadVirtualMemory( hProcess, (PVOID)lpBaseAddress,lpBuffer, nSize,
-               (PULONG)lpNumberOfBytesRead
-               );
+        Status = NtReadVirtualMemory( hProcess, (PVOID)lpBaseAddress,lpBuffer, nSize,
+                (PULONG)lpNumberOfBytesRead
+                );
 
-       if (!NT_SUCCESS(Status))
-       {
-               SetLastErrorByStatus (Status);
-               return FALSE;
-       }
-       return TRUE;
+        if (!NT_SUCCESS(Status))
+             {
+                SetLastErrorByStatus (Status);
+                return FALSE;
+             }
+        return TRUE;
 }
 
 
@@ -51,107 +51,107 @@ ReadProcessMemory (
 BOOL
 STDCALL
 WriteProcessMemory (
-       HANDLE hProcess,
-       LPVOID lpBaseAddress,
-       LPCVOID lpBuffer,
-       SIZE_T nSize,
-       SIZE_T *lpNumberOfBytesWritten
-       )
+        HANDLE hProcess,
+        LPVOID lpBaseAddress,
+        LPCVOID lpBuffer,
+        SIZE_T nSize,
+        SIZE_T *lpNumberOfBytesWritten
+        )
 {
-       NTSTATUS Status, ProtectStatus = STATUS_SUCCESS;
-       MEMORY_BASIC_INFORMATION MemInfo;
-       ULONG Length;
-       BOOLEAN UnProtect;
-
-       if (lpNumberOfBytesWritten)
-       {
-           *lpNumberOfBytesWritten = 0;
-       }
-
-       while (nSize)
-       {
-           Status = NtQueryVirtualMemory(hProcess, 
-                                         lpBaseAddress,
-                                         MemoryBasicInformation,
-                                         &MemInfo,
-                                         sizeof(MEMORY_BASIC_INFORMATION),
-                                         NULL);
-
-           if (!NT_SUCCESS(Status))
-           {
-               SetLastErrorByStatus(Status);
-               return FALSE;
-           }
-           Length = MemInfo.RegionSize - ((ULONG_PTR)lpBaseAddress - (ULONG_PTR)MemInfo.BaseAddress);
-           if (Length > nSize)
-           {
-               Length = nSize;
-           }
-           UnProtect = MemInfo.Protect & (PAGE_READWRITE|PAGE_WRITECOPY|PAGE_EXECUTE_READWRITE|PAGE_EXECUTE_WRITECOPY) ? FALSE : TRUE;
-           if (UnProtect)
-           {
-               MemInfo.BaseAddress = lpBaseAddress;
-               MemInfo.RegionSize = Length;
-               if (MemInfo.Protect & (PAGE_EXECUTE|PAGE_EXECUTE_READ))
-               {
-                   MemInfo.Protect &= ~(PAGE_EXECUTE|PAGE_EXECUTE_READ);
-                   MemInfo.Protect |= PAGE_EXECUTE_READWRITE;
-               }
-               else 
-               {
-                   MemInfo.Protect &= ~(PAGE_READONLY|PAGE_NOACCESS);
-                   MemInfo.Protect |= PAGE_READWRITE;
-               }
-
-               ProtectStatus = NtProtectVirtualMemory(hProcess, 
-                                                      &MemInfo.BaseAddress, 
-                                                      &MemInfo.RegionSize,
-                                                      MemInfo.Protect,
-                                                      &MemInfo.Protect);
-               if (!NT_SUCCESS(ProtectStatus))
-               {
-                   SetLastErrorByStatus(ProtectStatus);
-                   return FALSE;
-               }
-               Length = MemInfo.RegionSize - ((ULONG_PTR)lpBaseAddress - (ULONG_PTR)MemInfo.BaseAddress);
-               if (Length > nSize)
-               {
-                   Length = nSize;
-               }
-           }
-                                           
-           Status = NtWriteVirtualMemory(hProcess, 
-                                         lpBaseAddress, 
-                                         (LPVOID)lpBuffer, 
-                                         Length,
-                                         &Length);
-           if (UnProtect)
-           {
-               ProtectStatus = NtProtectVirtualMemory(hProcess, 
-                                                      &MemInfo.BaseAddress, 
-                                                      &MemInfo.RegionSize,
-                                                      MemInfo.Protect,
-                                                      &MemInfo.Protect);
-           }
-           if (!NT_SUCCESS(Status))
-           {
-               SetLastErrorByStatus (Status);
-               return FALSE;
-           }
-           if (UnProtect && !NT_SUCCESS(ProtectStatus))
-           {
-               SetLastErrorByStatus (ProtectStatus);
-               return FALSE;
-           }
-           lpBaseAddress = (LPVOID)((ULONG_PTR)lpBaseAddress + Length);
-           lpBuffer = (LPCVOID)((ULONG_PTR)lpBuffer + Length);
-           nSize -= Length;
-           if (lpNumberOfBytesWritten)
-           {
-               *lpNumberOfBytesWritten += Length;
-           }
-       }
-       return TRUE;
+        NTSTATUS Status, ProtectStatus = STATUS_SUCCESS;
+        MEMORY_BASIC_INFORMATION MemInfo;
+        ULONG Length;
+        BOOLEAN UnProtect;
+
+        if (lpNumberOfBytesWritten)
+        {
+            *lpNumberOfBytesWritten = 0;
+        }
+
+        while (nSize)
+        {
+            Status = NtQueryVirtualMemory(hProcess,
+                                          lpBaseAddress,
+                                          MemoryBasicInformation,
+                                          &MemInfo,
+                                          sizeof(MEMORY_BASIC_INFORMATION),
+                                          NULL);
+
+            if (!NT_SUCCESS(Status))
+            {
+                SetLastErrorByStatus(Status);
+                return FALSE;
+            }
+            Length = MemInfo.RegionSize - ((ULONG_PTR)lpBaseAddress - (ULONG_PTR)MemInfo.BaseAddress);
+            if (Length > nSize)
+            {
+                Length = nSize;
+            }
+            UnProtect = MemInfo.Protect & (PAGE_READWRITE|PAGE_WRITECOPY|PAGE_EXECUTE_READWRITE|PAGE_EXECUTE_WRITECOPY) ? FALSE : TRUE;
+            if (UnProtect)
+            {
+                MemInfo.BaseAddress = lpBaseAddress;
+                MemInfo.RegionSize = Length;
+                if (MemInfo.Protect & (PAGE_EXECUTE|PAGE_EXECUTE_READ))
+                {
+                    MemInfo.Protect &= ~(PAGE_EXECUTE|PAGE_EXECUTE_READ);
+                    MemInfo.Protect |= PAGE_EXECUTE_READWRITE;
+                }
+                else
+                {
+                    MemInfo.Protect &= ~(PAGE_READONLY|PAGE_NOACCESS);
+                    MemInfo.Protect |= PAGE_READWRITE;
+                }
+
+                ProtectStatus = NtProtectVirtualMemory(hProcess,
+                                                       &MemInfo.BaseAddress,
+                                                       &MemInfo.RegionSize,
+                                                       MemInfo.Protect,
+                                                       &MemInfo.Protect);
+                if (!NT_SUCCESS(ProtectStatus))
+                {
+                    SetLastErrorByStatus(ProtectStatus);
+                    return FALSE;
+                }
+                Length = MemInfo.RegionSize - ((ULONG_PTR)lpBaseAddress - (ULONG_PTR)MemInfo.BaseAddress);
+                if (Length > nSize)
+                {
+                    Length = nSize;
+                }
+            }
+
+            Status = NtWriteVirtualMemory(hProcess,
+                                          lpBaseAddress,
+                                          (LPVOID)lpBuffer,
+                                          Length,
+                                          &Length);
+            if (UnProtect)
+            {
+                ProtectStatus = NtProtectVirtualMemory(hProcess,
+                                                       &MemInfo.BaseAddress,
+                                                       &MemInfo.RegionSize,
+                                                       MemInfo.Protect,
+                                                       &MemInfo.Protect);
+            }
+            if (!NT_SUCCESS(Status))
+                 {
+                SetLastErrorByStatus (Status);
+                return FALSE;
+                 }
+            if (UnProtect && !NT_SUCCESS(ProtectStatus))
+            {
+                SetLastErrorByStatus (ProtectStatus);
+                return FALSE;
+            }
+            lpBaseAddress = (LPVOID)((ULONG_PTR)lpBaseAddress + Length);
+            lpBuffer = (LPCVOID)((ULONG_PTR)lpBuffer + Length);
+            nSize -= Length;
+            if (lpNumberOfBytesWritten)
+            {
+                *lpNumberOfBytesWritten += Length;
+            }
+        }
+        return TRUE;
 }
 
 /* EOF */