├── .gitattributes ├── .github ├── FUNDING.yml └── ISSUE_TEMPLATE │ ├── bug_report.yml │ ├── config.yml │ ├── feature_request.yml │ └── question.md ├── .gitignore ├── LICENSE ├── README.md └── src ├── ntapi.h ├── ntrtl.h ├── rapp.c ├── rapp.h ├── rconfig.h ├── routine.c ├── routine.h └── rtypes.h /.gitattributes: -------------------------------------------------------------------------------- 1 | *.c diff 2 | *.cpp diff 3 | *.h diff 4 | *.rc diff 5 | *.ini diff 6 | *.txt diff 7 | *.xml diff 8 | *.lng diff 9 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | custom: ["https://www.paypal.me/henrypp", "https://yoomoney.ru/to/4100115776040583", "https://www.blockchain.com/btc/address/1LrRTXPsvHcQWCNZotA9RcwjsGcRghG96c", "https://www.blockchain.com/eth/address/0xe2C84A62eb2a4EF154b19bec0c1c106734B95960"] 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.yml: -------------------------------------------------------------------------------- 1 | name: Bug report 2 | title: "[Bug]" 3 | description: Let me know about crash or existing functionality not working like it should. 4 | labels: [ "bug" ] 5 | body: 6 | - type: markdown 7 | attributes: 8 | value: Thanks for taking the time to fill out this bug report! 9 | - type: checkboxes 10 | id: checklist 11 | attributes: 12 | label: Checklist 13 | options: 14 | - label: I have used the search function to see if someone else has already submitted the same bug report. 15 | required: true 16 | - label: I will describe the problem with as much detail as possible. 17 | required: true 18 | - type: input 19 | id: version 20 | attributes: 21 | label: App version 22 | description: What the application version do you use. 23 | placeholder: x.y.z 24 | validations: 25 | required: true 26 | - type: input 27 | id: windows_version 28 | attributes: 29 | label: Windows version 30 | description: What Windows version do you use. 31 | validations: 32 | required: true 33 | - type: textarea 34 | id: steps 35 | attributes: 36 | label: Steps to reproduce 37 | placeholder: | 38 | 1. Go to '…' 39 | 2. Click on '…' 40 | 3. Scroll down to '…' 41 | 4. etc. 42 | validations: 43 | required: true 44 | - type: textarea 45 | id: expected 46 | attributes: 47 | label: Expected behavior 48 | description: After following the steps, what did you think application would do? 49 | validations: 50 | required: false 51 | - type: textarea 52 | id: actual 53 | attributes: 54 | label: Actual behavior 55 | description: What did application do instead? Screenshots might help. 56 | validations: 57 | required: true 58 | - type: textarea 59 | id: logs 60 | attributes: 61 | label: Logs 62 | description: | 63 | - If application have debug log insert it here. 64 | - If application have crash dump please attach it here. 65 | 66 | Tip: You can attach images, log files or crash dumps by clicking this area to highlight it and then dragging files in. 67 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.yml: -------------------------------------------------------------------------------- 1 | name: Feature request 2 | title: "[Feature]" 3 | description: Suggest an idea for this project. 4 | labels: [ "feature" ] 5 | body: 6 | - type: checkboxes 7 | id: checklist 8 | attributes: 9 | label: Checklist 10 | options: 11 | - label: I have used the search function to see if someone else has already submitted the same feature request. 12 | required: true 13 | - label: I will describe the problem with as much detail as possible. 14 | required: true 15 | - label: This issue only contains a request for one single feature, **not** multiple (related) features. 16 | required: true 17 | - type: input 18 | id: version 19 | attributes: 20 | label: App version 21 | description: What the application version do you use. 22 | placeholder: x.y.z 23 | validations: 24 | required: true 25 | - type: textarea 26 | id: problem 27 | attributes: 28 | label: Problem you are trying to solve 29 | description: Give a brief explanation of the problem you are trying to solve. 30 | validations: 31 | required: true 32 | - type: textarea 33 | id: solution 34 | attributes: 35 | label: Suggested solution 36 | description: Describe how you would like the app to help you solve that problem. Try to be as specific as possible. 37 | validations: 38 | required: true 39 | - type: textarea 40 | id: screenshots 41 | attributes: 42 | label: Screenshots / Drawings / Technical details 43 | description: | 44 | If your request is about (or includes) changing or extending the user interface (UI), describe what the UI would look like and how the user would interact with it. 45 | 46 | Tip: You can attach images or log files by clicking this area to highlight it and then dragging files in. 47 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/question.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Question 3 | about: Ask a question about application. 4 | title: '[Question]' 5 | labels: [ "question" ] 6 | assignees: '' 7 | 8 | --- 9 | 10 | Describe the question with as much detail as possible. 11 | 12 | --- 13 | 14 | App version: 15 | Windows version: -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .vs/ 2 | .vscode/ 3 | temp/ 4 | bin/32/ 5 | bin/64/ 6 | bin/arm64/ 7 | x64/ 8 | win32/ 9 | arm64/ 10 | __pycache__ 11 | 12 | thumbs.db 13 | ehthumbs.db 14 | desktop.ini 15 | 16 | *.cab 17 | *.msi 18 | *.msm 19 | *.msp 20 | *.lnk 21 | *.jpg 22 | *.zip 23 | *.log 24 | *.pdb 25 | *.exp 26 | *.sdf 27 | *.opensdf 28 | *.db 29 | *.opendb 30 | *.suo 31 | *.exp 32 | *.iobj 33 | *.ipch 34 | *.ipdb 35 | *.ilk 36 | *.obj 37 | *.res 38 | *.tlog 39 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## routine.c 2 | routine library for my projects. 3 | 4 | ### System requirements: 5 | - Windows 7, 8, 8.1, 10, 11 32-bit/64-bit/ARM64 6 | - An SSE2-capable CPU 7 | - KB2533623 KB3063858 update for Windows 7 was required [[x64](https://www.microsoft.com/en-us/download/details.aspx?id=47442) / [x32](https://www.microsoft.com/en-us/download/details.aspx?id=47409)] 8 | 9 | ### Donate: 10 | - [Bitcoin](https://www.blockchain.com/btc/address/1LrRTXPsvHcQWCNZotA9RcwjsGcRghG96c) (BTC) 11 | - [Ethereum](https://www.blockchain.com/explorer/addresses/eth/0xe2C84A62eb2a4EF154b19bec0c1c106734B95960) (ETC) 12 | - [Paypal](https://paypal.me/henrypp) (USD) 13 | - [Yandex Money](https://yoomoney.ru/to/4100115776040583) (RUB) 14 | 15 | ### GPG Signature: 16 | Binaries have this GPG signature. 17 | 18 | - Public key: [pubkey.asc](https://raw.githubusercontent.com/henrypp/builder/master/pubkey.asc) ([pgpkeys.eu](https://pgpkeys.eu/pks/lookup?op=index&fingerprint=on&search=0x5635B5FD)) 19 | - Key ID: 0x5635B5FD 20 | - Fingerprint: D985 2361 1524 AB29 BE73 30AC 2881 20A7 5635 B5FD 21 | 22 | ### Command line: 23 | List of arguments for compiled binary with `routine` library: 24 | 25 | ~~~ 26 | -minimized - start application with minimized/hidden window. 27 | -portable - set force portable mode. 28 | -readonly - set force readonly mode (no settings will be written). 29 | -nowow64 - allow to run 32-bit executable under 64-bit environment (32-bit only) 30 | ~~~ 31 | 32 | ### Settings: 33 | List of `ini` options for compiled binary with `routine` library: 34 | 35 |
36 | APP_NAME_SHORT.ini: 37 | 38 | --- 39 | ~~~ini 40 | # 41 | #2.0+ 42 | # 43 | 44 | # Enable update checking (BOOLEAN) 45 | # CheckUpdates=TRUE // removed in 2.3 46 | 47 | # Last update checking timestamp (LONG64) 48 | CheckUpdatesLast=0 49 | 50 | # Last opened settings dialog id (LONG) 51 | SettingsLastPage=0 52 | 53 | # Main window always on top (BOOLEAN) 54 | AlwaysOnTop=FALSE 55 | 56 | # Minimized main window on startup (BOOLEAN) 57 | IsStartMinimized=FALSE 58 | 59 | # Application locale name (STRING) 60 | Language=NULL 61 | 62 | # WinHTTP connections user-agent (STRING) 63 | UserAgent=NULL 64 | 65 | # 66 | #2.1+ 67 | # 68 | 69 | # Minimum error logging level (LONG) 70 | ErrorLevel=LOG_LEVEL_INFO 71 | 72 | # Last error notification timestamp (LONG64) 73 | #ErrorNotificationsTimestamp=0 // removed in 2.3 74 | 75 | # Error notification period in seconds (LONG64) 76 | #ErrorNotificationsPeriod=4 // removed in 2.3 77 | 78 | # Enable error notifications (BOOLEAN) 79 | IsErrorNotificationsEnabled=TRUE 80 | 81 | # Enable notifications sound (BOOLEAN) 82 | IsNotificationsSound=TRUE 83 | 84 | # 85 | #2.3+ 86 | # 87 | 88 | # Update checking period in hours, 0 for disable (LONG) 89 | CheckUpdatesPeriod=APP_UPDATE_PERIOD 90 | 91 | # 92 | #2.3.1+ 93 | # 94 | 95 | # Minimized main window into system tray (BOOLEAN) 96 | # Note: only when APP_HAVE_TRAY defined. 97 | IsMinimizeToTray=TRUE 98 | 99 | # Close main window into system tray (BOOLEAN) 100 | # Note: only when APP_HAVE_TRAY defined. 101 | IsCloseToTray=TRUE 102 | 103 | # 104 | #2.4+ 105 | # 106 | 107 | # Auto install non-executable updates if found (BOOLEAN) 108 | IsAutoinstallUpdates=FALSE (changed to TRUE in 2.7.12+) 109 | 110 | # 111 | #2.7+ 112 | # 113 | 114 | # Enable dark theme support (BOOLEAN) 115 | IsDarkThemeEnabled= 116 | 117 | # 118 | #2.7.2+ 119 | # 120 | 121 | # Show window border in Windows 11 and above (BOOLEAN) 122 | IsWindowBorderEnabled=TRUE 123 | 124 | # 125 | #2.7.10+ 126 | # 127 | 128 | # Show window round corners in Windows 11 and above (BOOLEAN) 129 | IsWindowCornerRound=FALSE 130 | ~~~ 131 |
132 | 133 | --- 134 | - Website: [github.com/henrypp](https://github.com/henrypp) 135 | - Support: sforce5@mail.ru 136 | --- 137 | (c) 2012-2025 Henry++ 138 | -------------------------------------------------------------------------------- /src/ntrtl.h: -------------------------------------------------------------------------------- 1 | // ntrtl.h 2 | 3 | #pragma once 4 | 5 | // 6 | // Linked lists 7 | // 8 | 9 | FORCEINLINE VOID InitializeListHead ( 10 | _Out_ PLIST_ENTRY ListHead 11 | ) 12 | { 13 | ListHead->Flink = ListHead->Blink = ListHead; 14 | } 15 | 16 | _Check_return_ 17 | FORCEINLINE BOOLEAN IsListEmpty ( 18 | _In_ PLIST_ENTRY ListHead 19 | ) 20 | { 21 | return ListHead->Flink == ListHead; 22 | } 23 | 24 | FORCEINLINE BOOLEAN RemoveEntryList ( 25 | _In_ PLIST_ENTRY Entry 26 | ) 27 | { 28 | PLIST_ENTRY Blink; 29 | PLIST_ENTRY Flink; 30 | 31 | Flink = Entry->Flink; 32 | Blink = Entry->Blink; 33 | Blink->Flink = Flink; 34 | Flink->Blink = Blink; 35 | 36 | return Flink == Blink; 37 | } 38 | 39 | FORCEINLINE PLIST_ENTRY RemoveHeadList ( 40 | _Inout_ PLIST_ENTRY ListHead 41 | ) 42 | { 43 | PLIST_ENTRY Flink; 44 | PLIST_ENTRY Entry; 45 | 46 | Entry = ListHead->Flink; 47 | Flink = Entry->Flink; 48 | ListHead->Flink = Flink; 49 | Flink->Blink = ListHead; 50 | 51 | return Entry; 52 | } 53 | 54 | FORCEINLINE PLIST_ENTRY RemoveTailList ( 55 | _Inout_ PLIST_ENTRY ListHead 56 | ) 57 | { 58 | PLIST_ENTRY Blink; 59 | PLIST_ENTRY Entry; 60 | 61 | Entry = ListHead->Blink; 62 | Blink = Entry->Blink; 63 | ListHead->Blink = Blink; 64 | Blink->Flink = ListHead; 65 | 66 | return Entry; 67 | } 68 | 69 | FORCEINLINE VOID InsertTailList ( 70 | _Inout_ PLIST_ENTRY ListHead, 71 | _Inout_ PLIST_ENTRY Entry 72 | ) 73 | { 74 | PLIST_ENTRY Blink; 75 | 76 | Blink = ListHead->Blink; 77 | Entry->Flink = ListHead; 78 | Entry->Blink = Blink; 79 | Blink->Flink = Entry; 80 | ListHead->Blink = Entry; 81 | } 82 | 83 | FORCEINLINE VOID InsertHeadList ( 84 | _Inout_ PLIST_ENTRY ListHead, 85 | _Inout_ PLIST_ENTRY Entry 86 | ) 87 | { 88 | PLIST_ENTRY Flink; 89 | 90 | Flink = ListHead->Flink; 91 | Entry->Flink = Flink; 92 | Entry->Blink = ListHead; 93 | Flink->Blink = Entry; 94 | ListHead->Flink = Entry; 95 | } 96 | 97 | FORCEINLINE VOID AppendTailList ( 98 | _Inout_ PLIST_ENTRY ListHead, 99 | _Inout_ PLIST_ENTRY ListToAppend 100 | ) 101 | { 102 | PLIST_ENTRY ListEnd = ListHead->Blink; 103 | 104 | ListHead->Blink->Flink = ListToAppend; 105 | ListHead->Blink = ListToAppend->Blink; 106 | ListToAppend->Blink->Flink = ListHead; 107 | ListToAppend->Blink = ListEnd; 108 | } 109 | 110 | FORCEINLINE PSINGLE_LIST_ENTRY PopEntryList ( 111 | _Inout_ PSINGLE_LIST_ENTRY ListHead 112 | ) 113 | { 114 | PSINGLE_LIST_ENTRY FirstEntry; 115 | 116 | FirstEntry = ListHead->Next; 117 | 118 | if (FirstEntry) 119 | ListHead->Next = FirstEntry->Next; 120 | 121 | return FirstEntry; 122 | } 123 | 124 | FORCEINLINE VOID PushEntryList ( 125 | _Inout_ PSINGLE_LIST_ENTRY ListHead, 126 | _Inout_ PSINGLE_LIST_ENTRY Entry 127 | ) 128 | { 129 | Entry->Next = ListHead->Next; 130 | ListHead->Next = Entry; 131 | } 132 | -------------------------------------------------------------------------------- /src/rapp.h: -------------------------------------------------------------------------------- 1 | // routine.c 2 | // project sdk library 3 | // 4 | // Copyright (c) 2012-2025 Henry++ 5 | 6 | #pragma once 7 | 8 | #include "routine.h" 9 | #include "rconfig.h" 10 | 11 | #include "resource.h" 12 | 13 | #if !defined(IDC_NAV) 14 | #define IDC_NAV 1000 15 | #endif // IDC_NAV 16 | 17 | #if !defined(IDC_RESET) 18 | #define IDC_RESET 1001 19 | #endif // IDC_RESET 20 | 21 | #if !defined(IDC_SAVE) 22 | #define IDC_SAVE 1002 23 | #endif // IDC_SAVE 24 | 25 | #if !defined(IDC_CLOSE) 26 | #define IDC_CLOSE 1003 27 | #endif // IDC_CLOSE 28 | 29 | #define WND_BACKGROUND_CLR RGB(0x2A, 0x2A, 0x2A) 30 | #define WND_BACKGROUND2_CLR RGB(0x40, 0x40, 0x40) 31 | #define WND_BORDER_CLR RGB(0x90, 0x10, 0x20) 32 | #define WND_BUTTON_CLR RGB(0x24, 0x24, 0x24) 33 | #define WND_HIGHLIGHT_CLR RGB(0x80, 0x80, 0x80) 34 | #define WND_HOT_CLR RGB(0xE3, 0x20, 0x00) 35 | #define WND_TEXT_CLR RGB(0xFF, 0xFF, 0xFF) 36 | #define WND_GRAYTEXT_CLR RGB(0x50, 0x50, 0x50) 37 | 38 | // 39 | // Global variables 40 | // 41 | 42 | DECLSPEC_SELECTANY APP_GLOBAL_CONFIG app_global = {0}; 43 | 44 | EXTERN_C_START 45 | 46 | // 47 | // Configuration 48 | // 49 | 50 | VOID _r_config_initialize (); 51 | 52 | BOOLEAN _r_config_getboolean ( 53 | _In_ LPCWSTR key_name, 54 | _In_ BOOLEAN def_value 55 | ); 56 | 57 | BOOLEAN _r_config_getboolean_ex ( 58 | _In_ LPCWSTR key_name, 59 | _In_opt_ BOOLEAN def_value, 60 | _In_opt_ LPCWSTR section_name 61 | ); 62 | 63 | LONG _r_config_getlong ( 64 | _In_ LPCWSTR key_name, 65 | _In_ LONG def_value 66 | ); 67 | 68 | LONG _r_config_getlong_ex ( 69 | _In_ LPCWSTR key_name, 70 | _In_opt_ LONG def_value, 71 | _In_opt_ LPCWSTR section_name 72 | ); 73 | 74 | LONG64 _r_config_getlong64 ( 75 | _In_ LPCWSTR key_name, 76 | _In_ LONG64 def_value 77 | ); 78 | 79 | LONG64 _r_config_getlong64_ex ( 80 | _In_ LPCWSTR key_name, 81 | _In_opt_ LONG64 def_value, 82 | _In_opt_ LPCWSTR section_name 83 | ); 84 | 85 | ULONG _r_config_getulong ( 86 | _In_ LPCWSTR key_name, 87 | _In_opt_ ULONG def_value 88 | ); 89 | 90 | ULONG _r_config_getulong_ex ( 91 | _In_ LPCWSTR key_name, 92 | _In_opt_ ULONG def_value, 93 | _In_opt_ LPCWSTR section_name 94 | ); 95 | 96 | ULONG64 _r_config_getulong64 ( 97 | _In_ LPCWSTR key_name, 98 | _In_opt_ ULONG64 def_value 99 | ); 100 | 101 | ULONG64 _r_config_getulong64_ex ( 102 | _In_ LPCWSTR key_name, 103 | _In_opt_ ULONG64 def_value, 104 | _In_opt_ LPCWSTR section_name 105 | ); 106 | 107 | VOID _r_config_getfont ( 108 | _In_ LPCWSTR key_name, 109 | _Inout_ PLOGFONT logfont, 110 | _In_ LONG dpi_value 111 | ); 112 | 113 | VOID _r_config_getfont_ex ( 114 | _In_ LPCWSTR key_name, 115 | _Inout_ PLOGFONT logfont, 116 | _In_ LONG dpi_value, 117 | _In_opt_ LPCWSTR section_name 118 | ); 119 | 120 | VOID _r_config_getsize ( 121 | _In_ LPCWSTR key_name, 122 | _Out_ PR_SIZE size, 123 | _In_opt_ PR_SIZE def_value, 124 | _In_opt_ LPCWSTR section_name 125 | ); 126 | 127 | _Ret_maybenull_ 128 | PR_STRING _r_config_getstringexpand ( 129 | _In_ LPCWSTR key_name, 130 | _In_opt_ LPCWSTR def_value 131 | ); 132 | 133 | _Ret_maybenull_ 134 | PR_STRING _r_config_getstringexpand_ex ( 135 | _In_ LPCWSTR key_name, 136 | _In_opt_ LPCWSTR def_value, 137 | _In_opt_ LPCWSTR section_name 138 | ); 139 | 140 | _Ret_maybenull_ 141 | PR_STRING _r_config_getstring ( 142 | _In_ LPCWSTR key_name, 143 | _In_opt_ LPCWSTR def_value 144 | ); 145 | 146 | _Ret_maybenull_ 147 | PR_STRING _r_config_getstring_ex ( 148 | _In_ LPCWSTR key_name, 149 | _In_opt_ LPCWSTR def_value, 150 | _In_opt_ LPCWSTR section_name 151 | ); 152 | 153 | VOID _r_config_setboolean ( 154 | _In_ LPCWSTR key_name, 155 | _In_ BOOLEAN value 156 | ); 157 | 158 | VOID _r_config_setboolean_ex ( 159 | _In_ LPCWSTR key_name, 160 | _In_ BOOLEAN value, 161 | _In_opt_ LPCWSTR section_name 162 | ); 163 | 164 | VOID _r_config_setlong ( 165 | _In_ LPCWSTR key_name, 166 | _In_ LONG value 167 | ); 168 | 169 | VOID _r_config_setlong_ex ( 170 | _In_ LPCWSTR key_name, 171 | _In_ LONG value, 172 | _In_opt_ LPCWSTR section_name 173 | ); 174 | 175 | VOID _r_config_setlong64 ( 176 | _In_ LPCWSTR key_name, 177 | _In_ LONG64 value 178 | ); 179 | 180 | VOID _r_config_setlong64_ex ( 181 | _In_ LPCWSTR key_name, 182 | _In_ LONG64 value, 183 | _In_opt_ LPCWSTR section_name 184 | ); 185 | 186 | VOID _r_config_setulong ( 187 | _In_ LPCWSTR key_name, 188 | _In_ ULONG value 189 | ); 190 | 191 | VOID _r_config_setulong_ex ( 192 | _In_ LPCWSTR key_name, 193 | _In_ ULONG value, 194 | _In_opt_ LPCWSTR section_name 195 | ); 196 | 197 | VOID _r_config_setulong64 ( 198 | _In_ LPCWSTR key_name, 199 | _In_ ULONG64 value 200 | ); 201 | 202 | VOID _r_config_setulong64_ex ( 203 | _In_ LPCWSTR key_name, 204 | _In_ ULONG64 value, 205 | _In_opt_ LPCWSTR section_name 206 | ); 207 | 208 | VOID _r_config_setfont ( 209 | _In_ LPCWSTR key_name, 210 | _In_ PLOGFONT logfont, 211 | _In_ LONG dpi_value 212 | ); 213 | 214 | VOID _r_config_setfont_ex ( 215 | _In_ LPCWSTR key_name, 216 | _In_ PLOGFONT logfont, 217 | _In_ LONG dpi_value, 218 | _In_opt_ LPCWSTR section_name 219 | ); 220 | 221 | VOID _r_config_setsize ( 222 | _In_ LPCWSTR key_name, 223 | _In_ PR_SIZE size, 224 | _In_opt_ LPCWSTR section_name 225 | ); 226 | 227 | VOID _r_config_setstringexpand ( 228 | _In_ LPCWSTR key_name, 229 | _In_opt_ LPWSTR value 230 | ); 231 | 232 | VOID _r_config_setstringexpand_ex ( 233 | _In_ LPCWSTR key_name, 234 | _In_opt_ LPWSTR value, 235 | _In_opt_ LPCWSTR section_name 236 | ); 237 | 238 | VOID _r_config_setstring ( 239 | _In_ LPCWSTR key_name, 240 | _In_opt_ LPCWSTR value 241 | ); 242 | 243 | VOID _r_config_setstring_ex ( 244 | _In_ LPCWSTR key_name, 245 | _In_opt_ LPCWSTR value, 246 | _In_opt_ LPCWSTR section_name 247 | ); 248 | 249 | // 250 | // Localization 251 | // 252 | 253 | VOID _r_locale_initialize (); 254 | 255 | VOID _r_locale_apply ( 256 | _In_ PVOID hwnd, 257 | _In_ INT ctrl_id, 258 | _In_opt_ UINT menu_id 259 | ); 260 | 261 | VOID _r_locale_enum ( 262 | _In_ PVOID hwnd, 263 | _In_ INT ctrl_id, 264 | _In_opt_ UINT menu_id 265 | ); 266 | 267 | ULONG_PTR _r_locale_getcount (); 268 | 269 | _Ret_maybenull_ 270 | PR_STRING _r_locale_getstring_ex ( 271 | _In_ ULONG uid 272 | ); 273 | 274 | LPWSTR _r_locale_getstring ( 275 | _In_ ULONG uid 276 | ); 277 | 278 | LONG64 _r_locale_getversion (); 279 | 280 | // 281 | // Settings 282 | // 283 | 284 | VOID _r_settings_addpage ( 285 | _In_ INT dlg_id, 286 | _In_ UINT locale_id 287 | ); 288 | 289 | VOID _r_settings_adjustchild ( 290 | _In_ HWND hwnd, 291 | _In_ INT ctrl_id, 292 | _In_ HWND hchild 293 | ); 294 | 295 | VOID _r_settings_createwindow ( 296 | _In_opt_ HWND hparent, 297 | _In_opt_ DLGPROC dlg_proc, 298 | _In_opt_ LONG dlg_id 299 | ); 300 | 301 | INT_PTR CALLBACK _r_settings_wndproc ( 302 | _In_ HWND hwnd, 303 | _In_ UINT msg, 304 | _In_ WPARAM wparam, 305 | _In_ LPARAM lparam 306 | ); 307 | 308 | FORCEINLINE HWND _r_settings_getwindow () 309 | { 310 | return app_global.settings.hwnd; 311 | } 312 | 313 | // 314 | // Autorun (optional feature) 315 | // 316 | 317 | _Success_ (NT_SUCCESS (return)) 318 | NTSTATUS _r_autorun_enable ( 319 | _In_opt_ HWND hwnd, 320 | _In_ BOOLEAN is_enable 321 | ); 322 | 323 | BOOLEAN _r_autorun_isenabled (); 324 | 325 | // 326 | // Skip UAC (optional feature) 327 | // 328 | 329 | HRESULT _r_skipuac_checkmodulepath ( 330 | _In_ IRegisteredTaskPtr registered_task 331 | ); 332 | 333 | BOOLEAN _r_skipuac_isenabled (); 334 | 335 | HRESULT _r_skipuac_enable ( 336 | _In_opt_ HWND hwnd, 337 | _In_ BOOLEAN is_enable 338 | ); 339 | 340 | BOOLEAN _r_skipuac_run (); 341 | 342 | // 343 | // Theme 344 | // 345 | 346 | VOID _r_theme_cleanup ( 347 | _In_ HWND hwnd, 348 | _In_ PR_THEME_CONTEXT context 349 | ); 350 | 351 | VOID _r_theme_enable ( 352 | _In_ HWND hwnd, 353 | _In_ BOOLEAN is_enable 354 | ); 355 | 356 | BOOL CALLBACK _r_theme_enumchildwindows ( 357 | _In_ HWND hwnd, 358 | _In_ LPARAM context 359 | ); 360 | 361 | VOID _r_theme_initialize ( 362 | _In_ HWND hwnd, 363 | _In_ BOOLEAN is_enable 364 | ); 365 | 366 | VOID _r_theme_initializecontext ( 367 | _In_ HWND hwnd, 368 | _In_opt_ LPCWSTR class_list, 369 | _In_ WNDPROC subclass_proc, 370 | _In_ BOOLEAN is_enable 371 | ); 372 | 373 | BOOLEAN _r_theme_isenabled (); 374 | 375 | VOID _r_theme_setwindowframe ( 376 | _In_ HWND hwnd, 377 | _In_ BOOLEAN is_enable 378 | ); 379 | 380 | LRESULT CALLBACK _r_theme_combobox_subclassproc ( 381 | _In_ HWND hwnd, 382 | _In_ UINT msg, 383 | _In_ WPARAM wparam, 384 | _In_ LPARAM lparam 385 | ); 386 | 387 | LRESULT CALLBACK _r_theme_drawbutton ( 388 | _In_ LPNMCUSTOMDRAW draw_info, 389 | _In_ LONG_PTR style 390 | ); 391 | 392 | LRESULT CALLBACK _r_theme_drawcheckbox ( 393 | _In_ LPNMCUSTOMDRAW draw_info, 394 | _In_ LONG_PTR style 395 | ); 396 | 397 | LRESULT CALLBACK _r_theme_edit_subclass ( 398 | _In_ HWND hwnd, 399 | _In_ UINT msg, 400 | _In_ WPARAM wparam, 401 | _In_ LPARAM lparam 402 | ); 403 | 404 | LRESULT CALLBACK _r_theme_groupbox_subclass ( 405 | _In_ HWND hwnd, 406 | _In_ UINT msg, 407 | _In_ WPARAM wparam, 408 | _In_ LPARAM lparam 409 | ); 410 | 411 | LRESULT CALLBACK _r_theme_header_subclass ( 412 | _In_ HWND hwnd, 413 | _In_ UINT msg, 414 | _In_ WPARAM wparam, 415 | _In_ LPARAM lparam 416 | ); 417 | 418 | LRESULT CALLBACK _r_theme_rebar_subclass ( 419 | _In_ HWND hwnd, 420 | _In_ UINT msg, 421 | _In_ WPARAM wparam, 422 | _In_ LPARAM lparam 423 | ); 424 | 425 | LRESULT CALLBACK _r_theme_statusbar_subclass ( 426 | _In_ HWND hwnd, 427 | _In_ UINT msg, 428 | _In_ WPARAM wparam, 429 | _In_ LPARAM lparam 430 | ); 431 | 432 | LRESULT CALLBACK _r_theme_tabcontrol_subclass ( 433 | _In_ HWND hwnd, 434 | _In_ UINT msg, 435 | _In_ WPARAM wparam, 436 | _In_ LPARAM lparam 437 | ); 438 | 439 | LRESULT CALLBACK _r_theme_subclassproc ( 440 | _In_ HWND hwnd, 441 | _In_ UINT msg, 442 | _In_ WPARAM wparam, 443 | _In_ LPARAM lparam 444 | ); 445 | 446 | FORCEINLINE HRESULT _r_theme_setdarkmode ( 447 | _In_ HWND hwnd, 448 | _In_ BOOLEAN is_enable 449 | ) 450 | { 451 | return SetWindowTheme (hwnd, is_enable ? L"DarkMode_Explorer" : L"Explorer", NULL); 452 | } 453 | 454 | // 455 | // Update checker (optional feature) 456 | // 457 | 458 | BOOLEAN NTAPI _r_update_downloadcallback ( 459 | _In_ ULONG total_written, 460 | _In_ ULONG total_length, 461 | _In_ PVOID lparam 462 | ); 463 | 464 | NTSTATUS _r_update_downloadupdate ( 465 | _In_ PR_UPDATE_INFO update_info, 466 | _Inout_ PR_UPDATE_COMPONENT update_component 467 | ); 468 | 469 | NTSTATUS NTAPI _r_update_downloadthread ( 470 | _In_ PVOID arglist 471 | ); 472 | 473 | NTSTATUS NTAPI _r_update_checkthread ( 474 | _In_ PVOID arglist 475 | ); 476 | 477 | VOID _r_update_enable ( 478 | _In_ BOOLEAN is_enable 479 | ); 480 | 481 | _Success_ (return) 482 | BOOLEAN _r_update_isenabled ( 483 | _In_ BOOLEAN is_checktimestamp 484 | ); 485 | 486 | _Success_ (return) 487 | BOOLEAN _r_update_check ( 488 | _In_opt_ HWND hparent 489 | ); 490 | 491 | HRESULT CALLBACK _r_update_pagecallback ( 492 | _In_ HWND hwnd, 493 | _In_ UINT msg, 494 | _In_ WPARAM wparam, 495 | _In_ LPARAM lparam, 496 | _In_ LONG_PTR pdata 497 | ); 498 | 499 | VOID _r_update_navigate ( 500 | _In_ PR_UPDATE_INFO update_info, 501 | _In_ TASKDIALOG_COMMON_BUTTON_FLAGS buttons, 502 | _In_opt_ TASKDIALOG_FLAGS flags, 503 | _In_opt_ LPCWSTR icon, 504 | _In_opt_ LPCWSTR title, 505 | _In_opt_ LPCWSTR content, 506 | _In_opt_ LONG error_code, 507 | _In_ R_ERROR_TYPE type 508 | ); 509 | 510 | VOID _r_update_addcomponent ( 511 | _In_ LPCWSTR full_name, 512 | _In_ LPCWSTR short_name, 513 | _In_ LPCWSTR version, 514 | _In_ PR_STRING target_path, 515 | _In_ BOOLEAN is_installer 516 | ); 517 | 518 | VOID _r_update_applyconfig (); 519 | 520 | VOID _r_update_install ( 521 | _In_opt_ HWND hwnd, 522 | _In_ PR_UPDATE_COMPONENT update_component 523 | ); 524 | 525 | // 526 | // Logging 527 | // 528 | 529 | BOOLEAN _r_log_isenabled ( 530 | _In_ R_LOG_LEVEL log_level_check 531 | ); 532 | 533 | _Ret_maybenull_ 534 | HANDLE _r_log_getfilehandle (); 535 | 536 | VOID _r_log ( 537 | _In_ R_LOG_LEVEL log_level, 538 | _In_opt_ LPCGUID tray_guid, 539 | _In_ LPCWSTR title, 540 | _In_ LONG error_code, 541 | _In_opt_ LPCWSTR description 542 | ); 543 | 544 | VOID _r_log_v ( 545 | _In_ R_LOG_LEVEL log_level, 546 | _In_opt_ LPCGUID tray_guid, 547 | _In_ LPCWSTR title, 548 | _In_ LONG error_code, 549 | _In_ _Printf_format_string_ LPCWSTR format, 550 | ... 551 | ); 552 | 553 | LPCWSTR _r_log_leveltostring ( 554 | _In_ R_LOG_LEVEL log_level 555 | ); 556 | 557 | ULONG _r_log_leveltrayicon ( 558 | _In_ R_LOG_LEVEL log_level 559 | ); 560 | 561 | // 562 | // Messages 563 | // 564 | 565 | VOID _r_report_error ( 566 | _In_opt_ LPCWSTR title, 567 | _In_opt_ LPCWSTR string, 568 | _In_ LONG status, 569 | _In_ R_ERROR_TYPE type 570 | ); 571 | 572 | VOID _r_show_aboutmessage ( 573 | _In_opt_ HWND hwnd 574 | ); 575 | 576 | BOOLEAN _r_show_confirmmessage ( 577 | _In_opt_ HWND hwnd, 578 | _In_opt_ LPCWSTR title, 579 | _In_opt_ LPCWSTR content, 580 | _In_opt_ LPCWSTR config_key, 581 | _In_opt_ BOOLEAN is_adminrequired 582 | ); 583 | 584 | NTSTATUS _r_show_errormessage ( 585 | _In_opt_ HWND hwnd, 586 | _In_opt_ LPCWSTR title, 587 | _In_ LONG error_code, 588 | _In_opt_ LPCWSTR description, 589 | _In_ R_ERROR_TYPE type 590 | ); 591 | 592 | INT _r_show_message ( 593 | _In_opt_ HWND hwnd, 594 | _In_ ULONG flags, 595 | _In_opt_ LPCWSTR title, 596 | _In_ LPCWSTR content 597 | ); 598 | 599 | VOID _r_window_restoreposition ( 600 | _In_ HWND hwnd, 601 | _In_ LPCWSTR window_name 602 | ); 603 | 604 | VOID _r_window_saveposition ( 605 | _In_ HWND hwnd, 606 | _In_ LPCWSTR window_name 607 | ); 608 | 609 | // 610 | // Application: seh 611 | // 612 | 613 | ULONG NTAPI _r_app_exceptionfilter_callback ( 614 | _In_ PEXCEPTION_POINTERS exception_ptr 615 | ); 616 | 617 | // 618 | // Application: common 619 | // 620 | 621 | LPWSTR _r_app_getmutexname (); 622 | 623 | BOOLEAN _r_app_isportable (); 624 | 625 | BOOLEAN _r_app_initialize_com (); 626 | 627 | VOID _r_app_initialize_components (); 628 | 629 | VOID _r_app_initialize_controls (); 630 | 631 | VOID _r_app_initialize_dll (); 632 | 633 | VOID _r_app_initialize_locale (); 634 | 635 | VOID _r_app_initialize_seh (); 636 | 637 | typedef enum _R_CMDLINE_INFO_CLASS 638 | { 639 | CmdlineHelp, 640 | CmdlineClean, 641 | CmdlineInstall, 642 | CmdlineUninstall, 643 | } R_CMDLINE_INFO_CLASS; 644 | 645 | typedef BOOLEAN (NTAPI *PR_CMDLINE_CALLBACK) ( 646 | _In_ R_CMDLINE_INFO_CLASS info_class 647 | ); 648 | 649 | BOOLEAN _r_app_initialize ( 650 | _In_opt_ PR_CMDLINE_CALLBACK cmd_callback 651 | ); 652 | 653 | PR_STRING _r_app_getdirectory (); 654 | 655 | PR_STRING _r_app_getconfigpath (); 656 | 657 | PR_STRING _r_app_getcachedirectory ( 658 | _In_ BOOLEAN is_create 659 | ); 660 | 661 | PR_STRING _r_app_getcrashdirectory ( 662 | _In_ BOOLEAN is_create 663 | ); 664 | 665 | PR_STRING _r_app_getlocalepath (); 666 | 667 | PR_STRING _r_app_getlogpath (); 668 | 669 | PR_STRING _r_app_getprofiledirectory (); 670 | 671 | _Ret_maybenull_ 672 | PR_STRING _r_app_getproxyconfiguration (); 673 | 674 | PR_STRING _r_app_getuseragent (); 675 | 676 | LRESULT CALLBACK _r_app_maindlgproc ( 677 | _In_ HWND hwnd, 678 | _In_ UINT msg, 679 | _In_ WPARAM wparam, 680 | _In_ LPARAM lparam 681 | ); 682 | 683 | _Ret_maybenull_ 684 | HWND _r_app_createwindow ( 685 | _In_ PVOID hinst, 686 | _In_ LPCWSTR dlg_name, 687 | _In_opt_ LPWSTR icon_name, 688 | _In_ DLGPROC dlg_proc 689 | ); 690 | 691 | ULONG _r_app_getshowcode ( 692 | _In_ HWND hwnd 693 | ); 694 | 695 | BOOLEAN _r_app_runasadmin (); 696 | 697 | VOID _r_app_restart ( 698 | _In_opt_ HWND hwnd 699 | ); 700 | 701 | EXTERN_C_END 702 | 703 | FORCEINLINE HWND _r_app_gethwnd () 704 | { 705 | return app_global.main.hwnd; 706 | } 707 | 708 | FORCEINLINE VOID _r_app_sethwnd ( 709 | _In_opt_ HWND hwnd 710 | ) 711 | { 712 | app_global.main.hwnd = hwnd; 713 | } 714 | 715 | FORCEINLINE LPWSTR _r_app_getname () 716 | { 717 | return (LPWSTR)APP_NAME; 718 | } 719 | 720 | FORCEINLINE LPCWSTR _r_app_getnameshort () 721 | { 722 | return APP_NAME_SHORT; 723 | } 724 | 725 | FORCEINLINE LPCWSTR _r_app_getauthor () 726 | { 727 | return APP_AUTHOR; 728 | } 729 | 730 | FORCEINLINE LPCWSTR _r_app_getcopyright () 731 | { 732 | return APP_COPYRIGHT; 733 | } 734 | 735 | FORCEINLINE LPCWSTR _r_app_getdonate_url () 736 | { 737 | return L"https://github.com/henrypp/" APP_NAME_SHORT L"#donate"; 738 | } 739 | 740 | FORCEINLINE LPCWSTR _r_app_getwebsite_url () 741 | { 742 | return L"https://github.com/henrypp/" APP_NAME_SHORT; 743 | } 744 | 745 | FORCEINLINE LPCWSTR _r_app_getupdate_url () 746 | { 747 | return L"https://raw.githubusercontent.com/henrypp/" APP_NAME_SHORT L"/master/VERSION"; 748 | } 749 | 750 | FORCEINLINE LPCWSTR _r_app_getversiontype () 751 | { 752 | #if defined(_DEBUG) || defined(APP_BETA) 753 | return L"Pre-release"; 754 | #else 755 | return L"Release"; 756 | #endif // _DEBUG || APP_BETA 757 | } 758 | 759 | FORCEINLINE LONG _r_app_getarch () 760 | { 761 | #if defined(_WIN64) 762 | return 64L; 763 | #else 764 | return 32L; 765 | #endif // _WIN64 766 | } 767 | 768 | FORCEINLINE LPCWSTR _r_app_getversion () 769 | { 770 | return APP_VERSION; 771 | } 772 | -------------------------------------------------------------------------------- /src/rconfig.h: -------------------------------------------------------------------------------- 1 | // routine.c 2 | // project sdk library 3 | // 4 | // Copyright (c) 2012-2025 Henry++ 5 | 6 | #pragma once 7 | 8 | // 9 | // Warning message macro 10 | // 11 | 12 | #define STRINGIZE_HELPER(x) #x 13 | #define STRINGIZE(x) STRINGIZE_HELPER(x) 14 | 15 | #define PR_PRINT_WARNING_UNDEFINED(desc) \ 16 | message("[WARNING!] Undefined: " #desc " (" STRINGIZE(__FILE__) ":" STRINGIZE(__LINE__) ")") 17 | 18 | #define PR_PRINT_WARNING_DEFINE(desc) \ 19 | message("[WARNING!] Config already defined: " #desc " (" STRINGIZE(__FILE__) ":" STRINGIZE(__LINE__) ")") 20 | 21 | // 22 | // Available project configurations 23 | // 24 | 25 | //#define APP_BETA // app has pre-release status 26 | 27 | //#define APP_HAVE_AUTORUN // enable autorun feature 28 | //#define APP_HAVE_SETTINGS_TABS // enable settings dialog feature based on treeview 29 | //#define APP_HAVE_TRAY // enable tray icon feature 30 | 31 | //#define APP_NO_APPDATA // use portable builds 32 | //#define APP_NO_CONFIG // do not save configuration 33 | //#define APP_NO_GUEST // disable "guest" mode, running without admin rights; see APP_HAVE_SKIPUAC 34 | //#define APP_NO_MUTEX // disable mutex 35 | 36 | #if defined(APP_CONSOLE) 37 | #undef APP_HAVE_AUTORUN 38 | #undef APP_HAVE_SETTINGS 39 | #undef APP_HAVE_SETTINGS_TABS 40 | #undef APP_HAVE_SKIPUAC 41 | #undef APP_HAVE_TRAY 42 | #undef APP_HAVE_UPDATES 43 | 44 | #define APP_NO_APPDATA 45 | #define APP_NO_CONFIG 46 | #endif // APP_CONSOLE 47 | 48 | #if defined(APP_HAVE_SETTINGS_TABS) 49 | #define APP_HAVE_SETTINGS 50 | #endif // APP_HAVE_SETTINGS_TABS 51 | 52 | // 53 | // Callback message codes 54 | // 55 | 56 | #define RM_INITIALIZE (WM_APP + 1) // application initialization 57 | #define RM_UNINITIALIZE (WM_APP + 2) // application uninitialization 58 | 59 | #define RM_INITIALIZE_POST (WM_APP + 3) // application one-time initialization 60 | #define RM_UNINITIALIZE_POST (WM_APP + 4) // application uninitialization 61 | 62 | #define RM_LOCALIZE (WM_APP + 5) // localization applied/changed 63 | #define RM_ARGUMENTS (WM_APP + 6) // application arguments 64 | #define RM_TASKBARCREATED (WM_APP + 7) // explorer restarted 65 | 66 | #define RM_CONFIG_SAVE (WM_APP + 8) // save configuration 67 | #define RM_CONFIG_UPDATE (WM_APP + 9) // update has finished 68 | #define RM_CONFIG_RESET (WM_APP + 10) // reset configuration has finished 69 | 70 | #define RM_TRAYICON (WM_APP + 11) 71 | 72 | // 73 | // Project configuration 74 | // 75 | 76 | #define APP_LANGUAGE_DEFAULT L"English" 77 | #define APP_SKIPUAC_NAME APP_NAME_SHORT L"Task" 78 | 79 | #if defined(APP_COMMENT) 80 | #pragma PR_PRINT_WARNING_DEFINE(APP_COMMENT) 81 | #else 82 | #define APP_COMMENT \ 83 | "What a tragedy it is for these words to fall upon deaf ears doomed to never reach their subject..." 84 | #endif /// APP_COMMENT 85 | 86 | // update checking period (in days) 87 | #if defined(APP_UPDATE_PERIOD) 88 | #pragma PR_PRINT_WARNING_DEFINE(APP_UPDATE_PERIOD) 89 | #else 90 | #define APP_UPDATE_PERIOD 6 91 | #endif // APP_UPDATE_PERIOD 92 | 93 | // error tray balloon period (in seconds) 94 | #if defined(APP_ERROR_PERIOD) 95 | #pragma PR_PRINT_WARNING_DEFINE(APP_ERROR_PERIOD) 96 | #else 97 | #define APP_ERROR_PERIOD 4 98 | #endif // APP_UPDATE_PERIOD 99 | 100 | // 101 | // Messages 102 | // 103 | 104 | #define APP_ABOUT_FOOTER L"This program is free software; you can redistribute it and/or modify it under the terms of " \ 105 | L"the GNU General Public License 3 " \ 106 | L"as published by the Free Software Foundation." 107 | 108 | #define APP_ABOUT_DONATE L"Bitcoin | " \ 109 | L"Ethereum | " \ 110 | L"PayPal | Yandex Money" 111 | 112 | #define APP_EXCEPTION_TITLE L"Exception raised :(" 113 | 114 | #define APP_SECURITY_TITLE L"Security warning!" 115 | 116 | #define APP_FAILED_MESSAGE_TITLE L"It happens ;(" 117 | #define APP_FAILED_MESSAGE_FOOTER L"This information may provide clues as to what went wrong and how to fix it." 118 | 119 | #define APP_FAILED_ADMIN_RIGHTS L"Administrative privileges are required!" 120 | #define APP_FAILED_COM_INITIALIZE L"COM library initialization failed!" 121 | 122 | #define APP_WARNING_WOW64_TITLE L"WoW64 warning!" 123 | #define APP_WARNING_WOW64_TEXT L"This application was not designed to run under WoW64. Do not run " \ 124 | L"32-bit executables\r\non 64-bit system because of performance loss and increased memory consumption.\r\n\r\n" \ 125 | L"Note: Add \"-nowow64\" argument to avoid this warning and take responsibility for the consequences." 126 | 127 | #define APP_WARNING_UAC_TEXT L"It is not recommended to enable this option\r\n" \ 128 | L"when running from outside a secure location (e.g. Program Files).\r\n\r\nAre you sure you want to continue?" 129 | 130 | #define APP_WARNING_UPDATE_TEXT \ 131 | L"This operating system are obsolete and does not meet security\r\nrequirements to establish secure network connection." 132 | 133 | #define APP_WARNING_LOG_TEXT L"Something went wrong. Open debug log file in profile directory." 134 | 135 | #define APP_QUESTION_RESTART L"Restart is required to apply configuration, restart now?" 136 | #define APP_QUESTION_RESET L"Are you really sure you want to reset all application settings?" 137 | 138 | // 139 | // Debug header 140 | // 141 | 142 | #define PR_DEBUG_HEADER L"Level,Date,Function,Code,Description,App version,OS version\r\n" 143 | #define PR_DEBUG_BODY L"\"%s\",\"%s\",\"%s\",\"0x%08" TEXT (PRIX32) L"\",\"%s\"" \ 144 | L",\"%s\",\"%" TEXT (PR_ULONG) L".%" TEXT (PR_ULONG) L" build %" TEXT (PRIu32) L"\"\r\n" 145 | -------------------------------------------------------------------------------- /src/rtypes.h: -------------------------------------------------------------------------------- 1 | // rtypes.h 2 | // project sdk library 3 | // 4 | // Copyright (c) 2019-2025 Henry++ 5 | 6 | #pragma once 7 | 8 | #include 9 | 10 | // 11 | // Types definition 12 | // 13 | 14 | typedef PSYSTEM_PROCESS_INFORMATION *PSYSTEM_PROCESS_INFORMATION_PTR; 15 | typedef PSECURITY_DESCRIPTOR *PSECURITY_DESCRIPTOR_PTR; 16 | typedef HIMAGELIST *HIMAGELIST_PTR; 17 | typedef HCATADMIN *HCATADMIN_PTR; 18 | typedef HBITMAP *HBITMAP_PTR; 19 | typedef PVOID *PVOID_PTR; 20 | typedef PBYTE *PBYTE_PTR; 21 | typedef HICON *HICON_PTR; 22 | typedef HDWP *HDWP_PTR; 23 | typedef PACL *PACL_PTR; 24 | 25 | typedef COMDLG_FILTERSPEC *LPCOMDLG_FILTERSPEC; 26 | typedef TASKDIALOGCONFIG *LPTASKDIALOGCONFIG; 27 | typedef IRegisteredTask *IRegisteredTaskPtr; 28 | 29 | #if defined(_ARM64_) 30 | typedef int64x2_t R_INT128; 31 | #else 32 | typedef __m128i R_INT128; 33 | #endif 34 | 35 | // 36 | // Exported function definitions 37 | // 38 | 39 | // VerQueryValue 40 | typedef BOOL (WINAPI *VQV) ( 41 | _In_ LPCVOID pBlock, 42 | _In_ LPCWSTR lpSubBlock, 43 | _Outptr_ PVOID_PTR lplpBuffer, 44 | _Out_ PUINT puLen 45 | ); 46 | 47 | // I_QueryTagInformation 48 | typedef ULONG (NTAPI *IQTI) ( 49 | _In_opt_ PCWSTR MachineName, 50 | _In_ TAG_INFO_LEVEL InfoLevel, 51 | _Inout_ PTAG_INFO_NAME_FROM_TAG TagInfo 52 | ); 53 | 54 | // IsImmersiveProcess (win8+) 55 | typedef BOOL (WINAPI *IIP) ( 56 | _In_ HANDLE hProcess 57 | ); 58 | 59 | // NtQueryWnfStateData (win8+) 60 | typedef NTSTATUS (NTAPI *NTQWNFSD) ( 61 | _In_ PCWNF_STATE_NAME StateName, 62 | _In_opt_ PCWNF_TYPE_ID TypeId, 63 | _In_opt_ const VOID *ExplicitScope, 64 | _Out_ PWNF_CHANGE_STAMP ChangeStamp, 65 | _Out_writes_bytes_to_opt_ (*BufferSize, *BufferSize) PVOID Buffer, 66 | _Inout_ PULONG BufferSize 67 | ); 68 | 69 | // GetDpiForMonitor (win81+) 70 | typedef HRESULT (WINAPI *GDFM)( 71 | _In_ HMONITOR hmonitor, 72 | _In_ MONITOR_DPI_TYPE dpiType, 73 | _Out_ PUINT dpiX, 74 | _Out_ PUINT dpiY 75 | ); 76 | 77 | // GetStagedPackagePathByFullName (win81+) 78 | typedef LONG (WINAPI *GSPPBF)( 79 | _In_ PCWSTR packageFullName, 80 | _Inout_ PUINT32 pathLength, 81 | _Out_opt_ PWSTR path 82 | ); 83 | 84 | // AdjustWindowRectExForDpi (win10rs1+) 85 | typedef BOOL (WINAPI *AWRFD)( 86 | _Inout_ LPRECT lpRect, 87 | _In_ ULONG dwStyle, 88 | _In_ BOOL bMenu, 89 | _In_ ULONG dwExStyle, 90 | _In_ UINT dpi 91 | ); 92 | 93 | // RtlDelayExecution (win10+) 94 | typedef NTSTATUS (NTAPI* RDE)( 95 | _In_ BOOLEAN Alertable, 96 | _In_opt_ PLARGE_INTEGER DelayInterval 97 | ); 98 | 99 | // GetDpiForSystem (win10rs1+) 100 | typedef UINT (WINAPI *GDFS)( 101 | VOID 102 | ); 103 | 104 | // GetDpiForWindow (win10rs1+) 105 | typedef UINT (WINAPI *GDFW)( 106 | _In_ HWND hwnd 107 | ); 108 | 109 | // GetSystemMetricsForDpi (win10rs1+) 110 | typedef INT (WINAPI *GSMFD)( 111 | _In_ INT nIndex, 112 | _In_ UINT dpi 113 | ); 114 | 115 | // SystemParametersInfoForDpi (win10rs1+) 116 | typedef BOOL (WINAPI *SPIFP)( 117 | _In_ UINT uiAction, 118 | _In_ UINT uiParam, 119 | _Pre_maybenull_ _Post_valid_ PVOID pvParam, 120 | _In_ UINT fWinIni, 121 | _In_ UINT dpi 122 | ); 123 | 124 | // RtlDosLongPathNameToNtPathName_I_WithStatus (win10rs1+) 125 | typedef NTSTATUS (NTAPI *RDLPN2NPN)( 126 | _In_ LPCWSTR DosFileName, 127 | _Out_ PUNICODE_STRING NtFileName, 128 | _Out_opt_ LPWSTR *FilePart, 129 | _Out_opt_ PRTL_RELATIVE_NAME_U RelativeName 130 | ); 131 | 132 | // OpenThemeDataForDpi (win10rs2+) 133 | typedef HTHEME (WINAPI *OTDFD)( 134 | _In_opt_ HWND hwnd, 135 | _In_ LPCWSTR pszClassList, 136 | _In_ UINT dpi 137 | ); 138 | 139 | // AllowDarkModeForApp (win10rs5+) 140 | typedef BOOL (WINAPI* ADMFA)( 141 | _In_ BOOL Enabled 142 | ); 143 | 144 | // FlushMenuThemes (win10rs5+) 145 | typedef VOID (WINAPI* FMT)(); 146 | 147 | // SetPreferredAppMode (win10rs5+) 148 | typedef BOOL (WINAPI* SPAM)( 149 | _In_ PreferredAppMode AppMode 150 | ); 151 | 152 | // RefreshImmersiveColorPolicyState (win10rs5+) 153 | typedef VOID (WINAPI* RICPS)(); 154 | 155 | // GetIsImmersiveColorUsingHighContrast (win10rs5+) 156 | typedef BOOL (WINAPI* GIICUHC)( 157 | _In_ IMMERSIVE_HC_CACHE_MODE Mode 158 | ); 159 | 160 | // OpenNcThemeData (win10rs5+) 161 | typedef HTHEME (WINAPI* ONCTD)( 162 | _In_ HWND hWnd, 163 | _In_ LPCWSTR classList 164 | ); 165 | 166 | // 167 | // Printf specifiers 168 | // 169 | 170 | #define PR_LONG "ld" 171 | #define PR_LONG64 "lld" 172 | 173 | #define PR_ULONG "lu" 174 | #define PR_ULONG64 "llu" 175 | 176 | #define PR_DOUBLE ".3f" 177 | 178 | #if defined(_WIN64) 179 | 180 | #define PR_LONG_PTR PR_LONG64 181 | #define PR_ULONG_PTR PR_ULONG64 182 | 183 | #define PR_PTRDIFF PR_LONG64 184 | 185 | #elif defined(_WIN32) 186 | 187 | #define PR_LONG_PTR PR_LONG 188 | #define PR_ULONG_PTR PR_ULONG 189 | 190 | #define PR_PTRDIFF PRIi32 191 | 192 | #else 193 | 194 | #error "Some printf specifiers are not defined. Unknown architecture!" 195 | 196 | #endif // _WIN64 197 | 198 | // 199 | // Configuration 200 | // 201 | 202 | #define PR_DEVICE_COUNT 26 203 | #define PR_DEVICE_PREFIX_LENGTH 64 204 | 205 | #define PR_SIZE_TREEINDENT 12 206 | #define PR_SIZE_ITEMHEIGHT 20 207 | #define PR_SIZE_FOOTERHEIGHT 48 208 | 209 | #define PR_SIZE_BUFFER_OVERFLOW (256 * 1024 * 1024) // 256 MB 210 | #define PR_SIZE_BUFFER 0x8000 211 | #define PR_SIZE_CONCAT_LENGTH_CACHE 16 212 | #define PR_SIZE_MAX_STRING_LENGTH (LONG_MAX - 1) 213 | 214 | // Macro for telling -Wimplicit-fallthrough that a fallthrough is intentional 215 | #if defined(__clang__) 216 | #define FALLTHROUGH [[clang::fallthrough]] 217 | #else 218 | #define FALLTHROUGH __fallthrough 219 | #endif 220 | 221 | #define I_DEFAULT -8 222 | 223 | // 224 | // Dark theme 225 | // 226 | 227 | typedef struct _R_THEME_CONTEXT 228 | { 229 | POINT pt; 230 | 231 | WNDPROC wnd_proc; 232 | 233 | HTHEME htheme; 234 | 235 | HDC hdc; 236 | 237 | BOOLEAN is_mouseactive; 238 | } R_THEME_CONTEXT, *PR_THEME_CONTEXT; 239 | 240 | // 241 | // Messages 242 | // 243 | 244 | // not really used in our case but part of the other structures 245 | typedef struct _UAHMENUPOPUPMETRICS 246 | { 247 | ULONG rgcx[4]; 248 | ULONG fUpdateMaxWidths : 2; // from kernel symbols, padded to full dword 249 | } UAHMENUPOPUPMETRICS, *LPUAHMENUPOPUPMETRICS; 250 | 251 | // describes the sizes of the menu bar or menu item 252 | typedef union _UAHMENUITEMMETRICS 253 | { 254 | // cx appears to be 14 / 0xE less than rcItem's width! 255 | // cy 0x14 seems stable, i wonder if it is 4 less than rcItem's height which is always 24 atm 256 | 257 | struct 258 | { 259 | ULONG cx; 260 | ULONG cy; 261 | } rgSizeBar[2]; 262 | 263 | struct 264 | { 265 | ULONG cx; 266 | ULONG cy; 267 | } rgSizePopup[4]; 268 | } UAHMENUITEMMETRICS, *LPUAHMENUITEMMETRICS; 269 | 270 | // menu items are always referred to by iPosition here 271 | typedef struct _UAHMENUITEM 272 | { 273 | LONG iPosition; // 0-based position of menu item in menubar 274 | UAHMENUITEMMETRICS umim; 275 | UAHMENUPOPUPMETRICS umpm; 276 | } UAHMENUITEM, *LPUAHMENUITEM; 277 | 278 | // hmenu is the main window menu; hdc is the context to draw in 279 | typedef struct _UAHMENU 280 | { 281 | HMENU hmenu; 282 | HDC hdc; 283 | ULONG dwFlags; // no idea what these mean, in my testing it's either 0x00000A00 or sometimes 0x00000A10 284 | } UAHMENU, *LPUAHMENU; 285 | 286 | // the DRAWITEMSTRUCT contains the states of the menu items, as well as 287 | // the position index of the item in the menu, which is duplicated in 288 | // the UAHMENUITEM's iPosition as well 289 | typedef struct _UAHDRAWMENUITEM 290 | { 291 | DRAWITEMSTRUCT dis; 292 | UAHMENU um; 293 | UAHMENUITEM umi; 294 | } UAHDRAWMENUITEM, *LPUAHDRAWMENUITEM; 295 | 296 | // window messages related to menu bar drawing 297 | #define WM_UAHDESTROYWINDOW 0x0090 // handled by DefWindowProc 298 | #define WM_UAHDRAWMENU 0x0091 // lParam is UAHMENU 299 | #define WM_UAHDRAWMENUITEM 0x0092 // lParam is UAHDRAWMENUITEM 300 | #define WM_UAHINITMENU 0x0093 // handled by DefWindowProc 301 | #define WM_UAHMEASUREMENUITEM 0x0094 // lParam is UAHMEASUREMENUITEM 302 | #define WM_UAHNCPAINTMENUPOPUP 0x0095 // handled by DefWindowProc 303 | 304 | #define EM_SETBKGNDCOLOR (WM_USER + 67) 305 | 306 | #define HRGN_FULL ((HRGN)1) // passed by WM_NCPAINT even though it's completely undocumented (wj32) 307 | 308 | #define DCX_USESTYLE 0x00010000 309 | #define DCX_NODELETERGN 0x00040000 310 | 311 | // 312 | // Logging 313 | // 314 | 315 | typedef enum _R_LOG_LEVEL 316 | { 317 | LOG_LEVEL_DISABLED = 0, 318 | LOG_LEVEL_DEBUG = 1, 319 | LOG_LEVEL_INFO = 2, 320 | LOG_LEVEL_WARNING = 3, 321 | LOG_LEVEL_ERROR = 4, 322 | LOG_LEVEL_CRITICAL = 5, 323 | } R_LOG_LEVEL, *PR_LOG_LEVEL; 324 | 325 | typedef enum _R_ERROR_TYPE 326 | { 327 | ET_NONE = -1, 328 | ET_WINDOWS = 0, 329 | ET_NATIVE = 1, 330 | ET_WINHTTP = 2, 331 | } R_ERROR_TYPE, *PR_ERROR_TYPE; 332 | 333 | // 334 | // Synchronization: A fast event object. 335 | // 336 | 337 | typedef struct _R_EVENT 338 | { 339 | union 340 | { 341 | volatile ULONG_PTR value; 342 | 343 | struct 344 | { 345 | USHORT is_set : 1; 346 | USHORT ref_count : 15; 347 | UCHAR reserved; 348 | UCHAR available_for_use; 349 | 350 | #if defined(_WIN64) 351 | ULONG spare_bit; 352 | #endif // _WIN64 353 | }; 354 | }; 355 | 356 | HANDLE event_handle; 357 | } R_EVENT, *PR_EVENT; 358 | 359 | C_ASSERT (sizeof (R_EVENT) == sizeof (ULONG_PTR) + sizeof (HANDLE)); 360 | 361 | #define PR_EVENT_SET 0x01 362 | #define PR_EVENT_SET_SHIFT 0x00 363 | #define PR_EVENT_REFCOUNT_SHIFT 0x01 364 | #define PR_EVENT_REFCOUNT_INC 0x02 365 | #define PR_EVENT_REFCOUNT_MASK (((ULONG_PTR)1 << 15) - 1) 366 | 367 | #define PR_EVENT_INIT { { PR_EVENT_REFCOUNT_INC }, NULL } 368 | 369 | // 370 | // Synchronization: One-time initialization 371 | // 372 | 373 | typedef RTL_RUN_ONCE R_INITONCE; 374 | typedef PRTL_RUN_ONCE PR_INITONCE; 375 | 376 | #define PR_INITONCE_INIT RTL_RUN_ONCE_INIT 377 | 378 | // 379 | // Synchronization: Auto-dereference pool 380 | // 381 | 382 | // The size of the static array in an auto-release pool. 383 | #define PR_AUTO_POOL_STATIC_SIZE 64 384 | 385 | // The maximum size of the dynamic array for it to be kept after the auto-release pool is drained. 386 | #define PR_AUTO_POOL_DYNAMIC_BIG_SIZE 256 387 | 388 | typedef struct _R_AUTO_POOL 389 | { 390 | PVOID static_objects[PR_AUTO_POOL_STATIC_SIZE]; 391 | ULONG_PTR static_count; 392 | 393 | ULONG_PTR dynamic_count; 394 | ULONG_PTR dynamic_allocated; 395 | PVOID_PTR dynamic_objects; 396 | 397 | struct _R_AUTO_POOL *next_pool; 398 | } R_AUTO_POOL, *PR_AUTO_POOL; 399 | 400 | // 401 | // Synchronization: Free list 402 | // 403 | 404 | typedef struct _R_FREE_LIST 405 | { 406 | SLIST_HEADER list_head; 407 | 408 | ULONG_PTR size; 409 | 410 | ULONG maximum_count; 411 | ULONG count; 412 | } R_FREE_LIST, *PR_FREE_LIST; 413 | 414 | typedef struct _R_FREE_LIST_ENTRY 415 | { 416 | SLIST_ENTRY list_entry; 417 | QUAD_PTR body; 418 | } R_FREE_LIST_ENTRY, *PR_FREE_LIST_ENTRY; 419 | 420 | #if defined(_WIN64) 421 | C_ASSERT (FIELD_OFFSET (R_FREE_LIST_ENTRY, list_entry) == 0x00); 422 | C_ASSERT (FIELD_OFFSET (R_FREE_LIST_ENTRY, body) == 0x10); 423 | #else 424 | C_ASSERT (FIELD_OFFSET (R_FREE_LIST_ENTRY, list_entry) == 0x00); 425 | C_ASSERT (FIELD_OFFSET (R_FREE_LIST_ENTRY, body) == 0x08); 426 | #endif // _WIN64 427 | 428 | // 429 | // Synchronization: Queued lock 430 | // 431 | 432 | typedef struct _R_QUEUED_LOCK 433 | { 434 | ULONG_PTR value; 435 | } R_QUEUED_LOCK, *PR_QUEUED_LOCK; 436 | 437 | typedef struct DECLSPEC_ALIGN (16) _R_QUEUED_WAIT_BLOCK 438 | { 439 | // A pointer to the next wait block, i.e. the wait block pushed onto the list before this one. 440 | struct _R_QUEUED_WAIT_BLOCK *next_block; 441 | 442 | // A pointer to the previous wait block, i.e. the wait block pushed onto the list after this one. 443 | struct _R_QUEUED_WAIT_BLOCK *previous_block; 444 | 445 | // A pointer to the last wait block, i.e. the first waiter pushed onto the list. 446 | struct _R_QUEUED_WAIT_BLOCK *last_block; 447 | 448 | ULONG shared_owners; 449 | ULONG flags; 450 | } R_QUEUED_WAIT_BLOCK, *PR_QUEUED_WAIT_BLOCK; 451 | 452 | static_assert ((sizeof (R_QUEUED_WAIT_BLOCK) % MEMORY_ALLOCATION_ALIGNMENT) == 0); 453 | 454 | #define PR_QUEUED_LOCK_INIT {0} 455 | 456 | #define PR_QUEUED_WAITER_EXCLUSIVE 0x1 457 | #define PR_QUEUED_WAITER_SPINNING 0x2 458 | #define PR_QUEUED_WAITER_SPINNING_SHIFT 1 459 | 460 | #define PR_QUEUED_LOCK_OWNED ((ULONG_PTR)0x1) 461 | #define PR_QUEUED_LOCK_OWNED_SHIFT 0 462 | #define PR_QUEUED_LOCK_WAITERS ((ULONG_PTR)0x2) 463 | 464 | // Valid only if Waiters = 0 465 | #define PR_QUEUED_LOCK_SHARED_INC ((ULONG_PTR)0x4) 466 | #define PR_QUEUED_LOCK_SHARED_SHIFT 2 467 | 468 | // Valid only if Waiters = 1 469 | #define PR_QUEUED_LOCK_TRAVERSING ((ULONG_PTR)0x4) 470 | #define PR_QUEUED_LOCK_MULTIPLE_SHARED ((ULONG_PTR)0x8) 471 | 472 | #define PR_QUEUED_LOCK_FLAGS ((ULONG_PTR)0xF) 473 | 474 | #define _r_queuedlock_getsharedowners(value) \ 475 | ((ULONG_PTR)(value) >> PR_QUEUED_LOCK_SHARED_SHIFT) 476 | 477 | #define _r_queuedlock_getwaitblock(value) \ 478 | ((PR_QUEUED_WAIT_BLOCK)((ULONG_PTR)(value) & ~PR_QUEUED_LOCK_FLAGS)) 479 | 480 | // 481 | // Synchronization: Condition 482 | // 483 | 484 | typedef struct _R_QUEUED_LOCK R_CONDITION, *PR_CONDITION; 485 | 486 | #define PR_CONDITION_WAIT_QUEUED_LOCK 0x001 487 | #define PR_CONDITION_WAIT_CRITICAL_SECTION 0x002 488 | #define PR_CONDITION_WAIT_FAST_LOCK 0x004 489 | #define PR_CONDITION_WAIT_LOCK_TYPE_MASK 0xFFF 490 | 491 | #define PR_CONDITION_WAIT_SHARED 0x1000 492 | #define PR_CONDITION_WAIT_SPIN 0x2000 493 | 494 | #define PR_CONDITION_INIT PR_QUEUED_LOCK_INIT 495 | 496 | // 497 | // Synchronization: Rundown protection 498 | // 499 | 500 | typedef struct _R_RUNDOWN_WAIT_BLOCK 501 | { 502 | R_EVENT wake_event; 503 | 504 | volatile ULONG_PTR count; 505 | } R_RUNDOWN_WAIT_BLOCK, *PR_RUNDOWN_WAIT_BLOCK; 506 | 507 | typedef struct _R_QUEUED_LOCK R_RUNDOWN_PROTECT, *PR_RUNDOWN_PROTECT; 508 | 509 | #define PR_RUNDOWN_ACTIVE 0x1 510 | #define PR_RUNDOWN_REF_SHIFT 1 511 | #define PR_RUNDOWN_REF_INC 0x2 512 | 513 | #define PR_RUNDOWN_PROTECT_INIT PR_QUEUED_LOCK_INIT 514 | 515 | // 516 | // Synchronization: Workqueue 517 | // 518 | 519 | typedef VOID (NTAPI *PR_WORKQUEUE_FUNCTION) ( 520 | _In_opt_ PVOID arglist 521 | ); 522 | 523 | typedef struct _R_ENVIRONMENT 524 | { 525 | KPRIORITY base_priority : 6; // Base priority increment 526 | ULONG io_priority : 3; // I/O priority hint 527 | ULONG page_priority : 3; // Page/memory priority 528 | ULONG spare_bits : 20; 529 | } R_ENVIRONMENT, *PR_ENVIRONMENT; 530 | 531 | typedef struct _R_WORKQUEUE_ITEM 532 | { 533 | LIST_ENTRY list_entry; 534 | PR_WORKQUEUE_FUNCTION base_address; 535 | PVOID context; 536 | } R_WORKQUEUE_ITEM, *PR_WORKQUEUE_ITEM; 537 | 538 | typedef struct _R_WORKQUEUE 539 | { 540 | LIST_ENTRY queue_list_head; 541 | 542 | R_QUEUED_LOCK queue_lock; 543 | R_QUEUED_LOCK state_lock; 544 | 545 | R_RUNDOWN_PROTECT rundown_protect; 546 | R_CONDITION queue_empty_condition; 547 | 548 | R_ENVIRONMENT environment; 549 | PVOID thread_name; // PR_STRING 550 | 551 | HANDLE hsemaphore; 552 | 553 | ULONG minimum_threads; 554 | ULONG maximum_threads; 555 | 556 | volatile ULONG current_threads; 557 | volatile ULONG busy_count; 558 | 559 | BOOLEAN is_terminating; 560 | } R_WORKQUEUE, *PR_WORKQUEUE; 561 | 562 | // 563 | // Objects reference 564 | // 565 | 566 | typedef VOID (NTAPI *PR_OBJECT_CLEANUP_CALLBACK) ( 567 | _In_ PVOID object_body 568 | ); 569 | 570 | typedef struct _R_OBJECT_HEADER 571 | { 572 | struct 573 | { 574 | PR_OBJECT_CLEANUP_CALLBACK cleanup_callback; 575 | 576 | volatile LONG ref_count; 577 | }; 578 | 579 | QUAD_PTR body; 580 | } R_OBJECT_HEADER, *PR_OBJECT_HEADER; 581 | 582 | #define PR_OBJECT_HEADER_TO_OBJECT(object_header) (&((PR_OBJECT_HEADER)(object_header))->body) 583 | 584 | #define PR_OBJECT_TO_OBJECT_HEADER(object) (CONTAINING_RECORD((object), R_OBJECT_HEADER, body)) 585 | 586 | // 587 | // 8-bit string object 588 | // 589 | 590 | typedef struct _R_BYTEREF 591 | { 592 | ULONG_PTR length; 593 | LPSTR buffer; 594 | } R_BYTEREF, *PR_BYTEREF; 595 | 596 | typedef struct _R_BYTE 597 | { 598 | union 599 | { 600 | R_BYTEREF sr; 601 | 602 | struct 603 | { 604 | ULONG_PTR length; 605 | LPSTR buffer; 606 | }; 607 | }; 608 | 609 | CHAR data[1]; 610 | } R_BYTE, *PR_BYTE; 611 | 612 | typedef PR_BYTE *PR_BYTE_PTR; 613 | 614 | #define PR_BYTEREF_INIT(string) { sizeof(string) - sizeof(ANSI_NULL), (string) } 615 | 616 | // 617 | // 16-bit string object 618 | // 619 | 620 | typedef struct _R_STRINGREF 621 | { 622 | ULONG_PTR length; 623 | LPWSTR buffer; 624 | } R_STRINGREF, *PR_STRINGREF; 625 | 626 | typedef struct _R_STRING 627 | { 628 | union 629 | { 630 | R_STRINGREF sr; 631 | 632 | struct 633 | { 634 | ULONG_PTR length; 635 | LPWSTR buffer; 636 | }; 637 | }; 638 | 639 | WCHAR data[1]; 640 | } R_STRING, *PR_STRING; 641 | 642 | typedef PR_STRING *PR_STRING_PTR; 643 | 644 | #define PR_STRINGREF_INIT(string) { sizeof(string) - sizeof(UNICODE_NULL), (string) } 645 | 646 | // 647 | // String builder 648 | // 649 | 650 | typedef struct _R_STRINGBUILDER 651 | { 652 | PR_STRING string; 653 | ULONG_PTR allocated_length; 654 | } R_STRINGBUILDER, *PR_STRINGBUILDER; 655 | 656 | // 657 | // Array object 658 | // 659 | 660 | typedef struct _R_ARRAY 661 | { 662 | PR_OBJECT_CLEANUP_CALLBACK cleanup_callback; 663 | ULONG_PTR allocated_count; 664 | ULONG_PTR count; 665 | ULONG_PTR item_size; 666 | PVOID items; 667 | } R_ARRAY, *PR_ARRAY; 668 | 669 | typedef PR_ARRAY *PR_ARRAY_PTR; 670 | 671 | // 672 | // List object 673 | // 674 | 675 | typedef struct _R_LIST 676 | { 677 | PR_OBJECT_CLEANUP_CALLBACK cleanup_callback; 678 | ULONG_PTR allocated_count; 679 | ULONG_PTR count; 680 | PVOID_PTR items; 681 | } R_LIST, *PR_LIST; 682 | 683 | typedef PR_LIST *PR_LIST_PTR; 684 | 685 | // 686 | // Hashtable object 687 | // 688 | 689 | typedef struct _R_HASHTABLE_ENTRY 690 | { 691 | ULONG_PTR next; 692 | ULONG_PTR hash_code; 693 | QUAD_PTR body; 694 | } R_HASHTABLE_ENTRY, *PR_HASHTABLE_ENTRY; 695 | 696 | typedef struct _R_HASHTABLE 697 | { 698 | PR_OBJECT_CLEANUP_CALLBACK cleanup_callback; 699 | PULONG_PTR buckets; 700 | PVOID entries; 701 | ULONG_PTR free_entry; 702 | ULONG_PTR next_entry; 703 | ULONG_PTR entry_size; 704 | ULONG_PTR allocated_buckets; 705 | ULONG_PTR allocated_entries; 706 | ULONG_PTR count; 707 | } R_HASHTABLE, *PR_HASHTABLE; 708 | 709 | typedef PR_HASHTABLE *PR_HASHTABLE_PTR; 710 | 711 | #define PR_HASHTABLE_ENTRY_SIZE(inner_size) \ 712 | (UFIELD_OFFSET(R_HASHTABLE_ENTRY, body) + (inner_size)) 713 | 714 | #define PR_HASHTABLE_GET_ENTRY(hashtable, index) \ 715 | ((PR_HASHTABLE_ENTRY)PTR_ADD_OFFSET((hashtable)->entries, PR_HASHTABLE_ENTRY_SIZE((hashtable)->entry_size) * (index))) 716 | 717 | #define PR_HASHTABLE_GET_ENTRY_INDEX(hashtable, entry) \ 718 | ((ULONG_PTR)(PTR_ADD_OFFSET(entry, -(hashtable)->entries) / PR_HASHTABLE_ENTRY_SIZE((hashtable)->entry_size))) 719 | 720 | #define PR_HASHTABLE_INIT_VALUE 0xFF 721 | 722 | // 723 | // Hashtable object pointer object 724 | // 725 | 726 | typedef struct _R_OBJECT_POINTER 727 | { 728 | PVOID object_body; 729 | } R_OBJECT_POINTER, *PR_OBJECT_POINTER; 730 | 731 | // 732 | // Pointer storage 733 | // 734 | 735 | typedef struct _R_STORAGE 736 | { 737 | ULONG length; 738 | PVOID buffer; 739 | } R_STORAGE, *PR_STORAGE; 740 | 741 | // 742 | // Strings 743 | // 744 | 745 | #define PR_MAKE_VERSION_ULONG64(major, minor, build, revision) \ 746 | (((ULONG64)(major) << 48) | \ 747 | ((ULONG64)(minor) << 32) | \ 748 | ((ULONG64)(build) << 16) | \ 749 | ((ULONG64)(revision) << 0)) 750 | 751 | #define PR_TRIM_START_ONLY 0x0001 752 | #define PR_TRIM_END_ONLY 0x0002 753 | 754 | // 755 | // Cryptography 756 | // 757 | 758 | typedef struct _R_CRYPT_CONTEXT 759 | { 760 | BCRYPT_ALG_HANDLE alg_handle; 761 | 762 | union 763 | { 764 | BCRYPT_HASH_HANDLE hash_handle; 765 | BCRYPT_KEY_HANDLE key_handle; 766 | } u; 767 | 768 | PR_BYTE object_data; // cipher - key object, hashing - hash object 769 | PR_BYTE block_data; // cipher - block iv, hashing - hash value 770 | 771 | BOOLEAN is_hashing; 772 | } R_CRYPT_CONTEXT, *PR_CRYPT_CONTEXT; 773 | 774 | // 775 | // Memory 776 | // 777 | 778 | typedef struct _R_MEMORY_OBJECT 779 | { 780 | ULONG64 total_bytes; 781 | ULONG64 free_bytes; 782 | ULONG64 used_bytes; 783 | ULONG percent; 784 | DOUBLE percent_f; 785 | } R_MEMORY_OBJECT, *PR_MEMORY_OBJECT; 786 | 787 | typedef struct _R_MEMORY_INFO 788 | { 789 | R_MEMORY_OBJECT physical_memory; 790 | R_MEMORY_OBJECT page_file; 791 | R_MEMORY_OBJECT system_cache; 792 | } R_MEMORY_INFO, *PR_MEMORY_INFO; 793 | 794 | // 795 | // System information 796 | // 797 | 798 | #define WINDOWS_ANCIENT 0x0000 799 | #define WINDOWS_7 0x0601 800 | #define WINDOWS_8 0x0602 801 | #define WINDOWS_8_1 0x0603 802 | #define WINDOWS_10_TH1 0x0A00 // build 10240 [TH1] 803 | #define WINDOWS_10_TH2 0x0A01 // build 10586 [TH2] 804 | #define WINDOWS_10_RS1 0x0A02 // build 14393 [RS1] 805 | #define WINDOWS_10_RS2 0x0A03 // build 15063 [RS2] 806 | #define WINDOWS_10_RS3 0x0A04 // build 16299 [RS3] 807 | #define WINDOWS_10_RS4 0x0A05 // build 17763 [RS4] 808 | #define WINDOWS_10_RS5 0x0A06 // build 17763 [RS5] 809 | #define WINDOWS_10_19H1 0x0A07 // build 18362 [19H1] 810 | #define WINDOWS_10_19H2 0x0A08 // build 18363 [19H2] 811 | #define WINDOWS_10_20H1 0x0A09 // build 19041 [20H1] 812 | #define WINDOWS_10_20H2 0x0A0A // build 19042 [20H2] 813 | #define WINDOWS_10_21H1 0x0A0B // build 19043 [21H1] 814 | #define WINDOWS_10_21H2 0x0A0C // build 19044 [21H2] 815 | #define WINDOWS_10_22H2 0x0A0D // build 19045 [22H2] 816 | #define WINDOWS_11_21H2 0x0B00 // build 22000 [21H2] 817 | #define WINDOWS_11_22H2 0x0B01 // build 22621 [22H2] 818 | #define WINDOWS_11_23H2 0x0B02 // build 22631 [23H2] 819 | #define WINDOWS_11_24H2 0x0B03 // build 26000 [24H2] 820 | #define WINDOWS_NEW ULONG_MAX 821 | 822 | #define WINDOWS_10 WINDOWS_10_TH1 823 | #define WINDOWS_11 WINDOWS_11_21H2 824 | 825 | typedef struct _R_THREAD_CONTEXT 826 | { 827 | PUSER_THREAD_START_ROUTINE base_address; 828 | PVOID arglist; 829 | } R_THREAD_CONTEXT, *PR_THREAD_CONTEXT; 830 | 831 | typedef struct _R_TOKEN_ATTRIBUTES 832 | { 833 | PSID token_sid; 834 | 835 | struct 836 | { 837 | ULONG is_elevated : 1; 838 | ULONG elevation_type : 2; 839 | ULONG spare_bits : 29; 840 | }; 841 | 842 | ULONG reserved; 843 | } R_TOKEN_ATTRIBUTES, *PR_TOKEN_ATTRIBUTES; 844 | 845 | // 846 | // File dialog 847 | // 848 | 849 | typedef struct _R_FILE_DIALOG 850 | { 851 | IFileDialog *ifd; // vista+ 852 | 853 | ULONG flags; 854 | } R_FILE_DIALOG, *PR_FILE_DIALOG; 855 | 856 | #define PR_FILEDIALOG_OPENDIR 0x0001 857 | #define PR_FILEDIALOG_OPENFILE 0x0002 858 | #define PR_FILEDIALOG_SAVEFILE 0x0004 859 | 860 | // 861 | // Window management 862 | // 863 | 864 | typedef struct _R_SIZE 865 | { 866 | LONG cx; 867 | LONG cy; 868 | } R_SIZE, *PR_SIZE; 869 | 870 | C_ASSERT (sizeof (R_SIZE) == sizeof (POINT)); 871 | 872 | C_ASSERT (FIELD_OFFSET (R_SIZE, cx) == FIELD_OFFSET (POINT, x)); 873 | C_ASSERT (FIELD_OFFSET (R_SIZE, cy) == FIELD_OFFSET (POINT, y)); 874 | 875 | typedef struct _R_RECTANGLE 876 | { 877 | union 878 | { 879 | R_SIZE position; 880 | 881 | struct 882 | { 883 | LONG left; 884 | LONG top; 885 | }; 886 | }; 887 | 888 | union 889 | { 890 | R_SIZE size; 891 | 892 | struct 893 | { 894 | LONG width; 895 | LONG height; 896 | }; 897 | }; 898 | } R_RECTANGLE, *PR_RECTANGLE; 899 | 900 | C_ASSERT (sizeof (R_RECTANGLE) == sizeof (RECT)); 901 | 902 | C_ASSERT (FIELD_OFFSET (R_RECTANGLE, left) == FIELD_OFFSET (RECT, left)); 903 | C_ASSERT (FIELD_OFFSET (R_RECTANGLE, top) == FIELD_OFFSET (RECT, top)); 904 | C_ASSERT (FIELD_OFFSET (R_RECTANGLE, width) == FIELD_OFFSET (RECT, right)); 905 | C_ASSERT (FIELD_OFFSET (R_RECTANGLE, height) == FIELD_OFFSET (RECT, bottom)); 906 | 907 | // 908 | // Window layout 909 | // 910 | 911 | typedef struct _R_LAYOUT_ITEM 912 | { 913 | HWND hwnd; 914 | HDWP defer_handle; 915 | struct _R_LAYOUT_ITEM *parent_item; 916 | R_RECTANGLE rect; 917 | R_RECTANGLE prev_rect; 918 | ULONG number_of_children; 919 | ULONG flags; 920 | } R_LAYOUT_ITEM, *PR_LAYOUT_ITEM; 921 | 922 | typedef struct _R_LAYOUT_MANAGER 923 | { 924 | R_LAYOUT_ITEM root_item; 925 | R_SIZE original_size; 926 | PR_LIST list; 927 | LONG dpi_value; 928 | } R_LAYOUT_MANAGER, *PR_LAYOUT_MANAGER; 929 | 930 | typedef struct _R_LAYOUT_ENUM 931 | { 932 | PR_LAYOUT_MANAGER layout_manager; 933 | PR_LAYOUT_ITEM layout_item; 934 | HWND root_hwnd; 935 | } R_LAYOUT_ENUM, *PR_LAYOUT_ENUM; 936 | 937 | #define PR_LAYOUT_ANCHOR_LEFT 0x0001 938 | #define PR_LAYOUT_ANCHOR_TOP 0x0002 939 | #define PR_LAYOUT_ANCHOR_RIGHT 0x0004 940 | #define PR_LAYOUT_ANCHOR_BOTTOM 0x0008 941 | 942 | #define PR_LAYOUT_DOCK_LEFT 0x0010 943 | #define PR_LAYOUT_DOCK_TOP 0x0020 944 | #define PR_LAYOUT_DOCK_RIGHT 0x0040 945 | #define PR_LAYOUT_DOCK_BOTTOM 0x0080 946 | 947 | #define PR_LAYOUT_ANCHOR_ALL 0x00FF 948 | 949 | // invalidate the control when it is resized 950 | #define PR_LAYOUT_FORCE_INVALIDATE 0x1000 951 | 952 | // send WM_SIZE message on resize 953 | #define PR_LAYOUT_SEND_NOTIFY 0x2000 954 | 955 | // do not calculate anchors for control 956 | #define PR_LAYOUT_NO_ANCHOR 0x4000 957 | 958 | // 959 | // Inernet access (WinHTTP) 960 | // 961 | 962 | typedef BOOLEAN (NTAPI *PR_INET_DOWNLOAD_CALLBACK) ( 963 | _In_ ULONG total_written, 964 | _In_ ULONG total_length, 965 | _In_opt_ PVOID lparam 966 | ); 967 | 968 | typedef struct _R_DOWNLOAD_INFO 969 | { 970 | union 971 | { 972 | HANDLE hfile; 973 | PR_STRING string; 974 | }; 975 | 976 | PR_INET_DOWNLOAD_CALLBACK download_callback; 977 | PVOID lparam; 978 | 979 | BOOLEAN is_savetofile; 980 | } R_DOWNLOAD_INFO, *PR_DOWNLOAD_INFO; 981 | 982 | typedef struct _R_URLPARTS 983 | { 984 | PR_STRING host; 985 | PR_STRING path; 986 | PR_STRING user; 987 | PR_STRING pass; 988 | 989 | INTERNET_SCHEME scheme; 990 | INTERNET_PORT port; 991 | } R_URLPARTS, *PR_URLPARTS; 992 | 993 | #define PR_URLPARTS_SCHEME 0x0001 994 | #define PR_URLPARTS_HOST 0x0002 995 | #define PR_URLPARTS_PORT 0x0004 996 | #define PR_URLPARTS_PATH 0x0008 997 | #define PR_URLPARTS_USER 0x0010 998 | #define PR_URLPARTS_PASS 0x0020 999 | 1000 | // 1001 | // Resources 1002 | // 1003 | 1004 | #define PR_LANG_TO_LCID(lang_id,codepage_id) (((lang_id) << 16) + (codepage_id)) 1005 | 1006 | typedef struct _R_VERSION_TRANSLATION 1007 | { 1008 | WORD lang_id; 1009 | WORD code_page; 1010 | } R_VERSION_TRANSLATION, *PR_VERSION_TRANSLATION; 1011 | 1012 | // 1013 | // Xml library 1014 | // 1015 | 1016 | typedef IStream *PR_XML_STREAM; 1017 | 1018 | typedef struct _R_XML_LIBRARY 1019 | { 1020 | union 1021 | { 1022 | IXmlReader *reader; 1023 | IXmlWriter *writer; 1024 | }; 1025 | 1026 | PR_XML_STREAM hstream; 1027 | 1028 | BOOLEAN is_reader; 1029 | } R_XML_LIBRARY, *PR_XML_LIBRARY; 1030 | 1031 | // 1032 | // Application structures 1033 | // 1034 | 1035 | typedef struct _R_SETTINGS_PAGE 1036 | { 1037 | HWND hwnd; 1038 | ULONG locale_id; 1039 | LONG dlg_id; 1040 | } R_SETTINGS_PAGE, *PR_SETTINGS_PAGE; 1041 | 1042 | #define PR_UPDATE_FLAG_AVAILABLE 0x0001 1043 | #define PR_UPDATE_FLAG_INSTALLER 0x0002 1044 | #define PR_UPDATE_FLAG_FILE 0x0004 1045 | 1046 | typedef struct _R_UPDATE_COMPONENT 1047 | { 1048 | PR_STRING full_name; 1049 | PR_STRING short_name; 1050 | PR_STRING current_version; 1051 | PR_STRING new_version; 1052 | PR_STRING cache_path; 1053 | PR_STRING target_path; 1054 | PR_STRING url; 1055 | ULONG flags; 1056 | } R_UPDATE_COMPONENT, *PR_UPDATE_COMPONENT; 1057 | 1058 | typedef struct _R_UPDATE_INFO 1059 | { 1060 | PR_ARRAY components; 1061 | HWND htaskdlg; 1062 | HWND hparent; 1063 | HANDLE hthread; 1064 | HANDLE htaskbar; 1065 | HINTERNET hsession; 1066 | ULONG flags; 1067 | volatile LONG lock; 1068 | BOOLEAN is_clicked; 1069 | } R_UPDATE_INFO, *PR_UPDATE_INFO; 1070 | 1071 | typedef struct _R_SHARED_IMAGE 1072 | { 1073 | PVOID hinst; 1074 | HICON hicon; 1075 | LONG icon_id; 1076 | LONG icon_size; 1077 | } R_SHARED_IMAGE, *PR_SHARED_IMAGE; 1078 | 1079 | typedef struct _APP_GLOBAL_CONFIG 1080 | { 1081 | struct 1082 | { 1083 | WNDPROC wnd_proc; 1084 | HANDLE hmutex; 1085 | HWND hwnd; 1086 | 1087 | ULONG taskbar_msg; 1088 | 1089 | BOOLEAN is_needmaximize; 1090 | } main; 1091 | 1092 | struct 1093 | { 1094 | R_QUEUED_LOCK lock; 1095 | PR_HASHTABLE table; 1096 | PR_LIST available_list; 1097 | 1098 | PR_STRING resource_name; 1099 | PR_STRING default_name; 1100 | PR_STRING current_name; 1101 | } locale; 1102 | 1103 | struct 1104 | { 1105 | R_QUEUED_LOCK lock; 1106 | PR_HASHTABLE table; 1107 | } config; 1108 | 1109 | struct 1110 | { 1111 | DLGPROC wnd_proc; 1112 | PR_ARRAY page_list; 1113 | HWND hwnd; 1114 | } settings; 1115 | 1116 | struct 1117 | { 1118 | R_UPDATE_INFO info; 1119 | } update; 1120 | 1121 | struct 1122 | { 1123 | HBRUSH bg_brush; 1124 | } theme; 1125 | 1126 | struct 1127 | { 1128 | LONG64 last_timestamp; 1129 | } error; 1130 | } APP_GLOBAL_CONFIG, *PAPP_GLOBAL_CONFIG; 1131 | --------------------------------------------------------------------------------