|
I, for one, would (will) really look forward to such an article.
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
Hi All,
Here's an interesting one... Debug is Broken, Release is OK. I've got test cases down to failures on LARGE files in Debug Builds. The reason the large file does not exist in Release: Debug information is stripped (I'm literally probing my own EXE).
The original FileMapping code was shamelessly ripped from Matt Pietrek's An In-Depth Look into the Win32 Portable Executable File Format[^]. I can't seem to find what is wrong with the original useage.
I suspect this has to do with the Memory Manager's ability to keep up... Any ideas? Below is how I am using CreateFileMapping/MapViewOfFile.
Jeff
if( 0 == GetModuleFileName( NULL, szFilename, PATH_SIZE ) )
{
std::cout << _T("Error Retrieving Process Filename") << std::endl;
__leave;
}
hFile = CreateFile( szFilename, GENERIC_READ, FILE_SHARE_READ,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
if ( hFile == INVALID_HANDLE_VALUE )
{
std::cout << _T("Error - CreateFile()") << std::endl;
__leave;
}
hFileMapping = CreateFileMapping(hFile, NULL,
PAGE_READONLY, 0, 0, NULL);
if ( NULL == hFileMapping )
{
std::cout << _T("Error - CreateFileMapping()") << std::endl;
__leave;
}
PVOID pMappedFile = NULL;
pMappedFile = MapViewOfFile(hFileMapping, FILE_MAP_READ, 0, 0, 0);
if ( NULL == pMappedFile )
{
std::cout << _T("Error - MapViewOfFile()") << std::endl;
__leave;
}
|
|
|
|
|
Where exactly are you picking up the error and did you make sure you SetLastError before the whole process?
|
|
|
|
|
Hi Waldermort,
WalderMort wrote: Where exactly are you picking up the error...
From the Output Window in Visual Studio .NET on Windows 2000.
I also confirmed it was a bug Windows XP, and Windows Server 2003. And confirmed the behavior using Visual Studio 2005. The bad thing was, it was my bug...
Basically, when inspecting ones own .CODE section, one of two methods is used:
1) if the image is a disk image, use (.TEXT Section)pSectionHeader-> PointerToRawData to locate the first .CODE page on DISK.
2) if the image is a memory image, use (.TEXT Section)pSectionHeader-> VirtualAddress to locate the first .CODE page in MEMORY.
PointerToRawData is usually 0x1000. VirtualAddress is larger - for example 0x3D00. The previous is added to a image Base Address - 0x400000 (hModule), PVOID from MapViewOfFile(), etc. Under certain circumstances (Debug Builds with large LIB files that cause a cross of Granulation Boundary), an ACCEESS_DENIED occurs - more correctly Access Violation.
With Debug builds, VirtualAddress != PointerToRawData. In Release builds, VirtualAddress == PointerToRawData. Hence the reason why Debug failed, and Release was successful.
My error crept in with the fact that VirtualAddress >>> PointerToRawData, and I was using VirtualAddress when probing the disk image in Debug.
What was especially frustrating was the fact that I wasted time in WinDbg on my spare Server (it only has 700 MHz CPU and 768MB of RAM) - painful. My development machine has dual 1GHz with 2GB of RAM. This is my personal Test lab at the house - complete with a pair of Cisco 1700s for segment testing
Jeff
|
|
|
|
|
BTW, I think this will make for an interesting article... Others could extend it as a Dynamic Disassembler, etc. I'll have to put a Cryptographic spin on it.
Jeff
|
|
|
|
|
Jeffrey Walton wrote: I'll have to put a Cryptographic spin on it.
LMAO.
If you do make an article from it. Please, please, please make it 64-bit compatible.
Glad you found the error.
|
|
|
|
|
Jeffrey Walton wrote: I suspect this has to do with [something other than my code or logic]...
Famous last words.
Jeff
|
|
|
|
|
Usually my last words are "Doh! It was me"
|
|
|
|
|
hello
i am calling a web service written in C# , from MFC application , and i need to know how to change the time out of the web service from the MFC application
thanks alot
|
|
|
|
|
What do you want to do ? What time do you want to change ? Do you mean the web service returns a DateTime and you don't know how to read it ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
How I can send XML packet from client to server
|
|
|
|
|
|
Hello,
I am looking for examples of UML drawings. Drawings of class diagrams for a general dialog based GUI application. The GUI could be some general buttons for the user to press that leads to child dialogs getting opened for more user interactions.
Does anyone know of any case studies, examples, tutorials that explains what I am after? Or may be web sites of interest?
Thanks for any information you could provide.
|
|
|
|
|
Hi All,
Please clarfy this point.
I have two classes COne and CTwo.And in the class declaration of COne i have the following declarations.
Class COne Class CTwo
{ {
Public: Public:
CTwo* p; int i,j;
CTwo p1;
CTwo *p2=new CTwo;
}; };
I want to know when i should do a "CTwo *p" and When "CTwo p1" and when i should do "CTwo * p2=new CTwo" because after all the declarations we can access the member functions and data members of the class CTwo.
Thanking you,
Ashwath Hegde.
|
|
|
|
|
You dont need to ask repeated
|
|
|
|
|
He has posted slightly different code in each thread. Perhaps he should locate the 'edit' button instead?
|
|
|
|
|
It seems odd for COne to have both "has a" and "is a" constructs. Is that intentional?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hello,
Does anyone know whic *.dll files I need to include with my VS2005 C++(MFC) Application
in order to run it on other machine, which does not have VS2005 installed ?
thanks
|
|
|
|
|
There's a redistributable program that comes with VC2005, which installs all the WinSXS stuff for MFC in the right folders. It's called vcredist2005 or something along those lines.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
|
Thanks for replies guys, but I am interested specifically in the *.dll files which are required for given program to run on another machine.
|
|
|
|
|
Perhaps you should read the docs pertaining to the redistritubals for your compiler/SDK. Sometimes distributing a single dll is not permitted, the whole installer must be distributed instead.
This is the case with DirectX, you cannot distribute a single 3mb dll, you must send the 40mb installer or provide a weblink ( the installer will download and install ).
|
|
|
|
|
One upon a time, in a galaxy far away, before an evil empire consumed all the protoculture on earth, you could statically link MFC to your Visual C++ application so you wouldn't have to worry about which dll's (except GDI+ on pre-XP boxes of course) you needed to send out the door with your app.
It used to be in the Project settings/properties in VC++ 6.0 and 2003.
Please tell me the children of the shadow did not remove that option from VC++ 2005. I'm still struggling with them cancelling Paul DiLascia's "C++ At Work" articles and I don't think I can take much more of this assimilation.
Does the option to statically link still exist on 2005?
|
|
|
|
|
|
I'm trying to find a good way to programmatically prevent a user from switching to, or gaining focus on, a specific application.
I have an appication which writes large files. These are intended to be used by another application.
This "Other Application" is a large elaborate system, and one of the things it does is monitor a particular directory, continuously updating its own status about the contents of that directory.
This is the directory which my application would also like to write.
If this App is allowed to monitor this directory at the same time my app is writing to it there will be trouble, including potential lost of data, deadlock, or crash.
If this App is running, but does not have focus, it's monitoring stops, so my application can write to the "shared" directory as long as the user does not switch back to this other App.
So, I would like to prevent the user from switching to it (while allowing any other action). I've thought of a few ways to attempt this -
A) Inject code into the other app and hook its message loop (I don't really want to do it that way, as it risks creating instability).
B) Hook the desktop and trap user messages which would wake that App up (but I'm not exactly sure how to go about this).
C) Use SuspendThread() and ResumeThread() to turn it off and on.
Does anyone have suggestions or ideas about how to accompish this?
Thanks.
(If there is a better discussion area for this topic, please let me know)
Brooks
|
|
|
|