AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
Ipicture regina voss8/13/2023 ![]() It allows to call the original function as if there was no the interception. After that, a temporary buffer is allocated (with the permissions to execute data) into which these instructions JMP (to the instruction following to the rewritable one) will be copied. When the Hook method is called the length disassembler calculates the integer number of instructions which will be overwritten by the JMP instruction (5 bytes). ![]() Since the beginning of the original function contains instructions which we overwrite, it is necessary to correctly transfer the instructions in order to be able to call the original function. In that method the JMP instruction is inserted at the beginning of the function which transfers the execution flow to the interceptor function. To intercept a function, the simplest method is used - splicing. The modification is to add the OP_RE元2 flag to some instructions (for example, JMP SHORT), since this flag was missing in the original one in some relative instructions. This class uses the length disassembler (ldasm) from Ms-Rem with a slight revision. The function interceptor is implemented in the CHooker class. When VB6-runtime loads a picture from the PropertyBag it firstly creates the object based on CLSID saved in that storage ( IPersist::GetClassID) and then initializes it using IPersistStream::Load. It's neccesary in order to create image objects unsing CoCreateInstance function especially when you load a image from PropertyBag (or other storages). It initializes COM, GDI , installs hooks and registers the Image-COM server. This function initializes the data needed to work with module. To use the library you need to call the Initialize function. The object supports IPicture, IPictureDisp, IPersistStream, IConnectionPointContainer (does not support connection point returns E_NOTIMPL), IDispatch interfaces, so it can be assigned to an Object variable or, for example, stored in a PropertyBag. For the caller it looks like it works with the original object. If successful, a similar StdPicture object is created and is returned by the function. ![]() These functions don't support such images, so if a file is loaded, the VbPng library attempts to load the file using GDI or USER32 (depending on the image type). The principle of the library is based on the interception of OleLoadPictureEx, OleLoadPicture and OleIconToCursor functions. In the DLL, in the compiled form it is necessary to do initialization by calling the Initialize function from itself at the start. \Libs\VBPng.lib -ENTRY:VBDllMain -EXPORT:Initialize -EXPORT:Uninitialize Private Declare Function Initialize Lib "VBPng.dll" () As Long Private Declare Sub Uninitialize Lib "VBPng.dll" () Private Sub Form_Initialize() If Initialize() = 0 Then MsgBox "Unable to initialize png dll", vbCritical End If End Sub Private Sub Form_Terminate() Uninitialize End Subįor static linking, you need to use a newer linker (in my examples I used the linker from Visual Studio 2010), since the original one has the bugs when using the /OPT:REF option and also you need to add this parameters in the VBCompiler section of the project file (vbp): In the compiled version, for example, you can call the Initialize function in the Initialize event or in the Main procedure, and Uninaitilze function at the end of the code: For IDE, a special Add-in was created that automatically loads the library when the environment starts. If the function returns S_FALSE, the library can't be unloaded because there are the active Picture objects that aren't yet unloaded and they use the library. If the library is ready for unloading, the function will return S_OK after which you need to call Uninitialize. If you need to unload the library, then you need to call the function CanUnloadNow which tells you whether it is possible to unload the library at the moment. After that, you can use the library features. ![]() To use it as the Dll, you must call the Initialize function which returns 1 if successful. The library can be used as an external DLL or to be linked to an executable file (native code only). This library should work in all the versions of Windows since XP: In turn, if an image is displayed via IPicture::Render then the image will be drawn with the alpha channel. Any control that uses standard Ole Picture objects will support Png images. This library allows you to load and save that images (with the alpha channel) by the standard functions ( LoadPicture / SavePicture), and also gives the ability to use these images (with the alpha channel) in the controls. I present a small library and an add-in which allow you to bypass these limitations. for example, you can't use a Png image as the Form.Picture property. The built-in functions in Visual Basic 6.0 doesn't support the ability to work with PNG images, 32bpp icons and cursors, animated cursors, i.e.
0 Comments
Read More
Leave a Reply. |