|
The only limit is the amount of memory that can be allocated, which will depend on a) the amount of memory you have installed in your PC (as the amount of physical RAM affects the size of the page-file), and b) the other processes you have running.
On 32-bit Windows 2000 and XP, the absolute maximum limit will be something under 2GB, I guess.
|
|
|
|
|
Hello,
I've been read through various articles about DEP(Data Execution Prevention)[^] and realized that many of them implied that old ATL/WTL application may trigger DEP then be terminated due to non-DEP compliant thunking code that old version of ATL/WTL uses.
However when I wanted and tried to verify it myself by creating WTL applications based on both ATL3 and ATL71, they didn't trigger DEP nor crashed and run without any problem.
The testing systems (one AMD64 and one Intel DuoCore in WinXP SP2) were set to enable hardware DEP through control panel, and it was confirmed by running NXTEST[^].
Why can't DEP detect data ( on the stack(ATL3) or on the heap(ATL71) ) being executed without the excutable flag set in ATL/WTL application?
|
|
|
|
|
Because they allocate the thunks from memory marked as executable... dig into the source
--
Raaaaaaaaaaaaaaaaaaaaa!
|
|
|
|
|
No, they are not allocated from memory marked as executable.
If you are talking about ATL8(from VC80), yes the thunk are allocated from memory with executable flag bit set (DEP compatible thunk).
But ATL71 and prior (as I specified in my original question) do not allocate the thunk from memory marked as executable. ATL3 uses thunk from the stack memory(as a member variable) and ATL71 uses it from ::HeapAlloc() thus no excutable bit set.
And my question is why ATL/WTL applications using thunk from ATL71 or prior do not trigger DEP mechanism when hardware DEP is enabled in WinXP SP2 or WinVista?
Am I missing something here?
Regards,
Jae.
|
|
|
|
|
Yes, you are right. I was refering to ATL8. I just checked my ATL71 code, but could not see the "special alloc" as one can in ATL8.
I too would like to know why DEP won't shoot it down.
|
|
|
|
|
I got some answer from the microsoft ATL newsgroup.
Click Here.[^]
Martyn Lovell in MS replied long time ago:
"You have nothing to worry about. We worked with the Windows team to ensure
that applications based on all versions of ATL will keep running even in the
presence of the NX-supporting processors.
The way we did this might have a small perf impact, so we'll also be
ensuring that future versions of ATL do store their thunks in appropriately
marked pages; we're also considering putting this change into service packs
of V7.x releases of VS. But with or without these changes your applications
ATL-based code will keep running just fine."
~~~
By the way, I found that my custom thunk code which is identical to that from ATL3 does not trigger DEP either therefore, IMHO, I guess DEP does some sort of machine code comparison in the data being executed to avoid shooting down a code based on the thunk of ATL71 or prior.
Jae
|
|
|
|
|
Not much details (or am I blind??). The penalty hit comment smells of trapping exceptions, do code analysis, and then either allow or disallow execution.
Thanks for the information!
|
|
|
|
|
Hi all!
I want to write an ATL exe that uses the mscomm32.ocx activex for serial communication.
How to do this? specially how to call the methods of this ocx as we can do it with
mfc exe by declaring a member variable of the class CMSComm.
Thanks in advance.
Viral Joshi.
|
|
|
|
|
Hi All,
I am having a ASPX page on whose submission I open a PopUp Window for
sending mails.In the main page I have four hidden variables for
setting the MailTo Mailcc,MailSubject and MailBody fields which I am
getting in my PopUp Window by using
if((document.getElementById("hdnForPOst").value)=="1")
{
document.getElementById("txtTo").value=window.opener.document.getElementById("hdnMailTo").value;
document.getElementById("txtCC").value=window.opener.document.getElementById("hdnMailCC").value;
document.getElementById("txtMailSubject").value=window.opener.document.getElementById("hdnMailSubject").value;
document.getElementById("txtMailBody").value=window.opener.document.getElementById("hdnMailBody").value;
}
hdnForPOst is the variable set for sending mail.
This script I have pasted in a after my controls code.
The problem is that sometimes this code does't execute and I get a
blank popup Window.
I have checked by putting alerts inside script block also.These alerts
also dont execute.It happens only at times and no specific scenario.
Anybody can help please?
Dipti Arora
|
|
|
|
|
I'm using attribute ATL, and i need to forward declare an interface but i'm not sure what the correct syntax is? this is what i currently have but i'm getting a compile error. VS2005
error MIDL2025 : syntax error : expecting a type specification near "IDLArchiveFile"
[export]
__interface IDLArchiveFile;
[
object,
uuid("3E661C7F-C4C4-4EF8-94A3-4AA9FC0F9419"),
dual, helpstring("IDLArchiveDirectory Interface"),
pointer_default(unique)
]
__interface IDLArchiveDirectory : IDispatch
{
[id(6), helpstring("method GetFileAt")] HRESULT GetFileAt([in] SHORT index,[out,retval] IDLArchiveFile** pFile);
};
[
object,
uuid("08B48958-99C0-4AE1-91C9-1DD68B419A07"),
dual, helpstring("IDLArchiveFile Interface"),
pointer_default(unique)
]
__interface IDLArchiveFile : IDispatch
{
[propget, id(3), helpstring("property Parent")] HRESULT Parent([out, retval] IDLArchiveDirectory** pVal);
};
Jared Allen.
|
|
|
|
|
This is going to sound snarky, but in all honesty you shouldn't use attributed ATL. It has never worked right. If at all possible, you should rewrite it in regular ATL.
|
|
|
|
|
I have to agree with Michael. Attributed COM/ATL is one of the most stupid idea ever conceived by the VC++ team... It's inefficient at compile time (Zzzzzz), and it causes general headaches in cases such as these.
MIDL for the win!
--
Raaaaaaaaaaaaaaaaaaaaa!
|
|
|
|
|
hmmm, yeah i'm not enjoying using Attributed ATL. I only used it because I started a new project in VS 2003 and it must have been the default setting back then and so i thought "It must be better and the thing todo" so it has stuck with this particular project since then...
I'm not looking forward to rewriting it though, i figured that forward declaration was such a common thing that there would be a well known solution.
Jared Allen.
www.chironexsoftware.com
|
|
|
|
|
The idea is to create some add-on in a program using COM functions interface exist in his own API.
The particular type which I try to implement is a generic one , let say MyClass, and is declared like below:
//MyClassPtr declaration;
_COM_SMARTPTR_TYPEDEF(MyClass, __uuidof(IDispatch));
//The class itself
struct __declspec(uuid("5e772660-389b-11ce-ba48-080036250302"))
MyClass : IDispatch
{
...
// other functions...
...
IDispatchPtr Function1;
__declspec(property(get=GetArea,put=PutArea))
IDispatchPtr Function2;
__declspec(property(get=GetSize))
...
}
I create an instance of MyClass using:
MyClassPtr pMyInstance;
This pMyInsatance have to be provided to another API function but in form of a SAFEARRAY!This function can look like below:
FinalFunction(SAFEARRAY * * pMyClassInstances, .. , ..)
So I have to convert my variable MyClass (can be more than one in my code of course, but I want to limit only to one instance for now) to this SAFEARRAY .. How can I do this?
I try:
SAFEARRAYBOUND rgsabound[1];
rgsabound[0].lLbound = 0;
rgsabound[0].cElements = 1;
long a=0;
SAFEARRAY * vMyClassArray;
vMyClassArray.vt = VT_VARIANT|VT_ARRAY;
vMyClassArray= SafeArrayCreate(VT_VARIANT, 1, rgsabound);
SafeArrayPutElement(vMyClassArray .parray, &a, &(pMyInstance));
Finally I put my class instance as an argument for:
FinalFunction(pMyInstance, .. , ..)
It doesn't seem to work, probably because argument pMyInstance can not be express as a VARIANT declarated type.
The class I want to work with - MyClass- which exist in a .tlh file, is part of the API interface, so it is not exactly a user define type, but more an interface define type. I mention this becose I try to work with VT_RECORD type in SafeArrayCreate(...) instead of VT_VARIANT type, but this imply an idl function declaration for my type, and other additional stuff
Any ideea ??
|
|
|
|
|
I use a third part COM API lib. I need to pass an array of double to a method which accept VARIANT*, Is there any simple way to cast from double* to VARIANT*, I don't want to create a VARIANT array and copy each double value into it.
|
|
|
|
|
songll wrote: I don't want to create a VARIANT array and copy each double value into it.
Hmmmm - no can do. You'll need to pass a VARIANT that contains a SAFEARRAY of doubles. Something like:
SAFEARRAY* sa = SafeArrayCreateVector(VT_R8, 0, count);
double* pSAData;
if (SUCCEEDED(SafeArrayAccessData(sa, (void HUGEP**)&pSAData)))
{
std::copy(start, start+count, pSAData);
SafeArrayUnaccessData(sa);
VARIANT v;
V_VT(&v) = VT_ARRAY|VT_R8;
V_ARRAY(&v) = sa;
} should set the VARIANT , then you can pass a pointer to it.
|
|
|
|
|
Stuart Dootson wrote: HUGEP
Dude.. it's 2007!
--
Raaaaaaaaaaaaaaaaaaaaa!
|
|
|
|
|
Joergen Sigvardsson wrote: Dude.. it's 2007!
Tell that to Microsoft - it's copy'n'pasted from their documentation...
|
|
|
|
|
Just pullin' your leg..
--
Raaaaaaaaaaaaaaaaaaaaa!
|
|
|
|
|
Hi,
I am trying to fire an event from the worker thread and it worked fine as long as I worked with a VB client inside VB development environment. As I created an exe and ran, it was crashing and found that there is a KB article in Microsoft on that talking about marshalling the sink interface (http://support.microsoft.com/kb/q280512/ ). But, when I use that, I am getting a 0x80004002 error in the pDispatch->Invoke. Appreciate your help in sorting out this issue,
Thanks & Regards,
Satish
|
|
|
|
|
What have you done so far?
Have you initialized the new apartment with a call to ::CoInitialize() ?
You cannot fire events from a secondary thread without marshalling since the call crosses apartment boundaries.
You could also post a message to the main thread and fire the event from there.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Hello Satishkumar,
Not sure why you are getting your error. I've tried to use ATLCPImplMT.h entirely as advised by the MSDN article in http://support.microsoft.com/kb/q280512/[^]
and faced no problem.
If you would like to have a look at my sample codes, pls email me :
bio_lim_2004@yahoo.com
Regards,
Bio.
|
|
|
|
|
//Belows are from MSDN2003, an example about hash_set::find
// hash_map_find.cpp
// compile with: /EHsc
#define _DEFINE_DEPRECATED_HASH_CLASSES 0
#include <hash_map>
#include <iostream>
int main( )
{
using namespace std;
using namespace stdext;
hash_map <int, int=""> hm1;
hash_map <int, int=""> :: const_iterator hm1_AcIter, hm1_RcIter;
typedef pair <int, int=""> Int_Pair;
hm1.insert ( Int_Pair ( 1, 10 ) );
hm1.insert ( Int_Pair ( 2, 20 ) );
hm1.insert ( Int_Pair ( 3, 30 ) );
hm1_RcIter = hm1.find( 2 );
cout << "The element of hash_map hm1 with a key of 2 is: "
<< hm1_RcIter -> second << "." << endl;
// If no match is found for the key, end( ) is returned
hm1_RcIter = hm1.find( 4 );
if ( hm1_RcIter == hm1.end( ) )
cout << "The hash_map hm1 doesn't have an element "
<< "with a key of 4." << endl;
else
cout << "The element of hash_map hm1 with a key of 4 is: "
<< hm1_RcIter -> second << "." << endl;
// The element at a specific location in the hash_map can be found
// using a dereferenced iterator addressing the location
hm1_AcIter = hm1.end( );
hm1_AcIter--;
hm1_RcIter = hm1.find( hm1_AcIter -> first );
cout << "The element of hm1 with a key matching "
<< "that of the last element is: "
<< hm1_RcIter -> second << "." << endl;
}
Output
The element of hash_map hm1 with a key of 2 is: 20.
The hash_map hm1 doesn't have an element with a key of 4.
The element of hm1 with a key matching that of the last element is: 30
My question is: hm1_RcIter is definded as a iterator, how can it use the member function of Pair: "hm1_RcIter -> second "? what is wrong?
|
|
|
|
|
An iterator just has 2 pointers. First pointer points to the key value. Second pointer points to the value itself for that key. The member variable/function second is not a member of the pair class. It is a specific part of the iterator itself.
From what I can see, nothing is wrong with your code. What's the problem? Nothing.
|
|
|
|
|
I build my project with "Win32 Unicode Release MinSize" setting. It defines "_UNICODE", "_ATL_DLL", "_ATL_MIN_CRT". And I don't want my dll to use MFC and CRT.
now I need to format strings. I think I should prevent calling functions like "_stprintf" from using CRT. But I don't know other way to fromat strings. Can you tell me some helpful Win32 functions. Or, maybe my idea is wrong!
|
|
|
|