├── LICENSE ├── MMMojoCall ├── 3rdparty │ └── 3rdparty.7z ├── CMakeLists.txt ├── README.md ├── examples │ ├── cpp │ │ ├── childipc_test.cpp │ │ ├── parentipc_test.cpp │ │ ├── xplugin_ocr_test.cpp │ │ ├── xplugin_player_test.cpp │ │ ├── xplugin_test.cpp │ │ └── xplugin_utility_test.cpp │ ├── java │ │ └── MMMojoCallUsage.java │ └── python │ │ └── mmmojo_call_usage.py ├── proto │ ├── ocr_protobuf.proto │ ├── player_protobuf.proto │ └── utility_protobuf.proto └── src │ ├── dllmain.cpp │ ├── include │ ├── mmmojo_call.h │ ├── mmmojo_ocr.h │ ├── mmmojo_player.h │ ├── mmmojo_source │ │ ├── mmmojo.h │ │ └── mmmojo_environment_callbacks.h │ ├── mmmojo_utility.h │ ├── mojo_call_export.h │ ├── qq_mojoipc │ │ ├── qq_ipc.h │ │ └── qq_ipc_asm.h │ ├── utils.h │ └── xplugin_protobuf │ │ ├── google.zip │ │ ├── ocr_protobuf.pb.h │ │ ├── player_protobuf.pb.h │ │ └── utility_protobuf.pb.h │ ├── mmmojocall │ ├── mmmojo_call.cpp │ ├── mojo_call_export.cpp │ └── wrapper │ │ ├── mmmojo_ocr.cpp │ │ ├── mmmojo_player.cpp │ │ ├── mmmojo_utility.cpp │ │ ├── ocr_protobuf.pb.cc │ │ ├── player_protobuf.pb.cc │ │ └── utility_protobuf.pb.cc │ ├── qq_mojoipc │ ├── qq_ipc.cpp │ └── qq_ipc_asm.asm │ └── utils.cpp ├── README.md ├── parent-ipc-core-x64.dll └── parent-ipc-core-x86.dll /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /MMMojoCall/3rdparty/3rdparty.7z: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EEEEhex/QQImpl/3aac29788fc63d25665a0ae473b8b8c788ed20bb/MMMojoCall/3rdparty/3rdparty.7z -------------------------------------------------------------------------------- /MMMojoCall/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 3.5) 2 | 3 | cmake_policy(SET CMP0091 NEW) 4 | cmake_policy(SET CMP0078 NEW) 5 | cmake_policy(SET CMP0086 NEW) 6 | 7 | project (MMMojoCall LANGUAGES CXX VERSION 2.0.0) 8 | 9 | # project use folder 10 | set_property(GLOBAL PROPERTY USE_FOLDERS ON) 11 | 12 | # set up option variable for cmake 13 | option(XPLUGIN_WRAPPER "Enable this to build the OCR/Utility/Player Wrapper Code" ON) 14 | option(BUILD_QQIPC "Enable this to build the QQ Mojo IPC code" OFF) 15 | option(BUILD_CPPEXAMPLE "Enable this to build the c++ usage example" OFF) 16 | option(EXAMPLE_USE_JSON "Example Code's callback function data using protobuf or json" ON) 17 | option(BUILD_PURE_C_MODE "Export Pure C Interface" OFF) 18 | 19 | # add mmmojo_call src file 20 | aux_source_directory(src SRC_FILES) 21 | aux_source_directory(src/mmmojocall SRC_FILES) 22 | 23 | # add xplugin wrapper src file 24 | if (XPLUGIN_WRAPPER) 25 | # check depend files 26 | if (NOT EXISTS "${CMAKE_SOURCE_DIR}/3rdparty/libprotobuf_32_MT.lib") 27 | message(FATAL_ERROR "the depends lib is not exist!") 28 | endif() 29 | 30 | if (NOT EXISTS "${CMAKE_SOURCE_DIR}/src/include/xplugin_protobuf/google/protobuf") 31 | message(FATAL_ERROR "the google protobuf header file is not exist!") 32 | endif() 33 | 34 | aux_source_directory(src/mmmojocall/wrapper SRC_FILES) 35 | endif() 36 | 37 | # add qq mojo ipc src file 38 | if (BUILD_QQIPC) 39 | list(APPEND SRC_FILES src/qq_mojoipc/qq_ipc.cpp) 40 | 41 | # if x64 then need asm file 42 | if(CMAKE_SIZEOF_VOID_P EQUAL 8) 43 | list(APPEND SRC_FILES src/qq_mojoipc/qq_ipc_asm.asm) 44 | enable_language(C ASM_MASM) # enable masm 45 | endif() 46 | endif() 47 | 48 | # create library 49 | add_library(${PROJECT_NAME} SHARED ${SRC_FILES}) 50 | 51 | # add mmmojo_call include dir 52 | include_directories(src/include) 53 | include_directories(src/include/mmmojo_source) 54 | 55 | # add xplugin wrapper include dir 56 | if (XPLUGIN_WRAPPER) 57 | include_directories(src/include/xplugin_protobuf) 58 | endif() 59 | 60 | # add qq mojo ipc include dir 61 | if (BUILD_QQIPC) 62 | include_directories(src/include/qq_mojoipc) 63 | endif() 64 | 65 | # add xplugin wrapper marco 66 | if (XPLUGIN_WRAPPER) 67 | add_definitions(-DUSE_WRAPPER) 68 | endif() 69 | 70 | # add PURE_C_MODE marco 71 | if (BUILD_PURE_C_MODE) 72 | add_definitions(-DPURE_C_MODE) 73 | endif() 74 | 75 | # add protobuf link lib 76 | if (XPLUGIN_WRAPPER) 77 | # which arch 78 | if(CMAKE_SIZEOF_VOID_P EQUAL 8) 79 | set(ARCH_SUFFIX "64") 80 | else() 81 | set(ARCH_SUFFIX "32") 82 | endif() 83 | 84 | target_link_libraries(${PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/3rdparty/libprotobuf_${ARCH_SUFFIX}_MT$<$:d>.lib) 85 | endif() 86 | 87 | # set /MT or /MTd 88 | # add 'd' to Debug output 89 | set_target_properties(${PROJECT_NAME} PROPERTIES 90 | MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>" 91 | DEBUG_POSTFIX _d 92 | ) 93 | 94 | # build c++ usage example 95 | if (BUILD_CPPEXAMPLE) 96 | if (EXAMPLE_USE_JSON) 97 | add_definitions(-DEXAMPLE_USE_JSON) 98 | endif() 99 | 100 | # add xplugin (without wrapper) example 101 | set(XPLUGIN_USAGE xplugin_test) 102 | set(XPLUGIN_USAGE_SRC examples/cpp/xplugin_test.cpp) 103 | add_executable(${XPLUGIN_USAGE} ${XPLUGIN_USAGE_SRC}) 104 | set_property(TARGET ${XPLUGIN_USAGE} PROPERTY FOLDER "EXAMPLE") 105 | set_target_properties(${XPLUGIN_USAGE} PROPERTIES 106 | MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>" 107 | DEBUG_POSTFIX _d) 108 | add_dependencies(${XPLUGIN_USAGE} ${PROJECT_NAME}) 109 | target_link_libraries(${XPLUGIN_USAGE} PRIVATE $(SolutionDir)$,Debug,Release>/${PROJECT_NAME}$<$:_d>.lib) 110 | 111 | # add xplugin wrapper example 112 | if (XPLUGIN_WRAPPER) 113 | #OCR TEST 114 | set(XPLUGIN_OCR_USAGE xplugin_ocr_test) 115 | set(XPLUGIN_OCR_USAGE_SRC examples/cpp/xplugin_ocr_test.cpp) 116 | 117 | if (NOT EXAMPLE_USE_JSON) 118 | list(APPEND XPLUGIN_OCR_USAGE_SRC src/mmmojocall/wrapper/ocr_protobuf.pb.cc) 119 | endif() 120 | 121 | add_executable(${XPLUGIN_OCR_USAGE} ${XPLUGIN_OCR_USAGE_SRC}) 122 | set_property(TARGET ${XPLUGIN_OCR_USAGE} PROPERTY FOLDER "EXAMPLE") 123 | set_target_properties(${XPLUGIN_OCR_USAGE} PROPERTIES 124 | MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>" 125 | DEBUG_POSTFIX _d) 126 | add_dependencies(${XPLUGIN_OCR_USAGE} ${PROJECT_NAME}) 127 | target_link_libraries(${XPLUGIN_OCR_USAGE} PRIVATE $(SolutionDir)$,Debug,Release>/${PROJECT_NAME}$<$:_d>.lib) 128 | if (NOT EXAMPLE_USE_JSON) 129 | target_link_libraries(${XPLUGIN_OCR_USAGE} PRIVATE ${CMAKE_SOURCE_DIR}/3rdparty/libprotobuf_${ARCH_SUFFIX}_MT$<$:d>.lib) 130 | endif() 131 | 132 | #UTILITY TEST 133 | set(XPLUGIN_UTILITY_USAGE xplugin_utility_test) 134 | set(XPLUGIN_UTILITY_USAGE_SRC examples/cpp/xplugin_utility_test.cpp) 135 | 136 | if (NOT EXAMPLE_USE_JSON) 137 | list(APPEND XPLUGIN_UTILITY_USAGE_SRC src/mmmojocall/wrapper/utility_protobuf.pb.cc) 138 | endif() 139 | 140 | add_executable(${XPLUGIN_UTILITY_USAGE} ${XPLUGIN_UTILITY_USAGE_SRC}) 141 | set_property(TARGET ${XPLUGIN_UTILITY_USAGE} PROPERTY FOLDER "EXAMPLE") 142 | set_target_properties(${XPLUGIN_UTILITY_USAGE} PROPERTIES 143 | MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>" 144 | DEBUG_POSTFIX _d) 145 | add_dependencies(${XPLUGIN_UTILITY_USAGE} ${PROJECT_NAME}) 146 | target_link_libraries(${XPLUGIN_UTILITY_USAGE} PRIVATE $(SolutionDir)$,Debug,Release>/${PROJECT_NAME}$<$:_d>.lib) 147 | if (NOT EXAMPLE_USE_JSON) 148 | target_link_libraries(${XPLUGIN_UTILITY_USAGE} PRIVATE ${CMAKE_SOURCE_DIR}/3rdparty/libprotobuf_${ARCH_SUFFIX}_MT$<$:d>.lib) 149 | endif() 150 | 151 | #PLAYER TEST 152 | set(XPLUGIN_PLAYER_USAGE xplugin_player_test) 153 | set(XPLUGIN_PLAYER_USAGE_SRC examples/cpp/xplugin_player_test.cpp) 154 | 155 | add_executable(${XPLUGIN_PLAYER_USAGE} ${XPLUGIN_PLAYER_USAGE_SRC}) 156 | set_property(TARGET ${XPLUGIN_PLAYER_USAGE} PROPERTY FOLDER "EXAMPLE") 157 | set_target_properties(${XPLUGIN_PLAYER_USAGE} PROPERTIES 158 | MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>" 159 | DEBUG_POSTFIX _d) 160 | add_dependencies(${XPLUGIN_PLAYER_USAGE} ${PROJECT_NAME}) 161 | target_link_libraries(${XPLUGIN_PLAYER_USAGE} PRIVATE $(SolutionDir)$,Debug,Release>/${PROJECT_NAME}$<$:_d>.lib) 162 | endif() 163 | 164 | if (BUILD_QQIPC) 165 | set(QQIPC_PARENT_USAGE qqipc_parent_test) 166 | set(QQIPC_PARENT_USAGE_SRC examples/cpp/parentipc_test.cpp) 167 | 168 | add_executable(${QQIPC_PARENT_USAGE} ${QQIPC_PARENT_USAGE_SRC}) 169 | set_property(TARGET ${QQIPC_PARENT_USAGE} PROPERTY FOLDER "EXAMPLE") 170 | 171 | set_target_properties(${QQIPC_PARENT_USAGE} PROPERTIES 172 | MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>" 173 | DEBUG_POSTFIX _d) 174 | add_dependencies(${QQIPC_PARENT_USAGE} ${PROJECT_NAME}) 175 | target_link_libraries(${QQIPC_PARENT_USAGE} PRIVATE $(SolutionDir)$,Debug,Release>/${PROJECT_NAME}$<$:_d>.lib) 176 | 177 | set(QQIPC_CHILD_USAGE qqipc_child_test) 178 | set(QQIPC_CHILD_USAGE_SRC examples/cpp/childipc_test.cpp) 179 | 180 | add_executable(${QQIPC_CHILD_USAGE} ${QQIPC_CHILD_USAGE_SRC}) 181 | set_property(TARGET ${QQIPC_CHILD_USAGE} PROPERTY FOLDER "EXAMPLE") 182 | 183 | set_target_properties(${QQIPC_CHILD_USAGE} PROPERTIES 184 | MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>" 185 | DEBUG_POSTFIX _d) 186 | add_dependencies(${QQIPC_CHILD_USAGE} ${PROJECT_NAME}) 187 | target_link_libraries(${QQIPC_CHILD_USAGE} PRIVATE $(SolutionDir)$,Debug,Release>/${PROJECT_NAME}$<$:_d>.lib) 188 | endif() 189 | endif() 190 | -------------------------------------------------------------------------------- /MMMojoCall/README.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /MMMojoCall/examples/cpp/childipc_test.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "qq_ipc.h" 4 | 5 | using namespace qqimpl; 6 | 7 | void __stdcall OnChildReceiveMsg32(void* pArg, char* msg, int arg3, int arg4, char* addition_msg, int addition_msg_size) 8 | { 9 | //std::cout << "[ " << __FUNCTION__ << "] | Arg: 0x" << std::hex << pArg << std::endl; 10 | std::string msg_str = msg, add_msg_str(addition_msg, addition_msg_size); 11 | std::cout << "[*] [C] [ " << __FUNCTION__ << "] | Msg: " << msg_str << std::endl; 12 | std::cout << "[*] [C] [ " << __FUNCTION__ << "] | Addition Msg Size: " << addition_msg_size << std::endl; 13 | if (addition_msg_size != 0) 14 | { 15 | std::cout << "[*] [C] [ " << __FUNCTION__ << "] | The Addition Msg: "; 16 | for (size_t i = 0; i < addition_msg_size; i++) 17 | printf_s("0x%02X ", (byte)(addition_msg[i])); 18 | printf_s("(%s)", addition_msg); 19 | puts(""); 20 | } 21 | } 22 | 23 | void OnChildReceiveMsg64(void* pArg, char* msg, int arg3, char* addition_msg, int addition_msg_size) 24 | { 25 | //std::cout << "[ " << __FUNCTION__ << "] | Arg: 0x" << std::hex << pArg << std::endl; 26 | 27 | std::string msg_str = msg, add_msg_str(addition_msg, addition_msg_size); 28 | std::cout << "[*] [C] [ " << __FUNCTION__ << "] | Msg: " << msg_str << std::endl; 29 | std::cout << "[*] [C] [ " << __FUNCTION__ << "] | Addition Msg Size: " << addition_msg_size << std::endl; 30 | if (addition_msg_size != 0) 31 | { 32 | std::cout << "[*] [C] [ " << __FUNCTION__ << "] | The Addition Msg: "; 33 | for (size_t i = 0; i < addition_msg_size; i++) 34 | printf_s("0x%02X ", (byte)(addition_msg[i])); 35 | printf_s("(%s)", addition_msg); 36 | puts(""); 37 | } 38 | 39 | //qqimpl::QQIpcParentWrapper::OnDefaultReceiveMsg(pArg, msg, arg3, addition_msg, addition_msg_size); 40 | } 41 | 42 | int main() 43 | { 44 | std::cout << "[+] [C] Child Begin!\n"; 45 | 46 | qqipc::QQIpcChildWrapper child_ipc; 47 | 48 | if (!child_ipc.InitEnv()) 49 | { 50 | std::cout << "[!] [C] Init Child Err: " << child_ipc.GetLastErrStr() << std::endl; 51 | getchar(); return 0; 52 | } 53 | 54 | child_ipc.InitLog(); 55 | #ifdef _WIN64 56 | child_ipc.SetChildReceiveCallback(OnChildReceiveMsg64); 57 | #else 58 | child_ipc.SetChildReceiveCallback(OnChildReceiveMsg32); 59 | #endif // _WIN64 60 | child_ipc.InitChildIpc(); 61 | 62 | std::cout << "[=] [C] Press any key to SendIpcMessage to Parent: \n"; 63 | getchar(); 64 | 65 | std::string addtion_msg = "addition_test_child"; 66 | child_ipc.SendIpcMessage("child_test", addtion_msg.data(), addtion_msg.size()); 67 | 68 | MSG msg; 69 | // 主消息循环: 70 | while (GetMessage(&msg, nullptr, 0, 0)) 71 | { 72 | TranslateMessage(&msg); 73 | DispatchMessage(&msg); 74 | } 75 | return 0; 76 | } 77 | 78 | 79 | -------------------------------------------------------------------------------- /MMMojoCall/examples/cpp/parentipc_test.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "qq_ipc.h" 5 | 6 | using namespace qqimpl; 7 | 8 | void __stdcall OnParentReceiveMsg32(void*, char*, int, int, char*, int); 9 | void OnParentReceiveMsg64(void*, char*, int, char*, int); 10 | 11 | int main() 12 | { 13 | std::cout << "[+] [P] Parent Ipc Begin!\n"; 14 | int child_pid_1 = 0, child_pid_2 = 0; 15 | 16 | qqipc::QQIpcParentWrapper parent_ipc; 17 | //初始化环境 18 | if (!parent_ipc.InitEnv()) 19 | { 20 | std::cout << "[!] [P] Init ParentIpc Err: " << parent_ipc.GetLastErrStr() << std::endl; 21 | getchar(); return 0; 22 | } 23 | parent_ipc.InitLog(5); 24 | parent_ipc.InitParentIpc(); 25 | 26 | qqipc::callback_ipc cb_ptr; 27 | #ifdef _WIN64 28 | cb_ptr = OnParentReceiveMsg64; 29 | #else 30 | cb_ptr = OnParentReceiveMsg32; 31 | #endif // _WIN64 32 | 33 | const char* child_path; 34 | #ifdef _DEBUG 35 | child_path = "qqipc_child_test_d.exe"; 36 | #else 37 | child_path = "qqipc_child_test.exe"; 38 | #endif // _WIN64 39 | 40 | 41 | const char* cmd_args[] = {"-test1", "-test2"};//传递命令行参数 42 | child_pid_1 = parent_ipc.LaunchChildProcess(child_path, cb_ptr, (void*)"Child_1", (char**)cmd_args, 2);// "Child_1"为传递给OnUsrReceiveMsg的参数 43 | if (child_pid_1 == 0) 44 | { 45 | std::cout << "[!] [P] Launch CihldIpc.exe Err: " << parent_ipc.GetLastErrStr() << std::endl; 46 | getchar(); return 0; 47 | } 48 | 49 | std::cout << "[+] [P] Launch OK! Ready to Connect!\n"; 50 | parent_ipc.ConnectedToChildProcess(child_pid_1); 51 | 52 | std::cout << "[=] [P] Press any key to SendIpcMessage to Child1: \n"; 53 | getchar(); 54 | std::string addtion_msg = "addition_parent"; 55 | parent_ipc.SendIpcMessage(child_pid_1, "test_parent", addtion_msg.data(), addtion_msg.size()); 56 | 57 | 58 | std::cout << "[=] [P] Press any key to Terminate Child1: \n"; 59 | getchar(); 60 | parent_ipc.TerminateChildProcess(child_pid_1, 0, true); 61 | 62 | std::cout << "[=] [P] Press any key to ReLaunchChildProcess Child1: \n"; 63 | getchar(); 64 | child_pid_1 = parent_ipc.ReLaunchChildProcess(child_pid_1); 65 | parent_ipc.ConnectedToChildProcess(child_pid_1); 66 | 67 | MSG msg; 68 | // 主消息循环: 69 | while (GetMessage(&msg, nullptr, 0, 0)) 70 | { 71 | TranslateMessage(&msg); 72 | DispatchMessage(&msg); 73 | } 74 | 75 | return 0; 76 | } 77 | 78 | void __stdcall OnParentReceiveMsg32(void* pArg, char* msg, int arg3, int arg4, char* addition_msg, int addition_msg_size) 79 | { 80 | char* cb_arg = (char*)pArg; 81 | std::cout << "[*] [P] [ " << __FUNCTION__ << "] | Arg: " << cb_arg << std::endl; 82 | 83 | std::string msg_str = msg, add_msg_str(addition_msg, addition_msg_size); 84 | std::cout << "[*] [P] [ " << __FUNCTION__ << "] | Msg: " << msg_str << std::endl; 85 | std::cout << "[*] [P] [ " << __FUNCTION__ << "] | Addition Msg Size: " << addition_msg_size << std::endl; 86 | if (addition_msg_size != 0) 87 | { 88 | std::cout << "[*] [P] [ " << __FUNCTION__ << "] | The Addition Msg: "; 89 | for (size_t i = 0; i < addition_msg_size; i++) 90 | printf_s("0x%02X ", (byte)(addition_msg[i])); 91 | printf_s("(%s)", addition_msg); 92 | puts(""); 93 | } 94 | 95 | if (msg_str == "IPC_CONNECTED") 96 | { 97 | std::cout << "[*] [P] [ " << __FUNCTION__ << "] | " << cb_arg << " : Alive!" << std::endl; 98 | } 99 | else if (msg_str == "IPC_DISCONNECTED") 100 | { 101 | std::cout << "[*] [P] [ " << __FUNCTION__ << "] | " << cb_arg << " : Dead!" << std::endl; 102 | } 103 | 104 | //qqimpl::QQIpcParentWrapper::OnDefaultReceiveMsg(pArg, msg, arg3, arg4, addition_msg, addition_msg_size); 105 | } 106 | 107 | 108 | void OnParentReceiveMsg64(void* pArg, char* msg, int arg3, char* addition_msg, int addition_msg_size) 109 | { 110 | char* cb_arg = (char*)pArg; 111 | std::cout << "[*] [P] [ " << __FUNCTION__ << "] | Arg: " << cb_arg << std::endl; 112 | 113 | std::string msg_str = msg, add_msg_str(addition_msg, addition_msg_size); 114 | std::cout << "[*] [P] [ " << __FUNCTION__ << "] | Msg: " << msg_str << std::endl; 115 | std::cout << "[*] [P] [ " << __FUNCTION__ << "] | Addition Msg Size: " << addition_msg_size << std::endl; 116 | if (addition_msg_size != 0) 117 | { 118 | std::cout << "[*] [P] [ " << __FUNCTION__ << "] | The Addition Msg: "; 119 | for (size_t i = 0; i < addition_msg_size; i++) 120 | printf_s("0x%02X ", (byte)(addition_msg[i])); 121 | printf_s("(%s)", addition_msg); 122 | puts(""); 123 | } 124 | 125 | if (msg_str == "IPC_CONNECTED") 126 | { 127 | std::cout << "[*] [P] [ " << __FUNCTION__ << "] | " << cb_arg << " : Alive!" << std::endl; 128 | } 129 | else if (msg_str == "IPC_DISCONNECTED") 130 | { 131 | std::cout << "[*] [P] [ " << __FUNCTION__ << "] | " << cb_arg << " : Dead!" << std::endl; 132 | } 133 | 134 | //qqimpl::QQIpcParentWrapper::OnDefaultReceiveMsg(pArg, msg, arg3, addition_msg, addition_msg_size); 135 | } 136 | -------------------------------------------------------------------------------- /MMMojoCall/examples/cpp/xplugin_ocr_test.cpp: -------------------------------------------------------------------------------- 1 | /*****************************************************************//** 2 | * @file xplugin_test.cpp 3 | * @brief 此文件代码是使用OCRManager类调用WeChatOCR.exe的示例 4 | *********************************************************************/ 5 | 6 | #include 7 | 8 | #include "mmmojo_ocr.h" 9 | 10 | using namespace qqimpl; 11 | 12 | void OCRUsrReadOnPush(const char* pic_path, const void* data, int data_size) 13 | { 14 | std::cout << "[↓] " << __FUNCTION__ << ":\n[\n"; 15 | 16 | #ifdef EXAMPLE_USE_JSON 17 | //此时参数data为json字符串 18 | std::cout << (char*)data << std::endl; 19 | #else 20 | ocr_protobuf::OcrResponse ocr_response; 21 | ocr_response.ParseFromArray(data, data_size); 22 | 23 | char out_buf[512] = { 0 }; 24 | sprintf_s(out_buf, sizeof(out_buf), "\t[*] type: %d task id: %d errCode: %d\n", ocr_response.type(), ocr_response.task_id(), ocr_response.err_code()); 25 | std::cout << out_buf; 26 | 27 | if (pic_path != nullptr) 28 | { 29 | sprintf_s(out_buf, sizeof(out_buf), "\t[*] TaskId: %d -> PicPath: %s\n", ocr_response.task_id(), pic_path); 30 | std::cout << out_buf; 31 | } 32 | else 33 | { 34 | std::cout << "\t[*] This is a type 1 Push that is called back only once at startup of WeChatOCR.exe"; 35 | } 36 | 37 | if (ocr_response.type() == 0) 38 | { 39 | std::cout << "\t[*] OcrResult:\n\t[\n"; 40 | for (int i = 0; i < ocr_response.ocr_result().single_result_size(); i++) 41 | { 42 | ocr_protobuf::OcrResponse::OcrResult::SingleResult single_result = ocr_response.ocr_result().single_result(i); 43 | 44 | sprintf_s(out_buf, sizeof(out_buf), "\t\tRECT:[left: %f, top: %f, right: %f, bottom: %f]\n", single_result.left(), single_result.top(), single_result.right(), single_result.bottom()); 45 | std::cout << out_buf; 46 | std::string utf8str = single_result.single_str_utf8(); 47 | std::cout << "\t\tUTF8STR:["; 48 | for (size_t j = 0; j < utf8str.size(); j++) 49 | { 50 | printf_s("0x%2X ", (BYTE)utf8str[j]); 51 | } 52 | std::cout << " (" << utf8str << ")]\n"; 53 | } 54 | std::cout << "\t]"; 55 | } 56 | 57 | std::cout << "\n]" << std::endl; 58 | #endif 59 | } 60 | 61 | 62 | int main() 63 | { 64 | SetConsoleOutputCP(CP_UTF8); 65 | 66 | std::string wechat_ocr_dir;//"C:\\Users\\{YourName}\\AppData\\Roaming\\Tencent\\WeChat\\XPlugin\\Plugins\\WeChatOCR\\7057\\extracted\\WeChatOCR.exe" 67 | std::string wechat_dir;//Such as "D:\\WeChat\\[3.9.7.29]" 68 | 69 | std::cout << "\033[34m[=] Enter WeChatOCR.exe Path:\n[>]\033[0m "; 70 | std::getline(std::cin, wechat_ocr_dir); 71 | 72 | std::cout << "\033[34m[=] Enter mmmojo(_64).dll Path:\n[>]\033[0m "; 73 | std::getline(std::cin, wechat_dir); 74 | 75 | // 加载mmmojo(_64).dll并获取导出函数, 只需要调用一次. 76 | if (!mmmojocall::InitMMMojoDLLFuncs(wechat_dir.c_str())) 77 | { 78 | std::cout << "\033[31m[!] mmmojocall::InitMMMojoDLLFuncs ERR!\033[0m\n"; 79 | return 1; 80 | } 81 | 82 | // 初始化MMMojo (包括ThreadPool等), 只需要调用一次. 83 | mmmojocall::InitMMMojoGlobal(NULL, NULL); 84 | 85 | //------------------------ 86 | //以下为使用封装好的OCRManager类调用WeChatOCR进行OCR的示例 87 | mmmojocall::OCRManager ocr_manager; 88 | if (!ocr_manager.SetExePath(wechat_ocr_dir.c_str())) 89 | { 90 | std::cout << "\033[31m[!] " << ocr_manager.GetLastErrStr() << "\033[0m\n"; 91 | return 1; 92 | } 93 | 94 | if (!ocr_manager.SetUsrLibDir(wechat_dir.c_str())) 95 | { 96 | std::cout << "\033[31m[!] " << ocr_manager.GetLastErrStr() << "\033[0m\n"; 97 | return 1; 98 | } 99 | 100 | #ifdef EXAMPLE_USE_JSON 101 | ocr_manager.SetCallbackDataMode(true);//回调函数的参数传入json 102 | #endif //EXAMPLE_USE_JSON 103 | ocr_manager.SetReadOnPush(OCRUsrReadOnPush); 104 | 105 | //启动WeChatOCR.exe 106 | if (!ocr_manager.StartWeChatOCR()) 107 | { 108 | std::cout << "\033[31m[!] " << ocr_manager.GetLastErrStr() << "\033[0m\n"; 109 | return 1; 110 | } 111 | std::cout << "\033[31m[+] StartWeChatOCR OK!\033[0m\n"; 112 | 113 | //向其发送OCR请求 114 | std::cout << "[=] Press any key to send ocr request...\n"; getchar(); 115 | if (!ocr_manager.DoOCRTask(".\\test.png")) 116 | { 117 | std::cout << "\033[31m[!] " << ocr_manager.GetLastErrStr() << "\033[0m\n"; 118 | return 1; 119 | } 120 | 121 | //结束WeChatOCR.exe 122 | std::cout << "[=] Press any key to stop WeChatOCR Env...\n"; getchar(); 123 | ocr_manager.KillWeChatOCR(); 124 | std::cout << "\033[31m[-] KillWeChatOCR!\033[0m\n"; 125 | 126 | 127 | mmmojocall::ShutdownMMMojoGlobal(); 128 | return 0; 129 | } 130 | -------------------------------------------------------------------------------- /MMMojoCall/examples/cpp/xplugin_player_test.cpp: -------------------------------------------------------------------------------- 1 | /*****************************************************************//** 2 | * @file xplugin_test.cpp 3 | * @brief 此文件代码是使用PlayerManager类调用WeChatPlayer.exe的示例 4 | *********************************************************************/ 5 | 6 | #include 7 | #include 8 | 9 | #include "mmmojo_player.h" 10 | 11 | using namespace qqimpl; 12 | 13 | //简单Player播放窗口类名 14 | const char PLAYER_CLASS_NAME[] = "Simple Player Window Class"; 15 | 16 | //简单Player播放窗口的消息处理事件 17 | LRESULT CALLBACK SimplePlayerWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) 18 | { 19 | return DefWindowProc(hWnd, message, wParam, lParam); 20 | } 21 | 22 | //注册窗口类 为TRUE则注册 FALSE则取消注册 23 | void RegisterSimplePlayerWin32(BOOL reg) 24 | { 25 | if (reg) 26 | { 27 | // Register the window class. 28 | WNDCLASS wc = { }; 29 | 30 | wc.lpfnWndProc = SimplePlayerWndProc; 31 | wc.hInstance = GetModuleHandle(NULL); 32 | wc.lpszClassName = PLAYER_CLASS_NAME; 33 | 34 | RegisterClassA(&wc); 35 | } 36 | else 37 | { 38 | HINSTANCE hInst = GetModuleHandle(NULL); 39 | UnregisterClassA(PLAYER_CLASS_NAME, hInst); 40 | } 41 | } 42 | 43 | //创建窗口 44 | DWORD WINAPI CreateSimplePlayerWIN32(LPVOID lpParam) 45 | { 46 | //解析参数 47 | HWND* lpHwnd = (HWND*)(((DWORD64*)lpParam)[0]); 48 | HANDLE* lpEvent = (LPHANDLE)(((DWORD64*)lpParam)[1]); 49 | 50 | // Create the window. 51 | HWND hwnd = CreateWindowEx( 52 | 0, // Optional window styles. 53 | PLAYER_CLASS_NAME, // Window class 54 | "Simple Player Window", // Window text 55 | WS_OVERLAPPEDWINDOW, // Window style 56 | 57 | // Size and position 58 | CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, 59 | 60 | NULL, // Parent window 61 | NULL, // Menu 62 | GetModuleHandle(NULL), // Instance handle 63 | NULL // Additional application data 64 | ); 65 | 66 | if (hwnd == NULL) 67 | { 68 | SetEvent(*lpEvent);//设置Event 69 | return 0; 70 | } 71 | 72 | *lpHwnd = hwnd;//传递参数 73 | SetEvent(*lpEvent);//设置Event 74 | 75 | ShowWindow(hwnd, SW_SHOWNORMAL); 76 | UpdateWindow(hwnd); 77 | 78 | // 消息循环: 79 | MSG msg; 80 | while (GetMessage(&msg, nullptr, 0, 0)) 81 | { 82 | TranslateMessage(&msg); 83 | DispatchMessage(&msg); 84 | } 85 | return (int)msg.wParam; 86 | } 87 | 88 | 89 | HWND CreateSimplePlayerWindow() 90 | { 91 | HWND winHwnd = NULL; 92 | HANDLE hEvent = CreateEvent(NULL, TRUE, FALSE, NULL); 93 | //前8个字节为LPHWND, 后8个字节为LPEVENT, 最后8个字节为this类指针 94 | DWORD64* lpParam = (DWORD64*)calloc(16, 1); 95 | lpParam[0] = (DWORD64)(&winHwnd); 96 | lpParam[1] = (DWORD64)(&hEvent); 97 | CloseHandle(CreateThread(NULL, 0, CreateSimplePlayerWIN32, lpParam, 0, NULL)); 98 | WaitForSingleObject(hEvent, INFINITE); 99 | free(lpParam); 100 | CloseHandle(hEvent); 101 | return winHwnd; 102 | } 103 | 104 | int main() 105 | { 106 | SetConsoleOutputCP(CP_UTF8); 107 | 108 | std::string wechat_player_dir;//"C:\\Users\\{YourName}\\AppData\Roaming\\Tencent\\WeChat\\XPlugin\\Plugins\\ThumbPlayer\\4063\\extracted\\WeChatPlayer.exe 109 | std::string wechat_dir;//Such as "D:\\WeChat\\[3.9.7.29]" 110 | 111 | std::cout << "\033[34m[=] Enter WeChatPlayer.exe Path:\n[>]\033[0m "; 112 | std::getline(std::cin, wechat_player_dir); 113 | 114 | std::cout << "\033[34m[=] Enter mmmojo(_64).dll Path:\n[>]\033[0m "; 115 | std::getline(std::cin, wechat_dir); 116 | 117 | // 加载mmmojo(_64).dll并获取导出函数, 只需要调用一次. 118 | if (!mmmojocall::InitMMMojoDLLFuncs(wechat_dir.c_str())) 119 | { 120 | std::cout << "\033[31m[!] mmmojocall::InitMMMojoDLLFuncs ERR!\033[0m\n"; 121 | return 1; 122 | } 123 | 124 | // 初始化MMMojo (包括ThreadPool等), 只需要调用一次. 125 | mmmojocall::InitMMMojoGlobal(NULL, NULL); 126 | 127 | 128 | //注册窗口类 129 | RegisterSimplePlayerWin32(TRUE); 130 | 131 | mmmojocall::PlayerManager player_manager; 132 | mmmojocall::PlayerManager::CoreStatus* core_status; 133 | 134 | //设置启动所需参数 135 | player_manager.SetExePath(wechat_player_dir.c_str()); 136 | player_manager.SetSwitchArgs(wechat_dir.c_str()); 137 | 138 | //启动WeChatPlayer.exe 139 | player_manager.StartWeChatPlayer(); 140 | std::cout << "\033[31m[+] StartWeChatPlayer OK!\033[0m\n"; 141 | 142 | 143 | std::string video_path, file_name; 144 | std::cout << "\033[34m[=] Enter The Video Path:\n[>]\033[0m "; 145 | std::getline(std::cin, video_path); 146 | 147 | std::string::size_type iPos = video_path.find_last_of('\\') + 1; 148 | std::string filename_ = video_path.substr(iPos, video_path.length() - iPos); 149 | file_name = filename_.substr(0, filename_.rfind(".")); 150 | 151 | std::cout << "[=] Press any key to Create Player Core...\n"; getchar(); 152 | //创建一个播放器内核 (可以创建多个 一个内核就是一个视频) 153 | int player_id_1 = player_manager.CreatePlayerCore(); 154 | std::cout << "[*] Player Core ID: " << player_id_1 << std::endl; 155 | 156 | //创建WIN32窗口 157 | HWND video_win_1 = CreateSimplePlayerWindow(); 158 | std::cout << "[*] Create Player Window OK [HANDLE: " << video_win_1 << "]\n"; 159 | 160 | player_manager.InitPlayerCore(player_id_1, video_win_1, file_name.c_str(), video_path.c_str()); 161 | std::cout << "[*] Init Player [" << player_id_1 << "] Core OK!\n"; 162 | 163 | std::cout << "[*] Player [" << player_id_1 << "] Core Status:\n{\n"; 164 | core_status = player_manager.GetPlayerCoreStatus(player_id_1); 165 | std::cout << "\tSize: " << core_status->org_width << " | " << core_status->org_height << std::endl; 166 | std::cout << "\tDuration: " << core_status->duration << std::endl; 167 | std::cout << "}\n"; 168 | 169 | std::cout << "[=] Press any key to Start Video...\n"; getchar(); 170 | player_manager.StartVideo(player_id_1); 171 | 172 | std::cout << "[=] Press any key to Pause Video...\n"; getchar(); 173 | player_manager.PauseVideo(player_id_1); 174 | 175 | std::cout << "[=] Press any key to Resume Video...\n"; getchar(); 176 | player_manager.ResumeVideo(player_id_1); 177 | 178 | std::cout << "[=] Press any key to Get Video Current Pos(ms)...\n"; getchar(); 179 | int pos_ms = player_manager.GetCurrentPosition(player_id_1); 180 | std::cout << "[*] Player [" << player_id_1 << "] Core Pos: [" << pos_ms << "]\n"; 181 | 182 | std::cout << "[=] Press any key to Seek to pos 0(begin)...\n"; getchar(); 183 | player_manager.SeekToVideo(player_id_1, 0.0); 184 | 185 | std::cout << "[=] Press any key to Mute Video...\n"; getchar(); 186 | player_manager.MuteVideo(player_id_1, true); 187 | 188 | std::cout << "[=] Press any key to Cancel Mute Video...\n"; getchar(); 189 | player_manager.MuteVideo(player_id_1, false); 190 | 191 | std::cout << "[=] Press any key to Set Video Speed Ratio x2...\n"; getchar(); 192 | player_manager.SetSpeedVideo(player_id_1, 2.0); 193 | 194 | std::cout << "[=] Press any key to Stop Video...\n"; getchar(); 195 | player_manager.StopVideo(player_id_1); 196 | 197 | std::cout << "[=] Press any key to Destroy Player Core...\n"; getchar(); 198 | player_manager.DestroyPlayerCore(player_id_1); 199 | 200 | std::cout << "[=] Press any key to Kill WeChatPlayer.exe...\n"; getchar(); 201 | player_manager.KillWeChatPlayer(); 202 | 203 | //卸载窗口类 204 | RegisterSimplePlayerWin32(FALSE); 205 | 206 | mmmojocall::ShutdownMMMojoGlobal(); 207 | return 0; 208 | } 209 | -------------------------------------------------------------------------------- /MMMojoCall/examples/cpp/xplugin_test.cpp: -------------------------------------------------------------------------------- 1 | /*****************************************************************//** 2 | * @file xplugin_test.cpp 3 | * @brief 此文件代码是直接使用XPluginManager类调用微信XPlugin组件(WeChatOCR)的示例 4 | *********************************************************************/ 5 | 6 | #include 7 | #include 8 | 9 | #include "mmmojo_call.h" 10 | 11 | using namespace qqimpl; 12 | 13 | //↓mmmojo::common::MMMojoReadOnPush; 14 | void UsrReadOnPush(uint32_t request_id, const void* request_info, void* user_data) 15 | { 16 | std::cout << "[↓] " << __FUNCTION__ << " [RequestID: " << request_id << "] :\n[\n"; 17 | 18 | uint32_t pb_size; 19 | const void* pb_data = mmmojocall::GetPbSerializedData(request_info, pb_size); 20 | 21 | std::cout << "\t[*] Request ID: " << request_id << " | Protobuf Size: " << pb_size << std::endl; 22 | std::cout << "\t[*] Protobuf Data: "; 23 | for (size_t i = 0; i < pb_size; i++) 24 | { 25 | printf_s("0x%02X ", ((LPBYTE)pb_data)[i]); 26 | } 27 | 28 | mmmojocall::RemoveReadInfo(request_info); 29 | 30 | std::cout << "\n]" << std::endl; 31 | } 32 | 33 | int main() 34 | { 35 | SetConsoleOutputCP(CP_UTF8); 36 | 37 | std::string wechat_ocr_dir;//"C:\\Users\\{YourName}\\AppData\\Roaming\\Tencent\\WeChat\\XPlugin\\Plugins\\WeChatOCR\\7057\\extracted\\WeChatOCR.exe" 38 | std::string wechat_dir;//Such as "D:\\WeChat\\[3.9.7.29]" 39 | 40 | std::cout << "\033[34m[=] Enter WeChatOCR.exe Path:\n[>]\033[0m "; 41 | std::getline(std::cin, wechat_ocr_dir); 42 | 43 | std::cout << "\033[34m[=] Enter mmmojo(_64).dll Path:\n[>]\033[0m "; 44 | std::getline(std::cin, wechat_dir); 45 | 46 | // 加载mmmojo(_64).dll并获取导出函数, 只需要调用一次. 47 | if (!mmmojocall::InitMMMojoDLLFuncs(wechat_dir.c_str())) 48 | { 49 | std::cout << "\033[31m[!] mmmojocall::InitMMMojoDLLFuncs ERR!\033[0m\n"; 50 | return 1; 51 | } 52 | 53 | // 初始化MMMojo (包括ThreadPool等), 只需要调用一次. 54 | mmmojocall::InitMMMojoGlobal(NULL, NULL); 55 | 56 | //------------------------------- 57 | //以下为直接使用XPluginManager类调用微信XPlugin组件(WeChatOCR)的示例 58 | mmmojocall::XPluginManager xplugin_manager; 59 | if (!xplugin_manager.SetExePath(wechat_ocr_dir.c_str()))//设置XPlugin组件路径 60 | { 61 | std::cout << "\033[31m[!] " << xplugin_manager.GetLastErrStr() << "\033[0m\n"; 62 | return 1; 63 | } 64 | xplugin_manager.AppendSwitchNativeCmdLine("user-lib-dir", wechat_dir.c_str());//添加需要的Switch命令行 65 | xplugin_manager.SetOneCallback(MMMojoEnvironmentCallbackType::kMMReadPush, UsrReadOnPush);//设置ReadPush回调函数 66 | if (!xplugin_manager.StartMMMojoEnv())//启动环境和组件 67 | { 68 | std::cout << "\033[31m[!] " << xplugin_manager.GetLastErrStr() << "\033[0m\n"; 69 | return 1; 70 | } 71 | std::cout << "\033[31m[+] InitMMMojoEnv OK!\033[0m\n"; 72 | std::cout << "\033[31m[*] Will Use \'.\\test.png\' for test\033[0m\n"; 73 | 74 | //以下为图片路径为:".\test.png"的序列化数据 75 | unsigned char pb_hex_data[16] = { 76 | 0x10, 0x01, 0x1A, 0x0C, 0x0A, 0x0A, 0x2E, 0x5C, 0x74, 0x65, 0x73, 0x74, 0x2E, 0x70, 0x6E, 0x67 77 | }; 78 | 79 | std::cout << "[=] Press any key to send request...\n"; getchar();//发送请求 80 | xplugin_manager.SendPbSerializedData(pb_hex_data, sizeof(pb_hex_data), MMMojoInfoMethod::kMMPush, false, mmmojocall::RequestIdOCR::OCRPush); 81 | 82 | std::cout << "[=] Press any key to stop xplugin mmmojo env...\n"; getchar();//停止环境 83 | xplugin_manager.StopMMMojoEnv(); 84 | std::cout << "\033[31m[-] StopMMMojoEnv...\033[0m\n"; 85 | 86 | 87 | mmmojocall::ShutdownMMMojoGlobal(); 88 | return 0; 89 | } 90 | -------------------------------------------------------------------------------- /MMMojoCall/examples/cpp/xplugin_utility_test.cpp: -------------------------------------------------------------------------------- 1 | /*****************************************************************//** 2 | * @file xplugin_test.cpp 3 | * @brief 此文件代码是UtilityManager类调用WeChatUtility扫描二维码的示例 4 | *********************************************************************/ 5 | 6 | #include 7 | #include 8 | 9 | #include "mmmojo_utility.h" 10 | 11 | using namespace qqimpl; 12 | 13 | void UtilityUsrReadOnPush(int type, const void* data, int data_size) 14 | { 15 | std::cout << "[↓] " << __FUNCTION__ << " [RequestID: " << type << "] :\n[\n"; 16 | 17 | switch (type) 18 | { 19 | case mmmojocall::RequestIdUtility::UtilityTextScanPushResp: 20 | { 21 | #ifdef EXAMPLE_USE_JSON 22 | std::cout << (char*)data << std::endl; 23 | #else 24 | utility_protobuf::TextScanMessage text_scan_msg; 25 | text_scan_msg.ParseFromArray(data, data_size); 26 | 27 | char out_buf[512] = { 0 }; 28 | sprintf_s(out_buf, sizeof(out_buf), "\t[*] TextScanResult: ID: [%d] | PicPath: [%s] | HaveText?: [%d] | UKN0: [%d] | Rate: [%f]\n", 29 | text_scan_msg.text_scan_id(), text_scan_msg.pic_path().c_str(), text_scan_msg.have_text(), text_scan_msg.unknown_0(), text_scan_msg.rate()); 30 | std::cout << out_buf; 31 | #endif // EXAMPLE_USE_JSON 32 | } 33 | break; 34 | default: 35 | break; 36 | } 37 | 38 | std::cout << "\n]" << std::endl; 39 | } 40 | 41 | void UtilityUsrReadOnPull(int type, const void* data, int data_size) 42 | { 43 | std::cout << "[↓] " << __FUNCTION__ << " [RequestID: " << type << "] :\n[\n"; 44 | 45 | switch (type) 46 | { 47 | case mmmojocall::RequestIdUtility::UtilityQRScanPullResp: 48 | { 49 | #ifdef EXAMPLE_USE_JSON 50 | std::cout << (char*)data << std::endl; 51 | #else 52 | utility_protobuf::QRScanRespMessage qrscan_response; 53 | qrscan_response.ParseFromArray(data, data_size); 54 | 55 | std::cout << "\t[*] QRScanResult UKN0: [" << qrscan_response.unknown_0() << "] :\n\t[\n"; 56 | for (int i = 0; i < qrscan_response.qr_result_size(); i++) 57 | { 58 | utility_protobuf::QRScanRespMessage::QRScanResult qrscan_result = qrscan_response.qr_result(i); 59 | std::string result = qrscan_result.result(); 60 | uint32_t unknown_0 = qrscan_result.unknow_0(); 61 | double unknown_1 = qrscan_result.unknown_1(); 62 | double unknown_2 = qrscan_result.unknown_2(); 63 | uint32_t unknown_3 = qrscan_result.unknown_3(); 64 | 65 | char out_buf[512] = { 0 }; 66 | sprintf_s(out_buf, sizeof(out_buf), "\t\tResult: [%s] | UKN0: [%d] | UKN1: [%f] | UKN2: [%f] | UNK3: [%d]\n", 67 | result.c_str(), unknown_0, unknown_1, unknown_2, unknown_3); 68 | std::cout << out_buf; 69 | } 70 | std::cout << "\t]"; 71 | #endif 72 | } 73 | break; 74 | default: 75 | break; 76 | } 77 | 78 | std::cout << "\n]" << std::endl; 79 | } 80 | 81 | int main() 82 | { 83 | SetConsoleOutputCP(CP_UTF8); 84 | 85 | std::string wechat_utility_dir;//"C:\\Users\\{YourName}\\AppData\\Roaming\\Tencent\\WeChat\\XPlugin\\Plugins\\WeChatUtility\\8077\\extracted\\WeChatUtility.exe" 86 | std::string wechat_dir;//Such as "D:\\WeChat\\[3.9.7.29]" 87 | 88 | std::cout << "\033[34m[=] Enter WeChatUtility.exe Path:\n[>]\033[0m "; 89 | std::getline(std::cin, wechat_utility_dir); 90 | 91 | std::cout << "\033[34m[=] Enter mmmojo(_64).dll Path:\n[>]\033[0m "; 92 | std::getline(std::cin, wechat_dir); 93 | 94 | // 加载mmmojo(_64).dll并获取导出函数, 只需要调用一次. 95 | if (!mmmojocall::InitMMMojoDLLFuncs(wechat_dir.c_str())) 96 | { 97 | std::cout << "\033[31m[!] mmmojocall::InitMMMojoDLLFuncs ERR!\033[0m\n"; 98 | return 1; 99 | } 100 | 101 | // 初始化MMMojo (包括ThreadPool等), 只需要调用一次. 102 | mmmojocall::InitMMMojoGlobal(NULL, NULL); 103 | 104 | 105 | //UtilityManager类调用WeChatUtility扫描二维码的示例 106 | mmmojocall::UtilityManager utility_manager; 107 | if (!utility_manager.SetExePath(wechat_utility_dir.c_str())) 108 | { 109 | std::cout << "\033[31m[!] " << utility_manager.GetLastErrStr() << "\033[0m\n"; 110 | return 1; 111 | } 112 | 113 | if (!utility_manager.SetUsrLibDir(wechat_dir.c_str())) 114 | { 115 | std::cout << "\033[31m[!] " << utility_manager.GetLastErrStr() << "\033[0m\n"; 116 | return 1; 117 | } 118 | 119 | #ifdef EXAMPLE_USE_JSON 120 | utility_manager.SetCallbackDataMode(true);//回调函数的参数传入json 121 | #endif //EXAMPLE_USE_JSON 122 | 123 | //设置回调函数, Push用于接收TextScan的结果 124 | utility_manager.SetReadOnPull(UtilityUsrReadOnPull); 125 | utility_manager.SetReadOnPush(UtilityUsrReadOnPush); 126 | 127 | //启动WeChatUtility.exe 128 | if (!utility_manager.StartWeChatUtility()) 129 | { 130 | std::cout << "\033[31m[!] " << utility_manager.GetLastErrStr() << "\033[0m\n"; 131 | return 1; 132 | } 133 | std::cout << "\033[31m[+] StartWeChatUtility OK!\033[0m\n"; 134 | 135 | //发起QRScan请求, 第二个参数为TextScan的任务ID 136 | std::cout << "[=] Press any key to send QRScan request...\n"; getchar(); 137 | if (!utility_manager.DoPicQRScan(".\\test.png", 0xEE)) 138 | { 139 | std::cout << "\033[31m[!] " << utility_manager.GetLastErrStr() << "\033[0m\n"; 140 | } 141 | 142 | //结束WeChatUtility.exe 143 | std::cout << "[=] Press any key to stop WeChatUtility Env...\n"; getchar(); 144 | utility_manager.KillWeChatUtility(); 145 | std::cout << "\033[31m[-] KillWeChatUtility\033[0m\n"; 146 | 147 | 148 | mmmojocall::ShutdownMMMojoGlobal(); 149 | return 0; 150 | } 151 | -------------------------------------------------------------------------------- /MMMojoCall/examples/java/MMMojoCallUsage.java: -------------------------------------------------------------------------------- 1 | import com.sun.jna.Library; 2 | import com.sun.jna.Native; 3 | import com.sun.jna.Pointer; 4 | 5 | interface MMMojoCall extends Library { 6 | public static MMMojoCall MMMojoCallDLL = Native.load("./MMMojoCall.dll", MMMojoCall.class); 7 | 8 | // 声明DLL导出函数 9 | Pointer GetInstanceXPluginMgr(int mgr_type); 10 | 11 | int CallFuncXPluginMgr(Pointer class_ptr, int mgr_type, String func_name, Pointer ret_ptr, Object ... args); 12 | 13 | void ReleaseInstanceXPluginMgr(String mgr_ptr); 14 | 15 | } 16 | 17 | public class MMMojoCallUsage { 18 | public static void main(String[] args) { 19 | // 调用DLL导出函数 20 | Pointer cobj_ocr_mgr = MMMojoCall.MMMojoCallDLL.GetInstanceXPluginMgr(1); 21 | System.out.println("未完成"); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /MMMojoCall/examples/python/mmmojo_call_usage.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | import ctypes 4 | import sys 5 | import json 6 | import base64 7 | 8 | def PyOCRUsrReadOnPush(pic_path, data, data_size): 9 | print("[↓] OCRUsrReadOnPush:\n[") 10 | 11 | # 设置了Mode的use_json为True则data为json字符串 12 | if pic_path != None: 13 | chr_ptr = ctypes.cast(data, ctypes.c_char_p) 14 | json_string = chr_ptr.value.decode('utf-8') 15 | json_obj = json.loads(json_string) 16 | 17 | # 解析json 18 | print("\t[*] type:{} taskId:{} errCode:{}".format(json_obj['type'], json_obj['task_id'], json_obj['err_code'])) 19 | print("\t[*] TaskId: {} -> PicPath: {}".format(json_obj['task_id'], pic_path.decode('utf-8'))); 20 | 21 | print("\t[*] OcrResult:\n\t[") 22 | response_ocr_result = json_obj['ocr_result'] 23 | for single_result in response_ocr_result['single_result']: 24 | print("\t\tRECT:[left: {}, top: {}, right: {}, bottom: {}]".format(single_result['left'], single_result['top'], single_result['right'], single_result['bottom'])) 25 | b64str = single_result['single_str_utf8'] 26 | single_str = base64.b64decode(b64str).decode('utf-8') 27 | print("\t\tUTF8STR:[{} | Rate: {}]".format(single_str, single_result['single_rate'])) 28 | print("\t]", end="") 29 | print("\n]") 30 | 31 | 32 | def PyUtilityUsrReadOnPush(type_id, data, data_size): 33 | print("[↓] PyUtilityUsrReadOnPush [RequestID: {}] :\n[".format(type_id)) 34 | 35 | UtilityTextScanPushResp = 10040 36 | # 设置了Mode的use_json为True则data为json字符串 37 | if type_id == UtilityTextScanPushResp: 38 | chr_ptr = ctypes.cast(data, ctypes.c_char_p) 39 | json_string = chr_ptr.value.decode('utf-8') 40 | json_obj = json.loads(json_string) 41 | print("\t[*] TextScanResult: ID: [{}] | PicPath: [{}] | HaveText?: [{}] | UKN0: [{}] | Rate: [{}]".format(\ 42 | json_obj['text_scan_id'], json_obj['pic_path'], json_obj['have_text'], json_obj['unknown_0'], json_obj['rate'])) 43 | print("\n]") 44 | 45 | def PyUtilityUsrReadOnPull(type_id, data, data_size): 46 | print("[↓] PyUtilityUsrReadOnPush [RequestID: {}] :\n[".format(type_id)) 47 | 48 | UtilityInitPullResp = 10003 49 | UtilityQRScanPullResp = 10032 50 | if type_id == UtilityInitPullResp: 51 | print("\t[*] UtilityInitPullResp", end="") 52 | elif type_id == UtilityQRScanPullResp: 53 | chr_ptr = ctypes.cast(data, ctypes.c_char_p) 54 | json_string = chr_ptr.value.decode('utf-8') 55 | json_obj = json.loads(json_string) 56 | 57 | print("\t[*] QRScanResult UKN0: [{}] :\n\t[".format(json_obj['unknown_0'])) 58 | for qrscan_result in json_obj['qr_result']: 59 | b64result = qrscan_result['result'] 60 | result = base64.b64decode(b64result).decode('utf-8') 61 | unknown_0 = qrscan_result['unknow_0'] 62 | unknown_1 = qrscan_result['unknown_1'] 63 | unknown_2 = qrscan_result['unknown_2'] 64 | unknown_3 = qrscan_result['unknown_3'] 65 | print("\t\tResult: [{}] | UKN0: [{}] | UKN1: [{}] | UKN2: [{}] | UNK3: [{}]".format(result, unknown_0, unknown_1, unknown_2, unknown_3)) 66 | print("\t]", end="") 67 | 68 | print("\n]") 69 | 70 | # 调用XPluginManager::GetLastErrStr 71 | def call_mmmojocall_getlasterrstr(cobj_mgr): 72 | call_ret = ctypes.c_ulonglong() 73 | method_get_last_err_str = ctypes.c_char_p("GetLastErrStr".encode('utf-8')) 74 | mmmojocall_call_func(cobj_mgr, 0, method_get_last_err_str, ctypes.byref(call_ret)) 75 | chr_ptr = ctypes.cast(call_ret.value, ctypes.c_char_p) 76 | err_string = chr_ptr.value.decode('utf-8') 77 | return err_string 78 | 79 | if __name__ == '__main__': 80 | mmmojocall_dll = ctypes.cdll.LoadLibrary('./MMMojoCall.dll') 81 | print('[+] LoadLibrary MMMojoCall.dll OK!') 82 | 83 | #------------------------- 84 | #以下为DLL导出函数初始化操作 85 | mmmojocall_get_instance = mmmojocall_dll.GetInstanceXPluginMgr 86 | mmmojocall_get_instance.argtypes = [ctypes.c_int] 87 | mmmojocall_get_instance.restype = ctypes.c_void_p 88 | 89 | mmmojocall_call_func = mmmojocall_dll.CallFuncXPluginMgr 90 | mmmojocall_call_func.argtypes = [ctypes.c_void_p, ctypes.c_int, ctypes.c_char_p, ctypes.c_void_p] 91 | mmmojocall_call_func.restype = ctypes.c_int 92 | 93 | mmmojocall_release_instance = mmmojocall_dll.ReleaseInstanceXPluginMgr 94 | mmmojocall_release_instance.argtypes = [ctypes.c_void_p] 95 | mmmojocall_release_instance.restype = None 96 | 97 | mmmojocall_init_dll_funcs = mmmojocall_dll.InitMMMojoDLLFuncs 98 | mmmojocall_init_dll_funcs.argtypes = [ctypes.c_char_p] 99 | mmmojocall_init_dll_funcs.restype = ctypes.c_bool 100 | 101 | mmmojocall_init_mmmojo_global_func = mmmojocall_dll.InitMMMojoGlobal 102 | mmmojocall_init_mmmojo_global_func.argtypes = [ctypes.c_int, ctypes.c_char_p] 103 | mmmojocall_init_mmmojo_global_func.restype = ctypes.c_bool 104 | 105 | mmmojocall_shutdown_mmmojo_global_func = mmmojocall_dll.ShutdownMMMojoGlobal 106 | mmmojocall_shutdown_mmmojo_global_func.restype = ctypes.c_bool 107 | 108 | print('[+] Init Dll Export Funcs Over!') 109 | 110 | #---------------------------- 111 | #以下为读入WeChat组件路径 112 | wechat_ocr_dir = input('\033[34m[=] Enter WeChatOCR.exe Path:\n[>]\033[0m ') 113 | if not wechat_ocr_dir: 114 | print('[!] WeChatOCR.exe Path can\'t be EMPTY!') 115 | sys.exit(1) 116 | wechat_ocr_dir_c = ctypes.c_char_p(wechat_ocr_dir.encode('utf-8')) 117 | 118 | wechat_dir = input('\033[34m[=] Enter mmmojo(_64).dll Path:\n[>]\033[0m ') 119 | if not wechat_ocr_dir: 120 | print('[!] mmmojo(_64).dll Path can\'t be EMPTY!') 121 | sys.exit(1) 122 | wechat_dir_c = ctypes.c_char_p(wechat_dir.encode('utf-8')) 123 | 124 | wechat_utility_dir = input('\033[34m[=] Enter WeChatUtility.exe Path:\n[>]\033[0m ') 125 | if not wechat_ocr_dir: 126 | print('[!] WeChatUtility.exe Path can\'t be EMPTY!') 127 | sys.exit(1) 128 | wechat_utility_dir_c = ctypes.c_char_p(wechat_utility_dir.encode('utf-8')) 129 | 130 | #----------------------------- 131 | #以下为定义回调函数 132 | CFUNC_PYOCRUSRREADONPUSH = ctypes.CFUNCTYPE(None, ctypes.c_char_p, ctypes.c_void_p, ctypes.c_int) 133 | py_ocr_usr_read_on_push = CFUNC_PYOCRUSRREADONPUSH(PyOCRUsrReadOnPush) 134 | 135 | CFUNC_PYUTILITYUSRREADONPUSH = ctypes.CFUNCTYPE(None, ctypes.c_int, ctypes.c_void_p, ctypes.c_int) 136 | py_utility_usr_read_on_push = CFUNC_PYUTILITYUSRREADONPUSH(PyUtilityUsrReadOnPush) 137 | 138 | CFUNC_PYUTILITYUSRREADONPULL = ctypes.CFUNCTYPE(None, ctypes.c_int, ctypes.c_void_p, ctypes.c_int) 139 | py_utility_usr_read_on_pull = CFUNC_PYUTILITYUSRREADONPULL(PyUtilityUsrReadOnPull) 140 | print('\033[31m[+] Def Python Callback Funcs Over!\033[0m') 141 | 142 | ''' 143 | 加载mmmojo(_64).dll并获取导出函数, 只需要调用一次. 144 | ''' 145 | if not mmmojocall_init_dll_funcs(wechat_dir_c): 146 | print('\033[31m[!] mmmojocall::InitMMMojoDLLFuncs ERR!\033[0m') 147 | sys.exit(1) 148 | print('\033[31m[+] InitMMMojoDLLFuncs Over!\033[0m') 149 | 150 | # 初始化MMMojo (包括ThreadPool等), 只需要调用一次. 151 | mmmojocall_init_mmmojo_global_func(0, None); 152 | 153 | #------------------------ 154 | #以下为使用封装好的OCRManager类调用WeChatOCR进行OCR的示例 与 UtilityManager类调用WeChatUtility扫描二维码的示例 155 | call_ret = ctypes.c_ulonglong() 156 | 157 | mgr_type_ocr = 1 158 | cobj_ocr_mgr = mmmojocall_get_instance(mgr_type_ocr) 159 | 160 | method_name = ctypes.c_char_p("SetExePath".encode('utf-8')) 161 | mmmojocall_call_func(cobj_ocr_mgr, mgr_type_ocr, method_name, ctypes.byref(call_ret), wechat_ocr_dir_c) 162 | if not call_ret.value: 163 | print('\033[31m[!] {}\033[0m'.format(call_mmmojocall_getlasterrstr(cobj_ocr_mgr))) 164 | sys.exit(1) 165 | 166 | method_name = ctypes.c_char_p("SetUsrLibDir".encode('utf-8')) 167 | mmmojocall_call_func(cobj_ocr_mgr, mgr_type_ocr, method_name, ctypes.byref(call_ret), wechat_dir_c) 168 | if not call_ret: 169 | print('\033[31m[!] {}\033[0m'.format(call_mmmojocall_getlasterrstr(cobj_ocr_mgr))) 170 | sys.exit(1) 171 | 172 | method_name = ctypes.c_char_p("SetCallbackDataMode".encode('utf-8')) 173 | mmmojocall_call_func(cobj_ocr_mgr, mgr_type_ocr, method_name, ctypes.byref(call_ret), True) 174 | 175 | method_name = ctypes.c_char_p("SetReadOnPush".encode('utf-8')) 176 | mmmojocall_call_func(cobj_ocr_mgr, mgr_type_ocr, method_name, ctypes.byref(call_ret), py_ocr_usr_read_on_push) 177 | 178 | method_name = ctypes.c_char_p("StartWeChatOCR".encode('utf-8')) 179 | mmmojocall_call_func(cobj_ocr_mgr, mgr_type_ocr, method_name, ctypes.byref(call_ret)) 180 | if not call_ret: 181 | print('\033[31m[!] {}\033[0m'.format(call_mmmojocall_getlasterrstr(cobj_ocr_mgr))) 182 | sys.exit(1) 183 | 184 | print("\033[31m[+] StartWeChatOCR OK!\033[0m") 185 | 186 | input("[=] Press any key to send ocr request...\n") 187 | method_name = ctypes.c_char_p("DoOCRTask".encode('utf-8')) 188 | pic_path_c = ctypes.c_char_p(".\\test.png".encode('utf-8')) 189 | mmmojocall_call_func(cobj_ocr_mgr, mgr_type_ocr, method_name, ctypes.byref(call_ret), pic_path_c) 190 | if not call_ret: 191 | print('\033[31m[!] {}\033[0m'.format(call_mmmojocall_getlasterrstr(cobj_ocr_mgr))) 192 | sys.exit(1) 193 | 194 | input("[=] Press any key to stop WeChatOCR Env...\n") 195 | method_name = ctypes.c_char_p("KillWeChatOCR".encode('utf-8')) 196 | mmmojocall_call_func(cobj_ocr_mgr, mgr_type_ocr, method_name, None) 197 | print("\033[31m[-] KillWeChatOCR!\033[0m") 198 | 199 | mmmojocall_release_instance(cobj_ocr_mgr) 200 | 201 | #QRScan 202 | mgr_type_utility = 2 203 | cobj_utility_mgr = mmmojocall_get_instance(mgr_type_utility) 204 | 205 | method_name = ctypes.c_char_p("SetExePath".encode('utf-8')) 206 | mmmojocall_call_func(cobj_utility_mgr, mgr_type_utility, method_name, ctypes.byref(call_ret), wechat_utility_dir_c) 207 | if not call_ret.value: 208 | print('\033[31m[!] {}\033[0m'.format(call_mmmojocall_getlasterrstr(cobj_utility_mgr))) 209 | sys.exit(1) 210 | 211 | method_name = ctypes.c_char_p("SetUsrLibDir".encode('utf-8')) 212 | mmmojocall_call_func(cobj_utility_mgr, mgr_type_utility, method_name, ctypes.byref(call_ret), wechat_dir_c) 213 | if not call_ret: 214 | print('\033[31m[!] {}\033[0m'.format(call_mmmojocall_getlasterrstr(cobj_utility_mgr))) 215 | sys.exit(1) 216 | 217 | method_name = ctypes.c_char_p("SetCallbackDataMode".encode('utf-8')) 218 | mmmojocall_call_func(cobj_utility_mgr, mgr_type_utility, method_name, ctypes.byref(call_ret), True) 219 | 220 | method_name = ctypes.c_char_p("SetReadOnPull".encode('utf-8')) 221 | mmmojocall_call_func(cobj_utility_mgr, mgr_type_utility, method_name, ctypes.byref(call_ret), py_utility_usr_read_on_pull) 222 | 223 | method_name = ctypes.c_char_p("SetReadOnPush".encode('utf-8')) 224 | mmmojocall_call_func(cobj_utility_mgr, mgr_type_utility, method_name, ctypes.byref(call_ret), py_utility_usr_read_on_push) 225 | 226 | method_name = ctypes.c_char_p("StartWeChatUtility".encode('utf-8')) 227 | mmmojocall_call_func(cobj_utility_mgr, mgr_type_utility, method_name, ctypes.byref(call_ret)) 228 | if not call_ret: 229 | print('\033[31m[!] {}\033[0m'.format(call_mmmojocall_getlasterrstr(cobj_utility_mgr))) 230 | sys.exit(1) 231 | 232 | print("\033[31m[+] StartWeChatUtility OK!\033[0m") 233 | 234 | input("[=] Press any key to send OCRScan request...\n") 235 | method_name = ctypes.c_char_p("DoPicQRScan".encode('utf-8')) 236 | pic_path_c = ctypes.c_char_p(".\\test.png".encode('utf-8')) 237 | text_scan_id = 1 238 | mmmojocall_call_func(cobj_utility_mgr, mgr_type_utility, method_name, ctypes.byref(call_ret), pic_path_c, text_scan_id) 239 | if not call_ret: 240 | print('\033[31m[!] {}\033[0m'.format(call_mmmojocall_getlasterrstr(cobj_utility_mgr))) 241 | sys.exit(1) 242 | 243 | input("[=] Press any key to stop WeChatUtility Env...\n") 244 | method_name = ctypes.c_char_p("KillWeChatUtility".encode('utf-8')) 245 | mmmojocall_call_func(cobj_utility_mgr, mgr_type_utility, method_name, None) 246 | print("\033[31m[-] KillWeChatUtility!\033[0m") 247 | 248 | mmmojocall_release_instance(cobj_utility_mgr) 249 | 250 | mmmojocall_shutdown_mmmojo_global_func() 251 | 252 | 253 | -------------------------------------------------------------------------------- /MMMojoCall/proto/ocr_protobuf.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package ocr_protobuf; 4 | 5 | message OcrResponse { 6 | int32 type = 1; //第一次运行OCR会有push一次type1, 正常OCR结束type0 7 | int32 task_id = 2; 8 | int32 err_code = 3; 9 | 10 | message OcrResult { 11 | message ResultPos { //四个角的坐标 左上 右上 右下 左下 12 | message PosXY { 13 | float x = 1; 14 | float y = 2; 15 | } 16 | 17 | repeated PosXY pos = 1; 18 | } 19 | 20 | message SingleResult { //SingleResult是一行结果 OneResult是单字的 21 | ResultPos single_pos = 1; 22 | bytes single_str_utf8 = 2; //UTF8格式的字符串 23 | float single_rate = 3; //单行的识别率 24 | 25 | message OneResult { 26 | ResultPos one_pos = 1; 27 | bytes one_str_utf8 = 2; 28 | } 29 | 30 | repeated OneResult one_result = 4; 31 | float left = 5; //识别矩形的left\top\right\bottom的坐标 32 | float top = 6; 33 | float right = 7; 34 | float bottom = 8; 35 | int32 unknown_0 = 9; //未知 36 | ResultPos unknown_pos = 10; //未知 37 | } 38 | 39 | repeated SingleResult single_result = 1; //repeated 每行的结果 40 | int32 unknown_1 = 2; 41 | int32 unknown_2 = 3; 42 | } 43 | 44 | OcrResult ocr_result = 4; 45 | } 46 | 47 | 48 | message OcrRequest { 49 | int32 unknow = 1; //必定为0 50 | int32 task_id = 2; 51 | 52 | message PicPaths { 53 | repeated string pic_path = 1; //不一定是repeadted 猜的 54 | } 55 | 56 | PicPaths pic_path = 3; 57 | } -------------------------------------------------------------------------------- /MMMojoCall/proto/player_protobuf.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package player_protobuf; 4 | 5 | //WeChatWin: 10011(发) -> 10012(收) -> 10010(发) -> 10030(收) -> 10028(发) -> 10028(发) -> 10030(收) -> 10030(收) -> 10032(收) -> 10030(收) -> 10032(收) -> 10030(收) -> 10014(收) -> 6 | //WeChatPlayer: 1011(收) -> 10012(发) -> 10010(收) -> 10030(发) -> 10028(收) -> 10028(收) -> 10030(发) -> 10030(发) -> 10032(发) -> 10030(发) -> 10030(发) -> 10030(发) -> 10014(发) -> 7 | //所有int32都有可能是以下类型: int32,int64,uint32,uint64,sint32,sint64,bool,enum 8 | 9 | message InitReqMessage { 10 | int32 expire_timestamp = 1; //可能是过期时间 11 | int32 type = 2; //为1 12 | } 13 | 14 | message InitRespMessage { 15 | int32 status = 1; //为1 16 | } 17 | 18 | message CreatePlayerCoreReqMessage { 19 | int32 player_id = 1; 20 | int32 is_post_frame = 2; //为1 21 | } 22 | 23 | message CreatePlayerCoreRespMessage { 24 | int32 player_id = 1; //可能是 应该是返回1 25 | int32 is_suceess = 2; //可能是 应该是返回1 26 | } 27 | 28 | message InitPlayerCoreMessage { 29 | int32 player_id = 1; //Player ID 30 | string file_name = 2; //文件名 (不包括最后一个字母 不包括扩展名) 31 | string file_path = 3; //要播放的视频路径 32 | int64 file_size = 4; //网络视频的大小 本地时为0 33 | bool is_local = 5; //视频是来自本地还是网络 为1 34 | int32 placeholder_6 = 6; //为0 35 | int64 media_id = 7; //为1 36 | bool is_audio_mute = 8; //是否设置静音 为0 37 | int64 video_surface = 9; //窗口句柄 38 | float audio_volume = 10; //音量 为1.0 39 | int32 is_repeat = 11; //是否设置重复播放 为1 40 | float speed_ratio = 12; //播放速率 为1.0 41 | int32 max_frame_width = 13; //为0 42 | int32 max_frame_height = 14; //为0 43 | int32 codec_type = 15; //为-1 44 | int64 decoder_type = 16; //为-1 45 | } 46 | 47 | message InfoPlayerCoreMessage { 48 | int32 player_id = 1; //. 49 | string type = 2; //例如"video decoder type" "the first shard opened" "Unknow Player Msg" "read the first data packets" "read the key frame packet"... "whether to use p2p" 50 | int32 arg = 3; //未知 106 0 0 0 0... 1 51 | int32 unknown_2 = 4; //1或0 1 0 0 0 0... 0 52 | } 53 | 54 | //10014 10015 10016 10017 10018 55 | message PlayerIdMessage { 56 | int32 player_id = 1; 57 | } 58 | 59 | message CurrentPositionMsMessage { 60 | int32 unknown = 1; //为0 61 | } 62 | 63 | message CurrentPositionMsInfo { 64 | message MsInfo{ 65 | int32 player_id = 1; 66 | int32 pos = 2; 67 | } 68 | 69 | repeated bytes ms_info = 1; //这里面是MsInfo序列化 70 | } 71 | 72 | message ResizePlayerCoreMessage { 73 | int32 player_id = 1; 74 | int32 new_width = 2; 75 | int32 new_height = 3; 76 | } 77 | 78 | message VideoSizeChangedPlayerCoreMessage { 79 | int32 player_id = 1; 80 | int32 org_width = 2; //可能是 81 | int32 org_height = 3; //可能是 82 | } 83 | 84 | message PreparePlayerCoreMessage { 85 | int32 player_id = 1; 86 | int32 duration = 2; //视频时长 时分秒 87 | } 88 | 89 | message StatePlayerCoreMessage { 90 | int32 player_id = 1; 91 | int32 state = 2; //4: 开始播放 8: 停止播放 92 | } 93 | 94 | //以下都可能是 没有验证 95 | 96 | message AudioMutePlayerCoreMessage { 97 | int32 player_id = 1; 98 | bool is_audio_mute = 2; 99 | } 100 | 101 | message SeekToPlayerCoreMessage { 102 | int32 player_id = 1; 103 | int32 pos_ms = 2; 104 | } 105 | 106 | message VideoSurfaceMessage { 107 | int32 player_id = 1; 108 | int32 window = 2; //窗口句柄 109 | } 110 | 111 | message AudioVolumePlayerCoreMessage { 112 | int32 player_id = 1; 113 | float audio_volume = 2; 114 | } 115 | 116 | message RepeatPlayerCoreMessage { 117 | int32 player_id = 1; 118 | int32 is_repeat = 2; 119 | } 120 | 121 | message SpeedRatioPlayerCoreMessage { 122 | int32 player_id = 1; 123 | float speed_ratio = 2; 124 | } 125 | 126 | message ReadyDataSourceCoreMessage { 127 | int32 player_id = 1; 128 | string file_name = 2; 129 | string file_path = 3; 130 | int64 media_id = 4; 131 | } 132 | 133 | message DownloadDataSourceCoreMessage { 134 | int32 player_id = 1; 135 | string file_name = 2; 136 | string file_path = 3; 137 | int64 file_size = 4; 138 | int64 media_id = 5; 139 | } 140 | 141 | message ErrorPlayerCoreMessage { 142 | int32 player_id = 1; 143 | string error = 2; 144 | int32 error_type = 3; 145 | int32 error_code = 4; 146 | } 147 | 148 | message StartTaskProxyMessage { 149 | int32 task_id = 1; 150 | int32 player_id = 2; 151 | } 152 | 153 | message StartRequestProxyMessage { 154 | int32 task_id = 1; 155 | int32 player_id = 2; 156 | int32 request_start = 3; 157 | int32 request_end = 4; 158 | } 159 | 160 | message CloseRequestProxyMessage { 161 | int32 task_id = 1; 162 | int32 player_id = 2; 163 | } 164 | 165 | message PollingDataProxyReqMessage { 166 | int32 task_id = 1; 167 | int32 player_id = 2; 168 | int32 offset = 3; 169 | int32 ready_size = 4; 170 | int32 download_size = 5; 171 | int32 read_size=6; 172 | } 173 | 174 | message PollingDataProxyRespMessage { 175 | 176 | } -------------------------------------------------------------------------------- /MMMojoCall/proto/utility_protobuf.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package utility_protobuf; 4 | 5 | //所有int32都有可能是以下类型: int32,int64,uint32,uint64,sint32,sint64,bool,enum 6 | 7 | message InitReqMessage { 8 | int32 expire_timestamp = 1; //猜的 9 | int32 type = 2; //为1 10 | } 11 | 12 | message InitRespMessage { 13 | int32 status = 1; //是否初始化成功 WeChatWin.dll并没有处理这个消息 14 | } 15 | 16 | message ResampleImageReqMessage{ 17 | string decode_pic = 1; //解码图片的路径 18 | string encode_pic = 2; //原始加密图片的路径 19 | int32 re_pic_x = 3; //图片长 20 | int32 re_pic_y = 4; //图片宽 21 | int32 unknown_0 = 5; //未知 一般为1 22 | } 23 | 24 | message ResampleImageRespMessage { 25 | int32 err_code = 1; //可能是 一般为0 错误为8 26 | } 27 | 28 | message TextScanMessage { 29 | int32 text_scan_id = 1; //可能是 30 | string pic_path = 2; //扫描的图片路径 31 | int32 have_text = 3; //是否有文字 32 | int32 unknown_0 = 4; //未知 33 | float rate = 5; //应该是浮点数 图上要是没文字这个字段肯定为0.0 34 | } 35 | 36 | //当使用图片时发送的是1 2(可为空) 3 7 8 9项 37 | //当在截图中框选时发送的是 4 5 6 7 8 9项 38 | message QRScanReqMessage { 39 | string origin_pic = 1; //原始图片路径 可选 40 | string decode_pic = 2; //解码后的图片路径 可选 41 | int32 unknown_0 = 3; //未知 可选 一般为0 42 | bytes encode_pic_data = 4; //某种编码后的图片数据 可选 43 | int32 encode_pic_x = 5; //编码图片长 可选 44 | int32 encode_pic_y = 6; //编码图片宽 可选 45 | int32 unknown_1 = 7; //未知 一般为1 46 | int32 text_scan_id = 8; //可能是 47 | int32 unknown_3 = 9; //未知 一般为1 48 | } 49 | 50 | message QRScanRespMessage { 51 | message QRScanResult{ 52 | bytes result = 1; //二维码识别结果 53 | int32 unknow_0 = 2; //未知 一般为19 54 | double unknown_1 = 3; //未知 可能是浮点数 55 | double unknown_2 = 4; //未知 可能是浮点数 56 | int32 unknown_3 = 5; //未知 一般为1 57 | } 58 | 59 | repeated QRScanResult qr_result = 1; 60 | int32 unknown_0 = 2; //未知 一般为1 61 | } -------------------------------------------------------------------------------- /MMMojoCall/src/dllmain.cpp: -------------------------------------------------------------------------------- 1 | #ifdef USE_WRAPPER 2 | #include "google/protobuf/stubs/common.h" 3 | #endif 4 | 5 | #include 6 | 7 | BOOL APIENTRY DllMain( HMODULE hModule, 8 | DWORD ul_reason_for_call, 9 | LPVOID lpReserved 10 | ) 11 | { 12 | switch (ul_reason_for_call) 13 | { 14 | case DLL_PROCESS_ATTACH: 15 | break; 16 | case DLL_THREAD_ATTACH: 17 | break; 18 | case DLL_THREAD_DETACH: 19 | break; 20 | case DLL_PROCESS_DETACH: 21 | #ifdef USE_WRAPPER 22 | google::protobuf::ShutdownProtobufLibrary(); 23 | #endif 24 | break; 25 | } 26 | return TRUE; 27 | } 28 | 29 | -------------------------------------------------------------------------------- /MMMojoCall/src/include/mmmojo_call.h: -------------------------------------------------------------------------------- 1 | /*****************************************************************//** 2 | * @file mmmojo_call.h 3 | * @brief 实现调用mmmojo(微信XPlugin组件)的方法 根据mmmojo源码再次重构 4 | * 5 | * @author 0xEEEE 6 | * @date 2023.10.27 7 | *********************************************************************/ 8 | #pragma once 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | #include "mojo_call_export.h" 15 | #include "mmmojo.h" 16 | #include "mmmojo_environment_callbacks.h" 17 | 18 | //因为一开始是从QQNT逆向出来的, 所以保留qqimpl的叫法 19 | //根据https://github.com/PCWeChat/mmmojo源码再次重构 20 | namespace qqimpl 21 | { 22 | namespace mmmojocall 23 | { 24 | //每一个组件的每一个请求都有一个自己的RequestId 组件会根据请求ID进行对应的操作 25 | 26 | //WeChatOCR组件 27 | enum RequestIdOCR 28 | { 29 | OCRPush = 1 30 | }; 31 | 32 | //WeChatUtility组件 33 | enum RequestIdUtility 34 | { 35 | UtilityHiPush = 10001, //是Utility启动发送的 36 | UtilityInitPullReq = 10002, //初始化请求 37 | UtilityInitPullResp = 10003, //回复创建的都是Shared类型的info, 但是调用了SwapMMMojoWriteInfoCallback, 所以回调的还是Pull 38 | UtilityResampleImagePullReq = 10010, 39 | UtilityResampleImagePullResp = 10011, 40 | UtilityDecodeImagePullReq = 10020, 41 | UtilityDecodeImagePullResp = 10021, 42 | UtilityPicQRScanPullReq = 10030, //10030是点击OCR时(也是打开图片时)发送的请求, 参数是图片路径 43 | UtilityQRScanPullReq = 10031, //10031是截图框选时发送的请求, 参数应该是某种编码后的图片数据 44 | UtilityQRScanPullResp = 10032, //这两种请求的返回ID都是10032 45 | UtilityTextScanPushResp = 10040 //TextScan具体在扫什么不是很清楚 可能是用来判断图片上是否有文字 46 | }; 47 | 48 | //ThumbPlayer组件 49 | enum RequestIdPlayer 50 | { 51 | PlayerHiPush = 10001, //ThumbPlayer启动时发送的 52 | PlayerInitPullReq = 10002, //PlayerMgr::Init 53 | PlayerInitPullResp = 10003, //PlayerMgr::Init 54 | PlayerInitPlayerCorePush = 10010, 55 | PlayerCreatePlayerCorePullReq = 10011, //PlayerMgr::CreatePlayerCore 56 | PlayerCreatePlayerCorePullResp = 10012, //PlayerMgr::CreatePlayerCore 57 | PlayerDestroyPlayerCorePush = 10013, //PlayerMgr::DestroyCore 58 | PlayerPrepareAsyncPush = 10014, //PlayerMgr::PrepareCore 59 | PlayerStartPush = 10015, //PlayerMgr::StartCore 60 | PlayerStopPush = 10016, //PlayerMgr::StopCore 61 | PlayerPausePush = 10017, //PlayerMgr::PauseCore 62 | PlayerResumePush = 10018, //PlayerMgr::ResumeCore 63 | PlayerSetAudioMutePush = 10019, //PlayerMgr::AudioMuteCore 64 | PlayerSeekToAsyncPush = 10020, //PlayerMgr::SeekToCore 65 | PlayerGetCurrentPositionMsPullReq = 10021, //PlayerMgr::GetCurrentPositionMsCore 66 | PlayerGetCurrentPositionMsPullResp = 10022, //PlayerMgr::GetCurrentPositionMsCore 67 | PlayerSetVideoSurfacePush = 10023, //PlayerMgr::VideoSurfaceCore 68 | PlayerSetAudioVolumePush = 10024, //PlayerMgr::AudioVolumeCore 69 | PlayerSetDataSourcePush = 10025, //PlayerMgr::ReadyDataSourceCore 70 | PlayerSetLoaderSourcePush = 10026, //PlayerMgr::DownloadDataSourceCore 71 | PlayerSetRepeatPush = 10027, //PlayerMgr::RepeatCore 72 | PlayerResizePush = 10028, //PlayerMgr::ResizeCore 73 | PlayerSetPlaySpeedRatio = 10029, //PlayerMgr::SpeedRatioCore 74 | PlayerInfoPush = 10030, 75 | PlayerErrorPlayerPush = 10031, 76 | PlayerVideoSizeChangedPush = 10032, 77 | PlayerStopAsyncCompletedPush = 10033, 78 | PlayerStateChangePush = 10034, 79 | PlayerSeekCompletedPush = 10035, 80 | PlayerCompletedPush = 10036, 81 | PlayerStartTaskProxyPush = 10050, 82 | PlayerStartRequestProxyPush = 10051, 83 | PlayerCloseRequestProxyPush = 10052, 84 | PlayerPollingDatProxyPullReq = 10053, 85 | PlayerPollingDatProxyPullResp = 10054 86 | }; 87 | 88 | //一个类就是一个WeChat XPlugin组件 89 | class MMMOJOCALL_API XPluginManager 90 | { 91 | public: 92 | XPluginManager(); 93 | ~XPluginManager(); 94 | 95 | /** 96 | * @brief 设置要启动的WeChat组件(XPlugin)路径. 97 | * @param exe_path char*类型路径 98 | * @param 成功返回true 99 | */ 100 | bool SetExePath(const char* exe_path); 101 | 102 | /** 103 | * @brief 对应Chromium源码中的base::CommandLine->AppendSwitchNative方法 用于添加一个'开关(Switch)'. 104 | * @param switch_string 例如L"user-lib-dir", 这样会在命令行参数添加一个"--user-lib-dir" 105 | * @param value 参数'='后面的值 106 | * @return 是否添加成功 107 | */ 108 | bool AppendSwitchNativeCmdLine(const char* switch_string, const char* value); 109 | 110 | /** 111 | * @brief 设置对应type的回调. 112 | * @param type MMMojoEnvironmentCallbackType 113 | * @param pfunc 函数指针 mmmojo::common::MMMojoReadOnPull*等类型 114 | */ 115 | void SetOneCallback(int type, void* pfunc); 116 | 117 | /** 118 | * @brief 设置全部回调函数. 119 | * @param callbacks 回调函数 mmmojo::common::MMMojoEnvironmentCallbacks类型 如果是CallFuncXPluginMgr需传入结构体指针 120 | */ 121 | void SetCallbacks(mmmojo::common::MMMojoEnvironmentCallbacks callbacks); 122 | 123 | /** 124 | * @brief 设置回调函数的UsrData (一般为类的this指针). 125 | * @param usr_data 即回调函数的最后一个参数 126 | */ 127 | void SetCallbackUsrData(void* usr_data); 128 | 129 | /** 130 | * @brief 启动XPlugin组件. 131 | * @return 成功返回true 132 | */ 133 | bool StartMMMojoEnv(); 134 | 135 | /** 136 | * @brief 结束XPlugin组件. 137 | */ 138 | void StopMMMojoEnv(); 139 | 140 | /** 141 | * @brief 发送序列化后的protobuf数据. 142 | * @param pb_data 序列化后的数据 143 | * @param data_size 数据大小 144 | * @param method 默认为MMMojoInfoMethod::kMMPush 145 | * @param sync 默认为false 146 | * @param request_id 默认为MMMojoRequestId::OCRPush 147 | */ 148 | void SendPbSerializedData(void* pb_data, int data_size, int method = MMMojoInfoMethod::kMMPush, bool sync = false, uint32_t request_id = RequestIdOCR::OCRPush); 149 | 150 | /** 151 | * @brief 获取上一次的错误信息. 152 | * @return last err string 153 | */ 154 | const char* GetLastErrStr(); 155 | 156 | protected: 157 | void SetLastErrStr(std::string err_str); 158 | 159 | private: 160 | void* m_cb_usrdata; //回调函数的最后一个参数 161 | std::string m_last_err; //错误信息 162 | std::wstring m_exe_path; //要启动的组件路径 163 | std::map m_switch_native; //switch命令行参数 164 | void* m_mmmojo_env_ptr; //MMMojoEnv指针 165 | bool m_start_mmmojo_env; //是否启动了XPlugin组件 166 | mmmojo::common::MMMojoEnvironmentCallbacks m_callbacks; //回调函数 167 | }; 168 | 169 | /** 170 | * @brief 初始化m_MMMojoDLL. 171 | * @param mmmojo_dll_path mmmojo(_64).dll所在路径 172 | * @return 是否初始化成功 173 | */ 174 | extern "C" MMMOJOCALL_API bool InitMMMojoDLLFuncs(const char* mmmojo_dll_path); 175 | 176 | /** 177 | * @brief 初始化全局MMMojo环境 (全局调一次) 178 | * (如果参数中有sandbox::policy::switches::kNoSandbox switch则不会创建沙箱). 179 | * @param argc 当前进程的参数个数 180 | * @param argv 当前进程的参数 181 | * @return 是否初始化成功 182 | */ 183 | extern "C" MMMOJOCALL_API bool InitMMMojoGlobal(int argc, const char* const* argv); 184 | 185 | /** 186 | * @brief 结束全局MMMojo环境 (全局调一次). 187 | * @return 是否结束成功 188 | */ 189 | extern "C" MMMOJOCALL_API bool ShutdownMMMojoGlobal(); 190 | 191 | /** 192 | * @brief 根据request_info获取protobuf序列化数据. 193 | * @param request_info [IN] 回调函数的参数request_info 194 | * @param data_size [OUT] 数据大小 195 | * @return void* pb数据 196 | */ 197 | extern "C" MMMOJOCALL_API const void* GetPbSerializedData(const void* request_info, uint32_t &data_size); 198 | 199 | /** 200 | * @brief 获取ReadInfo (reqeust_info)的attach数据. 201 | * @param request_info [IN] 回调函数的参数request_info 202 | * @param data_size [OUT] 数据大小 203 | * @return void* attach数据 204 | */ 205 | extern "C" MMMOJOCALL_API const void* GetReadInfoAttachData(const void* request_info, uint32_t& data_size); 206 | 207 | /** 208 | * @brief 销毁request_info. 正确使用方法为 GetPbSerializedData(...); /Your Code;/ RemoveReadInfoRequest(...); 209 | * @param request_info [IN] 回调函数的参数request_info 210 | */ 211 | extern "C" MMMOJOCALL_API void RemoveReadInfo(const void* request_info); 212 | } 213 | } -------------------------------------------------------------------------------- /MMMojoCall/src/include/mmmojo_ocr.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EEEEhex/QQImpl/3aac29788fc63d25665a0ae473b8b8c788ed20bb/MMMojoCall/src/include/mmmojo_ocr.h -------------------------------------------------------------------------------- /MMMojoCall/src/include/mmmojo_player.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EEEEhex/QQImpl/3aac29788fc63d25665a0ae473b8b8c788ed20bb/MMMojoCall/src/include/mmmojo_player.h -------------------------------------------------------------------------------- /MMMojoCall/src/include/mmmojo_source/mmmojo.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EEEEhex/QQImpl/3aac29788fc63d25665a0ae473b8b8c788ed20bb/MMMojoCall/src/include/mmmojo_source/mmmojo.h -------------------------------------------------------------------------------- /MMMojoCall/src/include/mmmojo_source/mmmojo_environment_callbacks.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ifndef MMMOJO_COMMON_MMMOJO_ENVIRONMENT_CALLBACKS_H_ 4 | #define MMMOJO_COMMON_MMMOJO_ENVIRONMENT_CALLBACKS_H_ 5 | 6 | #include 7 | 8 | namespace mmmojo { 9 | namespace common { 10 | 11 | typedef void MMMojoReadOnPush(uint32_t request_id, 12 | const void* request_info, 13 | void* user_data); 14 | typedef void MMMojoReadOnPull(uint32_t request_id, 15 | const void* request_info, 16 | void* user_data); 17 | typedef void MMMojoReadOnShared(uint32_t request_id, 18 | const void* request_info, 19 | void* user_data); 20 | typedef void MMMojoRemoteOnConnect(bool is_connected, void* user_data); 21 | typedef void MMMojoRemoteOnDisConnect(void* user_data); 22 | typedef void MMMojoRemoteOnProcessLaunched(void* user_data); 23 | typedef void MMMojoRemoteOnProcessLaunchFailed(int error_code, void* user_data); 24 | typedef void MMMojoRemoteOnMojoError(const void* errorbuf, 25 | int errorsize, 26 | void* user_data); 27 | 28 | struct MMMojoEnvironmentCallbacks { 29 | MMMojoReadOnPush* read_on_push = nullptr; 30 | MMMojoReadOnPull* read_on_pull = nullptr; 31 | MMMojoReadOnShared* read_on_shared = nullptr; 32 | MMMojoRemoteOnConnect* remote_on_connect = nullptr; 33 | MMMojoRemoteOnDisConnect* remote_on_disconnect = nullptr; 34 | MMMojoRemoteOnProcessLaunched* remote_on_processlaunched = nullptr; 35 | MMMojoRemoteOnProcessLaunchFailed* remote_on_processlaunchfailed = nullptr; 36 | MMMojoRemoteOnMojoError* remote_on_mojoerror = nullptr; 37 | }; 38 | 39 | } // namespace common 40 | } // namespace mmmojo 41 | 42 | #endif // MMMOJO_COMMON_MMMOJO_ENVIRONMENT_CALLBACKS_H_ 43 | -------------------------------------------------------------------------------- /MMMojoCall/src/include/mmmojo_utility.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EEEEhex/QQImpl/3aac29788fc63d25665a0ae473b8b8c788ed20bb/MMMojoCall/src/include/mmmojo_utility.h -------------------------------------------------------------------------------- /MMMojoCall/src/include/mojo_call_export.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EEEEhex/QQImpl/3aac29788fc63d25665a0ae473b8b8c788ed20bb/MMMojoCall/src/include/mojo_call_export.h -------------------------------------------------------------------------------- /MMMojoCall/src/include/qq_mojoipc/qq_ipc.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | /*****************************************************************//** 3 | * @file QQIpc.h 4 | * @brief 此模块用于实现QQ Mojo IPC (改为DLL导出) 5 | * @version 2.0 6 | * 7 | * @author 0xEEEE 8 | * @date 2023.11.03 9 | *********************************************************************/ 10 | 11 | //此版本分离了IPC和OCR的实现 去除了C++20标准的依赖 并将32位和64位实现合并 12 | //不能保证所有版本的parent-ipc-core.dll可用, 接口参数可能发生变化 13 | 14 | //通过逆向分析实现一些QQ的IPC功能 15 | #include 16 | //#include 17 | #include 18 | 19 | #include "mojo_call_export.h" 20 | 21 | namespace qqimpl 22 | { 23 | namespace qqipc 24 | { 25 | //QQLAUNCHINFO结构体是逆向分析出来的一个类, 其是接收IPC消息回调函数的第一个参数, 26 | //(当然也可以自己定义一个类型, 其就是被传给OnDefaultReceiveMsg函数的第一个参数), 27 | //此类会被复制一份到pIMojoIpc, 也就是它是pIMojoIpc类的一个成员变量, 28 | // {位置为 (*(DWORD*)(((DWORD*)(*(DWORD*)(*(pIMojoIpc + 29)))) + 3))} (32位下) 29 | struct QQLAUNCHINFO 30 | { 31 | DWORD Reserved_0; // + 00 应该是虚表 32 | DWORD Reserved_1; // + 04 33 | DWORD Reserved_2; // + 08 34 | DWORD Reserved_3; // + 12 添加命令行参数用的 35 | DWORD Reserved_4; // + 16 命令行参数的截止地址 36 | DWORD* pIMojoIpc; // + 20 COM指针 37 | DWORD launchResult; // + 24 LaunchChildProcess()返回值 38 | DWORD PlaceHolder_0[5]; // + 28 39 | std::wstring ExePath; // + 48 QQScreenShot.exe路径 <- 这里后面+56会被写入其他值 没懂但无所谓 40 | DWORD Reserved_18; // + 72 41 | DWORD PlaceHolder_1[28];// + 76 42 | DWORD* ProcessClass; // + 188 Chrome内部Process类 43 | DWORD Reserved_48; // + 192 44 | DWORD ChildPid; // + 196 子进程PID 45 | DWORD PlaceHolder_3[14];// + 200 46 | };//size = 256 47 | //以上结构体不使用 只是逆向出来的原逻辑 48 | 49 | #ifdef _WIN64 50 | typedef void (*callback_ipc)(void*, char*, int, char*, int); 51 | #else 52 | //32位下必须为__stdcall 53 | typedef void (WINAPI* callback_ipc)(void*, char*, int, int, char*, int); 54 | //typedef std::function callback_ipc32_func; 55 | #endif 56 | 57 | 58 | //QQ对Ipc一些操作的封装 59 | class MMMOJOCALL_API QQIpcParentWrapper { 60 | public: 61 | QQIpcParentWrapper(); 62 | ~QQIpcParentWrapper(); 63 | 64 | #ifdef _WIN64 65 | /** 66 | * @brief 默认的子进程接收消息的函数. 67 | * @param pArg 自定义参数 68 | * @param msg IPC_MSG 69 | * @param arg3 用不到 可能是版本号之类的 70 | * @param addition_msg 如果addition_msg_size不为0就是有addition_msg(图片路径) 71 | * @param addition_msg_size strlen(addition_msg) 72 | */ 73 | static void OnDefaultReceiveMsg(void* pArg, char* msg, int arg3, char* addition_msg, int addition_msg_size); 74 | #else 75 | /** 76 | * @brief 默认的子进程接收消息的函数. 77 | * @param pArg 自定义参数 78 | * @param msg IPC_MSG 79 | * @param arg3 用不到 可能是版本号之类的 80 | * @param arg4 可能是int 81 | * @param addition_msg 如果addition_msg_size不为0就是有addition_msg(图片路径) 82 | * @param addition_msg_size strlen(addition_msg) 83 | */ 84 | static void __stdcall OnDefaultReceiveMsg(void* pArg, char* msg, int arg3, int arg4, char* addition_msg, int addition_msg_size); 85 | 86 | /** 87 | * @brief 获取传给接收IPC消息的回调函数的参数 [已被弃用]. 88 | * @return void* 89 | */ 90 | void* GetCallbackArg(); 91 | #endif 92 | 93 | /** 94 | * @brief 初始化环境. 95 | * @param dll_path parent-ipc-core-x86/x64.dll的路径 默认为运行目录下 96 | * @return 成功返回true 97 | */ 98 | bool InitEnv(const char* dll_path = NULL); 99 | 100 | /** 101 | * @brief 设置dll内部的日志等级 [已被弃用]. 102 | * @param level 0-4 5则关闭 103 | */ 104 | void SetLogLevel(int level); 105 | 106 | /** 107 | * @brief 获取上一次的错误信息字符串. 108 | * @return 错误信息 109 | */ 110 | const char* GetLastErrStr(); 111 | 112 | /** 113 | * @brief 对pIMojoIpc->InitParentLog的封装. 114 | * @param level 日志等级 115 | * @param LogCallback为空 116 | */ 117 | void InitLog(int level = 0, void* callback = NULL); 118 | 119 | /** 120 | * @brief 对pIMojoIpc->InitParentIpc()的封装. 121 | */ 122 | void InitParentIpc(); 123 | 124 | /** 125 | * @brief 对pIMojoIpc->LaunchChildProcess的封装. 126 | * @param file_path 子进程路径 127 | * @param callback 用户自定义接收消息的函数 128 | * @param cb_arg 传递给接收ipc消息回调函数的第一个参数 129 | * @param cmdlines 要添加的命令行参数 例如const char* cmd_args[] = {"-t", "-m"}; 130 | * @param cmd_num 要添加的命令行参数的个数 131 | * @return 子进程PID 失败返回0 132 | */ 133 | int LaunchChildProcess(const char* file_path, callback_ipc callback = NULL, void* cb_arg = NULL, char** cmdlines = NULL, int cmd_num = 0); 134 | 135 | /** 136 | * @brief 对pIMojoIpc->ConnectedToChildProcess的封装. 137 | * @param pid 子进程的pid 138 | * @return 成功返回true 139 | */ 140 | bool ConnectedToChildProcess(int pid); 141 | 142 | /** 143 | * @brief 对pIMojoIpc->SendMessageUsingBufferInIPCThread的封装. 144 | * @param pid 子进程的pid 145 | * @param command IPC_MSG 以'\0'结尾的字符串 146 | * @param addition_msg 参数 147 | * @param addition_msg_size 参数大小 148 | * @return 成功返回true 149 | */ 150 | bool SendIpcMessage(int pid, const char* command, const char* addition_msg = NULL, int addition_msg_size = 0); 151 | 152 | /** 153 | * @brief 对pIMojoIpc->TerminateChildProcess的封装. 154 | * @param pid 子进程的pid 155 | * @param exit_code 即chrome process_win.cc里的Process::Terminate方法 156 | * @param wait The process may not end immediately due to pending I/O 157 | * @return 成功返回true 158 | */ 159 | bool TerminateChildProcess(int pid, int exit_code = 0, bool wait_ = true); 160 | 161 | /** 162 | * @brief 对pIMojoIpc->ReLaunchChildProcess的封装. 163 | * @param pid 子进程的pid 164 | * @return 成功返回新的pid 失败返回0 165 | */ 166 | int ReLaunchChildProcess(int pid); 167 | 168 | private: 169 | HMODULE m_ipc_dll; 170 | DWORD_PTR* m_ptr_IMojoIpc; 171 | 172 | std::string _last_err; 173 | }; 174 | 175 | class MMMOJOCALL_API QQIpcChildWrapper 176 | { 177 | public: 178 | QQIpcChildWrapper(); 179 | ~QQIpcChildWrapper(); 180 | 181 | /** 182 | * @brief 获取上一次的错误信息字符串. 183 | * @return 错误信息 184 | */ 185 | const char* GetLastErrStr(); 186 | 187 | /** 188 | * @brief 初始化环境. 189 | * @param dll_path child(或parent, 因为这俩是一样的)-ipc.dll的路径 默认为运行目录下 190 | * @return 成功返回true 191 | */ 192 | bool InitEnv(const char* dll_path = NULL); 193 | 194 | /** 195 | * @brief 对pIMojoIpc->InitChildIpc()的封装. 196 | */ 197 | void InitChildIpc(); 198 | 199 | /** 200 | * @brief 对pIMojoIpc->InitChildLog的封装. 201 | */ 202 | void InitLog(int level = 0, void* callback = NULL); 203 | 204 | /** 205 | * @brief 对pIMojoIpc->SetChildReceiveCallbackAndCOMPtr()的封装. 206 | * @param callback 接收IPC消息的函数 207 | */ 208 | void SetChildReceiveCallback(callback_ipc callback); 209 | 210 | /** 211 | * @brief 对pIMojoIpc->ChildSendMessageUsingBuffer的封装. 212 | * @param command IPC_MSG 213 | * @param addition_msg 参数 214 | */ 215 | void SendIpcMessage(const char* command, const char* addition_msg = NULL, int addition_msg_size = 0); 216 | 217 | private: 218 | HMODULE m_ipc_dll; 219 | DWORD_PTR* m_ptr_IMojoIpc; 220 | 221 | std::string _last_err; 222 | }; 223 | 224 | 225 | 226 | } 227 | } -------------------------------------------------------------------------------- /MMMojoCall/src/include/qq_mojoipc/qq_ipc_asm.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EEEEhex/QQImpl/3aac29788fc63d25665a0ae473b8b8c788ed20bb/MMMojoCall/src/include/qq_mojoipc/qq_ipc_asm.h -------------------------------------------------------------------------------- /MMMojoCall/src/include/utils.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EEEEhex/QQImpl/3aac29788fc63d25665a0ae473b8b8c788ed20bb/MMMojoCall/src/include/utils.h -------------------------------------------------------------------------------- /MMMojoCall/src/include/xplugin_protobuf/google.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EEEEhex/QQImpl/3aac29788fc63d25665a0ae473b8b8c788ed20bb/MMMojoCall/src/include/xplugin_protobuf/google.zip -------------------------------------------------------------------------------- /MMMojoCall/src/mmmojocall/mmmojo_call.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EEEEhex/QQImpl/3aac29788fc63d25665a0ae473b8b8c788ed20bb/MMMojoCall/src/mmmojocall/mmmojo_call.cpp -------------------------------------------------------------------------------- /MMMojoCall/src/mmmojocall/mojo_call_export.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EEEEhex/QQImpl/3aac29788fc63d25665a0ae473b8b8c788ed20bb/MMMojoCall/src/mmmojocall/mojo_call_export.cpp -------------------------------------------------------------------------------- /MMMojoCall/src/mmmojocall/wrapper/mmmojo_ocr.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EEEEhex/QQImpl/3aac29788fc63d25665a0ae473b8b8c788ed20bb/MMMojoCall/src/mmmojocall/wrapper/mmmojo_ocr.cpp -------------------------------------------------------------------------------- /MMMojoCall/src/mmmojocall/wrapper/mmmojo_player.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EEEEhex/QQImpl/3aac29788fc63d25665a0ae473b8b8c788ed20bb/MMMojoCall/src/mmmojocall/wrapper/mmmojo_player.cpp -------------------------------------------------------------------------------- /MMMojoCall/src/mmmojocall/wrapper/mmmojo_utility.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EEEEhex/QQImpl/3aac29788fc63d25665a0ae473b8b8c788ed20bb/MMMojoCall/src/mmmojocall/wrapper/mmmojo_utility.cpp -------------------------------------------------------------------------------- /MMMojoCall/src/qq_mojoipc/qq_ipc.cpp: -------------------------------------------------------------------------------- 1 | #include "qq_ipc.h" 2 | 3 | #include "utils.h" 4 | #include 5 | 6 | #ifdef _WIN64 7 | #include "qq_ipc_asm.h" 8 | #endif 9 | 10 | /* 11 | HRESULT DllGetClassObject( 12 | [in] REFCLSID rclsid, 13 | [in] REFIID riid, 14 | [out] LPVOID* ppv); 15 | */ 16 | typedef HRESULT(WINAPI* LPFN_DLLGETCLASSOBJECT)(REFCLSID, REFIID, LPVOID*); 17 | 18 | //以下为Parent IPC的实现 19 | qqimpl::qqipc::QQIpcParentWrapper::QQIpcParentWrapper() 20 | { 21 | m_ipc_dll = 0; 22 | m_ptr_IMojoIpc = NULL; 23 | _last_err = "ERR_OK"; 24 | } 25 | 26 | qqimpl::qqipc::QQIpcParentWrapper::~QQIpcParentWrapper() 27 | { 28 | } 29 | 30 | #ifdef _WIN64 31 | void qqimpl::qqipc::QQIpcParentWrapper::OnDefaultReceiveMsg(void* pArg, char* msg, int arg3, char* addition_msg, int addition_msg_size) 32 | { 33 | std::string msg_str = msg, add_msg_str(addition_msg, addition_msg_size); 34 | #ifdef _DEBUG 35 | std::cout << "[ " << __FUNCTION__ << "] | Msg: " << msg_str << std::endl; 36 | std::cout << "[ " << __FUNCTION__ << "] | Addition Msg Size: " << addition_msg_size << std::endl; 37 | if (addition_msg_size != 0) 38 | { 39 | std::cout << "[ " << __FUNCTION__ << "] | The Addition Msg: "; 40 | for (size_t i = 0; i < addition_msg_size; i++) 41 | printf("0x%02X ", (byte)(addition_msg[i])); 42 | puts(""); 43 | } 44 | #endif 45 | } 46 | #else 47 | void __stdcall qqimpl::qqipc::QQIpcParentWrapper::OnDefaultReceiveMsg(void* pArg, char* msg, int arg3, int arg4, char* addition_msg, int addition_msg_size) 48 | { 49 | std::string msg_str = msg, add_msg_str(addition_msg, addition_msg_size); 50 | #ifdef _DEBUG 51 | std::cout << "[ " << __FUNCTION__ << "] | Msg: " << msg_str << std::endl; 52 | std::cout << "[ " << __FUNCTION__ << "] | Addition Msg Size: " << addition_msg_size << std::endl; 53 | if (addition_msg_size != 0) 54 | { 55 | std::cout << "[ " << __FUNCTION__ << "] | The Addition Msg: "; 56 | for (size_t i = 0; i < addition_msg_size; i++) 57 | printf("0x%02X ", (byte)(addition_msg[i])); 58 | puts(""); 59 | } 60 | #endif 61 | } 62 | 63 | void* qqimpl::qqipc::QQIpcParentWrapper::GetCallbackArg() 64 | { 65 | DWORD* pIMojoIpc = (DWORD*)(this->m_ptr_IMojoIpc); 66 | if (pIMojoIpc == NULL) 67 | { 68 | _last_err = "IMojoIpc is not init!"; 69 | return nullptr; 70 | } 71 | 72 | return (void*)(*(DWORD*)(((DWORD*)(*(DWORD*)(*(pIMojoIpc + 29)))) + 3)); 73 | } 74 | #endif // _WIN64 75 | 76 | 77 | bool qqimpl::qqipc::QQIpcParentWrapper::InitEnv(const char* dll_path) 78 | { 79 | if ((dll_path == NULL) || (strlen(dll_path) == 0)) 80 | { 81 | #ifdef _WIN64 82 | dll_path = "parent-ipc-core-x64.dll"; 83 | #else 84 | dll_path = "parent-ipc-core-x86.dll"; 85 | #endif 86 | } 87 | 88 | m_ipc_dll = LoadLibraryA(dll_path); 89 | if (m_ipc_dll == NULL) 90 | { 91 | 92 | _last_err = "ParentIpc LoadDll Err"; 93 | return false; 94 | } 95 | 96 | LPFN_DLLGETCLASSOBJECT lpfnDllGetClassObject = (LPFN_DLLGETCLASSOBJECT)GetProcAddress(m_ipc_dll, "DllGetClassObject"); 97 | if (!lpfnDllGetClassObject) 98 | { 99 | _last_err = "ParentIpc Can't Get \'DllGetClassObject\' Addr"; 100 | return false; 101 | } 102 | 103 | IID clsid = { 0x14D5685E, 0x0574, 0x4F1F,{ 0xB6, 0xA4, 0x9B, 0xE9, 0xC3, 0xBE, 0x0C, 0x0D } }; 104 | //IID m_iid = { 0x00000001, 0x0000, 0x00000,{ 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46 } };//IID_IClassFactory 105 | IID riid = { 0x8504298A, 0xA491, 0x4B40,{ 0xAA, 0xC4, 0xB2, 0x60, 0x8D, 0xAC, 0x40, 0x45} }; 106 | 107 | IClassFactory* pIClassFactory = NULL; 108 | if (lpfnDllGetClassObject(clsid, IID_IClassFactory, (LPVOID*)(&pIClassFactory)) != S_OK) 109 | { 110 | _last_err = "ParentIpc lpfnDllGetClassObject Err"; 111 | return false; 112 | } 113 | 114 | DWORD_PTR* pIMojoIpc = NULL; 115 | pIClassFactory->CreateInstance(NULL, riid, (void**)&pIMojoIpc); 116 | pIClassFactory->Release(); 117 | if (pIMojoIpc == NULL) 118 | { 119 | _last_err = "pIClassFactory->CreateInstance Err"; 120 | return false; 121 | } 122 | 123 | this->m_ptr_IMojoIpc = pIMojoIpc; 124 | 125 | _last_err = "ERR_OK"; 126 | return true; 127 | } 128 | 129 | const char* qqimpl::qqipc::QQIpcParentWrapper::GetLastErrStr() 130 | { 131 | return _last_err.c_str(); 132 | } 133 | 134 | //把有直接操作内存的和内联汇编的代码片段的编译优化关掉 135 | #pragma optimize( "", off ) 136 | void qqimpl::qqipc::QQIpcParentWrapper::SetLogLevel(int level)//已被弃用 137 | { 138 | if (m_ipc_dll == NULL) return; 139 | if (level < 0 || level > 5) level = 5; 140 | 141 | DWORD_PTR offset = 0; 142 | #ifdef _WIN64 143 | offset = 0x18DAE8; 144 | #else 145 | offset = 0x150034; 146 | #endif // _WIN64 147 | 148 | DWORD_PTR lpLogLevel_ = (DWORD_PTR)(m_ipc_dll + offset);//待定 149 | *(DWORD_PTR*)lpLogLevel_ = level; 150 | } 151 | 152 | void qqimpl::qqipc::QQIpcParentWrapper::InitLog(int level, void* callback) 153 | { 154 | DWORD_PTR* pIMojoIpc = this->m_ptr_IMojoIpc, 155 | dwFunc = *((DWORD_PTR*)(*pIMojoIpc) + 4), logLevel = level; 156 | 157 | #ifdef _WIN64 158 | InitLogAsm((DWORD_PTR)pIMojoIpc, (DWORD_PTR)callback, logLevel, dwFunc); 159 | #else 160 | _asm 161 | { 162 | push logLevel 163 | push callback 164 | push pIMojoIpc 165 | call dwFunc 166 | } 167 | #endif 168 | 169 | _last_err = "ERR_OK"; 170 | } 171 | 172 | void qqimpl::qqipc::QQIpcParentWrapper::InitParentIpc() 173 | { 174 | DWORD_PTR* pIMojoIpc = this->m_ptr_IMojoIpc, 175 | dwFunc = *((DWORD_PTR*)(*pIMojoIpc) + 3);//pIMojoIpc->InitParentIpc() 176 | 177 | #ifdef _WIN64 178 | InitParentIpcAsm((DWORD_PTR)pIMojoIpc, dwFunc); 179 | #else 180 | _asm 181 | { 182 | push pIMojoIpc 183 | call dwFunc 184 | } 185 | #endif // _WIN64 186 | 187 | _last_err = "ERR_OK"; 188 | } 189 | 190 | int qqimpl::qqipc::QQIpcParentWrapper::LaunchChildProcess(const char* file_path, callback_ipc callback, void* cb_arg, char** cmdlines, int cmd_num) 191 | { 192 | //pIMojoIpc->LaunchChildProcess(wchar_t *path, DWORD 0,DWORD 0, LPVOID callback, LPVOID Launch函数的参数);//arg4: wrapper.node + 0x97D1B0 193 | DWORD_PTR* pIMojoIpc = this->m_ptr_IMojoIpc, 194 | dwFunc = *((DWORD_PTR*)(*pIMojoIpc) + 5); 195 | 196 | int child_pid = 0; 197 | void* lpArg = cb_arg, *lpCallback = callback; 198 | std::wstring file_path_w = utils::Utf8ToUnicode(file_path); 199 | const wchar_t* wzChildPath = file_path_w.c_str(); 200 | if (callback == nullptr) 201 | lpCallback = (void*)OnDefaultReceiveMsg; 202 | 203 | #ifdef _WIN64 204 | child_pid = LaunchChildProcessAsm((DWORD_PTR)pIMojoIpc, (DWORD_PTR)wzChildPath, cmd_num, (DWORD_PTR)cmdlines, (DWORD_PTR)lpCallback, (DWORD_PTR)cb_arg, dwFunc); 205 | #else 206 | _asm 207 | { 208 | push lpArg 209 | push lpCallback 210 | push 0 211 | push 0 212 | push wzChildPath 213 | push pIMojoIpc 214 | call dwFunc 215 | mov child_pid, eax 216 | }//成功返回PID 失败返回0 217 | #endif 218 | 219 | if (child_pid <= 0) 220 | { 221 | _last_err = "pIMojoIpc->LaunchChildProcess Internal Error"; 222 | return 0; 223 | } 224 | 225 | _last_err = "ERR_OK"; 226 | return child_pid; 227 | } 228 | 229 | bool qqimpl::qqipc::QQIpcParentWrapper::ConnectedToChildProcess(int pid) 230 | { 231 | if (pid <= 0) 232 | { 233 | _last_err = "ChildPid is not valid!"; 234 | return false; 235 | } 236 | 237 | //pIMojoIpc->ConnectedToChildProcess(DWORD64 child_pid); 238 | DWORD_PTR* pIMojoIpc = this->m_ptr_IMojoIpc, 239 | dwFunc = *((DWORD_PTR*)(*pIMojoIpc) + 6), dwPid = pid, call_result = 0; 240 | 241 | #ifdef _WIN64 242 | call_result = ConnectedToChildProcessAsm((DWORD_PTR)pIMojoIpc, dwPid, dwFunc); 243 | #else 244 | _asm 245 | { 246 | push dwPid 247 | push pIMojoIpc 248 | call dwFunc 249 | mov call_result, eax 250 | } 251 | #endif 252 | 253 | if (call_result == E_FAIL) 254 | { 255 | _last_err = "pIMojoIpc->ConnectedToChildProcess Internal Error"; 256 | return false; 257 | } 258 | _last_err = "ERR_OK"; 259 | return true; 260 | } 261 | 262 | bool qqimpl::qqipc::QQIpcParentWrapper::SendIpcMessage(int pid, const char* command, const char* addition_msg, int addition_msg_size) 263 | { 264 | //pIMojoIpc->SendMessageUsingBufferInIPCThread(DWORD child_pid, char* command, DWORD 0, DWORD 0, char* addition_msg, int addition_msg_size); 265 | //pIMojoIpc->SendIpcMessage(DWORD64 child_pid, char* msg_ptr, DWORD64 arg4, char* addition_ptr, DWORD64 addition_len); 266 | DWORD_PTR* pIMojoIpc = this->m_ptr_IMojoIpc, dwFunc = *((DWORD_PTR*)(*pIMojoIpc) + 7), 267 | addition_len = 0, dwPid = pid, call_result = 0; 268 | 269 | #ifdef _WIN64 270 | call_result = SendIpcMessageAsm((DWORD_PTR)pIMojoIpc, dwPid, (DWORD_PTR)command, 1, (DWORD_PTR)addition_msg, addition_msg_size, dwFunc); 271 | #else 272 | _asm 273 | { 274 | push addition_msg_size 275 | push addition_msg 276 | push 0 277 | push 0 278 | push command 279 | push dwPid 280 | push pIMojoIpc 281 | call dwFunc 282 | mov call_result, eax 283 | } 284 | #endif // _WIN64 285 | 286 | //失败会返回0x80004005 E_FAIL 287 | if (call_result == E_FAIL) 288 | { 289 | _last_err = "pIMojoIpc->SendMessageUsingBufferInIPCThread Internal Error"; 290 | return false; 291 | } 292 | _last_err = "ERR_OK"; 293 | return true; 294 | } 295 | 296 | bool qqimpl::qqipc::QQIpcParentWrapper::TerminateChildProcess(int pid, int exit_code, bool wait_) 297 | { 298 | //pIMojoIpc->TerminateChildProcess(DWORD child_pid, int exit_code, bool wait); 299 | DWORD_PTR* pIMojoIpc = this->m_ptr_IMojoIpc, dwFunc = *((DWORD_PTR*)(*pIMojoIpc) + 8), 300 | dwPid = pid, call_result = 0; 301 | DWORD_PTR arg_wait = (DWORD_PTR)wait_; 302 | 303 | #ifdef _WIN64 304 | call_result = TerminateChildProcessAsm((DWORD_PTR)pIMojoIpc, dwPid, exit_code, arg_wait, dwFunc); 305 | #else 306 | _asm 307 | { 308 | push arg_wait 309 | push exit_code 310 | push dwPid 311 | push pIMojoIpc 312 | call dwFunc 313 | mov call_result, eax 314 | } 315 | #endif // _WIN64 316 | 317 | if (call_result == E_FAIL) 318 | { 319 | _last_err = "pIMojoIpc->TerminateChildProcess Internal Error"; 320 | return false; 321 | } 322 | _last_err = "ERR_OK"; 323 | return true; 324 | } 325 | 326 | int qqimpl::qqipc::QQIpcParentWrapper::ReLaunchChildProcess(int pid) 327 | { 328 | //pIMojoIpc->ReLaunchChildProcess(DWORD child_pid); 329 | DWORD_PTR* pIMojoIpc = this->m_ptr_IMojoIpc, dwFunc = *((DWORD_PTR*)(*pIMojoIpc) + 9), 330 | dwPid = pid, call_result = 0; 331 | 332 | #ifdef _WIN64 333 | call_result = ReLaunchChildProcessAsm((DWORD_PTR)pIMojoIpc, dwPid, dwFunc); 334 | #else 335 | _asm 336 | { 337 | push dwPid 338 | push pIMojoIpc 339 | call dwFunc 340 | mov call_result, eax 341 | } 342 | #endif // _WIN64 343 | 344 | if (call_result == E_FAIL) 345 | { 346 | _last_err = "pIMojoIpc->ReLaunchChildProcess Internal Error"; 347 | return 0; 348 | } 349 | _last_err = "ERR_OK"; 350 | return call_result; 351 | } 352 | #pragma optimize( "", on ) 353 | 354 | //以下为Child IPC的实现 355 | qqimpl::qqipc::QQIpcChildWrapper::QQIpcChildWrapper() 356 | { 357 | m_ipc_dll = 0; 358 | m_ptr_IMojoIpc = NULL; 359 | _last_err = "ERR_OK"; 360 | } 361 | 362 | qqimpl::qqipc::QQIpcChildWrapper::~QQIpcChildWrapper() 363 | { 364 | } 365 | 366 | const char* qqimpl::qqipc::QQIpcChildWrapper::GetLastErrStr() 367 | { 368 | return this->_last_err.c_str(); 369 | } 370 | 371 | bool qqimpl::qqipc::QQIpcChildWrapper::InitEnv(const char* dll_path) 372 | { 373 | if ((dll_path == NULL) || (strlen(dll_path) == 0)) 374 | { 375 | #ifdef _WIN64 376 | dll_path = "parent-ipc-core-x64.dll"; 377 | #else 378 | dll_path = "parent-ipc-core-x86.dll"; 379 | #endif 380 | } 381 | 382 | m_ipc_dll = LoadLibraryA(dll_path); 383 | if (m_ipc_dll == NULL) 384 | { 385 | _last_err = "ChildIpc LoadDll Err"; 386 | return false; 387 | } 388 | 389 | LPFN_DLLGETCLASSOBJECT lpfnDllGetClassObject = (LPFN_DLLGETCLASSOBJECT)GetProcAddress(m_ipc_dll, "DllGetClassObject"); 390 | if (!lpfnDllGetClassObject) 391 | { 392 | _last_err = "Can't Get \'DllGetClassObject\' Addr"; 393 | return false; 394 | } 395 | 396 | IID clsid = { 0x14D5685E, 0x0574, 0x4F1F,{ 0xB6, 0xA4, 0x9B, 0xE9, 0xC3, 0xBE, 0x0C, 0x0D } }; 397 | //IID m_iid = { 0x00000001, 0x0000, 0x00000,{ 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46 } };//IID_IClassFactory 398 | IID riid = { 0x2A106583, 0xA3C4, 0x43AF,{ 0x85, 0xA0, 0x57, 0x81, 0x74, 0x89, 0x36, 0x1A} }; 399 | 400 | IClassFactory* pIClassFactory = NULL; 401 | if (lpfnDllGetClassObject(clsid, IID_IClassFactory, (LPVOID*)(&pIClassFactory)) != S_OK) 402 | { 403 | _last_err = "lpfnDllGetClassObject Err:[{}]"; 404 | return false; 405 | } 406 | 407 | DWORD_PTR* pIMojoIpc = NULL; 408 | pIClassFactory->CreateInstance(NULL, riid, (void**)&pIMojoIpc); 409 | pIClassFactory->Release(); 410 | if (pIMojoIpc == NULL) 411 | { 412 | _last_err = "pIClassFactory->CreateInstance Err"; 413 | return false; 414 | } 415 | 416 | this->m_ptr_IMojoIpc = pIMojoIpc; 417 | 418 | _last_err = "ERR_OK"; 419 | return true; 420 | } 421 | 422 | #pragma optimize( "", off ) 423 | void qqimpl::qqipc::QQIpcChildWrapper::InitChildIpc() 424 | { 425 | //pIMojoIpc->InitChildIpc() 426 | DWORD_PTR* pIMojoIpc = this->m_ptr_IMojoIpc, dwFunc = *((DWORD_PTR*)(*pIMojoIpc) + 3); 427 | 428 | #ifdef _WIN64 429 | InitChildIpcAsm((DWORD_PTR)pIMojoIpc, dwFunc); 430 | #else 431 | _asm 432 | { 433 | push pIMojoIpc 434 | call dwFunc 435 | } 436 | #endif // _WIN64 437 | 438 | _last_err = "ERR_OK"; 439 | } 440 | 441 | void qqimpl::qqipc::QQIpcChildWrapper::InitLog(int level, void* callback) 442 | { 443 | //pIMojoIpc->InitChildLog() 444 | DWORD_PTR* pIMojoIpc = this->m_ptr_IMojoIpc, dwFunc = *((DWORD_PTR*)(*pIMojoIpc) + 4); 445 | 446 | #ifdef _WIN64 447 | InitLogAsm((DWORD_PTR)pIMojoIpc, level, (DWORD_PTR)callback, dwFunc); 448 | #else 449 | _asm 450 | { 451 | push pIMojoIpc 452 | call dwFunc 453 | } 454 | #endif // _WIN64 455 | 456 | _last_err = "ERR_OK"; 457 | } 458 | 459 | void qqimpl::qqipc::QQIpcChildWrapper::SetChildReceiveCallback(callback_ipc callback) 460 | { 461 | //pIMojoIpc->SetChildReceiveCallbackAndCOMPtr() 462 | DWORD_PTR* pIMojoIpc = this->m_ptr_IMojoIpc, dwFunc = *((DWORD_PTR*)(*pIMojoIpc) + 5); 463 | DWORD_PTR ipc_ptr_addr = (DWORD_PTR)(&(this->m_ptr_IMojoIpc));//这个参数要是一个全局变量, 这里用类成员来代替 464 | DWORD_PTR* lpCallback = (DWORD_PTR*)(callback); 465 | 466 | #ifdef _WIN64 467 | SetChildReceiveCallbackAndCOMPtrAsm((DWORD_PTR)pIMojoIpc, (DWORD_PTR)lpCallback, ipc_ptr_addr, dwFunc); 468 | #else 469 | _asm 470 | { 471 | push ipc_ptr_addr 472 | push lpCallback 473 | push pIMojoIpc 474 | call dwFunc 475 | } 476 | #endif // _WIN64 477 | 478 | _last_err = "ERR_OK"; 479 | } 480 | 481 | void qqimpl::qqipc::QQIpcChildWrapper::SendIpcMessage(const char* command, const char* addition_msg, int addition_msg_size) 482 | { 483 | //pIMojoIpc->ChildSendMessageUsingBuffer(char* command, DWORD 0, DWORD 0, char* addition_msg, int addition_msg_size); 484 | DWORD_PTR* pIMojoIpc = this->m_ptr_IMojoIpc, dwFunc = *((DWORD_PTR*)(*pIMojoIpc) + 7); 485 | 486 | #ifdef _WIN64 487 | ChildSendIpcMessageAsm((DWORD_PTR)pIMojoIpc, (DWORD64)command, 0, (DWORD_PTR)addition_msg, addition_msg_size, dwFunc); 488 | #else 489 | _asm 490 | { 491 | push addition_msg_size 492 | push addition_msg 493 | push 0 494 | push 0 495 | push command 496 | push pIMojoIpc 497 | call dwFunc 498 | } 499 | #endif // _WIN64 500 | 501 | _last_err = "ERR_OK"; 502 | } 503 | #pragma optimize( "", on ) -------------------------------------------------------------------------------- /MMMojoCall/src/qq_mojoipc/qq_ipc_asm.asm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EEEEhex/QQImpl/3aac29788fc63d25665a0ae473b8b8c788ed20bb/MMMojoCall/src/qq_mojoipc/qq_ipc_asm.asm -------------------------------------------------------------------------------- /MMMojoCall/src/utils.cpp: -------------------------------------------------------------------------------- 1 | #include "utils.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | namespace qqimpl 9 | { 10 | namespace utils 11 | { 12 | std::wstring Utf8ToUnicode(std::string utf8_str) 13 | { 14 | if (utf8_str.empty()) 15 | return std::wstring(); 16 | 17 | const auto size_needed = MultiByteToWideChar(CP_UTF8, 0, &utf8_str.at(0), (int)utf8_str.size(), nullptr, 0); 18 | if (size_needed <= 0) 19 | { 20 | throw std::runtime_error("MultiByteToWideChar() failed: " + std::to_string(size_needed)); 21 | } 22 | 23 | std::wstring result(size_needed, 0); 24 | MultiByteToWideChar(CP_UTF8, 0, &utf8_str.at(0), (int)utf8_str.size(), &result.at(0), size_needed); 25 | return result; 26 | } 27 | 28 | std::string UnicodeToUtf8(std::wstring utf16_str) 29 | { 30 | if (utf16_str.empty()) 31 | return std::string(); 32 | 33 | const auto size_needed = WideCharToMultiByte(CP_UTF8, 0, &utf16_str.at(0), (int)utf16_str.size(), nullptr, 0, nullptr, nullptr); 34 | if (size_needed <= 0) 35 | { 36 | throw std::runtime_error("WideCharToMultiByte() failed: " + std::to_string(size_needed)); 37 | } 38 | 39 | std::string result(size_needed, 0); 40 | WideCharToMultiByte(CP_UTF8, 0, &utf16_str.at(0), (int)utf16_str.size(), &result.at(0), size_needed, nullptr, nullptr); 41 | return result; 42 | } 43 | 44 | int CheckPathInfo(std::string path) 45 | { 46 | struct _stat64i32 info; 47 | if (_stat(path.c_str(), &info) != 0) { // does not exist 48 | return 0; 49 | } 50 | 51 | if (info.st_mode & S_IFDIR) // directory 52 | return 1; 53 | else 54 | return 2; 55 | } 56 | 57 | int CheckPathInfo(std::wstring path) 58 | { 59 | struct _stat64i32 info; 60 | if (_wstat(path.c_str(), &info) != 0) { // does not exist 61 | return 0; 62 | } 63 | 64 | if (info.st_mode & S_IFDIR) // directory 65 | return 1; 66 | else 67 | return 2; 68 | } 69 | 70 | std::string string_format(const std::string fmt_str, ...) 71 | { 72 | int final_n, n = ((int)fmt_str.size()) * 2; /* Reserve two times as much as the length of the fmt_str */ 73 | std::unique_ptr formatted; 74 | va_list ap; 75 | while (1) { 76 | formatted.reset(new char[n]); /* Wrap the plain char array into the unique_ptr */ 77 | strcpy_s(&formatted[0], n, fmt_str.c_str()); 78 | va_start(ap, fmt_str); 79 | final_n = vsnprintf(&formatted[0], n, fmt_str.c_str(), ap); 80 | va_end(ap); 81 | if (final_n < 0 || final_n >= n) 82 | n += abs(final_n - n + 1); 83 | else 84 | break; 85 | } 86 | return std::string(formatted.get()); 87 | } 88 | } 89 | } 90 | 91 | 92 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 项目说明 2 | 本项目通过逆向QQNT 逆向出调用QQ Mojo IPC的方法, 使用QQMojoIPC可以调用QQNT的插件并与之通信。 3 | 并在此基础上逆向出调用微信MMMojo.dll的方法, 通过调用MMMojo可以调用WeChat的插件并与之通信。 4 | 5 | **目前可以调用QQNT的如下组件:** 6 | - [x] QQScreenShot 7 | 8 | **目前可以调用WeChat的如下组件:** 9 | 1. WeChatOCR.exe: 10 | - [x] OCR功能 11 | 12 | 2. WeChatUtility.exe: 13 | - [x] QRScan功能 (二维码扫描) 14 | - [x] TextScan功能 (可能是用来判断图片上有没有文字的) 15 | - [ ] ResampleImage功能 16 | - [ ] DecodeImage功能 17 | 18 | 3. WeChatPlayer.exe: 19 | - [x] 本地视频播放功能 20 | 21 | # 项目结构 22 | ├─3rdparty 23 | ├─examples 24 | ├─proto 25 | └─src 26 | \ \ ├─include 27 | \ \ │ ├─mmmojo_source 28 | \ \ │ ├─qq_mojoipc 29 | \ \ │ └─xplugin_protobuf 30 | \ \ ├─mmmojocall 31 | \ \ │ └─wrapper 32 | \ \ └─qq_mojoipc 33 | 34 | (此版本根据微信的mmmojo源码再次重构, 逻辑更清晰) 35 | 其中3rdparty是编译好的libprotobuf库, examples里是调用方法的示例, proto里是WeChat与组件之间的Protobuf通信协议的定义文件。 36 | src文件夹里 include中mmmojo_source是微信MMMojo的源代码中的一些定义, qq_mojoipc是实现QQMojoIPC的头文件, xplugin_protobuf是使用protoc编译后的头文件。 37 | qq_mojoipc文件夹是实现QQMojoIPC的实现文件, mmmojocall里是实现调用微信XPlugin组件的实现文件, 其中mmmojo_call.cpp是基础的调用XPlugin的方法, wrapper里是封装了对应组件通信协议的文件。 38 | 39 | # 编译说明 40 | 本项目使用cmake, 以下为cmake选项说明: 41 | | Option | 说明 | 42 | | ---- | ---- | 43 | | XPLUGIN_WRAPPER | 编译封装好WeChat通信协议的实现文件 默认为ON | 44 | | BUILD_QQIPC | 编译QQMojoIPC的实现文件 默认为OFF | 45 | | BUILD_CPPEXAMPLE | 编译调用方法示例项目 默认为OFF | 46 | | EXAMPLE_USE_JSON | CPP示例项目的回调函数的数据使用Json格式而非protobuf 默认为ON | 47 | | BUILD_PURE_C_MODE | 编译纯C接口方便其他语言调用 默认为OFF| 48 | 49 | ## 快速上手 50 | > 在编译前请先解压3rdparty下的压缩文件(或者自己编译一下protobuf) 以及src/include/xplugin_protobuf下的压缩的头文件 51 | 52 | 使用如下命令行: 53 | ``` 54 | cmake -B build -G "Visual Studio 17 2022" -A x64 -DBUILD_CPPEXAMPLE=ON 55 | ``` 56 | 如果需要使用其他语言调用, 需要加上(调用方法请查看examples文件夹) 57 | ``` 58 | -DBUILD_PURE_C_MODE=ON 59 | ``` 60 | 然后在build文件夹里编译生成visual studio项目即可 61 | 62 | # WeChat MMMojo说明 63 | 微信通过mmmojo_64.dll启动其组件并与组件通信。 64 | mmmojo就是对谷歌mojo ipc的一层封装, 有如下几种通信方式(具体请查看mmmojo.h) : 65 | ``` 66 | typedef enum { 67 | kMMNone = 0, 68 | kMMPush, 69 | kMMPullReq, 70 | kMMPullResp, 71 | kMMShared, 72 | } MMMojoInfoMethod; 73 | ``` 74 | 在与组件通信过程中,请求操作与回复都是通过发送 **request_id + pb数据 + MMMojoInfoMethod** 75 | 其中request_id表明了请求的操作类型(比如QRScan请求), pb数据携带操作的参数, MMMojoInfoMethod表明通信方式。 76 | 每个XPlugin组件都有自己定义的request_id(具体请查看mmmojo_call.h), 例如: 77 | (request_id 没有逆向全, 大体就是这么多了) 78 | ``` 79 | //WeChatUtility组件 80 | enum RequestIdUtility 81 | { 82 | UtilityHiPush = 10001, //是Utility启动发送的 83 | UtilityInitPullReq = 10002, //初始化请求 84 | UtilityInitPullResp = 10003, //回复创建的都是Shared类型的info, 但是调用了SwapMMMojoWriteInfoCallback, 所以回调的还是Pull 85 | UtilityResampleImagePullReq = 10010, 86 | UtilityResampleImagePullResp = 10011, 87 | UtilityDecodeImagePullReq = 10020, 88 | UtilityDecodeImagePullResp = 10021, 89 | UtilityPicQRScanPullReq = 10030, //10030是点击OCR时(也是打开图片时)发送的请求, 参数是图片路径 90 | UtilityQRScanPullReq = 10031, //10031是截图框选时发送的请求, 参数应该是某种编码后的图片数据 91 | UtilityQRScanPullResp = 10032, //这两种请求的返回ID都是10032 92 | UtilityTextScanPushResp = 10040 //TextScan具体在扫什么不是很清楚 可能是用来判断图片上是否有文字 93 | }; 94 | ``` 95 | pb数据就是对应的序列化后的protobuf数据(具体请查看proto文件夹下的定义文件), 例如: 96 | ``` 97 | message QRScanReqMessage { 98 | string origin_pic = 1; //原始图片路径 可选 99 | string decode_pic = 2; //解码后的图片路径 可选 100 | int32 unknown_0 = 3; //未知 可选 一般为0 101 | bytes encode_pic_data = 4; //某种编码后的图片数据 可选 102 | int32 encode_pic_x = 5; //编码图片长 可选 103 | int32 encode_pic_y = 6; //编码图片宽 可选 104 | int32 unknown_1 = 7; //未知 一般为1 105 | int32 text_scan_id = 8; //可能是 106 | int32 unknown_3 = 9; //未知 一般为1 107 | } 108 | 109 | ``` 110 | # 相关项目 111 | >本人代码能力比较差,此项目写的可能不是很方便使用,以下为其他师傅对本项目代码优化后的相关项目: 112 | 1. [swigger: wechat-ocr](https://github.com/swigger/wechat-ocr) 113 | 2. [kanadeblisst00: wechat_ocr](https://github.com/kanadeblisst00/wechat_ocr) 114 | 115 | 116 | -------------------------------------------------------------------------------- /parent-ipc-core-x64.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EEEEhex/QQImpl/3aac29788fc63d25665a0ae473b8b8c788ed20bb/parent-ipc-core-x64.dll -------------------------------------------------------------------------------- /parent-ipc-core-x86.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EEEEhex/QQImpl/3aac29788fc63d25665a0ae473b8b8c788ed20bb/parent-ipc-core-x86.dll --------------------------------------------------------------------------------