rossryan
asked on
Bitmaps & errors
struct SapphireData
{
Bitmap SapphireSwap;
};
SapphireData->SapphireSwap = Bitmap::FromHBITMAP(hBmp, CPalette::operator HPALETTE);
I need to copy a bitmap into a struct for shared memory. Why do I get a lot of errors when using this statement?
code beforehand:
hBmp = NULL;
{
HDC hDC = GetDC(hWnd);
hBmp = CreateCompatibleBitmap(hDC , rect.right - rect.left, rect.bottom - rect.top);
ReleaseDC(hWnd, hDC);
}
hOld = SelectObject(hDCMem, hBmp);
{
Bitmap SapphireSwap;
};
SapphireData->SapphireSwap
I need to copy a bitmap into a struct for shared memory. Why do I get a lot of errors when using this statement?
code beforehand:
hBmp = NULL;
{
HDC hDC = GetDC(hWnd);
hBmp = CreateCompatibleBitmap(hDC
ReleaseDC(hWnd, hDC);
}
hOld = SelectObject(hDCMem, hBmp);
Can you paste those errors here?
ASKER
------ Build started: Project: hook, Configuration: Debug Win32 ------
Compiling...
hookpaint.cpp
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Imaging.h( 67) : error C2501: 'MIDL_INTERFACE' : missing storage-class or type specifiers
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Imaging.h( 67) : error C2440: 'initializing' : cannot convert from 'const char [37]' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Imaging.h( 67) : error C2146: syntax error : missing ';' before identifier 'IImageBytes'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Imaging.h( 67) : error C2470: 'IImageBytes' : looks like a function definition, but there is no formal parameter list; skipping apparent body
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Imaging.h( 67) : error C2059: syntax error : 'public'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Imaging.h( 246) : error C2146: syntax error : missing ';' before identifier 'id'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Imaging.h( 246) : error C2501: 'Gdiplus::PropertyItem::PR OPID' : missing storage-class or type specifiers
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Imaging.h( 246) : error C2501: 'Gdiplus::PropertyItem::id ' : missing storage-class or type specifiers
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Headers.h( 384) : error C2143: syntax error : missing ')' before '*'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Headers.h( 384) : error C2143: syntax error : missing ';' before '*'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Headers.h( 384) : error C2460: 'Gdiplus::Image::IStream' : uses 'Gdiplus::Image', which is being defined
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Headers.h( 372) : see declaration of 'Gdiplus::Image'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Headers.h( 384) : error C2501: 'Gdiplus::Image::stream' : missing storage-class or type specifiers
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Headers.h( 384) : error C2146: syntax error : missing ';' before identifier 'useEmbeddedColorManagemen t'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Headers.h( 384) : error C2501: 'Gdiplus::Image::BOOL' : missing storage-class or type specifiers
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Headers.h( 384) : error C2059: syntax error : ')'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Headers.h( 384) : error C2864: 'useEmbeddedColorManagemen t' : only const static integral data members can be initialized inside a class or struct
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Headers.h( 384) : error C2501: 'Gdiplus::Image::useEmbedd edColorMan agement' : missing storage-class or type specifiers
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Headers.h( 395) : error C2061: syntax error : identifier 'IStream'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Headers.h( 405) : error C2061: syntax error : identifier 'IStream'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Headers.h( 443) : error C2061: syntax error : identifier 'PROPID'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Headers.h( 444) : error C2061: syntax error : identifier 'PROPID'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Headers.h( 445) : error C2061: syntax error : identifier 'PROPID'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Headers.h( 453) : error C2061: syntax error : identifier 'PROPID'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Headers.h( 499) : error C2143: syntax error : missing ')' before '*'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Headers.h( 499) : error C2143: syntax error : missing ';' before '*'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Headers.h( 499) : error C2460: 'Gdiplus::Bitmap::IStream' : uses 'Gdiplus::Bitmap', which is being defined
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Headers.h( 488) : see declaration of 'Gdiplus::Bitmap'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Headers.h( 499) : error C2501: 'Gdiplus::Bitmap::stream' : missing storage-class or type specifiers
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Headers.h( 499) : error C2146: syntax error : missing ';' before identifier 'useEmbeddedColorManagemen t'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Headers.h( 499) : error C2501: 'Gdiplus::Bitmap::BOOL' : missing storage-class or type specifiers
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Headers.h( 499) : error C2059: syntax error : ')'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Headers.h( 499) : error C2864: 'useEmbeddedColorManagemen t' : only const static integral data members can be initialized inside a class or struct
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Headers.h( 499) : error C2501: 'Gdiplus::Bitmap::useEmbed dedColorMa nagement' : missing storage-class or type specifiers
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Headers.h( 510) : error C2061: syntax error : identifier 'IStream'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Flat.h(113 3) : error C2065: 'IStream' : undeclared identifier
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Flat.h(113 3) : error C2065: 'stream' : undeclared identifier
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Flat.h(113 3) : error C2065: 'image' : undeclared identifier
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Flat.h(113 3) : error C2275: 'Gdiplus::GpImage' : illegal use of this type as an expression
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus GpStubs.h( 61) : see declaration of 'Gdiplus::GpImage'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Flat.h(113 3) : warning C4229: anachronism used : modifiers on data are ignored
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Flat.h(113 3) : error C2078: too many initializers
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Flat.h(113 9) : error C3861: 'IStream': identifier not found, even with argument-dependent lookup
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Flat.h(113 9) : error C3861: 'stream': identifier not found, even with argument-dependent lookup
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Flat.h(113 9) : error C2275: 'Gdiplus::GpImage' : illegal use of this type as an expression
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus GpStubs.h( 61) : see declaration of 'Gdiplus::GpImage'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Flat.h(113 9) : error C3861: 'image': identifier not found, even with argument-dependent lookup
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Flat.h(113 9) : warning C4229: anachronism used : modifiers on data are ignored
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Flat.h(113 9) : error C2078: too many initializers
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Flat.h(115 6) : error C2061: syntax error : identifier 'IStream'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Flat.h(124 4) : error C2061: syntax error : identifier 'PROPID'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Flat.h(124 7) : error C2061: syntax error : identifier 'PROPID'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Flat.h(125 0) : error C2061: syntax error : identifier 'PROPID'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Flat.h(126 2) : error C2061: syntax error : identifier 'PROPID'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Flat.h(127 5) : error C3861: 'IStream': identifier not found, even with argument-dependent lookup
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Flat.h(127 5) : error C3861: 'stream': identifier not found, even with argument-dependent lookup
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Flat.h(127 5) : error C2065: 'bitmap' : undeclared identifier
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Flat.h(127 5) : error C2275: 'Gdiplus::GpBitmap' : illegal use of this type as an expression
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus GpStubs.h( 62) : see declaration of 'Gdiplus::GpBitmap'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Flat.h(127 5) : warning C4229: anachronism used : modifiers on data are ignored
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Flat.h(127 5) : error C2078: too many initializers
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Flat.h(128 1) : error C3861: 'IStream': identifier not found, even with argument-dependent lookup
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Flat.h(128 1) : error C3861: 'stream': identifier not found, even with argument-dependent lookup
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Flat.h(128 1) : error C2275: 'Gdiplus::GpBitmap' : illegal use of this type as an expression
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus GpStubs.h( 62) : see declaration of 'Gdiplus::GpBitmap'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Flat.h(128 1) : error C3861: 'bitmap': identifier not found, even with argument-dependent lookup
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Flat.h(128 1) : warning C4229: anachronism used : modifiers on data are ignored
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Flat.h(128 1) : error C2078: too many initializers
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Flat.h(212 6) : error C3861: 'IStream': identifier not found, even with argument-dependent lookup
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Flat.h(212 6) : error C3861: 'stream': identifier not found, even with argument-dependent lookup
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Flat.h(212 8) : error C2065: 'header' : undeclared identifier
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Flat.h(212 8) : error C2275: 'Gdiplus::MetafileHeader' : illegal use of this type as an expression
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus MetaHeader .h(112) : see declaration of 'Gdiplus::MetafileHeader'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Flat.h(212 8) : warning C4229: anachronism used : modifiers on data are ignored
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Flat.h(212 8) : error C2078: too many initializers
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Flat.h(214 6) : error C2061: syntax error : identifier 'IStream'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Flat.h(216 6) : error C3861: 'IStream': identifier not found, even with argument-dependent lookup
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Flat.h(216 6) : error C3861: 'stream': identifier not found, even with argument-dependent lookup
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Flat.h(216 6) : error C2065: 'metafile' : undeclared identifier
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Flat.h(216 6) : error C2275: 'Gdiplus::GpMetafile' : illegal use of this type as an expression
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus GpStubs.h( 63) : see declaration of 'Gdiplus::GpMetafile'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Flat.h(216 6) : warning C4229: anachronism used : modifiers on data are ignored
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Flat.h(216 6) : error C2078: too many initializers
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Flat.h(221 2) : error C3861: 'IStream': identifier not found, even with argument-dependent lookup
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Flat.h(221 2) : error C3861: 'stream': identifier not found, even with argument-dependent lookup
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Flat.h(221 3) : error C2275: 'HDC' : illegal use of this type as an expression
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\WinDef. h(248) : see declaration of 'HDC'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Flat.h(221 3) : error C2146: syntax error : missing ')' before identifier 'referenceHdc'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Flat.h(221 3) : warning C4229: anachronism used : modifiers on data are ignored
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Flat.h(221 3) : error C2078: too many initializers
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Flat.h(221 3) : error C2275: 'HDC' : illegal use of this type as an expression
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\WinDef. h(248) : see declaration of 'HDC'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Flat.h(221 9) : error C2059: syntax error : ')'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Flat.h(222 3) : error C3861: 'IStream': identifier not found, even with argument-dependent lookup
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Flat.h(222 3) : error C3861: 'stream': identifier not found, even with argument-dependent lookup
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Flat.h(222 4) : error C2275: 'HDC' : illegal use of this type as an expression
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\WinDef. h(248) : see declaration of 'HDC'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Flat.h(222 4) : error C2146: syntax error : missing ')' before identifier 'referenceHdc'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Flat.h(222 4) : warning C4229: anachronism used : modifiers on data are ignored
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Flat.h(222 4) : error C2078: too many initializers
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Flat.h(222 4) : error C2275: 'HDC' : illegal use of this type as an expression
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\WinDef. h(248) : see declaration of 'HDC'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus Flat.h(223 0) : error C2059: syntax error : ')'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus MetaFile.h (80) : error C2143: syntax error : missing ')' before '*'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus MetaFile.h (80) : error C2143: syntax error : missing ';' before '*'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus MetaFile.h (80) : error C2460: 'Gdiplus::Metafile::IStrea m' : uses 'Gdiplus::Metafile', which is being defined
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus MetaFile.h (18) : see declaration of 'Gdiplus::Metafile'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus MetaFile.h (80) : error C2059: syntax error : ')'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus MetaFile.h (80) : error C2501: 'Gdiplus::Metafile::stream ' : missing storage-class or type specifiers
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus MetaFile.h (82) : error C2864: 'metafile' : only const static integral data members can be initialized inside a class or struct
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus MetaFile.h (85) : error C2327: 'Gdiplus::Metafile::metafi le' : is not a type name, static, or enumerator
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus MetaFile.h (84) : error C3861: 'stream': identifier not found, even with argument-dependent lookup
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus MetaFile.h (85) : error C3861: 'metafile': identifier not found, even with argument-dependent lookup
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus MetaFile.h (85) : error C2864: 'lastResult' : only const static integral data members can be initialized inside a class or struct
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus MetaFile.h (85) : error C2501: 'Gdiplus::Metafile::lastRe sult' : missing storage-class or type specifiers
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus MetaFile.h (87) : error C2061: syntax error : identifier 'metafile'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus MetaFile.h (87) : warning C4183: 'SetNativeImage': missing return type; assumed to be a member function returning 'int'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus MetaFile.h (100) : error C2065: 'lastResult' : undeclared identifier
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus MetaFile.h (104) : error C3861: 'SetNativeImage': identifier not found, even with argument-dependent lookup
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus MetaFile.h (119) : error C3861: 'lastResult': identifier not found, even with argument-dependent lookup
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus MetaFile.h (123) : error C3861: 'SetNativeImage': identifier not found, even with argument-dependent lookup
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus MetaFile.h (124) : warning C4508: 'Gdiplus::Metafile' : function should return a value; 'void' return type assumed
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus MetaFile.h (138) : error C3861: 'lastResult': identifier not found, even with argument-dependent lookup
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus MetaFile.h (142) : error C3861: 'SetNativeImage': identifier not found, even with argument-dependent lookup
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu de\GdiPlus MetaFile.h (142) : fatal error C1003: error count exceeds 100; stopping compilation
hook.cpp
c:\Documents and Settings\Ryan Ross\Desktop\capture\hook\ hookpaint. h(37) : error C2146: syntax error : missing ';' before identifier 'SapphireSwap'
c:\Documents and Settings\Ryan Ross\Desktop\capture\hook\ hookpaint. h(37) : error C2501: 'SapphireData::Bitmap' : missing storage-class or type specifiers
c:\Documents and Settings\Ryan Ross\Desktop\capture\hook\ hookpaint. h(37) : error C2501: 'SapphireData::SapphireSwa p' : missing storage-class or type specifiers
Generating Code...
Build log was saved at "file://c:\Documents and Settings\Ryan Ross\Desktop\capture\hook\ Debug\Buil dLog.htm"
hook - 105 error(s), 10 warning(s)
------ Build started: Project: hooktest, Configuration: Debug Win32 ------
hooktest - up-to-date.
---------------------- Done ----------------------
Build: 1 succeeded, 1 failed, 0 skipped
Compiling...
hookpaint.cpp
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Inclu
hook.cpp
c:\Documents and Settings\Ryan Ross\Desktop\capture\hook\
c:\Documents and Settings\Ryan Ross\Desktop\capture\hook\
c:\Documents and Settings\Ryan Ross\Desktop\capture\hook\
Generating Code...
Build log was saved at "file://c:\Documents and Settings\Ryan Ross\Desktop\capture\hook\
hook - 105 error(s), 10 warning(s)
------ Build started: Project: hooktest, Configuration: Debug Win32 ------
hooktest - up-to-date.
---------------------- Done ----------------------
Build: 1 succeeded, 1 failed, 0 skipped
What type is Bitmap? And what is the definition of Bitmap::FromHBITMAP? It looks a bit like CBitmap but not really.
this surely got nothing to do with the errors you mentioned,
but by the way,
remember that you can never write objects or handles to shared memory properly,
because these will have othere adresses/values in other processes,
you there will need duplicatehandle and only be able to write your bitmaps binary data and such
but by the way,
remember that you can never write objects or handles to shared memory properly,
because these will have othere adresses/values in other processes,
you there will need duplicatehandle and only be able to write your bitmaps binary data and such
From the errors it seems that either some header file(s) are missing or you need to make some defines before including GDI+ headers.
Can you show hookpaint.h and hookpaint.cpp. Mainly the include lines at the top are of interest.
Can you show hookpaint.h and hookpaint.cpp. Mainly the include lines at the top are of interest.
ASKER
// Copyright (C) 2000-2004 by Feng Yuan (www.fengyuan.com)
//hookpaint.h
class CPaintHook
{
BYTE m_thunk[9];
WNDPROC m_OldWndProc;
HDC m_hDC;
HWND m_hWnd;
static HDC WINAPI MyBeginPaint(HWND hWnd, LPPAINTSTRUCT lpPaint);
static BOOL WINAPI MyEndPaint(HWND hWnd, LPPAINTSTRUCT lpPaint);
virtual LRESULT WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
public:
bool Within_WM_PRINT(void) const
{
if ( IsBadWritePtr((void *) this, sizeof(CPaintHook)) )
return false;
if ( (m_thunk[0]==0xB9) && ((* (unsigned *) (m_thunk+5))==0x20FF018B) )
return m_hDC !=0;
else
return false;
}
CPaintHook(void);
~CPaintHook();
void SubClass(HWND hWnd);
};
struct SapphireData
{
Bitmap SapphireSwap;
};
void CaptureWindow(HWND hWnd);
void HookWindow2(HWND hWnd);
void UpdateWindow2();
void DestroyWindow2();
// Copyright (C) 2000-2004 by Feng Yuan (www.fengyuan.com)
//hookpaint.cpp
#include "stdafx.h"
#include <assert.h>
#include <gdiplus.h>
#include "hookpaint.h"
#pragma warning(disable : 4311 4312)
bool Hook(const TCHAR * module, const TCHAR * proc, unsigned & syscall_id, BYTE * & pProc, const void * pNewProc)
{
HINSTANCE hMod = GetModuleHandle(module);
pProc = (BYTE *) GetProcAddress(hMod, proc);
if (pProc[0] == 0xB8)
{
syscall_id = * (unsigned *) (pProc + 1);
DWORD flOldProtect;
VirtualProtect(pProc, 5, PAGE_EXECUTE_READWRITE, & flOldProtect);
pProc[0] = 0xE9;
* (unsigned *) (pProc+1) = (unsigned)pNewProc - (unsigned) (pProc+5);
pProc += 5;
return true;
}
else
{
return false;
}
}
static unsigned syscall_BeginPaint = 0;
static BYTE * pBeginPaint = NULL;
static unsigned syscall_EndPaint = 0;
static BYTE * pEndPaint = NULL;
LRESULT CPaintHook::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
assert(m_OldWndProc);
if (uMsg == WM_PRINTCLIENT)
{
m_hDC = (HDC) wParam;
uMsg = WM_PAINT;
}
LRESULT hRslt = CallWindowProc(m_OldWndPro c, hWnd, uMsg, wParam, lParam);
m_hDC = NULL;
return hRslt;
}
HDC WINAPI CPaintHook::MyBeginPaint(H WND hWnd, LPPAINTSTRUCT lpPaint)
{
const CPaintHook * pThis = (CPaintHook *) GetWindowLong(hWnd, GWL_WNDPROC);
pThis = (const CPaintHook *) ( (unsigned) pThis - (unsigned) & pThis->m_thunk[0] + (unsigned) pThis );
if (pThis->Within_WM_PRINT())
{
memset(lpPaint, 0, sizeof(PAINTSTRUCT));
lpPaint->hdc = pThis->m_hDC;
GetClientRect(hWnd, & lpPaint->rcPaint);
return pThis->m_hDC;
}
else
{
__asm mov eax, syscall_BeginPaint
__asm push lpPaint
__asm push hWnd
__asm call pBeginPaint
}
}
BOOL WINAPI CPaintHook::MyEndPaint(HWN D hWnd, LPPAINTSTRUCT lpPaint)
{
const CPaintHook * pThis = (CPaintHook *) GetWindowLong(hWnd, GWL_WNDPROC);
pThis = (const CPaintHook *) ( (unsigned) pThis - (unsigned) & pThis->m_thunk[0] + (unsigned) pThis );
if (pThis->Within_WM_PRINT())
{
return TRUE;
}
else
{
__asm mov eax, syscall_EndPaint
__asm push lpPaint
__asm push hWnd
__asm call pEndPaint
}
}
CPaintHook::CPaintHook()
{
static bool s_hooked = false;
if ( ! s_hooked )
{
Hook("USER32.DLL", "BeginPaint", syscall_BeginPaint, pBeginPaint, MyBeginPaint);
Hook("USER32.DLL", "EndPaint", syscall_EndPaint, pEndPaint, MyEndPaint);
s_hooked = true;
}
m_thunk[0] = 0xB9; // mov ecx,
*((DWORD *)(m_thunk+1)) = (DWORD) this; // this
*((DWORD *)(m_thunk+5)) = 0x20FF018B; // mov eax, [ecx]
m_OldWndProc = NULL;
m_hDC = NULL;
m_hWnd = NULL;
}
void CPaintHook::SubClass(HWND hWnd)
{
m_hWnd = hWnd;
m_OldWndProc = (WNDPROC) GetWindowLong(hWnd, GWL_WNDPROC);
SetWindowLong(hWnd, GWL_WNDPROC, (LONG) ((void *) m_thunk));
}
CPaintHook::~CPaintHook()
{
if (m_OldWndProc)
{
SetWindowLong(m_hWnd, GWL_WNDPROC, (LONG) m_OldWndProc);
}
}
////////////////////////// ////////// ////////// //////////
void CaptureWindow(HWND hWnd)
{
CPaintHook hook;
hook.SubClass(hWnd);
HDC hDCMem = CreateCompatibleDC(NULL);
RECT rect;
GetWindowRect(hWnd, & rect);
HBITMAP hBmp = NULL;
{
HDC hDC = GetDC(hWnd);
hBmp = CreateCompatibleBitmap(hDC , rect.right - rect.left, rect.bottom - rect.top);
ReleaseDC(hWnd, hDC);
}
HGDIOBJ hOld = SelectObject(hDCMem, hBmp);
SendMessage(hWnd, WM_PRINT, (WPARAM) hDCMem, PRF_CHILDREN | PRF_CLIENT | PRF_ERASEBKGND | PRF_NONCLIENT | PRF_OWNED);
SelectObject(hDCMem, hOld);
DeleteObject(hDCMem);
OpenClipboard(hWnd);
EmptyClipboard();
SetClipboardData(CF_BITMAP , hBmp);
CloseClipboard();
}
HWND hWnd = NULL;
HBITMAP hBmp = NULL;
HGDIOBJ hOld = NULL;
HDC hDCMem = NULL;
HANDLE hMap = NULL;
SapphireData* SapphireData;
HANDLE hSapphireData = NULL;
void* SapphireDataMap = NULL;
CPaintHook hook;
void HookWindow2(HWND hWnd)
{
hMap = CreateFileMapping(INVALID_ HANDLE_VAL UE, // current file handle
NULL, // default security
PAGE_READWRITE, // read/write permission
0, // max. object size
0, // size of hFile
"SapphireFSwap"); // name of mapping object
if (hMap != NULL && GetLastError() == ERROR_ALREADY_EXISTS)
{
CloseHandle(hMap);
hMap = NULL;
}
if (hMap != NULL)
{
CloseHandle(hMap);
hMap = NULL;
}
SapphireDataMap = OpenFileMapping(FILE_MAP_A LL_ACCESS, false, "SapphireFSwap");
if (SapphireDataMap != NULL)
{
hSapphireData = MapViewOfFile(hMap, FILE_MAP_ALL_ACCESS, 0, 0, 0);
}
if (hSapphireData != NULL)
{
SapphireData = (struct SapphireData*)hSapphireDat a;
}
hook.SubClass(hWnd);
hDCMem = CreateCompatibleDC(NULL);
RECT rect;
GetWindowRect(hWnd, & rect);
hBmp = NULL;
{
HDC hDC = GetDC(hWnd);
hBmp = CreateCompatibleBitmap(hDC , rect.right - rect.left, rect.bottom - rect.top);
ReleaseDC(hWnd, hDC);
}
hOld = SelectObject(hDCMem, hBmp);
}
void UpdateWindow2()
{
SendMessage(hWnd, WM_PRINT, (WPARAM) hDCMem, PRF_CHILDREN | PRF_CLIENT | PRF_ERASEBKGND | PRF_NONCLIENT | PRF_OWNED);
SapphireData->SapphireSwap = Bitmap::FromHBITMAP(hBmp, CPalette::operator HPALETTE);
}
void DestroyWindow2()
{
SelectObject(hDCMem, hOld);
DeleteObject(hDCMem);
/*
OpenClipboard(hWnd);
EmptyClipboard();
SetClipboardData(CF_BITMAP , hBmp);
CloseClipboard();
*/
if (hSapphireData)
{
UnmapViewOfFile(hSapphireD ata);
SapphireData = NULL;
}
CloseHandle(SapphireDataMa p);
}
//hook.cpp
// hook.cpp : Defines the entry point for the DLL application.
//
#include "stdafx.h"
#include "hookpaint.h"
// Shared Data
#pragma data_seg("Shared")
HHOOK h_WndProcHook = NULL;
#pragma data_seg()
HINSTANCE hInstance;
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
hInstance = (HINSTANCE) hModule;
return TRUE;
}
LRESULT CALLBACK CallWndProc(int nCode, WPARAM wParam, LPARAM lParam)
{
CWPRETSTRUCT * pInfo = (CWPRETSTRUCT *) (lParam - 4);
if ((pInfo != NULL) && (pInfo->message == WM_USER) && (pInfo->lParam == 130869856))
{
CaptureWindow(pInfo->hwnd) ;
}
else if ((pInfo != NULL) && (pInfo->message == WM_USER) && (pInfo->lParam == 130869857)) {
HookWindow2(pInfo->hwnd);
}
else if ((pInfo != NULL) && (pInfo->message == WM_USER) && (pInfo->lParam == 130869858)) {
UpdateWindow2();
}
else if ((pInfo != NULL) && (pInfo->message == WM_USER) && (pInfo->lParam == 130869859)) {
DestroyWindow2();
}
if (h_WndProcHook)
{
return CallNextHookEx(h_WndProcHo ok, nCode, wParam, lParam);
}
else
{
return 0;
}
}
void _declspec(dllexport) InstallHook(void)
{
h_WndProcHook = SetWindowsHookEx(WH_CALLWN DPROC, (HOOKPROC) CallWndProc, hInstance, 0);
}
//hookpaint.h
class CPaintHook
{
BYTE m_thunk[9];
WNDPROC m_OldWndProc;
HDC m_hDC;
HWND m_hWnd;
static HDC WINAPI MyBeginPaint(HWND hWnd, LPPAINTSTRUCT lpPaint);
static BOOL WINAPI MyEndPaint(HWND hWnd, LPPAINTSTRUCT lpPaint);
virtual LRESULT WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
public:
bool Within_WM_PRINT(void) const
{
if ( IsBadWritePtr((void *) this, sizeof(CPaintHook)) )
return false;
if ( (m_thunk[0]==0xB9) && ((* (unsigned *) (m_thunk+5))==0x20FF018B) )
return m_hDC !=0;
else
return false;
}
CPaintHook(void);
~CPaintHook();
void SubClass(HWND hWnd);
};
struct SapphireData
{
Bitmap SapphireSwap;
};
void CaptureWindow(HWND hWnd);
void HookWindow2(HWND hWnd);
void UpdateWindow2();
void DestroyWindow2();
// Copyright (C) 2000-2004 by Feng Yuan (www.fengyuan.com)
//hookpaint.cpp
#include "stdafx.h"
#include <assert.h>
#include <gdiplus.h>
#include "hookpaint.h"
#pragma warning(disable : 4311 4312)
bool Hook(const TCHAR * module, const TCHAR * proc, unsigned & syscall_id, BYTE * & pProc, const void * pNewProc)
{
HINSTANCE hMod = GetModuleHandle(module);
pProc = (BYTE *) GetProcAddress(hMod, proc);
if (pProc[0] == 0xB8)
{
syscall_id = * (unsigned *) (pProc + 1);
DWORD flOldProtect;
VirtualProtect(pProc, 5, PAGE_EXECUTE_READWRITE, & flOldProtect);
pProc[0] = 0xE9;
* (unsigned *) (pProc+1) = (unsigned)pNewProc - (unsigned) (pProc+5);
pProc += 5;
return true;
}
else
{
return false;
}
}
static unsigned syscall_BeginPaint = 0;
static BYTE * pBeginPaint = NULL;
static unsigned syscall_EndPaint = 0;
static BYTE * pEndPaint = NULL;
LRESULT CPaintHook::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
assert(m_OldWndProc);
if (uMsg == WM_PRINTCLIENT)
{
m_hDC = (HDC) wParam;
uMsg = WM_PAINT;
}
LRESULT hRslt = CallWindowProc(m_OldWndPro
m_hDC = NULL;
return hRslt;
}
HDC WINAPI CPaintHook::MyBeginPaint(H
{
const CPaintHook * pThis = (CPaintHook *) GetWindowLong(hWnd, GWL_WNDPROC);
pThis = (const CPaintHook *) ( (unsigned) pThis - (unsigned) & pThis->m_thunk[0] + (unsigned) pThis );
if (pThis->Within_WM_PRINT())
{
memset(lpPaint, 0, sizeof(PAINTSTRUCT));
lpPaint->hdc = pThis->m_hDC;
GetClientRect(hWnd, & lpPaint->rcPaint);
return pThis->m_hDC;
}
else
{
__asm mov eax, syscall_BeginPaint
__asm push lpPaint
__asm push hWnd
__asm call pBeginPaint
}
}
BOOL WINAPI CPaintHook::MyEndPaint(HWN
{
const CPaintHook * pThis = (CPaintHook *) GetWindowLong(hWnd, GWL_WNDPROC);
pThis = (const CPaintHook *) ( (unsigned) pThis - (unsigned) & pThis->m_thunk[0] + (unsigned) pThis );
if (pThis->Within_WM_PRINT())
{
return TRUE;
}
else
{
__asm mov eax, syscall_EndPaint
__asm push lpPaint
__asm push hWnd
__asm call pEndPaint
}
}
CPaintHook::CPaintHook()
{
static bool s_hooked = false;
if ( ! s_hooked )
{
Hook("USER32.DLL", "BeginPaint", syscall_BeginPaint, pBeginPaint, MyBeginPaint);
Hook("USER32.DLL", "EndPaint", syscall_EndPaint, pEndPaint, MyEndPaint);
s_hooked = true;
}
m_thunk[0] = 0xB9; // mov ecx,
*((DWORD *)(m_thunk+1)) = (DWORD) this; // this
*((DWORD *)(m_thunk+5)) = 0x20FF018B; // mov eax, [ecx]
m_OldWndProc = NULL;
m_hDC = NULL;
m_hWnd = NULL;
}
void CPaintHook::SubClass(HWND hWnd)
{
m_hWnd = hWnd;
m_OldWndProc = (WNDPROC) GetWindowLong(hWnd, GWL_WNDPROC);
SetWindowLong(hWnd, GWL_WNDPROC, (LONG) ((void *) m_thunk));
}
CPaintHook::~CPaintHook()
{
if (m_OldWndProc)
{
SetWindowLong(m_hWnd, GWL_WNDPROC, (LONG) m_OldWndProc);
}
}
//////////////////////////
void CaptureWindow(HWND hWnd)
{
CPaintHook hook;
hook.SubClass(hWnd);
HDC hDCMem = CreateCompatibleDC(NULL);
RECT rect;
GetWindowRect(hWnd, & rect);
HBITMAP hBmp = NULL;
{
HDC hDC = GetDC(hWnd);
hBmp = CreateCompatibleBitmap(hDC
ReleaseDC(hWnd, hDC);
}
HGDIOBJ hOld = SelectObject(hDCMem, hBmp);
SendMessage(hWnd, WM_PRINT, (WPARAM) hDCMem, PRF_CHILDREN | PRF_CLIENT | PRF_ERASEBKGND | PRF_NONCLIENT | PRF_OWNED);
SelectObject(hDCMem, hOld);
DeleteObject(hDCMem);
OpenClipboard(hWnd);
EmptyClipboard();
SetClipboardData(CF_BITMAP
CloseClipboard();
}
HWND hWnd = NULL;
HBITMAP hBmp = NULL;
HGDIOBJ hOld = NULL;
HDC hDCMem = NULL;
HANDLE hMap = NULL;
SapphireData* SapphireData;
HANDLE hSapphireData = NULL;
void* SapphireDataMap = NULL;
CPaintHook hook;
void HookWindow2(HWND hWnd)
{
hMap = CreateFileMapping(INVALID_
NULL, // default security
PAGE_READWRITE, // read/write permission
0, // max. object size
0, // size of hFile
"SapphireFSwap"); // name of mapping object
if (hMap != NULL && GetLastError() == ERROR_ALREADY_EXISTS)
{
CloseHandle(hMap);
hMap = NULL;
}
if (hMap != NULL)
{
CloseHandle(hMap);
hMap = NULL;
}
SapphireDataMap = OpenFileMapping(FILE_MAP_A
if (SapphireDataMap != NULL)
{
hSapphireData = MapViewOfFile(hMap, FILE_MAP_ALL_ACCESS, 0, 0, 0);
}
if (hSapphireData != NULL)
{
SapphireData = (struct SapphireData*)hSapphireDat
}
hook.SubClass(hWnd);
hDCMem = CreateCompatibleDC(NULL);
RECT rect;
GetWindowRect(hWnd, & rect);
hBmp = NULL;
{
HDC hDC = GetDC(hWnd);
hBmp = CreateCompatibleBitmap(hDC
ReleaseDC(hWnd, hDC);
}
hOld = SelectObject(hDCMem, hBmp);
}
void UpdateWindow2()
{
SendMessage(hWnd, WM_PRINT, (WPARAM) hDCMem, PRF_CHILDREN | PRF_CLIENT | PRF_ERASEBKGND | PRF_NONCLIENT | PRF_OWNED);
SapphireData->SapphireSwap
}
void DestroyWindow2()
{
SelectObject(hDCMem, hOld);
DeleteObject(hDCMem);
/*
OpenClipboard(hWnd);
EmptyClipboard();
SetClipboardData(CF_BITMAP
CloseClipboard();
*/
if (hSapphireData)
{
UnmapViewOfFile(hSapphireD
SapphireData = NULL;
}
CloseHandle(SapphireDataMa
}
//hook.cpp
// hook.cpp : Defines the entry point for the DLL application.
//
#include "stdafx.h"
#include "hookpaint.h"
// Shared Data
#pragma data_seg("Shared")
HHOOK h_WndProcHook = NULL;
#pragma data_seg()
HINSTANCE hInstance;
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
hInstance = (HINSTANCE) hModule;
return TRUE;
}
LRESULT CALLBACK CallWndProc(int nCode, WPARAM wParam, LPARAM lParam)
{
CWPRETSTRUCT * pInfo = (CWPRETSTRUCT *) (lParam - 4);
if ((pInfo != NULL) && (pInfo->message == WM_USER) && (pInfo->lParam == 130869856))
{
CaptureWindow(pInfo->hwnd)
}
else if ((pInfo != NULL) && (pInfo->message == WM_USER) && (pInfo->lParam == 130869857)) {
HookWindow2(pInfo->hwnd);
}
else if ((pInfo != NULL) && (pInfo->message == WM_USER) && (pInfo->lParam == 130869858)) {
UpdateWindow2();
}
else if ((pInfo != NULL) && (pInfo->message == WM_USER) && (pInfo->lParam == 130869859)) {
DestroyWindow2();
}
if (h_WndProcHook)
{
return CallNextHookEx(h_WndProcHo
}
else
{
return 0;
}
}
void _declspec(dllexport) InstallHook(void)
{
h_WndProcHook = SetWindowsHookEx(WH_CALLWN
}
ASKER
Modifications are made for shared memory, updates instead of captures, etc.
Now stdafx.h content seems to miss some defnitions needed for GDI+: MIDL_INTERFACE is not defined.
And:
GDI+ provides a few functions that are not part of any class. Two of those functions are GdiplusStartup and GdiplusShutdown. You must call GdiplusStartup before you make any other GDI+ calls, and you must call GdiplusShutdown when you have finished using GDI+.
A good place for this would be in DLLMain. Have a static int there to count the number of process attaches and subtract the number of process detaches. If there during attach call GdiplusStartup and if if 0 during detach call ~Shutdown.
And:
GDI+ provides a few functions that are not part of any class. Two of those functions are GdiplusStartup and GdiplusShutdown. You must call GdiplusStartup before you make any other GDI+ calls, and you must call GdiplusShutdown when you have finished using GDI+.
A good place for this would be in DLLMain. Have a static int there to count the number of process attaches and subtract the number of process detaches. If there during attach call GdiplusStartup and if if 0 during detach call ~Shutdown.
ASKER
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#pragma once
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
// Windows Header Files:
#include <windows.h>
// TODO: reference additional headers your program requires here
Ok, implementing GdiplusStartup.
// or project specific include files that are used frequently, but
// are changed infrequently
//
#pragma once
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
// Windows Header Files:
#include <windows.h>
// TODO: reference additional headers your program requires here
Ok, implementing GdiplusStartup.
ASKER
But, if it is calling a static method...
Should I create a new Bitmap, use the Bitmap.FromHBITMAP() method, copy the new bitmap into the structure, then axe the new Bitmap?
I mean, it is creating a new Bitmap from the static method, but there really isn't any inbetween.
Should I create a new Bitmap, use the Bitmap.FromHBITMAP() method, copy the new bitmap into the structure, then axe the new Bitmap?
I mean, it is creating a new Bitmap from the static method, but there really isn't any inbetween.
ASKER
And then there is this:
Do not call GdiplusStartup or GdiplusShutdown in DllMain or in any function that is called by DllMain. If you want to create a dynamic-link library (DLL) that uses GDI+, you should use one of the following techniques to initialize GDI+:
from the MSDN library.
Do not call GdiplusStartup or GdiplusShutdown in DllMain or in any function that is called by DllMain. If you want to create a dynamic-link library (DLL) that uses GDI+, you should use one of the following techniques to initialize GDI+:
from the MSDN library.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hmm, good enough. I'll repost with a new question.