|
Hi,
Thanks for the reply ... I was wondering if my question was even going to get one
I've done a full instrumentation of all the entire using Boundschecker, and no memory overwrites turned up. Maybe I should have mentioned in my original post that not a lot of code is being executed in the time it takes HeapAlloc() to spit out the duplicate pointer.
Basically, the structure of code is like:
Call one event sink
Insert the treeview item (first pointer)
Enumerate the treeview using TVM_GETNEXTITEM to ensure the item was added
Call next event sink
ATL event tracing (duplicate pointer)
I'd estimate that there were about ~30 calls to HeapAlloc in the time between the duplicate pointer returns.
I didn't check calls to HeapReAlloc, but I'll do that and post my results.
Fortunately, at work we have an MSDN subscription which includes 2 developer support calls, and I've been authorized to use one of them for this particular instance ... so hopefully I'll get an answer sometime soon.
Thanks for the help,
Scott
|
|
|
|
|
Just a though that struck me. If you can write some code before that "ATL event tracing (duplicate pointer)", and you can duplicate the bug even if you break into a debugger (which it seems you can), what about using a local variable and set it (using the debugger) to point to the memory you think is already allocated (but the "second" allocation returns) and just call IsBadReadPtr/IsBadWritePtr on it?
OK, checking HeapReAlloc isn't gonna hurt, but it never hurts to exhaust all options before that "support" call either.
|
|
|
|
|
Well,
I after adding the treeview item, I set a breakpoint on all HeapReAlloc() calls, and it was hit one time, on a call to realloc(), which is using the CRT heap ... aside from that, the GetProcessHeap() heap wasn't touched by any HeapReAlloc calls.
I tried your last suggestion ... I took the HTREEITEM returned by the TVM_INSERTITEM (which actually points to a 0x24 byte internal structure ... gotta love reverse engineering MS dll's) and called IsBadReadPtr(hItem, 0x24), and it returned 0 so ... hmmm ...
If you can think of anything else, let me know ... I feel as though I've tried every thing conceivable
Thanks,
Scott.
|
|
|
|
|
If i do this:
char s[] = "hello\nhow\nare\nyou\doing"
SetDlgItemText(ghWnd, IDC_EDIT, s);
then a newline doesen't appear, only a "|". what am i doing wrong? and it doesen't work if i use \r instead of \n either.
|
|
|
|
|
|
use "\r\n"
like this char s[] = "hello\r\nhow\r\nare\r\nyou\r\doing"
Casa.Sapo.pt
|
|
|
|
|
Hi,
I know it is a VC++ forum, but i really need help!!! Let's see my code first:
********************************************************************************
void operation(int[], char[]);
void waitprocess(int);
void main(void)
{
int i, j;
static char buffer[BUFSIZE+10], X_value[5], message[BUFSIZE];
int f_des[2];
if (pipe(f_des) == -1) //create the pipe
{
perror("Pipe");
exit(2);
}
if (fork()==0) //In the CHILD
{
// do nothing here because we will
// create 5 CHILDs by PARENT again later.
}
else //PARENT
{
for (j=1; j<=5; j++) //create 5 CHILD process
{
if (fork()==0)
{
static char temp[BUFSIZE];
sprintf(temp, "Thread %d", getpid()); //Get the thread ID
operation(f_des, temp); //Send the request
}
}
while (X>0) // keep doing (read from pipe) until X=0
{
close(f_des[1]);
if (read(f_des[0], message, BUFSIZE) != -1) //Read from pipe
{
sprintf(buffer, " - X = %d \n", X);
strcat(message, buffer);
write(1, message, sizeof(message)); //display output
waitprocess(getpid()); //force sleep awhile
X--;
}
else
{
printf("error");
}
}
}
}
********************************************************************************
I have to create 5 "threads" but using fork() because i have to use pipe() to communicate with "server". This program is doing that 5 "threads" are trying to decrement the global X until X=0. I use pipe as a mechanisam to protect this "critical section". I don't know whether i did it right or wrong. Please help me to check!!!
Also, I found that the output looks strange. The output is always in a pattern. For example, the output looks liked:
Thread 1001 - X = 20
Thread 1003 - X = 19
Thread 1002 - X = 18
Thread 1005 - X = 17
Thread 1004 - X = 16
Thread 1001 - X = 15
Thread 1003 - X = 14
Thread 1002 - X = 13
Thread 1005 - X = 12
Thread 1004 - X = 11
*
*
*
You can see the sequence is 1,3,2,5,4,1,3,2,5,4...etc. I think the output should be in random sequence. Why it's happened???
Thanks!!!!!
|
|
|
|
|
Hi,
how can I change my window dimension at runtime?
Is there something better as SetWindowPos() or how do I use it to change only the window size (position stays untouched)?
Thanks
|
|
|
|
|
Try MoveWindow which is an easyer way of calling SetWindowPos .
rechi
|
|
|
|
|
Use SWP_NOMOVE | SWP_NOZORDER in the "nFlags" argument of CWnd::SetWindowPos() . This will cause only the window's size to be changed.
/ravi
Let's put "civil" back into "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Okay, I use this code now:
RECT winRect = {0, 0, nWidth, nHeight};
AdjustWindowRectEx(&winRect, WS_OVERLAPPEDWINDOW, FALSE, WS_EX_APPWINDOW | WS_EX_WINDOWEDGE);
SetWindowPos(m_data.hWnd, HWND_TOP, 0, 0,
winRect.right-winRect.left,
winRect.bottom-winRect.top,
SWP_NOMOVE|SWP_NOZORDER|SWP_NOCOPYBITS);
I still have a problem: When the window is maximized and I change the dimensions with my code, the maximize button is not changed. Instead Windows thinks my window is still maximized.
Any ideas? Thanks for help again!
|
|
|
|
|
Performing a ShowWindow(m_data.hWnd, SW_RESTORE) before resizing did solve the problem.
|
|
|
|
|
PS: This should be the subject for last post
|
|
|
|
|
Does SetSize method of IStream preserve the information existing in the stream object if the new size is smaller then the previous one?
rechi
|
|
|
|
|
It should truncate it I think. It might depend on the IStream implementation though. Best is to make a test program. Create an IStream working on global memory (use StreamFromHGlobal() or something like that) and write to it, then setsize then read it back.
James
Drinking In The Sun
Forgot Password?
|
|
|
|
|
HI
I am developing a utility like spy++. Here till now I am able to highlight the mose controls & windows .But for the painted controls like static text in visual basic applications the things are not working.I am using
WindowFromPoint() API.
can anybody help me out ?
VIKS
|
|
|
|
|
See the source code section of the following page - there is an implementation there.
http://freespace.virgin.net/james.brown7/
Best regards,
Paul.
Paul Selormey, Bsc (Elect Eng), MSc (Mobile Communication) is currently Windows open source developer in Japan.
|
|
|
|
|
vikrams wrote:
.But for the painted controls like static text in visual basic applications the things are not working.
This is nothing strange nor a bug is your app. Visual Basic uses Windowless Controls so you don't get any window.
|
|
|
|
|
so what I need to do for highlighting the windowless controls?
VIKS
|
|
|
|
|
You can't do anything You can't spy them thru' normal means. If it is possible it will be very difficult
|
|
|
|
|
Thanx for helping Sir .
VIKS
|
|
|
|
|
How do you tell how long a function takes to run? Something like you start a timer, then call the function, then read the timer when you have broken out of the function.
-Raffi
|
|
|
|
|
If you're satisfied with a rough measuring, this will do:
DWORD dw=GetTickCount();
f();
dw=GetTickCount()-dw;
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
what about something like:
int i = GetTickCount();
SomeFunction();
int usedtime = GetTickCount() - i;
Just be aware that when the computer have been running for about 40 days, GetTickCount() starts from zero again...
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
sounds good. thx
-Raffi
|
|
|
|