|
|
Actually, my question stems from some articles
published in codeproject about "fast" c++ delegates
and the innards of pointers to member functions
(i.e. methods).
A functor is probably not resembling this. The most
significant contribution is Boost.Function and Signals.
As there has been significant discussion of the
memory usage of Boost.Function and how to improve it,
I was curious about the standard, as many parts
of boost are under review to be included in the
standard.
Cheers
|
|
|
|
|
I'm writing a plug-in for an NLE, and I wish to forcibly resize my window to fill the area that is available. The PlugInPP class is defined as such:
class ATL_NO_VTABLE CPluginPP :
public CComObjectRootEx<CComMultiThreadModel>,
public CComCoClass<CPluginPP, &CLSID_PluginPP>,
public IPropertyPageImpl<CPluginPP>,
public CDialogImpl<CPluginPP>
In order to get the sizing messages for the parent window, I have sub-classed it, and when I see a WM_SIZE message, I do the following:
::MoveWindow( Main_zMappingArray[ 0 ].hDialogWnd,
0,
0,
LOWORD( lParam ),
HIWORD( lParam ),
TRUE );
My PlugInPP::OnSize method gets called with the new size, no problem there. However, there is immediately another WM_SIZE message setting back the original sizes or the dialog resource.
I'm beginning to think that the silly buggers have subclassed the PlugInPP window and resize it whenever they see a WM_SIZE message, but that seems like an awful lot of work to do in a situation where the window is by no means resize-able.
Give the ATL::CDialogIMpl and ATL::IPropertyPageImpl base classes, I'm wondering if there's a trick to resizing them, or a trick to preventing them from being resized that I can opt out of.
Otherwise, I guess I'm stuck with subclassing my own window again, and just eating the WM_SIZE messages, and hope that works.
CraigL
|
|
|
|
|
Hoping someone can still provide some help here, this is some update on what I've been finding; but one Q at a time so it doesn't seem so haphazard.
When I subclass the propertypage/dialog, the previous proc address I get is an address well within the range that the Modules tab in VSW shows me user32.dll was loaded, so from that I can be fairly certain that the containing application is NOT subclassing it and simply re-initiating a MoveWindow whenever it sees a specific message.
Is this correct? Or if it is not a safe assumption, any pointers on where/how to figure out who all is busy subclassing and 'walk the tree'?
Thanks,
CraigL
|
|
|
|
|
Well, I did finally manage to figure it out. The containing app was moving it, but using the IPropertyPageImpl::Move method. Why they didn't see fit to call it MoveWindow like every other single thing in windows, is beyond me.
If I'd been able to figure out how to configure a breakpoint for whenever my DLL was entered, I'd have found it in no time.
CraigL
|
|
|
|
|
Craig Longman wrote: If I'd been able to figure out how to configure a breakpoint for whenever my DLL was entered, I'd have found it in no time.
Well, you can temporarily insert DebugBreak() into the code next time...
|
|
|
|
|
Thanks, but that actually wouldn't have helped. The point was I didn't know where the host app was calling in. So, short of adding in a call like that to every method, as well as every method of every base class, there was no solution that I could program in.
Breaking on MyDLL.dll!* is pretty much the only solution. Even the Class::* didn't work, as the parser failed to find some of the templatized based classes. Again, manually going through each and every base and adding breakpoints in would have caught them for each class that I tediously added them all in, but I was really hoping to get a better idea of when anything was called by the host app.
|
|
|
|
|
Hi
I have created BHO add ons for internet explorer. When I debug this add ons on vista IE7 then it debug correctly, but when I debug this on IE9 on windows vista , it can not be debug and no break point get invoked. So is there any setting required for this.
I also observed that BHO add ons can debug only on default browser come with windows OS. i.e win XP IE6, vista IE7 and windows 7 IE8, if user upgrade browser then BHO can not debug.
Please send me setting required for debuging.
|
|
|
|
|
Set HKCU/Software/Microsoft/Internet Explorer/Main/TabProcGrowth to 0 and check if you can debug correctly.
|
|
|
|
|
Thanks Rejeesh !!
|
|
|
|
|
I call DeviceIoControl() as below:
err = DeviceIoControl(hVolume,IOCTL_SCSI_PASS_THROUGH_DIRECT,(PVOID)sptd_sb, (DWORD)sizeof(sptd_sb),(PVOID)sptd_sb,(DWORD)sizeof(sptd_sb),dwBytesReturned,NULL);
which sptd_sb is a _SCSI_PASS_THROUGH_DIRECT_AND_SENSE_BUFFER.
in most of the DVD Rom and CD Rom it works well and it fills in sptd_sb but in some of them like ASUS CD s400/A ATA Device it doesn't and sptd_sb is empty while the return value is 1 and GetLastError is 0 in both situation.
does anybody have anyidea about it?
thanks in advance
|
|
|
|
|
Hey everybody!
Is there a way to get access rights out of a process HANDLE ?
Thanks!
|
|
|
|
|
|
Hey,
Thanks for your answer, but I can't see how it returns the Access rights of the process HANDLE (not the token's access rights).
|
|
|
|
|
CAccessToken::GetProcessToken will get the token belonging to the process handle.
You can do the same using the OpenProcessToken API.
|
|
|
|
|
Hey,
I know about Access tokens, but it is not what I want.
I want to know if the given HANDLE of process has a certain access rights. For instance, SYNCHRONIZE or PROCESS_TERMINATE.
Is it possible to do so with Access Token?
|
|
|
|
|
you may open another handle to that process using process id. Specify desired access right such as SYNCHRONIZE or PROCESS_TERMINATE in OpenProcess(). Check the return value to test whether desired right on process is granted or not
i don't know whether there is any undocumented API for enumerating process access rights
|
|
|
|
|
Yeah, that's what I thought as well...
So I guess I'll have to check the kernel mode function, and check if it is also implemented in ntdll.dll (like other functions I found).
Thanks a lot anyway!
|
|
|
|
|
Hey everybody.
I wrote (according to articles I found on the net) the following code, in order to get the command line of another process (it is not the "full code", just until it fails.
HANDLE hproc = ::OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid);
if(!hproc)
{
printf("OpenProcess() failed: 0x%x", ::GetLastError());
return _T("");
}
_NtQueryInformationProcess NtQueryInformationProcess = (_NtQueryInformationProcess)GetProcAddress(GetModuleHandleA("ntdll.dll"), "NtQueryInformationProcess");
PROCESS_BASIC_INFORMATION pbi;
DWORD size_written;
NTSTATUS nt = NtQueryInformationProcess(hproc, ProcessBasicInformation, (void*)&pbi, sizeof(PROCESS_BASIC_INFORMATION), &size_written);
if(nt)
{
printf("NtQueryInformationProcess() failed: 0x%x", nt);
return _T("");
}
PEB* peb = pbi.PebBaseAddress;
ULONG session_id = peb->SessionId;
SIZE_T read_size;
RTL_USER_PROCESS_PARAMETERS* proc_params = NULL;
DWORD old_protection;
if(!::VirtualProtectEx(hproc, peb->ProcessParameters, sizeof(RTL_USER_PROCESS_PARAMETERS*), PAGE_EXECUTE_READWRITE, &old_protection))
{
printf("VirtualProtectEx() failed: 0x%x", ::GetLastError());
return _T("");
}
if(!::ReadProcessMemory(hproc, peb->ProcessParameters, (RTL_USER_PROCESS_PARAMETERS*)proc_params, sizeof(RTL_USER_PROCESS_PARAMETERS*), &read_size))
{
printf("ReadProcessMemory() failed: 0x%x", ::GetLastError());
return _T("");
}
if(!::VirtualProtectEx(hproc, peb->ProcessParameters, sizeof(RTL_USER_PROCESS_PARAMETERS*), old_protection, NULL))
{
printf("VirtualProtectEx() failed: 0x%x", ::GetLastError());
return _T("");
}
The output is that ReadProcessMemory() fails with ERROR_PARTIAL_COPY.
The code works in XP for processes in the same session.
Currently I am trying to make it work in windows 7, for a process in the same session.
ANY IDEAS any one ????
Thanks!
|
|
|
|
|
Are you running the application with elevated privileges (Run as administrator)?
|
|
|
|
|
Yes.
|
|
|
|
|
I am testing a legacy app for use on Windows 7, both 32 and 64 bit. It presently runs on XP. For some unknown reason OLE database accesses take orders of magnitude time longer to run on Windows 7 than on XP. For this testing XP is running in a VM on the same Windows 7 64 bit machine used for Windows 7 testing, so the hardware is not the issue.
For example the following code takes 2276 ticks on Windows 7, 80 ticks on Windows XP.
startTime = GetTickCount();
CDBConnection DB;
if( DB.Open( m_DBConnectSettings ) )
{
DB.Close();
endTime = GetTickCount();
logStr.Format(_T("CDBEngine::InitializeDatabase DB.Open elapsedTime: %d ticks"), (endTime - startTime));
EventLog.LogEvent(0x04, logStr);
}
BOOL CDBConnection::Open( const CDBConnectSettings &Settings )
{
USES_CONVERSION;
return( SUCCEEDED( OpenFromInitializationString(
T2COLE((LPCTSTR)Settings) ) ) );
}
I am using:
Development Studio 2003, version 7.1.6030
Microsoft .NET 1.1 Version 1.1.4322 SP1
MSDE 2000 (SQLServer Express derives from this).
The following system dlls:
DLL
Unless otherwise noted, the DLL versions are:
Windows 7 is Product version: 6.1.7600.16385
Windows XP is Product version: 5.1.2600.5755
ADVAPI32.DLL
COMCTL32.DLL WinXP = Product version: 6.00.2900.5512
COMDLG32.DLL
GDI32.DLL WinXP = Product version: 5.1.2600.5698
MAPI32.DLL WinXP = Product version: 5.1.2600.0
MFC42.DLL Win 7 = Product version: 6.06.400, Win XP = Product version: 6.02.400
MSVCRT.DLL Win 7 = Product version: 7.0.7600.16385, WinXP = Product version: 7.0.2600.5512
OLE32.DLL WinXP = Product version: 5.1.2600.5512
OLEAUT32.DLL Win 7 = Product version: 6.1.7600.16567, WinXP = Product version: 5.1.2600.5512
RPCRT4.DLL WinXP = Product version: 5.1.2600.5795
SHELL32.DLL WinXP = Product version: 6.00.2900.6018
SHLWAPI.DLL WinXP = Product version: 6.00.2900.5912
USER32.DLL WinXP = Product version: 5.1.2600.5512
WINMM.DLL
Thanks for any thoughts, suggestions, ideas, answers, etc.
Clarence
|
|
|
|
|
Hello !
I want to develop this tool :
Customer can use the toolbar to draw his button , rectangle more and more.
the window can be move or draged ,like edit in the Visual C++ resource view.
(He can insert a new window, like Visual C++ "Insert a dialog".)
At last ,this will save as a script file.
Which knowledge is it to be need ?
|
|
|
|
|
Koma Wang wrote: Which knowledge is it to be need ?
Quite a lot. You need to be able to write a program with a GUI front end that can show menus, dialogs, bitmaps, icons, strings, version resources (and others I may have forgotten) in their natural state. The user will then want to add and remove pieces from them, move objects around, save and reload the resource, etc, etc. Assuming you are a highly skilled developer this should be less than a couple of years' work.
It's time for a new signature.
|
|
|
|
|
Richard MacCutchan wrote: Assuming you are a highly skilled developer this should be less than a couple of years' work.
|
|
|
|
|