|
Falconapollo wrote: >>it is even possible to embed the resource only DLL into the EXE itself.
could you explain how to do it? If successfully do it, how can submodule access the resource?
To embed a DLL in the resource, first create a custom type resource -
Right click on the .rc file in the resource view and select Add Resource -> Custom .
Give it any name like DLL.
The newly created resource will open in a binary editor and will be blank.
Now open the DLL file using the binary editor by using File -> Open , select the DLL and choose Open With -> Binary editor .
Select all the contents of the DLL (Ctrl + A), copy and paste it in the newly created resource file and save it.
To access the resource at runtime, do the following -
Use FindResource[^] to locate the resource.
Use SizeofResource[^] to get the size of the resource.
Use LoadResource[^] to get a handle to the resource.
Use LockResource[^] to get a pointer to the memory where the resource is loaded.
Use CopyMemory[^] to copy the resource contents into a buffer.
Now Create a new binary file using CreateFile[^].
Use WriteFile[^] to write the contents of the buffer into the file.
Now you have a resource only DLL file on disk that you can use just like a normal resource only DLL file.
Falconapollo wrote: >>If you do not want the resource extraction to be done at runtime, you could embed the resources in the static library itself.
as far as i can see, it's not possible to embed resources into static library directly, could you explain your idea?
You can create resources in static libraries in the exact same way as you do in an EXE or DLL project.
However, there are some caveats to it.
Read about it here -
VC++ resources in a static library[^]
LINKING RESOURCES FROM A STATIC LIBRARY[^]
«_Superman_»
I love work. It gives me something to do between weekends.
Microsoft MVP (Visual C++) (October 2009 - September 2013) Polymorphism in C
|
|
|
|
|
Thank you for your quick reply.
One more question: what if i modify our resources more frequently? it seems unconvenient to embed resources into static lib or exe, because i can't edit them directly...
|
|
|
|
|
Actually, you can - Using Resources[^]
«_Superman_»
I love work. It gives me something to do between weekends.
Microsoft MVP (Visual C++) (October 2009 - September 2013) Polymorphism in C
|
|
|
|
|
um...you might misunderstood me,i meants it's inconvenicent to edit *.rc file directly, for instance, adding dialog, adding strings, adding icons... it's even more inconvenient to use function: UpdateResource...
|
|
|
|
|
How do i find the position of taskbar in MFC...
|
|
|
|
|
|
This should do it -
CWnd* tray = FindWindow(L"Shell_TrayWnd", NULL);
RECT rect;
tray->GetWindowRect(&rect);
rect will have the screen coordinates of the taskbar.
«_Superman_»
I love work. It gives me something to do between weekends.
Microsoft MVP (Visual C++) (October 2009 - September 2013) Polymorphism in C
|
|
|
|
|
Hi
I am using VS2013 and I migrated a VS2005 to VS2013. It is a MDI application. I added in all the CMFCVisualManager code from the template project and it is working fine.
But in DEBUG mode when it terminates I see several memory leaks. I did the usual to try and track down where it was coming from and it took me to the MFC source code and a IMPLEMENT_DYNCREATE call that had the 2003 and 2007 VisualManagers as properties.
Has anyone else encountered memory leaks? Are they false?
Thanks.
Andrew
|
|
|
|
|
Hello!
I cannot offer any specific advice, but if you install Visual Leak Detector finding the root cause of your problem will be MUCH easier.
Regards
|
|
|
|
|
The problem was that I followed the tutorial for upgrading the Scribble application.
I changed the app class header to use CWinAppEx but not the source file. When I changed the source file the leak stopped.
|
|
|
|
|
Hi
I am using VS2013 Ribbon Designer and it allows you to select a 24 x 24 image for the application menu (that shows in the circle).
I have also added support for all the various visual styles to my application (CMFCVisualManager etc.).
My question relates to the Windows 7 style. It changes the application menu into a regular tab, coloured blue. This is more in line with MS Office 2013.
So my question is, my application menu has a name "FILE". Can I get that to display instead of the icon?
Thanks.
Andrew
|
|
|
|
|
I am programming a driver in kernel mode. I need my driver to detect a BSOD. When BSOD occurs my driver will write a flag out a registry or a file to mark BSOD occurred .In next boot ,My driver will read this flag to know BSOD in previous boot. if the flag is set the driver do something.
I found a way to detect BSOD by using KeRegisterBugCheckCallback routine. this routine registers a BugCheckCallback routine, which executes when the operating system issues a bug check.
but I don't know how to write file of write Registry in this callback (In this callback , ZwWriteFile or ZwSetValueKey can't do that)
Is there any way to do that?
or is there any other way to detect BSOD in previous boot ?
Thanks.
|
|
|
|
|
Not sure if it is even possible.
But here is a list of functions that work with the registry -
IoOpenDeviceRegistryKey
IoOpenDeviceInterfaceRegistryKey
RtlDeleteRegistryValue
RtlQueryRegistryValues
RtlWriteRegistryValue
ZwCreateKey
ZwDeleteKey
ZwDeleteValueKey
ZwEnumerateKey
ZwEnumerateValueKey
ZwOpenKey
ZwQueryKey
ZwQueryValueKey
ZwSetValueKey
Another possibility is for you to hook the KeBugCheckEx function.
Again not sure if this will actually work.
Here is an article on how to hook the kernel APIs - Hooking the kernel directly[^]
«_Superman_»
I love work. It gives me something to do between weekends.
Microsoft MVP (Visual C++) (October 2009 - September 2013) Polymorphism in C
|
|
|
|
|
I am going to say either impossible or very complex. Ask at OSR online though, that's where kernel experts hang out, someone else might have a suggestion.
"The whole idea that carbon dioxide is the main cause of the recent global warming is based on a guess that was proved false by empirical evidence during the 1990s." climate-models-go-cold
|
|
|
|
|
Dear Friends,
I have header file named as sample.h. My intention is, I don't want to modified this header by others (programmer). So I decided to create lib file for this header file alone.whether is possible??
I don't know whether my approach is right..
kindly help on this..
your suggestion are highly appreciated.
Thanks
S. Shanmuga Raja
modified 9-May-14 3:22am.
|
|
|
|
|
I don't see your point. Both header and lib file are needed in order to link with a library.
Veni, vidi, vici.
|
|
|
|
|
You cannot prevent people from modifying the header file, but it will not be much use to them if it does not match the library that comes with it.
|
|
|
|
|
It would be easier to just make a DLL if that is all you are trying to do.
In vino veritas
|
|
|
|
|
I am not trying to do anything. And whether it's a static library or DLL makes no difference.
|
|
|
|
|
Lazy man.
Veni, vidi, vici.
|
|
|
|
|
Hey, I'm retired, I'm supposed to be lazy. 
|
|
|
|
|
The Lion never sleeps.
Veni, vidi, vici.
|
|
|
|
|
Parturiunt montes, nascetur ridiculus mus.
|
|
|
|
|
Hello everybody.
I`m working on a project about Man In The Middle Attack by ARP poisoning method.
In this project I need to work like as a router. For example suppose In My Lan there is two other device (a modem & a laptop). I says to laptop that I`m the modem to fraud it. whenever the laptop wants to send a packet to outside of the LAN, sends the packet to me! All thing I need is I want to send the received packet to the modem & sends the response to victim laptop.
How can I do it programmatically?
Thanks a lot. Ya Ali.
|
|
|
|
|
I don't think anyone here is going to help you to create a program that can be used for illegal purposes.
|
|
|
|