Hook drawing method and device for Qt interface program based on WindML under VxWorks system

By obtaining the memory addresses of the fill and block transfer functions in the WindML library of the Qt framework under the VxWorks system, and constructing the target function to implement the drawing hook, the problem of low efficiency in troubleshooting Qt interface programs is solved, and it is suitable for stable operation of embedded devices.

CN121579004APending Publication Date: 2026-02-27TIANJIN JINHANG COMP TECH RES INST
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511737105.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-25
Publication Date
2026-02-27

AI Technical Summary

Technical Problem

Under the VxWorks system, existing technologies cannot implement drawing hooks for Qt interface programs without modifying the Qt framework source code, resulting in low troubleshooting efficiency and difficulty in meeting the stable operation requirements of embedded devices.

Method used

By obtaining the memory addresses of the fill function and block transfer function executed through the WindML library in the Qt framework, a target function is constructed to implement the drawing hook, including determining the offsets of the screen management class and the private screen drawing class, and replacing the function pointer to implement listening.

Benefits of technology

It implements drawing hooks without modifying the Qt framework source code, ensuring the effectiveness and integrity of listening, improving troubleshooting efficiency, adapting to embedded environments, and ensuring fault location in human-computer interaction interfaces.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121579004A_ABST
    Figure CN121579004A_ABST
Patent Text Reader

Abstract

The invention provides a Hook drawing method and device for a Qt interface program based on WindML under a VxWorks system. The method comprises the steps that a filling function and a block transfer function which execute a drawing action through a WindML library in a Qt frame are obtained; wherein the filling function is used for performing color filling on a preset area, and the block transfer function is used for performing image data drawing on the preset area; determining a first objective function according to the filling function, and determining a second objective function according to the block transfer function; and determining a target drawing Hook function according to the first target function and / or the second target function. According to the method and the device provided by the invention, monitoring on the drawing action of the Qt interface program can be realized on the premise of not modifying the source code of the Qt framework.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application generally relates to the technical field of embedded software development, and particularly relates to a Qt interface program drawing Hook method and device based on WindML under a VxWorks system. BACKGROUND

[0002] In the process of embedded software development, Qt framework is a widely used cross-platform interface program development framework, and is also an important carrier for implementing human-computer interaction functions of embedded devices. The interface program developed based on the framework is usually referred to as a Qt interface program.

[0003] Embedded devices, such as embedded devices in a VxWorks operating system, often need to work in a relatively harsh environment, and various faults may occur during running. When a Qt interface program fails, such as interface freezing, it is necessary to accurately determine whether the fault root cause is abnormal drawing running of the upper layer of the Qt interface program or abnormal execution of the lower layer of the graphics drawing driver. To achieve this determination, the core requirement is to listen to the graphics drawing action of the Qt interface program, which is referred to as drawing Hook in the technical field.

[0004] However, on the one hand, the existing Qt framework and multimedia libraries in the operating system, such as the WindML library (Wind Media Library) in the VxWorks operating system, usually do not provide a drawing Hook interface that can be directly called by users, and key parameters in the drawing process cannot be directly obtained. On the other hand, in actual development scenarios, users often cannot self-make a drawing Hook interface by modifying the source code of the Qt framework, for example, users may not be able to obtain the source code of the Qt framework corresponding to a binary file, or are restricted by software management regulations from customizing the Qt framework at will. The above problems lead to low troubleshooting efficiency of Qt interface programs, and it is difficult to meet the stable running requirements of embedded devices.

[0005] Therefore, how to realize a drawing Hook method of a Qt interface program based on a WindML library under a VxWorks system without modifying the source code of the Qt framework is a technical problem to be solved by the present application. SUMMARY

[0006] In view of the above defects or deficiencies in the prior art, it is desirable to provide a Qt interface program drawing Hook method and device based on WindML under a VxWorks system to solve the above problems.

[0007] The present application provides a Qt interface program drawing Hook method based on WindML under a VxWorks system, which comprises: Obtain the fill function and block transfer function in the Qt framework that perform drawing actions through the WindML library; the fill function is used to fill a preset area with color, and the block transfer function is used to draw image data in the preset area; The first objective function is determined based on the filling function, and the second objective function is determined based on the block transfer function; The target drawing Hook function is determined based on the first objective function and / or the second objective function.

[0008] According to the technical solution provided in the embodiments of this application, obtaining the fill function and block transfer function that perform drawing actions through the WindML library in the Qt framework includes: Determine the first memory address of the fill function and the second memory address of the block transfer function; The padding function is obtained based on the first memory address, and the block transfer function is obtained based on the second memory address.

[0009] According to the technical solution provided in the embodiments of this application, determining the first memory address of the fill function and the second memory address of the block transfer function includes: The screen management class and screen drawing private class in the Qt framework are determined based on the parameter characteristics corresponding to the fill function and the block transfer function, respectively, and the preset call dependency relationship. Determine the global variables corresponding to instances of the screen management class and instances of the private screen drawing class; Obtain the offset between the memory address of the instance of the screen drawing private class and the memory address of the global variable, and determine the first memory address of the filling function and the second memory address of the block transfer function based on the offset; The screen management class represents the interface for managing screen display attributes and drawing in the Qt framework; the fill function and the block transfer function are member functions of the private screen drawing class; the screen management class contains instances of the private screen drawing class; and the memory address corresponding to the instance of the screen management class is the memory address corresponding to the global variable.

[0010] According to the technical solution provided in the embodiments of this application, determining the first memory address of the fill function and the second memory address of the block transfer function based on the offset includes: Starting from the memory address of the global variable, the memory address corresponding to the instance of the private screen drawing class is determined by the offset. Based on the member order corresponding to the fill function and the drawing function in the private screen drawing class, obtain the first offset between the fill function and the instance of the private screen drawing class, and obtain the second offset between the drawing function and the instance of the private screen drawing class. The first memory address of the filling function is determined based on the memory address of the instance of the private class drawn on the screen and the first offset, and the second memory address is determined based on the memory address of the instance of the private class drawn on the screen and the second offset.

[0011] According to the technical solution provided in the embodiments of this application, the step of determining the first target function based on the filling function and determining the second target function based on the block transfer function includes: A first target function is constructed based on the parameter structure and return value of the fill function, so that the first target function calls the fill function to fill the preset area with color, and listens for the color filling drawing action; A second target function is constructed based on the parameter structure and return value of the block transfer function, so that the second target function calls the block transfer function to draw the image data to a preset position and listens for the drawing action of the image data.

[0012] According to the technical solution provided in the embodiments of this application, determining the target drawing Hook function based on the first target function and / or the second target function includes: Replace the first memory address corresponding to the fill function with the memory address of the first target function, and replace the second memory address corresponding to the block transfer function with the memory address of the second target function; If the preset drawing requirement is to fill a preset area with color, then the first objective function is determined as the target drawing Hook function; And / or, If the preset drawing requirement is to draw image data in the preset area, then the second objective function is determined as the objective Hook function.

[0013] According to the technical solution provided in the embodiments of this application, the step of replacing the first memory address corresponding to the fill function with the memory address of the first target function, and replacing the second memory address corresponding to the block transfer function with the memory address of the second target function, includes: The function pointer corresponding to the fill function is determined as the first pointer, and the function pointer corresponding to the block transfer function is determined as the second pointer; the value of the first pointer is determined as the first memory address, and the value of the second pointer is determined as the second memory address; Allocate a new pointer storage area in memory, store the value of the first pointer in the first area of ​​the pointer storage area, and store the value of the second pointer in the second area of ​​the pointer storage area; Replace the value of the first pointer in the instance of the private screen drawing class with the value of the function pointer corresponding to the first target function, and replace the value of the second pointer in the instance of the private screen drawing class with the value of the function pointer corresponding to the second target function.

[0014] This application provides a drawing Hook device for a Qt interface program based on WindML under the VxWorks system, the device comprising: The acquisition module is used to acquire the fill function and block transfer function of Qt performing drawing actions through the WindML library; wherein, the fill function is used to fill a preset area with color, and the block transfer function is used to draw image data in the preset area; A determining module is configured to determine a first objective function based on the filling function and a second objective function based on the block transfer function; The listening module is used to determine the target drawing Hook function based on the first target function and / or the second target function.

[0015] This application provides an electronic device, including a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that, when the processor executes the computer program, it implements a drawing Hook method for a Qt interface program based on WindML under the VxWorks system as described in any of the above claims.

[0016] This application provides a computer-readable storage medium storing a computer program, characterized in that, when the computer program is executed by a processor, it implements the steps of the drawing Hook method for a Qt interface program based on WindML under a VxWorks system as described in any of the above claims.

[0017] Compared with the prior art, the beneficial effects of this application are as follows: First, by obtaining the fill function and block transfer function executed by the WindML library in the Qt framework, it is possible to directly anchor the underlying core interface of Qt drawing under the VxWorks system, ensuring that the obtained target drawing Hook function can match the underlying interaction logic of the system, avoiding the omission of listening due to the lack of WindML adaptation, and ensuring the effectiveness of listening under the VxWorks system.

[0018] Secondly, it does not require modification of the Qt framework source code. By constructing the first and second target functions, no changes are needed to any Qt framework code. This avoids the problem of not being able to customize the Hook interface due to the inability to obtain the source code or restrictions imposed by management regulations. It is compatible with existing Qt framework usage scenarios and achieves non-intrusive drawing listening.

[0019] Third, by designing target functions for the fill function and block transfer function respectively, key parameters of color fill and image data drawing actions can be recorded in a targeted manner, which can accurately monitor the graphics drawing actions of Qt interface programs and further improve the efficiency of troubleshooting.

[0020] Fourth, the method proposed in this application can be adapted to embedded environments such as VxWorks, and can monitor drawing actions through target Hook functions, thus solving the problem of difficult fault location of human-computer interaction interface of embedded devices in this environment.

[0021] Fifth, by using the target Hook function determined based on the first objective function and / or the second objective function, the normal drawing process of the Qt interface program can be maintained without interfering with the listening process, ensuring that the human-computer interaction function is not affected. Attached Figure Description

[0022] Other features, objects, and advantages of this application will become more apparent from the following detailed description of non-limiting embodiments with reference to the accompanying drawings: Figure 1 A schematic diagram of a drawing Hook method for a Qt interface program based on WindML under the VxWorks system provided in this application; Figure 2 This application provides a calling process for a drawing Hook method in a Qt interface program based on WindML under the VxWorks system. Figure 3 A schematic diagram of the drawing Hook device for a Qt interface program based on WindML under the VxWorks system provided in this application; Figure 4 A schematic block diagram of the electronic device provided in this application.

[0023] The text labels in the image represent: 310. Acquisition module; 320. Determination module; 330. Monitoring module; 400. Electronic device; 401. Processor; 402. Input device; 403. Output device; 404. Memory; 405. Communication bus. Detailed Implementation

[0024] The present application will now be described in further detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and not intended to limit it. Furthermore, it should be noted that, for ease of description, only the parts relevant to the invention are shown in the accompanying drawings.

[0025] It should be noted that, unless otherwise specified, the embodiments and features described in this application can be combined with each other. This application will now be described in detail with reference to the accompanying drawings and embodiments.

[0026] Please refer to Figure 1 This application provides a drawing Hook method for Qt interface programs based on WindML under the VxWorks system.

[0027] Step S101: Obtain the fill function and block transfer function in the Qt framework that perform drawing actions through the WindML library.

[0028] In this embodiment, the fill function and block transfer function of the drawing action in the WindML library of the Qt framework can be obtained. The corresponding operating system environment can be VxWorks or other hardware platforms that also use the WindML library. The fill function can be used to fill a preset area with color, and the block transfer function can be used to draw image data to the preset area. In the WindML library, the fill function can represent the solidFill function, and the block transfer function can represent the blit function.

[0029] In this embodiment, the first memory address of the fill function and the second memory address of the block transfer function can be determined, and then the fill function can be obtained based on the first memory address, and the block transfer function can be obtained based on the second memory address. As an example, since the fill function (solidFill) and the block transfer function (blit) are both instances of the screen drawing private class (QScreenPrivate), the first memory address of the fill function and the second memory address of the block transfer function can be determined by determining the address of the screen drawing private class. Then, the fill function can be obtained based on the first memory address, and the block transfer function can be obtained based on the second memory address.

[0030] By obtaining the fill function and block transfer function respectively, the key dependency functions when Qt interacts with the preset graphics drawing interface library can be identified, which can provide clear operation objects for subsequent drawing listening and ensure the authenticity and integrity of the listening data.

[0031] Step S102: Determine the first objective function based on the filling function, and determine the second objective function based on the block transfer function.

[0032] In this embodiment, a first target function can be determined based on a fill function, and a second target function can be determined based on a block transfer function. The first target function is used to monitor the drawing action of the fill function, and the second target function is used to monitor the drawing action of the block transfer function.

[0033] In determining the first target function, it can be constructed based on the parameter structure and return value of the fill function. For example, the first target function can have the same parameter structure and return value type as the fill function, i.e., the `solidFill` function. The parameter structure can be set to `(QScreen*, const QColor&, const QRegion&)`, meaning it contains a pointer to `QScreen`, a constant reference to `QColor`, and a constant reference to `QRegion`. The return value can be set to `void` to ensure the first target function can correctly receive the parameters of the original drawing request from the fill function. In the function logic design of the first target function, it can call the fill function through the original memory address, enabling it to perform color filling drawing on the preset area. After the drawing is completed, the first target function can extract the identifier of the `QScreen` instance involved in the drawing, the color component data corresponding to `QColor`, and the boundary coordinate information of the preset area corresponding to `QRegion`. These can be written to a pre-allocated record storage area in a preset format, such as a key-value pair of timestamp and parameter values, to achieve the monitoring and recording of the color filling drawing action.

[0034] When determining the second objective function, it can be constructed based on the parameter structure and return value of the block transfer function. For example, the second objective function can have the same parameter structure and return value as the block transfer function, i.e., the `blit` function. The parameter structure can be set to `(QScreen*, const QImage&, const QPoint&, const QRegion&)`, meaning it contains a pointer to `QScreen`, a constant reference to `QImage`, a constant reference to `QPoint`, and a constant reference to `QRegion`. The return value can be set to `void` to ensure the second objective function can correctly receive the parameters of the original drawing request from the block transfer function. In the function logic design of the second objective function, it can call the block transfer function through the original memory address, enabling it to perform drawing operations on the image data. After the drawing is completed, the second objective function can extract the identifier of the `QScreen` instance, the coordinate values ​​of the `QPoint`, the region range of the `QRegion`, and the size, pixel format, and point-by-point color data of the `QImage`, and write them to a pre-allocated record storage area to monitor and record the image data drawing operations.

[0035] The first and second objective functions determined in the above manner can not only replace the original fill function and block transfer function to receive drawing requests, but also ensure the integrity of the drawing function by calling the original function. At the same time, they can achieve precise monitoring of drawing actions, providing data support for subsequent drawing process restoration and fault analysis.

[0036] Step S103: Determine the target drawing Hook function based on the first objective function and / or the second objective function.

[0037] In this embodiment, when the Qt interface program performs a drawing action, the target drawing hook function can be determined by jointly using a first objective function and a second objective function, so that the drawing action can be monitored and the monitoring results obtained. Alternatively, the target drawing hook function can be determined by either the first objective function or the second objective function, so that the drawing action can be monitored and the monitoring results obtained. In this case, a single objective function or a combination of objective functions can be selected as the final target drawing hook function based on the actual drawing requirements of the Qt interface program under the VxWorks system, ensuring that the monitoring scope accurately matches the drawing scenario.

[0038] During the execution of a Qt GUI application, key information regarding each color fill and image drawing operation can be monitored using a target hook function, and the monitoring results can be obtained. In this way, the drawing process of the Qt program can be completely reconstructed, providing data support for subsequently distinguishing between upper-level drawing logic exceptions and lower-level driver exceptions.

[0039] In one embodiment of this application, determining the first memory address of the fill function and the second memory address of the block transfer function includes: determining a screen management class and a private screen drawing class in the Qt framework based on the parameter characteristics corresponding to the fill function and the block transfer function, respectively, and a preset call dependency relationship; obtaining the global variable corresponding to the instance of the screen management class and the instance of the private screen drawing class; obtaining the offset between the memory address corresponding to the instance of the private screen drawing class and the memory address of the global variable, and determining the first memory address of the fill function and the second memory address of the block transfer function based on the offset. Wherein, the screen management class is used to represent the interface in the Qt framework that manages screen display attributes and drawing; the fill function and the block transfer function are respectively member functions of the private screen drawing class; the screen management class contains instances of the private screen drawing class; and the memory address corresponding to the instance of the screen management class is the memory address corresponding to the global variable.

[0040] In this embodiment, the parameter characteristics corresponding to the fill function and the block transfer function can be analyzed. The fill function, namely the solidFill function, contains a pointer of type QScreen, a constant reference of type QColor, and a constant reference of type QRegion. The block transfer function, namely the blit function, contains parameters such as a pointer of type QScreen and a constant reference of type QImage. Through the parameter characteristics, it can be determined that the parameters of the fill function and the block transfer function both have the same pointer of type QScreen. Combined with the preset calling dependency relationship in the Qt framework that "screen drawing operations need to rely on the display property interface provided by the QScreen class", it can be determined that the screen management class is the QScreen class. Since private classes in the Qt framework are usually responsible for encapsulating the underlying drawing logic and have an inclusion relationship with the management class, it can be further determined that the screen drawing private class responsible for the specific drawing implementation is the QScreenPrivate class based on the member variables in the QScreen class.

[0041] In this embodiment, the global variable corresponding to the screen management class instance and the instance of the QScreenPrivate class can be determined. This global variable can be represented by qt_screen, meaning its memory address directly corresponds to the memory address of the QScreen class instance. Since the QScreenPrivate class is a private member of the QScreen class, and instances of the QScreenPrivate class are stored within the QScreen class, the memory address of the QScreenPrivate class instance can be determined by the offset between its memory address and that of qt_screen. Because the solidFill and blit functions are stored as function pointers at the beginning of the QScreenPrivate class instance, the first memory address of the fill function and the second memory address of the block transfer function can be further determined using the memory address of the QScreenPrivate class instance.

[0042] Using the above method, the memory addresses of fill functions and block transfer functions can be accurately located without modifying the Qt framework source code, providing a reliable function location foundation for subsequent construction of Hook functions and implementation of drawing listening.

[0043] In one embodiment of this application, determining the first memory address of the padding function and the second memory address of the block transfer function based on the offset includes: Starting from the memory address of the global variable, the memory address corresponding to the instance of the private class for screen drawing is determined by the offset. Based on the member order of the fill function and the draw function in the private screen drawing class, obtain the first offset between the fill function and the instance of the private screen drawing class, and obtain the second offset between the draw function and the instance of the private screen drawing class. The first memory address of the filling function is determined based on the memory address of the instance of the private class drawn on the screen and the first offset, and the second memory address is determined based on the memory address of the instance of the private class drawn on the screen and the second offset.

[0044] In this embodiment, the memory address corresponding to the global variable directly points to an instance of the screen management class; while the instance of the screen drawing private class, as a private member of the screen management class, can be determined based on the memory address of the global variable and through this offset. As an example, in a scenario based on the Qt 4.8.5 framework, x86 hardware platform, and VxWorks operating system version 6.9, the offset between the global variable and the instance of the screen drawing private class can be determined through analysis of the Qt framework source code and memory debugging. For example, if it is 0x44c, the memory address of the global variable can be added to the offset, and the result is the memory address of the instance of the screen drawing private class. This offset needs to be dynamically adjusted according to the Qt framework version and the bit width of the hardware platform.

[0045] In this embodiment, since the member function pointers of the screen drawing private class are stored in a fixed order in the memory corresponding to the instance of the screen drawing private class, the positions of the padding function and the block transfer function can be determined by analyzing the layout of the members of the screen drawing private class. For example, the function pointer of the padding function is stored at the beginning of the instance of the screen drawing private class, located in the first position, and the function pointer of the block transfer function follows immediately, located in the second position. If a single function pointer occupies 4 bytes of memory space, therefore, the first offset between the memory address of the padding function and the instance of the screen drawing private class is 0 bytes; the second offset between the memory address of the block transfer function and the instance memory address is 4 bytes.

[0046] In this embodiment, the memory address of the instance of the private class for screen drawing can be added to the first offset to obtain the first memory address of the fill function. The value stored at this address directly points to the actual location of the fill function in memory. Similarly, the memory address of the instance of the private class for screen drawing can be added to the second offset to obtain the second memory address of the block transfer function. The function memory addresses calculated in this way can be directly used for subsequent Hook function replacement.

[0047] By following the steps above, the memory addresses of fill functions and block transfer functions can be accurately located without modifying the Qt framework source code. This not only breaks through the access restrictions of private class members but also ensures the accuracy and compatibility of address location, providing data support for implementing drawing monitoring in Qt programs.

[0048] In one embodiment of this application, the drawing actions performed by the Qt interface program are monitored according to the first objective function and / or the second objective function to obtain the monitoring results, including: Replace the first memory address corresponding to the fill function with the memory address of the first target function, and replace the second memory address corresponding to the block transfer function with the memory address of the second target function; If the preset drawing requirement is to fill a preset area with color, then the target drawing Hook function is determined according to the first target function; And / or, If the preset drawing requirement is to draw image data in the preset area, then the target Hook function is determined according to the second objective function.

[0049] In this embodiment, the first memory address corresponding to the fill function can be replaced with the memory address of the first target function, and the second memory address corresponding to the block transfer function can be replaced with the memory address of the second target function. Thus, when the Qt interface program triggers a drawing action requiring the call to the fill function or the block transfer function, it will automatically jump to the corresponding first or second target function, thereby enabling access to the listening entry point.

[0050] In this embodiment, when determining the target drawing Hook function, the preset drawing requirements corresponding to the core drawing scenario of the Qt interface program can be clearly defined, such as "color fill only", "image transmission only", or "color fill + image transmission" in three categories. The target function needs to be selected based on the preset drawing requirements.

[0051] If the preset drawing requirement is color filling, then all drawing actions can be covered by simply listening to the call to the fill function through the first objective function. Therefore, the first objective function is determined as the target drawing hook function. If the preset drawing requirement is image data drawing, then all drawing actions can be covered by simply listening to the call to the block transfer function through the second objective function. Therefore, the second objective function is determined as the target drawing hook function. If the preset drawing requirement includes both color filling and image data drawing, then the first objective function and the second objective function must be determined together as the target drawing hook function group.

[0052] In this embodiment, a new record storage area can be allocated in memory. In the VxWorks system, a contiguous block of memory of a specified size can be allocated through the system's memory allocation interface, such as the malloc function, to serve as the sole storage location for subsequent monitoring records.

[0053] In this embodiment, when the Qt program fills a preset area with color, it can use a target Hook function to call the original fill function through the memory address of the first target function to complete the color filling of the preset area; and it can listen for at least one of the following: the identifier of the screen management class instance, the color parameter, and the region parameter, and obtain the listening result. The instance identifier can be such as the instance memory address, the color parameter can be such as the red, green, and blue components of type QColor, such as RGB(255,0,0), transparency 255, and the region parameter can be such as the boundary coordinates of type QRegion. After the drawing is completed, the listening result can be written to the free unit of the record storage area according to a preset format.

[0054] When a Qt program draws image data to a preset area, it can use a target hook function to call the original block transfer function via the memory address of a second target function to complete the drawing of the image data to the corresponding position in the preset area. The second target function can listen for at least one of the following: the identifier of the screen management class instance, coordinate point parameters, area parameters, and complete image data, and obtain the listening result. The coordinate point parameter can be, for example, the drawing start coordinates of type QPoint; the area parameter can be the area covered by the image; and the complete image data can be, for example, the pixel format of type QImage or the color values ​​of the pixels. After the drawing is completed, the listening result can be written to the free unit of the record storage area according to the preset format to ensure that the key details of the image drawing are completely recorded.

[0055] When a Qt program fills a preset area with color and draws image data, it can use the target Hook function to call the original fill function through the first memory address of the first target function to complete the color filling of the preset area, and use the second memory address of the second target function to call the original block transfer function to complete the drawing of image data to the corresponding position of the preset area, and obtain the listening result.

[0056] In this embodiment, the monitoring record results can be obtained through the recording storage area. During the monitoring period, such as from program startup to the user actively stopping the monitoring, or continuous monitoring until a preset duration, the target Hook function can sequentially write the recording data for each color fill and image drawing operation into the recording storage area, arranging them in chronological order. When the monitoring ends, the monitoring record result for this drawing monitoring is obtained. Subsequently, by parsing this monitoring result, the drawing process can be reconstructed, distinguishing between an anomaly in the Qt upper-layer drawing logic and an anomaly in the lower-layer driver execution, providing direct data evidence for troubleshooting.

[0057] Through the above steps, without modifying the Qt framework source code, non-intrusive monitoring of Qt interface program drawing actions was achieved. This not only ensured the integrity of the program's original drawing functions but also accurately captured key information in the drawing process, effectively solving the problem of difficult fault location in subsequent Qt interface programs.

[0058] In one embodiment of this application, replacing the first memory address corresponding to the fill function with the memory address of the first target function, and replacing the second memory address corresponding to the block transfer function with the memory address of the second target function, includes: The function pointer corresponding to the fill function is designated as the first pointer, and the function pointer corresponding to the block transfer function is designated as the second pointer; the value of the first pointer is designated as the first memory address, and the value of the second pointer is designated as the second memory address. Allocate a new pointer storage area in memory, store the value of the first pointer in the first area of ​​the pointer storage area, and store the value of the second pointer in the second area of ​​the pointer storage area; Replace the value of the first pointer in the instance of the private screen drawing class with the value of the function pointer corresponding to the first target function, and replace the value of the second pointer in the instance of the private screen drawing class with the value of the function pointer corresponding to the second target function.

[0059] In this embodiment, the pointer storage area is used to back up the pointer values ​​of the original functions, preventing the loss of the original memory addresses after subsequent replacements and ensuring that the first target function and the second target function can normally call the original padding function and block transfer function. In the VxWorks system, a contiguous memory space can be allocated as the pointer storage area through the system memory allocation interface, such as the malloc function. This area can be divided into a first area and a second area. The value of the first pointer, i.e., the first memory address, is written to the first area, and the value of the second pointer, i.e., the second memory address, is written to the second area. The starting addresses of the two areas are recorded for easy retrieval when the function is called subsequently.

[0060] In this embodiment, the first target function is a hook function that matches the parameter structure and return value of the filling function, and its function pointer value is the memory address of the first target function; the second target function is a hook function that matches the parameter and return value of the block transfer function, and its function pointer value is the memory address of the second target function. First, the storage location of the first pointer in the private class instance of screen drawing can be located, and the memory address of the first target function can be written to that location, overwriting the original first memory address; then, the storage location of the second pointer can be located, and the memory address of the second target function can be written to that location, overwriting the original second memory address.

[0061] In this embodiment, after the replacement is completed, Figure 2 shows the calling process of the drawing action of a Qt interface program based on the WindML library under the VxWorks system. In the calling program corresponding to the upper-level drawing action of this Qt interface program, the screen management class is called first. The screen management class further calls the private screen drawing class, and then the fill function and block transfer function are called respectively. The fill function fills the specified preset area with color, such as filling a preset area of ​​a certain interface with a specific color. The block transfer function performs the drawing operation of the image data class, such as transferring the image data to the specified preset position on the screen for display. After that, the fill function and the block transfer function draw the result of the drawing action into the media library frame buffer corresponding to WindML, which is used to present it on the actual display device. Among them, when the fill function is called, the first pointer jumps to the first target function through the address pointed to by the first pointer; when the block transfer function is called, the second pointer jumps to the second target function through the address pointed to by the second pointer, realizing the entry point access of the drawing monitoring.

[0062] Through the above steps, without modifying the Qt framework source code, the addresses of the target function and the original function are replaced, and the original address is backed up through the pointer storage area. This ensures that subsequent drawing actions can be triggered normally, while also ensuring that the original drawing function can be called by the target function. This achieves the core requirement of "listening without interrupting drawing" and lays the foundation for troubleshooting the drawing process of Qt programs.

[0063] In one embodiment of this application, when it is necessary to monitor the drawing actions of a Qt interface program, a pre-designed Hook function can be used, namely, a first target function and a second target function, to replace the original fill function and block transfer function, respectively, and monitoring can begin. After monitoring is completed, the original functions are replaced back with the Hook function, and monitoring stops. This avoids unnecessary impact on the normal performance of the Qt interface program caused by the continuous execution of the Hook function, while also restoring the original drawing logic of the program. During operation, the addresses of the fill function and block transfer function are rewritten back to their original memory locations from the previously backed-up memory addresses of the original functions, so that subsequent drawing operations of the program no longer go through the Hook function and return to the normal execution flow. By reading the data recorded during the Hook function's monitoring process, it is possible to clearly understand which drawing operations the Qt interface program performed during the monitoring period, the specific parameters and execution status of each drawing operation, and thus restore the drawing process, analyze whether there are any drawing anomalies, parameter errors, or other problems, and provide a basis for debugging and optimizing the Qt interface program.

[0064] Figure 3This application provides a schematic diagram of a drawing hook device for a WindML-based Qt interface program under the VxWorks system. The drawing hook device includes an acquisition module 310, a determination module 320, and a listening module 330. The acquisition module 310 is used to acquire the fill function and block transfer function that perform drawing actions through the WindML library in the Qt framework; wherein, the fill function is used to fill a preset area with color, and the block transfer function is used to draw image data in the preset area; The determining module 320 is used to determine a first target function based on the filling function and a second target function based on the block transfer function. The listening module 330 is used to determine the target drawing Hook function based on the first target function and / or the second target function.

[0065] It should be noted that the drawing hook device for a Qt interface program based on WindML under the VxWorks system in this embodiment is used to implement the drawing hook method for a Qt interface program based on WindML under the VxWorks system in the aforementioned method embodiment, and has the beneficial effects of the corresponding method embodiment, which will not be repeated here.

[0066] See Figure 4 , Figure 4 This is a schematic block diagram of an electronic device provided according to an embodiment of this application. Figure 4 The electronic device 400 in this embodiment may include one or more processors 401, one or more input devices 402, one or more output devices 403, and one or more memories 404. The processors 401, input devices 402, output devices 403, and memories 404 communicate with each other via a communication bus 405. The memory 404 stores computer programs, including program instructions. The processor 401 executes the program instructions stored in the memory 404. Specifically, the processor 401 is configured to invoke the program instructions to perform the functions of each module / unit in the above system embodiments.

[0067] It should be understood that, in the embodiments of this application, the processor 401 may be a central processing unit (CPU), but it may also be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor.

[0068] Input device 402 may include a touchpad, a fingerprint sensor (for collecting the user's fingerprint information and fingerprint orientation information), a microphone, etc., and output device 403 may include a display (LCD, etc.), a speaker, etc.

[0069] The memory 404 may include read-only memory and random access memory, and provides instructions and data to the processor 301. A portion of the memory 404 may also include non-volatile random access memory. For example, the memory 404 may also store device type information.

[0070] In specific implementations, the processor 401, input device 402, and output device 403 described in the embodiments of this application can execute the implementation methods described in the embodiment of the drawing Hook method of a Qt interface program based on WindML under the VxWorks system provided in the embodiments of this application, or they can execute the implementation methods of the electronic devices described in the embodiments of this application, which will not be repeated here.

[0071] In another embodiment of this application, a computer-readable storage medium is provided. This computer-readable storage medium stores a computer program, which includes program instructions. When executed by a processor, the program instructions implement all or part of the processes in the methods described above. Alternatively, the computer program can instruct related hardware to complete the process. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include any entity or device capable of carrying computer program code, a recording medium, a USB flash drive, a portable hard drive, a magnetic disk, an optical disk, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electrical carrier signal, a telecommunication signal, and a software distribution medium, etc.

[0072] The computer-readable storage medium can be an internal storage unit of the electronic device in any of the foregoing embodiments, such as a hard disk or memory of the electronic device. The computer-readable storage medium can also be an external storage device of the electronic device, such as a plug-in hard disk, smart media card (SMC), secure digital card (SD), flash card, etc., equipped on the electronic device. Furthermore, the computer-readable storage medium can include both internal and external storage units of the electronic device. The computer-readable storage medium is used to store computer programs and other programs and data required by the electronic device. The computer-readable storage medium can also be used to temporarily store data that has been output or will be output.

[0073] The above description is merely a preferred embodiment of this application and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of the invention involved in this application is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the inventive concept. For example, technical solutions formed by substituting the above features with (but not limited to) technical features with similar functions disclosed in this application.

Claims

1. A drawing Hook method for a Qt interface program based on WindML under the VxWorks system, characterized in that, The method includes: Obtain the fill function and block transfer function in the Qt framework that perform drawing actions through the WindML library; wherein, the fill function is used to fill a preset area with color, and the block transfer function is used to draw image data in the preset area; The first objective function is determined based on the filling function, and the second objective function is determined based on the block transfer function; The target drawing Hook function is determined based on the first objective function and / or the second objective function.

2. The method according to claim 1, characterized in that, The process of obtaining the fill function and block transfer function in the Qt framework that perform drawing actions through the WindML library includes: Determine the first memory address of the fill function and the second memory address of the block transfer function; The padding function is obtained based on the first memory address, and the block transfer function is obtained based on the second memory address.

3. The method according to claim 2, characterized in that, Determining the first memory address of the fill function and the second memory address of the block transfer function includes: The screen management class and screen drawing private class in the Qt framework are determined based on the parameter characteristics corresponding to the fill function and the block transfer function, respectively, and the preset call dependency relationship. Determine the global variables corresponding to instances of the screen management class and instances of the private screen drawing class; Obtain the offset between the memory address of the instance of the screen drawing private class and the memory address of the global variable, and determine the first memory address of the filling function and the second memory address of the block transfer function based on the offset; The screen management class represents the interface for managing screen display attributes and drawing in the Qt framework; the fill function and the block transfer function are member functions of the private screen drawing class; the screen management class contains instances of the private screen drawing class; and the memory address corresponding to the instance of the screen management class is the memory address corresponding to the global variable.

4. The method according to claim 3, characterized in that, Determining the first memory address of the fill function and the second memory address of the block transfer function based on the offset includes: Starting from the memory address of the global variable, the memory address corresponding to the instance of the private screen drawing class is determined by the offset. Based on the member order corresponding to the fill function and the drawing function in the private screen drawing class, obtain the first offset between the fill function and the instance of the private screen drawing class, and obtain the second offset between the drawing function and the instance of the private screen drawing class. The first memory address of the filling function is determined based on the memory address of the instance of the private class drawn on the screen and the first offset, and the second memory address is determined based on the memory address of the instance of the private class drawn on the screen and the second offset.

5. The method according to claim 1, characterized in that, The step of determining the first target function based on the fill function and the second target function based on the block transfer function includes: A first target function is constructed based on the parameter structure and return value of the fill function, so that the first target function calls the fill function to fill the preset area with color, and listens for the color filling drawing action; A second target function is constructed based on the parameter structure and return value of the block transfer function, so that the second target function calls the block transfer function to draw the image data to a preset position and listens for the drawing action of the image data.

6. The method according to claim 1, characterized in that, The step of determining the target drawing Hook function based on the first objective function and / or the second objective function includes: Replace the first memory address corresponding to the fill function with the memory address of the first target function, and replace the second memory address corresponding to the block transfer function with the memory address of the second target function; If the preset drawing requirement is to fill a preset area with color, then the target drawing Hook function is determined according to the first target function; And / or, If the preset drawing requirement is to draw image data in the preset area, then the target Hook function is determined according to the second objective function.

7. The method according to claim 6, characterized in that, The step of replacing the first memory address corresponding to the fill function with the memory address of the first target function, and replacing the second memory address corresponding to the block transfer function with the memory address of the second target function, includes: The function pointer corresponding to the fill function is determined as the first pointer, and the function pointer corresponding to the block transfer function is determined as the second pointer; the value of the first pointer is determined as the first memory address, and the value of the second pointer is determined as the second memory address; Allocate a new pointer storage area in memory, store the value of the first pointer in the first area of ​​the pointer storage area, and store the value of the second pointer in the second area of ​​the pointer storage area; Replace the value of the first pointer in the instance of the private screen drawing class with the value of the function pointer corresponding to the first target function, and replace the value of the second pointer in the instance of the private screen drawing class with the value of the function pointer corresponding to the second target function.

8. A drawing Hook device for a Qt interface program based on WindML under the VxWorks system, characterized in that, The device includes: The acquisition module is used to acquire the fill function and block transfer function of Qt performing drawing actions through the WindML library; wherein, the fill function is used to fill a preset area with color, and the block transfer function is used to draw image data in the preset area; A determining module is configured to determine a first objective function based on the filling function and a second objective function based on the block transfer function; The listening module is used to determine the target drawing Hook function based on the first target function and / or the second target function.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that, When the processor executes the computer program, it implements a drawing Hook method for a Qt interface program based on WindML under the VxWorks system as described in any one of claims 1 to 7.

10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the steps of the drawing Hook method for a Qt interface program based on WindML under the VxWorks system as described in any one of claims 1 to 7.