How to find out if a file is loaded in memory?
-
Hello! Let's say I load a "data.bin" file in dinamic memory using a program. Now, can I by means of C++ code, find out using another program, if a file called "data.bin" is loaded in memory? Thanks!
-
Hello! Let's say I load a "data.bin" file in dinamic memory using a program. Now, can I by means of C++ code, find out using another program, if a file called "data.bin" is loaded in memory? Thanks!
-
What are you trying to accomplish? This sounds like an instance of the XY problem[^].
Well yes, it is a XY problem. :) When I'm opening a txt file from an application which I made I want to open another instance of this application with the file opened in it. So I don't want to load all the dlls and bins again, but just point to them in the memory (because the files were already loaded by the application which was first opened). I want to do this because I cannot make the application a MSDI one, because it's to hard to do for me.
-
Well yes, it is a XY problem. :) When I'm opening a txt file from an application which I made I want to open another instance of this application with the file opened in it. So I don't want to load all the dlls and bins again, but just point to them in the memory (because the files were already loaded by the application which was first opened). I want to do this because I cannot make the application a MSDI one, because it's to hard to do for me.
I don't think you can interfere much with how images (executables, not bitmaps) are loaded, but they're partly shared anyway. Don't ask me for too much detail, I'm not very familiar with what exactly windows does with images and/or memory mapped files. That's all much too complex for such a goal anyway - just look into MDI, it'll be simpler.
-
Hello! Let's say I load a "data.bin" file in dinamic memory using a program. Now, can I by means of C++ code, find out using another program, if a file called "data.bin" is loaded in memory? Thanks!
-
DLiviu wrote:
It will matter because it takes 15 seconds for the app to start.
You know that there are ways to mitigate that right?
-
DLiviu wrote:
No, there aren't.
I guess the number of times I have done it and countless others are just fantasy.
-
You say there are ways to make this files load faster? I guarantee you that in this case there are no ways. Loading has already been optimized to the max.
-
Is calling ReadProcessMemory[^] hacking? It would no doubt end up that way if the OP tried to use it to solve his problem.
Steve
-
Well yes, it is a XY problem. :) When I'm opening a txt file from an application which I made I want to open another instance of this application with the file opened in it. So I don't want to load all the dlls and bins again, but just point to them in the memory (because the files were already loaded by the application which was first opened). I want to do this because I cannot make the application a MSDI one, because it's to hard to do for me.
Each process has it's own address space so, in general, it's not possible to just run another instance and "point to them in the memory". If you're worried about DLL's and such beging loaded twice I'd leave the management of virtual memory up to the OS, it's smart enough to map the same physical page into multiple processes when possible.
Steve
-
DLiviu wrote:
It will matter because it takes 15 seconds for the app to start.
You know that there are ways to mitigate that right?
Find out what's really taking the time instead of guessing (I'm willing to bet incorrectly).
Steve
-
Each process has it's own address space so, in general, it's not possible to just run another instance and "point to them in the memory". If you're worried about DLL's and such beging loaded twice I'd leave the management of virtual memory up to the OS, it's smart enough to map the same physical page into multiple processes when possible.
Steve
Are you sure of this? In what operating system? I have Win XP and I can tell you for sure that this is not happening because when I open a second app it takes as much time as the first one for all the files and dlls to load. Maybe in higher operating systems all apps point to the same adress in memory but not in XP.
-
Is calling ReadProcessMemory[^] hacking? It would no doubt end up that way if the OP tried to use it to solve his problem.
Steve
-
Are you sure of this? In what operating system? I have Win XP and I can tell you for sure that this is not happening because when I open a second app it takes as much time as the first one for all the files and dlls to load. Maybe in higher operating systems all apps point to the same adress in memory but not in XP.
Yes, XP included. I'd guess what you think is taking the time is not the real culprit.
Steve
-
Are you sure of this? In what operating system? I have Win XP and I can tell you for sure that this is not happening because when I open a second app it takes as much time as the first one for all the files and dlls to load. Maybe in higher operating systems all apps point to the same adress in memory but not in XP.
You say it's taking 15 seconds to start up, this gives plenty of time to break into it 5 or so times with a debugger and get some stack traces to see what it's really up to.
Steve