|
get the HDC (or CDC if you are using MFC) and then use the GetTextExtent[^] api call to determine the string length
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
|
|
|
|
|
I have a client reporting that some of my code crashes on a few of his machines; I can't reproduce the problem on my end (what else is new) and all I have to work with is the crash address he's reporting.
I've had a look at Wouter Dhondt's excellent article on .MAP files[^]...and if I'm following the steps properly, the crash occurs in a memcpy() call...great, according to a search in my project's .cpp files, I'm calling it explicitely 74 times. Since I can't reproduce the crash there's hardly any point in stepping through all of them. Besides, if I understand correctly, the call to memcpy() might not necessarily be any of my own (ie, another C runtime library function might be doing it; who knows which one it is).
Taking it to the next step, I tried to determine what file/line the crash occurs in according to the .MAP file. Again based on the article, subtracting the load address (0x00400000) and the 0x1000 bytes PE header from the crash address (0x00459083), I end up with 0x00058xxx, which is nowhere near any of the addresses listed in the bottom part of the .MAP file. And since I'm within 0x004xxxxx, I'm pretty confident the crash doesn't occur in a DLL. I *know* I'm using the proper .MAP file as I've rebuilt the project (this time set to generate the .MAP file) and sent the client the recompiled EXE (which turned out to be identical to the previous one anyway).
I've tried to get the client to send me Dr. Watson logs and crash dumps, but none seem to ever get generated despite the options being selected (he's on Win2K SP2).
What next? I don't like the idea of sending a client an EXE with MsgBox() calls...
|
|
|
|
|
Run your release version in debug and and the break the program. Use the debugger to see if you have anything at the address in question. If your release program doesn't have any debug information, it would help to enable the program database debug information.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Well...I have *something*, I'm just not sure what it is. Wouldn't this (the memory at the crash address) be in the code segment?
|
|
|
|
|
The address you listed does seem like an IP, however if I remember the access violation dialog box, it lists a few numbers including the address being referenced and the IP of the instruction.
I just like using the debugger since reading map files can be confusing a hell. I have been doing it for 20 years and I still get confused.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
> if I remember the access violation dialog box, it lists a few numbers
> including the address being referenced and the IP of the instruction
That's part of the problem, I don't even get that much info on the crash dialog. Here's the full text (and I just realized I was looking at an old screenshot when I made the original post):
>>>
The instruction at "0x00459083" referenced memory at "0x00c70000". The memory could not be "read".
<<<
According to the .MAP file, the closest function (at 0x004590e0) is memcpy(), and 0x000580e0 isn't part of the .MAP file. So I don't know what to do next...
(I'd kill for a stack trace)
|
|
|
|
|
When you are looking at the map file, ignore the first column. Just take a look at the 3rd column. On an NT system, this will be the load address for the main image.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Yeah, the one entitled "rva+base". Given my crash address (0x00459113), here's what I have:
(...)
0001:00058080 __mbsrchr 00459080 f LIBC:mbsrchr.obj
0001:000580e0 _memcpy 004590e0 f LIBC:memcpy.obj
0001:00058415 __onexit 00459415 f LIBC:onexit.obj
(...)
...so the crash seems to occur in memcpy().
I understand the mapping back to the file/line number in Wouter's article...however in my case I don't have anything close to 0x00058113 (or close to that range) in the section where the .MAP file iterates through each source file (in the bottom half of the .MAP file). I'm wondering if there might be another offset I have to take into account that wasn't discussed in the article...my assumption is that I should be able to find an entry similar to:
nnn 0001:00058xxx
...where nnn is the line number in the source file being mapped.
I hope my description is a little clearer.
|
|
|
|
|
The program is crashing in memcpy. You won't have any source lines associated with that.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Not even a reference to which instance of my memcpy() calls causes the crash?
Back to my original post then...given this, what are my options?
|
|
|
|
|
Hi, everyone!
I want to know where can find a nice online
tutorial about raw socket programming on windows
platform?
Thanks in advance,
George
|
|
|
|
|
How raw do you want it? In terms of winsock programming, one excellent reference is CodeProject.
http://www.codeproject.com/internet/
Kuphryn
|
|
|
|
|
Thanks, kuphryn buddy!
George
|
|
|
|
|
Here's a little sump'n sump'n:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/winsock/tcp_ip_raw_sockets_2.asp
|
|
|
|
|
Thanks, Philnessosity buddy!
George
|
|
|
|
|
You're welcome, George2 buddy!
|
|
|
|
|
Hi !
I want to create array of objects of a certain class like:
CMyclass object[12];
But i want to intantiate these objects using one argument constructor of CMyClass. Is this possible or i've to create objects on heap ???
|
|
|
|
|
Initialize the array in the following way:
CMyclass object[12] = { CMyclass(argument), CMyclass(argument), CMyclass(argument), ..., CMyclass(argument) };
|
|
|
|
|
or, if you use stl,
std::vector<cmyclass> objects;
objects.resize( 12, CMyClass(argument) );
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
|
|
|
|
|
Help!
I am very confused with these functions :
OnWndMsg()
OnCommand()
OnCmdMsg()
What On earth are these functions's useful to out program?
And CView,CDocument,CMainFrame have their's own copy respectively
What's the difference to them?
Your answer will be greatly appreciated? I am very in urgence!
DavidWu
|
|
|
|
|
OnWndProc() is called by WindowProc during message reflection.
OnCommand() is called by the framework when the user selects an item from a menu, when a child control sends a notification message, or when an accelerator keystroke is translated. It processes the message map for control notification and ON_COMMAND entries, and calls the appropriate member function.
OnCmdMsg() is called by the framework to route and dispatch command messages and to handle the update of command user-interface objects. This is the main implementation routine of the framework command architecture.
|
|
|
|
|
Can anybody see why this doesn't link? (VSC++v.6)Any help would be truly appreciated...
HEADER FILE:
-----------
// set.h
#ifndef _INTLIST_H
#define _INTLIST_H
#include <iostream>
#include <vector>
#include <cassert> // for assert fn.
using namespace std;
template <class eltype="">
class Set
{
public:
// constructor
Set(); // construct a list of length 0
// accessors
int length () const;
// return length of list
Eltype retrieve (int i) const;
// retrieve ith list element
// (first element is in position 1)
bool contains (Eltype elt) const;
// return true if list contains elt; else false.
void make_empty();
// modifiers
void add (Eltype elt);
// add elt to end of list
void sort ();
// sort list in increasing order
void display ();
// display list on ostream os
Set<eltype> operator+(Set<eltype> set2);
void position(Eltype element, vector<int>& p);
void remove(Eltype element);
int len; vector<eltype> Elts;
private:
// length of the list
// elements of the list
bool sorted; // true if list is sorted; false otherwise
}; // end Int_list class declaration
template <class eltype="">
Set<eltype>::Set()
: len(0), sorted(true) // initializer list
{ }
template <class eltype="">
void Set<eltype>::add (Eltype elt)
{
if (len >= Elts.size())
Elts.resize(Elts.size() + 8);
Elts[len] = elt;
len++;
sorted = sorted &&
(len==1 || elt >= Elts[len-2]);
sort();
}
template <class eltype="">
void Set<eltype>::make_empty()
{
set();
Elts.resize(0);
}
template <class eltype="">
int Set<eltype>::length() const
{ return len; }
template <class eltype="">
void Set<eltype>::display()
{
ostream os=cout;
if (length()==0) return;
os << Elts[0];
for (int i=1; i<length(); i++)
="" os="" <<="" '="" elts[i];
}
template="" <class="" eltype="">
Eltype Set<eltype>::retrieve (int i) const
{
assert (0 <= i && i < len);
return Elts[i];
}
template <class eltype="">
bool Set<eltype>::contains (Eltype elt) const
{
for (int i=0; i< length(); i++)
if (Elts[i]==elt)
return true;
return false;
}
template <class eltype="">
void Set<eltype>::sort()
{
if (sorted) return;
int ins_elt; // element to insert
int ssv_sz; // sorted subvector size
int i;
for (ssv_sz = 1; ssv_sz < length(); ssv_sz++)
{
ins_elt = Elts[ssv_sz];
for (i = ssv_sz-1; i>=0; i--)
{
if (ins_elt >= Elts[i])
break;
Elts[i+1] = Elts[i];
}
Elts[i+1] = ins_elt;
}
sorted = true;
}
template <class eltype="">
void Set<eltype>::position(Eltype element, vector<int>& p)
{
int j=0;
for(int i=0;i<len;i++)
{
="" if(element="=Elts[i]){
" p[j]="i;
" j++;}
="" }
}
template="" <class="" eltype="">
void Set<eltype>::remove(Eltype element)
{
for(int i=0;i<len;i++)
{
="" if(element="=Elts[i]){
" for(int="" j="i;j<(len-1);j++)
" elts[j]="Elts[j+1];
" elts[j+1]="0;
" len="len-1;
" i="i-1;}
" }
}
template="" <class="" eltype="">
Set<eltype> operator+(Set<eltype> set2)
{
Set<eltype> result;
int total_length=len+set2.length();
result.Elts.resize(total_length);
for(int i=0;i<len;i++)
{
="" result.elts[i]="Elts[i];
" }
="" for(int="" j="len;j<set2.length();j++)
" return="" result;
}
#endif
test="" file:
---------
="" tstlist0.cpp
#include="" <iostream="">
#include <vector>
#include "ordintlist.h"
using namespace std;
template <class eltype="">
ostream& operator<<(ostream& outs, Set<eltype>& set2);
int main()
{
vector<int> p(6);
Set<int> L;
Set<int> M;
Set<int> N;
cout << "L= ";
L.display(); cout << endl;
cout << L.length() << endl;
L.add(30);
L.add(25);
L.add(30);
L.add(99);
M.add(67);
M.add(58);
M.add(30);
M.add(99);
cout << "L= ";
L.display();
cout << endl;
M.display();
cout << L + M;
cout << endl;
cout << N;
/*cout << L.length() << endl;
L.remove(30);
L.position(25, p);
cout << p[0];*/
cout << endl;
return 0;
}
// overloaded operators
template <class eltype="">
ostream& operator<<(ostream& outs, Set<eltype>& set2)
{
cout << "{";
for(int i=0;i<set2.len;i++)
{
="" cout="" <<set2.elts[i];
="" if(i!="set2.len-1)
" <<",="" ";
="" }
="" <<="" "}";
="" return="" cout;
}
errors:
------
compiling...
tstlist0.cpp
linking...
tstlist0.obj="" :="" error="" lnk2001:="" unresolved="" external="" symbol="" "public:="" class="" set<int=""> __thiscall Set<int>::operator+(class Set<int>)" (??H?$Set@H@@QAE?AV0@V0@@Z)
Debug/finally3.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
finally3.exe - 2 error(s), 0 warning(s)
|
|
|
|
|
yprog wrote:
Set operator+(Set set2)
I guess Set Set::operator+(Set set2) would be fine...
rechi
|
|
|
|
|
Hi,
I'm using MFC. I've have a handler for NM_CLICK for a listctrl, OnClickList() as shown below
ON_NOTIFY(NM_CLICK, IDC_ADDRESS_LIST, OnClickList)
OnClickList(NMHDR* pNMHDR, LRESULT* pResult)
The OnClickList() contains code which executes when user clicks on a row in the listcontrol. The problem is that, I want execute the same function OnClickList() on some other event as well.
I have the item and subitem index of the listctrl, where I want to simulate click. I tried
::SendMessage api with WM_NOTIFY and NM_CLICK. But I'm not able send the click notification to the list ctrl.
Can somebody illustrate with some sample code on how to do this.
Thanks a lot
|
|
|
|
|
Instead of sending a message, just call the function onclicklist()...
Actually, you have pointed out a problem in your program structure. Nothing should be done in your onclicklist function but handle the pNMHDR to call another function, for example HandleMyItem(UINT nIndex, int nButton), so that you can call the HandleMyItem not only in onclicklist but also in other functions in your app, changing the parameters if necessary.
~RaGE();
|
|
|
|