Hi ya-all,
I would like to know how to allocate a part of memory in windows globally for all instances of my proggy to acess - and only my proggy.
i am currently using CoTaskMemAlloc that gives me a pointer to the allocated memmory.
I would like to stick as closly to WinAPI calls as possible.
Oh by-the-way any routine like ZeroMemory (VC++) that can clear the contents of the allocated memory for me,
i hate loops... (no real trace debugger availible. Using Olly, i guess i got lazy while using VC++)
Thanx
I would like to know how to allocate a part of memory in windows globally for all instances of my proggy to acess - and only my proggy.
i am currently using CoTaskMemAlloc that gives me a pointer to the allocated memmory.
I would like to stick as closly to WinAPI calls as possible.
Oh by-the-way any routine like ZeroMemory (VC++) that can clear the contents of the allocated memory for me,
i hate loops... (no real trace debugger availible. Using Olly, i guess i got lazy while using VC++)
Thanx
memory mapped files as long as you do ring3... start by trying to map it, if it doesn't succed, create it.
CreateFileMapping will open if its already created, and create otherwise
The Question abou ZeroMemory Resolved : RtlZeroMemory!!!
The other, well... idealy i would like to generate the data on the fly cause the data is crutcial for my app. if i read it in from a file or memory mapping it then i might encounter unmarked bad sectors ect. and i need a fast acess to it.
the data will never change, and always follows a pattern. total required size is 6316032 bytes.
The other, well... idealy i would like to generate the data on the fly cause the data is crutcial for my app. if i read it in from a file or memory mapping it then i might encounter unmarked bad sectors ect. and i need a fast acess to it.
the data will never change, and always follows a pattern. total required size is 6316032 bytes.
why do u use api for zeroing memory when u are using assembly especially?
Maybe some special buffer allocation with zeroing memory.
If you want global memory between multiple programs, file mapping is your only choice. Use INVALID_HANDLE_VALUE instead of a regular file handle, that way it's backed up by the paging file - and is, in effect, just a global piece of memory. Note that it's not global in the sense that you can just pass the memory pointer around - you will have to use OpenFileMapping in other processes.
If you only need to share memory between instances of *one* application, you could use a shared PE section instead. But for a 6 meg buffer, I would prefer the dynamic approach.
Even a "rep stosd" should be faster than a call to RtlZeroMemory, and there's even faster ways to do it - I don't expect your buffer zeroing is a critical piece of code, though, so rep stosd (or even calling RtlZeroMemory) is an okay choice.
Note that sharing memory between processes can be a bit tricky - if you only have read-only access to the shared memory after it's been generated, that does make things a bit easier, but you have to consider the possibility of lauching two instances of the app nearly simultaneously...
If you only need to share memory between instances of *one* application, you could use a shared PE section instead. But for a 6 meg buffer, I would prefer the dynamic approach.
Even a "rep stosd" should be faster than a call to RtlZeroMemory, and there's even faster ways to do it - I don't expect your buffer zeroing is a critical piece of code, though, so rep stosd (or even calling RtlZeroMemory) is an okay choice.
Note that sharing memory between processes can be a bit tricky - if you only have read-only access to the shared memory after it's been generated, that does make things a bit easier, but you have to consider the possibility of lauching two instances of the app nearly simultaneously...
OK, i have tried using CreateFileMapping and it fails...
[6mb wrong, 8Mb - sorry my miscalculation]
invoke CreateFileMapping,INVALID_HANDLE_VALUE,NULL,PAGE_READWRITE,80h,NULL,ADDR szLookupTable
szLookupTable db "BitFusion.LookupTable",0
and eax is returned zero. i cant trace to this location in my progg and Olly is REALY startin to get on my bad side.
I initically wanted a worker thread to on "instance" to generate the code, but looking @ the documentation of F0dder's proposal, it looks simpler and it has the ability to tell me if i already created the buffer.
Any1 able to tell me why my call fails.
[6mb wrong, 8Mb - sorry my miscalculation]
invoke CreateFileMapping,INVALID_HANDLE_VALUE,NULL,PAGE_READWRITE,80h,NULL,ADDR szLookupTable
szLookupTable db "BitFusion.LookupTable",0
and eax is returned zero. i cant trace to this location in my progg and Olly is REALY startin to get on my bad side.
I initically wanted a worker thread to on "instance" to generate the code, but looking @ the documentation of F0dder's proposal, it looks simpler and it has the ability to tell me if i already created the buffer.
Any1 able to tell me why my call fails.
another thing, the data goes as follows....
0
1 0
2 1 0
3 3 1 0
4 6 4 1 0
5 10 10 5 1 0
6 15 20 15 6 1
7 21 35 35 21 7
this is arranged in columbs and rows. i have an implementation for it in a memory block. {it is a lookup table for many purposes. Example :Lotto.... 46 total possible numbers and 6 gets drawn, how many posible combinations are there ? Remember every number only occurs once.} But for me it is a lookup table to use for bit to bit data compression on an idependant platform {video, audio and execution code holds the same *weight*}
The reason for this table is say we have 1024 availible spaces and require 256 of those space to be occupied... generating the numerical representation of this sequence will *even in asm* take approx 3 days or more {full exec time} and this is for 1 line of code.
Hence a dirivative of the generation routine, using the numerics that will cause an impact upon the result will yeald a bell curve table that can be used to determine the numerical number of the senario and vice versa - hence fast compression on a simple bit platform.
0
1 0
2 1 0
3 3 1 0
4 6 4 1 0
5 10 10 5 1 0
6 15 20 15 6 1
7 21 35 35 21 7
this is arranged in columbs and rows. i have an implementation for it in a memory block. {it is a lookup table for many purposes. Example :Lotto.... 46 total possible numbers and 6 gets drawn, how many posible combinations are there ? Remember every number only occurs once.} But for me it is a lookup table to use for bit to bit data compression on an idependant platform {video, audio and execution code holds the same *weight*}
The reason for this table is say we have 1024 availible spaces and require 256 of those space to be occupied... generating the numerical representation of this sequence will *even in asm* take approx 3 days or more {full exec time} and this is for 1 line of code.
Hence a dirivative of the generation routine, using the numerics that will cause an impact upon the result will yeald a bell curve table that can be used to determine the numerical number of the senario and vice versa - hence fast compression on a simple bit platform.
Umm, you do realize you're asking for around 512 gigs of memory, right? :). If you want an 8meg buffer, pass 0 for dwMaximumSizeHigh and 0x800000 for dwMaximumSizeLow.
...that should probably help a bit :)
Sorry it took me so long to answer, but I was working on some driver code that behaved weirdly (until I realized it was because of a unregister failure etc and I had to do a reboot - sigh).
invoke CreateFileMapping, INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, 0800000h, ADDR szLookupTable
...that should probably help a bit :)
Sorry it took me so long to answer, but I was working on some driver code that behaved weirdly (until I realized it was because of a unregister failure etc and I had to do a reboot - sigh).
Oops, sorry bout the mistake! THANX F0dder!!!
i feel like such an ass, typing the code out without actually looking at it.
i feel like such an ass, typing the code out without actually looking at it.
Don't worry, we all do that from time to time. The most obvious bugs can be the hardest to find...
Hey F0dder, do you know where i can perhaps get an ASM Reference. Like all the acronym (operation) listings and their effect upon the registers.... you see i am @ work and i just say lost most of my asm programming doc's and now i need to get it back. {Yahoo yealded no goot results}
I think fasm has a good list of the instructions, www.flatassembler.net . Thomas has a little stuff in his win32asm tutor, www.madwizard.org . And of course, the intel stuff: http://www.intel.com/cd/ids/developer/asmo-na/eng/microprocessors/ia32/pentium4/resources/reference/index.htm .
Thank you again F0dder.
{i feel that i am going to start saying that i great deal more in this form....}
{i feel that i am going to start saying that i great deal more in this form....}