Skip to content
This repository has been archived by the owner on Oct 15, 2020. It is now read-only.

Commit

Permalink
deps: update ChakraCore to chakra-core/ChakraCore@1dd69bc4ba
Browse files Browse the repository at this point in the history
[1.8>1.9] [MERGE #4633 @MikeHolman] add some asserts during jit handshake

Merge pull request #4633 from MikeHolman:addasserts

Well behaved programs should never hit these paths, so add early asserts to catch bugs early in testing

OS: 15490382

Reviewed-By: chakrabot <chakrabot@users.noreply.github.com>
  • Loading branch information
MikeHolman authored and chakrabot committed Feb 2, 2018
1 parent 31a5b2e commit 2bc8958
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions deps/chakrashim/core/lib/JITServer/JITServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,23 +126,28 @@ HRESULT CheckModuleAddress(HANDLE process, LPCVOID remoteImageBase, LPCVOID loca
SIZE_T resultBytes = VirtualQueryEx(process, (LPCVOID)remoteImageBase, &remoteImageInfo, sizeof(remoteImageInfo));
if (resultBytes != sizeof(remoteImageInfo))
{
Assert(UNREACHED);
return E_ACCESSDENIED;
}
if (remoteImageInfo.BaseAddress != (PVOID)remoteImageBase)
{
Assert(UNREACHED);
return E_ACCESSDENIED;
}
if (remoteImageInfo.Type != MEM_IMAGE)
{
Assert(UNREACHED);
return E_ACCESSDENIED;
}
if (remoteImageInfo.State != MEM_COMMIT)
{
Assert(UNREACHED);
return E_ACCESSDENIED;
}

if (remoteImageInfo.RegionSize < sizeof(remoteImageHeader))
{
Assert(UNREACHED);
return E_ACCESSDENIED;
}

Expand All @@ -152,6 +157,7 @@ HRESULT CheckModuleAddress(HANDLE process, LPCVOID remoteImageBase, LPCVOID loca
}
if (resultBytes < sizeof(remoteImageHeader))
{
Assert(UNREACHED);
return E_ACCESSDENIED;
}
PIMAGE_DOS_HEADER localDosHeader = (PIMAGE_DOS_HEADER)localImageBase;
Expand All @@ -164,23 +170,28 @@ HRESULT CheckModuleAddress(HANDLE process, LPCVOID remoteImageBase, LPCVOID loca
uintptr_t remoteMaxRead = (uintptr_t)remoteNtHeader + sizeof(IMAGE_NT_HEADERS);
if (remoteMaxRead >= remoteHeaderMax || remoteMaxRead < (uintptr_t)remoteImageHeader)
{
Assert(UNREACHED);
return E_ACCESSDENIED;
}

if (localNtHeader->FileHeader.NumberOfSections != remoteNtHeader->FileHeader.NumberOfSections)
{
Assert(UNREACHED);
return E_ACCESSDENIED;
}
if (localNtHeader->FileHeader.NumberOfSymbols != remoteNtHeader->FileHeader.NumberOfSymbols)
{
Assert(UNREACHED);
return E_ACCESSDENIED;
}
if (localNtHeader->OptionalHeader.CheckSum != remoteNtHeader->OptionalHeader.CheckSum)
{
Assert(UNREACHED);
return E_ACCESSDENIED;
}
if (localNtHeader->OptionalHeader.SizeOfImage != remoteNtHeader->OptionalHeader.SizeOfImage)
{
Assert(UNREACHED);
return E_ACCESSDENIED;
}

Expand All @@ -207,12 +218,14 @@ ServerConnectProcess(
HANDLE targetHandle;
if (!DuplicateHandle(GetCurrentProcess(), processHandle, GetCurrentProcess(), &targetHandle, 0, false, DUPLICATE_SAME_ACCESS))
{
Assert(UNREACHED);
return E_ACCESSDENIED;
}
#else
HANDLE targetHandle = OpenProcess(PROCESS_VM_OPERATION | PROCESS_VM_READ | PROCESS_VM_WRITE | PROCESS_QUERY_LIMITED_INFORMATION, false, clientPid);
if (!targetHandle)
{
Assert(UNREACHED);
return E_ACCESSDENIED;
}
#endif
Expand Down Expand Up @@ -902,6 +915,7 @@ ProcessContextManager::RegisterNewProcess(DWORD pid, HANDLE processHandle, intpt
// We cannot register multiple ProcessContexts for a single process
if (ProcessContexts.ContainsKey(pid))
{
Assert(UNREACHED);
return E_ACCESSDENIED;
}

Expand Down

0 comments on commit 2bc8958

Please sign in to comment.