|
Mark Salsbery wrote:
Why did you pick 80ms to wait here? What if it takes 81ms?
Under normal conditions, it shouldn't take even 3ms on a fairly modern machine.
Why is it implemented this way? Because with insufficient access rights, NtQueryInformationFile doesn't return...at least not in reasonable time (I didn't write this code, but WAIT_TIMEOUT happens here up to 77 times on my machine. Also with 100 ms which was the default set several years ago by the author of this part).
_endthread() would need to be called by the thread itself, which is impossible when NtQueryInformationFile doesn't return. Yes, this can cause a resource leak, I need to rewrite it to use CreateThread instead.
Anyway, it's not the case. After a few hours of restarting my computer, I found where is the problem.
INtDll::NtQueryObject ( handle, 1, NULL, 0, &size );<br />
<br />
if ( size == 0 )<br />
size = 0x8000;<br />
<br />
lpBuffer = (UCHAR*)HeapAlloc(hHeap = GetProcessHeap(), 0, sizeof(UCHAR)*size);<br />
<br />
if ( INtDll::NtQueryObject( handle, 1, lpBuffer, size, NULL ) == 0 )<br />
{<br />
SystemInfoUtils::Unicode2CString( (UNICODE_STRING*)lpBuffer, str );<br />
ret = TRUE;<br />
}
Neither MSDN nor ntinternals.net write about thread security issues in NtQueryObject.
I'm going to try to put it in a critical section and see what happens. Need another restart though
-- modified at 15:13 Saturday 24th November, 2007
When there's a hung process in memory, it becomes totally unpredictable.
Even the single treaded, well tested version can hang here.
I'm leaving it for today, I'm too tired.
|
|
|
|
|
maciu2020 wrote: _endthread() would need to be called by the thread itself
Oops, yeah, sorry about that
maciu2020 wrote: Because with insufficient access rights, NtQueryInformationFile doesn't return
That's a bummer, as you well know Isn't there a way to do what you're trying to do using
documented/supported APIs?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark Salsbery wrote: Isn't there a way to do what you're trying to do using
documented/supported APIs?
Unfortunately, there isn't.
What I'm doing is making Zoltan Csizmadia's ForceDel (a tool that deletes locked files) more usable. Improved performance (originally-very poor, especially when trying to delete multiple files), GUI, some more features.
AFAIK there are 2 ways of doing it. The first is what Zoltan does - enumerating all handles and closing the right ones with CreateRemoteThread(CloseHandle).
No documented API gives these handles...
There's one more method, implemented in Unlocker. It's not open source and I had no time to reverse it..but it's a kernel mode hack. I guess, a kind of hook...and I think it's even worse than what I'm working at. It works faster though and maybe I'll decide to try to do the same.
|
|
|
|
|
Cool
I've never played around with that stuff before.
Good luck!
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks that you tried to help.
|
|
|
|
|
In .net (VS2003 ),C# can create a dialog with localizable attribute which can put the control outside the dialog and show it with two scroll bar .
But in VC 7.1,I didn't know how to realize it?
===========================
http://begtostudy.blogspot.com/
email:begtostudy@gmail.com
MSN:begtostudy@gmail.com
|
|
|
|
|
??????????
You can always use CFormView, make it very big in the resource editor and then override the CChildFrm to make the frame smaller than the real surface. That will make you the scrollbars and put your control outside the "First sight".
Is something like that what you wanted?
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
ChildFrm ?That is MDI .
What can I do in dialog of MFC dll .
Thanks .
===========================
http://begtostudy.blogspot.com/
email:begtostudy@gmail.com
MSN:begtostudy@gmail.com
|
|
|
|
|
i've added onidle plus invalidate the win and set the onidle to 0; as this option allows playing of the sound.
I am very much a begginer and I'm sorta testing things out.
Could any one tell me whats going on with this approach?
Thanks very much..
Simon
-- modified at 19:58 Friday 23rd November, 2007
|
|
|
|
|
Can you post some relevant code? I'm not clear where and how you
are calling PlaySound() and what OnIdle() has to do with it.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I am trying to create a game in mfc
in the OnDraw, I am calling ---- PlaySound("c:\\sound.wav",0,SND_FILENAME | SND_ASYNC); -----
the OnIdle is called when there is no mouse or keyboard activity
and with in onidle the invalidate is called for ondraw
--- AfxGetMainWnd()->Invalidate(false); ---
so the draw is called a number of times,
I know that the playsound is called a number of times, sofor I would expect
odd behavior, so I have set the onidle return value to 0, so it is only called after keyboard or mouse interuption has ended as aposed of the call to be continuse
as I mentioned the sound only plays when there is no keyboard or mouse acticvity
what I am after Is a soloution, or a structered method to go about this,
I have looked around on the internet, an d things seem very complcated
this playsound is all I can go about
if you can refer me to any relevant articles, it would very much be a appreciated
simon
|
|
|
|
|
simon alec smith wrote: as I mentioned the sound only plays when there is no keyboard or mouse acticvity
That's the only time you'll get OnIdle() calls!
Ok I understand now, thanks for the explanation.
You may want to look into using a timer, either a regular windows timer
if resolution isn't important, or a multimedia timer for more precise timing.
I think you'll find this will work much better than trying to do periodic stuff
in OnIdle()
Using Timers[^]
Multimedia Timers[^]
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi, for some reason i can only call ON_COMMAND in my main dialog, how can i call it in a child dialog?
Any ideas would be much apreciated!
|
|
|
|
|
How can you call ON_COMMAND? ON_COMMAND is not a function or method AFAIK.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi Mark, I call it via afx_msg void OnAddNewItem(); and ON_COMMAND(ID__ADDITEM, &CItemDlg::OnAddNewItem)
Edit:
the menu item is created via CMenu and if i move ON_COMMAND(ID__ADDITEM, &CItemDlg::OnAddNewItem) to the main dialog it works fine. But i want to know why i cant call it in the child dialog
|
|
|
|
|
You aren't calling anything. You've added a method that will get called when the
window you've added it to receives a WM_COMMAND message corresponding to a
menu item or child window with the id "ID__ADDITEM".
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Ok, how do i associate the menu to the dialog? The menu opens when right mouse button is pressed and so i dont care to attatch it to the Child Dialogs system menu.
|
|
|
|
|
FredrickNorge wrote: ...how do i associate the menu to the dialog? The menu opens when right mouse button is pressed...
The TrackPopupMenu() API/method takes a window handle/ptr to the window
that should receive the command messages.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks, that made it work
|
|
|
|
|
I will try to write question shortly
struct CEvents
{
virtual HRESULT Method1() = 0;
virtual HRESULT Method2() = 0;
virtual HRESULT Method3() = 0;
};
class A : public CEvents
{
// Implementation of VTBL methods
virtual HRESULT Method1();
virtual HRESULT Method2();
virtual HRESULT Method3();
HRESULT Some();
B *m_B;
};
HRESULT Some()
{
m_b->Initialize( (CEvents*)this );
return S_OK;
}
class B
{
CEvents *m_evs;
HRESULT Initialize( CEvents *evs );
}
HRESULT B::Initialize( CEvents *evs )
{
///////////////////// THIS IS MY QUESTION /////////////////
// This i have trouble... access violation and ect....
// But when i use not pointer to class B as member of A ( B *m_B; )
// there is no any problems - PLEASE, TOLD ME, WHY??????????????
m_evs = evs;
return S_OK;
}
ISQ 469907496
|
|
|
|
|
Are you initialising the m_b member in the constructor of class A?
Habetis bona deum
|
|
|
|
|
|
I don't see anywhere that you actually create any objects.
You have pointers declared but they are uninitialized.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
actually it was shortly sample...
ISQ 469907496
|
|
|
|
|
How should we help you then?
What errors are you getting? On what line(s)? Compile or runtime?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|