Fixed Memory I don't need to allocate?
I just need a fixed address in any win32 process, where I can store 8 bytes without using any winapi function. I also cannot use assembler prefixes like fs:. and I have no stack pointer.
What I need:
-8 bytes of memory -constant address and present in any process -read and write access (via pointer, from the same process) -should not crash the application (at least not instantly) if modified.开发者_如何转开发Don't even ask, why I need it.
The only way I'm aware of to do this is to use a DLL with a shared section...
// This goes in a DLL loaded by all apps that want to share the data #pragma data_seg (".sharedseg") long long myShared8Bytes = 0; // has to be initialized or this fails #pragma data_seg()
Then, you add the following to the link command for the dll:
/SECTION:sharedseg,RWS
I am also curious why you want this...
Not that I recommend this, but the PEB probably has some unused or inconsequential fields in it that you could overwrite. I still think this is a terrible idea, though.
constant address and present in any process
You won't be able to achieve that. Win32 uses paged memory so different processes can access the same memory addresses even though it is different memory.
精彩评论