1--- include/atl/atlbase.h.orig	2005-04-14 17:54:32.000000000 +0900
2+++ include/atl/atlbase.h	2007-12-23 14:38:02.467500000 +0900
3@@ -10,6 +10,9 @@
4
5 #ifndef __ATLBASE_H__
6 #define __ATLBASE_H__
7+#if __GNUC__ >=3
8+#pragma GCC system_header
9+#endif
10
11 #ifndef __cplusplus
12         #error ATL requires C++ compilation (use a .cpp suffix)
13@@ -73,19 +76,47 @@
14 #define _ATL_TYPELIB_INDEX_LENGTH 10
15 #define _ATL_QUOTES_SPACE 2
16
17-#pragma pack(push, _ATL_PACKING)
18+#pragma pack(push, 8)
19
20 #if defined(_ATL_DLL)
21         #pragma comment(lib, "atl.lib")
22 #endif
23
24-extern "C" const __declspec(selectany) GUID LIBID_ATLLib = {0x44EC0535,0x400F,0x11D0,{0x9D,0xCD,0x00,0xA0,0xC9,0x03,0x91,0xD3}};
25-extern "C" const __declspec(selectany) CLSID CLSID_Registrar = {0x44EC053A,0x400F,0x11D0,{0x9D,0xCD,0x00,0xA0,0xC9,0x03,0x91,0xD3}};
26-extern "C" const __declspec(selectany) IID IID_IRegistrar = {0x44EC053B,0x400F,0x11D0,{0x9D,0xCD,0x00,0xA0,0xC9,0x03,0x91,0xD3}};
27-extern "C" const __declspec(selectany) IID IID_IAxWinHostWindow = {0xb6ea2050,0x48a,0x11d1,{0x82,0xb9,0x0,0xc0,0x4f,0xb9,0x94,0x2e}};
28-extern "C" const __declspec(selectany) IID IID_IAxWinAmbientDispatch = {0xb6ea2051,0x48a,0x11d1,{0x82,0xb9,0x0,0xc0,0x4f,0xb9,0x94,0x2e}};
29-extern "C" const __declspec(selectany) IID IID_IInternalConnection = {0x72AD0770,0x6A9F,0x11d1,{0xBC,0xEC,0x00,0x60,0x08,0x8F,0x44,0x4E}};
30-extern "C" const __declspec(selectany) IID IID_IDocHostUIHandlerDispatch = {0x425B5AF0,0x65F1,0x11d1,{0x96,0x11,0x00,0x00,0xF8,0x1E,0x0D,0x0D}};
31+#define __uuidof(I) IID_##I
32+
33+#include <excpt.h>
34+
35+namespace ATL
36+{
37+inline int InlineIsEqualGUID(REFGUID rguid1, REFGUID rguid2)
38+{
39+   return (
40+      ((unsigned long *) &rguid1)[0] == ((unsigned long *) &rguid2)[0] &&
41+      ((unsigned long *) &rguid1)[1] == ((unsigned long *) &rguid2)[1] &&
42+      ((unsigned long *) &rguid1)[2] == ((unsigned long *) &rguid2)[2] &&
43+      ((unsigned long *) &rguid1)[3] == ((unsigned long *) &rguid2)[3]);
44+}
45+}
46+
47+#ifdef _INIT_ATL_COMMON_VARS
48+extern "C" const GUID LIBID_ATLLib = {0x44EC0535,0x400F,0x11D0,{0x9D,0xCD,0x00,0xA0,0xC9,0x03,0x91,0xD3}};
49+extern "C" const CLSID CLSID_Registrar = {0x44EC053A,0x400F,0x11D0,{0x9D,0xCD,0x00,0xA0,0xC9,0x03,0x91,0xD3}};
50+extern "C" const IID IID_IRegistrar = {0x44EC053B,0x400F,0x11D0,{0x9D,0xCD,0x00,0xA0,0xC9,0x03,0x91,0xD3}};
51+extern "C" const IID IID_IAxWinHostWindow = {0xb6ea2050,0x48a,0x11d1,{0x82,0xb9,0x0,0xc0,0x4f,0xb9,0x94,0x2e}};
52+extern "C" const IID IID_IAxWinAmbientDispatch = {0xb6ea2051,0x48a,0x11d1,{0x82,0xb9,0x0,0xc0,0x4f,0xb9,0x94,0x2e}};
53+extern "C" const IID IID_IInternalConnection = {0x72AD0770,0x6A9F,0x11d1,{0xBC,0xEC,0x00,0x60,0x08,0x8F,0x44,0x4E}};
54+extern "C" const IID IID_IDocHostUIHandlerDispatch = {0x425B5AF0,0x65F1,0x11d1,{0x96,0x11,0x00,0x00,0xF8,0x1E,0x0D,0x0D}};
55+#else
56+extern "C" {
57+extern const GUID LIBID_ATLLib;
58+extern const CLSID CLSID_Registrar;
59+extern const IID IID_IRegistrar;
60+extern const IID IID_IAxWinHostWindow;
61+extern const IID IID_IAxWinAmbientDispatch;
62+extern const IID IID_IInternalConnection;
63+extern const IID IID_IDocHostUIHandlerDispatch;
64+}
65+#endif
66
67 #ifndef _ATL_DLL_IMPL
68 namespace ATL
69@@ -135,7 +166,7 @@
70                 IUnknown* p = NULL;
71                 if (pfnGetClassObject == NULL)
72                         return S_OK;
73-                HRESULT hRes = pfnGetClassObject(pfnCreateInstance, IID_IUnknown, (LPVOID*) &p);
74+                HRESULT hRes = pfnGetClassObject((LPVOID)pfnCreateInstance, IID_IUnknown, (LPVOID*) &p);
75                 if (SUCCEEDED(hRes))
76                         hRes = CoRegisterClassObject(*pclsid, p, dwClsContext, dwFlags, &dwRegister);
77                 if (p != NULL)
78@@ -284,13 +315,15 @@
79 };
80 #pragma pack(pop)
81
82-PVOID __stdcall __AllocStdCallThunk(VOID);
83-VOID  __stdcall __FreeStdCallThunk(PVOID);
84+//PVOID __stdcall __AllocStdCallThunk(VOID);
85+//VOID  __stdcall __FreeStdCallThunk(PVOID);
86
87-#define AllocStdCallThunk() __AllocStdCallThunk()
88-#define FreeStdCallThunk(p) __FreeStdCallThunk(p)
89+//#define AllocStdCallThunk() __AllocStdCallThunk()
90+//#define FreeStdCallThunk(p) __FreeStdCallThunk(p)
91
92-#pragma comment(lib, "atlthunk.lib")
93+//#pragma comment(lib, "atlthunk.lib")
94+#define AllocStdCallThunk() HeapAlloc(GetProcessHeap(),0,sizeof(_stdcallthunk))
95+#define FreeStdCallThunk(p) HeapFree(GetProcessHeap(), 0, p)
96
97 #elif defined (_M_AMD64)
98 #pragma pack(push,2)
99@@ -465,7 +498,7 @@
100         return( HRESULT_FROM_WIN32( nError ) );
101 }
102
103-inline void __declspec(noreturn) _AtlRaiseException( DWORD dwExceptionCode, DWORD dwExceptionFlags = EXCEPTION_NONCONTINUABLE )
104+inline void _AtlRaiseException( DWORD dwExceptionCode, DWORD dwExceptionFlags = EXCEPTION_NONCONTINUABLE )
105 {
106         RaiseException( dwExceptionCode, dwExceptionFlags, 0, NULL );
107 }
108@@ -658,6 +691,7 @@
109 class _NoAddRefReleaseOnCComPtr : public T
110 {
111         private:
112+                _NoAddRefReleaseOnCComPtr();
113                 STDMETHOD_(ULONG, AddRef)()=0;
114                 STDMETHOD_(ULONG, Release)()=0;
115 };
116@@ -781,6 +815,7 @@
117         {
118                 return AtlAdvise(p, pUnk, iid, pdw);
119         }
120+#if 0
121         HRESULT CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter = NULL, DWORD dwClsContext = CLSCTX_ALL)
122         {
123                 ATLASSERT(p == NULL);
124@@ -801,11 +836,12 @@
125                 ATLASSERT(pp != NULL && *pp == NULL);
126                 return p->QueryInterface(__uuidof(Q), (void**)pp);
127         }
128+#endif
129         T* p;
130 };
131
132
133-template <class T, const IID* piid = &__uuidof(T)>
134+template <class T, const IID* piid>
135 class CComQIPtr
136 {
137 public:
138@@ -933,6 +969,7 @@
139         {
140                 return AtlAdvise(p, pUnk, iid, pdw);
141         }
142+#if 0
143         HRESULT CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter = NULL, DWORD dwClsContext = CLSCTX_ALL)
144         {
145                 ATLASSERT(p == NULL);
146@@ -953,6 +990,7 @@
147                 ATLASSERT(pp != NULL && *pp == NULL);
148                 return p->QueryInterface(__uuidof(Q), (void**)pp);
149         }
150+#endif
151         T* p;
152 };
153
154@@ -1087,12 +1125,14 @@
155                         hr = ::CoCreateInstance(clsid, pUnkOuter, dwClsContext, __uuidof(IUnknown), (void**)&p);
156                 return hr;
157         }
158+#if 0
159         template <class Q>
160         HRESULT QueryInterface(Q** pp)
161         {
162                 ATLASSERT(pp != NULL && *pp == NULL);
163                 return p->QueryInterface(__uuidof(Q), (void**)pp);
164         }
165+#endif
166         IUnknown* p;
167 };
168
169@@ -1257,21 +1297,26 @@
170 		LeaveCriticalSection(&m_sec);
171 		return S_OK;
172 	}
173+	static void _InitHandler(void *pData, LPEXCEPTION_POINTERS ep)
174+	  {
175+	    HRESULT &hRes=*reinterpret_cast<HRESULT*>(pData);
176+			if (STATUS_NO_MEMORY == ep->ExceptionRecord->ExceptionCode)
177+				hRes = E_OUTOFMEMORY;
178+			else
179+				hRes = E_FAIL;
180+	  }
181 	HRESULT Init() throw()
182 	{
183 		HRESULT hRes = S_OK;
184-		__try
185-		{
186+                jmp_buf _sejmpbuf;
187+                __SEHandler _sehandler;
188+                if (__builtin_setjmp(_sejmpbuf) == 0)
189+                {
190+                        _sehandler.Set(_sejmpbuf, &hRes, reinterpret_cast<__SEHandler::PF>(EXCEPTION_EXECUTE_HANDLER), _InitHandler);
191 			InitializeCriticalSection(&m_sec);
192-		}
193+                }
194 		// structured exception may be raised in low memory situations
195-		__except(EXCEPTION_EXECUTE_HANDLER)
196-		{
197-			if (STATUS_NO_MEMORY == GetExceptionCode())
198-				hRes = E_OUTOFMEMORY;
199-			else
200-				hRes = E_FAIL;
201-		}
202+                _sehandler.Reset();
203 		return hRes;
204 	}
205
206@@ -2799,10 +2844,19 @@
207
208
209 class CComModule;
210-__declspec(selectany) CComModule* _pModule=NULL;
211+#ifdef _INIT_ATL_COMMON_VARS
212+CComModule* _pModule=NULL;
213+#else
214+extern CComModule* _pModule;
215+#endif
216+
217
218 // {B62F5910-6528-11d1-9611-0000F81E0D0D}
219-_declspec(selectany) GUID GUID_ATLVer30 = { 0xb62f5910, 0x6528, 0x11d1, { 0x96, 0x11, 0x0, 0x0, 0xf8, 0x1e, 0xd, 0xd } };
220+#ifdef _INIT_ATL_COMMON_VARS
221+GUID GUID_ATLVer30 = { 0xb62f5910, 0x6528, 0x11d1, { 0x96, 0x11, 0x0, 0x0, 0xf8, 0x1e, 0xd, 0xd } };
222+#else
223+extern GUID GUID_ATLVer30;
224+#endif
225
226 class CComModule : public _ATL_MODULE
227 {
228@@ -4286,7 +4340,9 @@
229
230 #endif
231
232-__declspec(selectany) GUID CComModule::m_libid = {0x0,0x0,0x0,{0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0}};
233+#ifdef _INIT_ATL_COMMON_VARS
234+GUID CComModule::m_libid = {0x0,0x0,0x0,{0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0}};
235+#endif
236
237 #ifdef _ATL_STATIC_REGISTRY
238 #define UpdateRegistryFromResource UpdateRegistryFromResourceS
239@@ -4355,7 +4411,9 @@
240         LONG m_nLockCnt;
241 };
242
243-__declspec(selectany) UINT CComApartment::ATL_CREATE_OBJECT = 0;
244+#ifdef _INIT_ATL_COMMON_VARS
245+UINT CComApartment::ATL_CREATE_OBJECT = 0;
246+#endif
247
248 class CComSimpleThreadAllocator
249 {
250@@ -5855,6 +5913,10 @@
251                 }
252
253         }
254+        static int _Except(void *pThis, LPEXCEPTION_POINTERS lpEP)
255+        {
256+	  return reinterpret_cast<CVirtualBuffer *>(pThis)->Except(lpEP);
257+	}
258         void Seek(int nElement)
259         {
260                 if(nElement < 0 || nElement >= m_nMaxElements)
261@@ -5866,41 +5928,53 @@
262         {
263                 if(nElement < 0 || nElement >= m_nMaxElements)
264                         _AtlRaiseException((DWORD)EXCEPTION_ARRAY_BOUNDS_EXCEEDED);
265-                __try
266+                jmp_buf _sejmpbuf;
267+                __SEHandler _sehandler;
268+                if (__builtin_setjmp(_sejmpbuf) == 0)
269                 {
270+                        _sehandler.Set(_sejmpbuf, this, _Except);
271                         T* p = &m_pBase[nElement];
272                         *p = Element;
273                         m_pTop = p > m_pTop ? p : m_pTop;
274                 }
275-                __except(Except(GetExceptionInformation()))
276+                else
277                 {
278                 }
279+                _sehandler.Reset();
280
281         }
282         template <class Q>
283         void WriteBulk(Q& helper)
284         {
285-                __try
286+                jmp_buf _sejmpbuf;
287+                __SEHandler _sehandler;
288+                if (__builtin_setjmp(_sejmpbuf) == 0)
289                 {
290+                        _sehandler.Set(_sejmpbuf, this, _Except);
291                         m_pCurrent = helper(m_pBase);
292                         m_pTop = m_pCurrent > m_pTop ? m_pCurrent : m_pTop;
293                 }
294-                __except(Except(GetExceptionInformation()))
295+                else
296                 {
297                 }
298+                _sehandler.Reset();
299         }
300         void Write(const T& Element)
301         {
302             if (m_pCurrent < &m_pBase[m_nMaxElements]) {
303-                __try
304+                jmp_buf _sejmpbuf;
305+                __SEHandler _sehandler;
306+                if (__builtin_setjmp(_sejmpbuf) == 0)
307                 {
308+                    _sehandler.Set(_sejmpbuf, this, _Except);
309                     *m_pCurrent = Element;
310                     m_pCurrent++;
311                     m_pTop = m_pCurrent > m_pTop ? m_pCurrent : m_pTop;
312                 }
313-                __except(Except(GetExceptionInformation()))
314+                else
315                 {
316                 }
317+                _sehandler.Reset();
318             }
319         }
320         T& Read()
321@@ -5910,14 +5984,18 @@
322         operator BSTR()
323         {
324                 BSTR bstrTemp = NULL ;
325-                __try
326+                jmp_buf _sejmpbuf;
327+                __SEHandler _sehandler;
328+                if (__builtin_setjmp(_sejmpbuf) == 0)
329                 {
330+                        _sehandler.Set(_sejmpbuf, this, _Except);
331                         bstrTemp = SysAllocStringByteLen((char*) m_pBase,
332                                 (UINT) ((BYTE*)m_pTop - (BYTE*)m_pBase));
333                 }
334-                __except(Except(GetExceptionInformation()))
335+                else
336                 {
337                 }
338+                _sehandler.Reset();
339                 return bstrTemp;
340         }
341         const T& operator[](int nElement) const
342@@ -6336,6 +6414,11 @@
343 //Although these functions are big, they are only used once in a module
344 //so we should make them inline.
345
346+ATLINLINE int atlmoduleinitfilter(void *, LPEXCEPTION_POINTERS ep)
347+{
348+  return ep->ExceptionRecord->ExceptionCode == STATUS_NO_MEMORY ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH;
349+}
350+
351 ATLINLINE ATLAPI AtlModuleInit(_ATL_MODULE* pM, _ATL_OBJMAP_ENTRY* p, HINSTANCE h)
352 {
353         ATLASSERT(pM != NULL);
354@@ -6352,32 +6435,43 @@
355         pM->m_hInst = pM->m_hInstTypeLib = pM->m_hInstResource = h;
356         pM->m_nLockCnt=0L;
357         pM->m_hHeap = NULL;
358-        __try {
359+        jmp_buf _sejmpbuf;
360+        __SEHandler _sehandler;
361+        if (__builtin_setjmp(_sejmpbuf) == 0) {
362+            _sehandler.Set(_sejmpbuf, NULL, atlmoduleinitfilter);
363             InitializeCriticalSection(&pM->m_csTypeInfoHolder);
364-        } __except (GetExceptionCode() == STATUS_NO_MEMORY ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) {
365+        } else {
366             ZeroMemory(&pM->m_csTypeInfoHolder, sizeof(pM->m_csTypeInfoHolder));
367-            return STATUS_NO_MEMORY;
368+            _sehandler.Reset();
369+	    return STATUS_NO_MEMORY;
370         }
371+        _sehandler.Reset();
372
373-        __try {
374+        if (__builtin_setjmp(_sejmpbuf) == 0) {
375+            _sehandler.Set(_sejmpbuf, NULL, atlmoduleinitfilter);
376             InitializeCriticalSection(&pM->m_csWindowCreate);
377-        } __except (GetExceptionCode() == STATUS_NO_MEMORY ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) {
378+        } else {
379             DeleteCriticalSection(&pM->m_csTypeInfoHolder);
380             ZeroMemory(&pM->m_csWindowCreate, sizeof(pM->m_csWindowCreate));
381             ZeroMemory(&pM->m_csTypeInfoHolder, sizeof(pM->m_csTypeInfoHolder));
382+            _sehandler.Reset();
383             return STATUS_NO_MEMORY;
384         }
385+        _sehandler.Reset();
386
387-        __try {
388+        if (__builtin_setjmp(_sejmpbuf) == 0) {
389+            _sehandler.Set(_sejmpbuf, NULL, atlmoduleinitfilter);
390             InitializeCriticalSection(&pM->m_csObjMap);
391-        } __except (GetExceptionCode() == STATUS_NO_MEMORY ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) {
392+        } else {
393             DeleteCriticalSection(&pM->m_csWindowCreate);
394             DeleteCriticalSection(&pM->m_csTypeInfoHolder);
395             ZeroMemory(&pM->m_csObjMap, sizeof(pM->m_csObjMap));
396             ZeroMemory(&pM->m_csWindowCreate, sizeof(pM->m_csWindowCreate));
397             ZeroMemory(&pM->m_csTypeInfoHolder, sizeof(pM->m_csTypeInfoHolder));
398+            _sehandler.Reset();
399             return STATUS_NO_MEMORY;
400         }
401+        _sehandler.Reset();
402 #ifdef _ATL_DLL_IMPL
403         if (pM->cbSize > _nAtlModuleVer21Size)
404 #endif
405@@ -6450,6 +6544,11 @@
406         return hRes;
407 }
408
409+ATLINLINE void atlfinalleavecriticalsection(void *pData)
410+{
411+  LeaveCriticalSection(reinterpret_cast<LPCRITICAL_SECTION>(pData));
412+}
413+
414 ATLINLINE ATLAPI AtlModuleGetClassObject(_ATL_MODULE* pM, REFCLSID rclsid, REFIID riid, LPVOID* ppv)
415 {
416         ATLASSERT(pM != NULL);
417@@ -6473,15 +6572,15 @@
418                         if (pEntry->pCF == NULL)
419                         {
420                                 EnterCriticalSection(&pM->m_csObjMap);
421-                                __try
422+                                jmp_buf _sejmpbuf;
423+                                __SEHandler _sehandler;
424+                                if (__builtin_setjmp(_sejmpbuf) == 0)
425                                 {
426+                                        _sehandler.Set(_sejmpbuf, &pM->m_csObjMap, EXCEPTION_CONTINUE_SEARCH, NULL, atlfinalleavecriticalsection);
427                                         if (pEntry->pCF == NULL)
428-                                                hRes = pEntry->pfnGetClassObject(pEntry->pfnCreateInstance, IID_IUnknown, (LPVOID*)&pEntry->pCF);
429-                                }
430-                                __finally
431-                                {
432-                                        LeaveCriticalSection(&pM->m_csObjMap);
433+						hRes = pEntry->pfnGetClassObject((void *)(pEntry->pfnCreateInstance), IID_IUnknown, (LPVOID*)&pEntry->pCF);
434                                 }
435+                                _sehandler.Reset();
436                         }
437                         if (pEntry->pCF != NULL)
438                                 hRes = pEntry->pCF->QueryInterface(riid, ppv);
439--- include/atl/atlcom.h.orig	2005-04-14 17:54:32.000000000 +0900
440+++ include/atl/atlcom.h	2007-12-03 22:43:54.833375000 +0900
441@@ -10,6 +10,9 @@
442
443 #ifndef __ATLCOM_H__
444 #define __ATLCOM_H__
445+#if __GNUC__ >=3
446+#pragma GCC system_header
447+#endif
448
449 #ifndef __cplusplus
450         #error ATL requires C++ compilation (use a .cpp suffix)
451@@ -19,7 +22,10 @@
452         #error atlcom.h requires atlbase.h to be included first
453 #endif
454
455-#pragma pack(push, _ATL_PACKING)
456+#include <algorithm>
457+using ::std::min;
458+
459+#pragma pack(push, 8)
460
461 EXTERN_C const IID IID_ITargetFrame;
462
463@@ -2191,19 +2197,23 @@
464 // override it in your class and call each base class' version of this
465 #define BEGIN_COM_MAP(x) public: \
466         typedef x _ComMapClass; \
467+        static void _CacheFinal(void *pData)\
468+        {\
469+                reinterpret_cast<_ComMapClass*>(pData)->Unlock();\
470+        }\
471         static HRESULT WINAPI _Cache(void* pv, REFIID iid, void** ppvObject, DWORD_PTR dw)\
472         {\
473                 _ComMapClass* p = (_ComMapClass*)pv;\
474                 p->Lock();\
475                 HRESULT hRes = E_FAIL; \
476-                __try \
477+                jmp_buf _sejmpbuf; \
478+                __SEHandler _sehandler; \
479+                if (__builtin_setjmp(_sejmpbuf) == 0) \
480                 { \
481+                        _sehandler.Set(_sejmpbuf, p, EXCEPTION_CONTINUE_SEARCH, NULL, _CacheFinal);\
482                         hRes = CComObjectRootBase::_Cache(pv, iid, ppvObject, dw);\
483                 } \
484-                __finally \
485-                { \
486-                        p->Unlock();\
487-                } \
488+                _sehandler.Reset();\
489                 return hRes;\
490         }\
491         IUnknown* _GetRawUnknown() \
492@@ -2339,7 +2349,7 @@
493    return( pMap ); }
494
495 #define BEGIN_OBJECT_MAP(x) static _ATL_OBJMAP_ENTRY x[] = {
496-#define END_OBJECT_MAP()   {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}};
497+#define END_OBJECT_MAP()   {NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL}};
498 #define OBJECT_ENTRY(clsid, class) {&clsid, class::UpdateRegistry, class::_ClassFactoryCreatorClass::CreateInstance, class::_CreatorClass::CreateInstance, NULL, 0, class::GetObjectDescription, class::GetCategoryMap, class::ObjectMain },
499 #define OBJECT_ENTRY_NON_CREATEABLE(class) {&CLSID_NULL, class::UpdateRegistry, NULL, NULL, NULL, 0, NULL, class::GetCategoryMap, class::ObjectMain },
500
501@@ -2492,9 +2502,9 @@
502 public:
503         typedef ThreadModel _ThreadModel;
504 #ifdef OLD_ATL_CRITSEC_CODE
505-        typename typedef _ThreadModel::AutoCriticalSection _CritSec;
506+        typedef typename _ThreadModel::AutoCriticalSection _CritSec;
507 #else
508-    	typename typedef _ThreadModel::AutoDeleteCriticalSection _AutoDelCritSec;
509+    	typedef typename _ThreadModel::AutoDeleteCriticalSection _AutoDelCritSec;
510 #endif  /* OLD_ATL_CRITSEC_CODE */
511         typedef CComObjectLockT<_ThreadModel> ObjectLock;
512
513@@ -2638,8 +2648,8 @@
514         // Set refcount to 1 to protect destruction
515         ~CComObject()
516         {
517-                m_dwRef = 1L;
518-                FinalRelease();
519+                this->m_dwRef = 1L;
520+                this->FinalRelease();
521 #ifdef _ATL_DEBUG_INTERFACES
522                 _Module.DeleteNonAddRefThunk(_GetRawUnknown());
523 #endif
524@@ -2647,22 +2657,24 @@
525         }
526         //If InternalAddRef or InternalRelease is undefined then your class
527         //doesn't derive from CComObjectRoot
528-        STDMETHOD_(ULONG, AddRef)() {return InternalAddRef();}
529+        STDMETHOD_(ULONG, AddRef)() {return this->InternalAddRef();}
530         STDMETHOD_(ULONG, Release)()
531         {
532-                ULONG l = InternalRelease();
533+                ULONG l = this->InternalRelease();
534                 if (l == 0)
535                         delete this;
536                 return l;
537         }
538         //if _InternalQueryInterface is undefined then you forgot BEGIN_COM_MAP
539         STDMETHOD(QueryInterface)(REFIID iid, void ** ppvObject)
540-        {return _InternalQueryInterface(iid, ppvObject);}
541+        {return this->_InternalQueryInterface(iid, ppvObject);}
542+#if 0
543         template <class Q>
544         HRESULT STDMETHODCALLTYPE QueryInterface(Q** pp)
545         {
546                 return QueryInterface(__uuidof(Q), (void**)pp);
547         }
548+#endif
549
550         static HRESULT WINAPI CreateInstance(CComObject<Base>** pp);
551 };
552@@ -2719,8 +2731,8 @@
553 #endif  /* OLD_ATL_CRITSEC_CODE */
554         ~CComObjectCached()
555         {
556-                m_dwRef = 1L;
557-                FinalRelease();
558+                this->m_dwRef = 1L;
559+                this->FinalRelease();
560 #ifdef _ATL_DEBUG_INTERFACES
561                 _Module.DeleteNonAddRefThunk(_GetRawUnknown());
562 #endif
563@@ -2729,14 +2741,14 @@
564         //doesn't derive from CComObjectRoot
565         STDMETHOD_(ULONG, AddRef)()
566         {
567-                ULONG l = InternalAddRef();
568+                ULONG l = this->InternalAddRef();
569                 if (l == 2)
570                         _Module.Lock();
571                 return l;
572         }
573         STDMETHOD_(ULONG, Release)()
574         {
575-                ULONG l = InternalRelease();
576+                ULONG l = this->InternalRelease();
577                 if (l == 0)
578                         delete this;
579                 else if (l == 1)
580@@ -2745,7 +2757,7 @@
581         }
582         //if _InternalQueryInterface is undefined then you forgot BEGIN_COM_MAP
583         STDMETHOD(QueryInterface)(REFIID iid, void ** ppvObject)
584-        {return _InternalQueryInterface(iid, ppvObject);}
585+        {return this->_InternalQueryInterface(iid, ppvObject);}
586 #ifndef OLD_ATL_CRITSEC_CODE
587     	CComGlobalsThreadModel::AutoDeleteCriticalSection m_csCached;
588 #endif  /* OLD_ATL_CRITSEC_CODE */
589@@ -2762,8 +2774,8 @@
590         // Set refcount to 1 to protect destruction
591         ~CComObjectNoLock()
592         {
593-                m_dwRef = 1L;
594-                FinalRelease();
595+                this->m_dwRef = 1L;
596+                this->FinalRelease();
597 #ifdef _ATL_DEBUG_INTERFACES
598                 _Module.DeleteNonAddRefThunk(_GetRawUnknown());
599 #endif
600@@ -2771,17 +2783,17 @@
601
602         //If InternalAddRef or InternalRelease is undefined then your class
603         //doesn't derive from CComObjectRoot
604-        STDMETHOD_(ULONG, AddRef)() {return InternalAddRef();}
605+        STDMETHOD_(ULONG, AddRef)() {return this->InternalAddRef();}
606         STDMETHOD_(ULONG, Release)()
607         {
608-                ULONG l = InternalRelease();
609+                ULONG l = this->InternalRelease();
610                 if (l == 0)
611                         delete this;
612                 return l;
613         }
614         //if _InternalQueryInterface is undefined then you forgot BEGIN_COM_MAP
615         STDMETHOD(QueryInterface)(REFIID iid, void ** ppvObject)
616-        {return _InternalQueryInterface(iid, ppvObject);}
617+        {return this->_InternalQueryInterface(iid, ppvObject);}
618 };
619
620 // It is possible for Base not to derive from CComObjectRoot
621@@ -2794,14 +2806,14 @@
622         CComObjectGlobal(void* = NULL)
623         {
624 #ifndef OLD_ATL_CRITSEC_CODE
625-			m_hResFinalConstruct = _AtlInitialConstruct();
626+			m_hResFinalConstruct = this->_AtlInitialConstruct();
627 			if (SUCCEEDED(m_hResFinalConstruct))
628 #endif  /* OLD_ATL_CRITSEC_CODE */
629-                m_hResFinalConstruct = FinalConstruct();
630+                m_hResFinalConstruct = this->FinalConstruct();
631         }
632         ~CComObjectGlobal()
633         {
634-                FinalRelease();
635+                this->FinalRelease();
636 #ifdef _ATL_DEBUG_INTERFACES
637                 _Module.DeleteNonAddRefThunk(_GetRawUnknown());
638 #endif
639@@ -2810,7 +2822,7 @@
640         STDMETHOD_(ULONG, AddRef)() {return _Module.Lock();}
641         STDMETHOD_(ULONG, Release)(){return _Module.Unlock();}
642         STDMETHOD(QueryInterface)(REFIID iid, void ** ppvObject)
643-        {return _InternalQueryInterface(iid, ppvObject);}
644+        {return this->_InternalQueryInterface(iid, ppvObject);}
645         HRESULT m_hResFinalConstruct;
646 };
647
648@@ -2824,14 +2836,14 @@
649         CComObjectStack(void* = NULL)
650         {
651 #ifndef OLD_ATL_CRITSEC_CODE
652-			m_hResFinalConstruct = _AtlInitialConstruct();
653+			m_hResFinalConstruct = this->_AtlInitialConstruct();
654 			if (SUCCEEDED(m_hResFinalConstruct))
655 #endif  /* OLD_ATL_CRITSEC_CODE */
656-                m_hResFinalConstruct = FinalConstruct();
657+                m_hResFinalConstruct = this->FinalConstruct();
658         }
659         ~CComObjectStack()
660         {
661-                FinalRelease();
662+                this->FinalRelease();
663 #ifdef _ATL_DEBUG_INTERFACES
664                 _Module.DeleteNonAddRefThunk(_GetRawUnknown());
665 #endif
666@@ -2850,6 +2862,8 @@
667 {
668 public:
669         typedef Base _BaseClass;
670+        using Base::_GetRawUnknown;
671+        using Base::m_pOuterUnknown;
672         CComContainedObject(void* pv) {m_pOuterUnknown = (IUnknown*)pv;}
673 #ifdef _ATL_DEBUG_INTERFACES
674         ~CComContainedObject()
675@@ -2859,20 +2873,22 @@
676         }
677 #endif
678
679-        STDMETHOD_(ULONG, AddRef)() {return OuterAddRef();}
680-        STDMETHOD_(ULONG, Release)() {return OuterRelease();}
681+        STDMETHOD_(ULONG, AddRef)() {return this->OuterAddRef();}
682+        STDMETHOD_(ULONG, Release)() {return this->OuterRelease();}
683         STDMETHOD(QueryInterface)(REFIID iid, void ** ppvObject)
684         {
685-                HRESULT hr = OuterQueryInterface(iid, ppvObject);
686+                HRESULT hr = this->OuterQueryInterface(iid, ppvObject);
687                 if (FAILED(hr) && _GetRawUnknown() != m_pOuterUnknown)
688-                        hr = _InternalQueryInterface(iid, ppvObject);
689+                        hr = this->_InternalQueryInterface(iid, ppvObject);
690                 return hr;
691         }
692+#if 0
693         template <class Q>
694         HRESULT STDMETHODCALLTYPE QueryInterface(Q** pp)
695         {
696                 return QueryInterface(__uuidof(Q), (void**)pp);
697         }
698+#endif
699         //GetControllingUnknown may be virtual if the Base class has declared
700         //DECLARE_GET_CONTROLLING_UNKNOWN()
701         IUnknown* GetControllingUnknown()
702@@ -2915,18 +2931,18 @@
703         // override it in your class and call each base class' version of this
704         HRESULT FinalConstruct()
705         {
706-                CComObjectRootEx<contained::_ThreadModel::ThreadModelNoCS>::FinalConstruct();
707+                CComObjectRootEx<typename contained::_ThreadModel::ThreadModelNoCS>::FinalConstruct();
708                 return m_contained.FinalConstruct();
709         }
710         void FinalRelease()
711         {
712-                CComObjectRootEx<contained::_ThreadModel::ThreadModelNoCS>::FinalRelease();
713+                CComObjectRootEx<typename contained::_ThreadModel::ThreadModelNoCS>::FinalRelease();
714                 m_contained.FinalRelease();
715         }
716         // Set refcount to 1 to protect destruction
717         ~CComAggObject()
718         {
719-                m_dwRef = 1L;
720+                this->m_dwRef = 1L;
721                 FinalRelease();
722 #ifdef _ATL_DEBUG_INTERFACES
723                 _Module.DeleteNonAddRefThunk(this);
724@@ -2934,10 +2950,10 @@
725                 _Module.Unlock();
726         }
727
728-        STDMETHOD_(ULONG, AddRef)() {return InternalAddRef();}
729+        STDMETHOD_(ULONG, AddRef)() {return this->InternalAddRef();}
730         STDMETHOD_(ULONG, Release)()
731         {
732-                ULONG l = InternalRelease();
733+                ULONG l = this->InternalRelease();
734                 if (l == 0)
735                         delete this;
736                 return l;
737@@ -2959,11 +2975,13 @@
738                         hRes = m_contained._InternalQueryInterface(iid, ppvObject);
739                 return hRes;
740         }
741+#if 0
742         template <class Q>
743         HRESULT STDMETHODCALLTYPE QueryInterface(Q** pp)
744         {
745                 return QueryInterface(__uuidof(Q), (void**)pp);
746         }
747+#endif
748         static HRESULT WINAPI CreateInstance(LPUNKNOWN pUnkOuter, CComAggObject<contained>** pp)
749         {
750                 _ATL_VALIDATE_OUT_POINTER(pp);
751@@ -3023,21 +3041,21 @@
752         // override it in your class and call each base class' version of this
753         HRESULT FinalConstruct()
754         {
755-                InternalAddRef();
756-                CComObjectRootEx<contained::_ThreadModel::ThreadModelNoCS>::FinalConstruct();
757+                this->InternalAddRef();
758+                CComObjectRootEx<typename contained::_ThreadModel::ThreadModelNoCS>::FinalConstruct();
759                 HRESULT hr = m_contained.FinalConstruct();
760-                InternalRelease();
761+                this->InternalRelease();
762                 return hr;
763         }
764         void FinalRelease()
765         {
766-                CComObjectRootEx<contained::_ThreadModel::ThreadModelNoCS>::FinalRelease();
767+                CComObjectRootEx<typename contained::_ThreadModel::ThreadModelNoCS>::FinalRelease();
768                 m_contained.FinalRelease();
769         }
770         // Set refcount to 1 to protect destruction
771         ~CComPolyObject()
772         {
773-                m_dwRef = 1L;
774+                this->m_dwRef = 1L;
775                 FinalRelease();
776 #ifdef _ATL_DEBUG_INTERFACES
777                 _Module.DeleteNonAddRefThunk(this);
778@@ -3045,10 +3063,10 @@
779                 _Module.Unlock();
780         }
781
782-        STDMETHOD_(ULONG, AddRef)() {return InternalAddRef();}
783+        STDMETHOD_(ULONG, AddRef)() {return this->InternalAddRef();}
784         STDMETHOD_(ULONG, Release)()
785         {
786-                ULONG l = InternalRelease();
787+                ULONG l = this->InternalRelease();
788                 if (l == 0)
789                         delete this;
790                 return l;
791@@ -3072,11 +3090,13 @@
792                         hRes = m_contained._InternalQueryInterface(iid, ppvObject);
793                 return hRes;
794         }
795+#if 0
796         template <class Q>
797         HRESULT STDMETHODCALLTYPE QueryInterface(Q** pp)
798         {
799                 return QueryInterface(__uuidof(Q), (void**)pp);
800         }
801+#endif
802         static HRESULT WINAPI CreateInstance(LPUNKNOWN pUnkOuter, CComPolyObject<contained>** pp)
803         {
804                 _ATL_VALIDATE_OUT_POINTER(pp);
805@@ -3111,27 +3131,28 @@
806 class CComTearOffObject : public Base
807 {
808 public:
809+        using Base::m_pOwner;
810         CComTearOffObject(void* pv)
811         {
812                 ATLASSERT(m_pOwner == NULL);
813-                m_pOwner = reinterpret_cast<CComObject<Base::_OwnerClass>*>(pv);
814+                m_pOwner = reinterpret_cast<CComObject<typename Base::_OwnerClass>*>(pv);
815                 m_pOwner->AddRef();
816         }
817         // Set refcount to 1 to protect destruction
818         ~CComTearOffObject()
819         {
820-                m_dwRef = 1L;
821-                FinalRelease();
822+                this->m_dwRef = 1L;
823+                this->FinalRelease();
824 #ifdef _ATL_DEBUG_INTERFACES
825                 _Module.DeleteNonAddRefThunk(_GetRawUnknown());
826 #endif
827                 m_pOwner->Release();
828         }
829
830-        STDMETHOD_(ULONG, AddRef)() {return InternalAddRef();}
831+        STDMETHOD_(ULONG, AddRef)() {return this->InternalAddRef();}
832         STDMETHOD_(ULONG, Release)()
833         {
834-                ULONG l = InternalRelease();
835+                ULONG l = this->InternalRelease();
836                 if (l == 0)
837                         delete this;
838                 return l;
839@@ -3150,27 +3171,27 @@
840 public:
841         typedef contained _BaseClass;
842         CComCachedTearOffObject(void* pv) :
843-                m_contained(((contained::_OwnerClass*)pv)->GetControllingUnknown())
844+                m_contained(((typename contained::_OwnerClass*)pv)->GetControllingUnknown())
845         {
846                 ATLASSERT(m_contained.m_pOwner == NULL);
847-                m_contained.m_pOwner = reinterpret_cast<CComObject<contained::_OwnerClass>*>(pv);
848+                m_contained.m_pOwner = reinterpret_cast<CComObject<typename contained::_OwnerClass>*>(pv);
849         }
850         //If you get a message that this call is ambiguous then you need to
851         // override it in your class and call each base class' version of this
852         HRESULT FinalConstruct()
853         {
854-                CComObjectRootEx<contained::_ThreadModel::ThreadModelNoCS>::FinalConstruct();
855+                CComObjectRootEx<typename contained::_ThreadModel::ThreadModelNoCS>::FinalConstruct();
856                 return m_contained.FinalConstruct();
857         }
858         void FinalRelease()
859         {
860-                CComObjectRootEx<contained::_ThreadModel::ThreadModelNoCS>::FinalRelease();
861+                CComObjectRootEx<typename contained::_ThreadModel::ThreadModelNoCS>::FinalRelease();
862                 m_contained.FinalRelease();
863         }
864         // Set refcount to 1 to protect destruction
865         ~CComCachedTearOffObject()
866         {
867-                m_dwRef = 1L;
868+                this->m_dwRef = 1L;
869                 FinalRelease();
870 #ifdef _ATL_DEBUG_INTERFACES
871                 _Module.DeleteNonAddRefThunk(this);
872@@ -3178,10 +3199,10 @@
873         }
874
875
876-        STDMETHOD_(ULONG, AddRef)() {return InternalAddRef();}
877+        STDMETHOD_(ULONG, AddRef)() {return this->InternalAddRef();}
878         STDMETHOD_(ULONG, Release)()
879         {
880-                ULONG l = InternalRelease();
881+                ULONG l = this->InternalRelease();
882                 if (l == 0)
883                         delete this;
884                 return l;
885@@ -3260,7 +3281,9 @@
886 {
887 public:
888         typedef license _LicenseClass;
889-        typedef CComClassFactory2<license> _ComMapClass;
890+        using license::IsLicenseValid;
891+        using license::GetLicenseKey;
892+//        typedef CComClassFactory2<license> _ComMapClass;
893 BEGIN_COM_MAP(CComClassFactory2<license>)
894         COM_INTERFACE_ENTRY(IClassFactory)
895         COM_INTERFACE_ENTRY(IClassFactory2)
896@@ -3297,7 +3320,7 @@
897                 if (ppvObject == NULL)
898                         return E_POINTER;
899                 *ppvObject = NULL;
900-                if ( ((bstrKey != NULL) && !VerifyLicenseKey(bstrKey)) ||
901+                if ( ((bstrKey != NULL) && !this->VerifyLicenseKey(bstrKey)) ||
902                          ((bstrKey == NULL) && !IsLicenseValid()) )
903                         return CLASS_E_NOTLICENSED;
904                 if ((pUnkOuter != NULL) && !InlineIsEqualUnknown(riid))
905@@ -3363,7 +3386,7 @@
906                         if (pUnkOuter != NULL)
907                                 hRes = CLASS_E_NOAGGREGATION;
908                         else
909-                                hRes = _Module.CreateInstance(m_pfnCreateInstance, riid, ppvObj);
910+                                hRes = _Module.CreateInstance((LPVOID)m_pfnCreateInstance, riid, ppvObj);
911                 }
912                 return hRes;
913         }
914@@ -3454,6 +3477,7 @@
915                         lpszHelpFile, iid, hRes);
916         }
917 #endif
918+#if 0
919         template <class Q>
920         static HRESULT CreateInstance(IUnknown* punkOuter, Q** pp)
921         {
922@@ -3464,6 +3488,7 @@
923         {
924                 return T::_CreatorClass::CreateInstance(NULL, __uuidof(Q), (void**) pp);
925         }
926+#endif
927 };
928
929 // ATL doesn't support multiple LCID's at the same time
930@@ -3651,7 +3676,7 @@
931                         {
932                                 CComPtr<ITypeInfo> spInfo(spTypeInfo);
933                                 CComPtr<ITypeInfo2> spTypeInfo2;
934-                                if (SUCCEEDED(spTypeInfo->QueryInterface(&spTypeInfo2)))
935+                                if (SUCCEEDED(spTypeInfo->QueryInterface(IID_ITypeInfo2, (void**)&spTypeInfo2)))
936                                         spInfo = spTypeInfo2;
937
938                                 m_pInfo = spInfo.Detach();
939@@ -3760,6 +3785,9 @@
940 /////////////////////////////////////////////////////////////////////////////
941 // IDispEventImpl
942
943+template <class T>
944+struct _ATL_EVENT_ENTRY;
945+
946 #ifdef _ATL_DLL
947 ATLAPI AtlGetObjectSourceInterface(IUnknown* punkObj, GUID* plibid, IID* piid, unsigned short* pdwMajor, unsigned short* pdwMinor);
948 #else
949@@ -3909,16 +3937,17 @@
950 #else
951
952 #pragma warning(disable:4740)       // flow in/out of inline disables global opts
953-inline void __declspec(naked) __stdcall CComStdCallThunkHelper()
954+inline void __stdcall CComStdCallThunkHelper()
955 {
956-        __asm
957-        {
958-                mov eax, [esp+4];       // get pThunk
959-                mov edx, [eax+4];       // get the pThunk->pThis
960-                mov [esp+4], edx;       // replace pThunk with pThis
961-                mov eax, [eax+8];       // get pThunk->pfn
962-                jmp eax;                // jump pfn
963-        };
964+  asm(
965+      " movl $8(%ebp), %eax\n"       // get pThunk
966+      " movl $4(%eax), edx\n"       // get the pThunk->pThis
967+      " movl %edx, $8(%ebp)\n"       // replace pThunk with pThis
968+      " movl $8(%eax), %eax\n"       // get pThunk->pfn
969+      "	movl %ebp, %esp\n"
970+      "	popl %ebp\n"
971+      "	jmp %eax"                // jump pfn
972+      );
973 }
974 #pragma warning(default:4740)
975 #endif
976@@ -3985,6 +4014,7 @@
977 class ATL_NO_VTABLE IDispEventSimpleImpl : public _IDispEventLocator<nID, pdiid>
978 {
979 public:
980+        using _IDispEventLocator<nID, pdiid>::m_dwEventCookie;
981         STDMETHOD(_LocDEQueryInterface)(REFIID riid, void ** ppvObject)
982         {
983                 _ATL_VALIDATE_OUT_POINTER(ppvObject);
984@@ -3992,7 +4022,7 @@
985                 if (InlineIsEqualGUID(riid, *pdiid) ||
986                         InlineIsEqualUnknown(riid) ||
987                         InlineIsEqualGUID(riid, IID_IDispatch) ||
988-                        InlineIsEqualGUID(riid, m_iid))
989+                        InlineIsEqualGUID(riid, this->m_iid))
990                 {
991                         *ppvObject = this;
992                         AddRef();
993@@ -4186,6 +4216,10 @@
994 {
995 public:
996         typedef tihclass _tihclass;
997+        using IDispEventSimpleImpl<nID, T, pdiid>::m_libid;
998+        using IDispEventSimpleImpl<nID, T, pdiid>::m_iid;
999+        using IDispEventSimpleImpl<nID, T, pdiid>::m_wMajorVerNum;
1000+        using IDispEventSimpleImpl<nID, T, pdiid>::m_wMinorVerNum;
1001
1002         IDispEventImpl()
1003         {
1004@@ -4475,6 +4509,11 @@
1005         }
1006 };
1007
1008+template <class Base, const IID* piid, class T, class Copy, class ThreadModel = CComObjectThreadModel>
1009+class ATL_NO_VTABLE CComEnum;
1010+template <class Base, const IID* piid, class T, class Copy, class CollType, class ThreadModel = CComObjectThreadModel>
1011+class ATL_NO_VTABLE CComEnumOnSTL;
1012+
1013
1014 /////////////////////////////////////////////////////////////////////////////
1015 // CComEnumImpl
1016@@ -4746,7 +4785,7 @@
1017         return S_OK;
1018 }
1019
1020-template <class Base, const IID* piid, class T, class Copy, class ThreadModel = CComObjectThreadModel>
1021+template <class Base, const IID* piid, class T, class Copy, class ThreadModel>
1022 class ATL_NO_VTABLE CComEnum :
1023         public CComEnumImpl<Base, piid, T, Copy>,
1024         public CComObjectRootEx< ThreadModel >
1025@@ -4868,7 +4907,7 @@
1026         return hRes;
1027 }
1028
1029-template <class Base, const IID* piid, class T, class Copy, class CollType, class ThreadModel = CComObjectThreadModel>
1030+template <class Base, const IID* piid, class T, class Copy, class CollType, class ThreadModel>
1031 class ATL_NO_VTABLE CComEnumOnSTL :
1032         public IEnumOnSTLImpl<Base, piid, T, Copy, CollType>,
1033         public CComObjectRootEx< ThreadModel >
1034@@ -4901,7 +4940,7 @@
1035                         return E_INVALIDARG;
1036                 HRESULT hr = E_FAIL;
1037                 Index--;
1038-                CollType::iterator iter = m_coll.begin();
1039+                typename CollType::iterator iter = m_coll.begin();
1040                 while (iter != m_coll.end() && Index > 0)
1041                 {
1042                         iter++;
1043@@ -5314,7 +5353,7 @@
1044                 if (InlineIsEqualGUID(riid, IID_IConnectionPoint) || InlineIsEqualUnknown(riid))
1045                 {
1046                         *ppvObject = this;
1047-                        AddRef();
1048+                        this->AddRef();
1049 #ifdef _ATL_DEBUG_INTERFACES
1050                         _Module.AddThunk((IUnknown**)ppvObject, _T("IConnectionPointImpl"), riid);
1051 #endif // _ATL_DEBUG_INTERFACES
1052--- include/atl/atlconv.h.orig	2005-04-14 17:54:32.000000000 +0900
1053+++ include/atl/atlconv.h	2007-12-31 07:29:34.759750000 +0900
1054@@ -10,6 +10,9 @@
1055
1056 #ifndef __ATLCONV_H__
1057 #define __ATLCONV_H__
1058+#if __GNUC__ >=3
1059+#pragma GCC system_header
1060+#endif
1061
1062 #ifndef __cplusplus
1063         #error ATL requires C++ compilation (use a .cpp suffix)
1064@@ -30,7 +33,11 @@
1065 // Following code is to avoid alloca causing a stack overflow.
1066 // It is intended for use from the _ATL_SAFE_ALLOCA macros
1067 // or Conversion macros.
1068-__declspec(selectany) DWORD _Atlosplatform = 0;
1069+#ifdef _INIT_ATL_COMMON_VARS
1070+DWORD _Atlosplatform = 0;
1071+#else
1072+extern DWORD _Atlosplatform;
1073+#endif
1074 inline BOOL _AtlGetVersionEx()
1075 {
1076         OSVERSIONINFO osi;
1077@@ -156,8 +163,11 @@
1078 #pragma prefast(suppress:515, "Atlresetstkoflw is the same as resetstkoflw")
1079
1080 // Verifies if sufficient space is available on the stack.
1081-inline bool _AtlVerifyStackAvailable(SIZE_T Size)
1082+inline bool _AtlVerifyStackAvailable(SIZE_T /*Size*/)
1083 {
1084+#if 1
1085+    return false;
1086+#else
1087     bool bStackAvailable = true;
1088
1089     __try
1090@@ -173,6 +183,7 @@
1091         _Atlresetstkoflw();
1092     }
1093     return bStackAvailable;
1094+#endif
1095 }
1096
1097 #pragma prefast(pop)
1098@@ -281,15 +292,15 @@
1099
1100 #ifdef _CONVERSION_USES_THREAD_LOCALE
1101         #ifndef _DEBUG
1102-                #define USES_CONVERSION int _convert; _convert; UINT _acp = GetACP(); _acp; LPCWSTR _lpw; _lpw; LPCSTR _lpa; _lpa
1103+                #define USES_CONVERSION int _convert; (void)_convert; UINT _acp = GetACP(); (void)_acp; LPCWSTR _lpw; (void)_lpw; LPCSTR _lpa; (void)_lpa
1104         #else
1105-                #define USES_CONVERSION int _convert = 0; _convert; UINT _acp = GetACP(); _acp; LPCWSTR _lpw = NULL; _lpw; LPCSTR _lpa = NULL; _lpa
1106+                #define USES_CONVERSION int _convert = 0; (void)_convert; UINT _acp = GetACP(); (void)_acp; LPCWSTR _lpw = NULL; (void)_lpw; LPCSTR _lpa = NULL; (void)_lpa
1107         #endif
1108 #else
1109         #ifndef _DEBUG
1110-                #define USES_CONVERSION int _convert; _convert; UINT _acp = CP_ACP; _acp; LPCWSTR _lpw; _lpw; LPCSTR _lpa; _lpa
1111+                #define USES_CONVERSION int _convert; (void)_convert; UINT _acp = CP_ACP; (void)_acp; LPCWSTR _lpw; (void)_lpw; LPCSTR _lpa; (void)_lpa
1112         #else
1113-                #define USES_CONVERSION int _convert = 0; _convert; UINT _acp = CP_ACP; _acp; LPCWSTR _lpw = NULL; _lpw; LPCSTR _lpa = NULL; _lpa
1114+                #define USES_CONVERSION int _convert = 0; (void)_convert; UINT _acp = CP_ACP; (void)_acp; LPCWSTR _lpw = NULL; (void)_lpw; LPCSTR _lpa = NULL; (void)_lpa
1115         #endif
1116 #endif
1117
1118--- include/atl/atlctl.h.orig	2005-04-14 17:54:32.000000000 +0900
1119+++ include/atl/atlctl.h	2009-04-19 13:31:15.146000000 +0900
1120@@ -10,6 +10,9 @@
1121
1122 #ifndef __ATLCTL_H__
1123 #define __ATLCTL_H__
1124+#if __GNUC__ >=3
1125+#pragma GCC system_header
1126+#endif
1127
1128 #ifndef __cplusplus
1129         #error ATL requires C++ compilation (use a .cpp suffix)
1130@@ -57,7 +60,7 @@
1131 namespace ATL
1132 {
1133
1134-#pragma pack(push, _ATL_PACKING)
1135+#pragma pack(push, 8)
1136
1137 // Forward declarations
1138 //
1139@@ -142,7 +145,9 @@
1140         CComControlBase(HWND& h) : m_hWndCD(h)
1141         {
1142                 memset(this, 0, sizeof(CComControlBase));
1143-                m_phWndCD = &h;
1144+		// previous element of m_hWndCD in this class is m_rcPos
1145+		*reinterpret_cast<HWND **>(reinterpret_cast<DWORD>(reinterpret_cast<char *>(&m_rcPos)+sizeof(m_rcPos)+(__alignof__(m_hWndCD)-1))&(-(__alignof__(m_hWndCD))))=&h;
1146+//                m_phWndCD = &h;
1147                 m_sizeExtent.cx = 2*2540;
1148                 m_sizeExtent.cy = 2*2540;
1149                 m_sizeNatural = m_sizeExtent;
1150@@ -530,13 +535,13 @@
1151         SIZE m_sizeNatural; //unscaled size in himetric
1152         SIZE m_sizeExtent;  //current extents in himetric
1153         RECT m_rcPos; // position in pixels
1154-#pragma warning(disable: 4510 4610) // unnamed union
1155-        union
1156-        {
1157+//#pragma warning(disable: 4510 4610) // unnamed union
1158+//        union
1159+//        {
1160                 HWND& m_hWndCD;
1161-                HWND* m_phWndCD;
1162-        };
1163-#pragma warning(default: 4510 4610)
1164+//                HWND* m_phWndCD;
1165+//        };
1166+//#pragma warning(default: 4510 4610)
1167         union
1168         {
1169                 // m_nFreezeEvents is the only one actually used
1170@@ -1362,7 +1367,7 @@
1171 class ATL_NO_VTABLE CComControl :  public CComControlBase, public WinBase
1172 {
1173 public:
1174-        CComControl() : CComControlBase(m_hWnd) {}
1175+        CComControl() : CComControlBase(this->m_hWnd) {}
1176         HRESULT FireOnRequestEdit(DISPID dispID)
1177         {
1178                 T* pT = static_cast<T*>(this);
1179@@ -1401,6 +1406,8 @@
1180 class CComCompositeControl : public CComControl< T, CAxDialogImpl< T > >
1181 {
1182 public:
1183+        using CComControl< T, CAxDialogImpl< T > >::m_hWnd;
1184+        using CComControl< T, CAxDialogImpl< T > >::GetNextDlgTabItem;
1185         CComCompositeControl()
1186         {
1187                 m_hbrBackground = NULL;
1188@@ -1429,7 +1436,7 @@
1189                         m_hbrBackground = NULL;
1190                 }
1191                 OLE_COLOR clr;
1192-                HRESULT hr = GetAmbientBackColor(clr);
1193+                HRESULT hr = this->GetAmbientBackColor(clr);
1194                 if (SUCCEEDED(hr))
1195                 {
1196                         COLORREF rgb;
1197@@ -1443,7 +1450,7 @@
1198         {
1199                 CAxWindow wnd(hwnd);
1200                 CComPtr<IAxWinAmbientDispatch> spDispatch;
1201-                wnd.QueryHost(&spDispatch);
1202+                wnd.QueryHost(IID_IAxWinAmbientDispatch, (void**)&spDispatch);
1203                 if (spDispatch != NULL)
1204                         spDispatch->put_BackColor((OLE_COLOR)l);
1205                 return TRUE;
1206@@ -1458,10 +1465,10 @@
1207         }
1208         HWND Create(HWND hWndParent, RECT& /*rcPos*/, LPARAM dwInitParam = NULL)
1209         {
1210-                CComControl< T, CAxDialogImpl< T > >::Create(hWndParent, dwInitParam);
1211+                this->Create(hWndParent, dwInitParam);
1212                 SetBackgroundColorFromAmbient();
1213                 if (m_hWnd != NULL)
1214-                        ShowWindow(SW_SHOWNOACTIVATE);
1215+                        this->ShowWindow(SW_SHOWNOACTIVATE);
1216                 return m_hWnd;
1217         }
1218         BOOL CalcExtent(SIZE& size)
1219@@ -1488,7 +1495,7 @@
1220                         return FALSE;
1221                 // find a direct child of the dialog from the window that has focus
1222                 HWND hWndCtl = ::GetFocus();
1223-                if (IsChild(hWndCtl) && ::GetParent(hWndCtl) != m_hWnd)
1224+                if (this->IsChild(hWndCtl) && ::GetParent(hWndCtl) != m_hWnd)
1225                 {
1226                         do
1227                         {
1228@@ -1546,7 +1553,7 @@
1229                         break;
1230                 }
1231
1232-                return IsDialogMessage(pMsg);
1233+                return this->IsDialogMessage(pMsg);
1234         }
1235         HRESULT IOleInPlaceObject_InPlaceDeactivate(void)
1236         {
1237@@ -1563,7 +1570,7 @@
1238         }
1239         virtual HRESULT OnDraw(ATL_DRAWINFO& di)
1240         {
1241-                if(!m_bInPlaceActive)
1242+                if(!this->m_bInPlaceActive)
1243                 {
1244                         HPEN hPen = (HPEN)::GetStockObject(BLACK_PEN);
1245                         HBRUSH hBrush = (HBRUSH)::GetStockObject(GRAY_BRUSH);
1246@@ -1626,7 +1633,7 @@
1247         }
1248         STDMETHOD(OnAmbientPropertyChange)(DISPID dispid)
1249         {
1250-                dispid;
1251+                (void)dispid;
1252                 ATLTRACE2(atlTraceControls,2,_T("IOleControlImpl::OnAmbientPropertyChange\n"));
1253                 ATLTRACE2(atlTraceControls,2,_T(" -- DISPID = %d (%d)\n"), dispid);
1254                 return S_OK;
1255@@ -2905,7 +2912,7 @@
1256                 ATLTRACE2(atlTraceControls,2,_T("~CBindStatusCallback\n"));
1257         }
1258
1259-        STDMETHOD(OnStartBinding)(DWORD dwReserved, IBinding *pBinding)
1260+        STDMETHOD(OnStartBinding)(DWORD /*dwReserved*/, IBinding *pBinding)
1261         {
1262                 ATLTRACE2(atlTraceControls,2,_T("CBindStatusCallback::OnStartBinding\n"));
1263                 m_spBinding = pBinding;
1264@@ -2923,19 +2930,19 @@
1265                 return S_OK;
1266         }
1267
1268-        STDMETHOD(OnLowResource)(DWORD reserved)
1269+        STDMETHOD(OnLowResource)(DWORD /*reserved*/)
1270         {
1271                 ATLTRACE2(atlTraceControls,2,_T("CBindStatusCallback::OnLowResource"));
1272                 return S_OK;
1273         }
1274
1275-        STDMETHOD(OnProgress)(ULONG ulProgress, ULONG ulProgressMax, ULONG ulStatusCode, LPCWSTR szStatusText)
1276+        STDMETHOD(OnProgress)(ULONG /*ulProgress*/, ULONG /*ulProgressMax*/, ULONG /*ulStatusCode*/, LPCWSTR /*szStatusText*/)
1277         {
1278                 ATLTRACE2(atlTraceControls,2,_T("CBindStatusCallback::OnProgress"));
1279                 return S_OK;
1280         }
1281
1282-        STDMETHOD(OnStopBinding)(HRESULT hresult, LPCWSTR szError)
1283+        STDMETHOD(OnStopBinding)(HRESULT /*hresult*/, LPCWSTR /*szError*/)
1284         {
1285                 ATLTRACE2(atlTraceControls,2,_T("CBindStatusCallback::OnStopBinding\n"));
1286                 (m_pT->*m_pFunc)(this, NULL, 0);
1287@@ -2962,7 +2969,7 @@
1288                 return S_OK;
1289         }
1290
1291-        STDMETHOD(OnDataAvailable)(DWORD grfBSCF, DWORD dwSize, FORMATETC *pformatetc, STGMEDIUM *pstgmed)
1292+        STDMETHOD(OnDataAvailable)(DWORD grfBSCF, DWORD dwSize, FORMATETC */*pformatetc*/, STGMEDIUM *pstgmed)
1293         {
1294                 ATLTRACE2(atlTraceControls,2,_T("CBindStatusCallback::OnDataAvailable\n"));
1295                 HRESULT hr = S_OK;
1296@@ -3005,7 +3012,7 @@
1297                 return hr;
1298         }
1299
1300-        STDMETHOD(OnObjectAvailable)(REFIID riid, IUnknown *punk)
1301+        STDMETHOD(OnObjectAvailable)(REFIID /*riid*/, IUnknown */*punk*/)
1302         {
1303                 ATLTRACE2(atlTraceControls,2,_T("CBindStatusCallback::OnObjectAvailable"));
1304                 return S_OK;
1305--- include/atl/atlwin.h.orig	2005-04-14 17:54:32.000000000 +0900
1306+++ include/atl/atlwin.h	2007-12-31 07:29:28.525375000 +0900
1307@@ -10,6 +10,9 @@
1308
1309 #ifndef __ATLWIN_H__
1310 #define __ATLWIN_H__
1311+#if __GNUC__ >=3
1312+#pragma GCC system_header
1313+#endif
1314
1315 #ifndef __cplusplus
1316         #error ATL requires C++ compilation (use a .cpp suffix)
1317@@ -99,6 +102,8 @@
1318 #else
1319 #define CWndClassInfo CWndClassInfoA
1320 #endif
1321+template <DWORD t_dwStyle = 0, DWORD t_dwExStyle = 0> class CWinTraits;
1322+typedef CWinTraits<WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, 0>                                        CControlWinTraits;
1323 template <class T, class TBase = CWindow, class TWinTraits = CControlWinTraits> class CWindowImpl;
1324 template <class T, class TBase = CWindow> class CDialogImpl;
1325 #ifndef _ATL_NO_HOSTING
1326@@ -658,6 +663,13 @@
1327                 ATLASSERT(::IsWindow(m_hWnd));
1328                 return ::GetDlgItemText(m_hWnd, nID, lpStr, nMaxCount);
1329         }
1330+
1331+        HWND GetDlgItem(int nID) const
1332+        {
1333+                ATLASSERT(::IsWindow(m_hWnd));
1334+                return ::GetDlgItem(m_hWnd, nID);
1335+        }
1336+
1337         BOOL GetDlgItemText(int nID, BSTR& bstrText) const
1338         {
1339                 ATLASSERT(::IsWindow(m_hWnd));
1340@@ -847,12 +859,6 @@
1341                 return (int)::SetWindowLong(m_hWnd, GWL_ID, nID);
1342         }
1343
1344-        HWND GetDlgItem(int nID) const
1345-        {
1346-                ATLASSERT(::IsWindow(m_hWnd));
1347-                return ::GetDlgItem(m_hWnd, nID);
1348-        }
1349-
1350 // Alert Functions
1351
1352         BOOL FlashWindow(BOOL bInvert)
1353@@ -1319,7 +1325,9 @@
1354         }
1355 };
1356
1357-_declspec(selectany) RECT CWindow::rcDefault = { CW_USEDEFAULT, CW_USEDEFAULT, 0, 0 };
1358+#ifdef _INIT_ATL_COMMON_VARS
1359+RECT CWindow::rcDefault = { CW_USEDEFAULT, CW_USEDEFAULT, 0, 0 };
1360+#endif
1361
1362 /////////////////////////////////////////////////////////////////////////////
1363 // CAxWindow - client side for an ActiveX host window
1364@@ -1330,6 +1338,7 @@
1365 class CAxWindowT : public TBase
1366 {
1367 public:
1368+        using TBase::m_hWnd;
1369 // Constructors
1370         CAxWindowT(HWND hWnd = NULL) : TBase(hWnd)
1371         { }
1372@@ -1439,11 +1448,13 @@
1373                         hr = spUnk->QueryInterface(iid, ppUnk);
1374                 return hr;
1375         }
1376+#if 0
1377         template <class Q>
1378         HRESULT QueryHost(Q** ppUnk)
1379         {
1380                 return QueryHost(__uuidof(Q), (void**)ppUnk);
1381         }
1382+#endif
1383         HRESULT QueryControl(REFIID iid, void** ppUnk)
1384         {
1385                 ATLASSERT(ppUnk != NULL);
1386@@ -1459,11 +1470,13 @@
1387                         hr = spUnk->QueryInterface(iid, ppUnk);
1388                 return hr;
1389         }
1390+#if 0
1391         template <class Q>
1392         HRESULT QueryControl(Q** ppUnk)
1393         {
1394                 return QueryControl(__uuidof(Q), (void**)ppUnk);
1395         }
1396+#endif
1397         HRESULT SetExternalDispatch(IDispatch* pDisp)
1398         {
1399                 HRESULT hr;
1400@@ -1521,12 +1534,12 @@
1401         BOOL ProcessWindowMessage(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT& lResult, DWORD dwMsgMapID = 0) \
1402         { \
1403                 BOOL bHandled = TRUE; \
1404-                hWnd; \
1405-                uMsg; \
1406-                wParam; \
1407-                lParam; \
1408-                lResult; \
1409-                bHandled; \
1410+                (void)hWnd; \
1411+                (void)uMsg; \
1412+                (void)wParam; \
1413+                (void)lParam; \
1414+                (void)lResult; \
1415+                (void)bHandled; \
1416                 switch(dwMsgMapID) \
1417                 { \
1418                 case 0:
1419@@ -1750,7 +1763,7 @@
1420
1421         // search for an empty one
1422
1423-                for(i = 0; i < m_aChainEntry.GetSize(); i++)
1424+                for(int i = 0; i < m_aChainEntry.GetSize(); i++)
1425                 {
1426                         if(m_aChainEntry[i] == NULL)
1427                         {
1428@@ -1841,7 +1854,7 @@
1429 /////////////////////////////////////////////////////////////////////////////
1430 // CWinTraits - Defines various default values for a window
1431
1432-template <DWORD t_dwStyle = 0, DWORD t_dwExStyle = 0>
1433+template <DWORD t_dwStyle, DWORD t_dwExStyle>
1434 class CWinTraits
1435 {
1436 public:
1437@@ -1855,7 +1868,7 @@
1438         }
1439 };
1440
1441-typedef CWinTraits<WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, 0>                                        CControlWinTraits;
1442+//typedef CWinTraits<WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, 0>                                        CControlWinTraits;
1443 typedef CWinTraits<WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, WS_EX_APPWINDOW | WS_EX_WINDOWEDGE>                CFrameWinTraits;
1444 typedef CWinTraits<WS_OVERLAPPEDWINDOW | WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, WS_EX_MDICHILD>        CMDIChildWinTraits;
1445
1446@@ -1882,6 +1895,7 @@
1447 class ATL_NO_VTABLE CWindowImplRoot : public TBase, public CMessageMap
1448 {
1449 public:
1450+        using TBase::GetDlgItem;
1451         CWndProcThunk m_thunk;
1452         const MSG* m_pCurrentMsg;
1453
1454@@ -1892,7 +1906,7 @@
1455         ~CWindowImplRoot()
1456         {
1457 #ifdef _DEBUG
1458-                if(m_hWnd != NULL)        // should be cleared in WindowProc
1459+                if(this->m_hWnd != NULL)        // should be cleared in WindowProc
1460                 {
1461                         ATLTRACE2(atlTraceWindowing, 0, _T("ERROR - Object deleted before window was destroyed\n"));
1462                         ATLASSERT(FALSE);
1463@@ -2017,6 +2031,8 @@
1464 class ATL_NO_VTABLE CWindowImplBaseT : public CWindowImplRoot< TBase >
1465 {
1466 public:
1467+        using CWindowImplRoot< TBase >::m_hWnd;
1468+        using CWindowImplRoot< TBase >::m_thunk;
1469         WNDPROC m_pfnSuperWindowProc;
1470
1471         CWindowImplBaseT() : m_pfnSuperWindowProc(::DefWindowProc)
1472@@ -2049,7 +2065,7 @@
1473
1474         LRESULT DefWindowProc()
1475         {
1476-                const MSG* pMsg = m_pCurrentMsg;
1477+                const MSG* pMsg = this->m_pCurrentMsg;
1478                 LRESULT lRes = 0;
1479                 if (pMsg != NULL)
1480                         lRes = DefWindowProc(pMsg->message, pMsg->wParam, pMsg->lParam);
1481@@ -2091,7 +2107,7 @@
1482         if(pOldProc != StartWindowProc)
1483                 ATLTRACE2(atlTraceWindowing, 0, _T("Subclassing through a hook discarded.\n"));
1484 #else
1485-        pOldProc;        // avoid unused warning
1486+        (void)pOldProc;        // avoid unused warning
1487 #endif
1488         return pProc(hWnd, uMsg, wParam, lParam);
1489 }
1490@@ -2219,6 +2235,7 @@
1491 class ATL_NO_VTABLE CWindowImpl : public CWindowImplBaseT< TBase, TWinTraits >
1492 {
1493 public:
1494+        using CWindowImplBaseT< TBase, TWinTraits >::StartWindowProc;
1495         DECLARE_WND_CLASS(NULL)
1496
1497         HWND Create(HWND hWndParent, RECT& rcPos, LPCTSTR szWindowName = NULL,
1498@@ -2226,8 +2243,8 @@
1499                         UINT nID = 0, LPVOID lpCreateParam = NULL)
1500         {
1501                 if (T::GetWndClassInfo().m_lpszOrigName == NULL)
1502-                        T::GetWndClassInfo().m_lpszOrigName = GetWndClassName();
1503-                ATOM atom = T::GetWndClassInfo().Register(&m_pfnSuperWindowProc);
1504+                        T::GetWndClassInfo().m_lpszOrigName = this->GetWndClassName();
1505+                ATOM atom = T::GetWndClassInfo().Register(&(this->m_pfnSuperWindowProc));
1506
1507                 dwStyle = T::GetWndStyle(dwStyle);
1508                 dwExStyle = T::GetWndExStyle(dwExStyle);
1509@@ -2244,6 +2261,7 @@
1510 class ATL_NO_VTABLE CDialogImplBaseT : public CWindowImplRoot< TBase >
1511 {
1512 public:
1513+        using CWindowImplRoot< TBase >::m_hWnd;
1514 	virtual DLGPROC GetDialogProc()
1515 	{
1516 		return DialogProc;
1517@@ -2344,6 +2362,9 @@
1518 class ATL_NO_VTABLE CDialogImpl : public CDialogImplBaseT< TBase >
1519 {
1520 public:
1521+        using CDialogImplBaseT< TBase >::m_hWnd;
1522+        using CDialogImplBaseT< TBase >::m_thunk;
1523+        typedef CDialogImplBaseT< TBase > CDialogImplBase_Class;
1524 #ifdef _DEBUG
1525         bool m_bModal;
1526         CDialogImpl() : m_bModal(false) { }
1527@@ -2422,6 +2443,8 @@
1528 class ATL_NO_VTABLE CAxDialogImpl : public CDialogImplBaseT< TBase >
1529 {
1530 public:
1531+        using CDialogImplBaseT< TBase >::m_hWnd;
1532+        using CDialogImplBaseT< TBase >::m_thunk;
1533 #ifdef _DEBUG
1534         bool m_bModal;
1535         CAxDialogImpl() : m_bModal(false) { }
1536@@ -2515,6 +2538,8 @@
1537 class CContainedWindowT : public TBase
1538 {
1539 public:
1540+        using TBase::m_hWnd;
1541+        using TBase::GetWndClassName;
1542         CWndProcThunk m_thunk;
1543         LPCTSTR m_lpszClassName;
1544         WNDPROC m_pfnSuperWindowProc;
1545@@ -2536,7 +2561,7 @@
1546         { }
1547
1548         CContainedWindowT(CMessageMap* pObject, DWORD dwMsgMapID = 0)
1549-                : m_lpszClassName(TBase::GetWndClassName()),
1550+                : m_lpszClassName(GetWndClassName()),
1551                 m_pfnSuperWindowProc(::DefWindowProc),
1552                 m_pObject(pObject), m_dwMsgMapID(dwMsgMapID),
1553                 m_pCurrentMsg(NULL)
1554@@ -2666,7 +2691,7 @@
1555                 LPCTSTR szWindowName = NULL, DWORD dwStyle = 0, DWORD dwExStyle = 0,
1556                 UINT nID = 0, LPVOID lpCreateParam = NULL)
1557         {
1558-                m_lpszClassName = TBase::GetWndClassName();
1559+                m_lpszClassName = GetWndClassName();
1560                 m_pfnSuperWindowProc = ::DefWindowProc;
1561                 m_pObject = pObject;
1562                 m_dwMsgMapID = dwMsgMapID;
1563@@ -2959,8 +2984,11 @@
1564         {
1565
1566                 ::EnterCriticalSection(&pM->m_csWindowCreate);
1567-                __try
1568+                jmp_buf _sejmpbuf;
1569+                __SEHandler _sehandler;
1570+                if (__builtin_setjmp(_sejmpbuf) == 0)
1571                 {
1572+                        _sehandler.Set(_sejmpbuf, &pM->m_csWindowCreate, EXCEPTION_CONTINUE_SEARCH, NULL, atlfinalleavecriticalsection);
1573                         if(p->m_atom == 0)
1574                         {
1575                                 HINSTANCE hInst = pM->m_hInst;
1576@@ -2979,7 +3007,7 @@
1577                                                 if(!::GetClassInfoExA(_Module.GetModuleInstance(), p->m_lpszOrigName, &wc))
1578                                                 {
1579                                                         fFail = TRUE;
1580-                                                        __leave;
1581+                                                        __builtin_longjmp(_sejmpbuf, 1);
1582                                                 }
1583                                         }
1584                                         memcpy(&p->m_wc, &wc, sizeof(WNDCLASSEX));
1585@@ -3011,10 +3039,7 @@
1586                                         p->m_atom = ::RegisterClassExA(&p->m_wc);
1587                         }
1588                 }
1589-                __finally
1590-                {
1591-                        ::LeaveCriticalSection(&pM->m_csWindowCreate);
1592-                }
1593+                _sehandler.Reset();
1594         }
1595
1596         if (fFail)
1597@@ -3038,8 +3063,11 @@
1598         if (p->m_atom == 0)
1599         {
1600                 ::EnterCriticalSection(&pM->m_csWindowCreate);
1601-                __try
1602+                jmp_buf _sejmpbuf;
1603+                __SEHandler _sehandler;
1604+                if (__builtin_setjmp(_sejmpbuf) == 0)
1605                 {
1606+                        _sehandler.Set(_sejmpbuf, &pM->m_csWindowCreate, EXCEPTION_CONTINUE_SEARCH, NULL, atlfinalleavecriticalsection);
1607                         if(p->m_atom == 0)
1608                         {
1609                                 HINSTANCE hInst = pM->m_hInst;
1610@@ -3058,7 +3086,7 @@
1611                                                 if(!::GetClassInfoExW(_Module.GetModuleInstance(), p->m_lpszOrigName, &wc))
1612                                                 {
1613                                                         fFail = TRUE;
1614-                                                        __leave;
1615+                                                        __builtin_longjmp(_sejmpbuf, -1);
1616                                                 }
1617                                         }
1618                                         memcpy(&p->m_wc, &wc, sizeof(WNDCLASSEX));
1619@@ -3090,10 +3118,7 @@
1620                                         p->m_atom = ::RegisterClassExW(&p->m_wc);
1621                         }
1622                 }
1623-                __finally
1624-                {
1625-                        ::LeaveCriticalSection(&pM->m_csWindowCreate);
1626-                }
1627+                _sehandler.Reset();
1628         }
1629
1630         if (fFail)
1631--- include/atl/statreg.h.orig	2005-04-14 17:54:34.000000000 +0900
1632+++ include/atl/statreg.h	2006-09-18 20:05:01.468750000 +0900
1633@@ -573,15 +573,16 @@
1634         return hRes;
1635 }
1636
1637-__declspec(selectany) LPCTSTR CRegParser::rgszNeverDelete[] = //Component Catagories
1638+#ifdef _INIT_ATL_COMMON_VARS
1639+LPCTSTR CRegParser::rgszNeverDelete[] = //Component Catagories
1640 {
1641         _T("CLSID"), _T("TYPELIB")
1642 };
1643
1644-__declspec(selectany) const int CRegParser::cbNeverDelete = sizeof(rgszNeverDelete) / sizeof(LPCTSTR*);
1645-__declspec(selectany) const int CRegParser::MAX_VALUE=4096;
1646-__declspec(selectany) const int CRegParser::MAX_TYPE=MAX_VALUE;
1647-
1648+const int CRegParser::cbNeverDelete = sizeof(rgszNeverDelete) / sizeof(LPCTSTR*);
1649+const int CRegParser::MAX_VALUE=4096;
1650+const int CRegParser::MAX_TYPE=MAX_VALUE;
1651+#endif
1652
1653 inline BOOL CRegParser::VTFromRegType(LPCTSTR szValueType, VARTYPE& vt)
1654 {
1655