Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Remove Read/WriteProcessMemory from PAL. #8655

Merged
merged 1 commit into from
Dec 18, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/debug/daccess/fntableaccess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include "stdafx.h"

#ifndef FEATURE_PAL
#ifndef _TARGET_X86_

//
Expand Down Expand Up @@ -388,6 +389,7 @@ static NTSTATUS OutOfProcessFunctionTableCallback_Stub(IN ReadMemoryFunction

#endif // DEBUGSUPPORT_STUBS_HAVE_UNWIND_INFO


BOOL ReadMemory(PVOID pUserContext, LPCVOID lpBaseAddress, PVOID lpBuffer, SIZE_T nSize, SIZE_T* lpNumberOfBytesRead)
{
HANDLE hProcess = (HANDLE)pUserContext;
Expand Down Expand Up @@ -456,6 +458,5 @@ extern "C" NTSTATUS OutOfProcessFunctionTableCallbackEx()
return STATUS_UNSUCCESSFUL;
}



#endif // !_TARGET_X86_
#endif // !FEATURE_PAL
2 changes: 1 addition & 1 deletion src/debug/di/rspriv.inl
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ void CordbProcess::ForceDacFlush()
{
if (m_pDacPrimitives != NULL)
{
STRESS_LOG1(LF_CORDB, LL_INFO1000, "Flush() - old counter: %d", m_flushCounter);
STRESS_LOG1(LF_CORDB, LL_INFO1000, "Flush() - old counter: %d\n", m_flushCounter);
m_flushCounter++;
HRESULT hr = S_OK;
EX_TRY
Expand Down
36 changes: 1 addition & 35 deletions src/debug/shared/dbgtransportsession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1140,33 +1140,6 @@ DbgTransportSession::Message * DbgTransportSession::RemoveMessageFromSendQueue(D

#ifndef RIGHT_SIDE_COMPILE

#ifdef FEATURE_PAL
__attribute__((noinline))
__attribute__((optnone))
static void
ProbeMemory(__in_ecount(cbBuffer) volatile PBYTE pbBuffer, DWORD cbBuffer, bool fWriteAccess)
{
// Need an throw in this function to fool the C++ runtime into handling the
// possible h/w exception below.
if (pbBuffer == NULL)
{
throw PAL_SEHException();
}

// Simple one byte at a time probing
while (cbBuffer > 0)
{
volatile BYTE read = *pbBuffer;
if (fWriteAccess)
{
*pbBuffer = read;
}
++pbBuffer;
--cbBuffer;
}
}
#endif // FEATURE_PAL

// Check read and optionally write memory access to the specified range of bytes. Used to check
// ReadProcessMemory and WriteProcessMemory requests.
HRESULT DbgTransportSession::CheckBufferAccess(__in_ecount(cbBuffer) PBYTE pbBuffer, DWORD cbBuffer, bool fWriteAccess)
Expand Down Expand Up @@ -1220,14 +1193,7 @@ HRESULT DbgTransportSession::CheckBufferAccess(__in_ecount(cbBuffer) PBYTE pbBuf
}
while (cbBuffer > 0);
#else
try
{
// Need to explicit h/w exception holder so to catch them in ProbeMemory
CatchHardwareExceptionHolder __catchHardwareException;

ProbeMemory(pbBuffer, cbBuffer, fWriteAccess);
}
catch(...)
if (!PAL_ProbeMemory(pbBuffer, cbBuffer, fWriteAccess))
{
return HRESULT_FROM_WIN32(ERROR_INVALID_ADDRESS);
}
Expand Down
1 change: 1 addition & 0 deletions src/dlls/mscordac/mscordac_unixexports.src
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ PAL_GetSymbolModuleBase
PAL_GetTransportPipeName
PAL_InitializeDLL
PAL_IsDebuggerPresent
PAL_ProbeMemory
PAL_iswspace
PAL_memcpy
PAL_malloc
Expand Down
2 changes: 2 additions & 0 deletions src/inc/livedatatarget.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
// Does not include IXClrData definitions.
#include <clrdata.h>

#ifndef FEATURE_PAL

//---------------------------------------------------------------------------------------
//
Expand Down Expand Up @@ -100,6 +101,7 @@ class LiveProcDataTarget : public ICLRDataTarget
CLRDATA_ADDRESS m_baseAddressOfEngine;
};

#endif // FEATURE_PAL

#endif // _LIVEPROC_DATATARGET_H_

4 changes: 4 additions & 0 deletions src/jit/ee_il_dll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1537,6 +1537,9 @@ const char* Compiler::eeGetClassName(CORINFO_CLASS_HANDLE clsHnd)

const wchar_t* Compiler::eeGetCPString(size_t strHandle)
{
#ifdef FEATURE_PAL
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BruceForstall what do you think about this change?

return nullptr;
#else
char buff[512 + sizeof(CORINFO_String)];

// make this bulletproof, so it works even if we are wrong.
Expand All @@ -1558,6 +1561,7 @@ const wchar_t* Compiler::eeGetCPString(size_t strHandle)
}

return (asString->chars);
#endif // FEATURE_PAL
}

#endif // DEBUG
26 changes: 7 additions & 19 deletions src/pal/inc/pal.h
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,13 @@ PAL_DeleteExecWatchpoint(

#endif

PALIMPORT
BOOL
PALAPI
PAL_ProbeMemory(
PVOID pBuffer,
DWORD cbBuffer,
BOOL fWriteAccess);

/******************* winuser.h Entrypoints *******************************/

Expand Down Expand Up @@ -3652,16 +3659,6 @@ VirtualQuery(
OUT PMEMORY_BASIC_INFORMATION lpBuffer,
IN SIZE_T dwLength);

PALIMPORT
BOOL
PALAPI
ReadProcessMemory(
IN HANDLE hProcess,
IN LPCVOID lpBaseAddress,
OUT LPVOID lpBuffer,
IN SIZE_T nSize,
OUT SIZE_T * lpNumberOfBytesRead);

PALIMPORT
VOID
PALAPI
Expand Down Expand Up @@ -4715,15 +4712,6 @@ typedef struct _RUNTIME_FUNCTION {
DWORD UnwindData;
} RUNTIME_FUNCTION, *PRUNTIME_FUNCTION;

PALIMPORT
BOOL
PALAPI
WriteProcessMemory(IN HANDLE hProcess,
IN LPVOID lpBaseAddress,
IN LPCVOID lpBuffer,
IN SIZE_T nSize,
OUT SIZE_T * lpNumberOfBytesWritten);

#define STANDARD_RIGHTS_REQUIRED (0x000F0000L)
#define SYNCHRONIZE (0x00100000L)
#define READ_CONTROL (0x00020000L)
Expand Down
Loading