2

I have found a comportement that i can't explain and I would have liked someone to explain to me why it happend.

To resume my situation i'm trying to read memory regions with VirtualQueryEx to a 64 bit program (notepad.exe)

What i already figure out:

  • From a 32bits process i can read only 32bits process with using the MEMORY_BASIC_INFORMATION32 struct msdn doc
  • From a 64bits process i can read 64bits and 32bits process with using the MEMORY_BASIC_INFORMATION64 struct msdn doc
  • From "Any CPU" configuration i get exactly same comportement than if i run my program as x86 32bits program.

Then my question is : why ? I mean, i checked on msdn documentation they are saying that it should be runned in 64bits mode normaly because my computer is a 64bits OS. Then why it behaves like a 32bits process ?

Thank you a lot for your futur answer. I'm really curious to know.

OOM
  • 728
  • 7
  • 22
  • 1
    Sounds like your code runs as 32bit, eg. because you launched it under debugger which is 32bit (for reasons) https://stackoverflow.com/a/397695/3147740 – PTwr Dec 15 '18 at 01:58
  • 1
    The solution platform name is irrelevant in C# projects, it only matters to C++ projects. The kind of projects where using different build tools is important. The only settings that matters are the ones on your EXE project, the ones that force a particular jitter to get used. Project > Properties > Build tab > Prefer 32-bit and Platform target. They tried to change this in VS2010 btw, giving C# projects a solution platform name of "x86". Big fail whale, back to AnyCPU in VS2012. – Hans Passant Dec 15 '18 at 08:20
  • 1
    @HansPassant you are right. I just uncheck the "prefer 32-bit" and it worked. Could you tell me why it was a big fail ? Thank you a lot ! Now i can understand what happend here. – OOM Dec 16 '18 at 00:04
  • 1
    @PTwr I tried even in release it was needed to uncheck the "prefer 32-bit" option or to specify directly the x64 mode in "Platform targer" like Hans Passant just said it. Thank you even ! – OOM Dec 16 '18 at 00:06

1 Answers1

3

Thank to @hans-passant for the answear:

The solution platform name is irrelevant in C# projects, it only matters to C++ projects. The kind of projects where using different build tools is important. The only settings that matters are the ones on your EXE project, the ones that force a particular jitter to get used. Project > Properties > Build tab > Prefer 32-bit and Platform target. They tried to change this in VS2010 btw, giving C# projects a solution platform name of "x86". Big fail whale, back to AnyCPU in VS2012

Then the solution that worked for me was just to uncheck "Prefer 32-bits" to see visual choose the 64bit program as solution for Debug and Release mode.

Thank you again.

OOM
  • 728
  • 7
  • 22