Test method and device of game application, storage medium and electronic equipment
By generating opcode and boundary features of API functions, the starting address is automatically determined, solving the problem of low efficiency in manual analysis during game client security testing and realizing highly efficient and automated game application testing.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- NETEASE (HANGZHOU) NETWORK CO LTD
- Filing Date
- 2022-06-24
- Publication Date
- 2026-07-31
AI Technical Summary
Existing technologies require extensive manual analysis in game client security testing, resulting in low testing efficiency and high costs. Furthermore, each test requires re-injection, increasing learning and labor costs.
By generating API function opcode samples of the scripting language interpreter, opcode features and boundary features are determined, the starting address of the API function is automatically determined, and then a model is determined based on the starting address to test the game application under test.
It improves the testing efficiency of game applications, simplifies the testing process, reduces learning and labor costs, and enables automated game security testing.
Smart Images

Figure CN115080407B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of computer technology, and more specifically, to a method for testing game applications, a device for testing game applications, a computer-readable storage medium, and an electronic device. Background Technology
[0002] Testing the correctness, security, and integrity of the game client can ensure the secure execution of the game logic.
[0003] In the security testing of game clients, for engines that use scripts to drive game logic, the relevant technology requires manual reverse engineering to obtain the offset address of the API function of the scripting language interpreter corresponding to the script, then construct the injection function to be used, and then inject the written attack payload into the scripting language virtual machine in the game engine for execution to verify the security of the game logic.
[0004] However, this method requires a significant amount of manual analysis, resulting in low testing efficiency.
[0005] It should be noted that the information disclosed in the background section above is only used to enhance the understanding of the background of this disclosure, and therefore may include information that does not constitute prior art known to those skilled in the art. Summary of the Invention
[0006] The purpose of this disclosure is to provide a testing method and apparatus for game applications, a computer-readable storage medium and an electronic device, thereby improving, at least to some extent, the problem of low testing efficiency in game security testing.
[0007] Other features and advantages of this disclosure will become apparent from the following detailed description, or may be learned in part from practice of this disclosure.
[0008] According to a first aspect of this disclosure, a method for testing a game application is provided, comprising: obtaining the opcodes of an API function corresponding to a scripting language interpreter in at least one game application to generate an opcode sample of the API function, wherein the scripting language interpreter is used to execute a logic script of the game application; determining the opcode features of the API function based on the opcode sample; obtaining a starting address determination model of the API function based on the opcode features and the boundary features of the API function, wherein the boundary features are determined based on the tail information of the preceding function of the API function; and testing the game application to be tested based on the starting address determination model of the API function and the test script.
[0009] In an exemplary embodiment of this disclosure, based on the foregoing scheme, determining the opcode features of the API function based on the opcode sample includes: determining the opcode features of the API function based on the common parts in the opcode sample.
[0010] In an exemplary embodiment of this disclosure, based on the foregoing scheme, determining the opcode features of the API function based on the common part in the opcode sample includes: generating a first regular expression corresponding to the common part based on the common part in the opcode sample and a preset matching range; determining the opcode features of the API function according to the first regular expression; wherein the preset matching range is used to find the tail information of the preceding function of the API function.
[0011] In an exemplary embodiment of this disclosure, based on the foregoing scheme, determining the opcode features of the API function based on the common portion of the opcode samples includes: determining the opcode features of the API function based on the common portion of the opcode samples corresponding to the function information after the function header of the API function.
[0012] In an exemplary embodiment of this disclosure, based on the foregoing scheme, the common portion is determined according to consecutive identical opcodes in the opcode sample; determining the opcode features of the API function based on the common portion in the opcode sample includes: determining the opcode features of the API function based on at least one common portion in the opcode sample.
[0013] In an exemplary embodiment of this disclosure, based on the foregoing scheme, the tail information of the preceding function of the API function includes a jump instruction or a return instruction, and the boundary feature includes the opcode corresponding to the jump instruction or the return instruction.
[0014] In an exemplary embodiment of this disclosure, based on the foregoing scheme, obtaining the starting address determination model of the API function according to the opcode features and the boundary features of the API function includes: generating a second regular expression according to the opcode features and the boundary features of the API function; and obtaining the starting address determination model of the API function based on the second regular expression.
[0015] In an exemplary embodiment of this disclosure, based on the foregoing scheme, the step of determining the model based on the starting address of the API function and the test script, and testing the game application to be tested, includes: determining the starting address of the API function in the game application to be tested based on the model for determining the starting address of the API function and the game application to be tested; generating an injection function based on the starting address; and injecting the test script into the game application to be tested based on the injection function, so as to test the game application to be tested.
[0016] In an exemplary embodiment of this disclosure, based on the foregoing scheme, generating the injection function based on the starting address includes: obtaining the offset address of the game application to be tested in memory; determining the actual address of the API function in memory based on the starting address and the offset address; constructing a calling function corresponding to the API function based on the actual address, the return value type of the API function, and the parameter type of the API function, so as to generate the injection function based on the calling function corresponding to the API function.
[0017] In one exemplary embodiment of this disclosure, based on the foregoing scheme, the method further includes: injecting a test server for executing the test script into the game application to be tested based on the injection function, such that the test server sends the output content of the game application to be tested during the execution of the test script to a local client connected to the test server, so as to display the output content in the local client; the IP address of the test server is the local IP address of the network environment corresponding to the game client where the game application to be tested is located.
[0018] In an exemplary embodiment of this disclosure, based on the foregoing scheme, when the API function includes a frame function, the method further includes: determining the starting address of the frame function in the game application to be tested based on the starting address determination model of the frame function, wherein the frame function is used to execute the game logic of the game application to be tested according to the test script; interrupting the frame function when the frame data of the frame function is called; obtaining the data offset address of the currently called frame data in the frame data structure; determining the target address according to the starting address of the frame function and the data offset address, and searching for the data stored at the target address in memory; and outputting the data stored at the target address to generate the call stack of the game logic of the game application to be tested.
[0019] In an exemplary embodiment of this disclosure, based on the foregoing scheme, obtaining the data offset of the currently invoked frame data in the frame data structure includes: obtaining the data offset address of the currently invoked frame data in the frame data structure based on a data offset address feature model; wherein the data offset address feature model is generated by: obtaining the opcode of the instruction to operate on the frame data of the frame function in at least one game application to generate an opcode sample of the frame data; generating an opcode feature of the frame data based on the opcode sample of the frame data; and generating the data offset address feature model based on the opcode feature of the frame data.
[0020] According to a second aspect of this disclosure, a testing apparatus for a game application is provided, comprising: an opcode sample generation module configured to acquire the opcodes of an API function corresponding to a scripting language interpreter in at least one game application to generate an opcode sample of the API function, wherein the scripting language interpreter is used to execute the logic script of the game application; an opcode feature determination module configured to determine the opcode features of the API function based on the opcode sample; a starting address model determination module configured to obtain a starting address determination model of the API function based on the opcode features and the boundary features of the API function, wherein the boundary features are determined based on the tail information of the preceding function of the API function; and a testing module configured to test the game application to be tested based on the starting address determination model of the API function and the test script.
[0021] According to a third aspect of this disclosure, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements a testing method for a game application as described in the first aspect of the above embodiments.
[0022] According to a fourth aspect of the present disclosure, an electronic device is provided, comprising: a processor; and a storage device for storing one or more programs, which, when executed by the one or more processors, cause the one or more processors to implement the testing method for a game application as described in the first aspect of the above embodiments.
[0023] As can be seen from the above technical solutions, the game application testing method, the game application testing apparatus, and the computer-readable storage medium and electronic device implementing the game engine testing method in the exemplary embodiments of this disclosure have at least the following advantages and positive effects:
[0024] In some embodiments of this disclosure, the opcode features of the API function can be obtained by generating opcode samples of the API function of the scripting language interpreter used to execute the test script. The boundary features of the API function can be obtained by using the tail information of the preceding function. Based on the opcode features and boundary features, a starting address determination model for the API function can be determined. Furthermore, the starting address of the API function can be automatically determined based on this model, allowing testing of the game application under test based on the determined starting address. Compared with related technologies, this disclosure, through the generated starting address determination model, can automatically obtain the starting address of the API function corresponding to the scripting language interpreter, enabling game testing based on the determined starting address without manual analysis, thus improving the testing efficiency of the game application. Furthermore, this disclosure, through the generated starting address determination model, can automatically analyze the starting address of the API function, simplifying the operation steps in the game testing process and reducing the learning and manual costs of game testing.
[0025] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Attached Figure Description
[0026] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure. It is obvious that the drawings described below are merely some embodiments of this disclosure, and those skilled in the art can obtain other drawings based on these drawings without any inventive effort.
[0027] Figure 1 This diagram illustrates a flowchart of a game application testing method in an exemplary embodiment of this disclosure.
[0028] Figure 2 A flowchart illustrating a method for determining opcode features in an exemplary embodiment of this disclosure is shown.
[0029] Figure 3 This illustration shows a flowchart of a method for determining the starting address of an API function corresponding to a scripting language interpreter in a game application under test, according to an exemplary embodiment of this disclosure.
[0030] Figure 4 This diagram illustrates a flowchart of a method for generating an injection function based on a starting address in an exemplary embodiment of this disclosure.
[0031] Figure 5 This diagram illustrates a system framework for an injection-based, real-time interactive test server that prints game logs, according to an exemplary embodiment of this disclosure.
[0032] Figure 6 A flowchart illustrating a method for printing a game call stack according to an exemplary embodiment of this disclosure is shown.
[0033] Figure 7 A flowchart illustrating a method for generating a data offset address feature model in an exemplary embodiment of this disclosure is shown.
[0034] Figure 8 A flowchart illustrating another method for printing a game call stack according to an exemplary embodiment of this disclosure is shown.
[0035] Figure 9 This illustration shows a visual interface diagram for testing a game application according to an exemplary embodiment of the present disclosure.
[0036] Figure 10 This illustration shows another visualization interface for testing a game application according to an exemplary embodiment of the present disclosure.
[0037] Figure 11 This illustration shows another visualization interface for testing a game application according to an exemplary embodiment of the present disclosure.
[0038] Figure 12 This illustration shows another visualization interface for testing a game application according to an exemplary embodiment of the present disclosure;
[0039] Figure 13 This diagram illustrates the structure of a game application testing apparatus in an exemplary embodiment of this disclosure.
[0040] Figure 14 A schematic diagram of the structure of an electronic device in an exemplary embodiment of this disclosure is shown. Detailed Implementation
[0041] Exemplary embodiments will now be described more fully with reference to the accompanying drawings. However, these exemplary embodiments can be implemented in many forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided to make this disclosure more comprehensive and complete, and to fully convey the concept of the exemplary embodiments to those skilled in the art. The described features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. In the following description, numerous specific details are provided to give a full understanding of embodiments of this disclosure. However, those skilled in the art will recognize that the technical solutions of this disclosure can be practiced with one or more of these specific details omitted, or other methods, components, apparatus, steps, etc., can be employed. In other instances, well-known technical solutions are not shown or described in detail to avoid obscuring various aspects of this disclosure.
[0042] The terms “a,” “an,” “the,” and “the” are used in this specification to indicate the presence of one or more elements / components / etc.; the terms “including” and “having” are used to indicate an open-ended inclusion and to mean that there may be other elements / components / etc. in addition to the listed elements / components / etc.; the terms “first” and “second” are used only as markings and are not a limitation on the number of objects.
[0043] Furthermore, the accompanying drawings are merely illustrative of this disclosure and are not necessarily drawn to scale. The same reference numerals in the drawings denote the same or similar parts, and therefore repeated descriptions of them will be omitted. Some block diagrams shown in the drawings are functional entities and do not necessarily correspond to physically or logically independent entities.
[0044] Below, we will first explain some of the technical terms that may be involved in this disclosure.
[0045] Scripting languages, also known as extended languages or dynamic languages, are programming languages used to control software applications. Scripts are usually saved as text and are only interpreted or compiled when called. Examples include Python, VBScript, JavaScript, InstallShield Script, and ActionScript. Unlike languages such as C or C++, which need to be compiled into binary code and exist as executable files before execution, scripting languages do not require pre-compilation into executable files. Their interpretation is handled by the corresponding scripting language interpreter during execution.
[0046] Scripting language interpreter: A scripting language interpreter is a computer program that can directly execute instructions written in a scripting language without first compiling them into a machine language program.
[0047] CPython: A Python interpreter written in C.
[0048] Frida: A hook (interruption) framework based on Python and JavaScript, which can be used on various operating systems such as Android, iOS, macOS, Linux, and Windows.
[0049] Payload: An attack payload, such as a Python script injected into a game client to test the game's security.
[0050] Hook: A hook function that forces the execution of a target function before it is called, and then jumps to execute a code snippet of your own design.
[0051] Game engine: A pre-written, editable computer game system or a core component of an interactive real-time graphics application. These systems provide game designers with a variety of tools needed to write game applications, aiming to enable game designers to easily and quickly create game applications without starting from scratch.
[0052] API functions: API (Application Programming Interface) functions are predefined functions. They can be understood as code provided by a computer's operating system or library for applications to call and use. Their main purpose is to allow application developers to call a set of routine functions without needing to know the underlying source code or understand the details of their internal workings. An API itself is abstract; it only defines an interface and does not involve the specific operations performed by the application in the actual implementation process.
[0053] In security testing of game clients, for game engines that use scripting languages to drive game logic, such as NeoX and Messiah, the relevant technologies require manual reverse engineering of the core logic files of the game engine, extraction of API functions related to the scripting language interpreter, manual analysis to obtain the starting address of the API function, manual construction of injection methods based on the extracted API function starting address, and then verification of the security of the game logic of the game application generated based on the game engine using injection techniques.
[0054] This approach requires extensive manual analysis, resulting in low testing efficiency. It also places high demands on the reverse engineering capabilities of testers, creating a high testing threshold, increasing labor costs, and requiring re-injection each time, further reducing testing efficiency.
[0055] In the embodiments of this disclosure, a testing method for a game application is first provided, which at least to some extent overcomes the defects existing in the above-mentioned related technologies.
[0056] Figure 1 This diagram illustrates a flowchart of a game application testing method according to an exemplary embodiment of this disclosure. (Reference) Figure 1 The method includes:
[0057] Step S110: Obtain the opcode of the API function corresponding to the scripting language interpreter in at least one game application to generate an opcode sample of the API function, wherein the scripting language interpreter is used to execute the logic script of the game application;
[0058] Step S120: Based on the opcode sample, determine the opcode features of the API function;
[0059] Step S130: Based on the opcode features and the boundary features of the API function, obtain the starting address determination model of the API function, wherein the boundary features are determined based on the tail information of the preceding function of the API function;
[0060] Step S140: Determine the model and the test script based on the starting address of the API function, and test the game application to be tested.
[0061] exist Figure 1 In the technical solution provided by the illustrated embodiment, the opcode features of the API function can be obtained by generating opcode samples of the API function of the scripting language interpreter used to execute the test script. The boundary features of the API function can be obtained by using the tail information of the preceding function. Based on the opcode features and boundary features, a starting address determination model for the API function can be determined. Furthermore, the starting address of the API function can be automatically determined based on this model, allowing testing of the game application under test based on the determined starting address. Compared with related technologies, this disclosure, through the generated starting address determination model, can automatically obtain the starting address of the API function corresponding to the scripting language interpreter, enabling game testing based on the determined starting address without manual analysis, thus improving the testing efficiency of the game application. On the other hand, this disclosure, through the generated starting address determination model, can automatically analyze the starting address of the API function, simplifying the operation steps in the game testing process and reducing the learning and manual costs of game testing.
[0062] The following are Figure 1 The specific implementation methods of each step in the illustrated embodiment are described in detail below:
[0063] In step S110, the opcodes of the API functions corresponding to the scripting language interpreter in at least one game application are obtained to generate opcode samples of the API functions.
[0064] In one exemplary implementation, a scripting language interpreter is used to execute the logic script of a game application. The logic script of the game application can be a Python script, and the corresponding scripting language interpreter can be a Python scripting language interpreter, such as CPython.
[0065] Game engines can be written using compiled languages such as C and C++. Based on the game framework provided by this engine, the implementation logic of the game application itself can be written using a scripting language; that is, the logic scripts of the game application can be written using a scripting language. When the game engine is implemented using a compiled language, but the game logic of the game application is implemented using a scripting language interpreter, the logic scripts of the game application can be executed using a scripting language interpreter.
[0066] When testing a game application, test scripts can be written. For example, if the game application uses Python scripts, Python scripts can be written to test it. The test scripts can be interfaced with the game application through the API functions of the scripting language interpreter included in the game application, allowing the game application to execute the logic corresponding to the test scripts.
[0067] For example, based on requirements, it can be determined which API functions in the scripting language interpreter need to be used for test integration with the game application to obtain the target API functions. Then, based on the existing game application, the opcode (operation code) of each target API function in different game applications can be extracted to obtain the opcode sample corresponding to each target API function.
[0068] Taking the CPython scripting language interpreter as an example, target API functions may include: PyImport_AddModule, PyModule_GetDict, PyRun_StringFlags, Py_FlushLine, PyGILState_Ensure, PyGILState_Release, PyEval_EvalFrameEx, PyFrame_GetLineNumber, etc.
[0069] In other words, the API function in step S110 may include multiple functions. A specific implementation of step S110 may be to obtain the operation code of the API function in at least one game application for each API function, so as to generate an operation code sample corresponding to the API function.
[0070] If the API function can include API function 1, API function 2, and API function 3, then the opcode of API function 1 in at least one game application can be obtained to generate an opcode sample corresponding to API function 1, the opcode of API function 2 in at least one game application can be obtained to generate an opcode sample corresponding to API function 2, and the opcode of API function 3 in at least one game application can be obtained to generate an opcode sample corresponding to API function 3.
[0071] Next, in step S120, the opcode features of the API function are determined based on the opcode sample.
[0072] For example, a specific implementation of step S120 may be to determine the opcode features of the API function based on the common parts in the opcode samples.
[0073] For example, if there is only one game application in step S110, then there is only one opcode sample, which is shared with itself. Therefore, this opcode sample can be directly identified as the opcode feature of the corresponding API function. If there are multiple game applications in step S110, such as 10, then there are 10 opcode samples. The opcode feature of the corresponding API function can be determined based on the common parts of these 10 opcode samples.
[0074] In one exemplary implementation, the opcode features of the API function can be determined based on the common portion of the opcode samples corresponding to the function information following the function header of the API function.
[0075] For example, since the opcodes in the function header are usually related to saving the environment, they lack logical structure and cannot truly represent the function itself. Therefore, the opcode characteristics of an API function can be determined based on the common parts of the opcode samples corresponding to the function information after the function header. In other words, when determining opcode characteristics, the common parts are extracted starting from the latter part of each opcode.
[0076] The specific position after the function header can be determined based on manual experience or the opcode corresponding to the function header. The common part is extracted from the last opcode corresponding to the function header. This exemplary implementation does not impose any special limitations on this.
[0077] In one exemplary implementation, the common part is determined based on consecutive identical opcodes in each opcode sample. That is, there may be multiple common parts, and the opcode features of the API function can be determined based on at least one common part in the opcode samples.
[0078] For example, at least one common part in the opcode samples corresponding to the function information following the function header of an API function can represent the characteristics of that API function, and thus the opcode features of the API function can be determined based on it. Of course, the opcode features of an API function can also be determined based on multiple common parts, and this exemplary embodiment does not place special limitations on this.
[0079] For example, Figure 2 This diagram illustrates a flowchart of a method for determining opcode features based on common portions of opcode samples according to an exemplary embodiment of this disclosure. (See also:) Figure 2 The method may include steps S210 to S220.
[0080] In step S210, a first regular expression corresponding to the common part is generated based on the common part in the opcode sample and the preset matching range.
[0081] Taking the example of obtaining the opcode corresponding to API function 1 in five existing game applications, let A, B, C, D, and E represent the opcodes of the API function in the five existing game applications. We can then compare the differences between A and B, A and C, A and D, and A and E to obtain the common parts corresponding to these five opcodes. We can use any existing difference comparison algorithm to obtain the differences between A and B, A and C, A and D, and A and E, and determine the common parts among A, B, C, D, and E based on the parts outside of these differences.
[0082] After obtaining the common parts, at least one common part can be selected, and then a first regular expression corresponding to the at least one common part can be generated according to the preset matching range.
[0083] The preset matching range is used to find the tail information of the preceding function of the API function. In other words, the preset matching range can be customized as needed, as long as it matches the tail information of the preceding function of the API function starting from the common part. This ensures that the first regular expression generated based on the preset matching range and the common part can simultaneously represent the header information and logical information of the API function.
[0084] Taking the common parts of the API function opcode sample as "C0 00 00 34 60 0A 40 F9 20 01 00B5" and "97 60 0A", with a 6-character interval between them and a preset matching range of 40 to 60, meaning that the range of 40 to 60 characters before the first common part can be matched, the final generated first regular expression can be ".{40,160}c0000034600a40f9200100b5.{6}97600a".
[0085] In the example above, the "." in the first regular expression matches any single character except the newline character \n. In ARM64 (64-bit ARM architecture), 8 bytes, or 16 zeros to F, form a group of opcodes. The preset matching range of ".{40,160}" can include the function header of the API function and the end of the previous function.
[0086] In step S220, the opcode characteristics of the API function are determined based on the first regular expression.
[0087] For example, after generating the first regular expression, the first regular expression can be used as the opcode feature of the API function.
[0088] Opcode features can only match the approximate range of API functions. However, when calling API functions for injection during subsequent testing, it is necessary to be precise down to the function header. Therefore, the function's boundary features can also be combined to obtain the function's starting address determination model.
[0089] Continue to refer to Figure 1 In step S130, the starting address determination model of the API function is obtained based on the opcode features and the boundary features of the API function.
[0090] The boundary features of the API function are determined based on the tail information of the preceding function.
[0091] In one exemplary implementation, the tail information of the preceding function of the API function includes a jump instruction or a return instruction, and the boundary feature includes the opcode corresponding to the jump instruction or the return instruction.
[0092] In this disclosure, the inventors, in the process of determining boundary features, reverse-analyzed the tail of the preceding function of each API function and found that the tail of the preceding function of all API functions can be classified into two cases: jump instructions and return instructions. Therefore, the boundary features of API functions can be determined as the opcode corresponding to the jump instruction or the opcode corresponding to the return instruction. Taking the opcode corresponding to the jump instruction as f2 ff ff 17 and the opcode corresponding to the return instruction as c0 03 5f d6 as an example, the boundary feature of each target API function can be characterized as f2ffff17|c0035fd6, where "|" represents an "OR" relationship.
[0093] After obtaining the opcode features and boundary features, a model for determining the starting address of the API function can be generated based on these features. For example, a second regular expression can be generated based on the opcode features and the boundary features of the API function; and based on this second regular expression, the model for determining the starting address of the API function can be obtained.
[0094] For example, the boundary features and opcode features can be concatenated in the order of boundary features first, followed by opcode features, to generate a second regular expression. This second regular expression can then be used as the model for determining the starting address of the API function. Continuing with the example of the opcode feature ".{40,160}c0000034600a40f9200100b5.{6}97600a", the corresponding API function's starting address determination model can be:
[0095] ".*(f2ffff17|c0035fd6)(.{40,160})c0000034600a40f9200100b5.{6}97600".
[0096] As mentioned earlier, "." matches any single character except the newline character "\n", "*" matches any number of times the preceding subexpression, and ".*" together means any character appears zero or more times.
[0097] Next, in step S140, the model and the test script are determined based on the starting address of the API function, and the game application to be tested is tested.
[0098] For example, you can first determine the starting address model of the API function, and then, based on the determined starting address model of the API function and the game application to be tested, obtain the starting address of each API function in the game application to be tested. Then, you can test the game application to be tested based on the determined starting address of the API function and the test script.
[0099] Below, we will take a specific API function as an example and combine it with... Figure 3 The method for determining the starting address of API functions in the game application under test will be further explained. (See reference...) Figure 3 The method may include steps S310 to S360. Specifically: in step S310, opcodes corresponding to API functions are extracted from game applications 1 to N respectively; in step S320, opcode features of the API functions are generated based on the extracted opcodes; in step S330, boundary features of the API functions are analyzed; in step S340, a starting address determination model for the API functions is obtained based on the opcode features and boundary features; in step S350, the game application to be tested and the starting address determination model are matched; and in step S360, the starting address of the API functions in the game application to be sequenced is obtained based on the matching result.
[0100] The specific implementation of the API function starting address determination model in steps S310 to S340 can be referred to the corresponding parts in steps S110 to S130 above, and will not be repeated here.
[0101] In one exemplary implementation, step S140 may include: determining the starting address of the API function in the game application under test based on the API function's starting address determination model and the game application under test; generating an injection function based on the starting address; and injecting the test script into the game application under test based on the injection function to test the game application under test.
[0102] As described in step S350 above, the starting address determination model (i.e., the second regular expression mentioned above) of each API function to be used can be matched with the opcode corresponding to the sequencing game application to be tested using regular expressions to obtain the starting address of each API function in the game application to be tested.
[0103] After obtaining the starting address of each API function, an injection function can be dynamically generated based on that address to inject the test script into the game application under test. The test script is then injected into the game application to drive its game logic, thereby enabling security testing of the game logic.
[0104] For example, Figure 4 This diagram illustrates a flowchart of a method for generating an injection function based on a starting address in an exemplary embodiment of this disclosure. (See reference...) Figure 4 The method may include steps S410 to S430.
[0105] In step S410, the offset address of the game application to be tested in memory is obtained.
[0106] Taking Android as an example, the game application under test, libc (function library), and other logic are compiled into .so (shared object, dynamic link library) files. The logic scripts of the game application under test are executed by a scripting language interpreter. Therefore, the scripting language interpreter is also an .so file, and it is linked with the game application under test as the same module at runtime. Therefore, the offset address of the scripting language interpreter executing the game application under test can be determined based on the offset address of the module containing the game application under test in memory.
[0107] Based on this, the memory offset address of the game application under test can be obtained according to the library name of the dynamic link library corresponding to the game application under test. For example, the Frida tool can be used to obtain the memory offset address of the dynamic link module corresponding to the game application under test based on the instruction Module.findBaseAddress(libName), where libName is the library name of the dynamic link library corresponding to the game application under test. Of course, other methods can also be used to obtain the memory offset address of the game application under test, and this exemplary embodiment does not impose any special limitations on this.
[0108] Next, in step 420, the actual address of the API function in memory is determined based on the starting address and the offset address.
[0109] After obtaining the offset address of the game application to be sequenced in memory, the starting address of the API function obtained by the model and the offset address of the game application to be tested in memory can be determined based on the starting address of the API function mentioned above, thus determining the actual address of the API function in memory.
[0110] Taking CPython as the scripting language interpreter and PyModule_GetDic as the API function in CPython as an example, by matching the opcode of the game application under test with the starting address of PyModule_GetDic, we can obtain the offset address funcOffset of PyModule_GetDic in the game application under test (i.e., the starting address of the function in the game application under test. The starting address refers to the address of the function header. If the function is used in the game application under test, its starting address can also be understood as its offset address in the game application under test). We can use Frida's Module.findBaseAddress(libName) command to obtain the address moduleAddr of the dynamic link library module corresponding to the game application under test in the game process. moduleAddr is the actual memory address of the game application under test. Therefore, in this process, the actual memory address funcaddr of PyModule_GetDict can be determined as funcaddr = funcOffset + moduleAddr.
[0111] For example, if the actual memory address of libGame.so (the game application to be tested) is 0x6efd9e000, and the offset address of API function 1 in libGame.so is 0x413117c, then the actual memory address of API function 1 is 0x6efd9e000 + 0x413117c = 0x6F3ECF17C, that is, 0x6F3ECF17C is the actual address of API function 1 in memory.
[0112] Next, in step S430, a calling function corresponding to the API function is constructed based on the actual address, the return value type of the API function, and the parameter type of the API function, so as to generate the injection function based on the calling function corresponding to the API function.
[0113] Continuing with the example of the API function PyModule_GetDict mentioned above, we can see from the CPython source code that the return type of PyModule_GetDict is a pointer type, and the parameter type is a pointer type. We can then obtain the corresponding calling function for PyModule_GetDict: var PyModule_GetDict=new NativeFunction(funcaddr),'pointer',['pointer']). When calling, we can directly use this variable as the function call, such as var d=PyModule_GetDict(m).
[0114] After constructing the calling function for each API function that needs to be used, the calling function corresponding to each API function can be encapsulated to generate the injection function used to inject the test script into the game application to be tested.
[0115] In one exemplary embodiment, the testing method for the game application disclosed herein may further include: injecting a test server for executing the test script into the game application to be tested based on the injection function, such that the test server sends the output content of the game application to be tested during the execution of the test script to a local client connected to the test server, so as to display the output content in the local client; wherein, the IP address of the test server is the local IP address of the network environment corresponding to the game client where the game application to be tested is located.
[0116] For example, in this disclosure, a server payload for real-time interaction, namely the aforementioned test server, can be generated. This server payload may include a server socket implemented using a scripting language. Taking the implementation of the server payload using a Python script as an example, the server payload is run in a separate thread within the Python script. The IP address of this server payload is the local IP address of the network environment where the game client is located, and the port can be any unused port. Then, using the injection function described above, this Python script can be injected into the game application to be tested, allowing the server payload corresponding to the Python script to run in the game client.
[0117] A connection can be established between a local client and a server payload. The local client provides test scripts; it sends these scripts to the server payload, allowing the game application under test to execute their logic. Simultaneously, the local client receives output data from the game application during testing, sent by the server payload. This output data includes all game outputs, categorized as both those intended for display on the game client and those not. Essentially, any output containing a "print" statement can be considered output data and sent to the local client for display. User-inputted "print" commands can also be displayed on the local client.
[0118] In other words, the local client can provide a window and a test script, and send the test script to the server payload. When the server payload receives the data sent by the local client, it can execute the data as executable code, and replace all the data output instructions of the game application under test with the instruction to send the output data instruction to the server payload. In this way, during the entire connection process, the server payload can send the received output data of the game application under test to the local client, so that all the game's output, including standard output and error output, can be displayed on the local client. This enables real-time interaction based on the server payload and allows for quick querying of game logs.
[0119] Figure 5 This diagram illustrates a system framework for an injection-based, real-time interactive test server that prints game logs, according to an exemplary embodiment of this disclosure. (Reference) Figure 5 The system may include an injection platform 51, a test server 52, a game application to be tested 53, and a local client 54. Among them:
[0120] The injection platform 51 may include Frida. The injection platform 51 is used to call the API corresponding to the scripting language interpreter to inject the test server 52, such as the server payload mentioned above, into the game application 53 to be tested.
[0121] The local client 54 can send test scripts to the test server 52. The test server 52 can execute the received test scripts as executable code to drive the game logic of the game application under test based on the test scripts, thereby realizing the testing of the game application under test based on the test scripts.
[0122] Simultaneously, all existing outputs from the game application 54 to be sequenced can be redirected to the test server 52. Taking Python as an example, the `sys.stdout` method of the `sys` module in Python can be used to send all existing outputs from the game application 54 to the test server 52. Then, the test server 52 will send all outputs from the game application 54 during this test to the local client 54. In this way, the game output during the test can be displayed on the local client 54 to print game logs, which facilitates the testers' analysis of the game test results based on the displayed game logs.
[0123] In one exemplary implementation, the error output of the game program under test during the testing process can also be specially marked, for example, the error output can be displayed in red font to alert the testers, thereby further assisting in improving the efficiency of game testing.
[0124] Furthermore, the game application testing method disclosed herein can also print the game logic call stack during the testing process. For example, Figure 6 This diagram illustrates a flowchart of a method for printing a game call stack according to an exemplary embodiment of this disclosure. (See reference...) Figure 6 The method may include steps S610 to S650. Wherein:
[0125] In step S610, the starting address of the frame function in the game application to be tested is determined based on the frame function starting address determination model.
[0126] The frame function is used to execute the game logic of the game application according to the test script. In other words, the frame function can be understood as a function used in each frame of the game application under test during its operation. When the test script is a Python script, the frame function can be a Python frame function.
[0127] In one exemplary embodiment, the API function in this disclosure may include a frame function. Correspondingly, through the steps S110 to S130 described above, a frame function starting address determination model can be obtained. Then, the frame function starting address determination model is matched with the game application to be tested to obtain the starting address of the frame function in the game application to be tested.
[0128] Next, in step S620, the frame function is interrupted when the frame data of the frame function is invoked.
[0129] For example, calling a frame function's frame data can be understood as performing operations on that frame data, such as reading it. When a frame function's frame data is called, the frame function can be interrupted, for example, by hooking the frame function.
[0130] In step S630, the data offset address of the currently invoked frame data in the frame data structure is obtained.
[0131] For example, a specific implementation of step S630 may include obtaining the data offset address of the currently invoked frame data in the frame data structure based on the data offset address feature model.
[0132] Figure 7 A flowchart illustrating a method for generating a data offset address feature model according to an exemplary embodiment of this disclosure is shown. (See reference...) Figure 7 The method may include steps S710 to S730. Specifically: in step S710, the opcode of the instruction to operate on the frame data of the frame function in at least one game application is obtained to generate an opcode sample of the frame data; in step S720, the opcode feature of the frame data is generated based on the opcode sample of the frame data; and in step S730, the data offset address feature model is generated based on the opcode feature of the frame data.
[0133] For example, for each frame of data in a frame function, the opcodes of instructions that operate on the frame data in at least one existing game application can be obtained to generate an opcode sample for that frame data. Then, based on the common parts of the opcode samples of the frame data in different game applications, the opcode features of the frame data are determined. A third regular expression is then generated based on the opcode features of the frame data, and a data offset address feature model is determined based on the third regular expression.
[0134] After determining the data offset address feature model, the opcode corresponding to the frame data structure of the frame function in the application under test can be matched with the data offset address feature model to obtain the target opcode representing the offset address of the frame data. Then, the target opcode is parsed to determine the offset address of the frame data based on the parsing result.
[0135] Next, in step S640, the target address is determined based on the starting address of the frame function and the data offset address, and the data stored at the target address is searched in memory.
[0136] For example, the target address can be determined based on the starting address and data offset address of the frame function. Then, by searching and retrieving the data stored at the target address in memory, information about the function currently operating on the frame data can be obtained. In other words, the data stored at the target address may include the function name and / or the function's storage path, etc.
[0137] In step S650, the data stored at the target address is output to generate the call stack of the game logic of the game application to be tested.
[0138] For example, by outputting the function name and / or function storage path stored in the target address, the call stack corresponding to the game logic executed by the game application under test during the test can be generated and displayed on the local client mentioned above. This further assists testers in analyzing the game test results based on the call stack and improves testing efficiency.
[0139] Figure 8 This diagram illustrates a flowchart of another method for printing a game call stack according to an exemplary embodiment of this disclosure. (See reference) Figure 8 The method may include steps S810 to S870.
[0140] In step S810, opcodes are extracted from game applications 1 through N respectively; in step S820, a data offset address feature model is determined based on the extracted opcodes; in step S830, the game application to be tested is tested, and the offset address of the frame data of the current operation is obtained based on the data offset address feature model; in step S840, the starting address of the frame function in the game application to be tested is obtained based on the model determined by the starting address of the frame function; in step S850, the target address is determined based on the starting address and the offset address; in step S860, the frame function is interrupted to search for and output the data stored at the target address in memory; in step S870, the call stack of the game application to be tested is obtained based on the output results of each interrupt. In step S810, the extracted opcodes are the opcodes corresponding to the instructions that operate on the frame data of the frame function.
[0141] For example, when an operation on frame data of a frame function is detected, the frame function can be hooked. Then, based on the starting address of the determined frame function and the offset address of the currently operated frame data, the target address can be determined. The function name and / or function path stored at the target address can be searched in memory and output, thereby generating the game logic call stack of the game application under test during the test process.
[0142] In one exemplary implementation, the API function's starting address determination model can also be updated based on the new game application. For example, the API function's opcode sample can be updated based on the opcode of the API function in the new game application, and the API function's starting address determination model can be updated based on the updated opcode sample to improve the accuracy of the determined API function's starting address.
[0143] In one exemplary embodiment, a game application testing software system can be generated based on the game application testing method of this disclosure. Specifically, the implementation logic of the game application testing method of this disclosure can be deployed in the background of the game application testing software system, and then a human-computer interaction interface can be designed to achieve rapid testing of the game application to be tested through the human-computer interaction interface.
[0144] For example, after running the main program of the game application testing software system, it can display... Figure 9 The graphical user interface shown is available for testers. Figure 9 In the interface shown, enter the local IP address of the network environment corresponding to the game client where the game application to be tested is located, such as... Figure 9 The "10.228.56.163" and the specified port of the injection script, such as Figure 9 The "8080" in it.
[0145] Then, click Figure 9 The "Injection" control allows you to choose between automatically analyzing the starting address of API functions and tracing the call stack based on the SO (Shared Object, Dynamic Link Library) file, or manually entering the starting address of the API function and the address to trace the call stack. If you choose to automatically analyze the starting address of the API function and the address to trace the call stack, it will display something like this: Figure 10 The interface shown allows testers to click... Figure 10 The "Path" control in the interface shown allows you to select or enter the path to the SO file. After confirming the SO file path, click... Figure 10 The "Start Analysis" control allows the software system backend to obtain the game application to be tested based on the selected SO file path. Then, by combining the starting address to determine the model and data offset address feature model, it can automatically analyze the starting address of API functions and trace the call stack. After analysis, it can display results such as... Figure 11 The interface shown will automatically fill in the starting address of the API function and the address of the call stack after the analysis is complete, and a pop-up window will appear. Figure 11 The pop-up window shown is 111.
[0146] The address of the trace call frame can be understood as the starting address of the frame function and the offset address of the frame data.
[0147] Testers can close pop-up 111 by clicking the "OK" button. It's crucial that testers click the "OK" button again after pop-up 111 appears. Figure 11 The "injection" control allows the software system to automatically inject the test script into the game application under test based on the analyzed address. After successful injection, it will... Figure 12A pop-up window (121) will appear to inform the tester that the test script has been successfully injected. Similarly, clicking... Figure 12 The "OK" control in pop-up window 121 can be used to close pop-up window 121.
[0148] Then click again Figure 9 The "Connect" control allows you to connect the local client to the test server. This enables you to display game logs during the test on the local client, and error output in the game logs can also be displayed using special markers.
[0149] Testers click Figure 12 The "Trace" control in the browser can pop up a new window and display the printed game logic call stack of the game application under test on the local client.
[0150] This disclosure utilizes an API function start address determination model. The start address of the required scripting language interpreter's API functions can be directly determined from the binary data of the game application under test, improving game testing efficiency and eliminating the need for testers to possess the reverse engineering skills to analyze start addresses, thus reducing the manual costs of game testing. By injecting a test server that can interact in real-time into the game client and connecting via a local client, test scripts can be transmitted in real-time. This achieves real-time dynamic injection, saving significant time and further improving testing efficiency.
[0151] Furthermore, this disclosure also allows for the hijacking of the original output in the game via a test server, and then sending the hijacked output to the local client. This enables quick querying of game logs on the local client, further assisting in improving testing efficiency.
[0152] Those skilled in the art will understand that all or part of the steps of the above embodiments are implemented as a computer program executed by a CPU. When the computer program is executed by the CPU, it performs the functions defined by the method provided by the present invention. The program can be stored in a computer-readable storage medium, such as a read-only memory, a magnetic disk, or an optical disk.
[0153] Furthermore, it should be noted that the above figures are merely illustrative representations of the processes included in the method according to exemplary embodiments of the present invention, and are not intended to be limiting. It is readily understood that the processes shown in the above figures do not indicate or limit the temporal order of these processes. Additionally, it is readily understood that these processes may be executed synchronously or asynchronously, for example, in multiple modules.
[0154] Figure 13 This diagram illustrates the structure of a game application testing apparatus according to an exemplary embodiment of this disclosure. (Reference) Figure 13The device 1300 may include an opcode sample generation module 1310, an opcode feature determination module 1320, a starting address model determination module 1330, and a testing module 1340. Wherein:
[0155] The opcode sample generation module 1310 is configured to obtain the opcode of the API function corresponding to the script language interpreter in at least one game application, so as to generate an opcode sample of the API function, wherein the script language interpreter is used to execute the test script of the game application;
[0156] The opcode feature determination module 1320 is configured to determine the opcode features of the API function based on the opcode sample.
[0157] The first address model determination module 1330 is configured to obtain the first address determination model of the API function based on the opcode features and the boundary features of the API function, wherein the boundary features are determined based on the tail information of the preceding function of the API function;
[0158] Test module 1340 is configured to determine the model and the test script based on the starting address of the API function, and to test the game application to be tested.
[0159] In some exemplary embodiments of this disclosure, based on the foregoing embodiments, the opcode feature determination module 1320 can be specifically configured to: determine the opcode features of the API function based on the common parts in the opcode samples.
[0160] In some exemplary embodiments of this disclosure, based on the foregoing embodiments, determining the opcode features of the API function based on the common portion in the opcode sample includes: generating a first regular expression corresponding to the common portion based on the common portion in the opcode sample and a preset matching range; determining the opcode features of the API function according to the first regular expression; wherein the preset matching range is used to find the tail information of the preceding function of the API function.
[0161] In some exemplary embodiments of this disclosure, based on the foregoing embodiments, the step of determining the opcode features of the API function based on the common portion of the opcode samples includes: determining the opcode features of the API function based on the common portion of the opcode samples corresponding to the function information after the function header of the API function.
[0162] In some exemplary embodiments of this disclosure, based on the foregoing embodiments, the common portion is determined based on consecutive identical opcodes in the opcode sample; determining the opcode features of the API function based on the common portion in the opcode sample includes: determining the opcode features of the API function based on at least one common portion in the opcode sample.
[0163] In some exemplary embodiments of this disclosure, based on the foregoing embodiments, the tail information of the preceding function of the API function includes a jump instruction or a return instruction, and the boundary features include the opcode corresponding to the jump instruction or the return instruction.
[0164] In some exemplary embodiments of this disclosure, based on the foregoing embodiments, the starting address module determination module 1330 may be specifically configured to: generate a second regular expression based on the opcode features and the boundary features of the API function; and obtain the starting address determination model of the API function based on the second regular expression.
[0165] In some exemplary embodiments of this disclosure, based on the foregoing embodiments, the test module 1340 may be specifically configured to: determine the starting address of the API function in the game application under test based on the API function starting address determination model and the game application under test; generate an injection function based on the starting address; and inject the test script into the game application under test based on the injection function to test the game application under test.
[0166] In some exemplary embodiments of this disclosure, based on the foregoing embodiments, generating the injection function based on the starting address includes: obtaining the offset address of the game application to be tested in memory; determining the actual address of the API function in memory based on the starting address and the offset address; constructing a calling function corresponding to the API function based on the actual address, the return value type of the API function, and the parameter type of the API function, so as to generate the injection function based on the calling function corresponding to the API function.
[0167] In some exemplary embodiments of this disclosure, based on the foregoing embodiments, the apparatus may further include a game log display module, which may be configured to: inject a test server for executing the test script into the game application to be tested based on the injection function, such that the test server sends the output content of the game application to be tested during the execution of the test script to a local client connected to the test server, so as to display the output content in the local client; the IP address of the test server is the local IP address of the network environment corresponding to the game client where the game application to be tested is located.
[0168] In some exemplary embodiments of this disclosure, based on the foregoing embodiments, when the API function includes a frame function, the apparatus further includes a call stack printing module. This module can be configured to: determine the starting address of the frame function in the game application to be tested based on the starting address determination model of the frame function, wherein the frame function is used to execute the game logic of the game application to be tested according to the test script; interrupt the frame function when the frame data of the frame function is called; obtain the data offset address of the currently called frame data in the frame data structure; determine the target address according to the starting address of the frame function and the data offset address, and search for the data stored at the target address in memory; output the data stored at the target address to generate the call stack of the game logic of the game application to be tested.
[0169] In some exemplary embodiments of this disclosure, based on the foregoing embodiments, obtaining the data offset of the currently invoked frame data in the frame data structure includes: obtaining the data offset address of the currently invoked frame data in the frame data structure based on a data offset address feature model; wherein the data offset address feature model is generated by: obtaining the opcode of the instruction to operate on the frame data of the frame function in at least one game application to generate an opcode sample of the frame data; generating an opcode feature of the frame data based on the opcode sample of the frame data; and generating the data offset address feature model based on the opcode feature of the frame data.
[0170] The specific details of each module in the aforementioned game application testing device have been described in detail in the corresponding game application testing methods, so they will not be repeated here.
[0171] It should be noted that although several modules or units for the device used to perform actions have been mentioned in the detailed description above, this division is not mandatory. In fact, according to embodiments of this disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided and embodied by multiple modules or units.
[0172] Furthermore, although the steps of the method in this disclosure are described in a specific order in the accompanying drawings, this does not require or imply that the steps must be performed in that specific order, or that all the steps shown must be performed to achieve the desired result. Additional or alternative steps may be omitted, multiple steps may be combined into one step, and / or a step may be broken down into multiple steps.
[0173] From the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solutions according to the embodiments of this disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (such as a CD-ROM, USB flash drive, external hard drive, etc.) or on a network, including several instructions to cause a computing device (such as a personal computer, server, mobile terminal, or network device, etc.) to execute the methods according to the embodiments of this disclosure.
[0174] In exemplary embodiments of this disclosure, a computer storage medium capable of implementing the above-described methods is also provided. A program product capable of implementing the methods described in this specification is stored thereon. In some possible embodiments, various aspects of this disclosure can also be implemented as a program product including program code, which, when run on a terminal device, causes the terminal device to perform the steps described in the "Exemplary Methods" section of this specification according to various exemplary embodiments of this disclosure, for example:
[0175] Obtain the opcodes of the API functions corresponding to the scripting language interpreter in at least one game application to generate opcode samples of the API functions, wherein the scripting language interpreter is used to execute test scripts of the game application; based on the opcode samples, determine the opcode features of the API functions; according to the opcode features and the boundary features of the API functions, obtain a starting address determination model of the API functions, wherein the boundary features are determined based on the tail information of the preceding function of the API functions; and test the game application to be tested according to the starting address determination model of the API functions and the test scripts.
[0176] Optionally, determining the opcode features of the API function based on the opcode samples includes: determining the opcode features of the API function based on the common parts in the opcode samples.
[0177] Optionally, determining the opcode features of the API function based on the common parts in the opcode samples includes: generating a first regular expression corresponding to the common parts based on the common parts in the opcode samples and a preset matching range; determining the opcode features of the API function according to the first regular expression; wherein the preset matching range is used to find the tail information of the previous function of the API function.
[0178] Optionally, determining the opcode features of the API function based on the common parts in the opcode samples includes: determining the opcode features of the API function based on the common parts in the opcode samples corresponding to the function information after the function header of the API function.
[0179] Optionally, the common portion is determined based on consecutive identical opcodes in the opcode sample; determining the opcode features of the API function based on the common portion in the opcode sample includes: determining the opcode features of the API function based on at least one common portion in the opcode sample.
[0180] Optionally, the tail information of the preceding function of the API function includes a jump instruction or a return instruction, and the boundary feature includes the opcode corresponding to the jump instruction or the return instruction.
[0181] Optionally, obtaining the starting address determination model of the API function based on the opcode features and the boundary features of the API function includes: generating a second regular expression based on the opcode features and the boundary features of the API function; and obtaining the starting address determination model of the API function based on the second regular expression.
[0182] Optionally, the step of determining the model based on the starting address of the API function and the test script, and testing the game application to be tested, includes: determining the starting address of the API function in the game application to be tested based on the model based on the starting address of the API function and the game application to be tested; generating an injection function based on the starting address; and injecting the test script into the game application to be tested based on the injection function, so as to test the game application to be tested.
[0183] Optionally, generating the injection function based on the starting address includes: obtaining the offset address of the game application to be tested in memory; determining the actual address of the API function in memory based on the starting address and the offset address; constructing a calling function corresponding to the API function based on the actual address, the return value type of the API function, and the parameter type of the API function, so as to generate the injection function based on the calling function corresponding to the API function.
[0184] Optionally, the method further includes: injecting a test server for executing the test script into the game application to be tested based on the injection function, so that the test server sends the output content of the game application to be tested during the execution of the test script to a local client connected to the test server, so as to display the output content in the local client; the IP address of the test server is the local IP address of the network environment corresponding to the game client where the game application to be tested is located.
[0185] Optionally, if the API function includes a frame function, the method further includes: determining the starting address of the frame function in the game application to be tested based on the starting address determination model of the frame function, wherein the frame function is used to execute the game logic of the game application to be tested according to the test script; interrupting the frame function when the frame data of the frame function is called; obtaining the data offset address of the currently called frame data in the frame data structure; determining the target address according to the starting address of the frame function and the data offset address, and searching for the data stored at the target address in memory; and outputting the data stored at the target address to generate the call stack of the game logic of the game application to be tested.
[0186] Optionally, obtaining the data offset of the currently invoked frame data in the frame data structure includes: obtaining the data offset address of the currently invoked frame data in the frame data structure based on a data offset address feature model; wherein the data offset address feature model is generated by: obtaining the opcode of the instruction to operate on the frame data of the frame function in at least one game application to generate an opcode sample of the frame data; generating an opcode feature of the frame data based on the opcode sample of the frame data; and generating the data offset address feature model based on the opcode feature of the frame data.
[0187] Through the above implementation methods, on the one hand, the present disclosure can automatically obtain the starting address of the API function corresponding to the script language interpreter by generating the starting address determination model, so as to perform game testing based on the determined starting address without manual analysis, thus improving the testing efficiency of game applications; on the other hand, the present disclosure can automatically analyze the starting address of the API function by generating the starting address determination model, thus simplifying the operation steps in the game testing process and reducing the learning cost and manual cost of game testing.
[0188] Embodiments of this disclosure may also include a program product for implementing the above methods. This program product may employ a portable compact disc read-only memory (CD-ROM) and include program code, and may run on a terminal device, such as a personal computer. However, the program product of this disclosure is not limited thereto. In this document, a readable storage medium may be any tangible medium containing or storing a program that may be used by or in conjunction with an instruction execution system, apparatus, or device.
[0189] The program product may employ any combination of one or more readable media. A readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of readable storage media (a non-exhaustive list) include: an electrical connection having one or more wires, a portable disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.
[0190] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, carrying readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A readable signal medium may also be any readable medium other than a readable storage medium, capable of sending, propagating, or transmitting programs for use by or in conjunction with an instruction execution system, apparatus, or device.
[0191] The program code contained on the readable medium may be transmitted using any suitable medium, including but not limited to wireless, wired, optical fiber, RF, etc., or any suitable combination thereof.
[0192] Program code for performing the operations of this disclosure can be written in any combination of one or more programming languages, including object-oriented programming languages such as Java and C++, and conventional procedural programming languages such as C or similar languages. The program code can execute entirely on the user's computing device, partially on the user's computing device, as a standalone software package, partially on the user's computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving remote computing devices, the remote computing device can be connected to the user's computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computing device (e.g., via the Internet using an Internet service provider).
[0193] Furthermore, in an exemplary embodiment of this disclosure, an electronic device capable of implementing the above-described method is also provided.
[0194] Those skilled in the art will understand that various aspects of this disclosure can be implemented as a system, method, or program product. Therefore, various aspects of this disclosure can be specifically implemented in the following forms: a completely hardware implementation, a completely software implementation (including firmware, microcode, etc.), or a combination of hardware and software aspects, collectively referred to herein as a "circuit," "module," or "system."
[0195] The following reference Figure 14 To describe an electronic device 1400 according to such an embodiment of the present disclosure. Figure 14 The electronic device 1400 shown is merely an example and should not be construed as limiting the functionality and scope of use of the embodiments disclosed herein.
[0196] like Figure 14 As shown, the electronic device 1400 is manifested in the form of a general-purpose computing device. The components of the electronic device 1400 may include, but are not limited to: at least one processing unit 1410, at least one storage unit 1420, a bus 1430 connecting different system components (including storage unit 1420 and processing unit 1410), and a display unit 1440.
[0197] The storage unit stores program code, which can be executed by the processing unit 1410 to perform the steps described in the "Exemplary Methods" section of this specification according to various exemplary embodiments of this disclosure, such as:
[0198] Obtain the opcodes of the API functions corresponding to the scripting language interpreter in at least one game application to generate opcode samples of the API functions, wherein the scripting language interpreter is used to execute test scripts of the game application; based on the opcode samples, determine the opcode features of the API functions; according to the opcode features and the boundary features of the API functions, obtain a starting address determination model of the API functions, wherein the boundary features are determined based on the tail information of the preceding function of the API functions; and test the game application to be tested according to the starting address determination model of the API functions and the test scripts.
[0199] Optionally, determining the opcode features of the API function based on the opcode samples includes: determining the opcode features of the API function based on the common parts in the opcode samples.
[0200] Optionally, determining the opcode features of the API function based on the common parts in the opcode samples includes: generating a first regular expression corresponding to the common parts based on the common parts in the opcode samples and a preset matching range; determining the opcode features of the API function according to the first regular expression; wherein the preset matching range is used to find the tail information of the previous function of the API function.
[0201] Optionally, determining the opcode features of the API function based on the common parts in the opcode samples includes: determining the opcode features of the API function based on the common parts in the opcode samples corresponding to the function information after the function header of the API function.
[0202] Optionally, the common portion is determined based on consecutive identical opcodes in the opcode sample; determining the opcode features of the API function based on the common portion in the opcode sample includes: determining the opcode features of the API function based on at least one common portion in the opcode sample.
[0203] Optionally, the tail information of the preceding function of the API function includes a jump instruction or a return instruction, and the boundary feature includes the opcode corresponding to the jump instruction or the return instruction.
[0204] Optionally, obtaining the starting address determination model of the API function based on the opcode features and the boundary features of the API function includes: generating a second regular expression based on the opcode features and the boundary features of the API function; and obtaining the starting address determination model of the API function based on the second regular expression.
[0205] Optionally, the step of determining the model based on the starting address of the API function and the test script, and testing the game application to be tested, includes: determining the starting address of the API function in the game application to be tested based on the model based on the starting address of the API function and the game application to be tested; generating an injection function based on the starting address; and injecting the test script into the game application to be tested based on the injection function, so as to test the game application to be tested.
[0206] Optionally, generating the injection function based on the starting address includes: obtaining the offset address of the game application to be tested in memory; determining the actual address of the API function in memory based on the starting address and the offset address; constructing a calling function corresponding to the API function based on the actual address, the return value type of the API function, and the parameter type of the API function, so as to generate the injection function based on the calling function corresponding to the API function.
[0207] Optionally, the method further includes: injecting a test server for executing the test script into the game application to be tested based on the injection function, so that the test server sends the output content of the game application to be tested during the execution of the test script to a local client connected to the test server, so as to display the output content in the local client; the IP address of the test server is the local IP address of the network environment corresponding to the game client where the game application to be tested is located.
[0208] Optionally, if the API function includes a frame function, the method further includes: determining the starting address of the frame function in the game application to be tested based on the starting address determination model of the frame function, wherein the frame function is used to execute the game logic of the game application to be tested according to the test script; interrupting the frame function when the frame data of the frame function is called; obtaining the data offset address of the currently called frame data in the frame data structure; determining the target address according to the starting address of the frame function and the data offset address, and searching for the data stored at the target address in memory; and outputting the data stored at the target address to generate the call stack of the game logic of the game application to be tested.
[0209] Optionally, obtaining the data offset of the currently invoked frame data in the frame data structure includes: obtaining the data offset address of the currently invoked frame data in the frame data structure based on a data offset address feature model; wherein the data offset address feature model is generated by: obtaining the opcode of the instruction to operate on the frame data of the frame function in at least one game application to generate an opcode sample of the frame data; generating an opcode feature of the frame data based on the opcode sample of the frame data; and generating the data offset address feature model based on the opcode feature of the frame data.
[0210] Through the above implementation methods, on the one hand, the present disclosure can automatically obtain the starting address of the API function corresponding to the script language interpreter by generating the starting address determination model, so as to perform game testing based on the determined starting address without manual analysis, thus improving the testing efficiency of game applications; on the other hand, the present disclosure can automatically analyze the starting address of the API function by generating the starting address determination model, thus simplifying the operation steps in the game testing process and reducing the learning cost and manual cost of game testing.
[0211] Storage unit 1420 may include readable media in the form of volatile storage units, such as random access memory (RAM) 14201 and / or cache memory 14202, and may further include read-only memory (ROM) 14203.
[0212] Storage unit 1420 may also include a program / utility 14204 having a set (at least one) of program modules 14205, such program modules 14205 including but not limited to: operating system, one or more application programs, other program modules and program data, each or some combination of these examples may include an implementation of a network environment.
[0213] Bus 1430 can represent one or more of several types of bus structures, including a memory cell bus or memory cell controller, a peripheral bus, a graphics acceleration port, a processing unit, or a local bus using any of the various bus structures.
[0214] Electronic device 1400 can also communicate with one or more external devices 1500 (e.g., keyboard, pointing device, Bluetooth device, etc.), and with one or more devices that enable a user to interact with electronic device 1400, and / or with any device that enables electronic device 1400 to communicate with one or more other computing devices (e.g., router, modem, etc.). This communication can be performed via input / output (I / O) interface 1450. Furthermore, electronic device 1400 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN), and / or public networks, such as the Internet) via network adapter 1460. As shown, network adapter 1460 communicates with other modules of electronic device 1400 via bus 1430. It should be understood that, although not shown in the figures, other hardware and / or software modules can be used in conjunction with electronic device 1400, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0215] From the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solutions according to the embodiments of this disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (such as a CD-ROM, USB flash drive, external hard drive, etc.) or on a network, including several instructions to cause a computing device (such as a personal computer, server, terminal device, or network device, etc.) to execute the methods according to the embodiments of this disclosure.
[0216] Furthermore, the above figures are merely illustrative of the processes included in the method according to exemplary embodiments of this disclosure and are not intended to be limiting. It is readily understood that the processes shown in the above figures do not indicate or limit the temporal order of these processes. Additionally, it is readily understood that these processes may be executed synchronously or asynchronously, for example, in multiple modules.
[0217] Other embodiments of this disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not disclosed herein. The specification and embodiments are to be considered exemplary only, and the true scope and spirit of this disclosure are indicated by the claims.
Claims
1. A testing method for a game application, characterized in that, include: Obtain the opcodes of the API functions corresponding to the scripting language interpreter in at least one game application to generate an opcode sample of the API functions, wherein the scripting language interpreter is used to execute the logic scripts of the game application; Based on the opcode samples, the opcode features of the API function are determined; Based on the opcode features and the boundary features of the API function, a model for determining the starting address of the API function is obtained, wherein the boundary features are determined based on the tail information of the preceding function of the API function; The model and test script are determined based on the starting address of the API function, and the game application to be tested is then tested. The step of determining the opcode features of the API function based on the opcode samples includes: determining the opcode features of the API function based on the common parts in the opcode samples; The step of obtaining the starting address determination model of the API function based on the opcode features and the boundary features of the API function includes: generating a second regular expression based on the opcode features and the boundary features of the API function; and obtaining the starting address determination model of the API function based on the second regular expression.
2. The testing method for a game application according to claim 1, characterized in that, The step of determining the opcode features of the API function based on the common parts in the opcode samples includes: Based on the common part and the preset matching range in the opcode sample, a first regular expression corresponding to the common part is generated; Based on the first regular expression, the opcode characteristics of the API function are determined; The preset matching range is used to find the tail information of the previous function of the API function.
3. The testing method for a game application according to claim 1, characterized in that, The step of determining the opcode features of the API function based on the common parts in the opcode samples includes: Based on the common portion of the opcode samples corresponding to the function information following the function header of the API function, the opcode features of the API function are determined.
4. The testing method for a game application according to claim 1, characterized in that, The common portion is determined based on consecutive identical opcodes in the opcode sample; The process of determining the opcode features of the API function based on the common components in the opcode samples includes: Based on at least one common part in the opcode samples, the opcode features of the API function are determined.
5. The testing method for a game application according to claim 1, characterized in that, The trailing information of the preceding function of the API function includes a jump instruction or a return instruction, and the boundary features include the opcode corresponding to the jump instruction or the return instruction.
6. The testing method for a game application according to claim 1, characterized in that, The step of determining the model and the test script based on the starting address of the API function, and then testing the game application to be tested, includes: Based on the API function's starting address determination model and the game application to be tested, the starting address of the API function in the game application to be tested is determined; An injection function is generated based on the starting address, and the test script is injected into the game application to be tested based on the injection function.
7. The testing method for a game application according to claim 6, characterized in that, The step of generating the injection function based on the starting address includes: Obtain the offset address of the game application to be tested in memory; Based on the starting address and the offset address, the actual address of the API function in memory is determined; Based on the actual address, the return value type of the API function, and the parameter type of the API function, a calling function corresponding to the API function is constructed, and the injection function is generated based on the calling function corresponding to the API function.
8. The testing method for a game application according to claim 6 or 7, characterized in that, The method further includes: Based on the injection function, a test server for executing the test script is injected into the game application under test, so that the test server sends the output content of the game application under test during the execution of the test script to a local client connected to the test server, so as to display the output content in the local client; The IP address of the test server is the local IP address of the network environment corresponding to the game client where the game application to be tested is located.
9. The testing method for a game application according to claim 1, characterized in that, If the API function includes a frame function, the method further includes: Based on the frame function's starting address determination model, the starting address of the frame function in the game application to be tested is determined. The frame function is used to execute the game logic of the game application to be tested according to the test script. The frame function is interrupted when the frame data of the frame function is invoked; Obtain the data offset address of the currently invoked frame data in the frame data structure; The target address is determined based on the starting address of the frame function and the data offset address, and the data stored at the target address is searched in memory. Output the data stored at the target address to generate the call stack of the game logic of the game application to be tested.
10. The testing method for a game application according to claim 9, characterized in that, The step of obtaining the data offset of the currently invoked frame data in the frame data structure includes: Based on the data offset address feature model, the data offset address of the currently invoked frame data in the frame data structure is obtained; The data offset address feature model is generated in the following way: Obtain the opcodes in at least one game application that are instructions to manipulate frame data of a frame function, in order to generate an opcode sample of the frame data; Based on the opcode samples of the frame data, generate the opcode features of the frame data; Based on the opcode features of the frame data, the data offset address feature model is generated.
11. A testing device for a game application, characterized in that, include: An opcode sample generation module is configured to obtain the opcode of the API function corresponding to the scripting language interpreter in at least one game application, so as to generate an opcode sample of the API function, wherein the scripting language interpreter is used to execute the logic script of the game application; The opcode feature determination module is configured to determine the opcode features of the API function based on the opcode sample. The starting address model determination module is configured to obtain the starting address determination model of the API function based on the opcode features and the boundary features of the API function, wherein the boundary features are determined based on the tail information of the preceding function of the API function; The testing module is configured to determine the model and test script based on the starting address of the API function, and to test the game application to be tested. The step of determining the opcode features of the API function based on the opcode samples includes: determining the opcode features of the API function based on the common parts in the opcode samples; The step of obtaining the starting address determination model of the API function based on the opcode features and the boundary features of the API function includes: generating a second regular expression based on the opcode features and the boundary features of the API function; and obtaining the starting address determination model of the API function based on the second regular expression.
12. A computer-readable medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the testing method for the game application as described in any one of claims 1 to 10.
13. An electronic device, characterized in that, include: One or more processors; A storage device for storing one or more programs, which, when executed by one or more processors, cause the one or more processors to implement the testing method for a game application as described in any one of claims 1 to 10.