Skip to content

Commit

Permalink
Merge pull request #13 from RaMMicHaeL/master
Browse files Browse the repository at this point in the history
Calculate minAddr, maxAddr only for 64-bit
  • Loading branch information
TsudaKageyu committed Mar 4, 2015
2 parents f62d912 + 8201325 commit 6e401b1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,25 +146,25 @@ static LPVOID FindNextFreeRegion(LPVOID pAddress, LPVOID pMaxAddr, DWORD dwAlloc
//-------------------------------------------------------------------------
static PMEMORY_BLOCK GetMemoryBlock(LPVOID pOrigin)
{
PMEMORY_BLOCK pBlock;
#ifdef _M_X64
ULONG_PTR minAddr;
ULONG_PTR maxAddr;
PMEMORY_BLOCK pBlock;

SYSTEM_INFO si;
GetSystemInfo(&si);
minAddr = (ULONG_PTR)si.lpMinimumApplicationAddress;
maxAddr = (ULONG_PTR)si.lpMaximumApplicationAddress;

#ifdef _M_X64
// pOrigin ± 512MB
if ((ULONG_PTR)pOrigin > MAX_MEMORY_RANGE)
minAddr = max(minAddr, (ULONG_PTR)pOrigin - MAX_MEMORY_RANGE);

maxAddr = min(maxAddr, (ULONG_PTR)pOrigin + MAX_MEMORY_RANGE);
#endif

// Make room for MEMORY_BLOCK_SIZE bytes.
maxAddr -= MEMORY_BLOCK_SIZE - 1;
#endif

// Look the registered blocks for a reachable one.
for (pBlock = g_pMemoryBlocks; pBlock != NULL; pBlock = pBlock->pNext)
Expand Down

0 comments on commit 6e401b1

Please sign in to comment.