I have a module load a file by its path,
However I find it is slow.
I want to accelerate it,
Is there any technology in Windows to create a virtual memory file for the module?
Many thanks
I tested BoxedApp SDK.
It is awesome, but it is not free :)
I'm not entirely sure of what you're asking, but if you just want to create a temporary file that will live in RAM (if possible), you can use CreateFile with FILE_ATTRIBUTE_TEMPORARY.
Assuming you're talking about memory mapped file, yes there are APIs for that. It's too much to discuss in a little SO answer, and besides it's many many years since I used so I don't even recall the function names. Here's how I found info on that quickly: http://www.google.com/search?q=memory+mapped+file+windows.
However, other simpler means are probably the answer to "I find it is slow".
There can be many different reasons for slowness. Please post some code. Then better answers can be given.
Cheer & hth.,
Related
I have asked pretty much the same thing before, but my post got deleted for some reason.
Anyway, I'm trying to use C++ and write a program that allows me to access directly to the memory and write stuff to it. I heard I need to do something with the kernel as that is a "bridge" that connects the OS and application (I think). Is there anyway I can download some sdk for the kernel?
I've said this in my previous post (which got deleted after some time) that the reason to this is because I want to try and crash windows 7 as my professor at university asked me to. (so please don't ask me stuff like "why do you want to crash windows?" or something along those lines...)
Any help will be greatly appreciated.
If you're interesting in working with the kernel, you're likely looking for the Windows Driver Kit, found here:
http://msdn.microsoft.com/en-us/windows/hardware/gg487428
It has a variety of lower-level tools and headers to help you write drivers and other kernel-mode code.
Typical programs obviously don't have carte blanche access to memory, while drivers have more control (although I would guess they use the system's memory management as well, not entirely sure). You'll find more information in the WDK.
Write a driver, make it crash. Of course, in only very specific circumstances will this actually make Windows 7 crash (because, unlike the public opinion, it wasn't written by total idiots).
You can use the RtlSetProcessIsCritical function in order to flag that your process is critical for system operations.
If your process is terminated (for example if your application calls ExitProcess) a bluescreen will appear. In order to use this function you need to enable the SE_DEBUG_NAME privilege.
I'm studying C++, now I'm reading about working with files. As I have read, there is quite a lot of variants. So I wanna ask, what is the right way to work with files in C++? Using fstream(ifstream and ofstream)? I have read some opinions that fopen works much faster, so it is better to use it, but it will be no C++.
Thanks for attention!
Use ifstream and ofstream when working in C++. It should not be much slower than FILE*, but is much safer.
See this related question.
I agree with Juraj's assessment of i/ofstream vs. FILE*, I just wanted a word about memory-mapped files. In Boost.SpiritClassic, there's a lesser-known gem called a mmap_file_iterator:
http://www.boost.org/doc/libs/1_47_0/boost/spirit/home/classic/iterator/file_iterator.hpp
I believe that it will memory-map your file if you're in a windows or POSIX environment, and it is a RandomAccessIterator, rather than a Input/OutputIterator.
As for what method is "proper", it all depends on your application's requirements. It is definitely good to explore all of your options and compare the results along as many dimensions as you can conceive.
There is an API call under linux that I forgot the name of.
You can essentially hint to the system how you'll be mostly accessing the file and it'll tune performance accordingly.
Can anyone recall the api function?
Are you looking for posix_fadvise()?
If you could help me with this dilemma I have. Now, I know C \ C++, I know asm, I know about dll injection, I know about virtual memory addressing, but I just can't figure out how
software like CheatEngine, and others, manage to change a variable's value in another process.
For those who don't know, 3rd party cheat engine tools can scan for values in the memory space of a program and identify the location of a variable with a given value and change it.
My question is, how do they do it?
Given an address, if I were to write C code, how could I change the value at that address belonging to another process without getting an invalid addressing error?
Thanks.
I'm fairly certain those programs are pretending to be debuggers. On Windows, I would start with DebugActiveProcess() and go from there.
Oh, and the very useful looking ReadProcessMemory() function (and WriteProcessMemory()).
On unix: ptrace()
You can't do this with Standard C or C++ - you have to use operating system specific features. So you need to tell us which OS you are interested in.
You may also be interested in Detours:
Software packaged for detouring Win32 and application APIs.
I want to create a file that only resides in memory... In looking through some documentation I saw a recommendation to use a shell extension as a virtual file. Im not sure that is a workable solution but I would like to know
Is it a good approach (or should I be using a ramdisk instead)
Where is a good place to start to read up on it
Note: This is on the Windows platform
As I understand, you want your program to create a "file", which resides only in memory and that you can pass on to another external program (say, Microsoft Word).
AFAIK this is not possible, short of a ramdrive. I'd suggest using a temporary folder. You will however have to come up with a strategy for deleting the file when it's not needed anymore.
Added: On second though, you might want to check out Reparse points. I'm not familiar with them myself, and they will only work for NTFS formatted disks, but perhaps they can provide you with what you want. It will be a lot of coding though.
You don't say on which plateform you are but I'm guessing Windows. Is mmap() available? If not, I think BerkeleyDB has been ported to Windows so you should be able to use that. Win32 API may have something akin to mmap() but I don't know it.
If you want a file that resides only in memory, use a named pipe or something, though I question your scenario - can you go up a level and describe what you want to do?