From 7a5ad909a499d667fa302f92e5c8031443427358 Mon Sep 17 00:00:00 2001 From: "Mr. eXoDia" Date: Sun, 12 Jul 2015 20:07:18 +0200 Subject: [PATCH] DBG: fixed some common parameters in MemAllocRemote --- x64_dbg_dbg/_scriptapi_memory.cpp | 2 +- x64_dbg_dbg/debugger.cpp | 2 +- x64_dbg_dbg/debugger_commands.cpp | 6 +++--- x64_dbg_dbg/memory.cpp | 6 +++--- x64_dbg_dbg/memory.h | 8 ++++---- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/x64_dbg_dbg/_scriptapi_memory.cpp b/x64_dbg_dbg/_scriptapi_memory.cpp index 9a5acace..3af96199 100644 --- a/x64_dbg_dbg/_scriptapi_memory.cpp +++ b/x64_dbg_dbg/_scriptapi_memory.cpp @@ -18,7 +18,7 @@ SCRIPT_EXPORT bool Script::Memory::IsValidPtr(duint addr) SCRIPT_EXPORT duint Script::Memory::RemoteAlloc(duint addr, duint size) { - return (duint)MemAllocRemote(addr, size, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE); + return (duint)MemAllocRemote(addr, size); } SCRIPT_EXPORT bool Script::Memory::RemoteFree(duint addr) diff --git a/x64_dbg_dbg/debugger.cpp b/x64_dbg_dbg/debugger.cpp index b15c6894..9050a83b 100644 --- a/x64_dbg_dbg/debugger.cpp +++ b/x64_dbg_dbg/debugger.cpp @@ -1939,7 +1939,7 @@ bool dbgsetcmdline(const char* cmd_line, cmdline_error_t* cmd_line_error) new_command_line.Buffer = command_linewstr(); - uint mem = (uint)MemAllocRemote(0, new_command_line.Length * 2, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE); + uint mem = (uint)MemAllocRemote(0, new_command_line.Length * 2); if(!mem) { cmd_line_error->type = CMDL_ERR_ALLOC_UNICODEANSI_COMMANDLINE; diff --git a/x64_dbg_dbg/debugger_commands.cpp b/x64_dbg_dbg/debugger_commands.cpp index 90c0f510..19644ee9 100644 --- a/x64_dbg_dbg/debugger_commands.cpp +++ b/x64_dbg_dbg/debugger_commands.cpp @@ -789,7 +789,7 @@ CMDRESULT cbDebugAlloc(int argc, char* argv[]) if(argc > 1) if(!valfromstring(argv[1], &size, false)) return STATUS_ERROR; - uint mem = (uint)MemAllocRemote(0, size, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE); + uint mem = (uint)MemAllocRemote(0, size); if(!mem) dputs("VirtualAllocEx failed"); else @@ -1888,8 +1888,8 @@ CMDRESULT cbDebugLoadLib(int argc, char* argv[]) LoadLibThreadID = fdProcessInfo->dwThreadId; HANDLE LoadLibThread = ThreadGetHandle((DWORD)LoadLibThreadID); - DLLNameMem = MemAllocRemote(0, strlen(argv[1]) + 1, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE); - ASMAddr = MemAllocRemote(0, 0x1000, MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE); + DLLNameMem = MemAllocRemote(0, strlen(argv[1]) + 1); + ASMAddr = MemAllocRemote(0, 0x1000); if(!DLLNameMem || !ASMAddr) { diff --git a/x64_dbg_dbg/memory.cpp b/x64_dbg_dbg/memory.cpp index 7bba4063..e0cb3b16 100644 --- a/x64_dbg_dbg/memory.cpp +++ b/x64_dbg_dbg/memory.cpp @@ -173,7 +173,7 @@ uint MemFindBaseAddr(uint Address, uint* Size, bool Refresh) return found->first.first; } -bool MemRead(uint BaseAddress, void* Buffer, SIZE_T Size, SIZE_T* NumberOfBytesRead) +bool MemRead(uint BaseAddress, void* Buffer, uint Size, uint* NumberOfBytesRead) { if(!MemIsCanonicalAddress((uint)BaseAddress)) return false; @@ -227,7 +227,7 @@ bool MemRead(uint BaseAddress, void* Buffer, SIZE_T Size, SIZE_T* NumberOfBytesR return (*NumberOfBytesRead > 0); } -bool MemWrite(uint BaseAddress, const void* Buffer, SIZE_T Size, SIZE_T* NumberOfBytesWritten) +bool MemWrite(uint BaseAddress, const void* Buffer, uint Size, uint* NumberOfBytesWritten) { if(!MemIsCanonicalAddress((uint)BaseAddress)) return false; @@ -281,7 +281,7 @@ bool MemWrite(uint BaseAddress, const void* Buffer, SIZE_T Size, SIZE_T* NumberO return (*NumberOfBytesWritten > 0); } -bool MemPatch(uint BaseAddress, const void* Buffer, SIZE_T Size, SIZE_T* NumberOfBytesWritten) +bool MemPatch(uint BaseAddress, const void* Buffer, uint Size, uint* NumberOfBytesWritten) { // Buffer and size must be valid if(!Buffer || Size <= 0) diff --git a/x64_dbg_dbg/memory.h b/x64_dbg_dbg/memory.h index 4c4fbf84..17f7d0bf 100644 --- a/x64_dbg_dbg/memory.h +++ b/x64_dbg_dbg/memory.h @@ -8,10 +8,10 @@ extern bool bListAllPages; void MemUpdateMap(); uint MemFindBaseAddr(uint Address, uint* Size, bool Refresh = false); -bool MemRead(uint BaseAddress, void* Buffer, SIZE_T Size, SIZE_T* NumberOfBytesRead); -bool MemWrite(uint BaseAddress, const void* Buffer, SIZE_T Size, SIZE_T* NumberOfBytesWritten); -bool MemPatch(uint BaseAddress, const void* Buffer, SIZE_T Size, SIZE_T* NumberOfBytesWritten); +bool MemRead(uint BaseAddress, void* Buffer, uint Size, uint* NumberOfBytesRead = nullptr); +bool MemWrite(uint BaseAddress, const void* Buffer, uint Size, uint* NumberOfBytesWritten = nullptr); +bool MemPatch(uint BaseAddress, const void* Buffer, uint Size, uint* NumberOfBytesWritten = nullptr); bool MemIsValidReadPtr(uint Address); bool MemIsCanonicalAddress(uint Address); -uint MemAllocRemote(uint Address, uint Size, DWORD Type, DWORD Protect); +uint MemAllocRemote(uint Address, uint Size, DWORD Type = MEM_RESERVE | MEM_COMMIT, DWORD Protect = PAGE_EXECUTE_READWRITE); bool MemFreeRemote(uint Address); \ No newline at end of file