[
  {
    "path": ".gitattributes",
    "content": "*.c diff\r\n*.cpp diff\r\n*.h diff\r\n*.rc diff\r\n*.ini diff\r\n*.txt diff\r\n*.xml diff\r\n*.lng diff\r\n"
  },
  {
    "path": ".github/FUNDING.yml",
    "content": "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\"]\r\n"
  },
  {
    "path": ".github/ISSUE_TEMPLATE/bug_report.yml",
    "content": "name: Bug report\ntitle: \"[Bug]\"\ndescription: Let me know about crash or existing functionality not working like it should.\nlabels: [ \"bug\" ]\nbody:\n  - type: markdown\n    attributes:\n      value: Thanks for taking the time to fill out this bug report!\n  - type: checkboxes\n    id: checklist\n    attributes:\n      label: Checklist\n      options:\n        - label: I have used the search function to see if someone else has already submitted the same bug report.\n          required: true\n        - label: I will describe the problem with as much detail as possible.\n          required: true\n  - type: input\n    id: version\n    attributes:\n      label: App version\n      description: What the application version do you use.\n      placeholder: x.y.z\n    validations:\n      required: true\n  - type: input\n    id: windows_version\n    attributes:\n      label: Windows version\n      description: What Windows version do you use.\n    validations:\n      required: true\n  - type: textarea\n    id: steps\n    attributes:\n      label: Steps to reproduce\n      placeholder: |\n        1. Go to '…'\n        2. Click on '…'\n        3. Scroll down to '…'\n        4. etc.\n    validations:\n      required: true\n  - type: textarea\n    id: expected\n    attributes:\n      label: Expected behavior\n      description: After following the steps, what did you think application would do?\n    validations:\n      required: false\n  - type: textarea\n    id: actual\n    attributes:\n      label: Actual behavior\n      description: What did application do instead? Screenshots might help.\n    validations:\n      required: true\n  - type: textarea\n    id: logs\n    attributes:\n      label: Logs\n      description: |\n        - If application have debug log insert it here.\n        - If application have crash dump please attach it here.\n\n        Tip: You can attach images, log files or crash dumps by clicking this area to highlight it and then dragging files in.\n"
  },
  {
    "path": ".github/ISSUE_TEMPLATE/config.yml",
    "content": "blank_issues_enabled: false\n"
  },
  {
    "path": ".github/ISSUE_TEMPLATE/feature_request.yml",
    "content": "name: Feature request\ntitle: \"[Feature]\"\ndescription: Suggest an idea for this project.\nlabels: [ \"feature\" ]\nbody:\n  - type: checkboxes\n    id: checklist\n    attributes:\n      label: Checklist\n      options:\n        - label: I have used the search function to see if someone else has already submitted the same feature request.\n          required: true\n        - label: I will describe the problem with as much detail as possible.\n          required: true\n        - label: This issue only contains a request for one single feature, **not** multiple (related) features.\n          required: true\n  - type: input\n    id: version\n    attributes:\n      label: App version\n      description: What the application version do you use.\n      placeholder: x.y.z\n    validations:\n      required: true\n  - type: textarea\n    id: problem\n    attributes:\n      label: Problem you are trying to solve\n      description: Give a brief explanation of the problem you are trying to solve.\n    validations:\n      required: true\n  - type: textarea\n    id: solution\n    attributes:\n      label: Suggested solution\n      description: Describe how you would like the app to help you solve that problem. Try to be as specific as possible.\n    validations:\n      required: true\n  - type: textarea\n    id: screenshots\n    attributes:\n      label: Screenshots / Drawings / Technical details\n      description: |\n        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.\n\n        Tip: You can attach images or log files by clicking this area to highlight it and then dragging files in.\n"
  },
  {
    "path": ".github/ISSUE_TEMPLATE/question.md",
    "content": "---\nname: Question\nabout: Ask a question about application.\ntitle: '[Question]'\nlabels: [ \"question\" ]\nassignees: ''\n\n---\n\nDescribe the question with as much detail as possible.\n\n---\n\nApp version: <enter app version here>\nWindows version: <enter windows version here>"
  },
  {
    "path": ".github/workflows/scorecard.yml",
    "content": "# This workflow uses actions that are not certified by GitHub. They are provided\n# by a third-party and are governed by separate terms of service, privacy\n# policy, and support documentation.\n\nname: Scorecard supply-chain security\non:\n  # For Branch-Protection check. Only the default branch is supported. See\n  # https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection\n  branch_protection_rule:\n  # To guarantee Maintained check is occasionally updated. See\n  # https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained\n  schedule:\n    - cron: '32 18 * * 3'\n  push:\n    branches: [ \"master\" ]\n\n# Declare default permissions as read only.\npermissions: read-all\n\njobs:\n  analysis:\n    name: Scorecard analysis\n    runs-on: ubuntu-latest\n    # `publish_results: true` only works when run from the default branch. conditional can be removed if disabled.\n    if: github.event.repository.default_branch == github.ref_name || github.event_name == 'pull_request'\n    permissions:\n      # Needed to upload the results to code-scanning dashboard.\n      security-events: write\n      # Needed to publish results and get a badge (see publish_results below).\n      id-token: write\n      # Uncomment the permissions below if installing in a private repository.\n      # contents: read\n      # actions: read\n\n    steps:\n      - name: \"Checkout code\"\n        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2\n        with:\n          persist-credentials: false\n\n      - name: \"Run analysis\"\n        uses: ossf/scorecard-action@f49aabe0b5af0936a0987cfb85d86b75731b0186 # v2.4.1\n        with:\n          results_file: results.sarif\n          results_format: sarif\n          # (Optional) \"write\" PAT token. Uncomment the `repo_token` line below if:\n          # - you want to enable the Branch-Protection check on a *public* repository, or\n          # - you are installing Scorecard on a *private* repository\n          # To create the PAT, follow the steps in https://github.com/ossf/scorecard-action?tab=readme-ov-file#authentication-with-fine-grained-pat-optional.\n          # repo_token: ${{ secrets.SCORECARD_TOKEN }}\n\n          # Public repositories:\n          #   - Publish results to OpenSSF REST API for easy access by consumers\n          #   - Allows the repository to include the Scorecard badge.\n          #   - See https://github.com/ossf/scorecard-action#publishing-results.\n          # For private repositories:\n          #   - `publish_results` will always be set to `false`, regardless\n          #     of the value entered here.\n          publish_results: true\n\n          # (Optional) Uncomment file_mode if you have a .gitattributes with files marked export-ignore\n          file_mode: git\n\n      # Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF\n      # format to the repository Actions tab.\n      - name: \"Upload artifact\"\n        uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1\n        with:\n          name: SARIF file\n          path: results.sarif\n          retention-days: 5\n\n      # Upload the results to GitHub's code scanning dashboard (optional).\n      # Commenting out will disable upload of results to your repo's Code Scanning dashboard\n      - name: \"Upload to code-scanning\"\n        uses: github/codeql-action/upload-sarif@v3\n        with:\n          sarif_file: results.sarif\n"
  },
  {
    "path": ".gitignore",
    "content": ".vs/\r\n.vscode/\r\ntemp/\r\npackages/\r\nbin/32/\r\nbin/64/\r\nbin/arm64/\r\nx64/\r\nwin32/\r\narm64/\r\n__pycache__\r\n\r\nthumbs.db\r\nehthumbs.db\r\ndesktop.ini\r\n\r\n*.cab\r\n*.msi\r\n*.msm\r\n*.msp\r\n*.lnk\r\n*.jpg\r\n*.zip\r\n*.log\r\n*.pdb\r\n*.exp\r\n*.sdf\r\n*.opensdf\r\n*.db\r\n*.opendb\r\n*.suo\r\n*.exp\r\n*.iobj\r\n*.ipch\r\n*.ipdb\r\n*.ilk\r\n*.obj\r\n*.res\r\n*.tlog\r\n\r\n*PVS-Studio*\r\n"
  },
  {
    "path": ".gitmodules",
    "content": "[submodule \"routine\"]\r\n\tpath = ../routine\r\n\turl = https://github.com/henrypp/routine.git\r\n\r\n[submodule \"builder\"]\r\n\tpath = ../builder\r\n\turl = https://github.com/henrypp/builder.git\r\n"
  },
  {
    "path": "CHANGELOG.md",
    "content": "v3.8.7 (8 August 2025)\r\n- fixed not logical crash (issue #2012)\r\n- fixed context menu performance\r\n- updated locale (issue #1984)\r\n- updated project sdk\r\n- cosmetic fixes\r\n\r\nv3.8.6.1 (21 May 2025)\r\n- fixed \"open containing folder\" error (issue #1977)\r\n- fixed crash at startup (issue #1979)\r\n- fixed crash dump (issue #1958)\r\n\r\nv3.8.6 (1 April 2025)\r\n- fixed check for update, does not bring up popup (issue #1923)\r\n- fixed memory heap error (issue #1945)\r\n- fixed possible crash\r\n- improved dark theme support\r\n\r\nv3.8.5 (27 November 2024)\r\n- fixed adding apps with drive letters instead of specific apps (issue #1887)\r\n- fixed creating rules for inaccessible paths (issue #1891)\r\n- fixed opening log with spaces path (issue #1912)\r\n- fixed windows 7 loopback rules\r\n- cosmetic fixes\r\n\r\nv3.8.4 (11 September 2024)\r\n- added listview empty markup\r\n- fixed tray icon middle click not worked when log ui is disabled\r\n- fixed notification displays invalid signature (issue #1871)\r\n- fixed does not show up tray icon (issue #1844)\r\n- fixed crash when cleanup timers (issue #1860)\r\n- fixed possible memory leak\r\n- updated project sdk\r\n- updated rule hint\r\n- cosmetic fixes\r\n\r\nv3.8.3 (8 August 2024)\r\n- added remember last position of notification window (issue #1659)\r\n- added watch services & uwp apps for install/uninstall\r\n- added displays long time for apps\r\n- improved windows 7 compatibility\r\n- improved arm64 compatibility\r\n- improved dark theme support\r\n- fixed show log button does not work as expected (issue #1757, again!)\r\n- fixed apps sometimes delete themselves (issue #1794, not fixed)\r\n- fixed duplicate process at startup (issue #1769)\r\n- fixed do not save hash when it is not enabled\r\n- fixed row colors for dark mode (issue #1767)\r\n- fixed log listview sorting by date\r\n- fixed displaying timer tooltip\r\n- updated project sdk\r\n\r\nv3.8.2 (9 May 2024)\r\n- revert back windows 7 & windows 8 support\r\n- improved dark theme support\r\n- improved log subscription\r\n- fixed show log button does not work as expected (issue #1757)\r\n- fixed search visibility\r\n\r\nv3.8.1 (27 April 2024)\r\n- fixed lacks search context (issue #1760)\r\n- fixed incorrect log ui listview item counting\r\n- updated confirm message for timers cleanup\r\n- updated confirm message for unused cleanup\r\n- updated cppwinrt package\r\n- updated project sdk\r\n\r\nv3.8 (1 April 2024)\r\n- added mitigations (win10+) (issue #611)\r\n- added dark theme support (issue #248)\r\n- fixed displaying same context menu on apps and packets log\r\n- updated search engine\r\n- updated project sdk\r\n\r\nv3.7.8 (28 January 2024)\r\n- added saving flag state for install/uninstall filters\r\n- fixed crash on tooltip (issue #1686)\r\n- fixed apps disabled removal menu\r\n- updated dropped packets (ui) listview context menu\r\n- updated project sdk\r\n\r\nv3.7.7 (3 January 2024)\r\n- added error message when loading library on subscribe\r\n- added comment item for apps/rules (issue #1664)\r\n- added recheck app hash in properies dialog\r\n- added highlighting of undelatable apps\r\n- fixed displaying incorrect error messages\r\n- fixed high disk usage (issue #1665)\r\n- updated ports list\r\n\r\nv3.7.6 (30 November 2023)\r\n- fixed configuration of windows update (issue #1648)\r\n- fixed auto update fails to install (issue #1565)\r\n- updated project sdk\r\n\r\nv3.7.5 (1 November 2023)\r\n- fixed saving services and uwp apps (issue #1616)\r\n- fixed file locked by simplewall (issue #1621)\r\n- fixed removing unused apps\r\n- fixed process creation\r\n- updated project sdk\r\n\r\nv3.7.4 (27 October 2023)\r\n- added set option to disable apps removal from profile (issue #1155)\r\n- fixed cannot save itself as unchecked (issue #1609)\r\n- fixed could not save profile (issue #1594)\r\n- fixed crash (issue #1582)\r\n- updated project sdk\r\n\r\nv3.7.3 (11 October 2023)\r\n- added error message for saving profile\r\n- removed redistributable package requirement (issue #1587)\r\n- fixed profile was not found message (issue #1557)\r\n- fixed crash on reading version information\r\n- revert back certificates checking option\r\n- updated project sdk\r\n\r\nv3.7.2 (21 September 2023)\r\n- dropped windows 7 and windows 8 support\r\n- fixed launch of several copies of the application (issue #1547)\r\n- fixed create filters for inaccessible apps (issue #1528)\r\n- fixed displaying update dialog at startup (issue #1511)\r\n- fixed retrieving version information for some files\r\n- fixed slow apps search (issue #1477)\r\n- fixed periodicaly crashing (issue #1486)\r\n- fixed retrieving some apps icons\r\n- fixed saving input on settings\r\n- fixed saving unused apps\r\n- fixed process creation\r\n- improved signature checking\r\n- updated project sdk\r\n\r\nv3.7.1 (31 July 2023)\r\n- fixed import not correcly worked (issue #1466)\r\n- fixed crash when checking files (issue #1455)\r\n- updated project sdk\r\n\r\nv3.7 (27 July 2023)\r\n- added profile encryption [oldest versions cannot open new profile] (issue #599)\r\n- added terminate process into notification window (issue #1398)\r\n- added checksum calculation for the apps (issue #394)\r\n- added error message for log subscription\r\n- improved search performance (issue #1383)\r\n- fixed timer and apps timestamp displays incorrect information (32-bit only)\r\n- fixed sometimes application displays incrorrect icons\r\n- fixed possible crash when clearing log\r\n- fixed silent uninstaller do not worked\r\n- fixed arm64 build crash (issue #1228)\r\n- fixed internal bugs\r\n- fixed memory leaks\r\n- updated nuget package\r\n- updated project sdk\r\n- updated locale\r\n\r\nv3.6.7 (21 September 2022)\r\n- added windows update service solution (issue #677, thx @taviso) [win10+]\r\n- added feature to allow only the requested ip in notification (issue #1265)\r\n- added 12 and 24 hour timer values (issue #1298)\r\n- fixed opening editor are overlapped by notification window\r\n- fixed uwp apps are reset after installing updates (issue #1294)\r\n- fixed select all with search filter selects everything (issue #1264)\r\n- fixed loading default icons for services and uwp apps\r\n- fixed check update option in main menu (issue #1309)\r\n- fixed port numbers are now verified (issue #1240)\r\n\r\nv3.6.6 (12 August 2022)\r\n- fixed editor does not disable save button when rule name is empty\r\n- fixed network monitor duplicate calls\r\n- fixed application crash (issue #1272)\r\n\r\nv3.6.5 (11 August 2022)\r\n- added group for apps with timers\r\n- display long time in packets log date column\r\n- fixed uwp packages display name parsing\r\n- fixed blank notifications (again!) (issue #1009)\r\n\r\nv3.6.4 (19 Juny 2022)\r\n- added focus assistant support (win10rs3+)\r\n- fixed notification sometimes can lose focus of fullscreen app\r\n- fixed internal profile loading crash (issue #1228)\r\n\r\nv3.6.3 (10 May 2022)\r\n- fixed installer launches simplewall without asking user (issue #1119)\r\n- fixed saving unused apps in profile (issue #1216)\r\n- fixed app crash on create process (issue ##1224)\r\n- fixed uninstaller delete not all files\r\n- improved workqueue environment\r\n- improved threading model\r\n- fixed internal bugs\r\n\r\nv3.6.2 (26 April 2022)\r\n- added autoinstall non-executable updates feature (issue #1122)\r\n- added clear search with escape button for editor\r\n- added fallback for font loading when it does not exists\r\n- improved uwp packages information loading\r\n- fixed restore properties window position\r\n- fixed rule tooltip whitespace\r\n- fixed internal bugs\r\n- updated network monitor\r\n- updated locales\r\n- cosmetic fixes\r\n\r\nv3.6.1 (11 November 2021)\r\n- added clear search with escape button\r\n- fixed crash on delete filters (issue #1084)\r\n- fixed import profile warning (issue #1086)\r\n- fixed crash dumps processing\r\n- updated locales\r\n- cosmetic fixes\r\n\r\nv3.6 (9 November 2021)\r\n- improved multi-threading safety\r\n- improved startup time\r\n- improved dpi support\r\n- added option to confirm allowing applications (issue #1070)\r\n- added filtering for the application list (issue #663)\r\n- added editor list items count mark for tab title\r\n- added wfp initialization failure workaround\r\n- added filtering for editor apps and rules\r\n- added layer name into log\r\n- moved log exclude configuration into another settings page (issue #1064)\r\n- revert notification x button (issue #973)\r\n- changed create rule toolbar icon (#723)\r\n- fixed filters with hard permit can access internet (issue #689)\r\n- fixed issue with hotkeys for switch tabs (issue #723)\r\n- fixed rebar incrorrect resizing when dpi was changed\r\n- fixed update installation issue (issue #1061)\r\n- fixed notification multi-monitor support\r\n- fixed service missing path (issue #1036)\r\n- fixed editor can cause crash (#1071)\r\n- fixed big memory leak (issue #1066)\r\n- fixed net events unsubscription\r\n- optimized listview sorting\r\n- fixed internal bugs\r\n- cosmetic fixes\r\n\r\nv3.5.3 (18 October 2021)\r\n- fixed using uninitialzed port variable in ip ranges [regression] (issue #1055)\r\n\r\nv3.5.2 (17 October 2021)\r\n- builded with windows 11 sdk\r\n- fixed port can be omited when parsing ip ranges (issue #1010)\r\n- fixed remote range replaces local range (issue #1044)\r\n- fixed interface stuck by comctl library (issue #1009)\r\n- fixed massive gdi handles leak\r\n- fixed internal bugs\r\n\r\nv3.5.1 (6 October 2021)\r\n- optimized certificate checking\r\n- fixed check apps for digital signatures option not works (issue #1037)\r\n- fixed lock to avoid duplicate file information loading\r\n- fixed crash on profile loading (issue #1033)\r\n\r\nv3.5 (4 October 2021)\r\n- in this release fqdn support was removed because of security issue (issues #1012)\r\n- improved performance due caching network resolution and file information\r\n- partially revert of windows defender power off (issue #1022)\r\n- added ballon tip to display input limitations (issue #809)\r\n- added compress internal profile in resources with lznt1\r\n- fixed signatures information pointer use-after-free when dns resolver avoid arpa requests (issue #1008)\r\n- fixed resolve network addresses can cause crash (issue #1015)\r\n- fixed notification color issues (issue #1007)\r\n- fixed update installation (issue #1016)\r\n- fixed version information retrieval\r\n- fixed workqueue environment\r\n- fixed internal bugs\r\n\r\nv3.4.3 (30 August 2021)\r\n- added verify code signatures from catalog files (issue #1003)\r\n- fixed crash at startup (issue #995)\r\n- fixed rule reference (issue #1002)\r\n\r\nv3.4.2 (24 August 2021)\r\n- enable checking apps certificates by default\r\n- show notifications immediately without waiting for busy operations to complete\r\n- impoved listview responsiveness by using virtual listview callback\r\n- fixed packets log displays incorrect direction (issue #945)\r\n- fixed missed listview icons on refresh\r\n- fixed thread environment\r\n- fixed internal bugs\r\n- cosmetic fixes\r\n\r\nv3.4.1 (15 August 2021)\r\n- fixed blocklist can does not change action status\r\n- fixed crash at startup (issue #976)\r\n- fixed profile import compatibility\r\n- fixed install update\r\n\r\nv3.4 (11 August 2021)\r\n- added arm64 binaries (portable only)\r\n- added protocol and host name information into network alert window (issue #843)\r\n- added limit number of packets log entries (issue #941)\r\n- added host resolving for packet logger listview\r\n- added listview group for forever blocked apps\r\n- fixed loading icons of each application freezes interface (issue #830)\r\n- fixed log listview can have empty lines due to race condition\r\n- fixed ui not properly display installation status (issue #962)\r\n- fixed memory leak when loading profile (issue #888, #937)\r\n- fixed high cpu usage for packet logger (issue #949)\r\n- updated system rules\r\n- updated project sdk\r\n- fixed internal bugs\r\n\r\nv3.3.5 (5 July 2021)\r\n- added command line short opts\r\n- use guid for tray icon\r\n- updated project sdk\r\n- fixed toolbar glitch on hidpi displays (issue #950)\r\n- fixed multi-monitor with diffirent dpi support\r\n- fixed installer creates unused files\r\n- fixed internal bugs\r\n\r\nv3.3.4 (3 June 2021)\r\n- autoclean packets log ui when system suspended\r\n- fixed config may not be saved when profile directory does not exist\r\n- fixed unnecessary checking for app paths attributes\r\n- fixed threadpool does not initialized com library\r\n- fixed installer silent mode (issue #907)\r\n- updated blocklist and system rules\r\n- fixed internal bugs\r\n\r\nv3.3.3 (29 April 2021)\r\n- fixed listview tooltip can cause crash (issue #890)\r\n- fixed editor does not create filters for the app\r\n- fixed incorrect shared icons behaviour\r\n- fixed interlocked operations logic\r\n- fixed caching behaviour\r\n- fixed internal bugs\r\n\r\nv3.3.2 Beta (23 April 2021)\r\n- added half an hour timer\r\n- added missing spinlocks\r\n- fixed file write operation can cause crash\r\n- fixed path unexpand does not worked\r\n- fixed running log viewer\r\n- fixed little memory leak\r\n- fixed bugs\r\n\r\nv3.3.1 Beta (16 April 2021)\r\n- added workaround for native paths on profile loading (issue #817)\r\n- fixed net events does not subscribe on os version lower than 1607\r\n\r\nv3.3 Beta (15 April 2021)\r\n- added option for tray icon to open window in single click\r\n- added warning message for allowing service host\r\n- added quic service for internal rules (issue #819)\r\n- added multiple rules at once in rules editor\r\n- added properties dialog for apps\r\n- added index column for logs\r\n- added sorting for logs\r\n- do not mark apps as unused if it applied for rules\r\n- set limit for rules popup menu (issue #692)\r\n- increased speed of service enumeration\r\n- removed notification ignore button\r\n- use threadpool for timers\r\n- improved multi-monitor support\r\n- improved listviews highlighting\r\n- improved file dialogs\r\n- fixed rule window does not display rule length limitation (issue #867)\r\n- fixed update period timestamp does not set correctly (issue #745)\r\n- fixed crash when user uses ipv6 range in rules (issue #822)\r\n- fixed support filesystems with custom driver (issue #817)\r\n- fixed blank notification window (issue #775)\r\n- fixed dependencies load flags for win10rs1+\r\n- fixed crash on app startup (issue #775)\r\n- updated project sdk\r\n- cosmetic fixes\r\n- fixed bugs\r\n\r\nv3.2.4 (5 September 2020)\r\n- removed assertion from release builds (issue #764)\r\n- removed user service instance from the list (win10+)\r\n- fixed parsing not existing apps (issue #732, #739)\r\n- displays incorrect name on timer expiration\r\n- check app timer expiration on profile load\r\n- incorrect read-only rules tooltip markup\r\n- create filter does not report errors\r\n- fixed checking of file attributes\r\n- fixed parsing ip/port ranges\r\n- cosmetic fixes\r\n- fixed bugs\r\n\r\nv3.2.3 (25 August 2020)\r\n- added ncsi system rule (issue #709)\r\n- added command line mutex checking (issue #750)\r\n- added noficitation window redraw (issue #731)\r\n- use logical sorting order (issue #735)\r\n- check for provider status before create filters\r\n- do not highlight connections in log tab\r\n- fixed support oldest win7 versions (issue #737)\r\n- removed listview empty markup\r\n- cosmetic fixes\r\n- fixed bugs\r\n\r\nv3.2.2 (29 July 2020)\r\n- user rules broken with 3.2.1 (issue #729)\r\n\r\nv3.2.1 (29 July 2020)\r\n- added Enable silent-mode when full screen app in foreground option\r\n- added error message for createprocess failure (issue #720)\r\n- highlighting valid connections in network tab\r\n- changed \"Disabled apps\" group title into \"Apps without internet access\"\r\n- skip uac warning does not worked (issue #724)\r\n- notification window localized in english only\r\n- revert ip version selection ipv4/ipv6 in rules editor (issue #723)\r\n- revert expand rules in tooltip (issue #723)\r\n- revert \"recommended\" tag (fix #719)\r\n- fixed bugs\r\n\r\nv3.2 Beta (18 July 2020)\r\n- new rules editor\r\n- added option \"IsInternalRulesDisabled\" for completely disable internal rules (issue #630)\r\n- added temporary filtering mode whether is active until reboot (issue #576)\r\n- added packets logging interface (issue #672)\r\n- added tile view for listview\r\n- added information for export profile failure (issue #707)\r\n- improved tooltips details for apps and rules\r\n- improved listview resizing performance\r\n- changed \"Enabled apps\" group title into \"Apps with internet access\"\r\n- now highlight app with user rules only when user rules group is disabled\r\n- removed compatibility with v2 profile databases\r\n- removed special group for rules\r\n- removed user id from title\r\n- fixed local network connection treats as valid network connection (issue #579)\r\n- fixed notification window will bring focus to it's parent window (issue #668)\r\n- fixed \"/uninstall\" argument does not removing filters (issue #645)\r\n- fixed wfp engine security violation (issue #680)\r\n- fixed support custom windows themes (issue #701)\r\n- fixed getting uwp app paths and timestamps\r\n- fixed dpi support (issue #693)\r\n- fixed internal upnp rule\r\n- fixed bugs\r\n\r\nv3.1.2 (26 March 2020)\r\n- reverted disable windows firewall on startup (issue #559 and #562)\r\n- fixed application cannot be started because of continuously restart\r\n- fixed possible duplicate apps entries with short path (issue #640)\r\n- fixed network alert steals the focus (issue #637)\r\n- fixed network paths parsing (issue #629)\r\n- fixed netbios direction (issue #636)\r\n- fixed localization (issue #607)\r\n- fixed bugs\r\n\r\nv3.1.1 (27 February 2020)\r\n- fixed displaying tooltips for non-existing apps in network tab (issue #422)\r\n- fixed wsl apps do not display names in the network tab (issue #606)\r\n- fixed incorrect default locale name on some systems (issue #621)\r\n- fixed process mitigation policy (win10rs2+) (issue #611)\r\n- fixed persistent dark theme (win10rs5+) (issue #609)\r\n- fixed update window does not close (issue #616)\r\n- fixed log cleanup (issue #613)\r\n- updated blocklist\r\n- fixed bugs\r\n\r\nv3.1 (8 February 2020)\r\n- changed compiler build settings\r\n- changed settings interface\r\n- improved windows 10 1903+ suppport\r\n- show log cleanup confirmation only when it has entries\r\n- fixed notification tabstop processing (issue #497) by @flipkick\r\n- fixed downloading updates progress gets stuck (issue #568)\r\n- fixed find dialog does not worked correctly (issue #511)\r\n- fixed drawing filename in notification (issue #595)\r\n- fixed adjust privileges (theoretically fixes #596)\r\n- fixed inbound direction recognition (issue #581)\r\n- fixed search for next/active notification\r\n- fixed notification hotkeys (issue #597)\r\n- fixed memory duplicate allocation\r\n- updated project sdk (routine++)\r\n- updated ports definitions\r\n- updated blocklist\r\n- fixed bugs\r\n\r\nv3.0.9 (15 November 2019)\r\n- do not set notification to top when fullscreen apps working\r\n- fixed disable notifications for app from notification (issue #563)\r\n- fixed crash on system settings changing (issue #552)\r\n- fixed winhttp encoding conversion (issue #568)\r\n- fixed statusbar glitch (issue #569)\r\n- updated blocklist\r\n- fixed bugs\r\n\r\nv3.0.8 (8 November 2019)\r\n- removed disable windows firewall on startup (issue #554)\r\n- updated default timer values (issue #340)\r\n- fixed non-default system dpi (issue #544)\r\n- fixed overwrite notifications\r\n- fixed crash (issue #552)\r\n- cosmetics fixes\r\n- fixed bugs\r\n\r\nv3.0.7 (1 November 2019)\r\n- improved dpi support (win81+)\r\n- fixed ended timer handling on restart\r\n- fixed regular update message (issue #543)\r\n- fixed components update installation\r\n- fixed window and listview sizing\r\n- updated project sdk\r\n- updated blocklist\r\n- cosmetics fixes\r\n- fixed bugs\r\n\r\nv3.0.6 RC (12 October 2019)\r\n- added windows 10 1903+ support\r\n- added csv file title (clear the log to see changes)\r\n- disable network address resolution in network tab by default (issue #515)\r\n- improved refreshing filters on device connecting\r\n- improved network monitoring speed and ui\r\n- improved notification ui\r\n- improved dpi support (win81+)\r\n- fixed collecting services & uwp information\r\n- fixed device names resolution (issue #529)\r\n- fixed toolbar gray text draw (issue #437)\r\n- fixed network items blinking on refresh\r\n- fixed flickering on window resizing\r\n- fixed notification windows refresh\r\n- fixed hostname restricted symbols\r\n- fixed wfp security attributes\r\n- fixed highlighting priority\r\n- fixed memory leak\r\n- updated system rules\r\n- cosmetics fixes\r\n- fixed bugs\r\n\r\nv3.0.5 RC (6 August 2019)\r\n- added option to block outbound connections globally\r\n- added close connection feature (issue #506)\r\n- added powerful blocklist configuration\r\n- removed listen layer\r\n- skip saving default rules configuration\r\n- fixed connections port byte order (issue #504)\r\n- fixed user rules ui bug (issue #500)\r\n- fixed dropped packets log layout\r\n- fixed internal rules editor\r\n- fixed ipv6 rule formatting (issue #475)\r\n- fixed connections hashing\r\n- listview menu cosmetics\r\n- cosmetics fixes\r\n- fixed bugs\r\n\r\nv3.0.4 RC (23 July 2019)\r\n- added rules and blocklist options into main menu\r\n- set security settings enabled by default\r\n- set protocol names based on IEEE\r\n- made correct backups for profile on reset\r\n- bring notification window to top\r\n- correct determine connections for apps\r\n- fixed error message on new device insertion (issue #215)\r\n- fixed missing connections (issue #423)\r\n- fixed listview sorting does not save state sometimes\r\n- fixed listview sorting compare checked items\r\n- fixed uninstaller does not remove new profile\r\n- fixed tray menu notifications cosmetics\r\n- optimized group items counting\r\n- optimized listview sorting\r\n- cosmetics fixes\r\n- fixed bugs\r\n\r\nv3.0.3 Beta (3 July 2019)\r\n- added option to show notification window on tray\r\n- added highlighting for network tab\r\n- redraw app item on connection change\r\n- remove \"beta\" mark from network tab\r\n- improved wfp transactions\r\n- fixed ipv6 rules port parsing for system rules (issue #475)\r\n- fixed direction case for log and notification (issue #474)\r\n- fixed notification action adds timer (issue #472)\r\n- fixed timer set does not work (issue #484)\r\n- fixed notification refresh when app remove\r\n- fixed configuration reset does not work\r\n- fixed menu graphics (issue #473)\r\n- fixed log stack cleanup\r\n- updated port service names\r\n- cosmetics fixes\r\n- fixed bugs\r\n\r\nv3.0.2 Beta (22 Juny 2019)\r\n- new notification ui\r\n- allow microsoft update & microsoft apps servers by default\r\n- added information about ports into the log\r\n- moved icmp4 and icmp6 rules into custom rules\r\n- improved dropped packets log markup cosmetics\r\n- improved network monitoring speed\r\n- improved blocklist configuration\r\n- fixed saving special rules for uwp apps and services (issue #454)\r\n- fixed tray icon dissapear sometimes (issue #450)\r\n- fixed profile import does not work (issue #445)\r\n- fixed semicolons in app paths (issue #462)\r\n- fixed windows 20h1 uwp apps loading crash\r\n- fixed parsing rules with \"*\"\r\n- updated locales\r\n- cosmetic fixes\r\n- fixed bugs\r\n\r\nv3.0.1 Beta (22 May 2019)\r\n- new profile structure\r\n- added checking for correct xml file format before import\r\n- added service name resolution for connections\r\n- added Reverse DNS Lookup for IP\r\n- more flexible autoresizing for listview\r\n- fixed column size initialization (issue #426)\r\n- fixed apps list sorting by date (issue #412)\r\n- fixed status refreshing on timer deletion\r\n- fixed table view for rules (issue #438)\r\n- fixed connections recognition condition\r\n- fixed highlighting (issue #408)\r\n- fixed timers sets (issue #424)\r\n- fixed services icons\r\n- updated locales\r\n- cosmetic fixes\r\n- fixed bugs\r\n\r\nv3.0 Beta (7 May 2019)\r\n- dropped windows vista support\r\n- improved dpi support (ui)\r\n- moved rules list into main window\r\n- added services and uwp apps tab\r\n- added network connections monitor\r\n- fixed displaying notifications when it's disabled\r\n- fixed log file write through (issue #369)\r\n- fixed notifications safety timeout\r\n- fixed possible race conditions\r\n- fixed services path retrieve\r\n- fixed notifications cleanup\r\n- improved listview resizing\r\n- improved listview sorting\r\n- removed blacklist mode\r\n- cosmetic fixes\r\n- fixed bugs\r\n"
  },
  {
    "path": "CHANGELOGv1.md",
    "content": "v2.4.6 (27 March 2019)\r\n- enabled special rules group by default (issue #352)\r\n- fixed removing dropped packet items when overflow\r\n- fixed notifications crashing (issue #360)\r\n- fixed checkbox saving state (issue #355)\r\n- fixed possible memory dereferencing\r\n- fixed errors log overflow\r\n- cosmetic fixes\r\n- fixed bugs\r\n\r\nv2.4.5 (20 March 2019)\r\n- fixed user reported bugs\r\n\r\nv2.4.4 Beta (15 March 2019)\r\n- added safety timeout for notification buttons\r\n- added filename highlighting into notification window (issue #344)\r\n- fixed new notifications replacing old one (issue #299)\r\n- fixed updates installation in some cases\r\n- cosmetic fixes\r\n- fixed bugs\r\n\r\nv2.4.3 Beta (9 March 2019)\r\n- fixed filters access rights\r\n- fixed race conditions crash (issue #337)\r\n- fixed notifications locale\r\n- fixed bugs\r\n\r\nv2.4.2 Beta (5 March 2019)\r\n- fixed crash (issue #337)\r\n- updated blocklist\r\n- cosmetic fixes\r\n- fixed bugs\r\n\r\nv2.4.1 Beta (1 March 2019)\r\n- improved notifications speed\r\n- fixed rules listview sorting\r\n- fixed notification ui\r\n- cosmetic fixes\r\n- fixed bugs\r\n\r\nv2.4 Beta (21 February 2019)\r\n- new notification ui\r\n- improved transactions processing\r\n- added predefined rules (ftp, http etc)\r\n- added option to configure 6to4 redirections (it's allowed, but undocumented earlier)\r\n- added double-click for statusbar parts to make purgen faster\r\n- added option to secure installed filters\r\n- added more list view modes\r\n- fixed notifications stay visible when special rules applied for the app\r\n- fixed possible duplicate of special rules from notifications\r\n- fixed multithreading and possible race conditions\r\n- fixed duplicate filters callback on device arrival (issue #291)\r\n- fixed dropped packets csv log delimeter\r\n- fixed packages path retrieving (win8+)\r\n- replaced netsh commands by com interface\r\n- cosmetic fixes\r\n- fixed bugs\r\n\r\nv2.3.13 (3 January 2019)\r\n- added dns resolver caching\r\n- added dns resolver winsock fallback (issue #290)\r\n- avoid window flickering on window sizing\r\n- revert refresh filters on device arrival\r\n- fixed access rights for wfp provider and sublayer\r\n- fixed allocated strings dereferencing (issue #285)\r\n- fixed parsing hosnames with dashes (issue #271)\r\n- fixed localization (issue #288)\r\n- fixed bugs\r\n\r\nv2.3.12 (25 December 2018)\r\n- added (partialy) win10rs5+ dark theme (issue #248)\r\n- allow loopback connections by default for new users\r\n- fixed allocated strings dereferencing (issue #283)\r\n- cosmetic fixes\r\n- fixed bugs\r\n\r\nv2.3.11 (14 December 2018)\r\n- added \"/install\" argument for install filtering\r\n- added cache auto clean up (to prevent overflow)\r\n- changed minimum size of main window (issue #269)\r\n- changed installation message\r\n- increased rule parsing speed (issue #276)\r\n- memory optimization\r\n- fixed notification window appears on taskbar (regression)\r\n- fixed exclude user rules option was not working\r\n- cosmetic fixes\r\n- fixed bugs\r\n\r\nv2.3.10 (28 November 2018)\r\n- fixed old bug where incorrect rules are may accepted as filters\r\n- fixed bugs\r\n\r\nv2.3.9 (20 November 2018)\r\n- fixed resolving ip addresses may hang out net events thread (issue #256)\r\n- fixed net events subscription when option is not set\r\n- fixed protocol names\r\n- fixed bugs\r\n\r\nv2.3.8 (7 November 2018)\r\n- fixed #251\r\n- fixed #253\r\n\r\nv2.3.7 (5 November 2018)\r\n- fixed dropped events callback subscription on latest win10\r\n- fixed notifications sound cannot be played in some cases\r\n- fixed fastlock race condition (critical)\r\n- cosmetic fixes\r\n- fixed bugs\r\n\r\nv2.3.6 (16 October 2018)\r\n- added purgen submenu into tray menu\r\n- added more statusbar information\r\n- set extra large icons view by default\r\n- tray menu services counting bug\r\n- fixed app with overdue timer still enabled on profile load\r\n- fixed resetting some data on profile load\r\n- fixed timer resetting on profie load\r\n- fixed listview checkboxes\r\n- cosmetic fixes\r\n- fixed bugs\r\n\r\nv2.3.5 (14 October 2018)\r\n- added extra large icons view\r\n- use correct function for netevents subscription (win10rs4+)\r\n- fixed forced cleartype font style (issue #233)\r\n- fixed possible buffer overflow\r\n- rerwritten timer engine\r\n- cosmetic fixes\r\n\r\nv2.3.4 (21 September 2018)\r\n- fixed dns system rules when dns service is stopped\r\n- fixed listen filter conditions (issue #213, #222)\r\n- fixed memory referencing bug (issue #221)\r\n- fixed massive handles leak (issue #230)\r\n- fixed thread termination\r\n- various ui fixes\r\n\r\nv2.3.3 (8 July 2018)\r\n- added system rules update feature\r\n- fixed inaccurate timeout between notifications  (issue #194)\r\n- fixed fullscreen apps showstopper (issue #209)\r\n- fixed possible crash for device path resolution\r\n- fixed skipuac warnings for some machines\r\n- fixed some services path resolution\r\n- fixed saving empty rules config\r\n- fixed update engine (issue #182)\r\n- updated system rules\r\n\r\nv2.3.2 (27 Juny 2018)\r\n- added sorting by state for user rules in app context menu\r\n- increased priority for blocking user rules\r\n- fixed loading on startup (issue #75)\r\n- fixed editor apps list sorting\r\n- fixed service names displaying\r\n\r\nv2.3.1 (25 Juny 2018)\r\n- fixed loopback rules (added more reserved ip addresses)\r\n- fixed sometimes system cannot be going to sleep\r\n- fixed applying rules for services (appcrash)\r\n- fixed update sometimes cannot be installed\r\n- fixed services enumeration\r\n- fixed system rules\r\n\r\nv2.3 (19 Juny 2018)\r\n- added allowed connections monitoring in dropped packets log (win8+)\r\n- added inbound multicast and broadcast connections logging (win8+)\r\n- added outbound redirection filter layer (win7+)\r\n- added separation for remote/local address/port in rules editor\r\n- added hotkeys for import/export profile\r\n- added win10 rs5 support\r\n- prevent memory overflow for singly linked lists (win7+) (issue #193)\r\n- do not load icons for processes if icons displaying are disabled\r\n- improved multiple rules applying speed in settings window\r\n- increased time limit for displaying same notification (win7+)\r\n- search loading dlls in system directories only (safety)\r\n- check for correct xml data type before loading\r\n- store last notification timestamp for apps\r\n- removed proxy support (win8+)\r\n- fixed dropped events callback crash (win7+)\r\n- fixed applying services filters\r\n- fixed alphanumeric sorting\r\n- improved port scanning defense\r\n- improved loopback connections\r\n- improved boot-time filters\r\n- stability improvements\r\n- cleanup xml atributes\r\n- updated system rules\r\n- cosmetics fixes\r\n- fixed ui bugs\r\n- fixed bugs\r\n\r\nv2.2.12 (6 Juny 2018)\r\n- added win10 rs4 support\r\n\r\nv2.2.11 (6 Juny 2018)\r\n- fixed double race condition lock (critical)\r\n\r\nv2.2.10 (6 Juny 2018)\r\n- added feature to disable special rules group (issue #181)\r\n- revert special rules highlighting\r\n- fixed listview focusing (issue #164)\r\n- fixed switching modes\r\n- fixed reported bugs\r\n- code cleanup\r\n- fixed bugs\r\n\r\nv2.2.9 (5 Juny 2018)\r\n- added exclude custom rules from notifications feature (issue #177)\r\n- fixed app does not change group when special rule was removed\r\n- fixed sometimes netevents cannot be unsubcribed\r\n- fixed ipv6 addresses loopbacks\r\n- fixed thread event synchronization\r\n- fixed special rules group sorting\r\n- cosmetics fixes\r\n- fixed bugs\r\n\r\nv2.2.8 RC (21 May 2018)\r\n- fixed device changes notifications (issue #128)\r\n- fixed fullscreen apps loses focus (issue #178)\r\n- fixed saving new rules (issue #179)\r\n- fixed loopback condition flag\r\n- code cleanup\r\n\r\nv2.2.7 RC (13 May 2018)\r\n- removed search feature (do not used by anyone)\r\n- stability improvements\r\n- fixed loopback blocking (adobe software now working well when you enable loopback connections)\r\n- fixed singly linked list structure alignment for 32-bit\r\n- fixed timers does not applied from notification window (issue #172)\r\n- fixed apps does not change sorting sometimes\r\n- fixed apps does not change group sometimes\r\n- fixed bugs\r\n\r\nv2.2.6 RC (11 May 2018)\r\n- fixed special rules does not change apps group\r\n- fixed notifications indexing\r\n- fixed notifications icon redraw\r\n- fixed another dns caching\r\n- fixed ui bugs\r\n- fixed bugs\r\n\r\nv2.2.5 Beta (4 May 2018)\r\n- fixed saving profile on manual apps state changing\r\n- fixed some untranslated strings\r\n- fixed installer/uninstaller\r\n- fixed rules checkboxes\r\n- fixed ui bugs\r\n- fixed bugs\r\n\r\nv2.2.4 Beta (3 May 2018)\r\n- now simplewall install filters fastest than Manco pulls out his revolver\r\n- reworked update engine, now it check all components updates automatically\r\n- sort rules alphabeticaly\r\n- fixed threads priority race condition\r\n- fixed applying filters without pause\r\n- fixed dns caching (issue #153)\r\n- fixed ui bugs\r\n- fixed bugs\r\n\r\nv2.2.3 Beta (16 April 2018)\r\n- added drop settings to default feature\r\n- changed log format to csv (comma-separated values) table\r\n- changed install/uninstall filters button icon\r\n- notifications: instant timer applying in notification window\r\n- notifications: cosmetics ui (issue #150)\r\n- notifications: restored \"disable notifications for this app\" button\r\n- notifications: fixed notification buttons behavior\r\n- notifications: removed timeout threshold\r\n- changed current locale version calculation method (more precision)\r\n- removed special rules highlighting (they have own group for it)\r\n- updated to the latest pugixml 1.9\r\n- cosmetics update engine\r\n- fixed ui bugs\r\n- fixed bugs\r\n\r\nv2.2.2 Beta (26 March 2018)\r\n- new update engine\r\n- show full app paths in notifications when \"show filenames only\" is unchecked\r\n- added grouping for apps with user rules\r\n- added opening file properties feature\r\n- cosmetics for the notification ui (issue #146)\r\n- cosmetics for the apps menu\r\n- fixed installer who does not removing profile backups\r\n- fixed signature of apps cannot be checked at startup\r\n- fixed dns resolution in some cases (issue #127)\r\n- fixed various memory leaks because of icons resources\r\n- fixed ui bugs\r\n- fixed bugs\r\n\r\nv2.2.1 Beta (14 March 2018)\r\n- instant apps list sorting\r\n- notifications: added information about blocked protocol\r\n- notifications: replaced \"disable notifications for this app\" icon\r\n- notifications: changed default timeout between same notifications\r\n- notifications: tray popup sometimes won't shown on some systems\r\n- notifications: ignore button combined with block button\r\n- notifications: changed texts for remote/local addresses\r\n- timer does not removed when user manually uncheck apps\r\n- removed font boldening for itself (issue #135)\r\n- changed minimal width of main window\r\n- fixed timers formatting\r\n- fixed ui bugs\r\n- fixed bugs\r\n\r\nv2.2 Beta (4 March 2018)\r\n- new notification ui\r\n- now simplewall added to the apps list automatically (issue #106)\r\n- added windows services support [beta] (issue #88)\r\n- added profile timestamping\r\n- new localization engine (single .lng file)\r\n- more sensitive notifications (issue #107)\r\n- lock-free dropped events callback (win7+)\r\n- added group total items count indication\r\n- added block action for notifications (issue #123)\r\n- automatic profile backup (issue #110)\r\n- added network address resolution\r\n- make internal apps undeletable\r\n- menu bitmap transparent icons\r\n- app paths case correction\r\n- added timers (issue #96)\r\n- set process high priority\r\n- ipsec dropped packets logging (win8+)\r\n- removed wow64 redirection (use simplewall 64-bit binaries for win64)\r\n- revert \"purge unused apps\" feature\r\n- optimized apps types recognition\r\n- improved tray context menu (issue #103)\r\n- improved memory allocation\r\n- changed verify signatures algorithm (issue #94)\r\n- changed \"purge invalid apps\" hotkey\r\n- changed default font\r\n- cosmetics for filter names\r\n- cosmetic fixes (issue #108)\r\n- stability improvements\r\n- updated default colors\r\n- updated localization\r\n- fixed dropped events callback failure (win10 rs3 and above)\r\n- fixed steal focus at startup and when notification displaying\r\n- fixed working under blacklist mode\r\n- fixed multi-monitor support\r\n- fixed ui bugs\r\n- fixed bugs\r\n\r\nv2.1.4 (27 November 2017)\r\n- do not verify signatures for store apps (win8+)\r\n- optimized digital signatures verification (issue #94)\r\n- fixed appcontainers listing (removed firewallapi.dll dependence) (win8+) (issue #104)\r\n- fixed notifications race conditions (it may fix issue #73)\r\n- fixed status does not changed when app deleted\r\n- fixed \"system\" process marked as pico\r\n- updated blocklist\r\n- code cleanup\r\n- fixed bugs\r\n\r\nv2.1.3 (22 November 2017)\r\n- disabled loopback and digital signatures config by default\r\n- fixed displaying name of store apps (win8+) (issue #98)\r\n- fixed network paths rules (issue #102)\r\n\r\nv2.1.2 RC (21 November 2017)\r\n- added option to disable apps signature checking\r\n- set selected apps when you are open rules editor from main window\r\n- reworked special rules (minimized memory usage and speed improvements, also removed limit in apps selection for special rules)\r\n- removed ocsp signature verification (issue #94)\r\n- improved apps version receiving\r\n- renamed \"filters\" into \"rules\"\r\n- fixed various rules editor crashes (issue #89)\r\n- fixed notifications race conditions (it may fix issue #73)\r\n- fixed blocklist incorrect check state\r\n- fixed restoring after hibernation\r\n- updated localization\r\n- fixed ui bugs\r\n- fixed bugs\r\n\r\nv2.1.1 Beta (17 November 2017)\r\n- reworked filter settings page\r\n- added option to disable hosts support for rules\r\n- added option to load blocklist extra rules\r\n- cosmetic fixes for ipv6 address format\r\n- fixed dns resolutions where it does not required (issue #94)\r\n- fixed various rules editor crashes (issue #89)\r\n- fixed windows store icon destroying\r\n- removed filters configuration from menu (use settings dialog instead)\r\n- removed internal rules files from distro\r\n- updated internal rules\r\n- updated localization\r\n- fixed ui bugs\r\n- fixed bugs\r\n\r\nv2.1 Beta (12 November 2017)\r\n- added windows store apps support (win8+)\r\n- revert allowing loopback connection feature\r\n- converted log limit unit to kilobytes\r\n- dropped packets log cosmetic fixes\r\n- improved confirmation dialogs\r\n- updated localization\r\n- fixed settings will not be applied for main menu\r\n- fixed displaying icons for some processes\r\n- fixed rules editor crash (issue #89)\r\n- fixed color items reorganization\r\n- fixed ui bugs\r\n- fixed bugs\r\n\r\nv2.0.20 (6 November 2017)\r\n- now custom rules will overwrite system rules\r\n- added warning message for listen connections option\r\n- apply filters on demand in settings dialog\r\n- added port support for ip ranges\r\n- removed rules configuration from menu (use settings dialog instead)\r\n- fixed rule apps does not saved when checkbox are checked\r\n- fixed rule generation from notification window\r\n- fixed listen connections does not blocked\r\n- fixed highlighting special rules for apps\r\n- fixed running under non-admin account\r\n- fixed skip-uac working directory\r\n- fixed listview sorting\r\n- fixed ui bugs\r\n- fixed bugs\r\n\r\nv2.0.19 (1 November 2017)\r\n- new rules editor ui\r\n- added highlighting rules with errors\r\n- automatically sorting rules after changing\r\n- added feature to set custom dns ipv4 server (\"DnsServerV4\" in .ini)\r\n- added option to exclude blocklist rules from notifications\r\n- show process information in statusbar on menu item hover\r\n- optimized signature information retrieving from binaries\r\n- updated localization\r\n- fixed saving profile in some cases\r\n- fixed parsing rules types (issue #70)\r\n- fixed dns queries\r\n- fixed ui bugs\r\n- fixed bugs\r\n\r\nv2.0.18 (20 October 2017)\r\n- added setting to disable proxy support (win8+)\r\n- prevent notifications duplicate\r\n- fixed windows firewall disabling on win10\r\n- fixed notifications sound configuration does not saved\r\n- fixed notifications sound does not played on some systems\r\n- cosmetic fixes about notifications cross button\r\n- updated localization\r\n- updated blocklist\r\n- fixed dpi support\r\n- fixed ui bugs\r\n\r\nv2.0.17 (12 October 2017)\r\n- clear notifications cache on apply filters and configuration\r\n- show more address information on notification window tooltip\r\n- fixed redraw listview after notification actions\r\n- fixed ui hangouts for a long time sometimes\r\n- fixed race conditions\r\n- fixed ui bugs\r\n- fixed bugs\r\n\r\nv2.0.16 (6 October 2017)\r\n- fixed internal rules configuration saving\r\n\r\nv2.0.15 (6 October 2017)\r\n- make current settings backup before import\r\n- changed default listview font\r\n- fixed settings listview groups does not changed immediately\r\n- fixed notification window display at startup\r\n- fixed uninstaller do not removed some files\r\n\r\nv2.0.14 (5 October 2017)\r\n- apply settings on demand (too much faster)\r\n- revert listen connections blocking feature (request)\r\n- set font also for settings lists\r\n- revert forgotten rules editor button\r\n- updated localization\r\n- fixed ui bugs\r\n\r\nv2.0.13 (4 October 2017)\r\n- new settings ui\r\n- fixed settings reset on device arrival\r\n- fixed colors configuration checkboxes\r\n\r\nv2.0.12 RC (3 October 2017)\r\n- use colors and tooltip for notification icon same as in main window\r\n- do not show notifications on tray hover when it is disabled\r\n- do not bring notifications window into the foreground when it shows\r\n- revert error log tray menu\r\n- fixed network paths detection\r\n- fixed displaying non interesting errors\r\n- fixed some device path conversions\r\n- fixed notifications cleanup\r\n- updated localization\r\n- fixed ui bugs\r\n\r\nv2.0.11 Beta (30 September 2017)\r\n- subscribe for net events only when filters are installed (win7+)\r\n- fixed incorrect filters applied for special rules\r\n- fixed all apps are in lowercase\r\n\r\nv2.0.10 Beta (29 September 2017)\r\n- added selection counting for remove items dialog\r\n- show signature information in notification app icon tooltip\r\n- show exit confirmation dialog when filters are installing\r\n- set low-limit for notification timeout\r\n- revert forgotten privelege (regression)\r\n- fixed filters for non existing paths (regression)\r\n- fixed string case for cyrillic symbols\r\n- fixed filters thread\r\n- fixed minimize button\r\n- fixed ui bugs\r\n- fixed bugs\r\n\r\nv2.0.9 Beta (25 September 2017)\r\n- improved notifications cleanup\r\n- revert processes icons\r\n- fixed nt path conversions (regression)\r\n- fixed notification ui display timeout\r\n- fixed ui bugs\r\n- fixed bugs\r\n\r\nv2.0.8 Beta (21 September 2017)\r\n- new logo\r\n- changed minimal size of main window\r\n- updated notification ui\r\n- updated icons pack\r\n- updated blocklist\r\n- fixed font quality (use cleartype ever)\r\n- fixed notifications sound\r\n- fixed bugs\r\n\r\nv2.0.7 Beta (14 September 2017)\r\n- added count marks for all groups\r\n- added font selection for listview\r\n- prefer \"blocklist_full.xml\" parsing if it's presented\r\n- improved signatures checking\r\n- optimized listview redraw items\r\n- optimized listview autosizing columns\r\n- disable retrieving icon handle for network paths for notification dialog\r\n- changed default listview colors\r\n- optimized loading speed\r\n- code cleanup\r\n- fixed ui hanging in some cases\r\n- fixed bugs\r\n\r\nv2.0.6 Beta (11 September 2017)\r\n- added signature checking for apps\r\n- added set default language as in system\r\n- changed default listview colors\r\n- updated project sdk\r\n- fixed allowed apps cannot recieve any data from network (when stealth-mode enabled)\r\n- fixed retrieving nt path for reparse point files (issue #59)\r\n- fixed update checking not working on some systems\r\n- fixed bugs\r\n\r\nv2.0.5 Beta (30 August 2017)\r\n- added proxy support (win8+)\r\n- added indication for inbound connections for all (when stealth-mode enabled)\r\n- added group for special rules (rules applied for apps)\r\n- added apps list selection indication\r\n- changed experimental settings mark into \"for experts only\"\r\n- removed process list menu icons\r\n- improved retrieving file path by handle\r\n- improved notifications ui\r\n- updated project sdk\r\n- fixed ui bugs\r\n- fixed bugs\r\n\r\nv2.0.4 Beta (23 August 2017)\r\n- added grouping for rules\r\n- removed listen connections blocking feature\r\n- improved import/export xml database\r\n- fixed open rules editor action in main window\r\n- fixed crash on delete rules\r\n- fixed ui bugs\r\n- fixed bugs\r\n\r\nv2.0.3 Beta (17 August 2017)\r\n- added import/export applications list feature\r\n- added mode selection into installation dialog\r\n- added tooltips into the notifications ui\r\n- added remembering collapsed state for the listview groups\r\n- increased internal rules loading speed (please update blocklist.xml and rules_system.xml to latest versions)\r\n- increased rules list icons size\r\n- changed default sorting configuration\r\n- fixed notifications ui logic\r\n- fixed filters installation state flag\r\n- fixed support some domains\r\n- fixed carriage return type for rules_system.xml\r\n- fixed thread spinlock\r\n- updated localization\r\n- updated project sdk\r\n- updated blocklist\r\n- fixed bugs\r\n\r\nv2.0.2 Beta (7 August 2017)\r\n- fixed incorrect vector index\r\n\r\nv2.0.1 Beta (7 August 2017)\r\n- added update checking for new beta version\r\n- added flush dns cache after filters applied\r\n- set max prefix length for ipv6 addresses to 64\r\n- new rules editor interface\r\n- changed minimum width for a main window\r\n- fixed running with \"/minimized\" argument under uac\r\n- updated localization\r\n- fixed bugs\r\n\r\nv2.0 Beta (1 August 2017)\r\n- new notification ui\r\n- show notifications only for whitelist mode\r\n- allow listen connections for all is enabled by default\r\n- added import custom rules from file feature\r\n- added support to load large xml files\r\n- added more information into the main window\r\n- added apps grouping (allowed/blocked)\r\n- added custom rules syntax checking\r\n- added support dns resolution for custom rules\r\n- added resolving shortcut path\r\n- added notification display timeout config\r\n- save internal rules configuration into xml\r\n- purgen remove only apps with errors\r\n- minimized dropped packets log size (union remote and local address information)\r\n- minimized memory usage\r\n- removed \"trust no one\" mode\r\n- updated system rules\r\n- updated blocklist\r\n- fixed dropped packets logging hibernation (win7+)\r\n- fixed remember windows size and position sometimes\r\n- fixed version string trimming\r\n- fixed ui bugs\r\n- fixed memory leaks\r\n- fixed bugs\r\n\r\nv1.6.5 (1 June 2017)\r\n- do not block listen connections on stealth-mode\r\n- do not block listen connections on boot-time\r\n- fixed dropped events does not shutdown on exit (win7+)\r\n- fixed memory leak\r\n\r\nv1.6.4 (31 May 2017)\r\n- added fallback if blocklist and/or system rules not found\r\n- added more dropped events logging (win7+)\r\n- fixed dropped events subscription duplicate (win7+)\r\n- fixed run as admin does not work sometimes\r\n- updated blocklist\r\n- fixed bugs\r\n\r\nv1.6.3 (27 May 2017)\r\n- generate unique session key at startup\r\n- fixed custom app rules crash on delete\r\n- fixed lookup account sid length mismatch\r\n- fixed dropped packets logging crash (win7+)\r\n- stability improvements\r\n- updated system rules\r\n- fixed bugs\r\n\r\nv1.6.2 (24 May 2017)\r\n- create filter even if file doesn't exists (drive must be mounted)\r\n- allow inbound & listen traffic only if stealth-mode does not enabled\r\n- added required rules for the ipv6 stack to work properly\r\n- stealth-mode marked as experimental\r\n- fixed com library initialization (again!)\r\n- fixed stealth-mode\r\n- fixed bugs\r\n\r\nv1.6.1 (23 May 2017)\r\n- added username and domain information to the window title\r\n- added configuration refresh on user logon\r\n- removed static wfp session key (request)\r\n- fixed com library initialization\r\n- fixed incorrect return value on file not found error\r\n\r\nv1.6 (19 May 2017)\r\n- added stealth-mode (to prevent udp/tcp port scanning)\r\n- added acl (access control list) to the engine\r\n- added gridline for the listview config\r\n- added item into the custom rules menu for open rules editor\r\n- added version-independent network events api call (win7+)\r\n- added dropped packets log file size limit to 1mb (win7+)\r\n- reset windows firewall to its initial state when restore it back\r\n- blocklist marked as experimental\r\n- removed custom rules from package\r\n- fixed dropped packets logging stop sometimes (win7+)\r\n- fixed removing custom rules\r\n- fixed classic ui\r\n- fixed bugs\r\n- ui fixes\r\n\r\nv1.5.5 (6 May 2017)\r\n- added installer\r\n- added static wfp session key\r\n- copy filter name if description is not available for dropped packets log\r\n- removed \"file not found\" xml parsing errors\r\n- revert trim rules back (request)\r\n- fixed index flag cannot be set (win8+)\r\n- fixed ui bugs\r\n\r\nv1.5.4 (30 April 2017)\r\n- trim executable version string\r\n- fixed filters uninstallation\r\n- fixed duplicate update checking\r\n- fixed bugs\r\n\r\nv1.5.3 (27 April 2017)\r\n- fixed restoring windows firewall state\r\n- fixed incorrect window size at startup sometimes\r\n\r\nv1.5.2 (27 April 2017)\r\n- fixed dropped packets log spinlock cannot be unlocked (critical)\r\n- fixed displaying \"file not found\" errors\r\n- restore listview selection after application delete\r\n- disable main button on filters installation\r\n- improved shutting down windows firewall feature\r\n- removed unnecessary whitespace trims\r\n- optimized window resizing\r\n- updated to the latest sdk\r\n- fixed bugs\r\n\r\nv1.5.1 (17 April 2017)\r\n- added remember window position and size feature\r\n- added \"enable errors notifications\" config\r\n- added f11 hotkey for maximize window\r\n- disable wow64 filesystem redirection\r\n- changed error log notification text\r\n- fixed possible memory leak\r\n\r\nv1.5 (15 April 2017)\r\n- added index flag to the filters, to help enable faster lookup during classification (win8+)\r\n- added app container loopback traffic permission (win8+)\r\n- added \"allow listen connections for all\" config\r\n- added loopback indication for dropped packets log\r\n- copy real path instead display path on copy command in main window listview\r\n- do not show dropped packets notifications when filters are not installed\r\n- if boot-time filters enabled then apply system rules for boot-time too\r\n- custom rules for apps does not saved sometimes\r\n- removed running without admin rights feature\r\n- changed notification about errors logic\r\n- changed alt+f4 behaviour (request)\r\n- cosmetic fixes for tooltips\r\n- fixed disabling windows firewall on some systems\r\n- fixed settings tabstop doesn't work\r\n- fixed incorrect listview icons for some apps\r\n- fixed process list some apps have no icons\r\n- fixed possible duplicate filters\r\n- fixed purge unused apps\r\n- stability improvements\r\n- updated translations\r\n- updated system rules\r\n- updated pugixml\r\n- fixed bugs\r\n\r\nv1.4.6 (5 April 2017)\r\n- added write error logs into a file feature\r\n- fixed process list does not recognize pico applications on win10\r\n- updated translations\r\n- fixed bugs\r\n\r\nv1.4.5 (4 April 2017)\r\n- added pico support (subsystem for unix-based applications) for win10\r\n- added l2tp/ipsec for system rules\r\n- added localhost for custom rules\r\n- fixed access denied for some self protected applications (like \"ekrn.exe\" for nod32)\r\n\r\nv1.4.4 (28 March 2017)\r\n- added ipsec connections monitoring into the log (win8+)\r\n- cosmetic fixes about tray notifications\r\n- fixed dropped packets callback crash (critical)\r\n- fixed displaying tray notifications on win10\r\n- fixed possible duplicate filters\r\n\r\nv1.4.3 (27 March 2017)\r\n- added provider information into the log/notifications\r\n- added displaying error messages on filters configuration via tray popup\r\n- fixed link processing in settings window\r\n- cosmetic changes about debug error messages\r\n- removed \"nlatunicast\" flag from loopback permissions\r\n- updated blocklist\r\n- code cleanup\r\n\r\nv1.4.2 (19 February 2017)\r\n- added hints to rules pages\r\n- fixed filter creation for nonexistent apps (critical)\r\n- fixed resource definition\r\n- fixed purge unused apps\r\n- cosmetic changes about rules tooltip\r\n\r\nv1.4.1 (4 February 2017)\r\n- fixed suspended drop event callback (critical)\r\n- fixed suspended apply filters thread (critical)\r\n- fixed purge unused apps\r\n\r\nv1.4.0 (31 January 2017)\r\n* revert original project name\r\n- added mode changing confirmation\r\n- added reading information about \"System\" process\r\n- added protocol and version (ports only) option into the rules editor\r\n- added blocklist editor (set it \"on\" or \"off\" only)\r\n- added custom rules applying to the apps feature\r\n- added \"show filenames only\" option\r\n- added icon indication for rules\r\n- added loopback permission for \"trust no one\" mode\r\n- moved system rules into the \"rules_system.xml\" file\r\n- clear log even if logging to a file is not enabled\r\n- do not load information about apps from shared resources\r\n- fixed profile not saved if filters is not installed\r\n- removed tray balloon tips on filters changing\r\n- boot-time filters marked as experimental\r\n- improved working under uac (no rights)\r\n- improved system apps detection\r\n- cosmetic fixes in process list\r\n- cosmetic fixes in apps tooltip\r\n- fixed race conditions\r\n- updated translation\r\n- updated blocklist\r\n- updated ui\r\n- fixed bugs\r\n\r\nv1.3.7 (21 November 2016)\r\n- fixed special rules crash on apply settings\r\n- fixed special rules reinitialization in main menu/tray menu\r\n- updated translation\r\n\r\nv1.3.6 (20 November 2016)\r\n- added loopback permission for boot-time filters\r\n- added ip:port syntax for special rules\r\n- added default values for new special rules\r\n- fixed restore listview selection\r\n- fixed special rules crash on delete item\r\n- fixed log path unexpand environment strings\r\n\r\nv1.3.5 (17 November 2016)\r\n- fixed configuration saving (critical)\r\n- fixed xml saving (critical)\r\n\r\nv1.3.3 (14 November 2016)\r\n- added boot-time filters for prevent data leak during system startup, even before \"Base Filtering Engine\" (BFE) service starts\r\n- added \"purge unused applications\" feature\r\n- added \"hide icons\" feature\r\n- added documentation for rules editor and filter page\r\n- added special rules to main menu/tray menu\r\n- fixed multi-select configuration in listview\r\n- fixed system imagelist destroying\r\n- fixed dropped packets filters decription empty sometimes\r\n- fixed find dialog crash\r\n- removed inbound events logging for some reason\r\n- updated translation\r\n- updated pugixml\r\n\r\nv1.3.2 (29 October 2016)\r\n- added domain\\username indication to log events\r\n- added filter name to log events\r\n- added ip/port range support for rules\r\n- combined ip and port rules settings page\r\n- added save checkbox state on install/delete message\r\n- added listen loopback permission\r\n- added inbound events logging\r\n- set xml load encoding to auto\r\n- improved logic for detect incorrect applications\r\n- listview empty text indication doesn't changed at locale change\r\n- changed default log parameters for \"system\" & \"svchost.exe\"\r\n- fixed inbound ip doesn't affected in applied rules\r\n- changed default color for silent applications\r\n- removed output log into debug log feature\r\n- improved open/save file dialog flags\r\n- optimized log callback\r\n- updated blocklist\r\n- updated translation\r\n- minor improvements\r\n\r\nv1.3.1 (21 October 2016)\r\n- added option to set application for open log file\r\n- added option to exclude application from log\r\n- added option for disable notification sound\r\n- added middle click on tray icon now open log file\r\n- added empty listview text indication\r\n- added rules highlighting\r\n- added usage examples to rules.xml \r\n- reorganized log settings\r\n- fixed unit of time for notification timeout had in minutes (instead seconds)\r\n- fixed special rules saved twice\r\n- fixed skip user account control not worked\r\n- fixed special rules saved empty when filters not installed\r\n- fixed system rules cannot be unchecked automatically\r\n- changed auto byte order mask for xml load/save\r\n- replaced QueryFullProcessImageName to NtQueryInformationProcess\r\n- stability improvements\r\n- updated translation\r\n- ui improvements\r\n\r\nv1.3 (15 October 2016)\r\n- disable/enable windows firewall on filters installation/deletion\r\n- normalize nt paths for dropped packets callback\r\n- exclude \"svchost.exe\" & \"system\" from log configuration\r\n- abbility to show/clear log\r\n- resize support as in alpha builds\r\n- hotkeys for menu items\r\n- PathUnExpandEnvStrings for log path\r\n- confirmation settings for exit/deleting application/log clear\r\n- changed message boxes style\r\n- changed default color for invalid applications\r\n- fixed access denied for some processes\r\n- config doesn't saved if user don't trigger apply filters\r\n- improved windows firewall control\r\n- stability improvements\r\n- updated translation\r\n\r\nv1.2.118 (5 October 2016)\r\n- fixed crash on filters installation\r\n- save sort order into profile (regression)\r\n- unable to clear log path config\r\n- stability improvements\r\n- updated translation\r\n\r\nv1.2.117 (4 October 2016)\r\n* changed ui by IAEA safety standards (issue #2)\r\n- added logging configuration\r\n- now filters disabled by default\r\n- inbound ports doesn't blocked for special rules\r\n- updated translation\r\n- minor improvements\r\n\r\nv1.1.116 (30 September 2016)\r\n- added \"listen\" layer blocking\r\n- added forgotten rules into settings menu\r\n- added open folder by double click for listview\r\n- added shared resources highlighting\r\n- dropped packets logging optimizations\r\n- fixed process list menu icons with classic ui\r\n- updated translation\r\n- minor improvements\r\n\r\nv1.1.115 (22 September 2016)\r\n- added more information to dropped packets logging (win7+)\r\n- fixed inbound dont't blocking\r\n- cannot add port in rules editor\r\n- updated translation\r\n\r\nv1.1.114 (21 September 2016)\r\n- rules in settings dialog cannot be saved\r\n\r\nv1.1.113 (20 September 2016)\r\n- fixed cannot delete application from list bug\r\n- fixed default values for settings\r\n- filters for services do not set\r\n- fixed dhcpv6 ports configuration\r\n- fixed windows firewall configuration\r\n- updated translation\r\n- fixed bugs\r\n\r\nv1.1.112 (19 September 2016)\r\n* project renamed\r\n- added \"trust no one\" mode\r\n- added dropped packets logging to debugview (win7+)\r\n- added automatic rules applying on insert device\r\n- added name for filters\r\n- moved telemetry rules to the resources\r\n- rewritten rules editor\r\n- improved classic ui config\r\n- fixed tray tooltip visibility\r\n- decreased ballon tips\r\n\r\nv1.0.101 (7 September 2016)\r\n- added outbound connections configuration for rules\r\n- added color configuration\r\n- changed weight for sublayer\r\n- removed startup popup notification\r\n- updated translation\r\n\r\nv1.0.100 (30 August 2016)\r\n- added individual applicaiton rules\r\n- added highlight for invalid items\r\n- added icons for process popup menu\r\n- rewritten process retrieving code (fixed many bugs)\r\n- restored \"Refresh\" listview feature\r\n- prevent for duplicate filters on some configurations\r\n- unlocked application layer configuration in \"for all (global)\" rules\r\n- loaded default rules on initilize settings\r\n- updated translation\r\n- fixed bugs\r\n\r\nv1.0.99 (25 August 2016)\r\n- added windows update and http protocol allow rule\r\n- blocking list editor context menu does not showed\r\n- blocking list editor first item cannot be edited\r\n- fix rules checkbox displaying in settings window\r\n- rules re-grouped by OSI model\r\n- changed listview custom draw\r\n- updated translation\r\n- updated ui\r\n\r\nv1.0.98b (22 August 2016)\r\n- added ballon tip on remove filters\r\n- changed default rules for all\r\n- changed default rules for allowed\r\n\r\nv1.0.96b (21 August 2016)\r\n- settings improvements\r\n- fixed duplicate popup on startup\r\n- cleanup code/resources\r\n- updated translation\r\n\r\nv1.0.94b (20 August 2016)\r\n- updated translation\r\n- removed excess tray popups\r\n- filters not applied when firewall started manually\r\n- tray icon does not change on firewall enable\r\n- improved block list editor\r\n\r\nv1.0.90b (19 August 2016)\r\n- now compiled with \"treat warnings as error\" parameter\r\n- added global rules configuration\r\n- added \"disable windows firewall\" param\r\n- added balloon tips param\r\n- started localization\r\n- fixed buffer overflow on remove filters\r\n- finished blocking list editor\r\n- removed duplicate filters\r\n- fixed memory leaks on change window icon\r\n- ui improvements\r\n- now checking updates worked\r\n- fixed statusbar redraw forgotten\r\n- updated translation\r\n- ui fixes\r\n\r\nv1.0.81a (18 August 2016)\r\n- added indication allowed/blocked item count\r\n- added edit blocking list support\r\n- added loopback configuration into profile\r\n- fixed profile mask set to default at startup\r\n- improved profile configuration dialog\r\n\r\nv1.0.79a (17 August 2016)\r\n- added tooltips\r\n- inbound traffic not blocked sometimes\r\n\r\nv1.0.77a (16 August 2016)\r\n- added profiles for applications\r\n- added more hotkeys\r\n- find now worked\r\n- increased startup speed (moved filters applying function into another thread)\r\n- fixed ntp setting\r\n- fixed memory leak\r\n- ui improvements\r\n\r\nv1.0.52a (13 August 2016)\r\n- fixed main window dpi\r\n- fixed scroll height on change icon size\r\n- removed comments/debug strings\r\n- fixed application state does not saved on check/uncheck\r\n- added \"select all\" (ctrl+a) hotkey\r\n- added \"telemetry.xml\"\r\n- ip parsing optimization (due ParseNetworkString)\r\n- ui improvements\r\n\r\nv1.0.42a (12 August 2016)\r\n- added outbound/inbound ICMP permission\r\n- auto apply filters on settings change\r\n- removed \"Apply rules\" button (do not need it anymore)\r\n- increased startup speed\r\n- removed process monitor\r\n- changed config defaults\r\n- ui improvements\r\n- small bug fixes\r\n\r\nv1.0.30a (11 August 2016)\r\n- added outbound loopback permission\r\n- fixed DHCP/DNS/NTP allowed for all\r\n- fixed memory leak\r\n\r\nv1.0.23a (6 August 2016)\r\n- added support to allow DHCP/DNS/NTP through svchost.exe\r\n- fixed NtOpenProcess access rights\r\n\r\nv1.0.21a (4 August 2016)\r\n- fixed uncheck item doesn't saved\r\n- previous build changes extended\r\n- removed duplicate function calling\r\n- menu fixes\r\n\r\nv1.0.18a (4 August 2016)\r\n- added internal telemetry blocking\r\n- added menu accelerators\r\n- moved process monitor to low-level\r\n- fixed provider persistency\r\n- re-fuck-to-ring\r\n\r\nv1.0.13a (2 August 2016)\r\n- added search abbility for existing application filters and show them\r\n- added tray icon indication\r\n- added find in application list feature\r\n- increased speed (due transactions)\r\n- fixed 32-bit working under 64-bit system\r\n- ui improvements\r\n\r\nv1.0.10a (30 July 2016)\r\n- fixed xml saving/parsing bug\r\n- fixed read memory access on filter enumeration\r\n\r\nv1.0.7a (29 July 2016)\r\n- added inbound loopback permission\r\n- added balloon tips on events\r\n- fixed inbound permission for allowed applications\r\n- fixed critical bug (incorrect memory address access)\r\n- common optimizations\r\n- ui improvements\r\n\r\nv1.0.4a (27 July 2016)\r\n- added icons size configuration\r\n- fixed background thread to catch applications doesn't worked\r\n- fixed v6 callout misstake\r\n- ui improvements\r\n\r\nv1.0.3a (26 July 2016)\r\n- added more settings\r\n- improved ui\r\n- removed service (do not need it anymore)\r\n\r\nv1.0.2a (26 July 2016)\r\n- first public version\r\n"
  },
  {
    "path": "LICENSE",
    "content": "                    GNU GENERAL PUBLIC LICENSE\r\n                       Version 3, 29 June 2007\r\n\r\n Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>\r\n Everyone is permitted to copy and distribute verbatim copies\r\n of this license document, but changing it is not allowed.\r\n\r\n                            Preamble\r\n\r\n  The GNU General Public License is a free, copyleft license for\r\nsoftware and other kinds of works.\r\n\r\n  The licenses for most software and other practical works are designed\r\nto take away your freedom to share and change the works.  By contrast,\r\nthe GNU General Public License is intended to guarantee your freedom to\r\nshare and change all versions of a program--to make sure it remains free\r\nsoftware for all its users.  We, the Free Software Foundation, use the\r\nGNU General Public License for most of our software; it applies also to\r\nany other work released this way by its authors.  You can apply it to\r\nyour programs, too.\r\n\r\n  When we speak of free software, we are referring to freedom, not\r\nprice.  Our General Public Licenses are designed to make sure that you\r\nhave the freedom to distribute copies of free software (and charge for\r\nthem if you wish), that you receive source code or can get it if you\r\nwant it, that you can change the software or use pieces of it in new\r\nfree programs, and that you know you can do these things.\r\n\r\n  To protect your rights, we need to prevent others from denying you\r\nthese rights or asking you to surrender the rights.  Therefore, you have\r\ncertain responsibilities if you distribute copies of the software, or if\r\nyou modify it: responsibilities to respect the freedom of others.\r\n\r\n  For example, if you distribute copies of such a program, whether\r\ngratis or for a fee, you must pass on to the recipients the same\r\nfreedoms that you received.  You must make sure that they, too, receive\r\nor can get the source code.  And you must show them these terms so they\r\nknow their rights.\r\n\r\n  Developers that use the GNU GPL protect your rights with two steps:\r\n(1) assert copyright on the software, and (2) offer you this License\r\ngiving you legal permission to copy, distribute and/or modify it.\r\n\r\n  For the developers' and authors' protection, the GPL clearly explains\r\nthat there is no warranty for this free software.  For both users' and\r\nauthors' sake, the GPL requires that modified versions be marked as\r\nchanged, so that their problems will not be attributed erroneously to\r\nauthors of previous versions.\r\n\r\n  Some devices are designed to deny users access to install or run\r\nmodified versions of the software inside them, although the manufacturer\r\ncan do so.  This is fundamentally incompatible with the aim of\r\nprotecting users' freedom to change the software.  The systematic\r\npattern of such abuse occurs in the area of products for individuals to\r\nuse, which is precisely where it is most unacceptable.  Therefore, we\r\nhave designed this version of the GPL to prohibit the practice for those\r\nproducts.  If such problems arise substantially in other domains, we\r\nstand ready to extend this provision to those domains in future versions\r\nof the GPL, as needed to protect the freedom of users.\r\n\r\n  Finally, every program is threatened constantly by software patents.\r\nStates should not allow patents to restrict development and use of\r\nsoftware on general-purpose computers, but in those that do, we wish to\r\navoid the special danger that patents applied to a free program could\r\nmake it effectively proprietary.  To prevent this, the GPL assures that\r\npatents cannot be used to render the program non-free.\r\n\r\n  The precise terms and conditions for copying, distribution and\r\nmodification follow.\r\n\r\n                       TERMS AND CONDITIONS\r\n\r\n  0. Definitions.\r\n\r\n  \"This License\" refers to version 3 of the GNU General Public License.\r\n\r\n  \"Copyright\" also means copyright-like laws that apply to other kinds of\r\nworks, such as semiconductor masks.\r\n\r\n  \"The Program\" refers to any copyrightable work licensed under this\r\nLicense.  Each licensee is addressed as \"you\".  \"Licensees\" and\r\n\"recipients\" may be individuals or organizations.\r\n\r\n  To \"modify\" a work means to copy from or adapt all or part of the work\r\nin a fashion requiring copyright permission, other than the making of an\r\nexact copy.  The resulting work is called a \"modified version\" of the\r\nearlier work or a work \"based on\" the earlier work.\r\n\r\n  A \"covered work\" means either the unmodified Program or a work based\r\non the Program.\r\n\r\n  To \"propagate\" a work means to do anything with it that, without\r\npermission, would make you directly or secondarily liable for\r\ninfringement under applicable copyright law, except executing it on a\r\ncomputer or modifying a private copy.  Propagation includes copying,\r\ndistribution (with or without modification), making available to the\r\npublic, and in some countries other activities as well.\r\n\r\n  To \"convey\" a work means any kind of propagation that enables other\r\nparties to make or receive copies.  Mere interaction with a user through\r\na computer network, with no transfer of a copy, is not conveying.\r\n\r\n  An interactive user interface displays \"Appropriate Legal Notices\"\r\nto the extent that it includes a convenient and prominently visible\r\nfeature that (1) displays an appropriate copyright notice, and (2)\r\ntells the user that there is no warranty for the work (except to the\r\nextent that warranties are provided), that licensees may convey the\r\nwork under this License, and how to view a copy of this License.  If\r\nthe interface presents a list of user commands or options, such as a\r\nmenu, a prominent item in the list meets this criterion.\r\n\r\n  1. Source Code.\r\n\r\n  The \"source code\" for a work means the preferred form of the work\r\nfor making modifications to it.  \"Object code\" means any non-source\r\nform of a work.\r\n\r\n  A \"Standard Interface\" means an interface that either is an official\r\nstandard defined by a recognized standards body, or, in the case of\r\ninterfaces specified for a particular programming language, one that\r\nis widely used among developers working in that language.\r\n\r\n  The \"System Libraries\" of an executable work include anything, other\r\nthan the work as a whole, that (a) is included in the normal form of\r\npackaging a Major Component, but which is not part of that Major\r\nComponent, and (b) serves only to enable use of the work with that\r\nMajor Component, or to implement a Standard Interface for which an\r\nimplementation is available to the public in source code form.  A\r\n\"Major Component\", in this context, means a major essential component\r\n(kernel, window system, and so on) of the specific operating system\r\n(if any) on which the executable work runs, or a compiler used to\r\nproduce the work, or an object code interpreter used to run it.\r\n\r\n  The \"Corresponding Source\" for a work in object code form means all\r\nthe source code needed to generate, install, and (for an executable\r\nwork) run the object code and to modify the work, including scripts to\r\ncontrol those activities.  However, it does not include the work's\r\nSystem Libraries, or general-purpose tools or generally available free\r\nprograms which are used unmodified in performing those activities but\r\nwhich are not part of the work.  For example, Corresponding Source\r\nincludes interface definition files associated with source files for\r\nthe work, and the source code for shared libraries and dynamically\r\nlinked subprograms that the work is specifically designed to require,\r\nsuch as by intimate data communication or control flow between those\r\nsubprograms and other parts of the work.\r\n\r\n  The Corresponding Source need not include anything that users\r\ncan regenerate automatically from other parts of the Corresponding\r\nSource.\r\n\r\n  The Corresponding Source for a work in source code form is that\r\nsame work.\r\n\r\n  2. Basic Permissions.\r\n\r\n  All rights granted under this License are granted for the term of\r\ncopyright on the Program, and are irrevocable provided the stated\r\nconditions are met.  This License explicitly affirms your unlimited\r\npermission to run the unmodified Program.  The output from running a\r\ncovered work is covered by this License only if the output, given its\r\ncontent, constitutes a covered work.  This License acknowledges your\r\nrights of fair use or other equivalent, as provided by copyright law.\r\n\r\n  You may make, run and propagate covered works that you do not\r\nconvey, without conditions so long as your license otherwise remains\r\nin force.  You may convey covered works to others for the sole purpose\r\nof having them make modifications exclusively for you, or provide you\r\nwith facilities for running those works, provided that you comply with\r\nthe terms of this License in conveying all material for which you do\r\nnot control copyright.  Those thus making or running the covered works\r\nfor you must do so exclusively on your behalf, under your direction\r\nand control, on terms that prohibit them from making any copies of\r\nyour copyrighted material outside their relationship with you.\r\n\r\n  Conveying under any other circumstances is permitted solely under\r\nthe conditions stated below.  Sublicensing is not allowed; section 10\r\nmakes it unnecessary.\r\n\r\n  3. Protecting Users' Legal Rights From Anti-Circumvention Law.\r\n\r\n  No covered work shall be deemed part of an effective technological\r\nmeasure under any applicable law fulfilling obligations under article\r\n11 of the WIPO copyright treaty adopted on 20 December 1996, or\r\nsimilar laws prohibiting or restricting circumvention of such\r\nmeasures.\r\n\r\n  When you convey a covered work, you waive any legal power to forbid\r\ncircumvention of technological measures to the extent such circumvention\r\nis effected by exercising rights under this License with respect to\r\nthe covered work, and you disclaim any intention to limit operation or\r\nmodification of the work as a means of enforcing, against the work's\r\nusers, your or third parties' legal rights to forbid circumvention of\r\ntechnological measures.\r\n\r\n  4. Conveying Verbatim Copies.\r\n\r\n  You may convey verbatim copies of the Program's source code as you\r\nreceive it, in any medium, provided that you conspicuously and\r\nappropriately publish on each copy an appropriate copyright notice;\r\nkeep intact all notices stating that this License and any\r\nnon-permissive terms added in accord with section 7 apply to the code;\r\nkeep intact all notices of the absence of any warranty; and give all\r\nrecipients a copy of this License along with the Program.\r\n\r\n  You may charge any price or no price for each copy that you convey,\r\nand you may offer support or warranty protection for a fee.\r\n\r\n  5. Conveying Modified Source Versions.\r\n\r\n  You may convey a work based on the Program, or the modifications to\r\nproduce it from the Program, in the form of source code under the\r\nterms of section 4, provided that you also meet all of these conditions:\r\n\r\n    a) The work must carry prominent notices stating that you modified\r\n    it, and giving a relevant date.\r\n\r\n    b) The work must carry prominent notices stating that it is\r\n    released under this License and any conditions added under section\r\n    7.  This requirement modifies the requirement in section 4 to\r\n    \"keep intact all notices\".\r\n\r\n    c) You must license the entire work, as a whole, under this\r\n    License to anyone who comes into possession of a copy.  This\r\n    License will therefore apply, along with any applicable section 7\r\n    additional terms, to the whole of the work, and all its parts,\r\n    regardless of how they are packaged.  This License gives no\r\n    permission to license the work in any other way, but it does not\r\n    invalidate such permission if you have separately received it.\r\n\r\n    d) If the work has interactive user interfaces, each must display\r\n    Appropriate Legal Notices; however, if the Program has interactive\r\n    interfaces that do not display Appropriate Legal Notices, your\r\n    work need not make them do so.\r\n\r\n  A compilation of a covered work with other separate and independent\r\nworks, which are not by their nature extensions of the covered work,\r\nand which are not combined with it such as to form a larger program,\r\nin or on a volume of a storage or distribution medium, is called an\r\n\"aggregate\" if the compilation and its resulting copyright are not\r\nused to limit the access or legal rights of the compilation's users\r\nbeyond what the individual works permit.  Inclusion of a covered work\r\nin an aggregate does not cause this License to apply to the other\r\nparts of the aggregate.\r\n\r\n  6. Conveying Non-Source Forms.\r\n\r\n  You may convey a covered work in object code form under the terms\r\nof sections 4 and 5, provided that you also convey the\r\nmachine-readable Corresponding Source under the terms of this License,\r\nin one of these ways:\r\n\r\n    a) Convey the object code in, or embodied in, a physical product\r\n    (including a physical distribution medium), accompanied by the\r\n    Corresponding Source fixed on a durable physical medium\r\n    customarily used for software interchange.\r\n\r\n    b) Convey the object code in, or embodied in, a physical product\r\n    (including a physical distribution medium), accompanied by a\r\n    written offer, valid for at least three years and valid for as\r\n    long as you offer spare parts or customer support for that product\r\n    model, to give anyone who possesses the object code either (1) a\r\n    copy of the Corresponding Source for all the software in the\r\n    product that is covered by this License, on a durable physical\r\n    medium customarily used for software interchange, for a price no\r\n    more than your reasonable cost of physically performing this\r\n    conveying of source, or (2) access to copy the\r\n    Corresponding Source from a network server at no charge.\r\n\r\n    c) Convey individual copies of the object code with a copy of the\r\n    written offer to provide the Corresponding Source.  This\r\n    alternative is allowed only occasionally and noncommercially, and\r\n    only if you received the object code with such an offer, in accord\r\n    with subsection 6b.\r\n\r\n    d) Convey the object code by offering access from a designated\r\n    place (gratis or for a charge), and offer equivalent access to the\r\n    Corresponding Source in the same way through the same place at no\r\n    further charge.  You need not require recipients to copy the\r\n    Corresponding Source along with the object code.  If the place to\r\n    copy the object code is a network server, the Corresponding Source\r\n    may be on a different server (operated by you or a third party)\r\n    that supports equivalent copying facilities, provided you maintain\r\n    clear directions next to the object code saying where to find the\r\n    Corresponding Source.  Regardless of what server hosts the\r\n    Corresponding Source, you remain obligated to ensure that it is\r\n    available for as long as needed to satisfy these requirements.\r\n\r\n    e) Convey the object code using peer-to-peer transmission, provided\r\n    you inform other peers where the object code and Corresponding\r\n    Source of the work are being offered to the general public at no\r\n    charge under subsection 6d.\r\n\r\n  A separable portion of the object code, whose source code is excluded\r\nfrom the Corresponding Source as a System Library, need not be\r\nincluded in conveying the object code work.\r\n\r\n  A \"User Product\" is either (1) a \"consumer product\", which means any\r\ntangible personal property which is normally used for personal, family,\r\nor household purposes, or (2) anything designed or sold for incorporation\r\ninto a dwelling.  In determining whether a product is a consumer product,\r\ndoubtful cases shall be resolved in favor of coverage.  For a particular\r\nproduct received by a particular user, \"normally used\" refers to a\r\ntypical or common use of that class of product, regardless of the status\r\nof the particular user or of the way in which the particular user\r\nactually uses, or expects or is expected to use, the product.  A product\r\nis a consumer product regardless of whether the product has substantial\r\ncommercial, industrial or non-consumer uses, unless such uses represent\r\nthe only significant mode of use of the product.\r\n\r\n  \"Installation Information\" for a User Product means any methods,\r\nprocedures, authorization keys, or other information required to install\r\nand execute modified versions of a covered work in that User Product from\r\na modified version of its Corresponding Source.  The information must\r\nsuffice to ensure that the continued functioning of the modified object\r\ncode is in no case prevented or interfered with solely because\r\nmodification has been made.\r\n\r\n  If you convey an object code work under this section in, or with, or\r\nspecifically for use in, a User Product, and the conveying occurs as\r\npart of a transaction in which the right of possession and use of the\r\nUser Product is transferred to the recipient in perpetuity or for a\r\nfixed term (regardless of how the transaction is characterized), the\r\nCorresponding Source conveyed under this section must be accompanied\r\nby the Installation Information.  But this requirement does not apply\r\nif neither you nor any third party retains the ability to install\r\nmodified object code on the User Product (for example, the work has\r\nbeen installed in ROM).\r\n\r\n  The requirement to provide Installation Information does not include a\r\nrequirement to continue to provide support service, warranty, or updates\r\nfor a work that has been modified or installed by the recipient, or for\r\nthe User Product in which it has been modified or installed.  Access to a\r\nnetwork may be denied when the modification itself materially and\r\nadversely affects the operation of the network or violates the rules and\r\nprotocols for communication across the network.\r\n\r\n  Corresponding Source conveyed, and Installation Information provided,\r\nin accord with this section must be in a format that is publicly\r\ndocumented (and with an implementation available to the public in\r\nsource code form), and must require no special password or key for\r\nunpacking, reading or copying.\r\n\r\n  7. Additional Terms.\r\n\r\n  \"Additional permissions\" are terms that supplement the terms of this\r\nLicense by making exceptions from one or more of its conditions.\r\nAdditional permissions that are applicable to the entire Program shall\r\nbe treated as though they were included in this License, to the extent\r\nthat they are valid under applicable law.  If additional permissions\r\napply only to part of the Program, that part may be used separately\r\nunder those permissions, but the entire Program remains governed by\r\nthis License without regard to the additional permissions.\r\n\r\n  When you convey a copy of a covered work, you may at your option\r\nremove any additional permissions from that copy, or from any part of\r\nit.  (Additional permissions may be written to require their own\r\nremoval in certain cases when you modify the work.)  You may place\r\nadditional permissions on material, added by you to a covered work,\r\nfor which you have or can give appropriate copyright permission.\r\n\r\n  Notwithstanding any other provision of this License, for material you\r\nadd to a covered work, you may (if authorized by the copyright holders of\r\nthat material) supplement the terms of this License with terms:\r\n\r\n    a) Disclaiming warranty or limiting liability differently from the\r\n    terms of sections 15 and 16 of this License; or\r\n\r\n    b) Requiring preservation of specified reasonable legal notices or\r\n    author attributions in that material or in the Appropriate Legal\r\n    Notices displayed by works containing it; or\r\n\r\n    c) Prohibiting misrepresentation of the origin of that material, or\r\n    requiring that modified versions of such material be marked in\r\n    reasonable ways as different from the original version; or\r\n\r\n    d) Limiting the use for publicity purposes of names of licensors or\r\n    authors of the material; or\r\n\r\n    e) Declining to grant rights under trademark law for use of some\r\n    trade names, trademarks, or service marks; or\r\n\r\n    f) Requiring indemnification of licensors and authors of that\r\n    material by anyone who conveys the material (or modified versions of\r\n    it) with contractual assumptions of liability to the recipient, for\r\n    any liability that these contractual assumptions directly impose on\r\n    those licensors and authors.\r\n\r\n  All other non-permissive additional terms are considered \"further\r\nrestrictions\" within the meaning of section 10.  If the Program as you\r\nreceived it, or any part of it, contains a notice stating that it is\r\ngoverned by this License along with a term that is a further\r\nrestriction, you may remove that term.  If a license document contains\r\na further restriction but permits relicensing or conveying under this\r\nLicense, you may add to a covered work material governed by the terms\r\nof that license document, provided that the further restriction does\r\nnot survive such relicensing or conveying.\r\n\r\n  If you add terms to a covered work in accord with this section, you\r\nmust place, in the relevant source files, a statement of the\r\nadditional terms that apply to those files, or a notice indicating\r\nwhere to find the applicable terms.\r\n\r\n  Additional terms, permissive or non-permissive, may be stated in the\r\nform of a separately written license, or stated as exceptions;\r\nthe above requirements apply either way.\r\n\r\n  8. Termination.\r\n\r\n  You may not propagate or modify a covered work except as expressly\r\nprovided under this License.  Any attempt otherwise to propagate or\r\nmodify it is void, and will automatically terminate your rights under\r\nthis License (including any patent licenses granted under the third\r\nparagraph of section 11).\r\n\r\n  However, if you cease all violation of this License, then your\r\nlicense from a particular copyright holder is reinstated (a)\r\nprovisionally, unless and until the copyright holder explicitly and\r\nfinally terminates your license, and (b) permanently, if the copyright\r\nholder fails to notify you of the violation by some reasonable means\r\nprior to 60 days after the cessation.\r\n\r\n  Moreover, your license from a particular copyright holder is\r\nreinstated permanently if the copyright holder notifies you of the\r\nviolation by some reasonable means, this is the first time you have\r\nreceived notice of violation of this License (for any work) from that\r\ncopyright holder, and you cure the violation prior to 30 days after\r\nyour receipt of the notice.\r\n\r\n  Termination of your rights under this section does not terminate the\r\nlicenses of parties who have received copies or rights from you under\r\nthis License.  If your rights have been terminated and not permanently\r\nreinstated, you do not qualify to receive new licenses for the same\r\nmaterial under section 10.\r\n\r\n  9. Acceptance Not Required for Having Copies.\r\n\r\n  You are not required to accept this License in order to receive or\r\nrun a copy of the Program.  Ancillary propagation of a covered work\r\noccurring solely as a consequence of using peer-to-peer transmission\r\nto receive a copy likewise does not require acceptance.  However,\r\nnothing other than this License grants you permission to propagate or\r\nmodify any covered work.  These actions infringe copyright if you do\r\nnot accept this License.  Therefore, by modifying or propagating a\r\ncovered work, you indicate your acceptance of this License to do so.\r\n\r\n  10. Automatic Licensing of Downstream Recipients.\r\n\r\n  Each time you convey a covered work, the recipient automatically\r\nreceives a license from the original licensors, to run, modify and\r\npropagate that work, subject to this License.  You are not responsible\r\nfor enforcing compliance by third parties with this License.\r\n\r\n  An \"entity transaction\" is a transaction transferring control of an\r\norganization, or substantially all assets of one, or subdividing an\r\norganization, or merging organizations.  If propagation of a covered\r\nwork results from an entity transaction, each party to that\r\ntransaction who receives a copy of the work also receives whatever\r\nlicenses to the work the party's predecessor in interest had or could\r\ngive under the previous paragraph, plus a right to possession of the\r\nCorresponding Source of the work from the predecessor in interest, if\r\nthe predecessor has it or can get it with reasonable efforts.\r\n\r\n  You may not impose any further restrictions on the exercise of the\r\nrights granted or affirmed under this License.  For example, you may\r\nnot impose a license fee, royalty, or other charge for exercise of\r\nrights granted under this License, and you may not initiate litigation\r\n(including a cross-claim or counterclaim in a lawsuit) alleging that\r\nany patent claim is infringed by making, using, selling, offering for\r\nsale, or importing the Program or any portion of it.\r\n\r\n  11. Patents.\r\n\r\n  A \"contributor\" is a copyright holder who authorizes use under this\r\nLicense of the Program or a work on which the Program is based.  The\r\nwork thus licensed is called the contributor's \"contributor version\".\r\n\r\n  A contributor's \"essential patent claims\" are all patent claims\r\nowned or controlled by the contributor, whether already acquired or\r\nhereafter acquired, that would be infringed by some manner, permitted\r\nby this License, of making, using, or selling its contributor version,\r\nbut do not include claims that would be infringed only as a\r\nconsequence of further modification of the contributor version.  For\r\npurposes of this definition, \"control\" includes the right to grant\r\npatent sublicenses in a manner consistent with the requirements of\r\nthis License.\r\n\r\n  Each contributor grants you a non-exclusive, worldwide, royalty-free\r\npatent license under the contributor's essential patent claims, to\r\nmake, use, sell, offer for sale, import and otherwise run, modify and\r\npropagate the contents of its contributor version.\r\n\r\n  In the following three paragraphs, a \"patent license\" is any express\r\nagreement or commitment, however denominated, not to enforce a patent\r\n(such as an express permission to practice a patent or covenant not to\r\nsue for patent infringement).  To \"grant\" such a patent license to a\r\nparty means to make such an agreement or commitment not to enforce a\r\npatent against the party.\r\n\r\n  If you convey a covered work, knowingly relying on a patent license,\r\nand the Corresponding Source of the work is not available for anyone\r\nto copy, free of charge and under the terms of this License, through a\r\npublicly available network server or other readily accessible means,\r\nthen you must either (1) cause the Corresponding Source to be so\r\navailable, or (2) arrange to deprive yourself of the benefit of the\r\npatent license for this particular work, or (3) arrange, in a manner\r\nconsistent with the requirements of this License, to extend the patent\r\nlicense to downstream recipients.  \"Knowingly relying\" means you have\r\nactual knowledge that, but for the patent license, your conveying the\r\ncovered work in a country, or your recipient's use of the covered work\r\nin a country, would infringe one or more identifiable patents in that\r\ncountry that you have reason to believe are valid.\r\n\r\n  If, pursuant to or in connection with a single transaction or\r\narrangement, you convey, or propagate by procuring conveyance of, a\r\ncovered work, and grant a patent license to some of the parties\r\nreceiving the covered work authorizing them to use, propagate, modify\r\nor convey a specific copy of the covered work, then the patent license\r\nyou grant is automatically extended to all recipients of the covered\r\nwork and works based on it.\r\n\r\n  A patent license is \"discriminatory\" if it does not include within\r\nthe scope of its coverage, prohibits the exercise of, or is\r\nconditioned on the non-exercise of one or more of the rights that are\r\nspecifically granted under this License.  You may not convey a covered\r\nwork if you are a party to an arrangement with a third party that is\r\nin the business of distributing software, under which you make payment\r\nto the third party based on the extent of your activity of conveying\r\nthe work, and under which the third party grants, to any of the\r\nparties who would receive the covered work from you, a discriminatory\r\npatent license (a) in connection with copies of the covered work\r\nconveyed by you (or copies made from those copies), or (b) primarily\r\nfor and in connection with specific products or compilations that\r\ncontain the covered work, unless you entered into that arrangement,\r\nor that patent license was granted, prior to 28 March 2007.\r\n\r\n  Nothing in this License shall be construed as excluding or limiting\r\nany implied license or other defenses to infringement that may\r\notherwise be available to you under applicable patent law.\r\n\r\n  12. No Surrender of Others' Freedom.\r\n\r\n  If conditions are imposed on you (whether by court order, agreement or\r\notherwise) that contradict the conditions of this License, they do not\r\nexcuse you from the conditions of this License.  If you cannot convey a\r\ncovered work so as to satisfy simultaneously your obligations under this\r\nLicense and any other pertinent obligations, then as a consequence you may\r\nnot convey it at all.  For example, if you agree to terms that obligate you\r\nto collect a royalty for further conveying from those to whom you convey\r\nthe Program, the only way you could satisfy both those terms and this\r\nLicense would be to refrain entirely from conveying the Program.\r\n\r\n  13. Use with the GNU Affero General Public License.\r\n\r\n  Notwithstanding any other provision of this License, you have\r\npermission to link or combine any covered work with a work licensed\r\nunder version 3 of the GNU Affero General Public License into a single\r\ncombined work, and to convey the resulting work.  The terms of this\r\nLicense will continue to apply to the part which is the covered work,\r\nbut the special requirements of the GNU Affero General Public License,\r\nsection 13, concerning interaction through a network will apply to the\r\ncombination as such.\r\n\r\n  14. Revised Versions of this License.\r\n\r\n  The Free Software Foundation may publish revised and/or new versions of\r\nthe GNU General Public License from time to time.  Such new versions will\r\nbe similar in spirit to the present version, but may differ in detail to\r\naddress new problems or concerns.\r\n\r\n  Each version is given a distinguishing version number.  If the\r\nProgram specifies that a certain numbered version of the GNU General\r\nPublic License \"or any later version\" applies to it, you have the\r\noption of following the terms and conditions either of that numbered\r\nversion or of any later version published by the Free Software\r\nFoundation.  If the Program does not specify a version number of the\r\nGNU General Public License, you may choose any version ever published\r\nby the Free Software Foundation.\r\n\r\n  If the Program specifies that a proxy can decide which future\r\nversions of the GNU General Public License can be used, that proxy's\r\npublic statement of acceptance of a version permanently authorizes you\r\nto choose that version for the Program.\r\n\r\n  Later license versions may give you additional or different\r\npermissions.  However, no additional obligations are imposed on any\r\nauthor or copyright holder as a result of your choosing to follow a\r\nlater version.\r\n\r\n  15. Disclaimer of Warranty.\r\n\r\n  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\r\nAPPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\r\nHOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY\r\nOF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\r\nTHE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\r\nPURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\r\nIS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\r\nALL NECESSARY SERVICING, REPAIR OR CORRECTION.\r\n\r\n  16. Limitation of Liability.\r\n\r\n  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\r\nWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS\r\nTHE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY\r\nGENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE\r\nUSE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF\r\nDATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD\r\nPARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),\r\nEVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF\r\nSUCH DAMAGES.\r\n\r\n  17. Interpretation of Sections 15 and 16.\r\n\r\n  If the disclaimer of warranty and limitation of liability provided\r\nabove cannot be given local legal effect according to their terms,\r\nreviewing courts shall apply local law that most closely approximates\r\nan absolute waiver of all civil liability in connection with the\r\nProgram, unless a warranty or assumption of liability accompanies a\r\ncopy of the Program in return for a fee.\r\n\r\n                     END OF TERMS AND CONDITIONS\r\n\r\n            How to Apply These Terms to Your New Programs\r\n\r\n  If you develop a new program, and you want it to be of the greatest\r\npossible use to the public, the best way to achieve this is to make it\r\nfree software which everyone can redistribute and change under these terms.\r\n\r\n  To do so, attach the following notices to the program.  It is safest\r\nto attach them to the start of each source file to most effectively\r\nstate the exclusion of warranty; and each file should have at least\r\nthe \"copyright\" line and a pointer to where the full notice is found.\r\n\r\n    <one line to give the program's name and a brief idea of what it does.>\r\n    Copyright (C) <year>  <name of author>\r\n\r\n    This program is free software: you can redistribute it and/or modify\r\n    it under the terms of the GNU General Public License as published by\r\n    the Free Software Foundation, either version 3 of the License, or\r\n    (at your option) any later version.\r\n\r\n    This program is distributed in the hope that it will be useful,\r\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\r\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r\n    GNU General Public License for more details.\r\n\r\n    You should have received a copy of the GNU General Public License\r\n    along with this program.  If not, see <http://www.gnu.org/licenses/>.\r\n\r\nAlso add information on how to contact you by electronic and paper mail.\r\n\r\n  If the program does terminal interaction, make it output a short\r\nnotice like this when it starts in an interactive mode:\r\n\r\n    <program>  Copyright (C) <year>  <name of author>\r\n    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\r\n    This is free software, and you are welcome to redistribute it\r\n    under certain conditions; type `show c' for details.\r\n\r\nThe hypothetical commands `show w' and `show c' should show the appropriate\r\nparts of the General Public License.  Of course, your program's commands\r\nmight be different; for a GUI interface, you would use an \"about box\".\r\n\r\n  You should also get your employer (if you work as a programmer) or school,\r\nif any, to sign a \"copyright disclaimer\" for the program, if necessary.\r\nFor more information on this, and how to apply and follow the GNU GPL, see\r\n<http://www.gnu.org/licenses/>.\r\n\r\n  The GNU General Public License does not permit incorporating your program\r\ninto proprietary programs.  If your program is a subroutine library, you\r\nmay consider it more useful to permit linking proprietary applications with\r\nthe library.  If this is what you want to do, use the GNU Lesser General\r\nPublic License instead of this License.  But first, please read\r\n<http://www.gnu.org/philosophy/why-not-lgpl.html>.\r\n"
  },
  {
    "path": "README.md",
    "content": "<h1 align=\"center\">simplewall</h1>\n\n<p align=\"center\">\n\t<a href=\"https://github.com/henrypp/simplewall/releases\"><img src=\"https://img.shields.io/github/v/release/henrypp/simplewall?style=flat-square&include_prereleases&label=version\" /></a>\n\t<a href=\"https://github.com/henrypp/simplewall/releases\"><img src=\"https://img.shields.io/github/downloads/henrypp/simplewall/total.svg?style=flat-square\" /></a>\n\t<a href=\"https://github.com/henrypp/simplewall/issues\"><img src=\"https://img.shields.io/github/issues-raw/henrypp/simplewall.svg?style=flat-square&label=issues\" /></a>\n\t<a href=\"https://github.com/henrypp/simplewall/graphs/contributors\"><img src=\"https://img.shields.io/github/contributors/henrypp/simplewall?style=flat-square\" /></a>\n\t<a href=\"https://github.com/henrypp/simplewall/blob/master/LICENSE\"><img src=\"https://img.shields.io/github/license/henrypp/simplewall?style=flat-square\" /></a>\n</p>\n\n<p align=\"center\">\n\t<i>Definitely for advanced users.</i>\n</p>\n\n-------\n\n<p align=\"center\">\n\t<img src=\"/images/simplewall.png?cache\" />\n</p>\n\n### Description:\nSimple tool to configure [Windows Filtering Platform (WFP)](https://docs.microsoft.com/en-us/windows/win32/fwp/windows-filtering-platform-start-page) which can configure network activity on your computer.\n\nThe lightweight application is less than a megabyte, and it is compatible with Windows 7 SP1 and higher operating systems.\nYou can download either the installer or portable version. For correct working you are require administrator rights.\n\n### Nota bene:\nKeep in mind, simplewall is not a control UI over Windows Firewall, and does not interact in any level with Windows Firewall. It works\nover Windows Filtering Platform (WFP) which is a set of internal API and system services that provide a platform for creating network filtering\napplications. Windows Filtering Platform is a development technology and not a firewall itself, but simplewall is the tool that uses this technology.\n\n### Features:\n- Simple interface without annoying pop ups\n- [Rules editor](https://github.com/henrypp/simplewall#rules-editor) (create your own rules)\n- [Internal blocklist](https://crazymax.dev/WindowsSpyBlocker/blocking-rules/simplewall/) (block Windows spy / telemetry)\n- Dropped packets information with notification and logging to a file feature (win7+)\n- Allowed packets information with logging to a file feature (win8+)\n- Windows Subsystem for Linux (WSL) support\n- Windows Store support (win8+)\n- Windows services support\n- Free and open source\n- Localization support\n- IPv6 support\n\n```\nTo activate portable mode, create \"simplewall.ini\" in application folder, or move it from \"%APPDATA%\\Henry++\\simplewall\".\n```\n\n### System requirements:\n- Windows 7, 8, 8.1, 10, 11 64-bit/ARM64\n- An SSE2-capable CPU\n- <s>KB2533623</s> [KB3063858](https://www.microsoft.com/en-us/download/details.aspx?id=47442) update for Windows 7 was required\n\n### Donate:\n- [Bitcoin](https://www.blockchain.com/btc/address/1LrRTXPsvHcQWCNZotA9RcwjsGcRghG96c) (BTC)\n- [Ethereum](https://www.blockchain.com/explorer/addresses/eth/0xe2C84A62eb2a4EF154b19bec0c1c106734B95960) (ETH)\n- [Yandex Money](https://yoomoney.ru/to/4100115776040583) (RUB)\n- [Paypal](https://paypal.me/henrypp) (USD)\n\n### GPG Signature:\nBinaries have GPG signature `simplewall.exe.sig` in application folder.\n\n- 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))\n- Key ID: 0x5635B5FD\n- Fingerprint: D985 2361 1524 AB29 BE73 30AC 2881 20A7 5635 B5FD\n\n### Reviews of idiots:\n[<img src=\"/images/idiot_n1.png\" />](https://alternativeto.net/software/simplewall-firewall/about/)\n\nLook at them, he does not know about [.gitmodules](https://github.com/henrypp/simplewall/blob/master/.gitmodules) and how to use, lol.\n\nPS: Without idiots we are not to be fun, yeah!\n\n### Installation:\nWhen install rules, you can choose two modes:\n- Permanent rules - rules are working until you <a href=\"#uninstall\">disable it manually</a>.\n- Temporary rules - rules are reset after the next reboot.\n\n### Uninstall:\nWhen you uninstall simplewall, all previously configured filters stay alive in system.\nTo remove all filters created by simplewall, start simplewall and press \"Disable filters\" button.\n\n### Command line:\n\n~~~\n-install - enable filtering.\n-install -temp - enable filtering until next reboot.\n-install -silent - enable filtering without prompt.\n-uninstall - remove all installed filters.\n~~~\n\n### Rules editor:\nsimplewall have two types of custom user rules rules:\n- **Global rules:** rule applied for all applications.\n- **Special rules:** rule applied only for specified applications.\n\n<img src=\"/images/simplewall_rules.png?cache2\" />\n\n### Rule syntax format:\n\nTo set rule applications, open rule and then navigate to \"Apps\" tab.\n\n<details>\n<summary>Rule syntax format:</summary>\n\n---\n- IP addresses `192.168.0.1; 192.168.0.1; [fc00::]`\n- IP addresses with port `192.168.0.1:80; 192.168.0.1:443; [fc00::]:443;`\n- IP ranges `192.168.0.1-192.168.0.255; 192.168.0.1-192.168.0.255;`\n- IP ranges (with port) `192.168.0.1-192.168.0.255:80; 192.168.0.1-192.168.0.255:443;` (v2.0.20+)\n- IP with prefix lengths (CIDR) `192.168.0.0/16; 192.168.0.0/24; fe80::/10`\n- Ports `21; 80; 443;`\n- Ports ranges `20-21; 49152-65534;`\n\n_To specify more than one ip, port and/or host, use semicolon._\n---\n</details>\n\n<details>\n<summary>IPv4 CIDR blocks:</summary>\n\n---\n| Address format | Mask |\n| -------- | ------- |\n| a.b.c.d/32 | 255.255.255.255 |\n| a.b.c.d/31 | 255.255.255.254 |\n| a.b.c.d/30 | 255.255.255.252 |\n| a.b.c.d/29 | 255.255.255.248 |\n| a.b.c.d/28 | 255.255.255.240 |\n| a.b.c.d/27 | 255.255.255.224 |\n| a.b.c.d/26 | 255.255.255.192 |\n| a.b.c.d/25 | 255.255.255.128 |\n| a.b.c.0/24 | 255.255.255.0|\n| a.b.c.0/23 | 255.255.254.0|\n| a.b.c.0/22 | 255.255.252.0|\n| a.b.c.0/21 | 255.255.248.0|\n| a.b.c.0/20 | 255.255.240.0|\n| a.b.c.0/19 | 255.255.224.0|\n| a.b.c.0/18 | 255.255.192.0|\n| a.b.c.0/17 | 255.255.128.0|\n| a.b.0.0/16 | 255.255.0.0|\n| a.b.0.0/15 | 255.254.0.0|\n| a.b.0.0/14 | 255.252.0.0|\n| a.b.0.0/13 | 255.248.0.0|\n| a.b.0.0/12 | 255.240.0.0|\n| a.b.0.0/11 | 255.224.0.0|\n| a.b.0.0/10 | 255.192.0.0|\n| a.b.0.0/9 | 255.128.0.0|\n| a.0.0.0/8 | 255.0.0.0|\n| a.0.0.0/7 | 254.0.0.0|\n| a.0.0.0/6 | 252.0.0.0|\n| a.0.0.0/5 | 248.0.0.0|\n| a.0.0.0/4 | 240.0.0.0|\n| a.0.0.0/3 | 224.0.0.0|\n| a.0.0.0/2 | 192.0.0.0|\n| a.0.0.0/1 | 128.0.0.0|\n| 0.0.0.0/0 | 0.0.0.0|\n---\n</details>\n\n<details>\n<summary>IPv6 CIDR blocks:</summary>\n\n---\n[IPv6 CIDR blocks](https://www.mediawiki.org/wiki/Help:Range_blocks/IPv6)\n---\n</details>\n\n### FAQ:\n#### Q: Are internet connections blocked when simplewall is not running?\nA: Yes. Installed filters are working even if simplewall is terminated.\n\n#### Q: What apps are blocked in default configuration?\nA: By default, simplewall blocks **all** applications. You do not need to create custom rules to block specific applications.\n\n#### Q: Is it safe to use simplewall with Windows Firewall?\nA: Yes. You do not need to disable Windows Firewall. These two firewalls work independently.\n\n#### Q: How can i disable blocklist entirely?\nA: Open `Settings` -> `Blocklist` and then click the radio buttons labeled `Disable`.\n\n#### Q: Where is blacklist mode?\nA: Blacklist was removed many days ago for uselessness. But if you need it, you can still configure it.\n\n<details>\n<summary>Solution: Configure blacklist mode in simplewall:</summary>\n\n---\n1) Open `Settings` -> `Rules`\n2) Uncheck `Block outbound for all` and `Block inbound for all` options.\n3) Create user rule (green cross on toolbar) with block action, any direction, `Block connection` name and empty remote and local rule.\n4) You can assign this rule for apps whatever you want to block network access.\n---\n</details>\n\n#### Q: Why does my network icon have an exclamation mark?\nA: When you are connected to a network, Windows checks for internet connectivity using Active Probing. This feature is named as NCSI (Network Connectivity Status Indicator). You can resolve this problem in one of the following ways:\n\n<details>\n<summary>Solution 1: Enable NCSI through internal system rule:</summary>\n\n---\n1) Open `System rules` tab.\n2) Allow `NCSI` rule (enabled by default).\n---\n</details>\n\n<details>\n<summary>Solution 2: Disable NCSI through system registry:</summary>\n\n---\nCreate `Disable NCSI.reg` and import it into registry.\n\n```reg\nWindows Registry Editor Version 5.00\n\n[HKEY_LOCAL_MACHINE\\SOFTWARE\\Policies\\Microsoft\\Windows\\NetworkConnectivityStatusIndicator]\n\"NoActiveProbe\"=dword:00000001\n\"DisablePassivePolling\"=dword:00000001\n```\n---\n</details>\n\n<details>\n<summary>Solution 3: Disable NCSI through group policy:</summary>\n\n---\n1) Launch the group policy editor (`gpedit.msc` ).\n2) Go to `Computer Configuration -> Administrative Templates -> System -> Internet Communication Management -> Internet Communication Settings`.\n3) Double-click `Turn off Windows Network Connectivity Status Indicator active tests` and then select Enabled. Click Ok.\n4) Open the Command Prompt (Admin) and enter `gpupdate /force` to enforce the changes made to the Group Policies.\n---\n</details>\n\n#### Q: How can I disable Windows Firewall?\nStart the command line _as an administrator_, and enter the commands below.\n\n<details>\n<summary>Disable Windows Firewall profiles:</summary>\n\n---\n~~~bat\nnetsh advfirewall set allprofiles state off\n~~~\n---\n</details>\n\n<details>\n<summary>Enable Windows Firewall profiles:</summary>\n\n---\n~~~bat\nnetsh advfirewall set allprofiles state on\n~~~\n---\n</details>\n\n#### Q: How can I view all filters information?\nStart the command line _as an administrator_, and enter the commands below.\n\n<details>\n<summary>Dump filters information saved into a `filters.xml` file:</summary>\n\n---\n~~~bat\ncd /d %USERPROFILE%\\Desktop\n\nnetsh wfp show filters\n~~~\n---\n</details>\n\n<details>\n<summary>Dump providers, callouts and layers information into a `wfpstate.xml` file:</summary>\n\n---\n~~~bat\ncd /d %USERPROFILE%\\Desktop\n\nnetsh wfp show state\n~~~\n---\n</details>\n\nOpen it in any text editor and study.\n\n#### Q: How to fix Windows Update internet access?\n<details>\n<summary>Windows 10 and above:</summary>\n\n---\nOpen main window menu `Settings` -> `Rules` -> `Allow Windows Update`.\n<br />\nThis is working by method described [here](https://github.com/henrypp/simplewall/issues/677).\n\n---\n</details>\n\n<details>\n<summary>Windows 8.1:</summary>\n\n---\nOpen main window, Navigate into `System rules` tab and then enable `Windows Update service` rule.\n\n---\n</details>\n\n#### Q: Other questions:\n- [Windows Security center integration (impossible)](https://stackoverflow.com/questions/3698285/how-can-i-tell-the-windows-security-center-that-im-an-antivirus/3698375#3698375)\n---\n- Website: [github.com/henrypp](https://github.com/henrypp)\n- Support: sforce5@mail.ru\n---\n(c) 2016-2026 Henry++\n"
  },
  {
    "path": "VERSION",
    "content": "simplewall=3.8.7|https://github.com/henrypp/simplewall/releases/download/v.3.8.7/simplewall-3.8.7-setup.exe;\nlanguage=1770315696|https://raw.githubusercontent.com/henrypp/simplewall/master/bin/simplewall.lng;\nrules_internal=1717635779|https://raw.githubusercontent.com/henrypp/simplewall/master/bin/profile_internal.sp;\n"
  },
  {
    "path": "bin/History.txt",
    "content": "v3.8.7 (8 August 2025)\r\n- fixed not logical crash (issue #2012)\r\n- fixed context menu performance\r\n- updated locale (issue #1984)\r\n- updated project sdk\r\n- cosmetic fixes\r\n\r\nv3.8.6.1 (21 May 2025)\r\n- fixed \"open containing folder\" error (issue #1977)\r\n- fixed crash at startup (issue #1979)\r\n- fixed crash dump (issue #1958)\r\n\r\nv3.8.6 (1 April 2025)\r\n- fixed check for update, does not bring up popup (issue #1923)\r\n- fixed memory heap error (issue #1945)\r\n- fixed possible crash\r\n- improved dark theme support\r\n\r\nv3.8.5 (27 November 2024)\r\n- fixed adding apps with drive letters instead of specific apps (issue #1887)\r\n- fixed creating rules for inaccessible paths (issue #1891)\r\n- fixed opening log with spaces path (issue #1912)\r\n- fixed windows 7 loopback rules\r\n- cosmetic fixes\r\n\r\nv3.8.4 (11 September 2024)\r\n- added listview empty markup\r\n- fixed tray icon middle click not worked when log ui is disabled\r\n- fixed notification displays invalid signature (issue #1871)\r\n- fixed does not show up tray icon (issue #1844)\r\n- fixed crash when cleanup timers (issue #1860)\r\n- fixed possible memory leak\r\n- updated project sdk\r\n- updated rule hint\r\n- cosmetic fixes\r\n\r\nv3.8.3 (8 August 2024)\r\n- added remember last position of notification window (issue #1659)\r\n- added watch services & uwp apps for install/uninstall\r\n- added displays long time for apps\r\n- improved windows 7 compatibility\r\n- improved arm64 compatibility\r\n- improved dark theme support\r\n- fixed show log button does not work as expected (issue #1757, again!)\r\n- fixed apps sometimes delete themselves (issue #1794, not fixed)\r\n- fixed duplicate process at startup (issue #1769)\r\n- fixed do not save hash when it is not enabled\r\n- fixed row colors for dark mode (issue #1767)\r\n- fixed log listview sorting by date\r\n- fixed displaying timer tooltip\r\n- updated project sdk\r\n\r\nv3.8.2 (9 May 2024)\r\n- revert back windows 7 & windows 8 support\r\n- improved dark theme support\r\n- improved log subscription\r\n- fixed show log button does not work as expected (issue #1757)\r\n- fixed search visibility\r\n\r\nv3.8.1 (27 April 2024)\r\n- fixed lacks search context (issue #1760)\r\n- fixed incorrect log ui listview item counting\r\n- updated confirm message for timers cleanup\r\n- updated confirm message for unused cleanup\r\n- updated cppwinrt package\r\n- updated project sdk\r\n\r\nv3.8 (1 April 2024)\r\n- added mitigations (win10+) (issue #611)\r\n- added dark theme support (issue #248)\r\n- fixed displaying same context menu on apps and packets log\r\n- updated search engine\r\n- updated project sdk\r\n\r\nv3.7.8 (28 January 2024)\r\n- added saving flag state for install/uninstall filters\r\n- fixed crash on tooltip (issue #1686)\r\n- fixed apps disabled removal menu\r\n- updated dropped packets (ui) listview context menu\r\n- updated project sdk\r\n\r\nv3.7.7 (3 January 2024)\r\n- added error message when loading library on subscribe\r\n- added comment item for apps/rules (issue #1664)\r\n- added recheck app hash in properies dialog\r\n- added highlighting of undelatable apps\r\n- fixed displaying incorrect error messages\r\n- fixed high disk usage (issue #1665)\r\n- updated ports list\r\n\r\nv3.7.6 (30 November 2023)\r\n- fixed configuration of windows update (issue #1648)\r\n- fixed auto update fails to install (issue #1565)\r\n- updated project sdk\r\n\r\nv3.7.5 (1 November 2023)\r\n- fixed saving services and uwp apps (issue #1616)\r\n- fixed file locked by simplewall (issue #1621)\r\n- fixed removing unused apps\r\n- fixed process creation\r\n- updated project sdk\r\n\r\nv3.7.4 (27 October 2023)\r\n- added set option to disable apps removal from profile (issue #1155)\r\n- fixed cannot save itself as unchecked (issue #1609)\r\n- fixed could not save profile (issue #1594)\r\n- fixed crash (issue #1582)\r\n- updated project sdk\r\n\r\nv3.7.3 (11 October 2023)\r\n- added error message for saving profile\r\n- removed redistributable package requirement (issue #1587)\r\n- fixed profile was not found message (issue #1557)\r\n- fixed crash on reading version information\r\n- revert back certificates checking option\r\n- updated project sdk\r\n\r\nv3.7.2 (21 September 2023)\r\n- dropped windows 7 and windows 8 support\r\n- fixed launch of several copies of the application (issue #1547)\r\n- fixed create filters for inaccessible apps (issue #1528)\r\n- fixed displaying update dialog at startup (issue #1511)\r\n- fixed retrieving version information for some files\r\n- fixed slow apps search (issue #1477)\r\n- fixed periodicaly crashing (issue #1486)\r\n- fixed retrieving some apps icons\r\n- fixed saving input on settings\r\n- fixed saving unused apps\r\n- fixed process creation\r\n- improved signature checking\r\n- updated project sdk\r\n\r\nv3.7.1 (31 July 2023)\r\n- fixed import not correcly worked (issue #1466)\r\n- fixed crash when checking files (issue #1455)\r\n- updated project sdk\r\n\r\nv3.7 (27 July 2023)\r\n- added profile encryption [oldest versions cannot open new profile] (issue #599)\r\n- added terminate process into notification window (issue #1398)\r\n- added checksum calculation for the apps (issue #394)\r\n- added error message for log subscription\r\n- improved search performance (issue #1383)\r\n- fixed timer and apps timestamp displays incorrect information (32-bit only)\r\n- fixed sometimes application displays incrorrect icons\r\n- fixed possible crash when clearing log\r\n- fixed silent uninstaller do not worked\r\n- fixed arm64 build crash (issue #1228)\r\n- fixed internal bugs\r\n- fixed memory leaks\r\n- updated nuget package\r\n- updated project sdk\r\n- updated locale\r\n\r\nv3.6.7 (21 September 2022)\r\n- added windows update service solution (issue #677, thx @taviso) [win10+]\r\n- added feature to allow only the requested ip in notification (issue #1265)\r\n- added 12 and 24 hour timer values (issue #1298)\r\n- fixed opening editor are overlapped by notification window\r\n- fixed uwp apps are reset after installing updates (issue #1294)\r\n- fixed select all with search filter selects everything (issue #1264)\r\n- fixed loading default icons for services and uwp apps\r\n- fixed check update option in main menu (issue #1309)\r\n- fixed port numbers are now verified (issue #1240)\r\n\r\nv3.6.6 (12 August 2022)\r\n- fixed editor does not disable save button when rule name is empty\r\n- fixed network monitor duplicate calls\r\n- fixed application crash (issue #1272)\r\n\r\nv3.6.5 (11 August 2022)\r\n- added group for apps with timers\r\n- display long time in packets log date column\r\n- fixed uwp packages display name parsing\r\n- fixed blank notifications (again!) (issue #1009)\r\n\r\nv3.6.4 (19 Juny 2022)\r\n- added focus assistant support (win10rs3+)\r\n- fixed notification sometimes can lose focus of fullscreen app\r\n- fixed internal profile loading crash (issue #1228)\r\n\r\nv3.6.3 (10 May 2022)\r\n- fixed installer launches simplewall without asking user (issue #1119)\r\n- fixed saving unused apps in profile (issue #1216)\r\n- fixed app crash on create process (issue ##1224)\r\n- fixed uninstaller delete not all files\r\n- improved workqueue environment\r\n- improved threading model\r\n- fixed internal bugs\r\n\r\nv3.6.2 (26 April 2022)\r\n- added autoinstall non-executable updates feature (issue #1122)\r\n- added clear search with escape button for editor\r\n- added fallback for font loading when it does not exists\r\n- improved uwp packages information loading\r\n- fixed restore properties window position\r\n- fixed rule tooltip whitespace\r\n- fixed internal bugs\r\n- updated network monitor\r\n- updated locales\r\n- cosmetic fixes\r\n\r\nv3.6.1 (11 November 2021)\r\n- added clear search with escape button\r\n- fixed crash on delete filters (issue #1084)\r\n- fixed import profile warning (issue #1086)\r\n- fixed crash dumps processing\r\n- updated locales\r\n- cosmetic fixes\r\n\r\nv3.6 (9 November 2021)\r\n- improved multi-threading safety\r\n- improved startup time\r\n- improved dpi support\r\n- added option to confirm allowing applications (issue #1070)\r\n- added filtering for the application list (issue #663)\r\n- added editor list items count mark for tab title\r\n- added wfp initialization failure workaround\r\n- added filtering for editor apps and rules\r\n- added layer name into log\r\n- moved log exclude configuration into another settings page (issue #1064)\r\n- revert notification x button (issue #973)\r\n- changed create rule toolbar icon (#723)\r\n- fixed filters with hard permit can access internet (issue #689)\r\n- fixed issue with hotkeys for switch tabs (issue #723)\r\n- fixed rebar incrorrect resizing when dpi was changed\r\n- fixed update installation issue (issue #1061)\r\n- fixed notification multi-monitor support\r\n- fixed service missing path (issue #1036)\r\n- fixed editor can cause crash (#1071)\r\n- fixed big memory leak (issue #1066)\r\n- fixed net events unsubscription\r\n- optimized listview sorting\r\n- fixed internal bugs\r\n- cosmetic fixes\r\n\r\nv3.5.3 (18 October 2021)\r\n- fixed using uninitialzed port variable in ip ranges [regression] (issue #1055)\r\n\r\nv3.5.2 (17 October 2021)\r\n- builded with windows 11 sdk\r\n- fixed port can be omited when parsing ip ranges (issue #1010)\r\n- fixed remote range replaces local range (issue #1044)\r\n- fixed interface stuck by comctl library (issue #1009)\r\n- fixed massive gdi handles leak\r\n- fixed internal bugs\r\n\r\nv3.5.1 (6 October 2021)\r\n- optimized certificate checking\r\n- fixed check apps for digital signatures option not works (issue #1037)\r\n- fixed lock to avoid duplicate file information loading\r\n- fixed crash on profile loading (issue #1033)\r\n\r\nv3.5 (4 October 2021)\r\n- in this release fqdn support was removed because of security issue (issues #1012)\r\n- improved performance due caching network resolution and file information\r\n- partially revert of windows defender power off (issue #1022)\r\n- added ballon tip to display input limitations (issue #809)\r\n- added compress internal profile in resources with lznt1\r\n- fixed signatures information pointer use-after-free when dns resolver avoid arpa requests (issue #1008)\r\n- fixed resolve network addresses can cause crash (issue #1015)\r\n- fixed notification color issues (issue #1007)\r\n- fixed update installation (issue #1016)\r\n- fixed version information retrieval\r\n- fixed workqueue environment\r\n- fixed internal bugs\r\n\r\nv3.4.3 (30 August 2021)\r\n- added verify code signatures from catalog files (issue #1003)\r\n- fixed crash at startup (issue #995)\r\n- fixed rule reference (issue #1002)\r\n\r\nv3.4.2 (24 August 2021)\r\n- enable checking apps certificates by default\r\n- show notifications immediately without waiting for busy operations to complete\r\n- impoved listview responsiveness by using virtual listview callback\r\n- fixed packets log displays incorrect direction (issue #945)\r\n- fixed missed listview icons on refresh\r\n- fixed thread environment\r\n- fixed internal bugs\r\n- cosmetic fixes\r\n\r\nv3.4.1 (15 August 2021)\r\n- fixed blocklist can does not change action status\r\n- fixed crash at startup (issue #976)\r\n- fixed profile import compatibility\r\n- fixed install update\r\n\r\nv3.4 (11 August 2021)\r\n- added arm64 binaries (portable only)\r\n- added protocol and host name information into network alert window (issue #843)\r\n- added limit number of packets log entries (issue #941)\r\n- added host resolving for packet logger listview\r\n- added listview group for forever blocked apps\r\n- fixed loading icons of each application freezes interface (issue #830)\r\n- fixed log listview can have empty lines due to race condition\r\n- fixed ui not properly display installation status (issue #962)\r\n- fixed memory leak when loading profile (issue #888, #937)\r\n- fixed high cpu usage for packet logger (issue #949)\r\n- updated system rules\r\n- updated project sdk\r\n- fixed internal bugs\r\n\r\nv3.3.5 (5 July 2021)\r\n- added command line short opts\r\n- use guid for tray icon\r\n- updated project sdk\r\n- fixed toolbar glitch on hidpi displays (issue #950)\r\n- fixed multi-monitor with diffirent dpi support\r\n- fixed installer creates unused files\r\n- fixed internal bugs\r\n\r\nv3.3.4 (3 June 2021)\r\n- autoclean packets log ui when system suspended\r\n- fixed config may not be saved when profile directory does not exist\r\n- fixed unnecessary checking for app paths attributes\r\n- fixed threadpool does not initialized com library\r\n- fixed installer silent mode (issue #907)\r\n- updated blocklist and system rules\r\n- fixed internal bugs\r\n\r\nv3.3.3 (29 April 2021)\r\n- fixed listview tooltip can cause crash (issue #890)\r\n- fixed editor does not create filters for the app\r\n- fixed incorrect shared icons behaviour\r\n- fixed interlocked operations logic\r\n- fixed caching behaviour\r\n- fixed internal bugs\r\n\r\nv3.3.2 Beta (23 April 2021)\r\n- added half an hour timer\r\n- added missing spinlocks\r\n- fixed file write operation can cause crash\r\n- fixed path unexpand does not worked\r\n- fixed running log viewer\r\n- fixed little memory leak\r\n- fixed bugs\r\n\r\nv3.3.1 Beta (16 April 2021)\r\n- added workaround for native paths on profile loading (issue #817)\r\n- fixed net events does not subscribe on os version lower than 1607\r\n\r\nv3.3 Beta (15 April 2021)\r\n- added option for tray icon to open window in single click\r\n- added warning message for allowing service host\r\n- added quic service for internal rules (issue #819)\r\n- added multiple rules at once in rules editor\r\n- added properties dialog for apps\r\n- added index column for logs\r\n- added sorting for logs\r\n- do not mark apps as unused if it applied for rules\r\n- set limit for rules popup menu (issue #692)\r\n- increased speed of service enumeration\r\n- removed notification ignore button\r\n- use threadpool for timers\r\n- improved multi-monitor support\r\n- improved listviews highlighting\r\n- improved file dialogs\r\n- fixed rule window does not display rule length limitation (issue #867)\r\n- fixed update period timestamp does not set correctly (issue #745)\r\n- fixed crash when user uses ipv6 range in rules (issue #822)\r\n- fixed support filesystems with custom driver (issue #817)\r\n- fixed blank notification window (issue #775)\r\n- fixed dependencies load flags for win10rs1+\r\n- fixed crash on app startup (issue #775)\r\n- updated project sdk\r\n- cosmetic fixes\r\n- fixed bugs\r\n\r\nv3.2.4 (5 September 2020)\r\n- removed assertion from release builds (issue #764)\r\n- removed user service instance from the list (win10+)\r\n- fixed parsing not existing apps (issue #732, #739)\r\n- displays incorrect name on timer expiration\r\n- check app timer expiration on profile load\r\n- incorrect read-only rules tooltip markup\r\n- create filter does not report errors\r\n- fixed checking of file attributes\r\n- fixed parsing ip/port ranges\r\n- cosmetic fixes\r\n- fixed bugs\r\n\r\nv3.2.3 (25 August 2020)\r\n- added ncsi system rule (issue #709)\r\n- added command line mutex checking (issue #750)\r\n- added noficitation window redraw (issue #731)\r\n- use logical sorting order (issue #735)\r\n- check for provider status before create filters\r\n- do not highlight connections in log tab\r\n- fixed support oldest win7 versions (issue #737)\r\n- removed listview empty markup\r\n- cosmetic fixes\r\n- fixed bugs\r\n\r\nv3.2.2 (29 July 2020)\r\n- user rules broken with 3.2.1 (issue #729)\r\n\r\nv3.2.1 (29 July 2020)\r\n- added Enable silent-mode when full screen app in foreground option\r\n- added error message for createprocess failure (issue #720)\r\n- highlighting valid connections in network tab\r\n- changed \"Disabled apps\" group title into \"Apps without internet access\"\r\n- skip uac warning does not worked (issue #724)\r\n- notification window localized in english only\r\n- revert ip version selection ipv4/ipv6 in rules editor (issue #723)\r\n- revert expand rules in tooltip (issue #723)\r\n- revert \"recommended\" tag (fix #719)\r\n- fixed bugs\r\n\r\nv3.2 Beta (18 July 2020)\r\n- new rules editor\r\n- added option \"IsInternalRulesDisabled\" for completely disable internal rules (issue #630)\r\n- added temporary filtering mode whether is active until reboot (issue #576)\r\n- added packets logging interface (issue #672)\r\n- added tile view for listview\r\n- added information for export profile failure (issue #707)\r\n- improved tooltips details for apps and rules\r\n- improved listview resizing performance\r\n- changed \"Enabled apps\" group title into \"Apps with internet access\"\r\n- now highlight app with user rules only when user rules group is disabled\r\n- removed compatibility with v2 profile databases\r\n- removed special group for rules\r\n- removed user id from title\r\n- fixed local network connection treats as valid network connection (issue #579)\r\n- fixed notification window will bring focus to it's parent window (issue #668)\r\n- fixed \"/uninstall\" argument does not removing filters (issue #645)\r\n- fixed wfp engine security violation (issue #680)\r\n- fixed support custom windows themes (issue #701)\r\n- fixed getting uwp app paths and timestamps\r\n- fixed dpi support (issue #693)\r\n- fixed internal upnp rule\r\n- fixed bugs\r\n\r\nv3.1.2 (26 March 2020)\r\n- reverted disable windows firewall on startup (issue #559 and #562)\r\n- fixed application cannot be started because of continuously restart\r\n- fixed possible duplicate apps entries with short path (issue #640)\r\n- fixed network alert steals the focus (issue #637)\r\n- fixed network paths parsing (issue #629)\r\n- fixed netbios direction (issue #636)\r\n- fixed localization (issue #607)\r\n- fixed bugs\r\n\r\nv3.1.1 (27 February 2020)\r\n- fixed displaying tooltips for non-existing apps in network tab (issue #422)\r\n- fixed wsl apps do not display names in the network tab (issue #606)\r\n- fixed incorrect default locale name on some systems (issue #621)\r\n- fixed process mitigation policy (win10rs2+) (issue #611)\r\n- fixed persistent dark theme (win10rs5+) (issue #609)\r\n- fixed update window does not close (issue #616)\r\n- fixed log cleanup (issue #613)\r\n- updated blocklist\r\n- fixed bugs\r\n\r\nv3.1 (8 February 2020)\r\n- changed compiler build settings\r\n- changed settings interface\r\n- improved windows 10 1903+ suppport\r\n- show log cleanup confirmation only when it has entries\r\n- fixed notification tabstop processing (issue #497) by @flipkick\r\n- fixed downloading updates progress gets stuck (issue #568)\r\n- fixed find dialog does not worked correctly (issue #511)\r\n- fixed drawing filename in notification (issue #595)\r\n- fixed adjust privileges (theoretically fixes #596)\r\n- fixed inbound direction recognition (issue #581)\r\n- fixed search for next/active notification\r\n- fixed notification hotkeys (issue #597)\r\n- fixed memory duplicate allocation\r\n- updated project sdk (routine++)\r\n- updated ports definitions\r\n- updated blocklist\r\n- fixed bugs\r\n\r\nv3.0.9 (15 November 2019)\r\n- do not set notification to top when fullscreen apps working\r\n- fixed disable notifications for app from notification (issue #563)\r\n- fixed crash on system settings changing (issue #552)\r\n- fixed winhttp encoding conversion (issue #568)\r\n- fixed statusbar glitch (issue #569)\r\n- updated blocklist\r\n- fixed bugs\r\n\r\nv3.0.8 (8 November 2019)\r\n- removed disable windows firewall on startup (issue #554)\r\n- updated default timer values (issue #340)\r\n- fixed non-default system dpi (issue #544)\r\n- fixed overwrite notifications\r\n- fixed crash (issue #552)\r\n- cosmetics fixes\r\n- fixed bugs\r\n\r\nv3.0.7 (1 November 2019)\r\n- improved dpi support (win81+)\r\n- fixed ended timer handling on restart\r\n- fixed regular update message (issue #543)\r\n- fixed components update installation\r\n- fixed window and listview sizing\r\n- updated project sdk\r\n- updated blocklist\r\n- cosmetics fixes\r\n- fixed bugs\r\n\r\nv3.0.6 RC (12 October 2019)\r\n- added windows 10 1903+ support\r\n- added csv file title (clear the log to see changes)\r\n- disable network address resolution in network tab by default (issue #515)\r\n- improved refreshing filters on device connecting\r\n- improved network monitoring speed and ui\r\n- improved notification ui\r\n- improved dpi support (win81+)\r\n- fixed collecting services & uwp information\r\n- fixed device names resolution (issue #529)\r\n- fixed toolbar gray text draw (issue #437)\r\n- fixed network items blinking on refresh\r\n- fixed flickering on window resizing\r\n- fixed notification windows refresh\r\n- fixed hostname restricted symbols\r\n- fixed wfp security attributes\r\n- fixed highlighting priority\r\n- fixed memory leak\r\n- updated system rules\r\n- cosmetics fixes\r\n- fixed bugs\r\n\r\nv3.0.5 RC (6 August 2019)\r\n- added option to block outbound connections globally\r\n- added close connection feature (issue #506)\r\n- added powerful blocklist configuration\r\n- removed listen layer\r\n- skip saving default rules configuration\r\n- fixed connections port byte order (issue #504)\r\n- fixed user rules ui bug (issue #500)\r\n- fixed dropped packets log layout\r\n- fixed internal rules editor\r\n- fixed ipv6 rule formatting (issue #475)\r\n- fixed connections hashing\r\n- listview menu cosmetics\r\n- cosmetics fixes\r\n- fixed bugs\r\n\r\nv3.0.4 RC (23 July 2019)\r\n- added rules and blocklist options into main menu\r\n- set security settings enabled by default\r\n- set protocol names based on IEEE\r\n- made correct backups for profile on reset\r\n- bring notification window to top\r\n- correct determine connections for apps\r\n- fixed error message on new device insertion (issue #215)\r\n- fixed missing connections (issue #423)\r\n- fixed listview sorting does not save state sometimes\r\n- fixed listview sorting compare checked items\r\n- fixed uninstaller does not remove new profile\r\n- fixed tray menu notifications cosmetics\r\n- optimized group items counting\r\n- optimized listview sorting\r\n- cosmetics fixes\r\n- fixed bugs\r\n\r\nv3.0.3 Beta (3 July 2019)\r\n- added option to show notification window on tray\r\n- added highlighting for network tab\r\n- redraw app item on connection change\r\n- remove \"beta\" mark from network tab\r\n- improved wfp transactions\r\n- fixed ipv6 rules port parsing for system rules (issue #475)\r\n- fixed direction case for log and notification (issue #474)\r\n- fixed notification action adds timer (issue #472)\r\n- fixed timer set does not work (issue #484)\r\n- fixed notification refresh when app remove\r\n- fixed configuration reset does not work\r\n- fixed menu graphics (issue #473)\r\n- fixed log stack cleanup\r\n- updated port service names\r\n- cosmetics fixes\r\n- fixed bugs\r\n\r\nv3.0.2 Beta (22 Juny 2019)\r\n- new notification ui\r\n- allow microsoft update & microsoft apps servers by default\r\n- added information about ports into the log\r\n- moved icmp4 and icmp6 rules into custom rules\r\n- improved dropped packets log markup cosmetics\r\n- improved network monitoring speed\r\n- improved blocklist configuration\r\n- fixed saving special rules for uwp apps and services (issue #454)\r\n- fixed tray icon dissapear sometimes (issue #450)\r\n- fixed profile import does not work (issue #445)\r\n- fixed semicolons in app paths (issue #462)\r\n- fixed windows 20h1 uwp apps loading crash\r\n- fixed parsing rules with \"*\"\r\n- updated locales\r\n- cosmetic fixes\r\n- fixed bugs\r\n\r\nv3.0.1 Beta (22 May 2019)\r\n- new profile structure\r\n- added checking for correct xml file format before import\r\n- added service name resolution for connections\r\n- added Reverse DNS Lookup for IP\r\n- more flexible autoresizing for listview\r\n- fixed column size initialization (issue #426)\r\n- fixed apps list sorting by date (issue #412)\r\n- fixed status refreshing on timer deletion\r\n- fixed table view for rules (issue #438)\r\n- fixed connections recognition condition\r\n- fixed highlighting (issue #408)\r\n- fixed timers sets (issue #424)\r\n- fixed services icons\r\n- updated locales\r\n- cosmetic fixes\r\n- fixed bugs\r\n\r\nv3.0 Beta (7 May 2019)\r\n- dropped windows vista support\r\n- improved dpi support (ui)\r\n- moved rules list into main window\r\n- added services and uwp apps tab\r\n- added network connections monitor\r\n- fixed displaying notifications when it's disabled\r\n- fixed log file write through (issue #369)\r\n- fixed notifications safety timeout\r\n- fixed possible race conditions\r\n- fixed services path retrieve\r\n- fixed notifications cleanup\r\n- improved listview resizing\r\n- improved listview sorting\r\n- removed blacklist mode\r\n- cosmetic fixes\r\n- fixed bugs\r\n"
  },
  {
    "path": "bin/License.txt",
    "content": "                    GNU GENERAL PUBLIC LICENSE\r\n                       Version 3, 29 June 2007\r\n\r\n Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>\r\n Everyone is permitted to copy and distribute verbatim copies\r\n of this license document, but changing it is not allowed.\r\n\r\n                            Preamble\r\n\r\n  The GNU General Public License is a free, copyleft license for\r\nsoftware and other kinds of works.\r\n\r\n  The licenses for most software and other practical works are designed\r\nto take away your freedom to share and change the works.  By contrast,\r\nthe GNU General Public License is intended to guarantee your freedom to\r\nshare and change all versions of a program--to make sure it remains free\r\nsoftware for all its users.  We, the Free Software Foundation, use the\r\nGNU General Public License for most of our software; it applies also to\r\nany other work released this way by its authors.  You can apply it to\r\nyour programs, too.\r\n\r\n  When we speak of free software, we are referring to freedom, not\r\nprice.  Our General Public Licenses are designed to make sure that you\r\nhave the freedom to distribute copies of free software (and charge for\r\nthem if you wish), that you receive source code or can get it if you\r\nwant it, that you can change the software or use pieces of it in new\r\nfree programs, and that you know you can do these things.\r\n\r\n  To protect your rights, we need to prevent others from denying you\r\nthese rights or asking you to surrender the rights.  Therefore, you have\r\ncertain responsibilities if you distribute copies of the software, or if\r\nyou modify it: responsibilities to respect the freedom of others.\r\n\r\n  For example, if you distribute copies of such a program, whether\r\ngratis or for a fee, you must pass on to the recipients the same\r\nfreedoms that you received.  You must make sure that they, too, receive\r\nor can get the source code.  And you must show them these terms so they\r\nknow their rights.\r\n\r\n  Developers that use the GNU GPL protect your rights with two steps:\r\n(1) assert copyright on the software, and (2) offer you this License\r\ngiving you legal permission to copy, distribute and/or modify it.\r\n\r\n  For the developers' and authors' protection, the GPL clearly explains\r\nthat there is no warranty for this free software.  For both users' and\r\nauthors' sake, the GPL requires that modified versions be marked as\r\nchanged, so that their problems will not be attributed erroneously to\r\nauthors of previous versions.\r\n\r\n  Some devices are designed to deny users access to install or run\r\nmodified versions of the software inside them, although the manufacturer\r\ncan do so.  This is fundamentally incompatible with the aim of\r\nprotecting users' freedom to change the software.  The systematic\r\npattern of such abuse occurs in the area of products for individuals to\r\nuse, which is precisely where it is most unacceptable.  Therefore, we\r\nhave designed this version of the GPL to prohibit the practice for those\r\nproducts.  If such problems arise substantially in other domains, we\r\nstand ready to extend this provision to those domains in future versions\r\nof the GPL, as needed to protect the freedom of users.\r\n\r\n  Finally, every program is threatened constantly by software patents.\r\nStates should not allow patents to restrict development and use of\r\nsoftware on general-purpose computers, but in those that do, we wish to\r\navoid the special danger that patents applied to a free program could\r\nmake it effectively proprietary.  To prevent this, the GPL assures that\r\npatents cannot be used to render the program non-free.\r\n\r\n  The precise terms and conditions for copying, distribution and\r\nmodification follow.\r\n\r\n                       TERMS AND CONDITIONS\r\n\r\n  0. Definitions.\r\n\r\n  \"This License\" refers to version 3 of the GNU General Public License.\r\n\r\n  \"Copyright\" also means copyright-like laws that apply to other kinds of\r\nworks, such as semiconductor masks.\r\n\r\n  \"The Program\" refers to any copyrightable work licensed under this\r\nLicense.  Each licensee is addressed as \"you\".  \"Licensees\" and\r\n\"recipients\" may be individuals or organizations.\r\n\r\n  To \"modify\" a work means to copy from or adapt all or part of the work\r\nin a fashion requiring copyright permission, other than the making of an\r\nexact copy.  The resulting work is called a \"modified version\" of the\r\nearlier work or a work \"based on\" the earlier work.\r\n\r\n  A \"covered work\" means either the unmodified Program or a work based\r\non the Program.\r\n\r\n  To \"propagate\" a work means to do anything with it that, without\r\npermission, would make you directly or secondarily liable for\r\ninfringement under applicable copyright law, except executing it on a\r\ncomputer or modifying a private copy.  Propagation includes copying,\r\ndistribution (with or without modification), making available to the\r\npublic, and in some countries other activities as well.\r\n\r\n  To \"convey\" a work means any kind of propagation that enables other\r\nparties to make or receive copies.  Mere interaction with a user through\r\na computer network, with no transfer of a copy, is not conveying.\r\n\r\n  An interactive user interface displays \"Appropriate Legal Notices\"\r\nto the extent that it includes a convenient and prominently visible\r\nfeature that (1) displays an appropriate copyright notice, and (2)\r\ntells the user that there is no warranty for the work (except to the\r\nextent that warranties are provided), that licensees may convey the\r\nwork under this License, and how to view a copy of this License.  If\r\nthe interface presents a list of user commands or options, such as a\r\nmenu, a prominent item in the list meets this criterion.\r\n\r\n  1. Source Code.\r\n\r\n  The \"source code\" for a work means the preferred form of the work\r\nfor making modifications to it.  \"Object code\" means any non-source\r\nform of a work.\r\n\r\n  A \"Standard Interface\" means an interface that either is an official\r\nstandard defined by a recognized standards body, or, in the case of\r\ninterfaces specified for a particular programming language, one that\r\nis widely used among developers working in that language.\r\n\r\n  The \"System Libraries\" of an executable work include anything, other\r\nthan the work as a whole, that (a) is included in the normal form of\r\npackaging a Major Component, but which is not part of that Major\r\nComponent, and (b) serves only to enable use of the work with that\r\nMajor Component, or to implement a Standard Interface for which an\r\nimplementation is available to the public in source code form.  A\r\n\"Major Component\", in this context, means a major essential component\r\n(kernel, window system, and so on) of the specific operating system\r\n(if any) on which the executable work runs, or a compiler used to\r\nproduce the work, or an object code interpreter used to run it.\r\n\r\n  The \"Corresponding Source\" for a work in object code form means all\r\nthe source code needed to generate, install, and (for an executable\r\nwork) run the object code and to modify the work, including scripts to\r\ncontrol those activities.  However, it does not include the work's\r\nSystem Libraries, or general-purpose tools or generally available free\r\nprograms which are used unmodified in performing those activities but\r\nwhich are not part of the work.  For example, Corresponding Source\r\nincludes interface definition files associated with source files for\r\nthe work, and the source code for shared libraries and dynamically\r\nlinked subprograms that the work is specifically designed to require,\r\nsuch as by intimate data communication or control flow between those\r\nsubprograms and other parts of the work.\r\n\r\n  The Corresponding Source need not include anything that users\r\ncan regenerate automatically from other parts of the Corresponding\r\nSource.\r\n\r\n  The Corresponding Source for a work in source code form is that\r\nsame work.\r\n\r\n  2. Basic Permissions.\r\n\r\n  All rights granted under this License are granted for the term of\r\ncopyright on the Program, and are irrevocable provided the stated\r\nconditions are met.  This License explicitly affirms your unlimited\r\npermission to run the unmodified Program.  The output from running a\r\ncovered work is covered by this License only if the output, given its\r\ncontent, constitutes a covered work.  This License acknowledges your\r\nrights of fair use or other equivalent, as provided by copyright law.\r\n\r\n  You may make, run and propagate covered works that you do not\r\nconvey, without conditions so long as your license otherwise remains\r\nin force.  You may convey covered works to others for the sole purpose\r\nof having them make modifications exclusively for you, or provide you\r\nwith facilities for running those works, provided that you comply with\r\nthe terms of this License in conveying all material for which you do\r\nnot control copyright.  Those thus making or running the covered works\r\nfor you must do so exclusively on your behalf, under your direction\r\nand control, on terms that prohibit them from making any copies of\r\nyour copyrighted material outside their relationship with you.\r\n\r\n  Conveying under any other circumstances is permitted solely under\r\nthe conditions stated below.  Sublicensing is not allowed; section 10\r\nmakes it unnecessary.\r\n\r\n  3. Protecting Users' Legal Rights From Anti-Circumvention Law.\r\n\r\n  No covered work shall be deemed part of an effective technological\r\nmeasure under any applicable law fulfilling obligations under article\r\n11 of the WIPO copyright treaty adopted on 20 December 1996, or\r\nsimilar laws prohibiting or restricting circumvention of such\r\nmeasures.\r\n\r\n  When you convey a covered work, you waive any legal power to forbid\r\ncircumvention of technological measures to the extent such circumvention\r\nis effected by exercising rights under this License with respect to\r\nthe covered work, and you disclaim any intention to limit operation or\r\nmodification of the work as a means of enforcing, against the work's\r\nusers, your or third parties' legal rights to forbid circumvention of\r\ntechnological measures.\r\n\r\n  4. Conveying Verbatim Copies.\r\n\r\n  You may convey verbatim copies of the Program's source code as you\r\nreceive it, in any medium, provided that you conspicuously and\r\nappropriately publish on each copy an appropriate copyright notice;\r\nkeep intact all notices stating that this License and any\r\nnon-permissive terms added in accord with section 7 apply to the code;\r\nkeep intact all notices of the absence of any warranty; and give all\r\nrecipients a copy of this License along with the Program.\r\n\r\n  You may charge any price or no price for each copy that you convey,\r\nand you may offer support or warranty protection for a fee.\r\n\r\n  5. Conveying Modified Source Versions.\r\n\r\n  You may convey a work based on the Program, or the modifications to\r\nproduce it from the Program, in the form of source code under the\r\nterms of section 4, provided that you also meet all of these conditions:\r\n\r\n    a) The work must carry prominent notices stating that you modified\r\n    it, and giving a relevant date.\r\n\r\n    b) The work must carry prominent notices stating that it is\r\n    released under this License and any conditions added under section\r\n    7.  This requirement modifies the requirement in section 4 to\r\n    \"keep intact all notices\".\r\n\r\n    c) You must license the entire work, as a whole, under this\r\n    License to anyone who comes into possession of a copy.  This\r\n    License will therefore apply, along with any applicable section 7\r\n    additional terms, to the whole of the work, and all its parts,\r\n    regardless of how they are packaged.  This License gives no\r\n    permission to license the work in any other way, but it does not\r\n    invalidate such permission if you have separately received it.\r\n\r\n    d) If the work has interactive user interfaces, each must display\r\n    Appropriate Legal Notices; however, if the Program has interactive\r\n    interfaces that do not display Appropriate Legal Notices, your\r\n    work need not make them do so.\r\n\r\n  A compilation of a covered work with other separate and independent\r\nworks, which are not by their nature extensions of the covered work,\r\nand which are not combined with it such as to form a larger program,\r\nin or on a volume of a storage or distribution medium, is called an\r\n\"aggregate\" if the compilation and its resulting copyright are not\r\nused to limit the access or legal rights of the compilation's users\r\nbeyond what the individual works permit.  Inclusion of a covered work\r\nin an aggregate does not cause this License to apply to the other\r\nparts of the aggregate.\r\n\r\n  6. Conveying Non-Source Forms.\r\n\r\n  You may convey a covered work in object code form under the terms\r\nof sections 4 and 5, provided that you also convey the\r\nmachine-readable Corresponding Source under the terms of this License,\r\nin one of these ways:\r\n\r\n    a) Convey the object code in, or embodied in, a physical product\r\n    (including a physical distribution medium), accompanied by the\r\n    Corresponding Source fixed on a durable physical medium\r\n    customarily used for software interchange.\r\n\r\n    b) Convey the object code in, or embodied in, a physical product\r\n    (including a physical distribution medium), accompanied by a\r\n    written offer, valid for at least three years and valid for as\r\n    long as you offer spare parts or customer support for that product\r\n    model, to give anyone who possesses the object code either (1) a\r\n    copy of the Corresponding Source for all the software in the\r\n    product that is covered by this License, on a durable physical\r\n    medium customarily used for software interchange, for a price no\r\n    more than your reasonable cost of physically performing this\r\n    conveying of source, or (2) access to copy the\r\n    Corresponding Source from a network server at no charge.\r\n\r\n    c) Convey individual copies of the object code with a copy of the\r\n    written offer to provide the Corresponding Source.  This\r\n    alternative is allowed only occasionally and noncommercially, and\r\n    only if you received the object code with such an offer, in accord\r\n    with subsection 6b.\r\n\r\n    d) Convey the object code by offering access from a designated\r\n    place (gratis or for a charge), and offer equivalent access to the\r\n    Corresponding Source in the same way through the same place at no\r\n    further charge.  You need not require recipients to copy the\r\n    Corresponding Source along with the object code.  If the place to\r\n    copy the object code is a network server, the Corresponding Source\r\n    may be on a different server (operated by you or a third party)\r\n    that supports equivalent copying facilities, provided you maintain\r\n    clear directions next to the object code saying where to find the\r\n    Corresponding Source.  Regardless of what server hosts the\r\n    Corresponding Source, you remain obligated to ensure that it is\r\n    available for as long as needed to satisfy these requirements.\r\n\r\n    e) Convey the object code using peer-to-peer transmission, provided\r\n    you inform other peers where the object code and Corresponding\r\n    Source of the work are being offered to the general public at no\r\n    charge under subsection 6d.\r\n\r\n  A separable portion of the object code, whose source code is excluded\r\nfrom the Corresponding Source as a System Library, need not be\r\nincluded in conveying the object code work.\r\n\r\n  A \"User Product\" is either (1) a \"consumer product\", which means any\r\ntangible personal property which is normally used for personal, family,\r\nor household purposes, or (2) anything designed or sold for incorporation\r\ninto a dwelling.  In determining whether a product is a consumer product,\r\ndoubtful cases shall be resolved in favor of coverage.  For a particular\r\nproduct received by a particular user, \"normally used\" refers to a\r\ntypical or common use of that class of product, regardless of the status\r\nof the particular user or of the way in which the particular user\r\nactually uses, or expects or is expected to use, the product.  A product\r\nis a consumer product regardless of whether the product has substantial\r\ncommercial, industrial or non-consumer uses, unless such uses represent\r\nthe only significant mode of use of the product.\r\n\r\n  \"Installation Information\" for a User Product means any methods,\r\nprocedures, authorization keys, or other information required to install\r\nand execute modified versions of a covered work in that User Product from\r\na modified version of its Corresponding Source.  The information must\r\nsuffice to ensure that the continued functioning of the modified object\r\ncode is in no case prevented or interfered with solely because\r\nmodification has been made.\r\n\r\n  If you convey an object code work under this section in, or with, or\r\nspecifically for use in, a User Product, and the conveying occurs as\r\npart of a transaction in which the right of possession and use of the\r\nUser Product is transferred to the recipient in perpetuity or for a\r\nfixed term (regardless of how the transaction is characterized), the\r\nCorresponding Source conveyed under this section must be accompanied\r\nby the Installation Information.  But this requirement does not apply\r\nif neither you nor any third party retains the ability to install\r\nmodified object code on the User Product (for example, the work has\r\nbeen installed in ROM).\r\n\r\n  The requirement to provide Installation Information does not include a\r\nrequirement to continue to provide support service, warranty, or updates\r\nfor a work that has been modified or installed by the recipient, or for\r\nthe User Product in which it has been modified or installed.  Access to a\r\nnetwork may be denied when the modification itself materially and\r\nadversely affects the operation of the network or violates the rules and\r\nprotocols for communication across the network.\r\n\r\n  Corresponding Source conveyed, and Installation Information provided,\r\nin accord with this section must be in a format that is publicly\r\ndocumented (and with an implementation available to the public in\r\nsource code form), and must require no special password or key for\r\nunpacking, reading or copying.\r\n\r\n  7. Additional Terms.\r\n\r\n  \"Additional permissions\" are terms that supplement the terms of this\r\nLicense by making exceptions from one or more of its conditions.\r\nAdditional permissions that are applicable to the entire Program shall\r\nbe treated as though they were included in this License, to the extent\r\nthat they are valid under applicable law.  If additional permissions\r\napply only to part of the Program, that part may be used separately\r\nunder those permissions, but the entire Program remains governed by\r\nthis License without regard to the additional permissions.\r\n\r\n  When you convey a copy of a covered work, you may at your option\r\nremove any additional permissions from that copy, or from any part of\r\nit.  (Additional permissions may be written to require their own\r\nremoval in certain cases when you modify the work.)  You may place\r\nadditional permissions on material, added by you to a covered work,\r\nfor which you have or can give appropriate copyright permission.\r\n\r\n  Notwithstanding any other provision of this License, for material you\r\nadd to a covered work, you may (if authorized by the copyright holders of\r\nthat material) supplement the terms of this License with terms:\r\n\r\n    a) Disclaiming warranty or limiting liability differently from the\r\n    terms of sections 15 and 16 of this License; or\r\n\r\n    b) Requiring preservation of specified reasonable legal notices or\r\n    author attributions in that material or in the Appropriate Legal\r\n    Notices displayed by works containing it; or\r\n\r\n    c) Prohibiting misrepresentation of the origin of that material, or\r\n    requiring that modified versions of such material be marked in\r\n    reasonable ways as different from the original version; or\r\n\r\n    d) Limiting the use for publicity purposes of names of licensors or\r\n    authors of the material; or\r\n\r\n    e) Declining to grant rights under trademark law for use of some\r\n    trade names, trademarks, or service marks; or\r\n\r\n    f) Requiring indemnification of licensors and authors of that\r\n    material by anyone who conveys the material (or modified versions of\r\n    it) with contractual assumptions of liability to the recipient, for\r\n    any liability that these contractual assumptions directly impose on\r\n    those licensors and authors.\r\n\r\n  All other non-permissive additional terms are considered \"further\r\nrestrictions\" within the meaning of section 10.  If the Program as you\r\nreceived it, or any part of it, contains a notice stating that it is\r\ngoverned by this License along with a term that is a further\r\nrestriction, you may remove that term.  If a license document contains\r\na further restriction but permits relicensing or conveying under this\r\nLicense, you may add to a covered work material governed by the terms\r\nof that license document, provided that the further restriction does\r\nnot survive such relicensing or conveying.\r\n\r\n  If you add terms to a covered work in accord with this section, you\r\nmust place, in the relevant source files, a statement of the\r\nadditional terms that apply to those files, or a notice indicating\r\nwhere to find the applicable terms.\r\n\r\n  Additional terms, permissive or non-permissive, may be stated in the\r\nform of a separately written license, or stated as exceptions;\r\nthe above requirements apply either way.\r\n\r\n  8. Termination.\r\n\r\n  You may not propagate or modify a covered work except as expressly\r\nprovided under this License.  Any attempt otherwise to propagate or\r\nmodify it is void, and will automatically terminate your rights under\r\nthis License (including any patent licenses granted under the third\r\nparagraph of section 11).\r\n\r\n  However, if you cease all violation of this License, then your\r\nlicense from a particular copyright holder is reinstated (a)\r\nprovisionally, unless and until the copyright holder explicitly and\r\nfinally terminates your license, and (b) permanently, if the copyright\r\nholder fails to notify you of the violation by some reasonable means\r\nprior to 60 days after the cessation.\r\n\r\n  Moreover, your license from a particular copyright holder is\r\nreinstated permanently if the copyright holder notifies you of the\r\nviolation by some reasonable means, this is the first time you have\r\nreceived notice of violation of this License (for any work) from that\r\ncopyright holder, and you cure the violation prior to 30 days after\r\nyour receipt of the notice.\r\n\r\n  Termination of your rights under this section does not terminate the\r\nlicenses of parties who have received copies or rights from you under\r\nthis License.  If your rights have been terminated and not permanently\r\nreinstated, you do not qualify to receive new licenses for the same\r\nmaterial under section 10.\r\n\r\n  9. Acceptance Not Required for Having Copies.\r\n\r\n  You are not required to accept this License in order to receive or\r\nrun a copy of the Program.  Ancillary propagation of a covered work\r\noccurring solely as a consequence of using peer-to-peer transmission\r\nto receive a copy likewise does not require acceptance.  However,\r\nnothing other than this License grants you permission to propagate or\r\nmodify any covered work.  These actions infringe copyright if you do\r\nnot accept this License.  Therefore, by modifying or propagating a\r\ncovered work, you indicate your acceptance of this License to do so.\r\n\r\n  10. Automatic Licensing of Downstream Recipients.\r\n\r\n  Each time you convey a covered work, the recipient automatically\r\nreceives a license from the original licensors, to run, modify and\r\npropagate that work, subject to this License.  You are not responsible\r\nfor enforcing compliance by third parties with this License.\r\n\r\n  An \"entity transaction\" is a transaction transferring control of an\r\norganization, or substantially all assets of one, or subdividing an\r\norganization, or merging organizations.  If propagation of a covered\r\nwork results from an entity transaction, each party to that\r\ntransaction who receives a copy of the work also receives whatever\r\nlicenses to the work the party's predecessor in interest had or could\r\ngive under the previous paragraph, plus a right to possession of the\r\nCorresponding Source of the work from the predecessor in interest, if\r\nthe predecessor has it or can get it with reasonable efforts.\r\n\r\n  You may not impose any further restrictions on the exercise of the\r\nrights granted or affirmed under this License.  For example, you may\r\nnot impose a license fee, royalty, or other charge for exercise of\r\nrights granted under this License, and you may not initiate litigation\r\n(including a cross-claim or counterclaim in a lawsuit) alleging that\r\nany patent claim is infringed by making, using, selling, offering for\r\nsale, or importing the Program or any portion of it.\r\n\r\n  11. Patents.\r\n\r\n  A \"contributor\" is a copyright holder who authorizes use under this\r\nLicense of the Program or a work on which the Program is based.  The\r\nwork thus licensed is called the contributor's \"contributor version\".\r\n\r\n  A contributor's \"essential patent claims\" are all patent claims\r\nowned or controlled by the contributor, whether already acquired or\r\nhereafter acquired, that would be infringed by some manner, permitted\r\nby this License, of making, using, or selling its contributor version,\r\nbut do not include claims that would be infringed only as a\r\nconsequence of further modification of the contributor version.  For\r\npurposes of this definition, \"control\" includes the right to grant\r\npatent sublicenses in a manner consistent with the requirements of\r\nthis License.\r\n\r\n  Each contributor grants you a non-exclusive, worldwide, royalty-free\r\npatent license under the contributor's essential patent claims, to\r\nmake, use, sell, offer for sale, import and otherwise run, modify and\r\npropagate the contents of its contributor version.\r\n\r\n  In the following three paragraphs, a \"patent license\" is any express\r\nagreement or commitment, however denominated, not to enforce a patent\r\n(such as an express permission to practice a patent or covenant not to\r\nsue for patent infringement).  To \"grant\" such a patent license to a\r\nparty means to make such an agreement or commitment not to enforce a\r\npatent against the party.\r\n\r\n  If you convey a covered work, knowingly relying on a patent license,\r\nand the Corresponding Source of the work is not available for anyone\r\nto copy, free of charge and under the terms of this License, through a\r\npublicly available network server or other readily accessible means,\r\nthen you must either (1) cause the Corresponding Source to be so\r\navailable, or (2) arrange to deprive yourself of the benefit of the\r\npatent license for this particular work, or (3) arrange, in a manner\r\nconsistent with the requirements of this License, to extend the patent\r\nlicense to downstream recipients.  \"Knowingly relying\" means you have\r\nactual knowledge that, but for the patent license, your conveying the\r\ncovered work in a country, or your recipient's use of the covered work\r\nin a country, would infringe one or more identifiable patents in that\r\ncountry that you have reason to believe are valid.\r\n\r\n  If, pursuant to or in connection with a single transaction or\r\narrangement, you convey, or propagate by procuring conveyance of, a\r\ncovered work, and grant a patent license to some of the parties\r\nreceiving the covered work authorizing them to use, propagate, modify\r\nor convey a specific copy of the covered work, then the patent license\r\nyou grant is automatically extended to all recipients of the covered\r\nwork and works based on it.\r\n\r\n  A patent license is \"discriminatory\" if it does not include within\r\nthe scope of its coverage, prohibits the exercise of, or is\r\nconditioned on the non-exercise of one or more of the rights that are\r\nspecifically granted under this License.  You may not convey a covered\r\nwork if you are a party to an arrangement with a third party that is\r\nin the business of distributing software, under which you make payment\r\nto the third party based on the extent of your activity of conveying\r\nthe work, and under which the third party grants, to any of the\r\nparties who would receive the covered work from you, a discriminatory\r\npatent license (a) in connection with copies of the covered work\r\nconveyed by you (or copies made from those copies), or (b) primarily\r\nfor and in connection with specific products or compilations that\r\ncontain the covered work, unless you entered into that arrangement,\r\nor that patent license was granted, prior to 28 March 2007.\r\n\r\n  Nothing in this License shall be construed as excluding or limiting\r\nany implied license or other defenses to infringement that may\r\notherwise be available to you under applicable patent law.\r\n\r\n  12. No Surrender of Others' Freedom.\r\n\r\n  If conditions are imposed on you (whether by court order, agreement or\r\notherwise) that contradict the conditions of this License, they do not\r\nexcuse you from the conditions of this License.  If you cannot convey a\r\ncovered work so as to satisfy simultaneously your obligations under this\r\nLicense and any other pertinent obligations, then as a consequence you may\r\nnot convey it at all.  For example, if you agree to terms that obligate you\r\nto collect a royalty for further conveying from those to whom you convey\r\nthe Program, the only way you could satisfy both those terms and this\r\nLicense would be to refrain entirely from conveying the Program.\r\n\r\n  13. Use with the GNU Affero General Public License.\r\n\r\n  Notwithstanding any other provision of this License, you have\r\npermission to link or combine any covered work with a work licensed\r\nunder version 3 of the GNU Affero General Public License into a single\r\ncombined work, and to convey the resulting work.  The terms of this\r\nLicense will continue to apply to the part which is the covered work,\r\nbut the special requirements of the GNU Affero General Public License,\r\nsection 13, concerning interaction through a network will apply to the\r\ncombination as such.\r\n\r\n  14. Revised Versions of this License.\r\n\r\n  The Free Software Foundation may publish revised and/or new versions of\r\nthe GNU General Public License from time to time.  Such new versions will\r\nbe similar in spirit to the present version, but may differ in detail to\r\naddress new problems or concerns.\r\n\r\n  Each version is given a distinguishing version number.  If the\r\nProgram specifies that a certain numbered version of the GNU General\r\nPublic License \"or any later version\" applies to it, you have the\r\noption of following the terms and conditions either of that numbered\r\nversion or of any later version published by the Free Software\r\nFoundation.  If the Program does not specify a version number of the\r\nGNU General Public License, you may choose any version ever published\r\nby the Free Software Foundation.\r\n\r\n  If the Program specifies that a proxy can decide which future\r\nversions of the GNU General Public License can be used, that proxy's\r\npublic statement of acceptance of a version permanently authorizes you\r\nto choose that version for the Program.\r\n\r\n  Later license versions may give you additional or different\r\npermissions.  However, no additional obligations are imposed on any\r\nauthor or copyright holder as a result of your choosing to follow a\r\nlater version.\r\n\r\n  15. Disclaimer of Warranty.\r\n\r\n  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\r\nAPPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\r\nHOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY\r\nOF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\r\nTHE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\r\nPURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\r\nIS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\r\nALL NECESSARY SERVICING, REPAIR OR CORRECTION.\r\n\r\n  16. Limitation of Liability.\r\n\r\n  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\r\nWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS\r\nTHE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY\r\nGENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE\r\nUSE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF\r\nDATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD\r\nPARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),\r\nEVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF\r\nSUCH DAMAGES.\r\n\r\n  17. Interpretation of Sections 15 and 16.\r\n\r\n  If the disclaimer of warranty and limitation of liability provided\r\nabove cannot be given local legal effect according to their terms,\r\nreviewing courts shall apply local law that most closely approximates\r\nan absolute waiver of all civil liability in connection with the\r\nProgram, unless a warranty or assumption of liability accompanies a\r\ncopy of the Program in return for a fee.\r\n\r\n                     END OF TERMS AND CONDITIONS\r\n\r\n            How to Apply These Terms to Your New Programs\r\n\r\n  If you develop a new program, and you want it to be of the greatest\r\npossible use to the public, the best way to achieve this is to make it\r\nfree software which everyone can redistribute and change under these terms.\r\n\r\n  To do so, attach the following notices to the program.  It is safest\r\nto attach them to the start of each source file to most effectively\r\nstate the exclusion of warranty; and each file should have at least\r\nthe \"copyright\" line and a pointer to where the full notice is found.\r\n\r\n    <one line to give the program's name and a brief idea of what it does.>\r\n    Copyright (C) <year>  <name of author>\r\n\r\n    This program is free software: you can redistribute it and/or modify\r\n    it under the terms of the GNU General Public License as published by\r\n    the Free Software Foundation, either version 3 of the License, or\r\n    (at your option) any later version.\r\n\r\n    This program is distributed in the hope that it will be useful,\r\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\r\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r\n    GNU General Public License for more details.\r\n\r\n    You should have received a copy of the GNU General Public License\r\n    along with this program.  If not, see <http://www.gnu.org/licenses/>.\r\n\r\nAlso add information on how to contact you by electronic and paper mail.\r\n\r\n  If the program does terminal interaction, make it output a short\r\nnotice like this when it starts in an interactive mode:\r\n\r\n    <program>  Copyright (C) <year>  <name of author>\r\n    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\r\n    This is free software, and you are welcome to redistribute it\r\n    under certain conditions; type `show c' for details.\r\n\r\nThe hypothetical commands `show w' and `show c' should show the appropriate\r\nparts of the General Public License.  Of course, your program's commands\r\nmight be different; for a GUI interface, you would use an \"about box\".\r\n\r\n  You should also get your employer (if you work as a programmer) or school,\r\nif any, to sign a \"copyright disclaimer\" for the program, if necessary.\r\nFor more information on this, and how to apply and follow the GNU GPL, see\r\n<http://www.gnu.org/licenses/>.\r\n\r\n  The GNU General Public License does not permit incorporating your program\r\ninto proprietary programs.  If your program is a subroutine library, you\r\nmay consider it more useful to permit linking proprietary applications with\r\nthe library.  If this is what you want to do, use the GNU Lesser General\r\nPublic License instead of this License.  But first, please read\r\n<http://www.gnu.org/philosophy/why-not-lgpl.html>.\r\n"
  },
  {
    "path": "bin/Readme.txt",
    "content": "simplewall\r\n\r\nDescription:\r\nSimple tool to configure Windows Filtering Platform (WFP) which can configure network activity on your computer.\r\n\r\nThe lightweight application is less than a megabyte, and it is compatible with Windows 7 SP1 and higher operating systems.\r\nYou can download either the installer or portable version. For correct working you are require administrator rights.\r\n\r\nSystem requirements:\r\n- Windows 7, 8, 8.1, 10, 11 64-bit/ARM64\r\n- An SSE2-capable CPU\r\n\r\nNota bene:\r\nKeep in mind, simplewall is not a control UI over Windows Firewall, and does not interact in any level with Windows Firewall. It works\r\nover Windows Filtering Platform (WFP) which is a set of internal API and system services that provide a platform for creating network filtering\r\napplications. Windows Filtering Platform is a development technology and not a firewall itself, but simplewall is the tool that uses this technology.\r\n\r\nCommand line:\r\nList of arguments for simplewall.\r\n-install - enable filtering (you can set \"-silent\" argument to skip prompt)\r\n-uninstall - remove all installed filters\r\n\r\nUninstall:\r\nWhen you uninstall simplewall, all previously installed filters are stay alive in system.\r\nTo remove all filters created by simplewall, start simplewall and press \"Disable filters\" button.\r\n\r\nFeatures:\r\n- Simple interface without annoying pop ups\r\n- Rules editor (create your own rules)\r\n- Internal blocklist rules (block Windows spy / telemetry)\r\n- Dropped packets information with notification and logging to a file feature (win7+)\r\n- Allowed packets information with logging to a file feature (win8+)\r\n- Windows Subsystem for Linux (WSL) support\r\n- Windows Store support (win8+)\r\n- Windows services support\r\n- Free and open source\r\n- Localization support\r\n- IPv6 support\r\n\r\nTo activate portable mode, create \"simplewall.ini\" in application folder, or move it from \"%APPDATA%\\Henry++\\simplewall\".\r\n\r\nInstallation:\r\nWhen install rules, you can choose two modes:\r\n- Permanent rules - rules are working until you disable it manually.\r\n- Temporary rules - rules are reset after the next reboot.\r\n\r\nUninstall:\r\nWhen you uninstall simplewall, all previously configured filters stay alive in system.\r\nTo remove all filters created by simplewall, start simplewall and press \"Disable filters\" button.\r\n\r\nCommand line:\r\n-install - enable filtering.\r\n-install -temp - enable filtering until next reboot.\r\n-install -silent - enable filtering without prompt.\r\n-uninstall - remove all installed filters.\r\n\r\nWebsite: https://github.com/henrypp\r\nSupport: sforce5@mail.ru\r\n\r\n(c) 2016-2026 Henry++\r\n"
  },
  {
    "path": "bin/profile_internal.xml",
    "content": "<?xml version=\"1.0\" ?>\n<!--Internal rules for simplewall-->\n<!--Minimum required version is 3.8-->\n<root timestamp=\"1717635779\" type=\"4\" version=\"5\">\n\t<rules_system>\n\t\t<item name=\"Cryptographic service\" apps=\"CryptSvc\" is_enabled=\"true\" />\n\t\t<item name=\"DHCP\" rule=\"67-68;546-547\" rule_local=\"67-68;546-547\" dir=\"2\" protocol=\"17\" apps=\"Dhcp\" is_enabled=\"true\" />\n\t\t<item name=\"DNS\" rule=\"53\" protocol=\"17\" apps=\"Dnscache\" is_enabled=\"true\" />\n\t\t<item name=\"IGMP\" rule=\"224.0.0.0/4\" protocol=\"2\" is_services=\"true\" is_enabled=\"true\" />\n\t\t<item name=\"IKEv2/IPSEC/L2TP\" rule=\"500;1701;4500\" protocol=\"17\" is_services=\"true\" />\n\t\t<item name=\"KMS service\" rule=\"1688\" protocol=\"6\" apps=\"%systemroot%\\system32\\SppExtComObj.exe\" os_version=\"6.2\" is_enabled=\"true\" />\n\t\t<item name=\"LLMNR\" rule=\"224.0.0.252:5355;[ff02::1:3]:5355\" protocol=\"17\" is_services=\"true\" is_enabled=\"true\" />\n\t\t<item name=\"mDNS\" rule=\"224.0.0.251:5353;[ff02::fb]:5353\" protocol=\"17\" is_services=\"true\" is_enabled=\"true\" />\n\t\t<item name=\"Microsoft account\" apps=\"wlidsvc\" os_version=\"6.2\" />\n\t\t<item name=\"NetBIOS [inbound]\" rule_local=\"137-139\" dir=\"1\" is_services=\"true\" is_enabled=\"true\" />\n\t\t<item name=\"NetBIOS [outbound]\" rule=\"137-139\" is_services=\"true\" is_enabled=\"true\" />\n\t\t<item name=\"NCSI\" apps=\"NlaSvc\" is_enabled=\"true\" />\n\t\t<item name=\"NTP\" rule=\"123\" protocol=\"17\" is_services=\"true\" is_enabled=\"true\" />\n\t\t<item name=\"Printer Service\" rule_remote=\"515;631\" protocol=\"6\" apps=\"Spooler\" />\n\t\t<item name=\"RDP [inbound]\" rule_local=\"3389\" dir=\"1\" is_services=\"true\" />\n\t\t<item name=\"RDP [outbound]\" rule=\"3389\" is_services=\"true\" />\n\t\t<item name=\"Security policy\" apps=\"%systemroot%\\system32\\lsass.exe\" is_enabled=\"true\" />\n\t\t<item name=\"SMB [inbound]\" rule_local=\"445\" dir=\"1\" protocol=\"6\" is_services=\"true\" />\n\t\t<item name=\"SMB [outbound]\" rule=\"445\" protocol=\"6\" is_services=\"true\" />\n\t\t<item name=\"SNMP\" rule=\"161-162\" dir=\"2\" protocol=\"17\" is_services=\"true\" />\n\t\t<item name=\"SSDP [inbound]\" rule_local=\"1900\" dir=\"1\" protocol=\"17\" is_services=\"true\" is_enabled=\"true\" />\n\t\t<item name=\"SSDP [outbound]\" rule=\"1900\" protocol=\"17\" is_services=\"true\" is_enabled=\"true\" />\n\t\t<item name=\"UPnP\" rule=\"2869;5000\" is_services=\"true\" is_enabled=\"true\" />\n\t\t<item name=\"Windows Update service\" apps=\"wuauserv\" />\n\t\t<item name=\"Windows Update Delivery service\" apps=\"DoSvc|UsoSvc\" os_version=\"10.0\" />\n\t\t<item name=\"WS-Discovery\" rule=\"3702\" protocol=\"17\" is_services=\"true\" is_enabled=\"true\" />\n\t\t<item name=\"WS-Discovery [events]\" rule=\"5357-5358\" protocol=\"6\" is_services=\"true\" is_enabled=\"true\" />\n\t</rules_system>\n\t<rules_custom>\n\t\t<item name=\"DNS protocol\" rule=\"53\" protocol=\"17\" />\n\t\t<item name=\"FTP\" rule=\"20-21;49152-65534\" protocol=\"6\" />\n\t\t<item name=\"HTTP\" rule=\"80;443;8000;8008;8080;8443-8444\" protocol=\"6\" />\n\t\t<item name=\"ICMPv4\" dir=\"2\" protocol=\"1\" />\n\t\t<item name=\"ICMPv6\" dir=\"2\" protocol=\"58\" />\n\t\t<item name=\"IMAP/POP3/SMTP\" rule=\"25;110;143;465;587;993;995;2525\" protocol=\"6\" />\n\t\t<item name=\"QUIC\" rule=\"443\" protocol=\"17\" />\n\t\t<item name=\"SSH\" rule=\"22\" protocol=\"6\" />\n\t\t<item name=\"Telnet\" rule=\"23\" protocol=\"6\" />\n\t</rules_custom>\n\t<rules_blocklist>\n\t\t<item name=\"extra_13.64.186.225\" rule=\"13.64.186.225\" />\n\t\t<item name=\"extra_13.69.116.104\" rule=\"13.69.116.104\" />\n\t\t<item name=\"extra_13.69.146.58\" rule=\"13.69.146.58\" />\n\t\t<item name=\"extra_13.69.239.72\" rule=\"13.69.239.72\" />\n\t\t<item name=\"extra_13.69.239.73\" rule=\"13.69.239.73\" />\n\t\t<item name=\"extra_13.69.239.74\" rule=\"13.69.239.74\" />\n\t\t<item name=\"extra_13.69.244.117\" rule=\"13.69.244.117\" />\n\t\t<item name=\"extra_13.70.180.171\" rule=\"13.70.180.171\" />\n\t\t<item name=\"extra_13.76.218.117\" rule=\"13.76.218.117\" />\n\t\t<item name=\"extra_13.76.219.191\" rule=\"13.76.219.191\" />\n\t\t<item name=\"extra_13.76.219.210\" rule=\"13.76.219.210\" />\n\t\t<item name=\"extra_13.77.112.132\" rule=\"13.77.112.132\" />\n\t\t<item name=\"extra_13.77.115.36\" rule=\"13.77.115.36\" />\n\t\t<item name=\"extra_13.78.111.198\" rule=\"13.78.111.198\" />\n\t\t<item name=\"extra_13.78.111.199\" rule=\"13.78.111.199\" />\n\t\t<item name=\"extra_13.78.235.126\" rule=\"13.78.235.126\" />\n\t\t<item name=\"extra_13.78.235.247\" rule=\"13.78.235.247\" />\n\t\t<item name=\"extra_13.79.7.57\" rule=\"13.79.7.57\" />\n\t\t<item name=\"extra_13.79.239.69\" rule=\"13.79.239.69\" />\n\t\t<item name=\"extra_13.79.239.82\" rule=\"13.79.239.82\" />\n\t\t<item name=\"extra_13.80.7.77\" rule=\"13.80.7.77\" />\n\t\t<item name=\"extra_13.80.12.54\" rule=\"13.80.12.54\" />\n\t\t<item name=\"extra_13.81.5.53\" rule=\"13.81.5.53\" />\n\t\t<item name=\"extra_13.81.118.91\" rule=\"13.81.118.91\" />\n\t\t<item name=\"extra_13.83.65.212\" rule=\"13.83.65.212\" />\n\t\t<item name=\"extra_13.83.98.37\" rule=\"13.83.98.37\" />\n\t\t<item name=\"extra_13.85.88.16\" rule=\"13.85.88.16\" />\n\t\t<item name=\"extra_13.86.252.235\" rule=\"13.86.252.235\" />\n\t\t<item name=\"extra_13.88.28.53\" rule=\"13.88.28.53\" />\n\t\t<item name=\"extra_13.88.139.208\" rule=\"13.88.139.208\" />\n\t\t<item name=\"extra_13.88.145.128\" rule=\"13.88.145.128\" />\n\t\t<item name=\"extra_13.89.51.159\" rule=\"13.89.51.159\" />\n\t\t<item name=\"extra_13.89.178.26\" rule=\"13.89.178.26\" />\n\t\t<item name=\"extra_13.89.178.27\" rule=\"13.89.178.27\" />\n\t\t<item name=\"extra_13.89.179.8\" rule=\"13.89.179.8\" />\n\t\t<item name=\"extra_13.89.179.9\" rule=\"13.89.179.9\" />\n\t\t<item name=\"extra_13.89.179.10\" rule=\"13.89.179.10\" />\n\t\t<item name=\"extra_13.89.179.12\" rule=\"13.89.179.12\" />\n\t\t<item name=\"extra_13.89.202.241\" rule=\"13.89.202.241\" />\n\t\t<item name=\"extra_13.95.147.73\" rule=\"13.95.147.73\" />\n\t\t<item name=\"extra_13.104.158.177\" rule=\"13.104.158.177\" />\n\t\t<item name=\"extra_13.104.158.179\" rule=\"13.104.158.179\" />\n\t\t<item name=\"extra_13.104.158.180\" rule=\"13.104.158.180\" />\n\t\t<item name=\"extra_13.104.158.183\" rule=\"13.104.158.183\" />\n\t\t<item name=\"extra_13.104.208.160\" rule=\"13.104.208.160\" />\n\t\t<item name=\"extra_13.104.208.162\" rule=\"13.104.208.162\" />\n\t\t<item name=\"extra_13.104.208.164\" rule=\"13.104.208.164\" />\n\t\t<item name=\"extra_13.104.208.165\" rule=\"13.104.208.165\" />\n\t\t<item name=\"extra_13.105.66.144\" rule=\"13.105.66.144\" />\n\t\t<item name=\"extra_13.105.74.49\" rule=\"13.105.74.49\" />\n\t\t<item name=\"extra_13.107.3.128\" rule=\"13.107.3.128\" />\n\t\t<item name=\"extra_13.107.3.254\" rule=\"13.107.3.254\" />\n\t\t<item name=\"extra_13.107.5.80\" rule=\"13.107.5.80\" />\n\t\t<item name=\"extra_13.107.5.88\" rule=\"13.107.5.88\" />\n\t\t<item name=\"extra_13.107.5.91\" rule=\"13.107.5.91\" />\n\t\t<item name=\"extra_13.107.6.156\" rule=\"13.107.6.156\" />\n\t\t<item name=\"extra_13.107.6.158\" rule=\"13.107.6.158\" />\n\t\t<item name=\"extra_13.107.6.163\" rule=\"13.107.6.163\" />\n\t\t<item name=\"extra_13.107.6.254\" rule=\"13.107.6.254\" />\n\t\t<item name=\"extra_13.107.13.88\" rule=\"13.107.13.88\" />\n\t\t<item name=\"extra_13.107.13.91\" rule=\"13.107.13.91\" />\n\t\t<item name=\"extra_13.107.18.11\" rule=\"13.107.18.11\" />\n\t\t<item name=\"extra_13.107.18.254\" rule=\"13.107.18.254\" />\n\t\t<item name=\"extra_13.107.19.254\" rule=\"13.107.19.254\" />\n\t\t<item name=\"extra_13.107.21.200\" rule=\"13.107.21.200\" />\n\t\t<item name=\"extra_13.107.21.229\" rule=\"13.107.21.229\" />\n\t\t<item name=\"extra_13.107.22.200\" rule=\"13.107.22.200\" />\n\t\t<item name=\"extra_13.107.40.203\" rule=\"13.107.40.203\" />\n\t\t<item name=\"extra_13.107.42.11\" rule=\"13.107.42.11\" />\n\t\t<item name=\"extra_13.107.42.12\" rule=\"13.107.42.12\" />\n\t\t<item name=\"extra_13.107.42.13\" rule=\"13.107.42.13\" />\n\t\t<item name=\"extra_13.107.42.14\" rule=\"13.107.42.14\" />\n\t\t<item name=\"extra_13.107.42.23\" rule=\"13.107.42.23\" />\n\t\t<item name=\"extra_13.107.42.254\" rule=\"13.107.42.254\" />\n\t\t<item name=\"extra_13.107.43.12\" rule=\"13.107.43.12\" />\n\t\t<item name=\"extra_13.107.43.14\" rule=\"13.107.43.14\" />\n\t\t<item name=\"extra_13.107.43.23\" rule=\"13.107.43.23\" />\n\t\t<item name=\"extra_13.107.46.88\" rule=\"13.107.46.88\" />\n\t\t<item name=\"extra_13.107.47.88\" rule=\"13.107.47.88\" />\n\t\t<item name=\"extra_13.107.49.254\" rule=\"13.107.49.254\" />\n\t\t<item name=\"extra_13.107.128.254\" rule=\"13.107.128.254\" />\n\t\t<item name=\"extra_13.107.136.254\" rule=\"13.107.136.254\" />\n\t\t<item name=\"extra_13.107.140.254\" rule=\"13.107.140.254\" />\n\t\t<item name=\"extra_13.107.213.42\" rule=\"13.107.213.42\" />\n\t\t<item name=\"extra_13.107.246.10\" rule=\"13.107.246.10\" />\n\t\t<item name=\"extra_13.107.246.13\" rule=\"13.107.246.13\" />\n\t\t<item name=\"extra_13.107.246.19\" rule=\"13.107.246.19\" />\n\t\t<item name=\"extra_13.107.246.254\" rule=\"13.107.246.254\" />\n\t\t<item name=\"extra_13.107.255.72\" rule=\"13.107.255.72\" />\n\t\t<item name=\"extra_13.107.255.73\" rule=\"13.107.255.73\" />\n\t\t<item name=\"extra_13.107.255.74\" rule=\"13.107.255.74\" />\n\t\t<item name=\"extra_13.107.255.76\" rule=\"13.107.255.76\" />\n\t\t<item name=\"extra_20.36.218.63\" rule=\"20.36.218.63\" />\n\t\t<item name=\"extra_20.36.218.70\" rule=\"20.36.218.70\" />\n\t\t<item name=\"extra_20.36.246.225\" rule=\"20.36.246.225\" />\n\t\t<item name=\"extra_20.36.253.92\" rule=\"20.36.253.92\" />\n\t\t<item name=\"extra_20.38.96.100\" rule=\"20.38.96.100\" />\n\t\t<item name=\"extra_20.38.101.132\" rule=\"20.38.101.132\" />\n\t\t<item name=\"extra_20.38.101.228\" rule=\"20.38.101.228\" />\n\t\t<item name=\"extra_20.38.122.68\" rule=\"20.38.122.68\" />\n\t\t<item name=\"extra_20.38.122.100\" rule=\"20.38.122.100\" />\n\t\t<item name=\"extra_20.38.122.132\" rule=\"20.38.122.132\" />\n\t\t<item name=\"extra_20.38.122.228\" rule=\"20.38.122.228\" />\n\t\t<item name=\"extra_20.40.129.122\" rule=\"20.40.129.122\" />\n\t\t<item name=\"extra_20.40.136.238\" rule=\"20.40.136.238\" />\n\t\t<item name=\"extra_20.42.65.84\" rule=\"20.42.65.84\" />\n\t\t<item name=\"extra_20.42.65.85\" rule=\"20.42.65.85\" />\n\t\t<item name=\"extra_20.42.65.88\" rule=\"20.42.65.88\" />\n\t\t<item name=\"extra_20.42.65.89\" rule=\"20.42.65.89\" />\n\t\t<item name=\"extra_20.42.65.90\" rule=\"20.42.65.90\" />\n\t\t<item name=\"extra_20.42.65.92\" rule=\"20.42.65.92\" />\n\t\t<item name=\"extra_20.42.72.131\" rule=\"20.42.72.131\" />\n\t\t<item name=\"extra_20.42.73.24\" rule=\"20.42.73.24\" />\n\t\t<item name=\"extra_20.42.73.25\" rule=\"20.42.73.25\" />\n\t\t<item name=\"extra_20.42.73.26\" rule=\"20.42.73.26\" />\n\t\t<item name=\"extra_20.42.73.27\" rule=\"20.42.73.27\" />\n\t\t<item name=\"extra_20.42.73.29\" rule=\"20.42.73.29\" />\n\t\t<item name=\"extra_20.43.92.14\" rule=\"20.43.92.14\" />\n\t\t<item name=\"extra_20.44.10.122\" rule=\"20.44.10.122\" />\n\t\t<item name=\"extra_20.44.10.123\" rule=\"20.44.10.123\" />\n\t\t<item name=\"extra_20.44.82.31\" rule=\"20.44.82.31\" />\n\t\t<item name=\"extra_20.44.208.51\" rule=\"20.44.208.51\" />\n\t\t<item name=\"extra_20.44.232.74\" rule=\"20.44.232.74\" />\n\t\t<item name=\"extra_20.46.146.84\" rule=\"20.46.146.84\" />\n\t\t<item name=\"extra_20.49.157.6\" rule=\"20.49.157.6\" />\n\t\t<item name=\"extra_20.50.73.9\" rule=\"20.50.73.9\" />\n\t\t<item name=\"extra_20.50.73.10\" rule=\"20.50.73.10\" />\n\t\t<item name=\"extra_20.50.80.209\" rule=\"20.50.80.209\" />\n\t\t<item name=\"extra_20.50.80.210\" rule=\"20.50.80.210\" />\n\t\t<item name=\"extra_20.50.102.62\" rule=\"20.50.102.62\" />\n\t\t<item name=\"extra_20.50.201.195\" rule=\"20.50.201.195\" />\n\t\t<item name=\"extra_20.50.201.200\" rule=\"20.50.201.200\" />\n\t\t<item name=\"extra_20.54.64.202\" rule=\"20.54.64.202\" />\n\t\t<item name=\"extra_20.54.88.152\" rule=\"20.54.88.152\" />\n\t\t<item name=\"extra_20.54.122.82\" rule=\"20.54.122.82\" />\n\t\t<item name=\"extra_20.60.18.36\" rule=\"20.60.18.36\" />\n\t\t<item name=\"extra_20.60.30.36\" rule=\"20.60.30.36\" />\n\t\t<item name=\"extra_20.60.30.68\" rule=\"20.60.30.68\" />\n\t\t<item name=\"extra_20.60.58.97\" rule=\"20.60.58.97\" />\n\t\t<item name=\"extra_20.60.59.193\" rule=\"20.60.59.193\" />\n\t\t<item name=\"extra_20.60.59.235\" rule=\"20.60.59.235\" />\n\t\t<item name=\"extra_20.60.133.132\" rule=\"20.60.133.132\" />\n\t\t<item name=\"extra_20.60.178.4\" rule=\"20.60.178.4\" />\n\t\t<item name=\"extra_20.60.179.4\" rule=\"20.60.179.4\" />\n\t\t<item name=\"extra_20.60.181.193\" rule=\"20.60.181.193\" />\n\t\t<item name=\"extra_20.60.181.225\" rule=\"20.60.181.225\" />\n\t\t<item name=\"extra_20.60.240.33\" rule=\"20.60.240.33\" />\n\t\t<item name=\"extra_20.60.240.65\" rule=\"20.60.240.65\" />\n\t\t<item name=\"extra_20.67.112.184\" rule=\"20.67.112.184\" />\n\t\t<item name=\"extra_20.67.219.150\" rule=\"20.67.219.150\" />\n\t\t<item name=\"extra_20.69.130.185\" rule=\"20.69.130.185\" />\n\t\t<item name=\"extra_20.72.78.248\" rule=\"20.72.78.248\" />\n\t\t<item name=\"extra_20.73.128.142\" rule=\"20.73.128.142\" />\n\t\t<item name=\"extra_20.82.209.104\" rule=\"20.82.209.104\" />\n\t\t<item name=\"extra_20.82.209.183\" rule=\"20.82.209.183\" />\n\t\t<item name=\"extra_20.82.210.154\" rule=\"20.82.210.154\" />\n\t\t<item name=\"extra_20.82.217.86\" rule=\"20.82.217.86\" />\n\t\t<item name=\"extra_20.82.250.189\" rule=\"20.82.250.189\" />\n\t\t<item name=\"extra_20.86.161.79\" rule=\"20.86.161.79\" />\n\t\t<item name=\"extra_20.86.173.234\" rule=\"20.86.173.234\" />\n\t\t<item name=\"extra_20.86.186.134\" rule=\"20.86.186.134\" />\n\t\t<item name=\"extra_20.93.58.141\" rule=\"20.93.58.141\" />\n\t\t<item name=\"extra_20.140.48.69\" rule=\"20.140.48.69\" />\n\t\t<item name=\"extra_20.140.56.70\" rule=\"20.140.56.70\" />\n\t\t<item name=\"extra_20.150.17.68\" rule=\"20.150.17.68\" />\n\t\t<item name=\"extra_20.150.29.228\" rule=\"20.150.29.228\" />\n\t\t<item name=\"extra_20.150.36.228\" rule=\"20.150.36.228\" />\n\t\t<item name=\"extra_20.150.50.4\" rule=\"20.150.50.4\" />\n\t\t<item name=\"extra_20.150.50.132\" rule=\"20.150.50.132\" />\n\t\t<item name=\"extra_20.150.77.68\" rule=\"20.150.77.68\" />\n\t\t<item name=\"extra_20.150.77.100\" rule=\"20.150.77.100\" />\n\t\t<item name=\"extra_20.150.88.4\" rule=\"20.150.88.4\" />\n\t\t<item name=\"extra_20.150.88.132\" rule=\"20.150.88.132\" />\n\t\t<item name=\"extra_20.150.88.196\" rule=\"20.150.88.196\" />\n\t\t<item name=\"extra_20.150.95.4\" rule=\"20.150.95.4\" />\n\t\t<item name=\"extra_20.150.95.132\" rule=\"20.150.95.132\" />\n\t\t<item name=\"extra_20.150.95.164\" rule=\"20.150.95.164\" />\n\t\t<item name=\"extra_20.150.95.196\" rule=\"20.150.95.196\" />\n\t\t<item name=\"extra_20.150.95.228\" rule=\"20.150.95.228\" />\n\t\t<item name=\"extra_20.188.76.57\" rule=\"20.188.76.57\" />\n\t\t<item name=\"extra_20.189.74.153\" rule=\"20.189.74.153\" />\n\t\t<item name=\"extra_20.189.79.72\" rule=\"20.189.79.72\" />\n\t\t<item name=\"extra_20.189.118.208\" rule=\"20.189.118.208\" />\n\t\t<item name=\"extra_20.189.173.1\" rule=\"20.189.173.1\" />\n\t\t<item name=\"extra_20.189.173.2\" rule=\"20.189.173.2\" />\n\t\t<item name=\"extra_20.189.173.3\" rule=\"20.189.173.3\" />\n\t\t<item name=\"extra_20.189.173.4\" rule=\"20.189.173.4\" />\n\t\t<item name=\"extra_20.189.173.5\" rule=\"20.189.173.5\" />\n\t\t<item name=\"extra_20.189.173.6\" rule=\"20.189.173.6\" />\n\t\t<item name=\"extra_20.189.173.7\" rule=\"20.189.173.7\" />\n\t\t<item name=\"extra_20.189.173.8\" rule=\"20.189.173.8\" />\n\t\t<item name=\"extra_20.189.173.9\" rule=\"20.189.173.9\" />\n\t\t<item name=\"extra_20.189.173.10\" rule=\"20.189.173.10\" />\n\t\t<item name=\"extra_20.189.173.11\" rule=\"20.189.173.11\" />\n\t\t<item name=\"extra_20.189.173.12\" rule=\"20.189.173.12\" />\n\t\t<item name=\"extra_20.189.173.13\" rule=\"20.189.173.13\" />\n\t\t<item name=\"extra_20.189.173.14\" rule=\"20.189.173.14\" />\n\t\t<item name=\"extra_20.189.173.15\" rule=\"20.189.173.15\" />\n\t\t<item name=\"extra_20.189.173.20\" rule=\"20.189.173.20\" />\n\t\t<item name=\"extra_20.189.173.21\" rule=\"20.189.173.21\" />\n\t\t<item name=\"extra_20.189.173.22\" rule=\"20.189.173.22\" />\n\t\t<item name=\"extra_20.190.129.2\" rule=\"20.190.129.2\" />\n\t\t<item name=\"extra_20.190.129.17\" rule=\"20.190.129.17\" />\n\t\t<item name=\"extra_20.190.129.19\" rule=\"20.190.129.19\" />\n\t\t<item name=\"extra_20.190.129.24\" rule=\"20.190.129.24\" />\n\t\t<item name=\"extra_20.190.129.128\" rule=\"20.190.129.128\" />\n\t\t<item name=\"extra_20.190.129.130\" rule=\"20.190.129.130\" />\n\t\t<item name=\"extra_20.190.129.133\" rule=\"20.190.129.133\" />\n\t\t<item name=\"extra_20.190.129.160\" rule=\"20.190.129.160\" />\n\t\t<item name=\"extra_20.190.137.6\" rule=\"20.190.137.6\" />\n\t\t<item name=\"extra_20.190.137.10\" rule=\"20.190.137.10\" />\n\t\t<item name=\"extra_20.190.137.14\" rule=\"20.190.137.14\" />\n\t\t<item name=\"extra_20.190.137.69\" rule=\"20.190.137.69\" />\n\t\t<item name=\"extra_20.190.137.73\" rule=\"20.190.137.73\" />\n\t\t<item name=\"extra_20.190.137.75\" rule=\"20.190.137.75\" />\n\t\t<item name=\"extra_20.190.137.96\" rule=\"20.190.137.96\" />\n\t\t<item name=\"extra_20.190.137.98\" rule=\"20.190.137.98\" />\n\t\t<item name=\"extra_20.190.159.0\" rule=\"20.190.159.0\" />\n\t\t<item name=\"extra_20.190.159.2\" rule=\"20.190.159.2\" />\n\t\t<item name=\"extra_20.190.159.4\" rule=\"20.190.159.4\" />\n\t\t<item name=\"extra_20.190.159.23\" rule=\"20.190.159.23\" />\n\t\t<item name=\"extra_20.190.159.30\" rule=\"20.190.159.30\" />\n\t\t<item name=\"extra_20.190.159.32\" rule=\"20.190.159.32\" />\n\t\t<item name=\"extra_20.190.159.64\" rule=\"20.190.159.64\" />\n\t\t<item name=\"extra_20.190.159.71\" rule=\"20.190.159.71\" />\n\t\t<item name=\"extra_20.190.159.73\" rule=\"20.190.159.73\" />\n\t\t<item name=\"extra_20.190.159.132\" rule=\"20.190.159.132\" />\n\t\t<item name=\"extra_20.190.159.134\" rule=\"20.190.159.134\" />\n\t\t<item name=\"extra_20.190.159.136\" rule=\"20.190.159.136\" />\n\t\t<item name=\"extra_20.190.159.138\" rule=\"20.190.159.138\" />\n\t\t<item name=\"extra_20.190.159.161\" rule=\"20.190.159.161\" />\n\t\t<item name=\"extra_20.190.159.162\" rule=\"20.190.159.162\" />\n\t\t<item name=\"extra_20.190.160.2\" rule=\"20.190.160.2\" />\n\t\t<item name=\"extra_20.190.160.4\" rule=\"20.190.160.4\" />\n\t\t<item name=\"extra_20.190.160.6\" rule=\"20.190.160.6\" />\n\t\t<item name=\"extra_20.190.160.8\" rule=\"20.190.160.8\" />\n\t\t<item name=\"extra_20.190.160.14\" rule=\"20.190.160.14\" />\n\t\t<item name=\"extra_20.190.160.17\" rule=\"20.190.160.17\" />\n\t\t<item name=\"extra_20.190.160.20\" rule=\"20.190.160.20\" />\n\t\t<item name=\"extra_20.190.160.22\" rule=\"20.190.160.22\" />\n\t\t<item name=\"extra_20.190.160.24\" rule=\"20.190.160.24\" />\n\t\t<item name=\"extra_20.190.160.67\" rule=\"20.190.160.67\" />\n\t\t<item name=\"extra_20.190.160.69\" rule=\"20.190.160.69\" />\n\t\t<item name=\"extra_20.190.160.71\" rule=\"20.190.160.71\" />\n\t\t<item name=\"extra_20.190.160.73\" rule=\"20.190.160.73\" />\n\t\t<item name=\"extra_20.190.160.75\" rule=\"20.190.160.75\" />\n\t\t<item name=\"extra_20.190.160.129\" rule=\"20.190.160.129\" />\n\t\t<item name=\"extra_20.190.160.132\" rule=\"20.190.160.132\" />\n\t\t<item name=\"extra_20.190.160.134\" rule=\"20.190.160.134\" />\n\t\t<item name=\"extra_20.190.160.136\" rule=\"20.190.160.136\" />\n\t\t<item name=\"extra_23.96.52.53\" rule=\"23.96.52.53\" />\n\t\t<item name=\"extra_23.96.208.208\" rule=\"23.96.208.208\" />\n\t\t<item name=\"extra_23.97.61.137\" rule=\"23.97.61.137\" />\n\t\t<item name=\"extra_23.97.153.169\" rule=\"23.97.153.169\" />\n\t\t<item name=\"extra_23.97.178.173\" rule=\"23.97.178.173\" />\n\t\t<item name=\"extra_23.97.209.97\" rule=\"23.97.209.97\" />\n\t\t<item name=\"extra_23.99.109.44\" rule=\"23.99.109.44\" />\n\t\t<item name=\"extra_23.99.109.64\" rule=\"23.99.109.64\" />\n\t\t<item name=\"extra_23.99.116.116\" rule=\"23.99.116.116\" />\n\t\t<item name=\"extra_23.99.121.207\" rule=\"23.99.121.207\" />\n\t\t<item name=\"extra_23.99.206.110\" rule=\"23.99.206.110\" />\n\t\t<item name=\"extra_23.100.122.175\" rule=\"23.100.122.175\" />\n\t\t<item name=\"extra_23.101.156.198\" rule=\"23.101.156.198\" />\n\t\t<item name=\"extra_23.101.158.111\" rule=\"23.101.158.111\" />\n\t\t<item name=\"extra_23.102.47.40\" rule=\"23.102.47.40\" />\n\t\t<item name=\"extra_40.67.249.61\" rule=\"40.67.249.61\" />\n\t\t<item name=\"extra_40.69.176.16\" rule=\"40.69.176.16\" />\n\t\t<item name=\"extra_40.70.0.108\" rule=\"40.70.0.108\" />\n\t\t<item name=\"extra_40.70.158.26\" rule=\"40.70.158.26\" />\n\t\t<item name=\"extra_40.70.186.239\" rule=\"40.70.186.239\" />\n\t\t<item name=\"extra_40.70.221.249\" rule=\"40.70.221.249\" />\n\t\t<item name=\"extra_40.74.35.71\" rule=\"40.74.35.71\" />\n\t\t<item name=\"extra_40.74.70.63\" rule=\"40.74.70.63\" />\n\t\t<item name=\"extra_40.74.94.131\" rule=\"40.74.94.131\" />\n\t\t<item name=\"extra_40.74.98.192\" rule=\"40.74.98.192\" />\n\t\t<item name=\"extra_40.74.98.193\" rule=\"40.74.98.193\" />\n\t\t<item name=\"extra_40.74.98.194\" rule=\"40.74.98.194\" />\n\t\t<item name=\"extra_40.74.98.195\" rule=\"40.74.98.195\" />\n\t\t<item name=\"extra_40.74.108.123\" rule=\"40.74.108.123\" />\n\t\t<item name=\"extra_40.77.225.248\" rule=\"40.77.225.248\" />\n\t\t<item name=\"extra_40.77.230.45\" rule=\"40.77.230.45\" />\n\t\t<item name=\"extra_40.79.48.16\" rule=\"40.79.48.16\" />\n\t\t<item name=\"extra_40.79.138.41\" rule=\"40.79.138.41\" />\n\t\t<item name=\"extra_40.79.189.58\" rule=\"40.79.189.58\" />\n\t\t<item name=\"extra_40.79.189.59\" rule=\"40.79.189.59\" />\n\t\t<item name=\"extra_40.79.197.35\" rule=\"40.79.197.35\" />\n\t\t<item name=\"extra_40.80.145.78\" rule=\"40.80.145.78\" />\n\t\t<item name=\"extra_40.81.30.53\" rule=\"40.81.30.53\" />\n\t\t<item name=\"extra_40.81.94.65\" rule=\"40.81.94.65\" />\n\t\t<item name=\"extra_40.81.188.85\" rule=\"40.81.188.85\" />\n\t\t<item name=\"extra_40.83.74.46\" rule=\"40.83.74.46\" />\n\t\t<item name=\"extra_40.83.127.51\" rule=\"40.83.127.51\" />\n\t\t<item name=\"extra_40.83.150.233\" rule=\"40.83.150.233\" />\n\t\t<item name=\"extra_40.85.78.63\" rule=\"40.85.78.63\" />\n\t\t<item name=\"extra_40.85.83.182\" rule=\"40.85.83.182\" />\n\t\t<item name=\"extra_40.89.135.48\" rule=\"40.89.135.48\" />\n\t\t<item name=\"extra_40.90.22.183\" rule=\"40.90.22.183\" />\n\t\t<item name=\"extra_40.90.22.184\" rule=\"40.90.22.184\" />\n\t\t<item name=\"extra_40.90.22.185\" rule=\"40.90.22.185\" />\n\t\t<item name=\"extra_40.90.22.186\" rule=\"40.90.22.186\" />\n\t\t<item name=\"extra_40.90.22.187\" rule=\"40.90.22.187\" />\n\t\t<item name=\"extra_40.90.22.188\" rule=\"40.90.22.188\" />\n\t\t<item name=\"extra_40.90.22.189\" rule=\"40.90.22.189\" />\n\t\t<item name=\"extra_40.90.22.190\" rule=\"40.90.22.190\" />\n\t\t<item name=\"extra_40.90.22.191\" rule=\"40.90.22.191\" />\n\t\t<item name=\"extra_40.90.22.192\" rule=\"40.90.22.192\" />\n\t\t<item name=\"extra_40.90.22.198\" rule=\"40.90.22.198\" />\n\t\t<item name=\"extra_40.90.23.0-40.90.23.255\" rule=\"40.90.23.0-40.90.23.255\" />\n\t\t<item name=\"extra_40.90.65.7\" rule=\"40.90.65.7\" />\n\t\t<item name=\"extra_40.90.65.17\" rule=\"40.90.65.17\" />\n\t\t<item name=\"extra_40.90.65.22\" rule=\"40.90.65.22\" />\n\t\t<item name=\"extra_40.90.65.26\" rule=\"40.90.65.26\" />\n\t\t<item name=\"extra_40.90.65.28\" rule=\"40.90.65.28\" />\n\t\t<item name=\"extra_40.90.65.32\" rule=\"40.90.65.32\" />\n\t\t<item name=\"extra_40.90.65.44\" rule=\"40.90.65.44\" />\n\t\t<item name=\"extra_40.90.65.53\" rule=\"40.90.65.53\" />\n\t\t<item name=\"extra_40.90.65.54\" rule=\"40.90.65.54\" />\n\t\t<item name=\"extra_40.90.65.65\" rule=\"40.90.65.65\" />\n\t\t<item name=\"extra_40.90.128.17\" rule=\"40.90.128.17\" />\n\t\t<item name=\"extra_40.90.130.192\" rule=\"40.90.130.192\" />\n\t\t<item name=\"extra_40.90.133.97\" rule=\"40.90.133.97\" />\n\t\t<item name=\"extra_40.90.133.112\" rule=\"40.90.133.112\" />\n\t\t<item name=\"extra_40.90.136.1\" rule=\"40.90.136.1\" />\n\t\t<item name=\"extra_40.90.136.3\" rule=\"40.90.136.3\" />\n\t\t<item name=\"extra_40.90.136.19\" rule=\"40.90.136.19\" />\n\t\t<item name=\"extra_40.90.136.20\" rule=\"40.90.136.20\" />\n\t\t<item name=\"extra_40.90.136.163\" rule=\"40.90.136.163\" />\n\t\t<item name=\"extra_40.90.136.166\" rule=\"40.90.136.166\" />\n\t\t<item name=\"extra_40.90.136.179\" rule=\"40.90.136.179\" />\n\t\t<item name=\"extra_40.90.136.180\" rule=\"40.90.136.180\" />\n\t\t<item name=\"extra_40.90.136.182\" rule=\"40.90.136.182\" />\n\t\t<item name=\"extra_40.90.137.120\" rule=\"40.90.137.120\" />\n\t\t<item name=\"extra_40.90.137.122\" rule=\"40.90.137.122\" />\n\t\t<item name=\"extra_40.90.137.124\" rule=\"40.90.137.124\" />\n\t\t<item name=\"extra_40.90.137.125\" rule=\"40.90.137.125\" />\n\t\t<item name=\"extra_40.90.137.126\" rule=\"40.90.137.126\" />\n\t\t<item name=\"extra_40.90.137.127\" rule=\"40.90.137.127\" />\n\t\t<item name=\"extra_40.90.142.224\" rule=\"40.90.142.224\" />\n\t\t<item name=\"extra_40.90.142.226\" rule=\"40.90.142.226\" />\n\t\t<item name=\"extra_40.90.142.230\" rule=\"40.90.142.230\" />\n\t\t<item name=\"extra_40.90.190.179\" rule=\"40.90.190.179\" />\n\t\t<item name=\"extra_40.90.218.0\" rule=\"40.90.218.0\" />\n\t\t<item name=\"extra_40.90.221.9\" rule=\"40.90.221.9\" />\n\t\t<item name=\"extra_40.91.76.238\" rule=\"40.91.76.238\" />\n\t\t<item name=\"extra_40.91.78.9\" rule=\"40.91.78.9\" />\n\t\t<item name=\"extra_40.97.161.50\" rule=\"40.97.161.50\" />\n\t\t<item name=\"extra_40.100.54.2\" rule=\"40.100.54.2\" />\n\t\t<item name=\"extra_40.100.54.194\" rule=\"40.100.54.194\" />\n\t\t<item name=\"extra_40.100.174.2\" rule=\"40.100.174.2\" />\n\t\t<item name=\"extra_40.100.174.18\" rule=\"40.100.174.18\" />\n\t\t<item name=\"extra_40.100.174.34\" rule=\"40.100.174.34\" />\n\t\t<item name=\"extra_40.100.174.194\" rule=\"40.100.174.194\" />\n\t\t<item name=\"extra_40.100.174.210\" rule=\"40.100.174.210\" />\n\t\t<item name=\"extra_40.100.174.226\" rule=\"40.100.174.226\" />\n\t\t<item name=\"extra_40.100.175.146\" rule=\"40.100.175.146\" />\n\t\t<item name=\"extra_40.101.4.2\" rule=\"40.101.4.2\" />\n\t\t<item name=\"extra_40.101.12.2\" rule=\"40.101.12.2\" />\n\t\t<item name=\"extra_40.101.12.50\" rule=\"40.101.12.50\" />\n\t\t<item name=\"extra_40.101.12.66\" rule=\"40.101.12.66\" />\n\t\t<item name=\"extra_40.101.12.98\" rule=\"40.101.12.98\" />\n\t\t<item name=\"extra_40.101.12.114\" rule=\"40.101.12.114\" />\n\t\t<item name=\"extra_40.101.12.130\" rule=\"40.101.12.130\" />\n\t\t<item name=\"extra_40.101.18.18\" rule=\"40.101.18.18\" />\n\t\t<item name=\"extra_40.101.18.226\" rule=\"40.101.18.226\" />\n\t\t<item name=\"extra_40.101.18.242\" rule=\"40.101.18.242\" />\n\t\t<item name=\"extra_40.101.19.146\" rule=\"40.101.19.146\" />\n\t\t<item name=\"extra_40.101.19.162\" rule=\"40.101.19.162\" />\n\t\t<item name=\"extra_40.101.46.178\" rule=\"40.101.46.178\" />\n\t\t<item name=\"extra_40.101.80.2\" rule=\"40.101.80.2\" />\n\t\t<item name=\"extra_40.101.80.18\" rule=\"40.101.80.18\" />\n\t\t<item name=\"extra_40.101.80.178\" rule=\"40.101.80.178\" />\n\t\t<item name=\"extra_40.101.80.194\" rule=\"40.101.80.194\" />\n\t\t<item name=\"extra_40.101.81.130\" rule=\"40.101.81.130\" />\n\t\t<item name=\"extra_40.101.81.146\" rule=\"40.101.81.146\" />\n\t\t<item name=\"extra_40.101.83.18\" rule=\"40.101.83.18\" />\n\t\t<item name=\"extra_40.101.83.194\" rule=\"40.101.83.194\" />\n\t\t<item name=\"extra_40.101.121.2\" rule=\"40.101.121.2\" />\n\t\t<item name=\"extra_40.101.121.18\" rule=\"40.101.121.18\" />\n\t\t<item name=\"extra_40.101.121.34\" rule=\"40.101.121.34\" />\n\t\t<item name=\"extra_40.101.124.34\" rule=\"40.101.124.34\" />\n\t\t<item name=\"extra_40.101.124.194\" rule=\"40.101.124.194\" />\n\t\t<item name=\"extra_40.101.128.178\" rule=\"40.101.128.178\" />\n\t\t<item name=\"extra_40.101.136.2\" rule=\"40.101.136.2\" />\n\t\t<item name=\"extra_40.101.136.18\" rule=\"40.101.136.18\" />\n\t\t<item name=\"extra_40.101.136.242\" rule=\"40.101.136.242\" />\n\t\t<item name=\"extra_40.101.137.2\" rule=\"40.101.137.2\" />\n\t\t<item name=\"extra_40.101.137.18\" rule=\"40.101.137.18\" />\n\t\t<item name=\"extra_40.101.137.34\" rule=\"40.101.137.34\" />\n\t\t<item name=\"extra_40.101.137.50\" rule=\"40.101.137.50\" />\n\t\t<item name=\"extra_40.101.137.66\" rule=\"40.101.137.66\" />\n\t\t<item name=\"extra_40.101.137.82\" rule=\"40.101.137.82\" />\n\t\t<item name=\"extra_40.101.137.98\" rule=\"40.101.137.98\" />\n\t\t<item name=\"extra_40.101.138.2\" rule=\"40.101.138.2\" />\n\t\t<item name=\"extra_40.101.138.18\" rule=\"40.101.138.18\" />\n\t\t<item name=\"extra_40.101.138.210\" rule=\"40.101.138.210\" />\n\t\t<item name=\"extra_40.102.34.194\" rule=\"40.102.34.194\" />\n\t\t<item name=\"extra_40.112.72.19\" rule=\"40.112.72.19\" />\n\t\t<item name=\"extra_40.112.72.44\" rule=\"40.112.72.44\" />\n\t\t<item name=\"extra_40.112.75.175\" rule=\"40.112.75.175\" />\n\t\t<item name=\"extra_40.112.90.122\" rule=\"40.112.90.122\" />\n\t\t<item name=\"extra_40.112.91.29\" rule=\"40.112.91.29\" />\n\t\t<item name=\"extra_40.112.93.153\" rule=\"40.112.93.153\" />\n\t\t<item name=\"extra_40.113.0.16\" rule=\"40.113.0.16\" />\n\t\t<item name=\"extra_40.113.10.47\" rule=\"40.113.10.47\" />\n\t\t<item name=\"extra_40.113.97.222\" rule=\"40.113.97.222\" />\n\t\t<item name=\"extra_40.113.109.30\" rule=\"40.113.109.30\" />\n\t\t<item name=\"extra_40.113.225.85\" rule=\"40.113.225.85\" />\n\t\t<item name=\"extra_40.114.54.223\" rule=\"40.114.54.223\" />\n\t\t<item name=\"extra_40.114.140.1\" rule=\"40.114.140.1\" />\n\t\t<item name=\"extra_40.114.224.200\" rule=\"40.114.224.200\" />\n\t\t<item name=\"extra_40.114.241.141\" rule=\"40.114.241.141\" />\n\t\t<item name=\"extra_40.115.33.128\" rule=\"40.115.33.128\" />\n\t\t<item name=\"extra_40.115.56.78\" rule=\"40.115.56.78\" />\n\t\t<item name=\"extra_40.115.117.93\" rule=\"40.115.117.93\" />\n\t\t<item name=\"extra_40.117.96.136\" rule=\"40.117.96.136\" />\n\t\t<item name=\"extra_40.117.190.72\" rule=\"40.117.190.72\" />\n\t\t<item name=\"extra_40.118.61.1\" rule=\"40.118.61.1\" />\n\t\t<item name=\"extra_40.118.103.7\" rule=\"40.118.103.7\" />\n\t\t<item name=\"extra_40.118.106.130\" rule=\"40.118.106.130\" />\n\t\t<item name=\"extra_40.119.6.179\" rule=\"40.119.6.179\" />\n\t\t<item name=\"extra_40.119.249.228\" rule=\"40.119.249.228\" />\n\t\t<item name=\"extra_40.121.213.159\" rule=\"40.121.213.159\" />\n\t\t<item name=\"extra_40.122.160.14\" rule=\"40.122.160.14\" />\n\t\t<item name=\"extra_40.122.192.126\" rule=\"40.122.192.126\" />\n\t\t<item name=\"extra_40.124.168.44\" rule=\"40.124.168.44\" />\n\t\t<item name=\"extra_40.125.120.53\" rule=\"40.125.120.53\" />\n\t\t<item name=\"extra_40.126.1.128\" rule=\"40.126.1.128\" />\n\t\t<item name=\"extra_40.126.1.130\" rule=\"40.126.1.130\" />\n\t\t<item name=\"extra_40.126.1.142\" rule=\"40.126.1.142\" />\n\t\t<item name=\"extra_40.126.1.145\" rule=\"40.126.1.145\" />\n\t\t<item name=\"extra_40.126.1.166\" rule=\"40.126.1.166\" />\n\t\t<item name=\"extra_40.126.9.5\" rule=\"40.126.9.5\" />\n\t\t<item name=\"extra_40.126.9.6\" rule=\"40.126.9.6\" />\n\t\t<item name=\"extra_40.126.9.8\" rule=\"40.126.9.8\" />\n\t\t<item name=\"extra_40.126.9.66\" rule=\"40.126.9.66\" />\n\t\t<item name=\"extra_40.126.9.73\" rule=\"40.126.9.73\" />\n\t\t<item name=\"extra_40.126.9.77\" rule=\"40.126.9.77\" />\n\t\t<item name=\"extra_40.126.31.1\" rule=\"40.126.31.1\" />\n\t\t<item name=\"extra_40.126.31.4\" rule=\"40.126.31.4\" />\n\t\t<item name=\"extra_40.126.31.6\" rule=\"40.126.31.6\" />\n\t\t<item name=\"extra_40.126.31.8\" rule=\"40.126.31.8\" />\n\t\t<item name=\"extra_40.126.31.69\" rule=\"40.126.31.69\" />\n\t\t<item name=\"extra_40.126.31.71\" rule=\"40.126.31.71\" />\n\t\t<item name=\"extra_40.126.31.135\" rule=\"40.126.31.135\" />\n\t\t<item name=\"extra_40.126.31.137\" rule=\"40.126.31.137\" />\n\t\t<item name=\"extra_40.126.31.139\" rule=\"40.126.31.139\" />\n\t\t<item name=\"extra_40.126.31.141\" rule=\"40.126.31.141\" />\n\t\t<item name=\"extra_40.126.31.143\" rule=\"40.126.31.143\" />\n\t\t<item name=\"extra_40.126.31.163\" rule=\"40.126.31.163\" />\n\t\t<item name=\"extra_40.126.31.164\" rule=\"40.126.31.164\" />\n\t\t<item name=\"extra_40.126.32.68\" rule=\"40.126.32.68\" />\n\t\t<item name=\"extra_40.126.32.72\" rule=\"40.126.32.72\" />\n\t\t<item name=\"extra_40.126.32.74\" rule=\"40.126.32.74\" />\n\t\t<item name=\"extra_40.126.32.133\" rule=\"40.126.32.133\" />\n\t\t<item name=\"extra_40.126.32.134\" rule=\"40.126.32.134\" />\n\t\t<item name=\"extra_40.126.32.136\" rule=\"40.126.32.136\" />\n\t\t<item name=\"extra_40.126.32.138\" rule=\"40.126.32.138\" />\n\t\t<item name=\"extra_40.126.32.140\" rule=\"40.126.32.140\" />\n\t\t<item name=\"extra_40.127.128.174\" rule=\"40.127.128.174\" />\n\t\t<item name=\"extra_40.127.142.76\" rule=\"40.127.142.76\" />\n\t\t<item name=\"extra_40.127.195.156\" rule=\"40.127.195.156\" />\n\t\t<item name=\"extra_40.127.240.158\" rule=\"40.127.240.158\" />\n\t\t<item name=\"extra_40.127.243.65\" rule=\"40.127.243.65\" />\n\t\t<item name=\"extra_51.11.168.160\" rule=\"51.11.168.160\" />\n\t\t<item name=\"extra_51.11.168.232\" rule=\"51.11.168.232\" />\n\t\t<item name=\"extra_51.104.15.252\" rule=\"51.104.15.252\" />\n\t\t<item name=\"extra_51.104.15.253\" rule=\"51.104.15.253\" />\n\t\t<item name=\"extra_51.104.139.180\" rule=\"51.104.139.180\" />\n\t\t<item name=\"extra_51.104.144.132\" rule=\"51.104.144.132\" />\n\t\t<item name=\"extra_51.104.146.109\" rule=\"51.104.146.109\" />\n\t\t<item name=\"extra_51.105.71.136\" rule=\"51.105.71.136\" />\n\t\t<item name=\"extra_51.105.71.137\" rule=\"51.105.71.137\" />\n\t\t<item name=\"extra_51.105.208.173\" rule=\"51.105.208.173\" />\n\t\t<item name=\"extra_51.105.236.244\" rule=\"51.105.236.244\" />\n\t\t<item name=\"extra_51.116.232.21\" rule=\"51.116.232.21\" />\n\t\t<item name=\"extra_51.124.78.146\" rule=\"51.124.78.146\" />\n\t\t<item name=\"extra_51.132.193.104\" rule=\"51.132.193.104\" />\n\t\t<item name=\"extra_51.132.193.105\" rule=\"51.132.193.105\" />\n\t\t<item name=\"extra_51.132.208.181\" rule=\"51.132.208.181\" />\n\t\t<item name=\"extra_51.136.15.177\" rule=\"51.136.15.177\" />\n\t\t<item name=\"extra_51.136.37.147\" rule=\"51.136.37.147\" />\n\t\t<item name=\"extra_51.138.106.75\" rule=\"51.138.106.75\" />\n\t\t<item name=\"extra_51.140.65.84\" rule=\"51.140.65.84\" />\n\t\t<item name=\"extra_51.140.98.69\" rule=\"51.140.98.69\" />\n\t\t<item name=\"extra_51.140.127.197\" rule=\"51.140.127.197\" />\n\t\t<item name=\"extra_51.141.26.229\" rule=\"51.141.26.229\" />\n\t\t<item name=\"extra_51.141.32.51\" rule=\"51.141.32.51\" />\n\t\t<item name=\"extra_51.141.118.220\" rule=\"51.141.118.220\" />\n\t\t<item name=\"extra_51.141.166.104\" rule=\"51.141.166.104\" />\n\t\t<item name=\"extra_51.143.49.132\" rule=\"51.143.49.132\" />\n\t\t<item name=\"extra_51.144.108.120\" rule=\"51.144.108.120\" />\n\t\t<item name=\"extra_51.144.113.175\" rule=\"51.144.113.175\" />\n\t\t<item name=\"extra_52.97.129.66\" rule=\"52.97.129.66\" />\n\t\t<item name=\"extra_52.97.129.226\" rule=\"52.97.129.226\" />\n\t\t<item name=\"extra_52.97.129.242\" rule=\"52.97.129.242\" />\n\t\t<item name=\"extra_52.97.133.146\" rule=\"52.97.133.146\" />\n\t\t<item name=\"extra_52.97.133.162\" rule=\"52.97.133.162\" />\n\t\t<item name=\"extra_52.97.133.178\" rule=\"52.97.133.178\" />\n\t\t<item name=\"extra_52.97.133.194\" rule=\"52.97.133.194\" />\n\t\t<item name=\"extra_52.97.133.210\" rule=\"52.97.133.210\" />\n\t\t<item name=\"extra_52.97.133.226\" rule=\"52.97.133.226\" />\n\t\t<item name=\"extra_52.97.133.242\" rule=\"52.97.133.242\" />\n\t\t<item name=\"extra_52.97.135.114\" rule=\"52.97.135.114\" />\n\t\t<item name=\"extra_52.97.144.2\" rule=\"52.97.144.2\" />\n\t\t<item name=\"extra_52.97.146.34\" rule=\"52.97.146.34\" />\n\t\t<item name=\"extra_52.97.146.130\" rule=\"52.97.146.130\" />\n\t\t<item name=\"extra_52.97.146.162\" rule=\"52.97.146.162\" />\n\t\t<item name=\"extra_52.97.146.194\" rule=\"52.97.146.194\" />\n\t\t<item name=\"extra_52.97.146.210\" rule=\"52.97.146.210\" />\n\t\t<item name=\"extra_52.97.150.2\" rule=\"52.97.150.2\" />\n\t\t<item name=\"extra_52.97.151.50\" rule=\"52.97.151.50\" />\n\t\t<item name=\"extra_52.97.151.82\" rule=\"52.97.151.82\" />\n\t\t<item name=\"extra_52.97.152.114\" rule=\"52.97.152.114\" />\n\t\t<item name=\"extra_52.97.155.114\" rule=\"52.97.155.114\" />\n\t\t<item name=\"extra_52.97.158.162\" rule=\"52.97.158.162\" />\n\t\t<item name=\"extra_52.97.163.2\" rule=\"52.97.163.2\" />\n\t\t<item name=\"extra_52.97.170.34\" rule=\"52.97.170.34\" />\n\t\t<item name=\"extra_52.97.171.194\" rule=\"52.97.171.194\" />\n\t\t<item name=\"extra_52.97.179.194\" rule=\"52.97.179.194\" />\n\t\t<item name=\"extra_52.97.179.226\" rule=\"52.97.179.226\" />\n\t\t<item name=\"extra_52.97.179.242\" rule=\"52.97.179.242\" />\n\t\t<item name=\"extra_52.97.186.114\" rule=\"52.97.186.114\" />\n\t\t<item name=\"extra_52.97.188.66\" rule=\"52.97.188.66\" />\n\t\t<item name=\"extra_52.97.189.98\" rule=\"52.97.189.98\" />\n\t\t<item name=\"extra_52.97.200.130\" rule=\"52.97.200.130\" />\n\t\t<item name=\"extra_52.97.200.146\" rule=\"52.97.200.146\" />\n\t\t<item name=\"extra_52.97.200.178\" rule=\"52.97.200.178\" />\n\t\t<item name=\"extra_52.97.201.2\" rule=\"52.97.201.2\" />\n\t\t<item name=\"extra_52.97.201.18\" rule=\"52.97.201.18\" />\n\t\t<item name=\"extra_52.97.201.34\" rule=\"52.97.201.34\" />\n\t\t<item name=\"extra_52.97.201.50\" rule=\"52.97.201.50\" />\n\t\t<item name=\"extra_52.97.201.66\" rule=\"52.97.201.66\" />\n\t\t<item name=\"extra_52.97.201.98\" rule=\"52.97.201.98\" />\n\t\t<item name=\"extra_52.97.208.18\" rule=\"52.97.208.18\" />\n\t\t<item name=\"extra_52.97.208.50\" rule=\"52.97.208.50\" />\n\t\t<item name=\"extra_52.97.211.66\" rule=\"52.97.211.66\" />\n\t\t<item name=\"extra_52.97.211.82\" rule=\"52.97.211.82\" />\n\t\t<item name=\"extra_52.97.211.98\" rule=\"52.97.211.98\" />\n\t\t<item name=\"extra_52.97.211.114\" rule=\"52.97.211.114\" />\n\t\t<item name=\"extra_52.97.211.130\" rule=\"52.97.211.130\" />\n\t\t<item name=\"extra_52.97.211.146\" rule=\"52.97.211.146\" />\n\t\t<item name=\"extra_52.97.211.162\" rule=\"52.97.211.162\" />\n\t\t<item name=\"extra_52.97.211.178\" rule=\"52.97.211.178\" />\n\t\t<item name=\"extra_52.97.211.194\" rule=\"52.97.211.194\" />\n\t\t<item name=\"extra_52.97.211.210\" rule=\"52.97.211.210\" />\n\t\t<item name=\"extra_52.97.211.226\" rule=\"52.97.211.226\" />\n\t\t<item name=\"extra_52.97.211.242\" rule=\"52.97.211.242\" />\n\t\t<item name=\"extra_52.97.212.82\" rule=\"52.97.212.82\" />\n\t\t<item name=\"extra_52.97.212.98\" rule=\"52.97.212.98\" />\n\t\t<item name=\"extra_52.97.212.114\" rule=\"52.97.212.114\" />\n\t\t<item name=\"extra_52.97.215.98\" rule=\"52.97.215.98\" />\n\t\t<item name=\"extra_52.97.219.194\" rule=\"52.97.219.194\" />\n\t\t<item name=\"extra_52.97.219.210\" rule=\"52.97.219.210\" />\n\t\t<item name=\"extra_52.97.219.226\" rule=\"52.97.219.226\" />\n\t\t<item name=\"extra_52.97.219.242\" rule=\"52.97.219.242\" />\n\t\t<item name=\"extra_52.97.232.194\" rule=\"52.97.232.194\" />\n\t\t<item name=\"extra_52.97.233.2\" rule=\"52.97.233.2\" />\n\t\t<item name=\"extra_52.97.233.18\" rule=\"52.97.233.18\" />\n\t\t<item name=\"extra_52.97.233.34\" rule=\"52.97.233.34\" />\n\t\t<item name=\"extra_52.97.233.50\" rule=\"52.97.233.50\" />\n\t\t<item name=\"extra_52.97.233.66\" rule=\"52.97.233.66\" />\n\t\t<item name=\"extra_52.97.233.82\" rule=\"52.97.233.82\" />\n\t\t<item name=\"extra_52.97.233.98\" rule=\"52.97.233.98\" />\n\t\t<item name=\"extra_52.97.233.114\" rule=\"52.97.233.114\" />\n\t\t<item name=\"extra_52.97.241.162\" rule=\"52.97.241.162\" />\n\t\t<item name=\"extra_52.97.241.178\" rule=\"52.97.241.178\" />\n\t\t<item name=\"extra_52.97.250.194\" rule=\"52.97.250.194\" />\n\t\t<item name=\"extra_52.97.250.226\" rule=\"52.97.250.226\" />\n\t\t<item name=\"extra_52.98.5.194\" rule=\"52.98.5.194\" />\n\t\t<item name=\"extra_52.98.42.194\" rule=\"52.98.42.194\" />\n\t\t<item name=\"extra_52.98.66.98\" rule=\"52.98.66.98\" />\n\t\t<item name=\"extra_52.98.145.66\" rule=\"52.98.145.66\" />\n\t\t<item name=\"extra_52.98.145.82\" rule=\"52.98.145.82\" />\n\t\t<item name=\"extra_52.98.145.98\" rule=\"52.98.145.98\" />\n\t\t<item name=\"extra_52.98.145.114\" rule=\"52.98.145.114\" />\n\t\t<item name=\"extra_52.98.151.226\" rule=\"52.98.151.226\" />\n\t\t<item name=\"extra_52.98.151.242\" rule=\"52.98.151.242\" />\n\t\t<item name=\"extra_52.98.207.130\" rule=\"52.98.207.130\" />\n\t\t<item name=\"extra_52.98.207.146\" rule=\"52.98.207.146\" />\n\t\t<item name=\"extra_52.98.207.162\" rule=\"52.98.207.162\" />\n\t\t<item name=\"extra_52.109.8.19\" rule=\"52.109.8.19\" />\n\t\t<item name=\"extra_52.109.8.20\" rule=\"52.109.8.20\" />\n\t\t<item name=\"extra_52.109.8.21\" rule=\"52.109.8.21\" />\n\t\t<item name=\"extra_52.109.12.18\" rule=\"52.109.12.18\" />\n\t\t<item name=\"extra_52.109.12.19\" rule=\"52.109.12.19\" />\n\t\t<item name=\"extra_52.109.12.20\" rule=\"52.109.12.20\" />\n\t\t<item name=\"extra_52.109.12.21\" rule=\"52.109.12.21\" />\n\t\t<item name=\"extra_52.109.12.22\" rule=\"52.109.12.22\" />\n\t\t<item name=\"extra_52.109.12.23\" rule=\"52.109.12.23\" />\n\t\t<item name=\"extra_52.109.12.24\" rule=\"52.109.12.24\" />\n\t\t<item name=\"extra_52.109.28.63\" rule=\"52.109.28.63\" />\n\t\t<item name=\"extra_52.109.28.107\" rule=\"52.109.28.107\" />\n\t\t<item name=\"extra_52.109.32.23\" rule=\"52.109.32.23\" />\n\t\t<item name=\"extra_52.109.32.63\" rule=\"52.109.32.63\" />\n\t\t<item name=\"extra_52.109.68.14\" rule=\"52.109.68.14\" />\n\t\t<item name=\"extra_52.109.68.21\" rule=\"52.109.68.21\" />\n\t\t<item name=\"extra_52.109.76.8\" rule=\"52.109.76.8\" />\n\t\t<item name=\"extra_52.109.76.30\" rule=\"52.109.76.30\" />\n\t\t<item name=\"extra_52.109.76.31\" rule=\"52.109.76.31\" />\n\t\t<item name=\"extra_52.109.76.32\" rule=\"52.109.76.32\" />\n\t\t<item name=\"extra_52.109.76.33\" rule=\"52.109.76.33\" />\n\t\t<item name=\"extra_52.109.76.34\" rule=\"52.109.76.34\" />\n\t\t<item name=\"extra_52.109.76.35\" rule=\"52.109.76.35\" />\n\t\t<item name=\"extra_52.109.76.36\" rule=\"52.109.76.36\" />\n\t\t<item name=\"extra_52.109.76.40\" rule=\"52.109.76.40\" />\n\t\t<item name=\"extra_52.109.76.68\" rule=\"52.109.76.68\" />\n\t\t<item name=\"extra_52.109.76.124\" rule=\"52.109.76.124\" />\n\t\t<item name=\"extra_52.109.88.6\" rule=\"52.109.88.6\" />\n\t\t<item name=\"extra_52.109.88.10\" rule=\"52.109.88.10\" />\n\t\t<item name=\"extra_52.109.88.34\" rule=\"52.109.88.34\" />\n\t\t<item name=\"extra_52.109.88.35\" rule=\"52.109.88.35\" />\n\t\t<item name=\"extra_52.109.88.36\" rule=\"52.109.88.36\" />\n\t\t<item name=\"extra_52.109.88.37\" rule=\"52.109.88.37\" />\n\t\t<item name=\"extra_52.109.88.38\" rule=\"52.109.88.38\" />\n\t\t<item name=\"extra_52.109.88.39\" rule=\"52.109.88.39\" />\n\t\t<item name=\"extra_52.109.88.40\" rule=\"52.109.88.40\" />\n\t\t<item name=\"extra_52.109.88.44\" rule=\"52.109.88.44\" />\n\t\t<item name=\"extra_52.109.88.174\" rule=\"52.109.88.174\" />\n\t\t<item name=\"extra_52.109.120.17\" rule=\"52.109.120.17\" />\n\t\t<item name=\"extra_52.109.120.18\" rule=\"52.109.120.18\" />\n\t\t<item name=\"extra_52.109.120.19\" rule=\"52.109.120.19\" />\n\t\t<item name=\"extra_52.109.120.20\" rule=\"52.109.120.20\" />\n\t\t<item name=\"extra_52.109.120.21\" rule=\"52.109.120.21\" />\n\t\t<item name=\"extra_52.109.120.22\" rule=\"52.109.120.22\" />\n\t\t<item name=\"extra_52.109.120.23\" rule=\"52.109.120.23\" />\n\t\t<item name=\"extra_52.109.124.18\" rule=\"52.109.124.18\" />\n\t\t<item name=\"extra_52.109.124.19\" rule=\"52.109.124.19\" />\n\t\t<item name=\"extra_52.109.124.20\" rule=\"52.109.124.20\" />\n\t\t<item name=\"extra_52.109.124.21\" rule=\"52.109.124.21\" />\n\t\t<item name=\"extra_52.109.124.22\" rule=\"52.109.124.22\" />\n\t\t<item name=\"extra_52.109.124.23\" rule=\"52.109.124.23\" />\n\t\t<item name=\"extra_52.109.124.24\" rule=\"52.109.124.24\" />\n\t\t<item name=\"extra_52.113.194.131\" rule=\"52.113.194.131\" />\n\t\t<item name=\"extra_52.113.194.132\" rule=\"52.113.194.132\" />\n\t\t<item name=\"extra_52.113.195.132\" rule=\"52.113.195.132\" />\n\t\t<item name=\"extra_52.113.196.254\" rule=\"52.113.196.254\" />\n\t\t<item name=\"extra_52.114.6.46\" rule=\"52.114.6.46\" />\n\t\t<item name=\"extra_52.114.6.47\" rule=\"52.114.6.47\" />\n\t\t<item name=\"extra_52.114.7.36\" rule=\"52.114.7.36\" />\n\t\t<item name=\"extra_52.114.7.37\" rule=\"52.114.7.37\" />\n\t\t<item name=\"extra_52.114.7.38\" rule=\"52.114.7.38\" />\n\t\t<item name=\"extra_52.114.7.39\" rule=\"52.114.7.39\" />\n\t\t<item name=\"extra_52.114.20.14\" rule=\"52.114.20.14\" />\n\t\t<item name=\"extra_52.114.20.18\" rule=\"52.114.20.18\" />\n\t\t<item name=\"extra_52.114.32.5\" rule=\"52.114.32.5\" />\n\t\t<item name=\"extra_52.114.32.6\" rule=\"52.114.32.6\" />\n\t\t<item name=\"extra_52.114.32.7\" rule=\"52.114.32.7\" />\n\t\t<item name=\"extra_52.114.32.8\" rule=\"52.114.32.8\" />\n\t\t<item name=\"extra_52.114.32.24\" rule=\"52.114.32.24\" />\n\t\t<item name=\"extra_52.114.32.25\" rule=\"52.114.32.25\" />\n\t\t<item name=\"extra_52.114.36.1\" rule=\"52.114.36.1\" />\n\t\t<item name=\"extra_52.114.36.2\" rule=\"52.114.36.2\" />\n\t\t<item name=\"extra_52.114.36.3\" rule=\"52.114.36.3\" />\n\t\t<item name=\"extra_52.114.36.4\" rule=\"52.114.36.4\" />\n\t\t<item name=\"extra_52.114.74.43\" rule=\"52.114.74.43\" />\n\t\t<item name=\"extra_52.114.74.44\" rule=\"52.114.74.44\" />\n\t\t<item name=\"extra_52.114.74.45\" rule=\"52.114.74.45\" />\n\t\t<item name=\"extra_52.114.75.78\" rule=\"52.114.75.78\" />\n\t\t<item name=\"extra_52.114.75.79\" rule=\"52.114.75.79\" />\n\t\t<item name=\"extra_52.114.75.149\" rule=\"52.114.75.149\" />\n\t\t<item name=\"extra_52.114.75.150\" rule=\"52.114.75.150\" />\n\t\t<item name=\"extra_52.114.76.34\" rule=\"52.114.76.34\" />\n\t\t<item name=\"extra_52.114.76.35\" rule=\"52.114.76.35\" />\n\t\t<item name=\"extra_52.114.76.37\" rule=\"52.114.76.37\" />\n\t\t<item name=\"extra_52.114.77.33\" rule=\"52.114.77.33\" />\n\t\t<item name=\"extra_52.114.77.34\" rule=\"52.114.77.34\" />\n\t\t<item name=\"extra_52.114.77.137\" rule=\"52.114.77.137\" />\n\t\t<item name=\"extra_52.114.77.164\" rule=\"52.114.77.164\" />\n\t\t<item name=\"extra_52.114.88.19\" rule=\"52.114.88.19\" />\n\t\t<item name=\"extra_52.114.88.20\" rule=\"52.114.88.20\" />\n\t\t<item name=\"extra_52.114.88.21\" rule=\"52.114.88.21\" />\n\t\t<item name=\"extra_52.114.88.22\" rule=\"52.114.88.22\" />\n\t\t<item name=\"extra_52.114.88.28\" rule=\"52.114.88.28\" />\n\t\t<item name=\"extra_52.114.88.29\" rule=\"52.114.88.29\" />\n\t\t<item name=\"extra_52.114.128.7\" rule=\"52.114.128.7\" />\n\t\t<item name=\"extra_52.114.128.8\" rule=\"52.114.128.8\" />\n\t\t<item name=\"extra_52.114.128.9\" rule=\"52.114.128.9\" />\n\t\t<item name=\"extra_52.114.128.10\" rule=\"52.114.128.10\" />\n\t\t<item name=\"extra_52.114.128.43\" rule=\"52.114.128.43\" />\n\t\t<item name=\"extra_52.114.128.44\" rule=\"52.114.128.44\" />\n\t\t<item name=\"extra_52.114.128.58\" rule=\"52.114.128.58\" />\n\t\t<item name=\"extra_52.114.128.69\" rule=\"52.114.128.69\" />\n\t\t<item name=\"extra_52.114.128.70\" rule=\"52.114.128.70\" />\n\t\t<item name=\"extra_52.114.128.71\" rule=\"52.114.128.71\" />\n\t\t<item name=\"extra_52.114.128.72\" rule=\"52.114.128.72\" />\n\t\t<item name=\"extra_52.114.128.73\" rule=\"52.114.128.73\" />\n\t\t<item name=\"extra_52.114.128.74\" rule=\"52.114.128.74\" />\n\t\t<item name=\"extra_52.114.128.75\" rule=\"52.114.128.75\" />\n\t\t<item name=\"extra_52.114.132.11\" rule=\"52.114.132.11\" />\n\t\t<item name=\"extra_52.114.132.12\" rule=\"52.114.132.12\" />\n\t\t<item name=\"extra_52.114.132.14\" rule=\"52.114.132.14\" />\n\t\t<item name=\"extra_52.114.132.20\" rule=\"52.114.132.20\" />\n\t\t<item name=\"extra_52.114.132.21\" rule=\"52.114.132.21\" />\n\t\t<item name=\"extra_52.114.132.22\" rule=\"52.114.132.22\" />\n\t\t<item name=\"extra_52.114.132.23\" rule=\"52.114.132.23\" />\n\t\t<item name=\"extra_52.114.132.34\" rule=\"52.114.132.34\" />\n\t\t<item name=\"extra_52.114.132.47\" rule=\"52.114.132.47\" />\n\t\t<item name=\"extra_52.114.132.73\" rule=\"52.114.132.73\" />\n\t\t<item name=\"extra_52.114.132.74\" rule=\"52.114.132.74\" />\n\t\t<item name=\"extra_52.114.132.91\" rule=\"52.114.132.91\" />\n\t\t<item name=\"extra_52.114.133.60\" rule=\"52.114.133.60\" />\n\t\t<item name=\"extra_52.114.133.61\" rule=\"52.114.133.61\" />\n\t\t<item name=\"extra_52.114.158.50\" rule=\"52.114.158.50\" />\n\t\t<item name=\"extra_52.114.158.51\" rule=\"52.114.158.51\" />\n\t\t<item name=\"extra_52.114.158.52\" rule=\"52.114.158.52\" />\n\t\t<item name=\"extra_52.114.158.53\" rule=\"52.114.158.53\" />\n\t\t<item name=\"extra_52.114.158.91\" rule=\"52.114.158.91\" />\n\t\t<item name=\"extra_52.114.158.92\" rule=\"52.114.158.92\" />\n\t\t<item name=\"extra_52.114.158.102\" rule=\"52.114.158.102\" />\n\t\t<item name=\"extra_52.114.159.22\" rule=\"52.114.159.22\" />\n\t\t<item name=\"extra_52.114.159.23\" rule=\"52.114.159.23\" />\n\t\t<item name=\"extra_52.114.159.32\" rule=\"52.114.159.32\" />\n\t\t<item name=\"extra_52.114.159.33\" rule=\"52.114.159.33\" />\n\t\t<item name=\"extra_52.114.159.34\" rule=\"52.114.159.34\" />\n\t\t<item name=\"extra_52.114.159.35\" rule=\"52.114.159.35\" />\n\t\t<item name=\"extra_52.114.159.112\" rule=\"52.114.159.112\" />\n\t\t<item name=\"extra_52.136.230.174\" rule=\"52.136.230.174\" />\n\t\t<item name=\"extra_52.138.148.87\" rule=\"52.138.148.87\" />\n\t\t<item name=\"extra_52.138.148.89\" rule=\"52.138.148.89\" />\n\t\t<item name=\"extra_52.138.148.159\" rule=\"52.138.148.159\" />\n\t\t<item name=\"extra_52.138.216.83\" rule=\"52.138.216.83\" />\n\t\t<item name=\"extra_52.142.80.173\" rule=\"52.142.80.173\" />\n\t\t<item name=\"extra_52.142.84.61\" rule=\"52.142.84.61\" />\n\t\t<item name=\"extra_52.142.114.2\" rule=\"52.142.114.2\" />\n\t\t<item name=\"extra_52.142.114.176\" rule=\"52.142.114.176\" />\n\t\t<item name=\"extra_52.142.119.134\" rule=\"52.142.119.134\" />\n\t\t<item name=\"extra_52.154.66.52\" rule=\"52.154.66.52\" />\n\t\t<item name=\"extra_52.154.67.2\" rule=\"52.154.67.2\" />\n\t\t<item name=\"extra_52.154.67.56\" rule=\"52.154.67.56\" />\n\t\t<item name=\"extra_52.155.172.105\" rule=\"52.155.172.105\" />\n\t\t<item name=\"extra_52.156.41.171\" rule=\"52.156.41.171\" />\n\t\t<item name=\"extra_52.156.48.67\" rule=\"52.156.48.67\" />\n\t\t<item name=\"extra_52.156.146.245\" rule=\"52.156.146.245\" />\n\t\t<item name=\"extra_52.156.196.151\" rule=\"52.156.196.151\" />\n\t\t<item name=\"extra_52.156.204.185\" rule=\"52.156.204.185\" />\n\t\t<item name=\"extra_52.158.24.209\" rule=\"52.158.24.209\" />\n\t\t<item name=\"extra_52.158.24.229\" rule=\"52.158.24.229\" />\n\t\t<item name=\"extra_52.158.25.39\" rule=\"52.158.25.39\" />\n\t\t<item name=\"extra_52.158.238.42\" rule=\"52.158.238.42\" />\n\t\t<item name=\"extra_52.159.49.192\" rule=\"52.159.49.192\" />\n\t\t<item name=\"extra_52.163.118.68\" rule=\"52.163.118.68\" />\n\t\t<item name=\"extra_52.164.191.55\" rule=\"52.164.191.55\" />\n\t\t<item name=\"extra_52.164.227.208\" rule=\"52.164.227.208\" />\n\t\t<item name=\"extra_52.164.251.44\" rule=\"52.164.251.44\" />\n\t\t<item name=\"extra_52.165.136.32\" rule=\"52.165.136.32\" />\n\t\t<item name=\"extra_52.166.110.64\" rule=\"52.166.110.64\" />\n\t\t<item name=\"extra_52.166.110.215\" rule=\"52.166.110.215\" />\n\t\t<item name=\"extra_52.166.120.77\" rule=\"52.166.120.77\" />\n\t\t<item name=\"extra_52.167.18.95\" rule=\"52.167.18.95\" />\n\t\t<item name=\"extra_52.167.88.112\" rule=\"52.167.88.112\" />\n\t\t<item name=\"extra_52.167.249.196\" rule=\"52.167.249.196\" />\n\t\t<item name=\"extra_52.168.24.174\" rule=\"52.168.24.174\" />\n\t\t<item name=\"extra_52.168.112.66\" rule=\"52.168.112.66\" />\n\t\t<item name=\"extra_52.168.112.67\" rule=\"52.168.112.67\" />\n\t\t<item name=\"extra_52.168.117.169\" rule=\"52.168.117.169\" />\n\t\t<item name=\"extra_52.168.117.170\" rule=\"52.168.117.170\" />\n\t\t<item name=\"extra_52.168.117.173\" rule=\"52.168.117.173\" />\n\t\t<item name=\"extra_52.169.71.150\" rule=\"52.169.71.150\" />\n\t\t<item name=\"extra_52.170.57.27\" rule=\"52.170.57.27\" />\n\t\t<item name=\"extra_52.170.194.77\" rule=\"52.170.194.77\" />\n\t\t<item name=\"extra_52.171.136.200\" rule=\"52.171.136.200\" />\n\t\t<item name=\"extra_52.173.152.64\" rule=\"52.173.152.64\" />\n\t\t<item name=\"extra_52.175.30.196\" rule=\"52.175.30.196\" />\n\t\t<item name=\"extra_52.176.224.96\" rule=\"52.176.224.96\" />\n\t\t<item name=\"extra_52.178.17.2\" rule=\"52.178.17.2\" />\n\t\t<item name=\"extra_52.178.17.3\" rule=\"52.178.17.3\" />\n\t\t<item name=\"extra_52.178.161.41\" rule=\"52.178.161.41\" />\n\t\t<item name=\"extra_52.178.163.85\" rule=\"52.178.163.85\" />\n\t\t<item name=\"extra_52.178.178.16\" rule=\"52.178.178.16\" />\n\t\t<item name=\"extra_52.178.182.73\" rule=\"52.178.182.73\" />\n\t\t<item name=\"extra_52.178.193.116\" rule=\"52.178.193.116\" />\n\t\t<item name=\"extra_52.179.13.204\" rule=\"52.179.13.204\" />\n\t\t<item name=\"extra_52.182.143.208\" rule=\"52.182.143.208\" />\n\t\t<item name=\"extra_52.182.143.210\" rule=\"52.182.143.210\" />\n\t\t<item name=\"extra_52.182.143.211\" rule=\"52.182.143.211\" />\n\t\t<item name=\"extra_52.182.143.212\" rule=\"52.182.143.212\" />\n\t\t<item name=\"extra_52.183.24.194\" rule=\"52.183.24.194\" />\n\t\t<item name=\"extra_52.183.104.36\" rule=\"52.183.104.36\" />\n\t\t<item name=\"extra_52.184.81.210\" rule=\"52.184.81.210\" />\n\t\t<item name=\"extra_52.184.82.129\" rule=\"52.184.82.129\" />\n\t\t<item name=\"extra_52.184.92.48\" rule=\"52.184.92.48\" />\n\t\t<item name=\"extra_52.184.168.116\" rule=\"52.184.168.116\" />\n\t\t<item name=\"extra_52.184.220.11\" rule=\"52.184.220.11\" />\n\t\t<item name=\"extra_52.186.25.68\" rule=\"52.186.25.68\" />\n\t\t<item name=\"extra_52.188.77.27\" rule=\"52.188.77.27\" />\n\t\t<item name=\"extra_52.224.75.92\" rule=\"52.224.75.92\" />\n\t\t<item name=\"extra_52.225.136.36\" rule=\"52.225.136.36\" />\n\t\t<item name=\"extra_52.225.255.33\" rule=\"52.225.255.33\" />\n\t\t<item name=\"extra_52.230.10.183\" rule=\"52.230.10.183\" />\n\t\t<item name=\"extra_52.230.240.94\" rule=\"52.230.240.94\" />\n\t\t<item name=\"extra_52.231.32.10\" rule=\"52.231.32.10\" />\n\t\t<item name=\"extra_52.232.16.77\" rule=\"52.232.16.77\" />\n\t\t<item name=\"extra_52.232.19.76\" rule=\"52.232.19.76\" />\n\t\t<item name=\"extra_52.232.69.150\" rule=\"52.232.69.150\" />\n\t\t<item name=\"extra_52.233.164.195\" rule=\"52.233.164.195\" />\n\t\t<item name=\"extra_52.233.199.249\" rule=\"52.233.199.249\" />\n\t\t<item name=\"extra_52.239.137.4\" rule=\"52.239.137.4\" />\n\t\t<item name=\"extra_52.239.150.170\" rule=\"52.239.150.170\" />\n\t\t<item name=\"extra_52.239.151.138\" rule=\"52.239.151.138\" />\n\t\t<item name=\"extra_52.239.151.170\" rule=\"52.239.151.170\" />\n\t\t<item name=\"extra_52.239.156.2\" rule=\"52.239.156.2\" />\n\t\t<item name=\"extra_52.239.156.2\" rule=\"52.239.156.2\" />\n\t\t<item name=\"extra_52.239.156.74\" rule=\"52.239.156.74\" />\n\t\t<item name=\"extra_52.239.156.138\" rule=\"52.239.156.138\" />\n\t\t<item name=\"extra_52.239.157.138\" rule=\"52.239.157.138\" />\n\t\t<item name=\"extra_52.239.157.202\" rule=\"52.239.157.202\" />\n\t\t<item name=\"extra_52.239.172.132\" rule=\"52.239.172.132\" />\n\t\t<item name=\"extra_52.239.172.164\" rule=\"52.239.172.164\" />\n\t\t<item name=\"extra_52.239.174.4\" rule=\"52.239.174.4\" />\n\t\t<item name=\"extra_52.239.174.132\" rule=\"52.239.174.132\" />\n\t\t<item name=\"extra_52.239.174.196\" rule=\"52.239.174.196\" />\n\t\t<item name=\"extra_52.239.174.228\" rule=\"52.239.174.228\" />\n\t\t<item name=\"extra_52.239.175.4\" rule=\"52.239.175.4\" />\n\t\t<item name=\"extra_52.239.175.68\" rule=\"52.239.175.68\" />\n\t\t<item name=\"extra_52.239.177.36\" rule=\"52.239.177.36\" />\n\t\t<item name=\"extra_52.239.177.68\" rule=\"52.239.177.68\" />\n\t\t<item name=\"extra_52.239.177.100\" rule=\"52.239.177.100\" />\n\t\t<item name=\"extra_52.239.177.228\" rule=\"52.239.177.228\" />\n\t\t<item name=\"extra_52.239.184.10\" rule=\"52.239.184.10\" />\n\t\t<item name=\"extra_52.239.184.42\" rule=\"52.239.184.42\" />\n\t\t<item name=\"extra_52.239.198.228\" rule=\"52.239.198.228\" />\n\t\t<item name=\"extra_52.239.207.100\" rule=\"52.239.207.100\" />\n\t\t<item name=\"extra_52.239.222.100\" rule=\"52.239.222.100\" />\n\t\t<item name=\"extra_52.239.223.19\" rule=\"52.239.223.19\" />\n\t\t<item name=\"extra_52.239.223.132\" rule=\"52.239.223.132\" />\n\t\t<item name=\"extra_52.239.234.100\" rule=\"52.239.234.100\" />\n\t\t<item name=\"extra_52.239.234.228\" rule=\"52.239.234.228\" />\n\t\t<item name=\"extra_52.239.235.100\" rule=\"52.239.235.100\" />\n\t\t<item name=\"extra_52.247.37.26\" rule=\"52.247.37.26\" />\n\t\t<item name=\"extra_52.255.148.73\" rule=\"52.255.148.73\" />\n\t\t<item name=\"extra_64.4.16.212\" rule=\"64.4.16.212\" />\n\t\t<item name=\"extra_64.4.16.214\" rule=\"64.4.16.214\" />\n\t\t<item name=\"extra_64.4.16.216\" rule=\"64.4.16.216\" />\n\t\t<item name=\"extra_64.4.16.218\" rule=\"64.4.16.218\" />\n\t\t<item name=\"extra_64.4.23.0-64.4.23.255\" rule=\"64.4.23.0-64.4.23.255\" />\n\t\t<item name=\"extra_64.4.54.18\" rule=\"64.4.54.18\" />\n\t\t<item name=\"extra_64.4.54.22\" rule=\"64.4.54.22\" />\n\t\t<item name=\"extra_64.4.54.253\" rule=\"64.4.54.253\" />\n\t\t<item name=\"extra_64.4.54.254\" rule=\"64.4.54.254\" />\n\t\t<item name=\"extra_65.52.98.231\" rule=\"65.52.98.231\" />\n\t\t<item name=\"extra_65.52.226.14\" rule=\"65.52.226.14\" />\n\t\t<item name=\"extra_65.54.187.128\" rule=\"65.54.187.128\" />\n\t\t<item name=\"extra_65.54.187.130\" rule=\"65.54.187.130\" />\n\t\t<item name=\"extra_65.54.187.131\" rule=\"65.54.187.131\" />\n\t\t<item name=\"extra_65.54.187.132\" rule=\"65.54.187.132\" />\n\t\t<item name=\"extra_65.54.187.134\" rule=\"65.54.187.134\" />\n\t\t<item name=\"extra_65.54.198.196\" rule=\"65.54.198.196\" />\n\t\t<item name=\"extra_65.55.44.51\" rule=\"65.55.44.51\" />\n\t\t<item name=\"extra_65.55.44.54\" rule=\"65.55.44.54\" />\n\t\t<item name=\"extra_65.55.44.108\" rule=\"65.55.44.108\" />\n\t\t<item name=\"extra_65.55.44.109\" rule=\"65.55.44.109\" />\n\t\t<item name=\"extra_65.55.108.23\" rule=\"65.55.108.23\" />\n\t\t<item name=\"extra_65.55.130.50\" rule=\"65.55.130.50\" />\n\t\t<item name=\"extra_65.55.223.0-65.55.223.255\" rule=\"65.55.223.0-65.55.223.255\" />\n\t\t<item name=\"extra_104.40.144.210\" rule=\"104.40.144.210\" />\n\t\t<item name=\"extra_104.40.159.215\" rule=\"104.40.159.215\" />\n\t\t<item name=\"extra_104.40.210.32\" rule=\"104.40.210.32\" />\n\t\t<item name=\"extra_104.40.211.35\" rule=\"104.40.211.35\" />\n\t\t<item name=\"extra_104.41.219.140\" rule=\"104.41.219.140\" />\n\t\t<item name=\"extra_104.42.41.237\" rule=\"104.42.41.237\" />\n\t\t<item name=\"extra_104.42.191.226\" rule=\"104.42.191.226\" />\n\t\t<item name=\"extra_104.43.203.255\" rule=\"104.43.203.255\" />\n\t\t<item name=\"extra_104.44.80.172\" rule=\"104.44.80.172\" />\n\t\t<item name=\"extra_104.44.88.24\" rule=\"104.44.88.24\" />\n\t\t<item name=\"extra_104.44.88.28\" rule=\"104.44.88.28\" />\n\t\t<item name=\"extra_104.44.88.103\" rule=\"104.44.88.103\" />\n\t\t<item name=\"extra_104.45.18.177\" rule=\"104.45.18.177\" />\n\t\t<item name=\"extra_104.46.91.34\" rule=\"104.46.91.34\" />\n\t\t<item name=\"extra_104.208.16.88\" rule=\"104.208.16.88\" />\n\t\t<item name=\"extra_104.208.16.89\" rule=\"104.208.16.89\" />\n\t\t<item name=\"extra_104.208.16.90\" rule=\"104.208.16.90\" />\n\t\t<item name=\"extra_104.208.16.94\" rule=\"104.208.16.94\" />\n\t\t<item name=\"extra_104.208.248.16\" rule=\"104.208.248.16\" />\n\t\t<item name=\"extra_104.209.172.133\" rule=\"104.209.172.133\" />\n\t\t<item name=\"extra_104.210.62.125\" rule=\"104.210.62.125\" />\n\t\t<item name=\"extra_104.211.73.16\" rule=\"104.211.73.16\" />\n\t\t<item name=\"extra_104.211.91.221\" rule=\"104.211.91.221\" />\n\t\t<item name=\"extra_104.211.93.71\" rule=\"104.211.93.71\" />\n\t\t<item name=\"extra_104.211.96.15\" rule=\"104.211.96.15\" />\n\t\t<item name=\"extra_104.212.67.88\" rule=\"104.212.67.88\" />\n\t\t<item name=\"extra_104.212.67.92\" rule=\"104.212.67.92\" />\n\t\t<item name=\"extra_104.212.67.142\" rule=\"104.212.67.142\" />\n\t\t<item name=\"extra_104.212.67.154\" rule=\"104.212.67.154\" />\n\t\t<item name=\"extra_104.212.67.162\" rule=\"104.212.67.162\" />\n\t\t<item name=\"extra_104.212.67.168\" rule=\"104.212.67.168\" />\n\t\t<item name=\"extra_104.212.67.187\" rule=\"104.212.67.187\" />\n\t\t<item name=\"extra_104.212.67.188\" rule=\"104.212.67.188\" />\n\t\t<item name=\"extra_104.212.67.223\" rule=\"104.212.67.223\" />\n\t\t<item name=\"extra_104.212.67.234\" rule=\"104.212.67.234\" />\n\t\t<item name=\"extra_104.212.67.245\" rule=\"104.212.67.245\" />\n\t\t<item name=\"extra_104.214.77.221\" rule=\"104.214.77.221\" />\n\t\t<item name=\"extra_104.214.150.122\" rule=\"104.214.150.122\" />\n\t\t<item name=\"extra_104.214.220.181\" rule=\"104.214.220.181\" />\n\t\t<item name=\"extra_104.215.146.200\" rule=\"104.215.146.200\" />\n\t\t<item name=\"extra_131.253.14.227\" rule=\"131.253.14.227\" />\n\t\t<item name=\"extra_131.253.14.229\" rule=\"131.253.14.229\" />\n\t\t<item name=\"extra_131.253.14.230\" rule=\"131.253.14.230\" />\n\t\t<item name=\"extra_131.253.14.231\" rule=\"131.253.14.231\" />\n\t\t<item name=\"extra_131.253.33.200\" rule=\"131.253.33.200\" />\n\t\t<item name=\"extra_131.253.33.203\" rule=\"131.253.33.203\" />\n\t\t<item name=\"extra_131.253.33.219\" rule=\"131.253.33.219\" />\n\t\t<item name=\"extra_131.253.33.254\" rule=\"131.253.33.254\" />\n\t\t<item name=\"extra_131.253.61.0-131.253.61.255\" rule=\"131.253.61.0-131.253.61.255\" />\n\t\t<item name=\"extra_134.170.178.97\" rule=\"134.170.178.97\" />\n\t\t<item name=\"extra_134.170.185.70\" rule=\"134.170.185.70\" />\n\t\t<item name=\"extra_134.170.188.248\" rule=\"134.170.188.248\" />\n\t\t<item name=\"extra_137.116.44.10\" rule=\"137.116.44.10\" />\n\t\t<item name=\"extra_137.116.234.82\" rule=\"137.116.234.82\" />\n\t\t<item name=\"extra_137.117.142.136\" rule=\"137.117.142.136\" />\n\t\t<item name=\"extra_137.117.144.39\" rule=\"137.117.144.39\" />\n\t\t<item name=\"extra_137.117.228.253\" rule=\"137.117.228.253\" />\n\t\t<item name=\"extra_137.117.235.16\" rule=\"137.117.235.16\" />\n\t\t<item name=\"extra_137.117.243.30\" rule=\"137.117.243.30\" />\n\t\t<item name=\"extra_137.135.251.63\" rule=\"137.135.251.63\" />\n\t\t<item name=\"extra_138.91.122.49\" rule=\"138.91.122.49\" />\n\t\t<item name=\"extra_138.91.136.108\" rule=\"138.91.136.108\" />\n\t\t<item name=\"extra_138.91.140.216\" rule=\"138.91.140.216\" />\n\t\t<item name=\"extra_138.91.141.104\" rule=\"138.91.141.104\" />\n\t\t<item name=\"extra_157.55.56.0-157.55.56.255\" rule=\"157.55.56.0-157.55.56.255\" />\n\t\t<item name=\"extra_157.55.109.7\" rule=\"157.55.109.7\" />\n\t\t<item name=\"extra_157.55.109.224\" rule=\"157.55.109.224\" />\n\t\t<item name=\"extra_157.55.109.226\" rule=\"157.55.109.226\" />\n\t\t<item name=\"extra_157.55.109.228\" rule=\"157.55.109.228\" />\n\t\t<item name=\"extra_157.55.109.230\" rule=\"157.55.109.230\" />\n\t\t<item name=\"extra_157.55.109.232\" rule=\"157.55.109.232\" />\n\t\t<item name=\"extra_157.55.129.21\" rule=\"157.55.129.21\" />\n\t\t<item name=\"extra_157.55.134.136\" rule=\"157.55.134.136\" />\n\t\t<item name=\"extra_157.55.134.138\" rule=\"157.55.134.138\" />\n\t\t<item name=\"extra_157.55.134.140\" rule=\"157.55.134.140\" />\n\t\t<item name=\"extra_157.55.134.142\" rule=\"157.55.134.142\" />\n\t\t<item name=\"extra_157.55.135.128\" rule=\"157.55.135.128\" />\n\t\t<item name=\"extra_157.55.135.130\" rule=\"157.55.135.130\" />\n\t\t<item name=\"extra_157.55.135.132\" rule=\"157.55.135.132\" />\n\t\t<item name=\"extra_157.55.135.134\" rule=\"157.55.135.134\" />\n\t\t<item name=\"extra_157.56.57.5\" rule=\"157.56.57.5\" />\n\t\t<item name=\"extra_168.62.57.154\" rule=\"168.62.57.154\" />\n\t\t<item name=\"extra_168.62.58.130\" rule=\"168.62.58.130\" />\n\t\t<item name=\"extra_168.62.200.169\" rule=\"168.62.200.169\" />\n\t\t<item name=\"extra_168.63.18.79\" rule=\"168.63.18.79\" />\n\t\t<item name=\"extra_168.63.67.155\" rule=\"168.63.67.155\" />\n\t\t<item name=\"extra_168.63.102.42\" rule=\"168.63.102.42\" />\n\t\t<item name=\"extra_191.237.208.126\" rule=\"191.237.208.126\" />\n\t\t<item name=\"extra_191.239.213.197\" rule=\"191.239.213.197\" />\n\t\t<item name=\"extra_204.152.141.244\" rule=\"204.152.141.244\" />\n\t\t<item name=\"extra_207.46.7.252\" rule=\"207.46.7.252\" />\n\t\t<item name=\"extra_207.46.26.12\" rule=\"207.46.26.12\" />\n\t\t<item name=\"extra_207.46.26.14\" rule=\"207.46.26.14\" />\n\t\t<item name=\"extra_207.46.26.16\" rule=\"207.46.26.16\" />\n\t\t<item name=\"extra_207.46.26.18\" rule=\"207.46.26.18\" />\n\t\t<item name=\"extra_207.46.101.29\" rule=\"207.46.101.29\" />\n\t\t<item name=\"extra_207.46.153.155\" rule=\"207.46.153.155\" />\n\t\t<item name=\"extra_207.46.194.14\" rule=\"207.46.194.14\" />\n\t\t<item name=\"extra_207.46.194.25\" rule=\"207.46.194.25\" />\n\t\t<item name=\"extra_207.46.194.33\" rule=\"207.46.194.33\" />\n\t\t<item name=\"extra_207.46.194.40\" rule=\"207.46.194.40\" />\n\t\t<item name=\"extra_207.46.223.94\" rule=\"207.46.223.94\" />\n\t\t<item name=\"spy_13.64.90.137\" rule=\"13.64.90.137\" />\n\t\t<item name=\"spy_13.66.56.243\" rule=\"13.66.56.243\" />\n\t\t<item name=\"spy_13.68.31.193\" rule=\"13.68.31.193\" />\n\t\t<item name=\"spy_13.68.82.8\" rule=\"13.68.82.8\" />\n\t\t<item name=\"spy_13.68.92.143\" rule=\"13.68.92.143\" />\n\t\t<item name=\"spy_13.68.233.9\" rule=\"13.68.233.9\" />\n\t\t<item name=\"spy_13.69.109.130\" rule=\"13.69.109.130\" />\n\t\t<item name=\"spy_13.69.109.131\" rule=\"13.69.109.131\" />\n\t\t<item name=\"spy_13.69.131.175\" rule=\"13.69.131.175\" />\n\t\t<item name=\"spy_13.73.26.107\" rule=\"13.73.26.107\" />\n\t\t<item name=\"spy_13.74.169.109\" rule=\"13.74.169.109\" />\n\t\t<item name=\"spy_13.78.130.220\" rule=\"13.78.130.220\" />\n\t\t<item name=\"spy_13.78.232.226\" rule=\"13.78.232.226\" />\n\t\t<item name=\"spy_13.78.233.133\" rule=\"13.78.233.133\" />\n\t\t<item name=\"spy_13.88.21.125\" rule=\"13.88.21.125\" />\n\t\t<item name=\"spy_13.92.194.212\" rule=\"13.92.194.212\" />\n\t\t<item name=\"spy_13.104.215.69\" rule=\"13.104.215.69\" />\n\t\t<item name=\"spy_13.105.28.32\" rule=\"13.105.28.32\" />\n\t\t<item name=\"spy_13.105.28.48\" rule=\"13.105.28.48\" />\n\t\t<item name=\"spy_20.44.86.43\" rule=\"20.44.86.43\" />\n\t\t<item name=\"spy_20.49.150.241\" rule=\"20.49.150.241\" />\n\t\t<item name=\"spy_20.54.232.160\" rule=\"20.54.232.160\" />\n\t\t<item name=\"spy_20.69.137.228\" rule=\"20.69.137.228\" />\n\t\t<item name=\"spy_20.190.169.24\" rule=\"20.190.169.24\" />\n\t\t<item name=\"spy_20.190.169.25\" rule=\"20.190.169.25\" />\n\t\t<item name=\"spy_23.99.49.121\" rule=\"23.99.49.121\" />\n\t\t<item name=\"spy_23.102.4.253\" rule=\"23.102.4.253\" />\n\t\t<item name=\"spy_23.102.5.5\" rule=\"23.102.5.5\" />\n\t\t<item name=\"spy_23.102.21.4\" rule=\"23.102.21.4\" />\n\t\t<item name=\"spy_23.103.182.126\" rule=\"23.103.182.126\" />\n\t\t<item name=\"spy_40.68.222.212\" rule=\"40.68.222.212\" />\n\t\t<item name=\"spy_40.69.153.67\" rule=\"40.69.153.67\" />\n\t\t<item name=\"spy_40.70.184.83\" rule=\"40.70.184.83\" />\n\t\t<item name=\"spy_40.70.220.248\" rule=\"40.70.220.248\" />\n\t\t<item name=\"spy_40.77.228.47\" rule=\"40.77.228.47\" />\n\t\t<item name=\"spy_40.77.228.87\" rule=\"40.77.228.87\" />\n\t\t<item name=\"spy_40.77.228.92\" rule=\"40.77.228.92\" />\n\t\t<item name=\"spy_40.77.232.101\" rule=\"40.77.232.101\" />\n\t\t<item name=\"spy_40.78.128.150\" rule=\"40.78.128.150\" />\n\t\t<item name=\"spy_40.79.85.125\" rule=\"40.79.85.125\" />\n\t\t<item name=\"spy_40.88.32.150\" rule=\"40.88.32.150\" />\n\t\t<item name=\"spy_40.112.209.200\" rule=\"40.112.209.200\" />\n\t\t<item name=\"spy_40.115.3.210\" rule=\"40.115.3.210\" />\n\t\t<item name=\"spy_40.115.119.185\" rule=\"40.115.119.185\" />\n\t\t<item name=\"spy_40.119.211.203\" rule=\"40.119.211.203\" />\n\t\t<item name=\"spy_40.124.34.70\" rule=\"40.124.34.70\" />\n\t\t<item name=\"spy_40.126.41.96\" rule=\"40.126.41.96\" />\n\t\t<item name=\"spy_40.126.41.160\" rule=\"40.126.41.160\" />\n\t\t<item name=\"spy_51.104.136.2\" rule=\"51.104.136.2\" />\n\t\t<item name=\"spy_51.105.218.222\" rule=\"51.105.218.222\" />\n\t\t<item name=\"spy_51.140.40.236\" rule=\"51.140.40.236\" />\n\t\t<item name=\"spy_51.140.157.153\" rule=\"51.140.157.153\" />\n\t\t<item name=\"spy_51.143.53.152\" rule=\"51.143.53.152\" />\n\t\t<item name=\"spy_51.143.111.7\" rule=\"51.143.111.7\" />\n\t\t<item name=\"spy_51.143.111.81\" rule=\"51.143.111.81\" />\n\t\t<item name=\"spy_51.144.227.73\" rule=\"51.144.227.73\" />\n\t\t<item name=\"spy_52.138.204.217\" rule=\"52.138.204.217\" />\n\t\t<item name=\"spy_52.147.198.201\" rule=\"52.147.198.201\" />\n\t\t<item name=\"spy_52.155.94.78\" rule=\"52.155.94.78\" />\n\t\t<item name=\"spy_52.157.234.37\" rule=\"52.157.234.37\" />\n\t\t<item name=\"spy_52.158.208.111\" rule=\"52.158.208.111\" />\n\t\t<item name=\"spy_52.164.241.205\" rule=\"52.164.241.205\" />\n\t\t<item name=\"spy_52.169.189.83\" rule=\"52.169.189.83\" />\n\t\t<item name=\"spy_52.170.83.19\" rule=\"52.170.83.19\" />\n\t\t<item name=\"spy_52.174.22.246\" rule=\"52.174.22.246\" />\n\t\t<item name=\"spy_52.178.147.240\" rule=\"52.178.147.240\" />\n\t\t<item name=\"spy_52.178.151.212\" rule=\"52.178.151.212\" />\n\t\t<item name=\"spy_52.178.223.23\" rule=\"52.178.223.23\" />\n\t\t<item name=\"spy_52.182.141.63\" rule=\"52.182.141.63\" />\n\t\t<item name=\"spy_52.183.114.173\" rule=\"52.183.114.173\" />\n\t\t<item name=\"spy_52.184.221.185\" rule=\"52.184.221.185\" />\n\t\t<item name=\"spy_52.229.39.152\" rule=\"52.229.39.152\" />\n\t\t<item name=\"spy_52.230.85.180\" rule=\"52.230.85.180\" />\n\t\t<item name=\"spy_52.230.222.68\" rule=\"52.230.222.68\" />\n\t\t<item name=\"spy_52.236.42.239\" rule=\"52.236.42.239\" />\n\t\t<item name=\"spy_52.236.43.202\" rule=\"52.236.43.202\" />\n\t\t<item name=\"spy_52.255.188.83\" rule=\"52.255.188.83\" />\n\t\t<item name=\"spy_65.52.100.7\" rule=\"65.52.100.7\" />\n\t\t<item name=\"spy_65.52.100.9\" rule=\"65.52.100.9\" />\n\t\t<item name=\"spy_65.52.100.11\" rule=\"65.52.100.11\" />\n\t\t<item name=\"spy_65.52.100.91\" rule=\"65.52.100.91\" />\n\t\t<item name=\"spy_65.52.100.92\" rule=\"65.52.100.92\" />\n\t\t<item name=\"spy_65.52.100.93\" rule=\"65.52.100.93\" />\n\t\t<item name=\"spy_65.52.100.94\" rule=\"65.52.100.94\" />\n\t\t<item name=\"spy_65.52.161.64\" rule=\"65.52.161.64\" />\n\t\t<item name=\"spy_65.55.29.238\" rule=\"65.55.29.238\" />\n\t\t<item name=\"spy_65.55.83.120\" rule=\"65.55.83.120\" />\n\t\t<item name=\"spy_65.55.113.11\" rule=\"65.55.113.11\" />\n\t\t<item name=\"spy_65.55.113.12\" rule=\"65.55.113.12\" />\n\t\t<item name=\"spy_65.55.113.13\" rule=\"65.55.113.13\" />\n\t\t<item name=\"spy_65.55.176.90\" rule=\"65.55.176.90\" />\n\t\t<item name=\"spy_65.55.252.43\" rule=\"65.55.252.43\" />\n\t\t<item name=\"spy_65.55.252.63\" rule=\"65.55.252.63\" />\n\t\t<item name=\"spy_65.55.252.70\" rule=\"65.55.252.70\" />\n\t\t<item name=\"spy_65.55.252.71\" rule=\"65.55.252.71\" />\n\t\t<item name=\"spy_65.55.252.72\" rule=\"65.55.252.72\" />\n\t\t<item name=\"spy_65.55.252.93\" rule=\"65.55.252.93\" />\n\t\t<item name=\"spy_65.55.252.190\" rule=\"65.55.252.190\" />\n\t\t<item name=\"spy_65.55.252.202\" rule=\"65.55.252.202\" />\n\t\t<item name=\"spy_66.119.147.131\" rule=\"66.119.147.131\" />\n\t\t<item name=\"spy_104.41.207.73\" rule=\"104.41.207.73\" />\n\t\t<item name=\"spy_104.42.151.234\" rule=\"104.42.151.234\" />\n\t\t<item name=\"spy_104.43.137.66\" rule=\"104.43.137.66\" />\n\t\t<item name=\"spy_104.43.139.21\" rule=\"104.43.139.21\" />\n\t\t<item name=\"spy_104.43.139.144\" rule=\"104.43.139.144\" />\n\t\t<item name=\"spy_104.43.140.223\" rule=\"104.43.140.223\" />\n\t\t<item name=\"spy_104.43.193.48\" rule=\"104.43.193.48\" />\n\t\t<item name=\"spy_104.43.228.53\" rule=\"104.43.228.53\" />\n\t\t<item name=\"spy_104.43.228.202\" rule=\"104.43.228.202\" />\n\t\t<item name=\"spy_104.43.237.169\" rule=\"104.43.237.169\" />\n\t\t<item name=\"spy_104.45.11.195\" rule=\"104.45.11.195\" />\n\t\t<item name=\"spy_104.45.214.112\" rule=\"104.45.214.112\" />\n\t\t<item name=\"spy_104.46.1.211\" rule=\"104.46.1.211\" />\n\t\t<item name=\"spy_104.46.38.64\" rule=\"104.46.38.64\" />\n\t\t<item name=\"spy_104.46.162.224\" rule=\"104.46.162.224\" />\n\t\t<item name=\"spy_104.46.162.226\" rule=\"104.46.162.226\" />\n\t\t<item name=\"spy_104.210.4.77\" rule=\"104.210.4.77\" />\n\t\t<item name=\"spy_104.210.40.87\" rule=\"104.210.40.87\" />\n\t\t<item name=\"spy_104.210.212.243\" rule=\"104.210.212.243\" />\n\t\t<item name=\"spy_104.214.35.244\" rule=\"104.214.35.244\" />\n\t\t<item name=\"spy_104.214.78.152\" rule=\"104.214.78.152\" />\n\t\t<item name=\"spy_131.253.6.87\" rule=\"131.253.6.87\" />\n\t\t<item name=\"spy_131.253.6.103\" rule=\"131.253.6.103\" />\n\t\t<item name=\"spy_131.253.34.230\" rule=\"131.253.34.230\" />\n\t\t<item name=\"spy_131.253.34.234\" rule=\"131.253.34.234\" />\n\t\t<item name=\"spy_131.253.34.237\" rule=\"131.253.34.237\" />\n\t\t<item name=\"spy_131.253.34.243\" rule=\"131.253.34.243\" />\n\t\t<item name=\"spy_131.253.34.246\" rule=\"131.253.34.246\" />\n\t\t<item name=\"spy_131.253.34.247\" rule=\"131.253.34.247\" />\n\t\t<item name=\"spy_131.253.34.249\" rule=\"131.253.34.249\" />\n\t\t<item name=\"spy_131.253.34.252\" rule=\"131.253.34.252\" />\n\t\t<item name=\"spy_131.253.34.255\" rule=\"131.253.34.255\" />\n\t\t<item name=\"spy_131.253.40.37\" rule=\"131.253.40.37\" />\n\t\t<item name=\"spy_134.170.30.202\" rule=\"134.170.30.202\" />\n\t\t<item name=\"spy_134.170.30.203\" rule=\"134.170.30.203\" />\n\t\t<item name=\"spy_134.170.30.204\" rule=\"134.170.30.204\" />\n\t\t<item name=\"spy_134.170.30.221\" rule=\"134.170.30.221\" />\n\t\t<item name=\"spy_134.170.52.151\" rule=\"134.170.52.151\" />\n\t\t<item name=\"spy_134.170.235.16\" rule=\"134.170.235.16\" />\n\t\t<item name=\"spy_157.56.74.250\" rule=\"157.56.74.250\" />\n\t\t<item name=\"spy_157.56.91.77\" rule=\"157.56.91.77\" />\n\t\t<item name=\"spy_157.56.106.184\" rule=\"157.56.106.184\" />\n\t\t<item name=\"spy_157.56.106.185\" rule=\"157.56.106.185\" />\n\t\t<item name=\"spy_157.56.106.189\" rule=\"157.56.106.189\" />\n\t\t<item name=\"spy_157.56.113.217\" rule=\"157.56.113.217\" />\n\t\t<item name=\"spy_157.56.121.89\" rule=\"157.56.121.89\" />\n\t\t<item name=\"spy_157.56.124.87\" rule=\"157.56.124.87\" />\n\t\t<item name=\"spy_157.56.149.250\" rule=\"157.56.149.250\" />\n\t\t<item name=\"spy_157.56.194.72\" rule=\"157.56.194.72\" />\n\t\t<item name=\"spy_157.56.194.73\" rule=\"157.56.194.73\" />\n\t\t<item name=\"spy_157.56.194.74\" rule=\"157.56.194.74\" />\n\t\t<item name=\"spy_168.61.24.141\" rule=\"168.61.24.141\" />\n\t\t<item name=\"spy_168.61.146.25\" rule=\"168.61.146.25\" />\n\t\t<item name=\"spy_168.61.149.17\" rule=\"168.61.149.17\" />\n\t\t<item name=\"spy_168.61.161.212\" rule=\"168.61.161.212\" />\n\t\t<item name=\"spy_168.61.172.71\" rule=\"168.61.172.71\" />\n\t\t<item name=\"spy_168.62.187.13\" rule=\"168.62.187.13\" />\n\t\t<item name=\"spy_168.63.100.61\" rule=\"168.63.100.61\" />\n\t\t<item name=\"spy_168.63.108.233\" rule=\"168.63.108.233\" />\n\t\t<item name=\"spy_191.236.155.80\" rule=\"191.236.155.80\" />\n\t\t<item name=\"spy_191.237.218.239\" rule=\"191.237.218.239\" />\n\t\t<item name=\"spy_191.239.50.18\" rule=\"191.239.50.18\" />\n\t\t<item name=\"spy_191.239.50.77\" rule=\"191.239.50.77\" />\n\t\t<item name=\"spy_191.239.52.100\" rule=\"191.239.52.100\" />\n\t\t<item name=\"spy_191.239.54.52\" rule=\"191.239.54.52\" />\n\t\t<item name=\"spy_207.68.166.254\" rule=\"207.68.166.254\" />\n\t\t<item name=\"update_13.68.87.47\" rule=\"13.68.87.47\" />\n\t\t<item name=\"update_13.68.87.175\" rule=\"13.68.87.175\" />\n\t\t<item name=\"update_13.68.88.129\" rule=\"13.68.88.129\" />\n\t\t<item name=\"update_13.68.93.109\" rule=\"13.68.93.109\" />\n\t\t<item name=\"update_13.74.179.117\" rule=\"13.74.179.117\" />\n\t\t<item name=\"update_13.78.168.230\" rule=\"13.78.168.230\" />\n\t\t<item name=\"update_13.78.177.144\" rule=\"13.78.177.144\" />\n\t\t<item name=\"update_13.78.179.199\" rule=\"13.78.179.199\" />\n\t\t<item name=\"update_13.78.180.50\" rule=\"13.78.180.50\" />\n\t\t<item name=\"update_13.78.180.90\" rule=\"13.78.180.90\" />\n\t\t<item name=\"update_13.78.184.44\" rule=\"13.78.184.44\" />\n\t\t<item name=\"update_13.78.184.186\" rule=\"13.78.184.186\" />\n\t\t<item name=\"update_13.78.186.254\" rule=\"13.78.186.254\" />\n\t\t<item name=\"update_13.78.187.58\" rule=\"13.78.187.58\" />\n\t\t<item name=\"update_13.78.230.134\" rule=\"13.78.230.134\" />\n\t\t<item name=\"update_13.83.148.218\" rule=\"13.83.148.218\" />\n\t\t<item name=\"update_13.83.148.235\" rule=\"13.83.148.235\" />\n\t\t<item name=\"update_13.83.149.5\" rule=\"13.83.149.5\" />\n\t\t<item name=\"update_13.83.149.67\" rule=\"13.83.149.67\" />\n\t\t<item name=\"update_13.83.151.160\" rule=\"13.83.151.160\" />\n\t\t<item name=\"update_13.86.124.174\" rule=\"13.86.124.174\" />\n\t\t<item name=\"update_13.86.124.184\" rule=\"13.86.124.184\" />\n\t\t<item name=\"update_13.86.124.191\" rule=\"13.86.124.191\" />\n\t\t<item name=\"update_13.91.16.64\" rule=\"13.91.16.64\" />\n\t\t<item name=\"update_13.91.16.65\" rule=\"13.91.16.65\" />\n\t\t<item name=\"update_13.91.16.66\" rule=\"13.91.16.66\" />\n\t\t<item name=\"update_13.91.16.67\" rule=\"13.91.16.67\" />\n\t\t<item name=\"update_13.91.16.68\" rule=\"13.91.16.68\" />\n\t\t<item name=\"update_13.91.16.69\" rule=\"13.91.16.69\" />\n\t\t<item name=\"update_13.91.16.70\" rule=\"13.91.16.70\" />\n\t\t<item name=\"update_13.91.16.71\" rule=\"13.91.16.71\" />\n\t\t<item name=\"update_13.92.211.120\" rule=\"13.92.211.120\" />\n\t\t<item name=\"update_13.107.4.50\" rule=\"13.107.4.50\" />\n\t\t<item name=\"update_13.107.4.52\" rule=\"13.107.4.52\" />\n\t\t<item name=\"update_13.107.4.254\" rule=\"13.107.4.254\" />\n\t\t<item name=\"update_20.36.222.39\" rule=\"20.36.222.39\" />\n\t\t<item name=\"update_20.36.252.130\" rule=\"20.36.252.130\" />\n\t\t<item name=\"update_20.41.41.23\" rule=\"20.41.41.23\" />\n\t\t<item name=\"update_20.42.24.29\" rule=\"20.42.24.29\" />\n\t\t<item name=\"update_20.42.24.50\" rule=\"20.42.24.50\" />\n\t\t<item name=\"update_20.44.77.24\" rule=\"20.44.77.24\" />\n\t\t<item name=\"update_20.44.77.45\" rule=\"20.44.77.45\" />\n\t\t<item name=\"update_20.44.77.49\" rule=\"20.44.77.49\" />\n\t\t<item name=\"update_20.44.77.219\" rule=\"20.44.77.219\" />\n\t\t<item name=\"update_20.45.4.77\" rule=\"20.45.4.77\" />\n\t\t<item name=\"update_20.45.4.178\" rule=\"20.45.4.178\" />\n\t\t<item name=\"update_20.54.24.69\" rule=\"20.54.24.69\" />\n\t\t<item name=\"update_20.54.24.79\" rule=\"20.54.24.79\" />\n\t\t<item name=\"update_20.54.24.148\" rule=\"20.54.24.148\" />\n\t\t<item name=\"update_20.54.24.169\" rule=\"20.54.24.169\" />\n\t\t<item name=\"update_20.54.24.231\" rule=\"20.54.24.231\" />\n\t\t<item name=\"update_20.54.24.246\" rule=\"20.54.24.246\" />\n\t\t<item name=\"update_20.54.25.4\" rule=\"20.54.25.4\" />\n\t\t<item name=\"update_20.54.25.16\" rule=\"20.54.25.16\" />\n\t\t<item name=\"update_20.54.89.15\" rule=\"20.54.89.15\" />\n\t\t<item name=\"update_20.54.89.106\" rule=\"20.54.89.106\" />\n\t\t<item name=\"update_20.54.110.119\" rule=\"20.54.110.119\" />\n\t\t<item name=\"update_20.54.110.249\" rule=\"20.54.110.249\" />\n\t\t<item name=\"update_20.62.190.184\" rule=\"20.62.190.184\" />\n\t\t<item name=\"update_20.62.190.185\" rule=\"20.62.190.185\" />\n\t\t<item name=\"update_20.62.190.186\" rule=\"20.62.190.186\" />\n\t\t<item name=\"update_20.62.190.187\" rule=\"20.62.190.187\" />\n\t\t<item name=\"update_20.62.190.188\" rule=\"20.62.190.188\" />\n\t\t<item name=\"update_20.62.190.189\" rule=\"20.62.190.189\" />\n\t\t<item name=\"update_20.62.190.190\" rule=\"20.62.190.190\" />\n\t\t<item name=\"update_20.62.190.191\" rule=\"20.62.190.191\" />\n\t\t<item name=\"update_20.83.81.160\" rule=\"20.83.81.160\" />\n\t\t<item name=\"update_20.83.81.161\" rule=\"20.83.81.161\" />\n\t\t<item name=\"update_20.83.81.162\" rule=\"20.83.81.162\" />\n\t\t<item name=\"update_20.83.81.163\" rule=\"20.83.81.163\" />\n\t\t<item name=\"update_20.83.81.164\" rule=\"20.83.81.164\" />\n\t\t<item name=\"update_20.83.81.165\" rule=\"20.83.81.165\" />\n\t\t<item name=\"update_20.185.109.208\" rule=\"20.185.109.208\" />\n\t\t<item name=\"update_20.186.48.46\" rule=\"20.186.48.46\" />\n\t\t<item name=\"update_20.188.74.161\" rule=\"20.188.74.161\" />\n\t\t<item name=\"update_20.188.78.184\" rule=\"20.188.78.184\" />\n\t\t<item name=\"update_20.188.78.185\" rule=\"20.188.78.185\" />\n\t\t<item name=\"update_20.188.78.187\" rule=\"20.188.78.187\" />\n\t\t<item name=\"update_20.188.78.188\" rule=\"20.188.78.188\" />\n\t\t<item name=\"update_20.188.78.189\" rule=\"20.188.78.189\" />\n\t\t<item name=\"update_20.190.3.175\" rule=\"20.190.3.175\" />\n\t\t<item name=\"update_20.190.9.86\" rule=\"20.190.9.86\" />\n\t\t<item name=\"update_20.191.46.109\" rule=\"20.191.46.109\" />\n\t\t<item name=\"update_20.191.46.211\" rule=\"20.191.46.211\" />\n\t\t<item name=\"update_20.199.120.85\" rule=\"20.199.120.85\" />\n\t\t<item name=\"update_20.199.120.151\" rule=\"20.199.120.151\" />\n\t\t<item name=\"update_20.199.120.182\" rule=\"20.199.120.182\" />\n\t\t<item name=\"update_23.103.189.125\" rule=\"23.103.189.125\" />\n\t\t<item name=\"update_23.103.189.126\" rule=\"23.103.189.126\" />\n\t\t<item name=\"update_23.103.189.157\" rule=\"23.103.189.157\" />\n\t\t<item name=\"update_23.103.189.158\" rule=\"23.103.189.158\" />\n\t\t<item name=\"update_40.67.248.104\" rule=\"40.67.248.104\" />\n\t\t<item name=\"update_40.67.251.132\" rule=\"40.67.251.132\" />\n\t\t<item name=\"update_40.67.251.134\" rule=\"40.67.251.134\" />\n\t\t<item name=\"update_40.67.252.175\" rule=\"40.67.252.175\" />\n\t\t<item name=\"update_40.67.252.206\" rule=\"40.67.252.206\" />\n\t\t<item name=\"update_40.67.253.249\" rule=\"40.67.253.249\" />\n\t\t<item name=\"update_40.67.254.36\" rule=\"40.67.254.36\" />\n\t\t<item name=\"update_40.67.254.97\" rule=\"40.67.254.97\" />\n\t\t<item name=\"update_40.67.255.199\" rule=\"40.67.255.199\" />\n\t\t<item name=\"update_40.69.216.73\" rule=\"40.69.216.73\" />\n\t\t<item name=\"update_40.69.216.129\" rule=\"40.69.216.129\" />\n\t\t<item name=\"update_40.69.216.251\" rule=\"40.69.216.251\" />\n\t\t<item name=\"update_40.69.218.62\" rule=\"40.69.218.62\" />\n\t\t<item name=\"update_40.69.219.197\" rule=\"40.69.219.197\" />\n\t\t<item name=\"update_40.69.220.46\" rule=\"40.69.220.46\" />\n\t\t<item name=\"update_40.69.221.239\" rule=\"40.69.221.239\" />\n\t\t<item name=\"update_40.69.222.109\" rule=\"40.69.222.109\" />\n\t\t<item name=\"update_40.69.223.39\" rule=\"40.69.223.39\" />\n\t\t<item name=\"update_40.69.223.198\" rule=\"40.69.223.198\" />\n\t\t<item name=\"update_40.70.224.144\" rule=\"40.70.224.144\" />\n\t\t<item name=\"update_40.70.224.145\" rule=\"40.70.224.145\" />\n\t\t<item name=\"update_40.70.224.147\" rule=\"40.70.224.147\" />\n\t\t<item name=\"update_40.70.224.148\" rule=\"40.70.224.148\" />\n\t\t<item name=\"update_40.70.224.149\" rule=\"40.70.224.149\" />\n\t\t<item name=\"update_40.70.229.150\" rule=\"40.70.229.150\" />\n\t\t<item name=\"update_40.77.18.167\" rule=\"40.77.18.167\" />\n\t\t<item name=\"update_40.77.224.8\" rule=\"40.77.224.8\" />\n\t\t<item name=\"update_40.77.224.11\" rule=\"40.77.224.11\" />\n\t\t<item name=\"update_40.77.224.145\" rule=\"40.77.224.145\" />\n\t\t<item name=\"update_40.77.224.254\" rule=\"40.77.224.254\" />\n\t\t<item name=\"update_40.77.226.13\" rule=\"40.77.226.13\" />\n\t\t<item name=\"update_40.77.226.181\" rule=\"40.77.226.181\" />\n\t\t<item name=\"update_40.77.226.246\" rule=\"40.77.226.246\" />\n\t\t<item name=\"update_40.77.226.247\" rule=\"40.77.226.247\" />\n\t\t<item name=\"update_40.77.226.248\" rule=\"40.77.226.248\" />\n\t\t<item name=\"update_40.77.226.249\" rule=\"40.77.226.249\" />\n\t\t<item name=\"update_40.77.226.250\" rule=\"40.77.226.250\" />\n\t\t<item name=\"update_40.77.229.8\" rule=\"40.77.229.8\" />\n\t\t<item name=\"update_40.77.229.9\" rule=\"40.77.229.9\" />\n\t\t<item name=\"update_40.77.229.12\" rule=\"40.77.229.12\" />\n\t\t<item name=\"update_40.77.229.13\" rule=\"40.77.229.13\" />\n\t\t<item name=\"update_40.77.229.16\" rule=\"40.77.229.16\" />\n\t\t<item name=\"update_40.77.229.21\" rule=\"40.77.229.21\" />\n\t\t<item name=\"update_40.77.229.22\" rule=\"40.77.229.22\" />\n\t\t<item name=\"update_40.77.229.24\" rule=\"40.77.229.24\" />\n\t\t<item name=\"update_40.77.229.26\" rule=\"40.77.229.26\" />\n\t\t<item name=\"update_40.77.229.27\" rule=\"40.77.229.27\" />\n\t\t<item name=\"update_40.77.229.29\" rule=\"40.77.229.29\" />\n\t\t<item name=\"update_40.77.229.30\" rule=\"40.77.229.30\" />\n\t\t<item name=\"update_40.77.229.32\" rule=\"40.77.229.32\" />\n\t\t<item name=\"update_40.77.229.35\" rule=\"40.77.229.35\" />\n\t\t<item name=\"update_40.77.229.38\" rule=\"40.77.229.38\" />\n\t\t<item name=\"update_40.77.229.44\" rule=\"40.77.229.44\" />\n\t\t<item name=\"update_40.77.229.45\" rule=\"40.77.229.45\" />\n\t\t<item name=\"update_40.77.229.50\" rule=\"40.77.229.50\" />\n\t\t<item name=\"update_40.77.229.53\" rule=\"40.77.229.53\" />\n\t\t<item name=\"update_40.77.229.62\" rule=\"40.77.229.62\" />\n\t\t<item name=\"update_40.77.229.65\" rule=\"40.77.229.65\" />\n\t\t<item name=\"update_40.77.229.67\" rule=\"40.77.229.67\" />\n\t\t<item name=\"update_40.77.229.69\" rule=\"40.77.229.69\" />\n\t\t<item name=\"update_40.77.229.70\" rule=\"40.77.229.70\" />\n\t\t<item name=\"update_40.77.229.71\" rule=\"40.77.229.71\" />\n\t\t<item name=\"update_40.77.229.74\" rule=\"40.77.229.74\" />\n\t\t<item name=\"update_40.77.229.76\" rule=\"40.77.229.76\" />\n\t\t<item name=\"update_40.77.229.80\" rule=\"40.77.229.80\" />\n\t\t<item name=\"update_40.77.229.81\" rule=\"40.77.229.81\" />\n\t\t<item name=\"update_40.77.229.82\" rule=\"40.77.229.82\" />\n\t\t<item name=\"update_40.77.229.88\" rule=\"40.77.229.88\" />\n\t\t<item name=\"update_40.77.229.118\" rule=\"40.77.229.118\" />\n\t\t<item name=\"update_40.77.229.123\" rule=\"40.77.229.123\" />\n\t\t<item name=\"update_40.77.229.128\" rule=\"40.77.229.128\" />\n\t\t<item name=\"update_40.77.229.133\" rule=\"40.77.229.133\" />\n\t\t<item name=\"update_40.77.229.141\" rule=\"40.77.229.141\" />\n\t\t<item name=\"update_40.77.229.199\" rule=\"40.77.229.199\" />\n\t\t<item name=\"update_40.79.65.78\" rule=\"40.79.65.78\" />\n\t\t<item name=\"update_40.79.65.123\" rule=\"40.79.65.123\" />\n\t\t<item name=\"update_40.79.65.235\" rule=\"40.79.65.235\" />\n\t\t<item name=\"update_40.79.65.237\" rule=\"40.79.65.237\" />\n\t\t<item name=\"update_40.79.66.194\" rule=\"40.79.66.194\" />\n\t\t<item name=\"update_40.79.66.209\" rule=\"40.79.66.209\" />\n\t\t<item name=\"update_40.79.67.176\" rule=\"40.79.67.176\" />\n\t\t<item name=\"update_40.79.70.158\" rule=\"40.79.70.158\" />\n\t\t<item name=\"update_40.91.73.169\" rule=\"40.91.73.169\" />\n\t\t<item name=\"update_40.91.73.219\" rule=\"40.91.73.219\" />\n\t\t<item name=\"update_40.91.75.5\" rule=\"40.91.75.5\" />\n\t\t<item name=\"update_40.91.80.89\" rule=\"40.91.80.89\" />\n\t\t<item name=\"update_40.91.91.94\" rule=\"40.91.91.94\" />\n\t\t<item name=\"update_40.91.120.196\" rule=\"40.91.120.196\" />\n\t\t<item name=\"update_40.91.122.44\" rule=\"40.91.122.44\" />\n\t\t<item name=\"update_40.125.122.151\" rule=\"40.125.122.151\" />\n\t\t<item name=\"update_40.125.122.176\" rule=\"40.125.122.176\" />\n\t\t<item name=\"update_51.103.5.159\" rule=\"51.103.5.159\" />\n\t\t<item name=\"update_51.103.5.186\" rule=\"51.103.5.186\" />\n\t\t<item name=\"update_51.104.162.50\" rule=\"51.104.162.50\" />\n\t\t<item name=\"update_51.104.162.168\" rule=\"51.104.162.168\" />\n\t\t<item name=\"update_51.104.164.114\" rule=\"51.104.164.114\" />\n\t\t<item name=\"update_51.104.167.48\" rule=\"51.104.167.48\" />\n\t\t<item name=\"update_51.104.167.186\" rule=\"51.104.167.186\" />\n\t\t<item name=\"update_51.104.167.245\" rule=\"51.104.167.245\" />\n\t\t<item name=\"update_51.104.167.255\" rule=\"51.104.167.255\" />\n\t\t<item name=\"update_51.105.249.223\" rule=\"51.105.249.223\" />\n\t\t<item name=\"update_51.105.249.228\" rule=\"51.105.249.228\" />\n\t\t<item name=\"update_51.105.249.239\" rule=\"51.105.249.239\" />\n\t\t<item name=\"update_52.137.102.105\" rule=\"52.137.102.105\" />\n\t\t<item name=\"update_52.137.103.96\" rule=\"52.137.103.96\" />\n\t\t<item name=\"update_52.137.103.130\" rule=\"52.137.103.130\" />\n\t\t<item name=\"update_52.137.110.235\" rule=\"52.137.110.235\" />\n\t\t<item name=\"update_52.142.21.136\" rule=\"52.142.21.136\" />\n\t\t<item name=\"update_52.142.21.137\" rule=\"52.142.21.137\" />\n\t\t<item name=\"update_52.142.21.139\" rule=\"52.142.21.139\" />\n\t\t<item name=\"update_52.142.21.140\" rule=\"52.142.21.140\" />\n\t\t<item name=\"update_52.142.21.141\" rule=\"52.142.21.141\" />\n\t\t<item name=\"update_52.143.80.209\" rule=\"52.143.80.209\" />\n\t\t<item name=\"update_52.143.81.222\" rule=\"52.143.81.222\" />\n\t\t<item name=\"update_52.143.84.45\" rule=\"52.143.84.45\" />\n\t\t<item name=\"update_52.143.86.214\" rule=\"52.143.86.214\" />\n\t\t<item name=\"update_52.143.87.28\" rule=\"52.143.87.28\" />\n\t\t<item name=\"update_52.147.176.8\" rule=\"52.147.176.8\" />\n\t\t<item name=\"update_52.148.148.114\" rule=\"52.148.148.114\" />\n\t\t<item name=\"update_52.152.108.96\" rule=\"52.152.108.96\" />\n\t\t<item name=\"update_52.152.110.14\" rule=\"52.152.110.14\" />\n\t\t<item name=\"update_52.155.95.90\" rule=\"52.155.95.90\" />\n\t\t<item name=\"update_52.155.115.56\" rule=\"52.155.115.56\" />\n\t\t<item name=\"update_52.155.169.137\" rule=\"52.155.169.137\" />\n\t\t<item name=\"update_52.155.183.99\" rule=\"52.155.183.99\" />\n\t\t<item name=\"update_52.155.217.156\" rule=\"52.155.217.156\" />\n\t\t<item name=\"update_52.155.223.194\" rule=\"52.155.223.194\" />\n\t\t<item name=\"update_52.156.144.83\" rule=\"52.156.144.83\" />\n\t\t<item name=\"update_52.158.114.119\" rule=\"52.158.114.119\" />\n\t\t<item name=\"update_52.158.122.14\" rule=\"52.158.122.14\" />\n\t\t<item name=\"update_52.161.15.246\" rule=\"52.161.15.246\" />\n\t\t<item name=\"update_52.164.221.179\" rule=\"52.164.221.179\" />\n\t\t<item name=\"update_52.164.226.245\" rule=\"52.164.226.245\" />\n\t\t<item name=\"update_52.167.222.82\" rule=\"52.167.222.82\" />\n\t\t<item name=\"update_52.167.222.147\" rule=\"52.167.222.147\" />\n\t\t<item name=\"update_52.167.223.135\" rule=\"52.167.223.135\" />\n\t\t<item name=\"update_52.169.82.131\" rule=\"52.169.82.131\" />\n\t\t<item name=\"update_52.169.83.3\" rule=\"52.169.83.3\" />\n\t\t<item name=\"update_52.169.87.42\" rule=\"52.169.87.42\" />\n\t\t<item name=\"update_52.169.123.48\" rule=\"52.169.123.48\" />\n\t\t<item name=\"update_52.175.23.79\" rule=\"52.175.23.79\" />\n\t\t<item name=\"update_52.177.164.251\" rule=\"52.177.164.251\" />\n\t\t<item name=\"update_52.177.247.15\" rule=\"52.177.247.15\" />\n\t\t<item name=\"update_52.178.192.146\" rule=\"52.178.192.146\" />\n\t\t<item name=\"update_52.179.216.235\" rule=\"52.179.216.235\" />\n\t\t<item name=\"update_52.179.219.14\" rule=\"52.179.219.14\" />\n\t\t<item name=\"update_52.183.47.176\" rule=\"52.183.47.176\" />\n\t\t<item name=\"update_52.183.118.171\" rule=\"52.183.118.171\" />\n\t\t<item name=\"update_52.184.152.136\" rule=\"52.184.152.136\" />\n\t\t<item name=\"update_52.184.155.206\" rule=\"52.184.155.206\" />\n\t\t<item name=\"update_52.184.212.181\" rule=\"52.184.212.181\" />\n\t\t<item name=\"update_52.184.213.21\" rule=\"52.184.213.21\" />\n\t\t<item name=\"update_52.184.213.187\" rule=\"52.184.213.187\" />\n\t\t<item name=\"update_52.184.214.53\" rule=\"52.184.214.53\" />\n\t\t<item name=\"update_52.184.214.123\" rule=\"52.184.214.123\" />\n\t\t<item name=\"update_52.184.214.139\" rule=\"52.184.214.139\" />\n\t\t<item name=\"update_52.184.216.174\" rule=\"52.184.216.174\" />\n\t\t<item name=\"update_52.184.216.226\" rule=\"52.184.216.226\" />\n\t\t<item name=\"update_52.184.216.246\" rule=\"52.184.216.246\" />\n\t\t<item name=\"update_52.184.217.20\" rule=\"52.184.217.20\" />\n\t\t<item name=\"update_52.184.217.37\" rule=\"52.184.217.37\" />\n\t\t<item name=\"update_52.184.217.56\" rule=\"52.184.217.56\" />\n\t\t<item name=\"update_52.187.60.107\" rule=\"52.187.60.107\" />\n\t\t<item name=\"update_52.188.72.233\" rule=\"52.188.72.233\" />\n\t\t<item name=\"update_52.226.130.114\" rule=\"52.226.130.114\" />\n\t\t<item name=\"update_52.229.170.171\" rule=\"52.229.170.171\" />\n\t\t<item name=\"update_52.229.170.224\" rule=\"52.229.170.224\" />\n\t\t<item name=\"update_52.229.171.86\" rule=\"52.229.171.86\" />\n\t\t<item name=\"update_52.229.171.202\" rule=\"52.229.171.202\" />\n\t\t<item name=\"update_52.229.172.155\" rule=\"52.229.172.155\" />\n\t\t<item name=\"update_52.229.174.29\" rule=\"52.229.174.29\" />\n\t\t<item name=\"update_52.229.174.172\" rule=\"52.229.174.172\" />\n\t\t<item name=\"update_52.229.174.233\" rule=\"52.229.174.233\" />\n\t\t<item name=\"update_52.229.175.79\" rule=\"52.229.175.79\" />\n\t\t<item name=\"update_52.230.216.17\" rule=\"52.230.216.17\" />\n\t\t<item name=\"update_52.230.216.157\" rule=\"52.230.216.157\" />\n\t\t<item name=\"update_52.230.220.159\" rule=\"52.230.220.159\" />\n\t\t<item name=\"update_52.230.223.92\" rule=\"52.230.223.92\" />\n\t\t<item name=\"update_52.230.223.167\" rule=\"52.230.223.167\" />\n\t\t<item name=\"update_52.232.225.93\" rule=\"52.232.225.93\" />\n\t\t<item name=\"update_52.238.248.1\" rule=\"52.238.248.1\" />\n\t\t<item name=\"update_52.238.248.2\" rule=\"52.238.248.2\" />\n\t\t<item name=\"update_52.238.248.3\" rule=\"52.238.248.3\" />\n\t\t<item name=\"update_52.238.248.4\" rule=\"52.238.248.4\" />\n\t\t<item name=\"update_52.238.248.5\" rule=\"52.238.248.5\" />\n\t\t<item name=\"update_52.238.248.6\" rule=\"52.238.248.6\" />\n\t\t<item name=\"update_52.238.248.7\" rule=\"52.238.248.7\" />\n\t\t<item name=\"update_52.242.97.97\" rule=\"52.242.97.97\" />\n\t\t<item name=\"update_52.242.101.226\" rule=\"52.242.101.226\" />\n\t\t<item name=\"update_52.242.231.32\" rule=\"52.242.231.32\" />\n\t\t<item name=\"update_52.242.231.33\" rule=\"52.242.231.33\" />\n\t\t<item name=\"update_52.242.231.35\" rule=\"52.242.231.35\" />\n\t\t<item name=\"update_52.242.231.36\" rule=\"52.242.231.36\" />\n\t\t<item name=\"update_52.242.231.37\" rule=\"52.242.231.37\" />\n\t\t<item name=\"update_52.243.153.146\" rule=\"52.243.153.146\" />\n\t\t<item name=\"update_52.248.96.36\" rule=\"52.248.96.36\" />\n\t\t<item name=\"update_52.249.24.101\" rule=\"52.249.24.101\" />\n\t\t<item name=\"update_52.249.36.200\" rule=\"52.249.36.200\" />\n\t\t<item name=\"update_52.249.36.205\" rule=\"52.249.36.205\" />\n\t\t<item name=\"update_52.249.36.206\" rule=\"52.249.36.206\" />\n\t\t<item name=\"update_52.249.36.207\" rule=\"52.249.36.207\" />\n\t\t<item name=\"update_52.249.58.51\" rule=\"52.249.58.51\" />\n\t\t<item name=\"update_52.250.46.232\" rule=\"52.250.46.232\" />\n\t\t<item name=\"update_52.250.46.237\" rule=\"52.250.46.237\" />\n\t\t<item name=\"update_52.250.46.238\" rule=\"52.250.46.238\" />\n\t\t<item name=\"update_52.250.195.200\" rule=\"52.250.195.200\" />\n\t\t<item name=\"update_52.250.195.204\" rule=\"52.250.195.204\" />\n\t\t<item name=\"update_52.250.195.206\" rule=\"52.250.195.206\" />\n\t\t<item name=\"update_52.250.195.207\" rule=\"52.250.195.207\" />\n\t\t<item name=\"update_52.251.79.25\" rule=\"52.251.79.25\" />\n\t\t<item name=\"update_52.253.130.84\" rule=\"52.253.130.84\" />\n\t\t<item name=\"update_52.254.106.61\" rule=\"52.254.106.61\" />\n\t\t<item name=\"update_52.254.114.64\" rule=\"52.254.114.64\" />\n\t\t<item name=\"update_52.254.114.65\" rule=\"52.254.114.65\" />\n\t\t<item name=\"update_52.254.114.67\" rule=\"52.254.114.67\" />\n\t\t<item name=\"update_52.254.114.68\" rule=\"52.254.114.68\" />\n\t\t<item name=\"update_52.254.114.69\" rule=\"52.254.114.69\" />\n\t\t<item name=\"update_52.254.114.70\" rule=\"52.254.114.70\" />\n\t\t<item name=\"update_52.254.114.71\" rule=\"52.254.114.71\" />\n\t\t<item name=\"update_64.4.27.50\" rule=\"64.4.27.50\" />\n\t\t<item name=\"update_65.52.108.29\" rule=\"65.52.108.29\" />\n\t\t<item name=\"update_65.52.108.33\" rule=\"65.52.108.33\" />\n\t\t<item name=\"update_65.52.108.59\" rule=\"65.52.108.59\" />\n\t\t<item name=\"update_65.52.108.90\" rule=\"65.52.108.90\" />\n\t\t<item name=\"update_65.52.108.92\" rule=\"65.52.108.92\" />\n\t\t<item name=\"update_65.52.108.153\" rule=\"65.52.108.153\" />\n\t\t<item name=\"update_65.52.108.154\" rule=\"65.52.108.154\" />\n\t\t<item name=\"update_65.52.108.185\" rule=\"65.52.108.185\" />\n\t\t<item name=\"update_65.55.138.0-65.55.138.255\" rule=\"65.55.138.0-65.55.138.255\" />\n\t\t<item name=\"update_65.55.242.254\" rule=\"65.55.242.254\" />\n\t\t<item name=\"update_66.119.144.157\" rule=\"66.119.144.157\" />\n\t\t<item name=\"update_66.119.144.158\" rule=\"66.119.144.158\" />\n\t\t<item name=\"update_66.119.144.189\" rule=\"66.119.144.189\" />\n\t\t<item name=\"update_66.119.144.190\" rule=\"66.119.144.190\" />\n\t\t<item name=\"update_67.26.27.254\" rule=\"67.26.27.254\" />\n\t\t<item name=\"update_104.45.177.233\" rule=\"104.45.177.233\" />\n\t\t<item name=\"update_111.221.29.40\" rule=\"111.221.29.40\" />\n\t\t<item name=\"update_134.170.51.187\" rule=\"134.170.51.187\" />\n\t\t<item name=\"update_134.170.51.188\" rule=\"134.170.51.188\" />\n\t\t<item name=\"update_134.170.51.190\" rule=\"134.170.51.190\" />\n\t\t<item name=\"update_134.170.51.246\" rule=\"134.170.51.246\" />\n\t\t<item name=\"update_134.170.51.247\" rule=\"134.170.51.247\" />\n\t\t<item name=\"update_134.170.51.248\" rule=\"134.170.51.248\" />\n\t\t<item name=\"update_134.170.53.29\" rule=\"134.170.53.29\" />\n\t\t<item name=\"update_134.170.53.30\" rule=\"134.170.53.30\" />\n\t\t<item name=\"update_134.170.58.0-134.170.58.255\" rule=\"134.170.58.0-134.170.58.255\" />\n\t\t<item name=\"update_134.170.115.55\" rule=\"134.170.115.55\" />\n\t\t<item name=\"update_134.170.115.56\" rule=\"134.170.115.56\" />\n\t\t<item name=\"update_134.170.115.60\" rule=\"134.170.115.60\" />\n\t\t<item name=\"update_134.170.115.62\" rule=\"134.170.115.62\" />\n\t\t<item name=\"update_134.170.165.248\" rule=\"134.170.165.248\" />\n\t\t<item name=\"update_134.170.165.249\" rule=\"134.170.165.249\" />\n\t\t<item name=\"update_134.170.165.251\" rule=\"134.170.165.251\" />\n\t\t<item name=\"update_134.170.165.253\" rule=\"134.170.165.253\" />\n\t\t<item name=\"update_137.135.62.92\" rule=\"137.135.62.92\" />\n\t\t<item name=\"update_157.55.133.204\" rule=\"157.55.133.204\" />\n\t\t<item name=\"update_157.55.240.89\" rule=\"157.55.240.89\" />\n\t\t<item name=\"update_157.55.240.126\" rule=\"157.55.240.126\" />\n\t\t<item name=\"update_157.55.240.220\" rule=\"157.55.240.220\" />\n\t\t<item name=\"update_157.56.77.138\" rule=\"157.56.77.138\" />\n\t\t<item name=\"update_157.56.77.139\" rule=\"157.56.77.139\" />\n\t\t<item name=\"update_157.56.77.140\" rule=\"157.56.77.140\" />\n\t\t<item name=\"update_157.56.77.141\" rule=\"157.56.77.141\" />\n\t\t<item name=\"update_157.56.77.148\" rule=\"157.56.77.148\" />\n\t\t<item name=\"update_157.56.77.149\" rule=\"157.56.77.149\" />\n\t\t<item name=\"update_157.56.96.54\" rule=\"157.56.96.54\" />\n\t\t<item name=\"update_157.56.96.58\" rule=\"157.56.96.58\" />\n\t\t<item name=\"update_157.56.96.123\" rule=\"157.56.96.123\" />\n\t\t<item name=\"update_157.56.96.157\" rule=\"157.56.96.157\" />\n\t\t<item name=\"update_191.232.80.53\" rule=\"191.232.80.53\" />\n\t\t<item name=\"update_191.232.80.58\" rule=\"191.232.80.58\" />\n\t\t<item name=\"update_191.232.80.60\" rule=\"191.232.80.60\" />\n\t\t<item name=\"update_191.232.80.62\" rule=\"191.232.80.62\" />\n\t\t<item name=\"update_191.232.139.2\" rule=\"191.232.139.2\" />\n\t\t<item name=\"update_191.232.139.182\" rule=\"191.232.139.182\" />\n\t\t<item name=\"update_191.232.139.253\" rule=\"191.232.139.253\" />\n\t\t<item name=\"update_191.232.139.254\" rule=\"191.232.139.254\" />\n\t\t<item name=\"update_191.234.72.183\" rule=\"191.234.72.183\" />\n\t\t<item name=\"update_191.234.72.186\" rule=\"191.234.72.186\" />\n\t\t<item name=\"update_191.234.72.188\" rule=\"191.234.72.188\" />\n\t\t<item name=\"update_191.234.72.190\" rule=\"191.234.72.190\" />\n\t\t<item name=\"update_207.46.114.58\" rule=\"207.46.114.58\" />\n\t\t<item name=\"update_207.46.114.61\" rule=\"207.46.114.61\" />\n\t</rules_blocklist>\n</root>\n"
  },
  {
    "path": "build.bat",
    "content": "@echo off\r\n\r\ncd ..\\builder\r\ncall build simplewall 3.8.7 simplewall\r\n\r\npause\r\n"
  },
  {
    "path": "build_locale.bat",
    "content": "@echo off\r\n\r\ncd ..\\builder\r\ncall build_locale simplewall\r\n\r\npause\r\n"
  },
  {
    "path": "build_simplewall_rules.bat",
    "content": "@echo off\n\ncd ..\\builder\ncall build_simplewall_rules update %~dp0bin\\profile_internal.xml %~dp0bin\\profile_internal.xml\n\npause\n"
  },
  {
    "path": "build_vc.bat",
    "content": "@echo off\n@setlocal enableextensions\nrem @cd /d \"%~dp0\\..\\\"\n\nrem VS 2026\n\nif exist \"%ProgramFiles%\\Microsoft Visual Studio\\18\\Community\\VC\\Auxiliary\\Build\\vcvarsall.bat\" (\n\tcall \"%ProgramFiles%\\Microsoft Visual Studio\\18\\Community\\VC\\Auxiliary\\Build\\vcvarsall.bat\" amd64_arm64\n\tgoto start\n)\n\nif exist \"%ProgramFiles%\\Microsoft Visual Studio\\18\\Professional\\VC\\Auxiliary\\Build\\vcvarsall.bat\" (\n\tcall \"%ProgramFiles%\\Microsoft Visual Studio\\18\\Professional\\VC\\Auxiliary\\Build\\vcvarsall.bat\" amd64_arm64\n\tgoto start\n)\n\necho VS 2026 was not found...\n\ngoto end\n\n:start\nmsbuild simplewall.sln -property:Configuration=Release -property:Platform=x64 -verbosity:normal\nif %ERRORLEVEL% neq 0 goto end\n\nmsbuild simplewall.sln -property:Configuration=Release -property:Platform=ARM64 -verbosity:normal\nif %ERRORLEVEL% neq 0 goto end\n\n:end\n\necho done...\n\npause\n"
  },
  {
    "path": "packages.config",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<packages>\n  <package id=\"Microsoft.Windows.CppWinRT\" version=\"2.0.230706.1\" targetFramework=\"native\" />\n</packages>\n"
  },
  {
    "path": "simplewall.sln",
    "content": "﻿\nMicrosoft Visual Studio Solution File, Format Version 12.00\n# Visual Studio Version 18\nVisualStudioVersion = 18.1.11312.151 d18.0\nMinimumVisualStudioVersion = 10.0.40219.1\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"simplewall\", \"simplewall.vcxproj\", \"{7FB76828-A353-4113-82D7-CD728EED81DF}\"\nEndProject\nGlobal\n\tGlobalSection(SolutionConfigurationPlatforms) = preSolution\n\t\tDebug|ARM64 = Debug|ARM64\n\t\tDebug|x64 = Debug|x64\n\t\tRelease|ARM64 = Release|ARM64\n\t\tRelease|x64 = Release|x64\n\tEndGlobalSection\n\tGlobalSection(ProjectConfigurationPlatforms) = postSolution\n\t\t{7FB76828-A353-4113-82D7-CD728EED81DF}.Debug|ARM64.ActiveCfg = Debug|ARM64\n\t\t{7FB76828-A353-4113-82D7-CD728EED81DF}.Debug|ARM64.Build.0 = Debug|ARM64\n\t\t{7FB76828-A353-4113-82D7-CD728EED81DF}.Debug|x64.ActiveCfg = Debug|x64\n\t\t{7FB76828-A353-4113-82D7-CD728EED81DF}.Debug|x64.Build.0 = Debug|x64\n\t\t{7FB76828-A353-4113-82D7-CD728EED81DF}.Release|ARM64.ActiveCfg = Release|ARM64\n\t\t{7FB76828-A353-4113-82D7-CD728EED81DF}.Release|ARM64.Build.0 = Release|ARM64\n\t\t{7FB76828-A353-4113-82D7-CD728EED81DF}.Release|x64.ActiveCfg = Release|x64\n\t\t{7FB76828-A353-4113-82D7-CD728EED81DF}.Release|x64.Build.0 = Release|x64\n\tEndGlobalSection\n\tGlobalSection(SolutionProperties) = preSolution\n\t\tHideSolutionNode = FALSE\n\tEndGlobalSection\n\tGlobalSection(ExtensibilityGlobals) = postSolution\n\t\tSolutionGuid = {A433DCFD-EECB-43BE-9EB1-DC7D0094F85F}\n\tEndGlobalSection\nEndGlobal\n"
  },
  {
    "path": "simplewall.vcxproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project DefaultTargets=\"Build\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <Import Project=\"packages\\Microsoft.Windows.CppWinRT.2.0.230706.1\\build\\native\\Microsoft.Windows.CppWinRT.props\" Condition=\"Exists('packages\\Microsoft.Windows.CppWinRT.2.0.230706.1\\build\\native\\Microsoft.Windows.CppWinRT.props')\" />\r\n  <ItemGroup Label=\"ProjectConfigurations\">\r\n    <ProjectConfiguration Include=\"Debug|ARM64\">\r\n      <Configuration>Debug</Configuration>\r\n      <Platform>ARM64</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"Release|ARM64\">\r\n      <Configuration>Release</Configuration>\r\n      <Platform>ARM64</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"Debug|Win32\">\r\n      <Configuration>Debug</Configuration>\r\n      <Platform>Win32</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"Release|Win32\">\r\n      <Configuration>Release</Configuration>\r\n      <Platform>Win32</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"Debug|x64\">\r\n      <Configuration>Debug</Configuration>\r\n      <Platform>x64</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"Release|x64\">\r\n      <Configuration>Release</Configuration>\r\n      <Platform>x64</Platform>\r\n    </ProjectConfiguration>\r\n  </ItemGroup>\r\n  <PropertyGroup Label=\"Globals\">\r\n    <ProjectGuid>{7FB76828-A353-4113-82D7-CD728EED81DF}</ProjectGuid>\r\n    <RootNamespace>simplewall</RootNamespace>\r\n    <ProjectName>simplewall</ProjectName>\r\n    <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>\r\n  </PropertyGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|ARM64'\" Label=\"Configuration\">\r\n    <ConfigurationType>Application</ConfigurationType>\r\n    <UseDebugLibraries>true</UseDebugLibraries>\r\n    <CharacterSet>Unicode</CharacterSet>\r\n    <PlatformToolset>v145</PlatformToolset>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|ARM64'\" Label=\"Configuration\">\r\n    <ConfigurationType>Application</ConfigurationType>\r\n    <UseDebugLibraries>false</UseDebugLibraries>\r\n    <WholeProgramOptimization>true</WholeProgramOptimization>\r\n    <CharacterSet>Unicode</CharacterSet>\r\n    <PlatformToolset>v145</PlatformToolset>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\" Label=\"Configuration\">\r\n    <ConfigurationType>Application</ConfigurationType>\r\n    <UseDebugLibraries>true</UseDebugLibraries>\r\n    <CharacterSet>Unicode</CharacterSet>\r\n    <PlatformToolset>v145</PlatformToolset>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\" Label=\"Configuration\">\r\n    <ConfigurationType>Application</ConfigurationType>\r\n    <UseDebugLibraries>false</UseDebugLibraries>\r\n    <WholeProgramOptimization>true</WholeProgramOptimization>\r\n    <CharacterSet>Unicode</CharacterSet>\r\n    <PlatformToolset>v145</PlatformToolset>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\" Label=\"Configuration\">\r\n    <ConfigurationType>Application</ConfigurationType>\r\n    <UseDebugLibraries>true</UseDebugLibraries>\r\n    <CharacterSet>Unicode</CharacterSet>\r\n    <PlatformToolset>v145</PlatformToolset>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\" Label=\"Configuration\">\r\n    <ConfigurationType>Application</ConfigurationType>\r\n    <UseDebugLibraries>false</UseDebugLibraries>\r\n    <WholeProgramOptimization>true</WholeProgramOptimization>\r\n    <CharacterSet>Unicode</CharacterSet>\r\n    <PlatformToolset>v145</PlatformToolset>\r\n  </PropertyGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />\r\n  <ImportGroup Label=\"ExtensionSettings\">\r\n  </ImportGroup>\r\n  <ImportGroup Label=\"Shared\">\r\n  </ImportGroup>\r\n  <ImportGroup Label=\"PropertySheets\" Condition=\"'$(Configuration)|$(Platform)'=='Debug|ARM64'\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n  </ImportGroup>\r\n  <ImportGroup Label=\"PropertySheets\" Condition=\"'$(Configuration)|$(Platform)'=='Release|ARM64'\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n  </ImportGroup>\r\n  <ImportGroup Label=\"PropertySheets\" Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n  </ImportGroup>\r\n  <ImportGroup Label=\"PropertySheets\" Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n  </ImportGroup>\r\n  <ImportGroup Label=\"PropertySheets\" Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n  </ImportGroup>\r\n  <ImportGroup Label=\"PropertySheets\" Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n  </ImportGroup>\r\n  <PropertyGroup Label=\"UserMacros\" />\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|ARM64'\">\r\n    <TargetName>$(ProjectName)</TargetName>\r\n    <IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);.\\..\\routine\\src\\;.\\src\\include\\;.\\src\\</IncludePath>\r\n    <GenerateManifest>false</GenerateManifest>\r\n    <IntDir>$(Platform)\\$(Configuration)\\$(ProjectName)\\</IntDir>\r\n    <CodeAnalysisRuleSet>MixedRecommendedRules.ruleset</CodeAnalysisRuleSet>\r\n    <OutDir>$(SolutionDir)bin\\$(PlatformArchitecture)\\</OutDir>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|ARM64'\">\r\n    <TargetName>$(ProjectName)</TargetName>\r\n    <IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);.\\..\\routine\\src\\;.\\src\\include\\;.\\src\\</IncludePath>\r\n    <GenerateManifest>false</GenerateManifest>\r\n    <IntDir>$(Platform)\\$(Configuration)\\$(ProjectName)\\</IntDir>\r\n    <CodeAnalysisRuleSet>MixedRecommendedRules.ruleset</CodeAnalysisRuleSet>\r\n    <OutDir>$(SolutionDir)bin\\$(PlatformArchitecture)\\</OutDir>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">\r\n    <OutDir>$(SolutionDir)bin\\$(PlatformArchitecture)\\</OutDir>\r\n    <TargetName>$(ProjectName)</TargetName>\r\n    <IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);.\\..\\routine\\src\\;.\\src\\include\\;.\\src\\</IncludePath>\r\n    <GenerateManifest>false</GenerateManifest>\r\n    <IntDir>$(Platform)\\$(Configuration)\\$(ProjectName)\\</IntDir>\r\n    <CodeAnalysisRuleSet>MixedRecommendedRules.ruleset</CodeAnalysisRuleSet>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">\r\n    <OutDir>$(SolutionDir)bin\\$(PlatformArchitecture)\\</OutDir>\r\n    <TargetName>$(ProjectName)</TargetName>\r\n    <IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);.\\..\\routine\\src\\;.\\src\\include\\;.\\src\\</IncludePath>\r\n    <GenerateManifest>false</GenerateManifest>\r\n    <IntDir>$(Platform)\\$(Configuration)\\$(ProjectName)\\</IntDir>\r\n    <CodeAnalysisRuleSet>MixedRecommendedRules.ruleset</CodeAnalysisRuleSet>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n    <OutDir>$(SolutionDir)bin\\$(PlatformArchitecture)\\</OutDir>\r\n    <TargetName>$(ProjectName)</TargetName>\r\n    <IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);.\\..\\routine\\src\\;.\\src\\include\\;.\\src\\</IncludePath>\r\n    <GenerateManifest>false</GenerateManifest>\r\n    <IntDir>$(Platform)\\$(Configuration)\\$(ProjectName)\\</IntDir>\r\n    <CodeAnalysisRuleSet>MixedRecommendedRules.ruleset</CodeAnalysisRuleSet>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n    <OutDir>$(SolutionDir)bin\\$(PlatformArchitecture)\\</OutDir>\r\n    <TargetName>$(ProjectName)</TargetName>\r\n    <IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);.\\..\\routine\\src\\;.\\src\\include\\;.\\src\\</IncludePath>\r\n    <GenerateManifest>false</GenerateManifest>\r\n    <IntDir>$(Platform)\\$(Configuration)\\$(ProjectName)\\</IntDir>\r\n    <CodeAnalysisRuleSet>MixedRecommendedRules.ruleset</CodeAnalysisRuleSet>\r\n  </PropertyGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|ARM64'\">\r\n    <ClCompile>\r\n      <WarningLevel>Level3</WarningLevel>\r\n      <Optimization>Disabled</Optimization>\r\n      <StringPooling>true</StringPooling>\r\n      <IntrinsicFunctions>true</IntrinsicFunctions>\r\n      <ControlFlowGuard>Guard</ControlFlowGuard>\r\n      <FunctionLevelLinking>true</FunctionLevelLinking>\r\n      <PreprocessorDefinitions>SECURITY_WIN32;MICROSOFT_WINDOWS_WINBASE_H_DEFINE_INTERLOCKED_CPLUSPLUS_OVERLOADS;_UNICODE;UNICODE;WIN32_LEAN_AND_MEAN;APP_NO_GUEST;APP_HAVE_AUTORUN;APP_HAVE_SKIPUAC;APP_HAVE_TRAY;APP_HAVE_SETTINGS;APP_HAVE_UPDATES;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <TreatWarningAsError>true</TreatWarningAsError>\r\n      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\r\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\r\n      <LanguageStandard>stdcpplatest</LanguageStandard>\r\n      <LanguageStandard_C>stdclatest</LanguageStandard_C>\r\n      <SDLCheck>true</SDLCheck>\r\n      <GuardEHContMetadata>true</GuardEHContMetadata>\r\n      <UseStandardPreprocessor>true</UseStandardPreprocessor>\r\n      <ConformanceMode>true</ConformanceMode>\r\n      <OmitFramePointers>true</OmitFramePointers>\r\n      <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>\r\n    </ClCompile>\r\n    <Link>\r\n      <GenerateDebugInformation>true</GenerateDebugInformation>\r\n      <OptimizeReferences>true</OptimizeReferences>\r\n      <EnableCOMDATFolding>true</EnableCOMDATFolding>\r\n      <SubSystem>Windows</SubSystem>\r\n      <AdditionalOptions>/DEPENDENTLOADFLAG:0x800 /BREPRO %(AdditionalOptions)</AdditionalOptions>\r\n      <DelayLoadDLLs>%(DelayLoadDLLs)</DelayLoadDLLs>\r\n      <LargeAddressAware>true</LargeAddressAware>\r\n    </Link>\r\n    <ResourceCompile>\r\n      <PreprocessorDefinitions>_UNICODE;UNICODE;_WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n    </ResourceCompile>\r\n  </ItemDefinitionGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">\r\n    <ClCompile>\r\n      <WarningLevel>Level3</WarningLevel>\r\n      <Optimization>Disabled</Optimization>\r\n      <StringPooling>true</StringPooling>\r\n      <IntrinsicFunctions>true</IntrinsicFunctions>\r\n      <ControlFlowGuard>Guard</ControlFlowGuard>\r\n      <FunctionLevelLinking>true</FunctionLevelLinking>\r\n      <PreprocessorDefinitions>SECURITY_WIN32;MICROSOFT_WINDOWS_WINBASE_H_DEFINE_INTERLOCKED_CPLUSPLUS_OVERLOADS;;UNICODE;WIN32_LEAN_AND_MEAN;APP_NO_GUEST;APP_HAVE_AUTORUN;APP_HAVE_SKIPUAC;APP_HAVE_TRAY;APP_HAVE_SETTINGS;APP_HAVE_UPDATES;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <TreatWarningAsError>true</TreatWarningAsError>\r\n      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\r\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\r\n      <LanguageStandard>stdcpplatest</LanguageStandard>\r\n      <LanguageStandard_C>stdclatest</LanguageStandard_C>\r\n      <CallingConvention>StdCall</CallingConvention>\r\n      <SDLCheck>true</SDLCheck>\r\n      <EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>\r\n      <UseStandardPreprocessor>true</UseStandardPreprocessor>\r\n      <ConformanceMode>true</ConformanceMode>\r\n      <OmitFramePointers>true</OmitFramePointers>\r\n      <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>\r\n    </ClCompile>\r\n    <Link>\r\n      <GenerateDebugInformation>true</GenerateDebugInformation>\r\n      <OptimizeReferences>true</OptimizeReferences>\r\n      <EnableCOMDATFolding>true</EnableCOMDATFolding>\r\n      <SubSystem>Windows</SubSystem>\r\n      <MinimumRequiredVersion>6.1</MinimumRequiredVersion>\r\n      <AdditionalOptions>/DEPENDENTLOADFLAG:0x800 /BREPRO %(AdditionalOptions)</AdditionalOptions>\r\n      <CETCompat>true</CETCompat>\r\n      <DelayLoadDLLs>%(DelayLoadDLLs)</DelayLoadDLLs>\r\n      <LargeAddressAware>true</LargeAddressAware>\r\n    </Link>\r\n    <ResourceCompile>\r\n      <PreprocessorDefinitions>_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n    </ResourceCompile>\r\n  </ItemDefinitionGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n    <ClCompile>\r\n      <WarningLevel>Level3</WarningLevel>\r\n      <Optimization>Disabled</Optimization>\r\n      <StringPooling>true</StringPooling>\r\n      <IntrinsicFunctions>true</IntrinsicFunctions>\r\n      <ControlFlowGuard>Guard</ControlFlowGuard>\r\n      <FunctionLevelLinking>true</FunctionLevelLinking>\r\n      <PreprocessorDefinitions>SECURITY_WIN32;MICROSOFT_WINDOWS_WINBASE_H_DEFINE_INTERLOCKED_CPLUSPLUS_OVERLOADS;_UNICODE;UNICODE;WIN32_LEAN_AND_MEAN;APP_NO_GUEST;APP_HAVE_AUTORUN;APP_HAVE_SKIPUAC;APP_HAVE_TRAY;APP_HAVE_SETTINGS;APP_HAVE_UPDATES;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <TreatWarningAsError>true</TreatWarningAsError>\r\n      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\r\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\r\n      <LanguageStandard>stdcpplatest</LanguageStandard>\r\n      <LanguageStandard_C>stdclatest</LanguageStandard_C>\r\n      <CallingConvention>StdCall</CallingConvention>\r\n      <SDLCheck>true</SDLCheck>\r\n      <GuardEHContMetadata>true</GuardEHContMetadata>\r\n      <EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>\r\n      <UseStandardPreprocessor>true</UseStandardPreprocessor>\r\n      <ConformanceMode>true</ConformanceMode>\r\n      <OmitFramePointers>true</OmitFramePointers>\r\n      <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>\r\n    </ClCompile>\r\n    <Link>\r\n      <GenerateDebugInformation>true</GenerateDebugInformation>\r\n      <OptimizeReferences>true</OptimizeReferences>\r\n      <EnableCOMDATFolding>true</EnableCOMDATFolding>\r\n      <SubSystem>Windows</SubSystem>\r\n      <AdditionalOptions>/DEPENDENTLOADFLAG:0x800 /BREPRO %(AdditionalOptions)</AdditionalOptions>\r\n      <MinimumRequiredVersion>6.1</MinimumRequiredVersion>\r\n      <CETCompat>true</CETCompat>\r\n      <DelayLoadDLLs>%(DelayLoadDLLs)</DelayLoadDLLs>\r\n      <LargeAddressAware>true</LargeAddressAware>\r\n    </Link>\r\n    <ResourceCompile>\r\n      <PreprocessorDefinitions>_UNICODE;UNICODE;_WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n    </ResourceCompile>\r\n  </ItemDefinitionGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|ARM64'\">\r\n    <ClCompile>\r\n      <WarningLevel>Level3</WarningLevel>\r\n      <Optimization>MaxSpeed</Optimization>\r\n      <FunctionLevelLinking>true</FunctionLevelLinking>\r\n      <IntrinsicFunctions>true</IntrinsicFunctions>\r\n      <ControlFlowGuard>Guard</ControlFlowGuard>\r\n      <StringPooling>true</StringPooling>\r\n      <RuntimeLibrary>MultiThreaded</RuntimeLibrary>\r\n      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\r\n      <PreprocessorDefinitions>SECURITY_WIN32;MICROSOFT_WINDOWS_WINBASE_H_DEFINE_INTERLOCKED_CPLUSPLUS_OVERLOADS;_UNICODE;UNICODE;WIN32_LEAN_AND_MEAN;APP_NO_GUEST;APP_HAVE_AUTORUN;APP_HAVE_SKIPUAC;APP_HAVE_TRAY;APP_HAVE_SETTINGS;APP_HAVE_UPDATES;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <TreatWarningAsError>true</TreatWarningAsError>\r\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\r\n      <LanguageStandard>stdcpplatest</LanguageStandard>\r\n      <LanguageStandard_C>stdclatest</LanguageStandard_C>\r\n      <SDLCheck>true</SDLCheck>\r\n      <GuardEHContMetadata>true</GuardEHContMetadata>\r\n      <UseStandardPreprocessor>true</UseStandardPreprocessor>\r\n      <ConformanceMode>true</ConformanceMode>\r\n      <OmitFramePointers>true</OmitFramePointers>\r\n      <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>\r\n      <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>\r\n    </ClCompile>\r\n    <Link>\r\n      <GenerateDebugInformation>true</GenerateDebugInformation>\r\n      <EnableCOMDATFolding>true</EnableCOMDATFolding>\r\n      <OptimizeReferences>true</OptimizeReferences>\r\n      <SetChecksum>true</SetChecksum>\r\n      <SubSystem>Windows</SubSystem>\r\n      <AdditionalOptions>/DEPENDENTLOADFLAG:0x800 /BREPRO %(AdditionalOptions)</AdditionalOptions>\r\n      <LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>\r\n      <DelayLoadDLLs>%(DelayLoadDLLs)</DelayLoadDLLs>\r\n      <LargeAddressAware>true</LargeAddressAware>\r\n    </Link>\r\n    <ResourceCompile>\r\n      <PreprocessorDefinitions>_UNICODE;UNICODE;_WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n    </ResourceCompile>\r\n  </ItemDefinitionGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">\r\n    <ClCompile>\r\n      <WarningLevel>Level3</WarningLevel>\r\n      <Optimization>MaxSpeed</Optimization>\r\n      <FunctionLevelLinking>true</FunctionLevelLinking>\r\n      <IntrinsicFunctions>true</IntrinsicFunctions>\r\n      <ControlFlowGuard>Guard</ControlFlowGuard>\r\n      <StringPooling>true</StringPooling>\r\n      <RuntimeLibrary>MultiThreaded</RuntimeLibrary>\r\n      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\r\n      <PreprocessorDefinitions>SECURITY_WIN32;MICROSOFT_WINDOWS_WINBASE_H_DEFINE_INTERLOCKED_CPLUSPLUS_OVERLOADS;_UNICODE;UNICODE;WIN32_LEAN_AND_MEAN;APP_NO_GUEST;APP_HAVE_AUTORUN;APP_HAVE_SKIPUAC;APP_HAVE_TRAY;APP_HAVE_SETTINGS;APP_HAVE_UPDATES;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <TreatWarningAsError>true</TreatWarningAsError>\r\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\r\n      <LanguageStandard>stdcpplatest</LanguageStandard>\r\n      <LanguageStandard_C>stdclatest</LanguageStandard_C>\r\n      <CallingConvention>StdCall</CallingConvention>\r\n      <SDLCheck>true</SDLCheck>\r\n      <EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>\r\n      <UseStandardPreprocessor>true</UseStandardPreprocessor>\r\n      <ConformanceMode>true</ConformanceMode>\r\n      <OmitFramePointers>true</OmitFramePointers>\r\n      <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>\r\n      <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>\r\n    </ClCompile>\r\n    <Link>\r\n      <GenerateDebugInformation>true</GenerateDebugInformation>\r\n      <EnableCOMDATFolding>true</EnableCOMDATFolding>\r\n      <OptimizeReferences>true</OptimizeReferences>\r\n      <SetChecksum>true</SetChecksum>\r\n      <SubSystem>Windows</SubSystem>\r\n      <MinimumRequiredVersion>6.1</MinimumRequiredVersion>\r\n      <AdditionalOptions>/DEPENDENTLOADFLAG:0x800 /BREPRO %(AdditionalOptions)</AdditionalOptions>\r\n      <CETCompat>true</CETCompat>\r\n      <LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>\r\n      <DelayLoadDLLs>%(DelayLoadDLLs)</DelayLoadDLLs>\r\n      <LargeAddressAware>true</LargeAddressAware>\r\n    </Link>\r\n    <ResourceCompile>\r\n      <PreprocessorDefinitions>_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n    </ResourceCompile>\r\n  </ItemDefinitionGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n    <ClCompile>\r\n      <WarningLevel>Level3</WarningLevel>\r\n      <Optimization>MaxSpeed</Optimization>\r\n      <FunctionLevelLinking>true</FunctionLevelLinking>\r\n      <IntrinsicFunctions>true</IntrinsicFunctions>\r\n      <ControlFlowGuard>Guard</ControlFlowGuard>\r\n      <StringPooling>true</StringPooling>\r\n      <RuntimeLibrary>MultiThreaded</RuntimeLibrary>\r\n      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\r\n      <PreprocessorDefinitions>SECURITY_WIN32;MICROSOFT_WINDOWS_WINBASE_H_DEFINE_INTERLOCKED_CPLUSPLUS_OVERLOADS;_UNICODE;UNICODE;WIN32_LEAN_AND_MEAN;APP_NO_GUEST;APP_HAVE_AUTORUN;APP_HAVE_SKIPUAC;APP_HAVE_TRAY;APP_HAVE_SETTINGS;APP_HAVE_UPDATES;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <TreatWarningAsError>true</TreatWarningAsError>\r\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\r\n      <LanguageStandard>stdcpplatest</LanguageStandard>\r\n      <LanguageStandard_C>stdclatest</LanguageStandard_C>\r\n      <CallingConvention>StdCall</CallingConvention>\r\n      <SDLCheck>true</SDLCheck>\r\n      <GuardEHContMetadata>true</GuardEHContMetadata>\r\n      <EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>\r\n      <UseStandardPreprocessor>true</UseStandardPreprocessor>\r\n      <ConformanceMode>true</ConformanceMode>\r\n      <OmitFramePointers>true</OmitFramePointers>\r\n      <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>\r\n      <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>\r\n    </ClCompile>\r\n    <Link>\r\n      <GenerateDebugInformation>true</GenerateDebugInformation>\r\n      <EnableCOMDATFolding>true</EnableCOMDATFolding>\r\n      <OptimizeReferences>true</OptimizeReferences>\r\n      <SetChecksum>true</SetChecksum>\r\n      <SubSystem>Windows</SubSystem>\r\n      <AdditionalOptions>/DEPENDENTLOADFLAG:0x800 /BREPRO %(AdditionalOptions)</AdditionalOptions>\r\n      <MinimumRequiredVersion>6.1</MinimumRequiredVersion>\r\n      <CETCompat>true</CETCompat>\r\n      <LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>\r\n      <DelayLoadDLLs>%(DelayLoadDLLs)</DelayLoadDLLs>\r\n      <LargeAddressAware>true</LargeAddressAware>\r\n    </Link>\r\n    <ResourceCompile>\r\n      <PreprocessorDefinitions>_UNICODE;UNICODE;_WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n    </ResourceCompile>\r\n  </ItemDefinitionGroup>\r\n  <ItemGroup>\r\n    <ClCompile Include=\"..\\routine\\src\\rapp.c\" />\r\n    <ClCompile Include=\"..\\routine\\src\\routine.c\" />\r\n    <ClCompile Include=\"src\\controls.c\" />\r\n    <ClCompile Include=\"src\\db.c\" />\r\n    <ClCompile Include=\"src\\editor.c\" />\r\n    <ClCompile Include=\"src\\helper.c\" />\r\n    <ClCompile Include=\"src\\icons.c\" />\r\n    <ClCompile Include=\"src\\listview.c\" />\r\n    <ClCompile Include=\"src\\log.c\" />\r\n    <ClCompile Include=\"src\\main.c\" />\r\n    <ClCompile Include=\"src\\network.c\" />\r\n    <ClCompile Include=\"src\\notifications.c\" />\r\n    <ClCompile Include=\"src\\packages.c\" />\r\n    <ClCompile Include=\"src\\profile.c\" />\r\n    <ClCompile Include=\"src\\search.c\" />\r\n    <ClCompile Include=\"src\\security.c\" />\r\n    <ClCompile Include=\"src\\timer.c\" />\r\n    <ClCompile Include=\"src\\uwp.cpp\" />\r\n    <ClCompile Include=\"src\\wfp.c\" />\r\n    <ClCompile Include=\"src\\messages.c\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ClInclude Include=\"..\\routine\\src\\ntapi.h\" />\r\n    <ClInclude Include=\"..\\routine\\src\\ntrtl.h\" />\r\n    <ClInclude Include=\"..\\routine\\src\\rapp.h\" />\r\n    <ClInclude Include=\"..\\routine\\src\\rconfig.h\" />\r\n    <ClInclude Include=\"..\\routine\\src\\routine.h\" />\r\n    <ClInclude Include=\"..\\routine\\src\\rtypes.h\" />\r\n    <ClInclude Include=\"src\\app.h\" />\r\n    <ClInclude Include=\"src\\controls.h\" />\r\n    <ClInclude Include=\"src\\db.h\" />\r\n    <ClInclude Include=\"src\\editor.h\" />\r\n    <ClInclude Include=\"src\\global.h\" />\r\n    <ClInclude Include=\"src\\helper.h\" />\r\n    <ClInclude Include=\"src\\icons.h\" />\r\n    <ClInclude Include=\"src\\listview.h\" />\r\n    <ClInclude Include=\"src\\log.h\" />\r\n    <ClInclude Include=\"src\\main.h\" />\r\n    <ClInclude Include=\"src\\network.h\" />\r\n    <ClInclude Include=\"src\\notifications.h\" />\r\n    <ClInclude Include=\"src\\packages.h\" />\r\n    <ClInclude Include=\"src\\profile.h\" />\r\n    <ClInclude Include=\"src\\resource.h\" />\r\n    <ClInclude Include=\"src\\search.h\" />\r\n    <ClInclude Include=\"src\\security.h\" />\r\n    <ClInclude Include=\"src\\timer.h\" />\r\n    <ClInclude Include=\"src\\uwp.h\" />\r\n    <ClInclude Include=\"src\\wfp.h\" />\r\n    <ClInclude Include=\"src\\messages.h\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ResourceCompile Include=\"src\\resource.rc\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <None Include=\"packages.config\" />\r\n  </ItemGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />\r\n  <ImportGroup Label=\"ExtensionTargets\">\r\n    <Import Project=\"packages\\Microsoft.Windows.CppWinRT.2.0.230706.1\\build\\native\\Microsoft.Windows.CppWinRT.targets\" Condition=\"Exists('packages\\Microsoft.Windows.CppWinRT.2.0.230706.1\\build\\native\\Microsoft.Windows.CppWinRT.targets')\" />\r\n  </ImportGroup>\r\n  <Target Name=\"EnsureNuGetPackageBuildImports\" BeforeTargets=\"PrepareForBuild\">\r\n    <PropertyGroup>\r\n      <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>\r\n    </PropertyGroup>\r\n    <Error Condition=\"!Exists('packages\\Microsoft.Windows.CppWinRT.2.0.230706.1\\build\\native\\Microsoft.Windows.CppWinRT.props')\" Text=\"$([System.String]::Format('$(ErrorText)', 'packages\\Microsoft.Windows.CppWinRT.2.0.240405.15\\build\\native\\Microsoft.Windows.CppWinRT.props'))\" />\r\n    <Error Condition=\"!Exists('packages\\Microsoft.Windows.CppWinRT.2.0.230706.1\\build\\native\\Microsoft.Windows.CppWinRT.targets')\" Text=\"$([System.String]::Format('$(ErrorText)', 'packages\\Microsoft.Windows.2.0.230706.1\\build\\native\\Microsoft.Windows.CppWinRT.targets'))\" />\r\n  </Target>\r\n</Project>"
  },
  {
    "path": "simplewall.vcxproj.filters",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <ItemGroup>\r\n    <Filter Include=\"Source Files\">\r\n      <UniqueIdentifier>{3C4265CC-2D78-44DE-BC9F-1C64FB817DA5}</UniqueIdentifier>\r\n      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>\r\n    </Filter>\r\n    <Filter Include=\"Header Files\">\r\n      <UniqueIdentifier>{7B1ACFC7-8801-49F4-9D4D-E3CBFEC33A8D}</UniqueIdentifier>\r\n      <Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>\r\n    </Filter>\r\n    <Filter Include=\"Resource Files\">\r\n      <UniqueIdentifier>{0373C32A-908E-4C0A-8D5B-07C4A21C3725}</UniqueIdentifier>\r\n      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>\r\n    </Filter>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ClCompile Include=\"src\\main.c\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"src\\wfp.c\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"src\\profile.c\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"src\\log.c\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"src\\notifications.c\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"src\\timer.c\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"src\\helper.c\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"src\\editor.c\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"src\\controls.c\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"src\\messages.c\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"src\\security.c\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"src\\search.c\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"src\\network.c\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"src\\packages.c\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"src\\icons.c\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"src\\db.c\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"src\\listview.c\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\routine\\src\\rapp.c\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\routine\\src\\routine.c\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"src\\uwp.cpp\">\r\n      <Filter>Source Files</Filter>\r\n    </ClCompile>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ClInclude Include=\"src\\main.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"src\\resource.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"src\\app.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"src\\wfp.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"src\\profile.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"src\\log.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"src\\notifications.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"src\\timer.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"src\\helper.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"src\\global.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"src\\editor.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"src\\controls.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"src\\security.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"src\\messages.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"src\\search.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"src\\network.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"src\\packages.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"src\\icons.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"src\\db.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"src\\listview.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\routine\\src\\rtypes.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\routine\\src\\ntapi.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\routine\\src\\ntrtl.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\routine\\src\\rapp.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\routine\\src\\rconfig.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\routine\\src\\routine.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"src\\uwp.h\">\r\n      <Filter>Header Files</Filter>\r\n    </ClInclude>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ResourceCompile Include=\"src\\resource.rc\">\r\n      <Filter>Resource Files</Filter>\r\n    </ResourceCompile>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <None Include=\"packages.config\" />\r\n  </ItemGroup>\r\n</Project>"
  },
  {
    "path": "simplewall.vcxproj.user",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project ToolsVersion=\"Current\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|ARM64'\">\n    <RemoteDebuggerWorkingDirectory>$(SolutionDir)bin\\$(PlatformArchitecture)\\</RemoteDebuggerWorkingDirectory>\n    <DebuggerFlavor>WindowsRemoteDebugger</DebuggerFlavor>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|ARM64'\">\n    <RemoteDebuggerWorkingDirectory>$(SolutionDir)bin\\$(PlatformArchitecture)\\</RemoteDebuggerWorkingDirectory>\n    <DebuggerFlavor>WindowsRemoteDebugger</DebuggerFlavor>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">\n    <LocalDebuggerWorkingDirectory>$(SolutionDir)bin\\$(PlatformArchitecture)\\</LocalDebuggerWorkingDirectory>\n    <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">\n    <LocalDebuggerWorkingDirectory>$(SolutionDir)bin\\$(PlatformArchitecture)\\</LocalDebuggerWorkingDirectory>\n    <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\n    <LocalDebuggerWorkingDirectory>$(SolutionDir)bin\\$(PlatformArchitecture)\\</LocalDebuggerWorkingDirectory>\n    <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\n    <LocalDebuggerWorkingDirectory>$(SolutionDir)bin\\$(PlatformArchitecture)\\</LocalDebuggerWorkingDirectory>\n    <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>\n  </PropertyGroup>\n</Project>"
  },
  {
    "path": "src/app.h",
    "content": "// simplewall\r\n// Copyright (c) 2016-2026 Henry++\r\n\r\n#pragma once\r\n\r\n#define APP_NAME L\"simplewall\"\r\n#define APP_NAME_SHORT L\"simplewall\"\r\n#define APP_VERSION L\"3.8.7\"\r\n#define APP_VERSION_RES 3,8,7,0\r\n#define APP_AUTHOR L\"Henry++\"\r\n#define APP_COPYRIGHT L\"(c) 2016-2026 \" APP_AUTHOR L\". All Rights Reversed.\"\r\n"
  },
  {
    "path": "src/controls.c",
    "content": "// simplewall\r\n// Copyright (c) 2016-2026 Henry++\r\n\r\n#include \"global.h\"\r\n\r\nVOID _app_getapptooltipstring (\r\n\t_Inout_ PR_STRINGBUILDER buffer,\r\n\t_In_ ULONG app_hash,\r\n\t_In_opt_ PITEM_NETWORK ptr_network,\r\n\t_In_opt_ PITEM_LOG ptr_log\r\n)\r\n{\r\n\tPITEM_APP_INFO ptr_app_info;\r\n\tR_STRINGBUILDER sb;\r\n\tPR_STRING path = NULL;\r\n\tPITEM_APP ptr_app;\r\n\tPR_STRING string;\r\n\tPR_STRING value;\r\n\r\n\tptr_app = _app_getappitem (app_hash);\r\n\r\n\t// file path\r\n\tif (ptr_app)\r\n\t{\r\n\t\tif (ptr_app->real_path)\r\n\t\t{\r\n\t\t\tpath = ptr_app->real_path;\r\n\t\t}\r\n\t\telse if (ptr_app->display_name)\r\n\t\t{\r\n\t\t\tpath = ptr_app->display_name;\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tpath = ptr_app->original_path;\r\n\t\t}\r\n\t}\r\n\telse if (ptr_network)\r\n\t{\r\n\t\tpath = ptr_network->path;\r\n\t}\r\n\telse if (ptr_log)\r\n\t{\r\n\t\tif (ptr_log->path)\r\n\t\t\tpath = ptr_log->path;\r\n\t}\r\n\r\n\tif (ptr_log)\r\n\t\t_r_obj_appendstringbuilderformat (buffer, L\"#%d - \", _InterlockedCompareExchange (&ptr_log->log_id, 0, 0));\r\n\r\n\tif (path)\r\n\t{\r\n\t\t_r_obj_appendstringbuilder2 (buffer, &path->sr);\r\n\r\n\t\t_r_obj_appendstringbuilder (buffer, SZ_CRLF);\r\n\t}\r\n\r\n\t// file information\r\n\t_r_obj_initializestringbuilder (&sb, 512);\r\n\r\n\t// file display name\r\n\tif (ptr_app)\r\n\t{\r\n\t\tif (ptr_app->display_name)\r\n\t\t{\r\n\t\t\t_r_obj_appendstringbuilder (&sb, SZ_TAB);\r\n\t\t\t_r_obj_appendstringbuilder2 (&sb, &ptr_app->display_name->sr);\r\n\t\t\t_r_obj_appendstringbuilder (&sb, SZ_CRLF);\r\n\t\t}\r\n\t}\r\n\r\n\t// file version\r\n\tptr_app_info = _app_getappinfobyhash2 (app_hash);\r\n\r\n\tif (ptr_app_info)\r\n\t{\r\n\t\tif (!_r_obj_isstringempty (ptr_app_info->version_info))\r\n\t\t{\r\n\t\t\t_r_obj_appendstringbuilder (&sb, SZ_TAB);\r\n\t\t\t_r_obj_appendstringbuilder2 (&sb, &ptr_app_info->version_info->sr);\r\n\t\t\t_r_obj_appendstringbuilder (&sb, SZ_CRLF);\r\n\t\t}\r\n\t}\r\n\r\n\t// compile\r\n\tif (!_r_obj_isstringempty2 (sb.string))\r\n\t{\r\n\t\tstring = _r_obj_concatstrings (\r\n\t\t\t2,\r\n\t\t\t_r_locale_getstring (IDS_FILE),\r\n\t\t\tL\":\\r\\n\"\r\n\t\t);\r\n\r\n\t\t_r_obj_insertstringbuilder2 (&sb, 0, &string->sr);\r\n\t\t_r_obj_appendstringbuilder2 (buffer, &sb.string->sr);\r\n\r\n\t\t_r_obj_dereference (string);\r\n\t}\r\n\r\n\t// comment\r\n\tif (ptr_app)\r\n\t{\r\n\t\tif (!_r_obj_isstringempty (ptr_app->comment))\r\n\t\t{\r\n\t\t\tstring = _r_obj_concatstrings (\r\n\t\t\t\t2,\r\n\t\t\t\t_r_locale_getstring (IDS_COMMENT),\r\n\t\t\t\tL\":\\r\\n\"\r\n\t\t\t);\r\n\r\n\t\t\t_r_obj_appendstringbuilder2 (buffer, &string->sr);\r\n\r\n\t\t\t_r_obj_appendstringbuilder (buffer, SZ_TAB);\r\n\t\t\t_r_obj_appendstringbuilder2 (buffer, &ptr_app->comment->sr);\r\n\t\t\t_r_obj_appendstringbuilder (buffer, SZ_CRLF);\r\n\r\n\t\t\t_r_obj_dereference (string);\r\n\t\t}\r\n\t}\r\n\r\n\t// file signature\r\n\tif (ptr_app_info)\r\n\t{\r\n\t\tif (!_r_obj_isstringempty (ptr_app_info->signature_info))\r\n\t\t{\r\n\t\t\tstring = _r_obj_concatstrings (\r\n\t\t\t\t4,\r\n\t\t\t\t_r_locale_getstring (IDS_SIGNATURE),\r\n\t\t\t\tL\":\\r\\n\" SZ_TAB,\r\n\t\t\t\tptr_app_info->signature_info->buffer,\r\n\t\t\t\tSZ_CRLF\r\n\t\t\t);\r\n\r\n\t\t\t_r_obj_appendstringbuilder2 (buffer, &string->sr);\r\n\r\n\t\t\t_r_obj_dereference (string);\r\n\t\t}\r\n\t}\r\n\r\n\t_r_obj_deletestringbuilder (&sb);\r\n\r\n\t// app timer\r\n\tif (ptr_app)\r\n\t{\r\n\t\tif (_app_istimerset (ptr_app))\r\n\t\t{\r\n\t\t\tvalue = _r_format_interval (ptr_app->timer - _r_unixtime_now ());\r\n\r\n\t\t\tif (value)\r\n\t\t\t{\r\n\t\t\t\tstring = _r_obj_concatstrings (\r\n\t\t\t\t\t4,\r\n\t\t\t\t\t_r_locale_getstring (IDS_TIMELEFT),\r\n\t\t\t\t\tL\":\" SZ_TAB_CRLF,\r\n\t\t\t\t\tvalue->buffer,\r\n\t\t\t\t\tSZ_CRLF\r\n\t\t\t\t);\r\n\r\n\t\t\t\t_r_obj_appendstringbuilder2 (buffer, &string->sr);\r\n\r\n\t\t\t\t_r_obj_dereference (string);\r\n\t\t\t\t_r_obj_dereference (value);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t// app rules\r\n\tvalue = _app_appexpandrules (app_hash, SZ_TAB_CRLF);\r\n\r\n\tif (value)\r\n\t{\r\n\t\tstring = _r_obj_concatstrings (\r\n\t\t\t4,\r\n\t\t\t_r_locale_getstring (IDS_RULE),\r\n\t\t\tL\":\" SZ_TAB_CRLF,\r\n\t\t\tvalue->buffer,\r\n\t\t\tSZ_CRLF\r\n\t\t);\r\n\r\n\t\t_r_obj_appendstringbuilder2 (buffer, &string->sr);\r\n\r\n\t\t_r_obj_dereference (string);\r\n\t\t_r_obj_dereference (value);\r\n\t}\r\n\r\n\t// app notes\r\n\tif (ptr_app)\r\n\t{\r\n\t\t_r_obj_initializestringbuilder (&sb, 512);\r\n\r\n\t\t// app type\r\n\t\tif (ptr_app->type == DATA_APP_NETWORK)\r\n\t\t{\r\n\t\t\t_r_obj_appendstringbuilder (&sb, SZ_TAB);\r\n\t\t\t_r_obj_appendstringbuilder (&sb, _r_locale_getstring (IDS_HIGHLIGHT_NETWORK));\r\n\t\t\t_r_obj_appendstringbuilder (&sb, SZ_CRLF);\r\n\t\t}\r\n\t\telse if (ptr_app->type == DATA_APP_PICO)\r\n\t\t{\r\n\t\t\t_r_obj_appendstringbuilder (&sb, SZ_TAB);\r\n\t\t\t_r_obj_appendstringbuilder (&sb, _r_locale_getstring (IDS_HIGHLIGHT_PICO));\r\n\t\t\t_r_obj_appendstringbuilder (&sb, SZ_CRLF);\r\n\t\t}\r\n\r\n\t\t// app settings\r\n\t\tif (_app_isappfromsystem (ptr_app->real_path, app_hash))\r\n\t\t{\r\n\t\t\t_r_obj_appendstringbuilder (&sb, SZ_TAB);\r\n\t\t\t_r_obj_appendstringbuilder (&sb, _r_locale_getstring (IDS_HIGHLIGHT_SYSTEM));\r\n\t\t\t_r_obj_appendstringbuilder (&sb, SZ_CRLF);\r\n\t\t}\r\n\r\n\t\tif (_app_network_isapphaveconnection (app_hash))\r\n\t\t{\r\n\t\t\t_r_obj_appendstringbuilder (&sb, SZ_TAB);\r\n\t\t\t_r_obj_appendstringbuilder (&sb, _r_locale_getstring (IDS_HIGHLIGHT_CONNECTION));\r\n\t\t\t_r_obj_appendstringbuilder (&sb, SZ_CRLF);\r\n\t\t}\r\n\r\n\t\tif (ptr_app->is_silent)\r\n\t\t{\r\n\t\t\t_r_obj_appendstringbuilder (&sb, SZ_TAB);\r\n\t\t\t_r_obj_appendstringbuilder (&sb, _r_locale_getstring (IDS_HIGHLIGHT_SILENT));\r\n\t\t\t_r_obj_appendstringbuilder (&sb, SZ_CRLF);\r\n\t\t}\r\n\r\n\t\tif (ptr_app->is_undeletable)\r\n\t\t{\r\n\t\t\t_r_obj_appendstringbuilder (&sb, SZ_TAB);\r\n\t\t\t_r_obj_appendstringbuilder (&sb, _r_locale_getstring (IDS_DISABLEREMOVAL));\r\n\t\t\t_r_obj_appendstringbuilder (&sb, SZ_CRLF);\r\n\t\t}\r\n\r\n\t\tif (!_app_isappexists (ptr_app))\r\n\t\t{\r\n\t\t\t_r_obj_appendstringbuilder (&sb, SZ_TAB);\r\n\t\t\t_r_obj_appendstringbuilder (&sb, _r_locale_getstring (IDS_HIGHLIGHT_INVALID));\r\n\t\t\t_r_obj_appendstringbuilder (&sb, SZ_CRLF);\r\n\t\t}\r\n\r\n\t\tstring = _r_obj_finalstringbuilder (&sb);\r\n\r\n\t\tif (!_r_obj_isstringempty2 (string))\r\n\t\t{\r\n\t\t\t_r_obj_insertstringbuilder (&sb, 0, L\":\\r\\n\");\r\n\t\t\t_r_obj_insertstringbuilder (&sb, 0, _r_locale_getstring (IDS_NOTES));\r\n\r\n\t\t\t_r_obj_appendstringbuilder2 (buffer, &string->sr);\r\n\t\t}\r\n\r\n\t\t_r_obj_deletestringbuilder (&sb);\r\n\r\n\t\t_r_obj_dereference (ptr_app);\r\n\t}\r\n\r\n\t// show additional log information\r\n\tif (ptr_log)\r\n\t{\r\n\t\t_r_obj_appendstringbuilder (buffer, _r_locale_getstring (IDS_TITLE_ADVANCED));\r\n\t\t_r_obj_appendstringbuilder (buffer, L\":\\r\\n\");\r\n\r\n\t\t_r_obj_appendstringbuilder (buffer, SZ_TAB);\r\n\r\n\t\t_r_obj_appendstringbuilder (buffer, _r_locale_getstring (IDS_FILTER));\r\n\t\t_r_obj_appendstringbuilder (buffer, L\": \");\r\n\r\n\t\tif (ptr_log->filter_name)\r\n\t\t{\r\n\t\t\t_r_obj_appendstringbuilder2 (buffer, &ptr_log->filter_name->sr);\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\t_r_obj_appendstringbuilder (buffer, _r_locale_getstring (IDS_STATUS_EMPTY));\r\n\t\t}\r\n\r\n\t\t_r_obj_appendstringbuilder (buffer, SZ_CRLF SZ_TAB);\r\n\r\n\t\t_r_obj_appendstringbuilder (buffer, _r_locale_getstring (IDS_LAYER));\r\n\t\t_r_obj_appendstringbuilder (buffer, L\": \");\r\n\r\n\t\tif (ptr_log->layer_name)\r\n\t\t{\r\n\t\t\t_r_obj_appendstringbuilder2 (buffer, &ptr_log->layer_name->sr);\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\t_r_obj_appendstringbuilder (buffer, _r_locale_getstring (IDS_STATUS_EMPTY));\r\n\t\t}\r\n\r\n\t\t_r_obj_appendstringbuilder (buffer, SZ_CRLF);\r\n\t}\r\n}\r\n\r\n_Ret_maybenull_\r\nPR_STRING _app_gettooltipbylparam (\r\n\t_In_ HWND hwnd,\r\n\t_In_ INT listview_id,\r\n\t_In_ LONG_PTR lparam\r\n)\r\n{\r\n\tR_STRINGBUILDER sb;\r\n\tPITEM_NETWORK ptr_network;\r\n\tPITEM_RULE ptr_rule;\r\n\tPR_STRING string1;\r\n\tPR_STRING string2;\r\n\tPITEM_LOG ptr_log;\r\n\r\n\tUNREFERENCED_PARAMETER (hwnd);\r\n\r\n\t_r_obj_initializestringbuilder (&sb, 512);\r\n\r\n\tswitch (listview_id)\r\n\t{\r\n\t\tcase IDC_APPS_PROFILE:\r\n\t\tcase IDC_APPS_SERVICE:\r\n\t\tcase IDC_APPS_UWP:\r\n\t\tcase IDC_RULE_APPS_ID:\r\n\t\t{\r\n\t\t\t_app_getapptooltipstring (&sb, (ULONG)lparam, NULL, NULL);\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase IDC_RULES_BLOCKLIST:\r\n\t\tcase IDC_RULES_SYSTEM:\r\n\t\tcase IDC_RULES_CUSTOM:\r\n\t\tcase IDC_APP_RULES_ID:\r\n\t\t{\r\n\t\t\tptr_rule = _app_getrulebyid (lparam);\r\n\r\n\t\t\tif (!ptr_rule)\r\n\t\t\t\tbreak;\r\n\r\n\t\t\t// rule address\r\n\t\t\tstring1 = _app_rulesexpandrules (ptr_rule->rule_remote, SZ_CRLF SZ_TAB);\r\n\t\t\tstring2 = _app_rulesexpandrules (ptr_rule->rule_local, SZ_CRLF SZ_TAB);\r\n\r\n\t\t\t_r_obj_appendstringbuilderformat (\r\n\t\t\t\t&sb,\r\n\t\t\t\tL\"%s (#%\" TEXT (PR_LONG_PTR) L\")\\r\\n%s (%s):\\r\\n%s%s\\r\\n%s (%s):\\r\\n%s%s\",\r\n\t\t\t\t_r_obj_getstringordefault (ptr_rule->name, _r_locale_getstring (IDS_STATUS_EMPTY)),\r\n\t\t\t\tlparam,\r\n\t\t\t\t_r_locale_getstring (IDS_RULE),\r\n\t\t\t\t_r_locale_getstring (IDS_DIRECTION_REMOTE),\r\n\t\t\t\tSZ_TAB,\r\n\t\t\t\t_r_obj_getstringordefault (string1, _r_locale_getstring (IDS_STATUS_EMPTY)),\r\n\t\t\t\t_r_locale_getstring (IDS_RULE),\r\n\t\t\t\t_r_locale_getstring (IDS_DIRECTION_LOCAL),\r\n\t\t\t\tSZ_TAB,\r\n\t\t\t\t_r_obj_getstringordefault (string2, _r_locale_getstring (IDS_STATUS_EMPTY))\r\n\t\t\t);\r\n\r\n\t\t\tif (string1)\r\n\t\t\t\t_r_obj_dereference (string1);\r\n\r\n\t\t\tif (string2)\r\n\t\t\t\t_r_obj_dereference (string2);\r\n\r\n\t\t\t// rule apps\r\n\t\t\tif (ptr_rule->is_forservices || !_r_obj_isempty (ptr_rule->apps))\r\n\t\t\t{\r\n\t\t\t\tstring1 = _app_rulesexpandapps (ptr_rule, TRUE, SZ_TAB_CRLF);\r\n\r\n\t\t\t\tif (string1)\r\n\t\t\t\t{\r\n\t\t\t\t\tstring2 = _r_obj_concatstrings (\r\n\t\t\t\t\t\t4,\r\n\t\t\t\t\t\tSZ_CRLF,\r\n\t\t\t\t\t\t_r_locale_getstring (IDS_TAB_APPS),\r\n\t\t\t\t\t\tL\":\\r\\n\" SZ_TAB,\r\n\t\t\t\t\t\tstring1->buffer\r\n\t\t\t\t\t);\r\n\r\n\t\t\t\t\t_r_obj_appendstringbuilder2 (&sb, &string2->sr);\r\n\t\t\t\t\t_r_obj_appendstringbuilder (&sb, SZ_CRLF);\r\n\r\n\t\t\t\t\t_r_obj_dereference (string1);\r\n\t\t\t\t\t_r_obj_dereference (string2);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\t// comment\r\n\t\t\tif (!_r_obj_isstringempty (ptr_rule->comment))\r\n\t\t\t{\r\n\t\t\t\tstring1 = _r_obj_concatstrings (\r\n\t\t\t\t\t3,\r\n\t\t\t\t\tSZ_CRLF,\r\n\t\t\t\t\t_r_locale_getstring (IDS_COMMENT),\r\n\t\t\t\t\tL\":\\r\\n\" SZ_TAB\r\n\t\t\t\t);\r\n\r\n\t\t\t\t_r_obj_appendstringbuilder2 (&sb, &string1->sr);\r\n\r\n\t\t\t\t_r_obj_appendstringbuilder2 (&sb, &ptr_rule->comment->sr);\r\n\r\n\t\t\t\t_r_obj_dereference (string1);\r\n\t\t\t}\r\n\r\n\t\t\t// rule notes\r\n\t\t\tif (ptr_rule->is_readonly && ptr_rule->type == DATA_RULE_USER)\r\n\t\t\t{\r\n\t\t\t\tstring2 = _r_obj_concatstrings (\r\n\t\t\t\t\t4,\r\n\t\t\t\t\tSZ_CRLF,\r\n\t\t\t\t\t_r_locale_getstring (IDS_NOTES),\r\n\t\t\t\t\tL\":\\r\\n\" SZ_TAB,\r\n\t\t\t\t\t_r_locale_getstring (IDS_INTERNAL_RULE)\r\n\t\t\t\t);\r\n\r\n\t\t\t\t_r_obj_appendstringbuilder2 (&sb, &string2->sr);\r\n\r\n\t\t\t\t_r_obj_dereference (string2);\r\n\t\t\t}\r\n\r\n\t\t\t_r_obj_dereference (ptr_rule);\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase IDC_NETWORK:\r\n\t\t{\r\n\t\t\tptr_network = _app_network_getitem ((ULONG)lparam);\r\n\r\n\t\t\tif (!ptr_network)\r\n\t\t\t\tbreak;\r\n\r\n\t\t\t_app_getapptooltipstring (&sb, ptr_network->app_hash, ptr_network, NULL);\r\n\r\n\t\t\t_r_obj_dereference (ptr_network);\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase IDC_LOG:\r\n\t\t{\r\n\t\t\tptr_log = _app_getlogitem ((ULONG)lparam);\r\n\r\n\t\t\tif (!ptr_log)\r\n\t\t\t\tbreak;\r\n\r\n\t\t\t_app_getapptooltipstring (&sb, ptr_log->app_hash, NULL, ptr_log);\r\n\r\n\t\t\t_r_obj_dereference (ptr_log);\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\r\n\tstring1 = _r_obj_finalstringbuilder (&sb);\r\n\r\n\tif (!_r_obj_isstringempty2 (string1))\r\n\t\treturn string1;\r\n\r\n\t_r_obj_deletestringbuilder (&sb);\r\n\r\n\treturn NULL;\r\n}\r\n\r\nVOID _app_settab_id (\r\n\t_In_ HWND hwnd,\r\n\t_In_ INT page_id\r\n)\r\n{\r\n\tPITEM_TAB_CONTEXT tab_context;\r\n\tHWND hctrl;\r\n\r\n\tif (!page_id)\r\n\t\treturn;\r\n\r\n\thctrl = GetDlgItem (hwnd, page_id);\r\n\r\n\tif (!hctrl)\r\n\t\treturn;\r\n\r\n\ttab_context = _app_listview_getcontext (hwnd, INT_ERROR);\r\n\r\n\tif (!tab_context || (tab_context->listview_id == page_id && _r_wnd_isvisible (hctrl, FALSE)))\r\n\t\treturn;\r\n\r\n\tfor (INT i = 0; i < _r_tab_getitemcount (hwnd, IDC_TAB); i++)\r\n\t{\r\n\t\ttab_context = _app_listview_getcontext (hwnd, i);\r\n\r\n\t\tif (tab_context && tab_context->listview_id == page_id)\r\n\t\t{\r\n\t\t\t_r_tab_selectitem (hwnd, IDC_TAB, i);\r\n\r\n\t\t\treturn;\r\n\t\t}\r\n\t}\r\n\r\n\tif (page_id != IDC_APPS_PROFILE)\r\n\t\t_app_settab_id (hwnd, IDC_APPS_PROFILE);\r\n}\r\n\r\nLPWSTR _app_getstateaction (\r\n\t_In_ ENUM_INSTALL_TYPE install_type\r\n)\r\n{\r\n\tUINT locale_id;\r\n\r\n\tswitch (install_type)\r\n\t{\r\n\t\tcase INSTALL_ENABLED:\r\n\t\tcase INSTALL_ENABLED_TEMPORARY:\r\n\t\t{\r\n\t\t\tlocale_id = IDS_TRAY_STOP;\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase INSTALL_DISABLED:\r\n\t\t{\r\n\t\t\tlocale_id = IDS_TRAY_START;\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tdefault:\r\n\t\t{\r\n\t\t\treturn NULL;\r\n\t\t}\r\n\t}\r\n\r\n\treturn _r_locale_getstring (locale_id);\r\n}\r\n\r\nHBITMAP _app_getstatebitmap (\r\n\t_In_ ENUM_INSTALL_TYPE install_type\r\n)\r\n{\r\n\tswitch (install_type)\r\n\t{\r\n\t\tcase INSTALL_ENABLED:\r\n\t\tcase INSTALL_ENABLED_TEMPORARY:\r\n\t\t{\r\n\t\t\treturn config.hbmp_disable;\r\n\t\t}\r\n\r\n\t\tcase INSTALL_DISABLED:\r\n\t\t{\r\n\t\t\treturn config.hbmp_enable;\r\n\t\t}\r\n\t}\r\n\r\n\treturn NULL;\r\n}\r\n\r\nINT _app_getstateicon (\r\n\t_In_ ENUM_INSTALL_TYPE install_type\r\n)\r\n{\r\n\tswitch (install_type)\r\n\t{\r\n\t\tcase INSTALL_ENABLED:\r\n\t\tcase INSTALL_ENABLED_TEMPORARY:\r\n\t\t{\r\n\t\t\treturn IDI_ACTIVE;\r\n\t\t}\r\n\r\n\t\tdefault:\r\n\t\t{\r\n\t\t\tFALLTHROUGH;\r\n\t\t}\r\n\t}\r\n\r\n\treturn IDI_INACTIVE;\r\n}\r\n\r\nLPCWSTR _app_getstatelocale (\r\n\t_In_ ENUM_INSTALL_TYPE install_type\r\n)\r\n{\r\n\tUINT locale_id;\r\n\r\n\tswitch (install_type)\r\n\t{\r\n\t\tcase INSTALL_ENABLED:\r\n\t\t{\r\n\t\t\tlocale_id = IDS_STATUS_FILTERS_ACTIVE;\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase INSTALL_ENABLED_TEMPORARY:\r\n\t\t{\r\n\t\t\tlocale_id = IDS_STATUS_FILTERS_ACTIVE_TEMP;\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase INSTALL_DISABLED:\r\n\t\t{\r\n\t\t\tlocale_id = IDS_STATUS_FILTERS_INACTIVE;\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tdefault:\r\n\t\t{\r\n\t\t\treturn NULL;\r\n\t\t}\r\n\t}\r\n\r\n\treturn _r_locale_getstring (locale_id);\r\n}\r\n\r\nBOOLEAN _app_initinterfacestate (\r\n\t_In_ HWND hwnd,\r\n\t_In_ BOOLEAN is_forced\r\n)\r\n{\r\n\tif (is_forced || _r_toolbar_isenabled (config.hrebar, IDC_TOOLBAR, IDM_TRAY_START))\r\n\t{\r\n\t\t_r_toolbar_enablebutton (config.hrebar, IDC_TOOLBAR, IDM_TRAY_START, FALSE);\r\n\t\t_r_toolbar_enablebutton (config.hrebar, IDC_TOOLBAR, IDM_REFRESH, FALSE);\r\n\r\n\t\t_r_status_settextformat (hwnd, IDC_STATUSBAR, 0, L\"%s...\", _r_locale_getstring (IDS_STATUS_FILTERS_PROCESSING));\r\n\r\n\t\treturn TRUE;\r\n\t}\r\n\r\n\treturn FALSE;\r\n}\r\n\r\nVOID _app_restoreinterfacestate (\r\n\t_In_ HWND hwnd,\r\n\t_In_ BOOLEAN is_enabled\r\n)\r\n{\r\n\tENUM_INSTALL_TYPE install_type;\r\n\r\n\tif (!is_enabled)\r\n\t\treturn;\r\n\r\n\tinstall_type = _wfp_getinstalltype ();\r\n\r\n\t_r_toolbar_enablebutton (config.hrebar, IDC_TOOLBAR, IDM_TRAY_START, TRUE);\r\n\t_r_toolbar_enablebutton (config.hrebar, IDC_TOOLBAR, IDM_REFRESH, TRUE);\r\n\r\n\t_r_status_settext (hwnd, IDC_STATUSBAR, 0, _app_getstatelocale (install_type));\r\n}\r\n\r\nVOID _app_setinterfacestate (\r\n\t_In_ HWND hwnd,\r\n\t_In_ LONG dpi_value\r\n)\r\n{\r\n\tENUM_INSTALL_TYPE install_type;\r\n\tHICON hico_sm;\r\n\tHICON hico_big;\r\n\tLONG icon_small;\r\n\tLONG icon_large;\r\n\tINT icon_id;\r\n\tBOOLEAN is_filtersinstalled;\r\n\r\n\tinstall_type = _wfp_getinstalltype ();\r\n\tis_filtersinstalled = (install_type != INSTALL_DISABLED);\r\n\r\n\ticon_small = _r_dc_getsystemmetrics (SM_CXSMICON, dpi_value);\r\n\ticon_large = _r_dc_getsystemmetrics (SM_CXICON, dpi_value);\r\n\r\n\ticon_id = _app_getstateicon (install_type);\r\n\r\n\thico_sm = _r_sys_loadsharedicon (_r_sys_getimagebase (), MAKEINTRESOURCE (icon_id), icon_small);\r\n\thico_big = _r_sys_loadsharedicon (_r_sys_getimagebase (), MAKEINTRESOURCE (icon_id), icon_large);\r\n\r\n\t_r_wnd_seticon (hwnd, hico_sm, hico_big);\r\n\r\n\t//_r_status_seticon (hwnd, IDC_STATUSBAR, 0, hico_sm);\r\n\r\n\tif (!_wfp_isfiltersapplying ())\r\n\t\t_r_status_settext (hwnd, IDC_STATUSBAR, 0, _app_getstatelocale (install_type));\r\n\r\n\t_r_toolbar_setbutton (config.hrebar, IDC_TOOLBAR, IDM_TRAY_START, _app_getstateaction (install_type), BTNS_BUTTON | BTNS_AUTOSIZE | BTNS_SHOWTEXT, 0, is_filtersinstalled ? 1 : 0);\r\n\r\n\t_app_settrayicon (hwnd, install_type);\r\n}\r\n\r\nVOID _app_settrayicon (\r\n\t_In_ HWND hwnd,\r\n\t_In_ ENUM_INSTALL_TYPE install_type\r\n)\r\n{\r\n\tHICON current_handle;\r\n\tHICON new_handle;\r\n\tLONG dpi_value;\r\n\tLONG icon_size;\r\n\tINT icon_id;\r\n\r\n\tdpi_value = _r_dc_gettaskbardpi ();\r\n\ticon_size = _r_dc_getsystemmetrics (SM_CXSMICON, dpi_value);\r\n\ticon_id = _app_getstateicon (install_type);\r\n\r\n\tcurrent_handle = _InterlockedCompareExchangePointer ((volatile PVOID_PTR)&config.htray_icon, NULL, config.htray_icon);\r\n\r\n\tif (current_handle)\r\n\t\tDestroyIcon (current_handle);\r\n\r\n\t_r_sys_loadicon (_r_sys_getimagebase (), MAKEINTRESOURCE (icon_id), icon_size, &new_handle);\r\n\r\n\t_r_tray_setinfo (hwnd, &GUID_TrayIcon, new_handle, _r_app_getname ());\r\n\r\n\tcurrent_handle = _InterlockedCompareExchangePointer ((volatile PVOID_PTR)&config.htray_icon, new_handle, NULL);\r\n\r\n\tif (current_handle)\r\n\t\tDestroyIcon (current_handle);\r\n}\r\n\r\nVOID _app_imagelist_init (\r\n\t_In_opt_ HWND hwnd,\r\n\t_In_ LONG dpi_value\r\n)\r\n{\r\n\tUINT toolbar_ids[] = {\r\n\t\tIDP_SHIELD_ENABLE,\r\n\t\tIDP_SHIELD_DISABLE,\r\n\t\tIDP_REFRESH,\r\n\t\tIDP_SETTINGS,\r\n\t\tIDP_NOTIFICATIONS,\r\n\t\tIDP_LOG,\r\n\t\tIDP_LOGOPEN,\r\n\t\tIDP_LOGCLEAR,\r\n\t\tIDP_ADD,\r\n\t\tIDP_DONATE,\r\n\t\tIDP_LOGUI,\r\n\t};\r\n\r\n\tUINT rules_ids[] = {\r\n\t\tIDP_ALLOW,\r\n\t\tIDP_BLOCK\r\n\t};\r\n\r\n\tHBITMAP hbitmap;\r\n\tLONG icon_size_toolbar;\r\n\tLONG icon_small;\r\n\tLONG icon_large;\r\n\r\n\tSAFE_DELETE_OBJECT (config.hbmp_enable);\r\n\tSAFE_DELETE_OBJECT (config.hbmp_disable);\r\n\tSAFE_DELETE_OBJECT (config.hbmp_allow);\r\n\tSAFE_DELETE_OBJECT (config.hbmp_block);\r\n\r\n\ticon_small = _r_dc_getsystemmetrics (SM_CXSMICON, dpi_value);\r\n\ticon_large = _r_dc_getsystemmetrics (SM_CXICON, dpi_value);\r\n\r\n\ticon_size_toolbar = _r_calc_clamp (_r_dc_getdpi (_r_config_getlong (L\"ToolbarSize\", PR_SIZE_ITEMHEIGHT, NULL), dpi_value), icon_small, icon_large);\r\n\r\n\t_r_res_loadimage (_r_sys_getimagebase (), L\"PNG\", MAKEINTRESOURCE (IDP_SHIELD_ENABLE), &GUID_ContainerFormatPng, icon_small, icon_small, &config.hbmp_enable);\r\n\t_r_res_loadimage (_r_sys_getimagebase (), L\"PNG\", MAKEINTRESOURCE (IDP_SHIELD_DISABLE), &GUID_ContainerFormatPng, icon_small, icon_small, &config.hbmp_disable);\r\n\r\n\t_r_res_loadimage (_r_sys_getimagebase (), L\"PNG\", MAKEINTRESOURCE (IDP_ALLOW), &GUID_ContainerFormatPng, icon_small, icon_small, &config.hbmp_allow);\r\n\t_r_res_loadimage (_r_sys_getimagebase (), L\"PNG\", MAKEINTRESOURCE (IDP_BLOCK), &GUID_ContainerFormatPng, icon_small, icon_small, &config.hbmp_block);\r\n\r\n\t// toolbar imagelist\r\n\tif (config.himg_toolbar)\r\n\t{\r\n\t\t_r_imagelist_setsize (config.himg_toolbar, icon_size_toolbar);\r\n\t}\r\n\telse\r\n\t{\r\n\t\t_r_imagelist_create (icon_size_toolbar, icon_size_toolbar, ILC_COLOR32 | ILC_HIGHQUALITYSCALE, RTL_NUMBER_OF (toolbar_ids), RTL_NUMBER_OF (toolbar_ids), &config.himg_toolbar);\r\n\t}\r\n\r\n\tif (config.himg_toolbar)\r\n\t{\r\n\t\tfor (ULONG_PTR i = 0; i < RTL_NUMBER_OF (toolbar_ids); i++)\r\n\t\t{\r\n\t\t\t_r_res_loadimage (_r_sys_getimagebase (), L\"PNG\", MAKEINTRESOURCE (toolbar_ids[i]), &GUID_ContainerFormatPng, icon_size_toolbar, icon_size_toolbar, &hbitmap);\r\n\r\n\t\t\tif (hbitmap)\r\n\t\t\t\t_r_imagelist_add (config.himg_toolbar, hbitmap, NULL, NULL);\r\n\t\t}\r\n\t}\r\n\r\n\tif (config.htoolbar)\r\n\t\t_r_toolbar_setimagelist (config.htoolbar, 0, config.himg_toolbar);\r\n\r\n\t// rules imagelist (small)\r\n\tif (config.himg_rules_small)\r\n\t{\r\n\t\t_r_imagelist_setsize (config.himg_rules_small, icon_small);\r\n\t}\r\n\telse\r\n\t{\r\n\t\t_r_imagelist_create (icon_small, icon_small, ILC_COLOR32 | ILC_HIGHQUALITYSCALE, RTL_NUMBER_OF (rules_ids), RTL_NUMBER_OF (rules_ids), &config.himg_rules_small);\r\n\t}\r\n\r\n\tif (config.himg_rules_small)\r\n\t{\r\n\t\tfor (ULONG_PTR i = 0; i < RTL_NUMBER_OF (rules_ids); i++)\r\n\t\t{\r\n\t\t\t_r_res_loadimage (_r_sys_getimagebase (), L\"PNG\", MAKEINTRESOURCE (rules_ids[i]), &GUID_ContainerFormatPng, icon_small, icon_small, &hbitmap);\r\n\r\n\t\t\tif (hbitmap)\r\n\t\t\t\t_r_imagelist_add (config.himg_rules_small, hbitmap, NULL, NULL);\r\n\t\t}\r\n\t}\r\n\r\n\t// rules imagelist (large)\r\n\tif (config.himg_rules_large)\r\n\t{\r\n\t\t_r_imagelist_setsize (config.himg_rules_large, icon_large);\r\n\t}\r\n\telse\r\n\t{\r\n\t\t_r_imagelist_create (icon_large, icon_large, ILC_COLOR32 | ILC_HIGHQUALITYSCALE, RTL_NUMBER_OF (rules_ids), RTL_NUMBER_OF (rules_ids), &config.himg_rules_large);\r\n\t}\r\n\r\n\tif (config.himg_rules_large)\r\n\t{\r\n\t\tfor (ULONG_PTR i = 0; i < RTL_NUMBER_OF (rules_ids); i++)\r\n\t\t{\r\n\t\t\t_r_res_loadimage (_r_sys_getimagebase (), L\"PNG\", MAKEINTRESOURCE (rules_ids[i]), &GUID_ContainerFormatPng, icon_large, icon_large, &hbitmap);\r\n\r\n\t\t\tif (hbitmap)\r\n\t\t\t\t_r_imagelist_add (config.himg_rules_large, hbitmap, NULL, NULL);\r\n\t\t}\r\n\t}\r\n}\r\n\r\nHFONT _app_createfont (\r\n\t_Inout_ PLOGFONT logfont,\r\n\t_In_ LONG size,\r\n\t_In_ BOOLEAN is_underline,\r\n\t_In_ LONG dpi_value\r\n)\r\n{\r\n\tHFONT hfont;\r\n\r\n\tif (size)\r\n\t\tlogfont->lfHeight = _r_dc_fontsizetoheight (size, dpi_value);\r\n\r\n\tlogfont->lfUnderline = is_underline;\r\n\tlogfont->lfCharSet = DEFAULT_CHARSET;\r\n\tlogfont->lfQuality = DEFAULT_QUALITY;\r\n\r\n\thfont = CreateFontIndirectW (logfont);\r\n\r\n\treturn hfont;\r\n}\r\n\r\nVOID _app_windowloadfont (\r\n\t_In_ LONG dpi_value\r\n)\r\n{\r\n\tNONCLIENTMETRICS ncm = {0};\r\n\r\n\tncm.cbSize = sizeof (NONCLIENTMETRICS);\r\n\r\n\tif (!_r_dc_getsystemparametersinfo (SPI_GETNONCLIENTMETRICS, ncm.cbSize, &ncm, dpi_value))\r\n\t\treturn;\r\n\r\n\tSAFE_DELETE_OBJECT (config.wnd_font);\r\n\r\n\tconfig.wnd_font = _app_createfont (&ncm.lfMessageFont, 0, FALSE, 0);\r\n\r\n\t_app_toolbar_setfont ();\r\n}\r\n\r\nVOID _app_toolbar_init (\r\n\t_In_ HWND hwnd,\r\n\t_In_ LONG dpi_value\r\n)\r\n{\r\n\tULONG button_size;\r\n\r\n\tconfig.hrebar = GetDlgItem (hwnd, IDC_REBAR);\r\n\r\n\t_app_windowloadfont (dpi_value);\r\n\r\n\tconfig.htoolbar = CreateWindowExW (\r\n\t\t0,\r\n\t\tTOOLBARCLASSNAMEW,\r\n\t\tNULL,\r\n\t\tWS_CHILD | WS_VISIBLE | CCS_NOPARENTALIGN | CCS_NODIVIDER | TBSTYLE_FLAT | TBSTYLE_LIST | TBSTYLE_TRANSPARENT | TBSTYLE_TOOLTIPS | TBSTYLE_AUTOSIZE,\r\n\t\tCW_USEDEFAULT,\r\n\t\tCW_USEDEFAULT,\r\n\t\tCW_USEDEFAULT,\r\n\t\tCW_USEDEFAULT,\r\n\t\tconfig.hrebar,\r\n\t\t(HMENU)IDC_TOOLBAR,\r\n\t\t_r_sys_getimagebase (),\r\n\t\tNULL\r\n\t);\r\n\r\n\tif (config.htoolbar)\r\n\t{\r\n\t\t_r_toolbar_setstyle (config.hrebar, IDC_TOOLBAR, TBSTYLE_EX_DOUBLEBUFFER | TBSTYLE_EX_MIXEDBUTTONS | TBSTYLE_EX_HIDECLIPPEDBUTTONS);\r\n\r\n\t\t_r_ctrl_setfont (config.htoolbar, 0, config.wnd_font); // fix font\r\n\t\t_r_toolbar_setimagelist (config.htoolbar, 0, config.himg_toolbar);\r\n\r\n\t\t_r_toolbar_addbutton (config.hrebar, IDC_TOOLBAR, IDM_TRAY_START, BTNS_BUTTON | BTNS_AUTOSIZE, NULL, TBSTATE_ENABLED, I_IMAGENONE);\r\n\r\n\t\t_r_toolbar_addseparator (config.hrebar, IDC_TOOLBAR);\r\n\r\n\t\t_r_toolbar_addbutton (config.hrebar, IDC_TOOLBAR, IDM_OPENRULESEDITOR, BTNS_BUTTON | BTNS_AUTOSIZE, NULL, TBSTATE_ENABLED, 8);\r\n\r\n\t\t_r_toolbar_addseparator (config.hrebar, IDC_TOOLBAR);\r\n\r\n\t\t_r_toolbar_addbutton (config.hrebar, IDC_TOOLBAR, IDM_TRAY_ENABLENOTIFICATIONS_CHK, BTNS_BUTTON | BTNS_AUTOSIZE, NULL, TBSTATE_ENABLED, 4);\r\n\t\t_r_toolbar_addbutton (config.hrebar, IDC_TOOLBAR, IDM_TRAY_ENABLELOG_CHK, BTNS_BUTTON | BTNS_AUTOSIZE, NULL, TBSTATE_ENABLED, 5);\r\n\t\t_r_toolbar_addbutton (config.hrebar, IDC_TOOLBAR, IDM_TRAY_ENABLEUILOG_CHK, BTNS_BUTTON | BTNS_AUTOSIZE, NULL, TBSTATE_ENABLED, 10);\r\n\r\n\t\t_r_toolbar_addseparator (config.hrebar, IDC_TOOLBAR);\r\n\r\n\t\t_r_toolbar_addbutton (config.hrebar, IDC_TOOLBAR, IDM_REFRESH, BTNS_BUTTON | BTNS_AUTOSIZE, NULL, TBSTATE_ENABLED, 2);\r\n\t\t_r_toolbar_addbutton (config.hrebar, IDC_TOOLBAR, IDM_SETTINGS, BTNS_BUTTON | BTNS_AUTOSIZE, NULL, TBSTATE_ENABLED, 3);\r\n\r\n\t\t_r_toolbar_addseparator (config.hrebar, IDC_TOOLBAR);\r\n\r\n\t\t_r_toolbar_addbutton (config.hrebar, IDC_TOOLBAR, IDM_TRAY_LOGSHOW, BTNS_BUTTON | BTNS_AUTOSIZE, NULL, TBSTATE_ENABLED, 6);\r\n\t\t_r_toolbar_addbutton (config.hrebar, IDC_TOOLBAR, IDM_TRAY_LOGCLEAR, BTNS_BUTTON | BTNS_AUTOSIZE, NULL, TBSTATE_ENABLED, 7);\r\n\r\n\t\t_r_toolbar_addseparator (config.hrebar, IDC_TOOLBAR);\r\n\r\n\t\t_r_toolbar_addbutton (config.hrebar, IDC_TOOLBAR, IDM_DONATE, BTNS_BUTTON | BTNS_AUTOSIZE, NULL, TBSTATE_ENABLED, 9);\r\n\r\n\t\t_r_toolbar_resize (config.hrebar, IDC_TOOLBAR);\r\n\r\n\t\t// insert toolbar\r\n\t\tbutton_size = _r_toolbar_getbuttonsize (config.hrebar, IDC_TOOLBAR);\r\n\r\n\t\t_r_rebar_insertband (hwnd, IDC_REBAR, REBAR_TOOLBAR_ID, config.htoolbar, RBBS_VARIABLEHEIGHT | RBBS_NOGRIPPER | RBBS_USECHEVRON, LOWORD (button_size), HIWORD (button_size));\r\n\t}\r\n\r\n\t// insert searchbar\r\n\tconfig.hsearchbar = CreateWindowExW (\r\n\t\tWS_EX_CLIENTEDGE,\r\n\t\tWC_EDITW,\r\n\t\tNULL,\r\n\t\tWS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | ES_LEFT | ES_AUTOHSCROLL,\r\n\t\tCW_USEDEFAULT,\r\n\t\tCW_USEDEFAULT,\r\n\t\tCW_USEDEFAULT,\r\n\t\tCW_USEDEFAULT,\r\n\t\tconfig.hrebar,\r\n\t\t(HMENU)IDC_SEARCH,\r\n\t\t_r_sys_getimagebase (),\r\n\t\tNULL\r\n\t);\r\n\r\n\tif (!config.hsearchbar)\r\n\t\treturn;\r\n\r\n\t_r_ctrl_setfont (config.hsearchbar, 0, config.wnd_font); // fix font\r\n\r\n\t_app_search_create (config.hsearchbar);\r\n\r\n\t_app_search_setvisible (hwnd, config.hsearchbar, dpi_value);\r\n}\r\n\r\nVOID _app_toolbar_resize (\r\n\t_In_ HWND hwnd,\r\n\t_In_ LONG dpi_value\r\n)\r\n{\r\n\tREBARBANDINFOW rbi;\r\n\tSIZE ideal_size = {0};\r\n\tULONG button_size;\r\n\tUINT rebar_count;\r\n\r\n\t_app_toolbar_setfont ();\r\n\r\n\t_r_toolbar_resize (config.htoolbar, 0);\r\n\r\n\trebar_count = _r_rebar_getcount (config.hrebar, 0);\r\n\r\n\tfor (UINT i = 0; i < rebar_count; i++)\r\n\t{\r\n\t\tRtlZeroMemory (&rbi, sizeof (REBARBANDINFOW));\r\n\r\n\t\trbi.cbSize = sizeof (REBARBANDINFOW);\r\n\t\trbi.fMask = RBBIM_ID | RBBIM_CHILD | RBBIM_IDEALSIZE | RBBIM_CHILDSIZE;\r\n\r\n\t\tif (!_r_rebar_getinfo (config.hrebar, 0, i, &rbi))\r\n\t\t\tcontinue;\r\n\r\n\t\tif (rbi.wID == REBAR_TOOLBAR_ID)\r\n\t\t{\r\n\t\t\tif (!_r_toolbar_getidealsize (config.htoolbar, 0, FALSE, &ideal_size))\r\n\t\t\t\tcontinue;\r\n\r\n\t\t\tbutton_size = _r_toolbar_getbuttonsize (config.hrebar, IDC_TOOLBAR);\r\n\r\n\t\t\trbi.cxIdeal = (UINT)ideal_size.cx;\r\n\t\t\trbi.cxMinChild = LOWORD (button_size);\r\n\t\t\trbi.cyMinChild = HIWORD (button_size);\r\n\t\t}\r\n\t\telse if (rbi.wID == REBAR_SEARCH_ID)\r\n\t\t{\r\n\t\t\tif (_r_wnd_isvisible (rbi.hwndChild, FALSE))\r\n\t\t\t{\r\n\t\t\t\trbi.cxIdeal = (UINT)_r_dc_getdpi (180, dpi_value);\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\trbi.cxIdeal = 0;\r\n\t\t\t}\r\n\r\n\t\t\trbi.cxMinChild = rbi.cxIdeal;\r\n\t\t\trbi.cyMinChild = 20;\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tcontinue;\r\n\t\t}\r\n\r\n\t\t_r_rebar_setinfo (config.hrebar, 0, i, &rbi);\r\n\t}\r\n}\r\n\r\nVOID _app_toolbar_setfont ()\r\n{\r\n\tif (config.htoolbar)\r\n\t\t_r_ctrl_setfont (config.htoolbar, 0, config.wnd_font); // fix font\r\n\r\n\tif (config.hsearchbar)\r\n\t\t_r_ctrl_setfont (config.hsearchbar, 0, config.wnd_font); // fix font\r\n}\r\n\r\nVOID _app_window_resize (\r\n\t_In_ HWND hwnd,\r\n\t_In_ LPCRECT rect,\r\n\t_In_ LONG dpi_value\r\n)\r\n{\r\n\tPITEM_TAB_CONTEXT new_context;\r\n\tPITEM_TAB_CONTEXT tab_context;\r\n\tHDWP hdefer;\r\n\tLONG statusbar_height;\r\n\tLONG rebar_height;\r\n\r\n\t_app_toolbar_resize (hwnd, dpi_value);\r\n\r\n\t_r_wnd_sendmessage (config.hrebar, 0, WM_SIZE, 0, 0);\r\n\t_r_wnd_sendmessage (hwnd, IDC_STATUSBAR, WM_SIZE, 0, 0);\r\n\r\n\ttab_context = _app_listview_getcontext (hwnd, INT_ERROR);\r\n\r\n\tif (!tab_context)\r\n\t\treturn;\r\n\r\n\trebar_height = _r_rebar_getheight (hwnd, IDC_REBAR);\r\n\tstatusbar_height = _r_status_getheight (hwnd, IDC_STATUSBAR);\r\n\r\n\thdefer = BeginDeferWindowPos (2);\r\n\r\n\tif (hdefer)\r\n\t{\r\n\t\thdefer = DeferWindowPos (\r\n\t\t\thdefer,\r\n\t\t\tconfig.hrebar,\r\n\t\t\tNULL,\r\n\t\t\t0,\r\n\t\t\t0,\r\n\t\t\trect->right,\r\n\t\t\trebar_height,\r\n\t\t\tSWP_NOZORDER | SWP_NOACTIVATE | SWP_NOOWNERZORDER\r\n\t\t);\r\n\r\n\t\thdefer = DeferWindowPos (\r\n\t\t\thdefer,\r\n\t\t\tGetDlgItem (hwnd, IDC_TAB),\r\n\t\t\tNULL,\r\n\t\t\t0,\r\n\t\t\trebar_height,\r\n\t\t\trect->right,\r\n\t\t\trect->bottom - rebar_height - statusbar_height,\r\n\t\t\tSWP_NOZORDER | SWP_NOACTIVATE | SWP_NOOWNERZORDER\r\n\t\t);\r\n\r\n\t\tEndDeferWindowPos (hdefer);\r\n\t}\r\n\r\n\tfor (INT i = 0; i < _r_tab_getitemcount (hwnd, IDC_TAB); i++)\r\n\t{\r\n\t\tnew_context = _app_listview_getcontext (hwnd, i);\r\n\r\n\t\tif (!new_context)\r\n\t\t\tcontinue;\r\n\r\n\t\t_r_tab_adjustchild (hwnd, IDC_TAB, GetDlgItem (hwnd, new_context->listview_id));\r\n\r\n\t\tif (new_context->listview_id == tab_context->listview_id)\r\n\t\t\t_app_listview_resize (hwnd, new_context->listview_id, FALSE);\r\n\t}\r\n\r\n\t_app_refreshstatus (hwnd);\r\n}\r\n\r\nVOID _app_refreshstatus (\r\n\t_In_ HWND hwnd\r\n)\r\n{\r\n\tITEM_STATUS status = {0};\r\n\tPR_STRING string[STATUSBAR_PARTS_COUNT] = {0};\r\n\tLONG parts[STATUSBAR_PARTS_COUNT] = {0};\r\n\tLONG size[STATUSBAR_PARTS_COUNT] = {0};\r\n\tLONG calculated_width = 0;\r\n\tLONG spacing;\r\n\tHWND hstatus;\r\n\tHDC hdc;\r\n\tLONG dpi_value;\r\n\r\n\thstatus = GetDlgItem (hwnd, IDC_STATUSBAR);\r\n\r\n\tif (!hstatus)\r\n\t\treturn;\r\n\r\n\thdc = GetDC (hstatus);\r\n\r\n\tif (!hdc)\r\n\t\treturn;\r\n\r\n\t_r_dc_fixfont (hdc, hwnd, IDC_STATUSBAR); // fix\r\n\r\n\t_app_getcount (&status);\r\n\r\n\tdpi_value = _r_dc_getwindowdpi (hwnd);\r\n\r\n\tspacing = _r_dc_getdpi (16, dpi_value);\r\n\r\n\tfor (ULONG_PTR i = 0; i < RTL_NUMBER_OF (parts); i++)\r\n\t{\r\n\t\tswitch (i)\r\n\t\t{\r\n\t\t\tcase 1:\r\n\t\t\t{\r\n\t\t\t\tstring[i] = _r_format_string (L\"%s: %\" TEXT (PR_ULONG_PTR), _r_locale_getstring (IDS_STATUS_UNUSED_APPS), status.apps_unused_count);\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\r\n\t\t\tcase 2:\r\n\t\t\t{\r\n\t\t\t\tstring[i] = _r_format_string (L\"%s: %\" TEXT (PR_ULONG_PTR), _r_locale_getstring (IDS_STATUS_TIMER_APPS), status.apps_timer_count);\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (i)\r\n\t\t{\r\n\t\t\tif (string[i])\r\n\t\t\t{\r\n\t\t\t\tsize[i] = _r_dc_getfontwidth (hdc, &string[i]->sr, NULL) + spacing;\r\n\r\n\t\t\t\tcalculated_width += size[i];\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tparts[0] = _r_ctrl_getwidth (hwnd, IDC_STATUSBAR) - calculated_width - _r_dc_getsystemmetrics (SM_CXVSCROLL, dpi_value) - (_r_dc_getsystemmetrics (SM_CXBORDER, dpi_value) * 4);\r\n\r\n\tparts[1] = parts[0] + size[1];\r\n\tparts[2] = parts[1] + size[2];\r\n\r\n\t_r_status_setparts (hwnd, IDC_STATUSBAR, parts, RTL_NUMBER_OF (parts));\r\n\r\n\tfor (ULONG_PTR i = 1; i < STATUSBAR_PARTS_COUNT; i++)\r\n\t{\r\n\t\tif (string[i])\r\n\t\t{\r\n\t\t\t_r_status_settext (hwnd, IDC_STATUSBAR, (LONG)i, string[i]->buffer);\r\n\r\n\t\t\t_r_obj_dereference (string[i]);\r\n\t\t}\r\n\t}\r\n\r\n\tReleaseDC (hstatus, hdc);\r\n}\r\n"
  },
  {
    "path": "src/controls.h",
    "content": "// simplewall\r\n// Copyright (c) 2016-2026 Henry++\r\n\r\n#pragma once\r\n\r\nEXTERN_C const IID IID_IImageList2;\r\n\r\n_Ret_maybenull_\r\nPR_STRING _app_gettooltipbylparam (\r\n\t_In_ HWND hwnd,\r\n\t_In_ INT listview_id,\r\n\t_In_ LONG_PTR lparam\r\n);\r\n\r\nVOID _app_settab_id (\r\n\t_In_ HWND hwnd,\r\n\t_In_ INT page_id\r\n);\r\n\r\nLPWSTR _app_getstateaction (\r\n\t_In_ ENUM_INSTALL_TYPE install_type\r\n);\r\n\r\nHBITMAP _app_getstatebitmap (\r\n\t_In_ ENUM_INSTALL_TYPE install_type\r\n);\r\n\r\nINT _app_getstateicon (\r\n\t_In_ ENUM_INSTALL_TYPE install_type\r\n);\r\n\r\nLPCWSTR _app_getstatelocale (\r\n\t_In_ ENUM_INSTALL_TYPE install_type\r\n);\r\n\r\nBOOLEAN _app_initinterfacestate (\r\n\t_In_ HWND hwnd,\r\n\t_In_ BOOLEAN is_forced\r\n);\r\n\r\nVOID _app_restoreinterfacestate (\r\n\t_In_ HWND hwnd,\r\n\t_In_ BOOLEAN is_enabled\r\n);\r\n\r\nVOID _app_setinterfacestate (\r\n\t_In_ HWND hwnd,\r\n\t_In_ LONG dpi_value\r\n);\r\n\r\nVOID _app_settrayicon (\r\n\t_In_ HWND hwnd,\r\n\t_In_ ENUM_INSTALL_TYPE install_type\r\n);\r\n\r\nVOID _app_imagelist_init (\r\n\t_In_opt_ HWND hwnd,\r\n\t_In_ LONG dpi_value\r\n);\r\n\r\nHFONT _app_createfont (\r\n\t_Inout_ PLOGFONT logfont,\r\n\t_In_ LONG size,\r\n\t_In_ BOOLEAN is_underline,\r\n\t_In_ LONG dpi_value\r\n);\r\n\r\nVOID _app_windowloadfont (\r\n\t_In_ LONG dpi_value\r\n);\r\n\r\nVOID _app_toolbar_init (\r\n\t_In_ HWND hwnd,\r\n\t_In_ LONG dpi_value\r\n);\r\n\r\nVOID _app_toolbar_resize (\r\n\t_In_ HWND hwnd,\r\n\t_In_ LONG dpi_value\r\n);\r\n\r\nVOID _app_toolbar_setfont ();\r\n\r\nVOID _app_window_resize (\r\n\t_In_ HWND hwnd,\r\n\t_In_ LPCRECT rect,\r\n\t_In_ LONG dpi_value\r\n);\r\n\r\nVOID _app_refreshstatus (\r\n\t_In_ HWND hwnd\r\n);\r\n"
  },
  {
    "path": "src/db.c",
    "content": "// simplewall\n// Copyright (c) 2019-2025 Henry++\n\n#include \"global.h\"\n\n_Success_ (SUCCEEDED (return))\nHRESULT _app_db_initialize (\n\t_Out_ PDB_INFORMATION db_info,\n\t_In_ BOOLEAN is_reader\n)\n{\n\tRtlZeroMemory (db_info, sizeof (DB_INFORMATION));\n\n\treturn _r_xml_initializelibrary (&db_info->xml_library, is_reader);\n}\n\nVOID _app_db_destroy (\n\t_Inout_ PDB_INFORMATION db_info\n)\n{\n\tif (db_info->bytes)\n\t\t_r_obj_clearreference ((PVOID_PTR)&db_info->bytes);\n\n\t_r_xml_destroylibrary (&db_info->xml_library);\n}\n\n_Success_ (NT_SUCCESS (return))\nNTSTATUS _app_db_encrypt (\n\t_In_ PR_BYTEREF bytes,\n\t_Out_ PR_BYTE_PTR out_buffer\n)\n{\n\tR_CRYPT_CONTEXT crypt_context;\n\tR_BYTEREF key;\n\tNTSTATUS status;\n\n\t*out_buffer = NULL;\n\n\tstatus = _r_crypt_createcryptcontext (&crypt_context, BCRYPT_AES_ALGORITHM);\n\n\tif (!NT_SUCCESS (status))\n\t\treturn status;\n\n\t_r_obj_initializebyteref (&key, PROFILE2_KEY);\n\n\tstatus = _r_crypt_generatekey (&crypt_context, &key);\n\n\tif (!NT_SUCCESS (status))\n\t\tgoto CleanupExit;\n\n\tstatus = _r_crypt_encryptbuffer (&crypt_context, bytes->buffer, (ULONG)bytes->length, out_buffer);\n\nCleanupExit:\n\n\t_r_crypt_destroycryptcontext (&crypt_context);\n\n\treturn status;\n}\n\n_Success_ (NT_SUCCESS (return))\nNTSTATUS _app_db_decrypt (\n\t_In_ PR_BYTEREF bytes,\n\t_Out_ PR_BYTE_PTR out_buffer\n)\n{\n\tR_CRYPT_CONTEXT crypt_context;\n\tR_BYTEREF key;\n\tNTSTATUS status;\n\n\t*out_buffer = NULL;\n\n\tstatus = _r_crypt_createcryptcontext (&crypt_context, BCRYPT_AES_ALGORITHM);\n\n\tif (!NT_SUCCESS (status))\n\t\treturn status;\n\n\t_r_obj_initializebyteref (&key, PROFILE2_KEY);\n\n\tstatus = _r_crypt_generatekey (&crypt_context, &key);\n\n\tif (!NT_SUCCESS (status))\n\t\tgoto CleanupExit;\n\n\tstatus = _r_crypt_decryptbuffer (&crypt_context, bytes->buffer, (ULONG)bytes->length, out_buffer);\n\nCleanupExit:\n\n\t_r_crypt_destroycryptcontext (&crypt_context);\n\n\treturn status;\n}\n\n_Success_ (NT_SUCCESS (return))\nNTSTATUS _app_db_gethash (\n\t_In_ PR_BYTEREF bytes,\n\t_Out_ PR_BYTE_PTR out_buffer\n)\n{\n\tR_CRYPT_CONTEXT hash_context;\n\tNTSTATUS status;\n\n\t*out_buffer = NULL;\n\n\tstatus = _r_crypt_createhashcontext (&hash_context, BCRYPT_SHA256_ALGORITHM);\n\n\tif (!NT_SUCCESS (status))\n\t\treturn status;\n\n\tstatus = _r_crypt_hashbuffer (&hash_context, bytes->buffer, (ULONG)bytes->length);\n\n\tif (NT_SUCCESS (status))\n\t\tstatus = _r_crypt_finalhashcontext (&hash_context, NULL, out_buffer);\n\n\t_r_crypt_destroycryptcontext (&hash_context);\n\n\treturn status;\n}\n\nBYTE _app_getprofiletype ()\n{\n\tLONG profile_type;\n\n\tprofile_type = _r_config_getlong (L\"ProfileType\", 0, NULL);\n\n\tswitch (profile_type)\n\t{\n\t\tcase 1:\n\t\t{\n\t\t\treturn PROFILE2_ID_COMPRESSED;\n\t\t}\n\n\t\tcase 2:\n\t\t{\n\t\t\treturn PROFILE2_ID_ENCRYPTED;\n\t\t}\n\t}\n\n\treturn PROFILE2_ID_PLAIN;\n}\n\n_Success_ (NT_SUCCESS (return))\nNTSTATUS _app_db_ishashvalid (\n\t_In_ PR_BYTEREF buffer,\n\t_In_ PR_BYTEREF hash_bytes\n)\n{\n\tPR_BYTE new_hash_bytes = NULL;\n\tNTSTATUS status;\n\n\tstatus = _app_db_gethash (buffer, &new_hash_bytes);\n\n\tif (!NT_SUCCESS (status))\n\t\treturn status;\n\n\tif (RtlEqualMemory (hash_bytes->buffer, new_hash_bytes->buffer, new_hash_bytes->length))\n\t{\n\t\tstatus = STATUS_SUCCESS;\n\t}\n\telse\n\t{\n\t\tstatus = STATUS_INVALID_IMAGE_HASH;\n\t}\n\n\t_r_obj_dereference (new_hash_bytes);\n\n\treturn status;\n}\n\n_Success_ (NT_SUCCESS (return))\nNTSTATUS _app_db_openfrombuffer (\n\t_Inout_ PDB_INFORMATION db_info,\n\t_In_ PR_STORAGE buffer,\n\t_In_ ENUM_VERSION_XML min_version,\n\t_In_ ENUM_TYPE_XML type\n)\n{\n\tNTSTATUS status;\n\n\t_r_obj_movereference ((PVOID_PTR)&db_info->bytes, _r_obj_createbyte4 (buffer));\n\n\tstatus = _app_db_decodebuffer (db_info, type, min_version);\n\n\treturn status;\n}\n\n_Success_ (NT_SUCCESS (return))\nNTSTATUS _app_db_openfromfile (\n\t_Inout_ PDB_INFORMATION db_info,\n\t_In_ PR_STRING path,\n\t_In_ ENUM_VERSION_XML min_version,\n\t_In_ ENUM_TYPE_XML type\n)\n{\n\tHANDLE hfile;\n\tNTSTATUS status;\n\n\tif (db_info->bytes)\n\t\t_r_obj_clearreference ((PVOID_PTR)&db_info->bytes);\n\n\tstatus = _r_fs_openfile (&path->sr, GENERIC_READ, FILE_SHARE_READ, 0, FALSE, &hfile);\n\n\tif (!NT_SUCCESS (status))\n\t\treturn status;\n\n\tstatus = _r_fs_readbytes (hfile, &db_info->bytes);\n\n\tif (!NT_SUCCESS (status))\n\t{\n\t\tNtClose (hfile);\n\n\t\treturn status;\n\t}\n\n\tstatus = _app_db_decodebuffer (db_info, type, min_version);\n\n\tNtClose (hfile);\n\n\treturn status;\n}\n\nVOID _app_db_parse_app (\n\t_Inout_ PDB_INFORMATION db_info\n)\n{\n\tPITEM_APP ptr_app;\n\tPR_STRING string;\n\tPR_STRING path;\n\tPR_STRING dos_path;\n\tLONG64 timestamp;\n\tLONG64 timer;\n\tULONG app_hash;\n\tBOOLEAN is_undeletable;\n\tBOOLEAN is_enabled;\n\tBOOLEAN is_silent;\n\n\tpath = _r_xml_getattribute_string (&db_info->xml_library, L\"path\");\n\n\tif (_r_obj_isstringempty (path))\n\t\treturn;\n\n\t// workaround for native paths\n\t// https://github.com/henrypp/simplewall/issues/817\n\tif (_r_str_isstartswith2 (&path->sr, L\"\\\\device\\\\\", TRUE))\n\t{\n\t\tdos_path = _r_path_dospathfromnt (&path->sr);\n\n\t\tif (dos_path)\n\t\t\t_r_obj_movereference ((PVOID_PTR)&path, dos_path);\n\t}\n\n\tif (!_r_obj_isstringempty2 (path))\n\t{\n\t\tapp_hash = _app_addapplication (NULL, DATA_UNKNOWN, path, NULL, NULL);\n\n\t\tif (app_hash)\n\t\t{\n\t\t\tptr_app = _app_getappitem (app_hash);\n\n\t\t\tif (ptr_app)\n\t\t\t{\n\t\t\t\tis_enabled = _r_xml_getattribute_boolean (&db_info->xml_library, L\"is_enabled\");\n\t\t\t\tis_silent = _r_xml_getattribute_boolean (&db_info->xml_library, L\"is_silent\");\n\t\t\t\tis_undeletable = _r_xml_getattribute_boolean (&db_info->xml_library, L\"is_undeletable\");\n\n\t\t\t\ttimestamp = _r_xml_getattribute_long64 (&db_info->xml_library, L\"timestamp\");\n\t\t\t\ttimer = _r_xml_getattribute_long64 (&db_info->xml_library, L\"timer\");\n\n\t\t\t\tstring = _r_xml_getattribute_string (&db_info->xml_library, L\"hash\");\n\n\t\t\t\tif (string)\n\t\t\t\t{\n\t\t\t\t\tif (!_r_obj_isstringempty2 (string))\n\t\t\t\t\t{\n\t\t\t\t\t\t_app_setappinfo (ptr_app, INFO_HASH, string);\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\t_r_obj_dereference (string);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tstring = _r_xml_getattribute_string (&db_info->xml_library, L\"comment\");\n\n\t\t\t\tif (string)\n\t\t\t\t{\n\t\t\t\t\tif (!_r_obj_isstringempty2 (string))\n\t\t\t\t\t{\n\t\t\t\t\t\t_app_setappinfo (ptr_app, INFO_COMMENT, string);\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\t_r_obj_dereference (string);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (is_silent)\n\t\t\t\t\t_app_setappinfo (ptr_app, INFO_IS_SILENT, LongToPtr (is_silent));\n\n\t\t\t\tif (is_enabled)\n\t\t\t\t\t_app_setappinfo (ptr_app, INFO_IS_ENABLED, LongToPtr (is_enabled));\n\n\t\t\t\tif (is_undeletable)\n\t\t\t\t\t_app_setappinfo (ptr_app, INFO_IS_UNDELETABLE, LongToPtr (is_undeletable));\n\n\t\t\t\tif (timestamp)\n\t\t\t\t\t_app_setappinfo (ptr_app, INFO_TIMESTAMP, &timestamp);\n\n\t\t\t\tif (timer)\n\t\t\t\t\t_app_setappinfo (ptr_app, INFO_TIMER, &timer);\n\n\t\t\t\t_r_obj_dereference (ptr_app);\n\t\t\t}\n\t\t}\n\t}\n\n\t_r_obj_dereference (path);\n}\n\nVOID _app_db_parse_rule (\n\t_Inout_ PDB_INFORMATION db_info,\n\t_In_ ENUM_TYPE_DATA type\n)\n{\n\tPITEM_RULE_CONFIG ptr_config = NULL;\n\tR_STRINGBUILDER sb;\n\tR_STRINGREF first_part;\n\tR_STRINGREF sr;\n\tPR_STRING rule_name;\n\tPR_STRING rule_remote;\n\tPR_STRING rule_local;\n\tPR_STRING path_string;\n\tPR_STRING comment;\n\tPR_STRING string;\n\tLONG blocklist_spy_state;\n\tLONG blocklist_update_state;\n\tLONG blocklist_extra_state;\n\tFWP_DIRECTION direction;\n\tFWP_ACTION_TYPE action;\n\tUINT8 protocol;\n\tADDRESS_FAMILY af;\n\tPITEM_RULE ptr_rule;\n\tULONG rule_hash;\n\tULONG app_hash;\n\tBOOLEAN is_internal;\n\tNTSTATUS status;\n\n\t// check support version\n\tstatus = _r_xml_getattribute (&db_info->xml_library, L\"os_version\", &sr);\n\n\tif (SUCCEEDED (status))\n\t{\n\t\tif (!_app_isrulesupportedbyos (&sr))\n\t\t\treturn;\n\t}\n\n\trule_name = _r_xml_getattribute_string (&db_info->xml_library, L\"name\");\n\n\tif (!rule_name)\n\t\treturn;\n\n\trule_remote = _r_xml_getattribute_string (&db_info->xml_library, L\"rule\");\n\trule_local = _r_xml_getattribute_string (&db_info->xml_library, L\"rule_local\");\n\tcomment = _r_xml_getattribute_string (&db_info->xml_library, L\"comment\");\n\tdirection = (FWP_DIRECTION)_r_xml_getattribute_long (&db_info->xml_library, L\"dir\");\n\taction = _r_xml_getattribute_boolean (&db_info->xml_library, L\"is_block\") ? FWP_ACTION_BLOCK : FWP_ACTION_PERMIT;\n\tprotocol = (UINT8)_r_xml_getattribute_long (&db_info->xml_library, L\"protocol\");\n\taf = (ADDRESS_FAMILY)_r_xml_getattribute_long (&db_info->xml_library, L\"version\");\n\n\tptr_rule = _app_addrule (rule_name, rule_remote, rule_local, direction, action, protocol, af);\n\n\t_r_obj_dereference (rule_name);\n\n\tif (rule_remote)\n\t\t_r_obj_dereference (rule_remote);\n\n\tif (rule_local)\n\t\t_r_obj_dereference (rule_local);\n\n\trule_hash = _r_str_gethash (&ptr_rule->name->sr, TRUE);\n\n\tif (!_r_obj_isstringempty (comment))\n\t{\n\t\t_r_obj_movereference ((PVOID_PTR)&ptr_rule->comment, comment);\n\t}\n\telse\n\t{\n\t\tif (comment)\n\t\t\t_r_obj_dereference (comment);\n\t}\n\n\tptr_rule->type = (type == DATA_RULE_SYSTEM_USER) ? DATA_RULE_USER : type;\n\tptr_rule->is_forservices = _r_xml_getattribute_boolean (&db_info->xml_library, L\"is_services\");\n\tptr_rule->is_readonly = (type != DATA_RULE_USER);\n\tptr_rule->is_enabled = _r_xml_getattribute_boolean (&db_info->xml_library, L\"is_enabled\");\n\n\t// calculate rule weight\n\tif (type == DATA_RULE_BLOCKLIST)\n\t{\n\t\tptr_rule->weight = FW_WEIGHT_RULE_BLOCKLIST;\n\t}\n\telse if (type == DATA_RULE_SYSTEM || type == DATA_RULE_SYSTEM_USER)\n\t{\n\t\tptr_rule->weight = FW_WEIGHT_RULE_SYSTEM;\n\t}\n\telse if (type == DATA_RULE_USER)\n\t{\n\t\tptr_rule->weight = (ptr_rule->action == FWP_ACTION_BLOCK) ? FW_WEIGHT_RULE_USER_BLOCK : FW_WEIGHT_RULE_USER;\n\t}\n\n\tif (type == DATA_RULE_BLOCKLIST)\n\t{\n\t\tblocklist_spy_state = _r_calc_clamp (_r_config_getlong (L\"BlocklistSpyState\", 2, NULL), 0, 2);\n\t\tblocklist_update_state = _r_calc_clamp (_r_config_getlong (L\"BlocklistUpdateState\", 0, NULL), 0, 2);\n\t\tblocklist_extra_state = _r_calc_clamp (_r_config_getlong (L\"BlocklistExtraState\", 0, NULL), 0, 2);\n\n\t\t_app_ruleblocklistsetstate (ptr_rule, blocklist_spy_state, blocklist_update_state, blocklist_extra_state);\n\t}\n\telse\n\t{\n\t\tptr_rule->is_enabled_default = ptr_rule->is_enabled; // set default value for rule\n\t}\n\n\t// load rules config\n\tis_internal = (type == DATA_RULE_BLOCKLIST || type == DATA_RULE_SYSTEM || type == DATA_RULE_SYSTEM_USER);\n\n\tif (is_internal)\n\t{\n\t\t// internal rules\n\t\tptr_config = _app_getruleconfigitem (rule_hash);\n\n\t\tif (ptr_config)\n\t\t\tptr_rule->is_enabled = ptr_config->is_enabled;\n\t}\n\n\t// load apps\n\t_r_obj_initializestringbuilder (&sb, 256);\n\n\tstring = _r_xml_getattribute_string (&db_info->xml_library, L\"apps\");\n\n\tif (!_r_obj_isstringempty (string))\n\t{\n\t\t_r_obj_appendstringbuilder2 (&sb, &string->sr);\n\n\t\t_r_obj_dereference (string);\n\t}\n\n\tif (is_internal && ptr_config && !_r_obj_isstringempty (ptr_config->apps))\n\t{\n\t\tif (!_r_obj_isstringempty2 (sb.string))\n\t\t\t_r_obj_appendstringbuilder (&sb, DIVIDER_APP);\n\n\t\t_r_obj_appendstringbuilder2 (&sb, &ptr_config->apps->sr);\n\t}\n\n\tstring = _r_obj_finalstringbuilder (&sb);\n\n\tif (!_r_obj_isstringempty2 (string))\n\t{\n\t\tif (db_info->version < XML_VERSION_3)\n\t\t\t_r_str_replacechar (&string->sr, DIVIDER_RULE[0], DIVIDER_APP[0]);\n\n\t\t_r_obj_initializestringref2 (&sr, &string->sr);\n\n\t\twhile (sr.length != 0)\n\t\t{\n\t\t\t_r_str_splitatchar (&sr, DIVIDER_APP[0], &first_part, &sr);\n\n\t\t\tstatus = _r_str_environmentexpandstring (NULL, &first_part, &path_string);\n\n\t\t\tif (status != STATUS_SUCCESS)\n\t\t\t\tpath_string = _r_obj_createstring2 (&first_part);\n\n\t\t\tapp_hash = _r_str_gethash (&path_string->sr, TRUE);\n\n\t\t\tif (app_hash)\n\t\t\t{\n\t\t\t\tif (ptr_rule->is_forservices && _app_issystemhash (app_hash))\n\t\t\t\t{\n\t\t\t\t\t_r_obj_dereference (path_string);\n\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tif (!_app_isappfound (app_hash))\n\t\t\t\t\tapp_hash = _app_addapplication (NULL, DATA_UNKNOWN, path_string, NULL, NULL);\n\n\t\t\t\tif (app_hash)\n\t\t\t\t{\n\t\t\t\t\t_r_obj_addhashtableitem (ptr_rule->apps, app_hash, NULL);\n\n\t\t\t\t\tif (ptr_rule->type == DATA_RULE_SYSTEM)\n\t\t\t\t\t\t_app_setappinfobyhash (app_hash, INFO_IS_UNDELETABLE, LongToPtr (TRUE));\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t_r_obj_dereference (path_string);\n\t\t}\n\n\t\t// check if no app is added into rule, then disable it!\n\t\tif (ptr_rule->is_enabled)\n\t\t{\n\t\t\tif (_r_obj_isempty (ptr_rule->apps))\n\t\t\t\tptr_rule->is_enabled = FALSE;\n\t\t}\n\t}\n\n\t_r_queuedlock_acquireexclusive (&lock_rules);\n\t_r_obj_addlistitem (rules_list, ptr_rule, NULL);\n\t_r_queuedlock_releaseexclusive (&lock_rules);\n\n\t_r_obj_deletestringbuilder (&sb);\n}\n\nVOID _app_db_parse_ruleconfig (\n\t_Inout_ PDB_INFORMATION db_info\n)\n{\n\tPITEM_RULE_CONFIG ptr_config;\n\tPR_STRING rule_name;\n\tULONG rule_hash;\n\n\trule_name = _r_xml_getattribute_string (&db_info->xml_library, L\"name\");\n\n\tif (!rule_name)\n\t\treturn;\n\n\trule_hash = _r_str_gethash (&rule_name->sr, TRUE);\n\n\tif (!rule_hash)\n\t{\n\t\t_r_obj_dereference (rule_name);\n\n\t\treturn;\n\t}\n\n\tptr_config = _app_getruleconfigitem (rule_hash);\n\n\tif (!ptr_config)\n\t{\n\t\t_r_queuedlock_acquireexclusive (&lock_rules_config);\n\t\tptr_config = _app_addruleconfigtable (rules_config, rule_hash, rule_name, _r_xml_getattribute_boolean (&db_info->xml_library, L\"is_enabled\"));\n\t\t_r_queuedlock_releaseexclusive (&lock_rules_config);\n\n\t\tif (ptr_config)\n\t\t{\n\t\t\tptr_config->apps = _r_xml_getattribute_string (&db_info->xml_library, L\"apps\");\n\n\t\t\tif (ptr_config->apps && db_info->version < XML_VERSION_3)\n\t\t\t\t_r_str_replacechar (&ptr_config->apps->sr, DIVIDER_RULE[0], DIVIDER_APP[0]);\n\t\t}\n\t}\n\n\t_r_obj_dereference (rule_name);\n}\n\n_Success_ (NT_SUCCESS (return))\nNTSTATUS _app_db_decodebody (\n\t_Inout_ PDB_INFORMATION db_info\n)\n{\n\tUSHORT format[] = {COMPRESSION_FORMAT_LZNT1, COMPRESSION_FORMAT_XPRESS};\n\tUSHORT architecture;\n\tPR_BYTE new_bytes;\n\tBYTE profile_type;\n\tNTSTATUS status;\n\n\tif (db_info->bytes->length < PROFILE2_HEADER_LENGTH)\n\t\treturn STATUS_SUCCESS;\n\n\tif (!RtlEqualMemory (db_info->bytes->buffer, profile2_fourcc, sizeof (profile2_fourcc)) || !RtlEqualMemory (db_info->bytes->buffer, profile2_fourcc, sizeof (profile2_fourcc_old)))\n\t\treturn STATUS_SUCCESS;\n\n\tprofile_type = db_info->bytes->buffer[sizeof (profile2_fourcc)];\n\n\t// skip fourcc\n\t_r_obj_skipbytelength (&db_info->bytes->sr, PROFILE2_FOURCC_LENGTH);\n\n\t// read the hash\n\t_r_obj_movereference ((PVOID_PTR)&db_info->hash, _r_obj_createbyte_ex (db_info->bytes->buffer, PROFILE2_SHA256_LENGTH));\n\n\t// skip hash\n\t_r_obj_skipbytelength (&db_info->bytes->sr, PROFILE2_SHA256_LENGTH);\n\n\tswitch (profile_type)\n\t{\n\t\tcase PROFILE2_ID_COMPRESSED:\n\t\t{\n\t\t\t// decompress bytes\n\t\t\tfor (ULONG_PTR i = 0; i < RTL_NUMBER_OF (format); i++)\n\t\t\t{\n\t\t\t\tstatus = _r_sys_decompressbuffer (format[i], &db_info->bytes->sr, &new_bytes);\n\n\t\t\t\tif (NT_SUCCESS (status))\n\t\t\t\t{\n\t\t\t\t\t_r_obj_movereference ((PVOID_PTR)&db_info->bytes, new_bytes);\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase PROFILE2_ID_ENCRYPTED:\n\t\t{\n\t\t\t// decrypt bytes\n\t\t\tstatus = _app_db_decrypt (&db_info->bytes->sr, &new_bytes);\n\n\t\t\tif (!NT_SUCCESS (status))\n\t\t\t\treturn status;\n\n\t\t\t_r_obj_movereference ((PVOID_PTR)&db_info->bytes, new_bytes);\n\n\t\t\tbreak;\n\t\t}\n\n\t\tdefault:\n\t\t{\n\t\t\treturn STATUS_FILE_NOT_SUPPORTED;\n\t\t}\n\t}\n\n\tif (!NT_SUCCESS (status))\n\t\treturn status;\n\n\tif (RtlEqualMemory (db_info->bytes->buffer, profile2_fourcc, sizeof (profile2_fourcc)) || RtlEqualMemory (db_info->bytes->buffer, profile2_fourcc_old, sizeof (profile2_fourcc_old)))\n\t\treturn STATUS_MORE_PROCESSING_REQUIRED;\n\n\t// fix arm64 crash that was introduced by Micro$oft (issue #1228)\n\tif (NT_SUCCESS (_r_sys_getprocessorinformation (&architecture, NULL, NULL)))\n\t{\n\t\tif (architecture == PROCESSOR_ARCHITECTURE_ARM || architecture == PROCESSOR_ARCHITECTURE_ARM64)\n\t\t\treturn STATUS_SUCCESS;\n\t}\n\n\t// validate hash\n\tif (db_info->hash)\n\t\tstatus = _app_db_ishashvalid (&db_info->bytes->sr, &db_info->hash->sr);\n\n\treturn status;\n}\n\n_Success_ (NT_SUCCESS (return))\nNTSTATUS _app_db_encodebody (\n\t_Inout_ PDB_INFORMATION db_info,\n\t_In_ BYTE profile_type,\n\t_Out_ PR_BYTE_PTR out_buffer\n)\n{\n\tPR_BYTE body_bytes;\n\tPR_BYTE hash_value;\n\tPR_BYTE new_bytes;\n\tPR_BYTE bytes;\n\tNTSTATUS status;\n\n\t*out_buffer = NULL;\n\n\tstatus = _r_xml_readstream (&db_info->xml_library, &bytes);\n\n\tif (FAILED (status))\n\t\treturn status;\n\n\t// generate body hash\n\tstatus = _app_db_gethash (&bytes->sr, &hash_value);\n\n\tif (!NT_SUCCESS (status))\n\t{\n\t\t_r_obj_dereference (hash_value);\n\t\t_r_obj_dereference (bytes);\n\n\t\treturn status;\n\t}\n\n\tswitch (profile_type)\n\t{\n\t\tcase PROFILE2_ID_PLAIN:\n\t\t{\n\t\t\tnew_bytes = _r_obj_reference (bytes);\n\t\t\tbreak;\n\t\t}\n\n\t\tcase PROFILE2_ID_COMPRESSED:\n\t\t{\n\t\t\t// compress body\n\t\t\tstatus = _r_sys_compressbuffer (COMPRESSION_FORMAT_LZNT1 | COMPRESSION_ENGINE_MAXIMUM, &bytes->sr, &new_bytes);\n\n\t\t\tif (!NT_SUCCESS (status))\n\t\t\t{\n\t\t\t\t_r_obj_dereference (hash_value);\n\t\t\t\t_r_obj_dereference (bytes);\n\n\t\t\t\treturn status;\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase PROFILE2_ID_ENCRYPTED:\n\t\t{\n\t\t\tstatus = _app_db_encrypt (&bytes->sr, &new_bytes);\n\n\t\t\tif (!NT_SUCCESS (status))\n\t\t\t{\n\t\t\t\t_r_obj_dereference (hash_value);\n\t\t\t\t_r_obj_dereference (bytes);\n\n\t\t\t\treturn status;\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tdefault:\n\t\t{\n\t\t\treturn STATUS_FILE_NOT_SUPPORTED;\n\t\t}\n\t}\n\n\t_r_obj_movereference ((PVOID_PTR)&bytes, new_bytes);\n\n\tstatus = _app_db_generatebody (profile_type, hash_value, bytes, &body_bytes);\n\n\t*out_buffer = body_bytes;\n\n\t_r_obj_dereference (hash_value);\n\t_r_obj_dereference (bytes);\n\n\treturn status;\n}\n\n_Success_ (NT_SUCCESS (return))\nNTSTATUS _app_db_generatebody (\n\t_In_ BYTE profile_type,\n\t_In_ PR_BYTE hash_value,\n\t_In_ PR_BYTE buffer,\n\t_Out_ PR_BYTE_PTR out_buffer\n)\n{\n\tPR_BYTE bytes;\n\tPVOID ptr;\n\n\tswitch (profile_type)\n\t{\n\t\tcase PROFILE2_ID_PLAIN:\n\t\t{\n\t\t\tbytes = _r_obj_reference (buffer);\n\t\t\tbreak;\n\t\t}\n\n\t\tcase PROFILE2_ID_COMPRESSED:\n\t\tcase PROFILE2_ID_ENCRYPTED:\n\t\t{\n\t\t\tbytes = _r_obj_createbyte_ex (NULL, PROFILE2_HEADER_LENGTH + buffer->length);\n\n\t\t\tRtlCopyMemory (bytes->buffer, profile2_fourcc, sizeof (profile2_fourcc));\n\n\t\t\tptr = PTR_ADD_OFFSET (bytes->buffer, sizeof (profile2_fourcc));\n\t\t\tRtlCopyMemory (ptr, &profile_type, sizeof (BYTE));\n\n\t\t\tptr = PTR_ADD_OFFSET (bytes->buffer, PROFILE2_FOURCC_LENGTH);\n\t\t\tRtlCopyMemory (ptr, hash_value->buffer, hash_value->length);\n\n\t\t\tptr = PTR_ADD_OFFSET (bytes->buffer, PROFILE2_HEADER_LENGTH);\n\t\t\tRtlCopyMemory (ptr, buffer->buffer, buffer->length);\n\n\t\t\tbreak;\n\t\t}\n\n\t\tdefault:\n\t\t{\n\t\t\t*out_buffer = NULL;\n\n\t\t\treturn STATUS_FILE_NOT_SUPPORTED;\n\t\t}\n\t}\n\n\t*out_buffer = bytes;\n\n\treturn STATUS_SUCCESS;\n}\n\n_Success_ (NT_SUCCESS (return))\nNTSTATUS _app_db_decodebuffer (\n\t_Inout_ PDB_INFORMATION db_info,\n\t_In_ ENUM_TYPE_XML type,\n\t_In_ ENUM_VERSION_XML min_version\n)\n{\n\tULONG attempts = 6;\n\tNTSTATUS status;\n\n\tif (!db_info->bytes)\n\t\treturn STATUS_BUFFER_ALL_ZEROS;\n\n\tdo\n\t{\n\t\tstatus = _app_db_decodebody (db_info);\n\n\t\tif (status != STATUS_MORE_PROCESSING_REQUIRED)\n\t\t\tbreak;\n\t}\n\twhile (--attempts);\n\n\tif (!NT_SUCCESS (status))\n\t\treturn status;\n\n\tstatus = _r_xml_parsestring (&db_info->xml_library, db_info->bytes->buffer, (ULONG)db_info->bytes->length);\n\n\tif (FAILED (status))\n\t\treturn status;\n\n\tif (!_r_xml_findchildbytagname (&db_info->xml_library, L\"root\"))\n\t\treturn STATUS_DATA_ERROR;\n\n\tdb_info->timestamp = _r_xml_getattribute_long64 (&db_info->xml_library, L\"timestamp\");\n\tdb_info->type = _r_xml_getattribute_long (&db_info->xml_library, L\"type\");\n\tdb_info->version = _r_xml_getattribute_long (&db_info->xml_library, L\"version\");\n\n\tif (db_info->type != type)\n\t\treturn STATUS_NDIS_INVALID_DATA;\n\n\tif (db_info->version < min_version)\n\t\treturn STATUS_FILE_NOT_SUPPORTED;\n\n\treturn STATUS_SUCCESS;\n}\n\nBOOLEAN _app_db_parse (\n\t_Inout_ PDB_INFORMATION db_info,\n\t_In_ ENUM_TYPE_XML type\n)\n{\n\tif (!_r_xml_findchildbytagname (&db_info->xml_library, L\"root\"))\n\t\treturn FALSE;\n\n\tswitch (type)\n\t{\n\t\tcase XML_TYPE_PROFILE:\n\t\t{\n\t\t\t// load apps\n\t\t\tif (_r_xml_findchildbytagname (&db_info->xml_library, L\"apps\"))\n\t\t\t{\n\t\t\t\twhile (_r_xml_enumchilditemsbytagname (&db_info->xml_library, L\"item\"))\n\t\t\t\t{\n\t\t\t\t\t_app_db_parse_app (db_info);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// load rules config\n\t\t\tif (_r_xml_findchildbytagname (&db_info->xml_library, L\"rules_config\"))\n\t\t\t{\n\t\t\t\twhile (_r_xml_enumchilditemsbytagname (&db_info->xml_library, L\"item\"))\n\t\t\t\t{\n\t\t\t\t\t_app_db_parse_ruleconfig (db_info);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// load user rules\n\t\t\tif (_r_xml_findchildbytagname (&db_info->xml_library, L\"rules_custom\"))\n\t\t\t{\n\t\t\t\twhile (_r_xml_enumchilditemsbytagname (&db_info->xml_library, L\"item\"))\n\t\t\t\t{\n\t\t\t\t\t_app_db_parse_rule (db_info, DATA_RULE_USER);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase XML_TYPE_PROFILE_INTERNAL:\n\t\t{\n\t\t\t// load system rules\n\t\t\tif (_r_xml_findchildbytagname (&db_info->xml_library, L\"rules_system\"))\n\t\t\t{\n\t\t\t\twhile (_r_xml_enumchilditemsbytagname (&db_info->xml_library, L\"item\"))\n\t\t\t\t{\n\t\t\t\t\t_app_db_parse_rule (db_info, DATA_RULE_SYSTEM);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// load internal custom rules\n\t\t\tif (_r_xml_findchildbytagname (&db_info->xml_library, L\"rules_custom\"))\n\t\t\t{\n\t\t\t\twhile (_r_xml_enumchilditemsbytagname (&db_info->xml_library, L\"item\"))\n\t\t\t\t{\n\t\t\t\t\t_app_db_parse_rule (db_info, DATA_RULE_SYSTEM_USER);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// load blocklist rules\n\t\t\tif (_r_xml_findchildbytagname (&db_info->xml_library, L\"rules_blocklist\"))\n\t\t\t{\n\t\t\t\twhile (_r_xml_enumchilditemsbytagname (&db_info->xml_library, L\"item\"))\n\t\t\t\t{\n\t\t\t\t\t_app_db_parse_rule (db_info, DATA_RULE_BLOCKLIST);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn TRUE;\n}\n\n_Success_ (NT_SUCCESS (return))\nNTSTATUS _app_db_savetofile (\n\t_Inout_ PDB_INFORMATION db_info,\n\t_In_ PR_STRING path,\n\t_In_ ENUM_VERSION_XML version,\n\t_In_ ENUM_TYPE_XML type,\n\t_In_ LONG64 timestamp\n)\n{\n\tNTSTATUS status;\n\n\tstatus = _r_xml_createstream (&db_info->xml_library, NULL, 1024);\n\n\tif (FAILED (status))\n\t\treturn status;\n\n\t_r_xml_writestartdocument (&db_info->xml_library);\n\n\t_r_xml_writestartelement (&db_info->xml_library, L\"root\");\n\n\t_r_xml_setattribute_long (&db_info->xml_library, L\"version\", version);\n\t_r_xml_setattribute_long (&db_info->xml_library, L\"type\", type);\n\t_r_xml_setattribute_long64 (&db_info->xml_library, L\"timestamp\", timestamp);\n\n\t_app_db_save_app (db_info);\n\t_app_db_save_rule (db_info);\n\t_app_db_save_ruleconfig (db_info);\n\n\t_r_xml_writewhitespace (&db_info->xml_library, L\"\\r\\n\");\n\t_r_xml_writeendelement (&db_info->xml_library);\n\t_r_xml_writewhitespace (&db_info->xml_library, L\"\\r\\n\");\n\t_r_xml_writeenddocument (&db_info->xml_library);\n\n\treturn _app_db_save_streamtofile (db_info, path);\n}\n\n_Success_ (NT_SUCCESS (return))\nNTSTATUS _app_db_save_streamtofile (\n\t_Inout_ PDB_INFORMATION db_info,\n\t_In_ PR_STRING path\n)\n{\n\tPR_BYTE new_bytes;\n\tHANDLE hfile;\n\tNTSTATUS status;\n\n\tstatus = _r_fs_createfile (\n\t\t&path->sr,\n\t\tFILE_OVERWRITE_IF,\n\t\tGENERIC_WRITE,\n\t\tFILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,\n\t\tFILE_ATTRIBUTE_NORMAL,\n\t\t0,\n\t\tFALSE,\n\t\tNULL,\n\t\t&hfile\n\t);\n\n\tif (!NT_SUCCESS (status))\n\t\treturn status;\n\n\tstatus = _app_db_encodebody (db_info, _app_getprofiletype (), &new_bytes);\n\n\tif (NT_SUCCESS (status))\n\t{\n\t\t_r_fs_writefile (hfile, new_bytes->buffer, (ULONG)new_bytes->length);\n\n\t\t_r_obj_dereference (new_bytes);\n\t}\n\n\tNtClose (hfile);\n\n\treturn status;\n}\n\nFORCEINLINE VOID _app_db_writeelementstart (\n\t_Inout_ PDB_INFORMATION db_info,\n\t_In_ LPCWSTR name\n)\n{\n\t_r_xml_writewhitespace (&db_info->xml_library, L\"\\r\\n\\t\");\n\n\t_r_xml_writestartelement (&db_info->xml_library, name);\n}\n\nFORCEINLINE VOID _app_db_writeelementend (\n\t_Inout_ PDB_INFORMATION db_info\n)\n{\n\t_r_xml_writewhitespace (&db_info->xml_library, L\"\\r\\n\\t\");\n\n\t_r_xml_writeendelement (&db_info->xml_library);\n}\n\nVOID _app_db_save_app (\n\t_Inout_ PDB_INFORMATION db_info\n)\n{\n\tPITEM_APP ptr_app = NULL;\n\tULONG_PTR enum_key = 0;\n\tBOOLEAN is_keepunusedapps;\n\tBOOLEAN is_usedapp;\n\n\tis_keepunusedapps = _r_config_getboolean (L\"IsKeepUnusedApps\", TRUE, NULL);\n\n\t_app_db_writeelementstart (db_info, L\"apps\");\n\n\t_r_queuedlock_acquireshared (&lock_apps);\n\n\twhile (_r_obj_enumhashtablepointer (apps_table, (PVOID_PTR)&ptr_app, NULL, &enum_key))\n\t{\n\t\tif (_r_obj_isstringempty (ptr_app->original_path))\n\t\t\tcontinue;\n\n\t\tis_usedapp = _app_isappused (ptr_app);\n\n\t\t// do not save unused apps/uwp apps...\n\t\tif (!is_usedapp && (!is_keepunusedapps || (ptr_app->type == DATA_APP_SERVICE || ptr_app->type == DATA_APP_UWP)))\n\t\t{\n\t\t\t//_app_deleteappitem (_r_app_gethwnd (), ptr_app->type, ptr_app->app_hash);\n\n\t\t\tcontinue;\n\t\t}\n\n\t\t_r_xml_writewhitespace (&db_info->xml_library, L\"\\r\\n\\t\\t\");\n\t\t_r_xml_writestartelement (&db_info->xml_library, L\"item\");\n\n\t\t_r_xml_setattribute (&db_info->xml_library, L\"path\", ptr_app->original_path->buffer);\n\n\t\tif (!_r_obj_isstringempty (ptr_app->hash) && _r_config_getboolean (L\"IsHashesEnabled\", FALSE, NULL))\n\t\t\t_r_xml_setattribute (&db_info->xml_library, L\"hash\", ptr_app->hash->buffer);\n\n\t\tif (!_r_obj_isstringempty (ptr_app->comment))\n\t\t\t_r_xml_setattribute (&db_info->xml_library, L\"comment\", ptr_app->comment->buffer);\n\n\t\tif (ptr_app->timestamp)\n\t\t\t_r_xml_setattribute_long64 (&db_info->xml_library, L\"timestamp\", ptr_app->timestamp);\n\n\t\t// set timer (if presented)\n\t\tif (ptr_app->timer && _app_istimerset (ptr_app))\n\t\t\t_r_xml_setattribute_long64 (&db_info->xml_library, L\"timer\", ptr_app->timer);\n\n\t\t// ffu!\n\t\tif (ptr_app->profile)\n\t\t\t_r_xml_setattribute_long (&db_info->xml_library, L\"profile\", ptr_app->profile);\n\n\t\tif (ptr_app->is_undeletable)\n\t\t\t_r_xml_setattribute_boolean (&db_info->xml_library, L\"is_undeletable\", !!ptr_app->is_undeletable);\n\n\t\tif (ptr_app->is_silent)\n\t\t\t_r_xml_setattribute_boolean (&db_info->xml_library, L\"is_silent\", !!ptr_app->is_silent);\n\n\t\tif (ptr_app->is_enabled)\n\t\t\t_r_xml_setattribute_boolean (&db_info->xml_library, L\"is_enabled\", !!ptr_app->is_enabled);\n\n\t\t_r_xml_writeendelement (&db_info->xml_library);\n\t}\n\n\t_r_queuedlock_releaseshared (&lock_apps);\n\n\t_app_db_writeelementend (db_info);\n}\n\nVOID _app_db_save_rule (\n\t_Inout_ PDB_INFORMATION db_info\n)\n{\n\tPITEM_RULE ptr_rule;\n\tPR_STRING apps_string;\n\n\t_app_db_writeelementstart (db_info, L\"rules_custom\");\n\n\t_r_queuedlock_acquireshared (&lock_rules);\n\n\tfor (ULONG_PTR i = 0; i < _r_obj_getlistsize (rules_list); i++)\n\t{\n\t\tptr_rule = _r_obj_getlistitem (rules_list, i);\n\n\t\tif (!ptr_rule || ptr_rule->is_readonly || _r_obj_isstringempty (ptr_rule->name))\n\t\t\tcontinue;\n\n\t\t_r_xml_writewhitespace (&db_info->xml_library, L\"\\r\\n\\t\\t\");\n\n\t\t_r_xml_writestartelement (&db_info->xml_library, L\"item\");\n\n\t\t_r_xml_setattribute (&db_info->xml_library, L\"name\", ptr_rule->name->buffer);\n\n\t\tif (!_r_obj_isstringempty (ptr_rule->rule_remote))\n\t\t\t_r_xml_setattribute (&db_info->xml_library, L\"rule\", ptr_rule->rule_remote->buffer);\n\n\t\tif (!_r_obj_isstringempty (ptr_rule->rule_local))\n\t\t\t_r_xml_setattribute (&db_info->xml_library, L\"rule_local\", ptr_rule->rule_local->buffer);\n\n\t\tif (!_r_obj_isstringempty (ptr_rule->comment))\n\t\t\t_r_xml_setattribute (&db_info->xml_library, L\"comment\", ptr_rule->comment->buffer);\n\n\t\t// ffu!\n\t\tif (ptr_rule->profile)\n\t\t\t_r_xml_setattribute_long (&db_info->xml_library, L\"profile\", ptr_rule->profile);\n\n\t\tif (ptr_rule->direction != FWP_DIRECTION_OUTBOUND)\n\t\t\t_r_xml_setattribute_long (&db_info->xml_library, L\"dir\", ptr_rule->direction);\n\n\t\tif (ptr_rule->protocol != 0)\n\t\t\t_r_xml_setattribute_long (&db_info->xml_library, L\"protocol\", ptr_rule->protocol);\n\n\t\tif (ptr_rule->af != AF_UNSPEC)\n\t\t\t_r_xml_setattribute_long (&db_info->xml_library, L\"version\", ptr_rule->af);\n\n\t\t// add apps attribute\n\t\tif (!_r_obj_isempty (ptr_rule->apps))\n\t\t{\n\t\t\tapps_string = _app_rulesexpandapps (ptr_rule, FALSE, DIVIDER_APP);\n\n\t\t\tif (apps_string)\n\t\t\t{\n\t\t\t\t_r_xml_setattribute (&db_info->xml_library, L\"apps\", apps_string->buffer);\n\n\t\t\t\t_r_obj_dereference (apps_string);\n\t\t\t}\n\t\t}\n\n\t\tif (ptr_rule->action == FWP_ACTION_BLOCK)\n\t\t\t_r_xml_setattribute_boolean (&db_info->xml_library, L\"is_block\", TRUE);\n\n\t\tif (ptr_rule->is_enabled)\n\t\t\t_r_xml_setattribute_boolean (&db_info->xml_library, L\"is_enabled\", !!ptr_rule->is_enabled);\n\n\t\t_r_xml_writeendelement (&db_info->xml_library);\n\t}\n\n\t_r_queuedlock_releaseshared (&lock_rules);\n\n\t_app_db_writeelementend (db_info);\n}\n\nVOID _app_db_save_ruleconfig (\n\t_Inout_ PDB_INFORMATION db_info\n)\n{\n\tPITEM_RULE_CONFIG ptr_config = NULL;\n\tPITEM_RULE ptr_rule;\n\tPR_STRING apps_string;\n\tULONG_PTR enum_key = 0;\n\tULONG_PTR rule_hash;\n\tBOOLEAN is_enabled_default;\n\n\t_app_db_writeelementstart (db_info, L\"rules_config\");\n\n\t_r_queuedlock_acquireshared (&lock_rules_config);\n\n\twhile (_r_obj_enumhashtable (rules_config, (PVOID_PTR)&ptr_config, NULL, &enum_key))\n\t{\n\t\tif (_r_obj_isstringempty (ptr_config->name))\n\t\t\tcontinue;\n\n\t\tis_enabled_default = ptr_config->is_enabled;\n\t\trule_hash = _r_str_gethash (&ptr_config->name->sr, TRUE);\n\n\t\tptr_rule = _app_getrulebyhash (rule_hash);\n\n\t\tapps_string = NULL;\n\n\t\tif (ptr_rule)\n\t\t{\n\t\t\tis_enabled_default = !!ptr_rule->is_enabled_default;\n\n\t\t\tif (ptr_rule->type == DATA_RULE_USER && !_r_obj_isempty (ptr_rule->apps))\n\t\t\t\tapps_string = _app_rulesexpandapps (ptr_rule, FALSE, DIVIDER_APP);\n\n\t\t\t_r_obj_dereference (ptr_rule);\n\t\t}\n\n\t\t// skip saving untouched configuration\n\t\tif (ptr_config->is_enabled == is_enabled_default && !apps_string)\n\t\t\tcontinue;\n\n\t\t_r_xml_writewhitespace (&db_info->xml_library, L\"\\r\\n\\t\\t\");\n\n\t\t_r_xml_writestartelement (&db_info->xml_library, L\"item\");\n\n\t\t_r_xml_setattribute (&db_info->xml_library, L\"name\", ptr_config->name->buffer);\n\n\t\tif (apps_string)\n\t\t{\n\t\t\t_r_xml_setattribute (&db_info->xml_library, L\"apps\", apps_string->buffer);\n\n\t\t\t_r_obj_clearreference ((PVOID_PTR)&apps_string);\n\t\t}\n\n\t\t_r_xml_setattribute_boolean (&db_info->xml_library, L\"is_enabled\", ptr_config->is_enabled);\n\n\t\t_r_xml_writeendelement (&db_info->xml_library);\n\t}\n\n\t_r_queuedlock_releaseshared (&lock_rules_config);\n\n\t_app_db_writeelementend (db_info);\n}\n\n_Ret_maybenull_\nLPCWSTR _app_db_getconnectionstatename (\n\t_In_ ULONG state\n)\n{\n\tswitch (state)\n\t{\n\t\tcase MIB_TCP_STATE_CLOSED:\n\t\t\treturn L\"Closed\";\n\n\t\tcase MIB_TCP_STATE_LISTEN:\n\t\t\treturn L\"Listen\";\n\n\t\tcase MIB_TCP_STATE_SYN_SENT:\n\t\t\treturn L\"SYN sent\";\n\n\t\tcase MIB_TCP_STATE_SYN_RCVD:\n\t\t\treturn L\"SYN received\";\n\n\t\tcase MIB_TCP_STATE_ESTAB:\n\t\t\treturn L\"Established\";\n\n\t\tcase MIB_TCP_STATE_FIN_WAIT1:\n\t\t\treturn L\"FIN wait 1\";\n\n\t\tcase MIB_TCP_STATE_FIN_WAIT2:\n\t\t\treturn L\"FIN wait 2\";\n\n\t\tcase MIB_TCP_STATE_CLOSE_WAIT:\n\t\t\treturn L\"Close wait\";\n\n\t\tcase MIB_TCP_STATE_CLOSING:\n\t\t\treturn L\"Closing\";\n\n\t\tcase MIB_TCP_STATE_LAST_ACK:\n\t\t\treturn L\"Last ACK\";\n\n\t\tcase MIB_TCP_STATE_TIME_WAIT:\n\t\t\treturn L\"Time wait\";\n\n\t\tcase MIB_TCP_STATE_DELETE_TCB:\n\t\t\treturn L\"Delete TCB\";\n\t}\n\n\treturn NULL;\n}\n\n_Ret_maybenull_\nPR_STRING _app_db_getdirectionname (\n\t_In_ FWP_DIRECTION direction,\n\t_In_ BOOLEAN is_loopback,\n\t_In_ BOOLEAN is_localized\n)\n{\n\tLPCWSTR text = NULL;\n\n\tif (is_localized)\n\t{\n\t\tswitch (direction)\n\t\t{\n\t\t\tcase FWP_DIRECTION_OUTBOUND:\n\t\t\t{\n\t\t\t\ttext = _r_locale_getstring (IDS_DIRECTION_1);\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase FWP_DIRECTION_INBOUND:\n\t\t\t{\n\t\t\t\ttext = _r_locale_getstring (IDS_DIRECTION_2);\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase FWP_DIRECTION_MAX:\n\t\t\t{\n\t\t\t\ttext = _r_locale_getstring (IDS_ANY);\n\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\telse\n\t{\n\t\tswitch (direction)\n\t\t{\n\t\t\tcase FWP_DIRECTION_OUTBOUND:\n\t\t\t{\n\t\t\t\ttext = SZ_DIRECTION_OUT;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase FWP_DIRECTION_INBOUND:\n\t\t\t{\n\t\t\t\ttext = SZ_DIRECTION_IN;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase FWP_DIRECTION_MAX:\n\t\t\t{\n\t\t\t\ttext = SZ_DIRECTION_ANY;\n\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (!text)\n\t\treturn NULL;\n\n\tif (is_loopback)\n\t\treturn _r_obj_concatstrings (2, text, L\" (\" SZ_DIRECTION_LOOPBACK L\")\");\n\n\treturn _r_obj_createstring (text);\n}\n\nLPCWSTR _app_db_getprotoname (\n\t_In_ ULONG proto,\n\t_In_ ADDRESS_FAMILY af\n)\n{\n\tswitch (proto)\n\t{\n\t\t// NOTE: this is used for \"any\" protocol\n\t\tcase IPPROTO_HOPOPTS:\n\t\t\tbreak;\n\n\t\tcase IPPROTO_ICMP:\n\t\t\treturn L\"icmp\";\n\n\t\tcase IPPROTO_IGMP:\n\t\t\treturn L\"igmp\";\n\n\t\tcase IPPROTO_GGP:\n\t\t\treturn L\"ggp\";\n\n\t\tcase IPPROTO_IPV4:\n\t\t\treturn L\"ipv4\";\n\n\t\tcase IPPROTO_ST:\n\t\t\treturn L\"st\";\n\n\t\tcase IPPROTO_TCP:\n\t\t\treturn ((af == AF_INET6) ? L\"tcp6\" : L\"tcp\");\n\n\t\tcase IPPROTO_CBT:\n\t\t\treturn L\"cbt\";\n\n\t\tcase IPPROTO_EGP:\n\t\t\treturn L\"egp\";\n\n\t\tcase IPPROTO_IGP:\n\t\t\treturn L\"igp\";\n\n\t\tcase IPPROTO_PUP:\n\t\t\treturn L\"pup\";\n\n\t\tcase IPPROTO_UDP:\n\t\t\treturn ((af == AF_INET6) ? L\"udp6\" : L\"udp\");\n\n\t\tcase IPPROTO_IDP:\n\t\t\treturn L\"xns-idp\";\n\n\t\tcase IPPROTO_RDP:\n\t\t\treturn L\"rdp\";\n\n\t\tcase IPPROTO_IPV6:\n\t\t\treturn L\"ipv6\";\n\n\t\tcase IPPROTO_ROUTING:\n\t\t\treturn L\"ipv6-route\";\n\n\t\tcase IPPROTO_FRAGMENT:\n\t\t\treturn L\"ipv6-frag\";\n\n\t\tcase IPPROTO_ESP:\n\t\t\treturn L\"esp\";\n\n\t\tcase IPPROTO_AH:\n\t\t\treturn L\"ah\";\n\n\t\tcase IPPROTO_ICMPV6:\n\t\t\treturn L\"ipv6-icmp\";\n\n\t\tcase IPPROTO_DSTOPTS:\n\t\t\treturn L\"ipv6-opts\";\n\n\t\tcase IPPROTO_L2TP:\n\t\t\treturn L\"l2tp\";\n\n\t\tcase IPPROTO_SCTP:\n\t\t\treturn L\"sctp\";\n\n\t\tcase IPPROTO_RAW:\n\t\t\treturn L\"raw\";\n\t}\n\n\treturn L\"n/a\";\n}\n\n_Ret_maybenull_\nLPCWSTR _app_db_getservicename (\n\t_In_ UINT16 port,\n\t_In_ UINT8 proto\n)\n{\n\tswitch (port)\n\t{\n\t\tcase 1:\n\t\t\treturn L\"tcpmux\";\n\n\t\tcase 2:\n\t\tcase 3:\n\t\t\treturn L\"compressnet\";\n\n\t\tcase 5:\n\t\t\treturn L\"rje\";\n\n\t\tcase 7:\n\t\t\treturn L\"echo\";\n\n\t\tcase 9:\n\t\t\treturn L\"discard\";\n\n\t\tcase 11:\n\t\t\treturn L\"systat\";\n\n\t\tcase 13:\n\t\t\treturn L\"daytime\";\n\n\t\tcase 15:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t\treturn L\"netstat\";\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 17:\n\t\t\treturn L\"qotd\";\n\n\t\tcase 18:\n\t\t\treturn L\"msp\";\n\n\t\tcase 20:\n\t\t\treturn L\"ftp-data\";\n\n\t\tcase 21:\n\t\t\treturn L\"ftp\";\n\n\t\tcase 22:\n\t\t\treturn L\"ssh\";\n\n\t\tcase 23:\n\t\t\treturn L\"telnet\";\n\n\t\tcase 24:\n\t\t\treturn L\"priv-mail\";\n\n\t\tcase 25:\n\t\t\treturn L\"smtp\";\n\n\t\tcase 26:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t\treturn L\"rsftp\";\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 27:\n\t\t\treturn L\"nsw-fe\";\n\n\t\tcase 29:\n\t\t\treturn L\"msg-icp\";\n\n\t\tcase 31:\n\t\t\treturn L\"msg-auth\";\n\n\t\tcase 33:\n\t\t\treturn L\"dsp\";\n\n\t\tcase 35:\n\t\t\treturn L\"priv-print\";\n\n\t\tcase 37:\n\t\t\treturn L\"time\";\n\n\t\tcase 38:\n\t\t\treturn L\"rap\";\n\n\t\tcase 39:\n\t\t\treturn L\"rlp\";\n\n\t\tcase 41:\n\t\t\treturn L\"graphics\";\n\n\t\tcase 42:\n\t\t\treturn L\"nameserver\";\n\n\t\tcase 43:\n\t\t\treturn L\"whois\";\n\n\t\tcase 47:\n\t\t\treturn L\"ni-ftp\";\n\n\t\tcase 48:\n\t\t\treturn L\"auditd\";\n\n\t\tcase 49:\n\t\t\treturn L\"tacacs\";\n\n\t\tcase 50:\n\t\t\treturn L\"re-mail-ck\";\n\n\t\tcase 52:\n\t\t\treturn L\"xns-time\";\n\n\t\tcase 53:\n\t\t\treturn L\"domain\";\n\n\t\tcase 54:\n\t\t\treturn L\"xns-ch\";\n\n\t\tcase 55:\n\t\t\treturn L\"isi-gl\";\n\n\t\tcase 57:\n\t\t\treturn L\"priv-term\";\n\n\t\tcase 58:\n\t\t\treturn L\"xns-mail\";\n\n\t\tcase 59:\n\t\t\treturn L\"priv-file\";\n\n\t\tcase 61:\n\t\t\treturn L\"ni-mail\";\n\n\t\tcase 62:\n\t\t\treturn L\"acas\";\n\n\t\tcase 63:\n\t\t\treturn L\"via-ftp\"; // whoispp\n\n\t\tcase 64:\n\t\t\treturn L\"covia\";\n\n\t\tcase 65:\n\t\t\treturn L\"tacacs-ds\";\n\n\t\tcase 66:\n\t\t\treturn L\"sqlnet\";\n\n\t\tcase 67:\n\t\t\treturn L\"dhcps\";\n\n\t\tcase 68:\n\t\t\treturn L\"dhcpc\";\n\n\t\tcase 69:\n\t\t\treturn L\"tftp\";\n\n\t\tcase 70:\n\t\t\treturn L\"gopher\";\n\n\t\tcase 75:\n\t\t\treturn L\"priv-dial\";\n\n\t\tcase 76:\n\t\t\treturn L\"deos\";\n\n\t\tcase 77:\n\t\t\treturn L\"priv-rje\"; // netjrs\n\n\t\tcase 78:\n\t\t\treturn L\"vettcp\";\n\n\t\tcase 79:\n\t\tcase 2003:\n\t\t\treturn L\"finger\";\n\n\t\tcase 80:\n\t\t\treturn L\"http\";\n\n\t\tcase 81:\n\t\t\treturn L\"hosts2-ns\";\n\n\t\tcase 82:\n\t\t\treturn L\"xfer\";\n\n\t\tcase 83:\n\t\t\treturn L\"mit-ml-dev\";\n\n\t\tcase 84:\n\t\t\treturn L\"ctf\";\n\n\t\tcase 85:\n\t\t\treturn L\"mit-ml-dev\";\n\n\t\tcase 86:\n\t\t\treturn L\"mfcobol\";\n\n\t\tcase 87:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t\treturn L\"priv-term-l\";\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 88:\n\t\t\treturn L\"kerberos-sec\";\n\n\t\tcase 89:\n\t\t\treturn L\"su-mit-tg\";\n\n\t\tcase 90:\n\t\t\treturn L\"dnsix\";\n\n\t\tcase 91:\n\t\t\treturn L\"mit-dov\";\n\n\t\tcase 92:\n\t\t\treturn L\"npp\";\n\n\t\tcase 93:\n\t\t\treturn L\"dcp\";\n\n\t\tcase 94:\n\t\t\treturn L\"objcall\";\n\n\t\tcase 95:\n\t\t\treturn L\"supdup\";\n\n\t\tcase 96:\n\t\t\treturn L\"dixie\";\n\n\t\tcase 97:\n\t\t\treturn L\"swift-rvf\";\n\n\t\tcase 98:\n\t\t\treturn L\"metagram\";\n\n\t\tcase 100:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t\treturn L\"newacct\";\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 101:\n\t\t\treturn L\"hostname\";\n\n\t\tcase 105:\n\t\t\treturn L\"csnet-ns\";\n\n\t\tcase 106:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t\treturn L\"pop3pw\";\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 107:\n\t\t\treturn L\"rtelnet\";\n\n\t\tcase 108:\n\t\t\treturn L\"snagas\";\n\n\t\tcase 109:\n\t\t\treturn L\"pop2\";\n\n\t\tcase 110:\n\t\t\treturn L\"pop3\";\n\n\t\tcase 111:\n\t\t\treturn L\"rpcbind\";\n\n\t\tcase 112:\n\t\t\treturn L\"mcidas\";\n\n\t\tcase 113:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t{\n\t\t\t\treturn L\"ident\";\n\t\t\t}\n\t\t\telse if (proto == IPPROTO_UDP)\n\t\t\t{\n\t\t\t\treturn L\"auth\";\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 114:\n\t\t\treturn L\"audionews\";\n\n\t\tcase 115:\n\t\t\treturn L\"sftp\";\n\n\t\tcase 116:\n\t\t\treturn L\"ansanotify\";\n\n\t\tcase 117:\n\t\t\treturn L\"uucp-path\";\n\n\t\tcase 118:\n\t\t\treturn L\"sqlserv\";\n\n\t\tcase 119:\n\t\t\treturn L\"nntp\";\n\n\t\tcase 121:\n\t\t\treturn L\"erpc\";\n\n\t\tcase 123:\n\t\t\treturn L\"ntp\";\n\n\t\tcase 125:\n\t\t\treturn L\"locus-map\";\n\n\t\tcase 126:\n\t\t\treturn L\"unitary\";\n\n\t\tcase 127:\n\t\t\treturn L\"locus-con\";\n\n\t\tcase 128:\n\t\t\treturn L\"gss-xlicen\";\n\n\t\tcase 129:\n\t\t\treturn L\"pwdgen\";\n\n\t\tcase 130:\n\t\t\treturn L\"cisco-fna\";\n\n\t\tcase 131:\n\t\t\treturn L\"cisco-tna\";\n\n\t\tcase 132:\n\t\t\treturn L\"cisco-sys\";\n\n\t\tcase 133:\n\t\t\treturn L\"statsrv\";\n\n\t\tcase 134:\n\t\t\treturn L\"ingres-net\";\n\n\t\tcase 135:\n\t\t\treturn L\"msrpc\";\n\n\t\tcase 136:\n\t\t\treturn L\"profile\";\n\n\t\tcase 137:\n\t\t\treturn L\"netbios-ns\";\n\n\t\tcase 138:\n\t\t\treturn L\"netbios-dgm\";\n\n\t\tcase 139:\n\t\t\treturn L\"netbios-ssn\";\n\n\t\tcase 140:\n\t\t\treturn L\"emfis-data\";\n\n\t\tcase 141:\n\t\t\treturn L\"emfis-cntl\";\n\n\t\tcase 142:\n\t\t\treturn L\"bl-idm\";\n\n\t\tcase 143:\n\t\t\treturn L\"imap\";\n\n\t\tcase 144:\n\t\t\treturn L\"news\";\n\n\t\tcase 145:\n\t\t\treturn L\"uaac\";\n\n\t\tcase 148:\n\t\t\treturn L\"cronus\";\n\n\t\tcase 149:\n\t\t\treturn L\"aed-512\";\n\n\t\tcase 150:\n\t\t\treturn L\"sql-net\";\n\n\t\tcase 152:\n\t\t\treturn L\"bftp\";\n\n\t\tcase 153:\n\t\t\treturn L\"sgmp\";\n\n\t\tcase 154:\n\t\t\treturn L\"netsc-prod\";\n\n\t\tcase 155:\n\t\t\treturn L\"netsc-dev\";\n\n\t\tcase 156:\n\t\t\treturn L\"sqlsrv\";\n\n\t\tcase 159:\n\t\t\treturn L\"nss-routing\";\n\n\t\tcase 160:\n\t\t\treturn L\"sgmp-traps\";\n\n\t\tcase 161:\n\t\t\treturn L\"snmp\";\n\n\t\tcase 162:\n\t\t\treturn L\"snmptrap\";\n\n\t\tcase 163:\n\t\t\treturn L\"cmip-man\";\n\n\t\tcase 164:\n\t\t\treturn L\"cmip-agent\";\n\n\t\tcase 165:\n\t\t\treturn L\"xns-courier\";\n\n\t\tcase 166:\n\t\t\treturn L\"s-net\";\n\n\t\tcase 167:\n\t\t\treturn L\"namp\";\n\n\t\tcase 168:\n\t\t\treturn L\"rsvd\";\n\n\t\tcase 169:\n\t\t\treturn L\"send\";\n\n\t\tcase 170:\n\t\t\treturn L\"print-srv\";\n\n\t\tcase 171:\n\t\t\treturn L\"multiplex\";\n\n\t\tcase 172:\n\t\t\treturn L\"cl-1\";\n\n\t\tcase 173:\n\t\t\treturn L\"xyplex-mux\";\n\n\t\tcase 174:\n\t\t\treturn L\"mailq\";\n\n\t\tcase 175:\n\t\t\treturn L\"vmnet\";\n\n\t\tcase 176:\n\t\t\treturn L\"genrad-mux\";\n\n\t\tcase 177:\n\t\t\treturn L\"xdmcp\";\n\n\t\tcase 178:\n\t\t\treturn L\"nextstep\";\n\n\t\tcase 179:\n\t\t\treturn L\"bgp\";\n\n\t\tcase 180:\n\t\t\treturn L\"ris\";\n\n\t\tcase 181:\n\t\t\treturn L\"unify\";\n\n\t\tcase 182:\n\t\t\treturn L\"audit\";\n\n\t\tcase 183:\n\t\t\treturn L\"ocbinder\";\n\n\t\tcase 184:\n\t\t\treturn L\"ocserver\";\n\n\t\tcase 185:\n\t\t\treturn L\"remote-kis\";\n\n\t\tcase 186:\n\t\t\treturn L\"kis\";\n\n\t\tcase 187:\n\t\t\treturn L\"aci\";\n\n\t\tcase 188:\n\t\t\treturn L\"mumps\";\n\n\t\tcase 189:\n\t\t\treturn L\"qft\";\n\n\t\tcase 190:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t{\n\t\t\t\treturn L\"gacp\";\n\t\t\t}\n\t\t\telse if (proto == IPPROTO_UDP)\n\t\t\t{\n\t\t\t\treturn L\"cacp\";\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 191:\n\t\t\treturn L\"prospero\";\n\n\t\tcase 192:\n\t\t\treturn L\"osu-nms\";\n\n\t\tcase 193:\n\t\t\treturn L\"srmp\";\n\n\t\tcase 194:\n\t\tcase 529:\n\t\t\treturn L\"irc\";\n\n\t\tcase 195:\n\t\t\treturn L\"dn6-nlm-aud\";\n\n\t\tcase 196:\n\t\t\treturn L\"dn6-smm-red\";\n\n\t\tcase 197:\n\t\t\treturn L\"dls\";\n\n\t\tcase 198:\n\t\t\treturn L\"dls-mon\";\n\n\t\tcase 199:\n\t\t\treturn L\"smux\";\n\n\t\tcase 200:\n\t\t\treturn L\"src\";\n\n\t\tcase 201:\n\t\t\treturn L\"at-rtmp\";\n\n\t\tcase 202:\n\t\t\treturn L\"at-nbp\";\n\n\t\tcase 203:\n\t\t\treturn L\"at-3\";\n\n\t\tcase 204:\n\t\t\treturn L\"at-echo\";\n\n\t\tcase 205:\n\t\t\treturn L\"at-5\";\n\n\t\tcase 206:\n\t\t\treturn L\"at-zis\";\n\n\t\tcase 207:\n\t\t\treturn L\"at-7\";\n\n\t\tcase 208:\n\t\t\treturn L\"at-8\";\n\n\t\tcase 209:\n\t\t\treturn L\"tam\"; // qmtp\n\n\t\tcase 212:\n\t\t\treturn L\"anet\";\n\n\t\tcase 213:\n\t\t\treturn L\"ipx\";\n\n\t\tcase 214:\n\t\t\treturn L\"vmpwscs\";\n\n\t\tcase 215:\n\t\t\treturn L\"softpc\";\n\n\t\tcase 216:\n\t\t\treturn L\"atls\";\n\n\t\tcase 217:\n\t\t\treturn L\"dbase\";\n\n\t\tcase 218:\n\t\t\treturn L\"mpp\";\n\n\t\tcase 219:\n\t\t\treturn L\"uarps\";\n\n\t\tcase 220:\n\t\t\treturn L\"imap3\";\n\n\t\tcase 221:\n\t\tcase 222:\n\t\t\treturn L\"rsh-spx\";\n\n\t\tcase 223:\n\t\t\treturn L\"cdc\";\n\n\t\tcase 224:\n\t\t\treturn L\"masqdialer\";\n\n\t\tcase 242:\n\t\t\treturn L\"direct\";\n\n\t\tcase 243:\n\t\t\treturn L\"sur-meas\";\n\n\t\tcase 244:\n\t\t\treturn L\"dayna\";\n\n\t\tcase 245:\n\t\t\treturn L\"link\";\n\n\t\tcase 246:\n\t\t\treturn L\"dsp3270\";\n\n\t\tcase 247:\n\t\t\treturn L\"subntbcst_tftp\";\n\n\t\tcase 248:\n\t\t\treturn L\"bhfhs\";\n\n\t\tcase 256:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t{\n\t\t\t\treturn L\"fw1-secureremote\";\n\t\t\t}\n\t\t\telse if (proto == IPPROTO_UDP)\n\t\t\t{\n\t\t\t\treturn L\"rap\";\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 257:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t\treturn L\"fw1-mc-fwmodule\";\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 258:\n\t\t\treturn L\"yak-chat\";\n\n\t\tcase 259:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t{\n\t\t\t\treturn L\"esro-gen\";\n\t\t\t}\n\t\t\telse if (proto == IPPROTO_UDP)\n\t\t\t{\n\t\t\t\treturn L\"firewall1-rdp\";\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 260:\n\t\t\treturn L\"openport\";\n\n\t\tcase 261:\n\t\t\treturn L\"nsiiops\";\n\n\t\tcase 262:\n\t\t\treturn L\"arcisdms\";\n\n\t\tcase 264:\n\t\t\treturn L\"fw1-or-bgmp\";\n\n\t\tcase 265:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t{\n\t\t\t\treturn L\"maybe-fw1\";\n\t\t\t}\n\t\t\telse if (proto == IPPROTO_UDP)\n\t\t\t{\n\t\t\t\treturn L\"x-bone-ctl\";\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 266:\n\t\t\treturn L\"sst\";\n\n\t\tcase 267:\n\t\t\treturn L\"td-service\";\n\n\t\tcase 268:\n\t\t\treturn L\"td-replica\";\n\n\t\tcase 269:\n\t\t\treturn L\"manet\";\n\n\t\tcase 270:\n\t\t\treturn L\"gist\";\n\n\t\tcase 271:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t\treturn L\"pt-tls\";\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 280:\n\t\t\treturn L\"http-mgmt\";\n\n\t\tcase 281:\n\t\t\treturn L\"personal-link\";\n\n\t\tcase 282:\n\t\t\treturn L\"cableport-ax\";\n\n\t\tcase 283:\n\t\t\treturn L\"rescap\";\n\n\t\tcase 284:\n\t\t\treturn L\"corerjd\";\n\n\t\tcase 286:\n\t\t\treturn L\"fxp\";\n\n\t\tcase 287:\n\t\t\treturn L\"k-block\";\n\n\t\tcase 308:\n\t\t\treturn L\"novastorbakcup\";\n\n\t\tcase 309:\n\t\t\treturn L\"entrusttime\";\n\n\t\tcase 310:\n\t\t\treturn L\"bhmds\";\n\n\t\tcase 311:\n\t\t\treturn L\"asip-webadmin\";\n\n\t\tcase 312:\n\t\t\treturn L\"vslmp\";\n\n\t\tcase 313:\n\t\t\treturn L\"magenta-logic\";\n\n\t\tcase 314:\n\t\t\treturn L\"opalis-robot\";\n\n\t\tcase 318:\n\t\t\treturn L\"pkix-timestamp\";\n\n\t\tcase 319:\n\t\t\treturn L\"ptp-event\";\n\n\t\tcase 320:\n\t\t\treturn L\"ptp-general\";\n\n\t\tcase 321:\n\t\t\treturn L\"pip\";\n\n\t\tcase 322:\n\t\t\treturn L\"rtsps\";\n\n\t\tcase 323:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t\treturn L\"rpki-rtr\";\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 324:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t\treturn L\"rpki-rtr-tls\";\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 333:\n\t\t\treturn L\"texar\";\n\n\t\tcase 344:\n\t\t\treturn L\"pdap\";\n\n\t\tcase 345:\n\t\t\treturn L\"pawserv\";\n\n\t\tcase 346:\n\t\t\treturn L\"zserv\";\n\n\t\tcase 347:\n\t\t\treturn L\"fatserv\";\n\n\t\tcase 348:\n\t\t\treturn L\"csi-sgwp\";\n\n\t\tcase 349:\n\t\t\treturn L\"mftp\";\n\n\t\tcase 353:\n\t\t\treturn L\"ndsauth\";\n\n\t\tcase 355:\n\t\t\treturn L\"datex-asn\";\n\n\t\tcase 358:\n\t\t\treturn L\"shrinkwrap\";\n\n\t\tcase 359:\n\t\t\treturn L\"tenebris_nts\";\n\n\t\tcase 362:\n\t\t\treturn L\"srssend\";\n\n\t\tcase 363:\n\t\t\treturn L\"rsvp_tunnel\";\n\n\t\tcase 364:\n\t\t\treturn L\"aurora-cmgr\";\n\n\t\tcase 365:\n\t\t\treturn L\"dtk\";\n\n\t\tcase 367:\n\t\t\treturn L\"mortgageware\";\n\n\t\tcase 369:\n\t\t\treturn L\"rpc2portmap\";\n\n\t\tcase 370:\n\t\t\treturn L\"codaauth2\";\n\n\t\tcase 375:\n\t\t\treturn L\"hassle\";\n\n\t\tcase 376:\n\t\t\treturn L\"nip\";\n\n\t\tcase 377:\n\t\t\treturn L\"tnETOS\";\n\n\t\tcase 378:\n\t\t\treturn L\"dsETOS\";\n\n\t\tcase 381:\n\t\t\treturn L\"hp-collector\";\n\n\t\tcase 382:\n\t\t\treturn L\"hp-managed-node\";\n\n\t\tcase 383:\n\t\t\treturn L\"hp-alarm-mgr\";\n\n\t\tcase 384:\n\t\t\treturn L\"arns\";\n\n\t\tcase 386:\n\t\t\treturn L\"asa\";\n\n\t\tcase 387:\n\t\t\treturn L\"aurp\";\n\n\t\tcase 388:\n\t\t\treturn L\"unidata-ldm\";\n\n\t\tcase 389:\n\t\t\treturn L\"ldap\";\n\n\t\tcase 391:\n\t\t\treturn L\"synotics-relay\";\n\n\t\tcase 392:\n\t\t\treturn L\"synotics-broker\";\n\n\t\tcase 393:\n\t\t\treturn L\"dis\";\n\n\t\tcase 398:\n\t\t\treturn L\"kryptolan\";\n\n\t\tcase 399:\n\t\t\treturn L\"iso-tsap-c2\";\n\n\t\tcase 401:\n\t\t\treturn L\"ups\";\n\n\t\tcase 402:\n\t\t\treturn L\"genie\";\n\n\t\tcase 403:\n\t\t\treturn L\"decap\";\n\n\t\tcase 404:\n\t\t{\n\t\t\tif (proto == IPPROTO_UDP)\n\t\t\t\treturn L\"nced\";\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 405:\n\t\t\treturn L\"ncld\";\n\n\t\tcase 406:\n\t\t\treturn L\"imsp\";\n\n\t\tcase 407:\n\t\t\treturn L\"timbuktu\";\n\n\t\tcase 410:\n\t\t\treturn L\"decladebug\";\n\n\t\tcase 411:\n\t\t\treturn L\"rmt\";\n\n\t\tcase 412:\n\t\t\treturn L\"synoptics-trap\";\n\n\t\tcase 413:\n\t\t\treturn L\"smsp\";\n\n\t\tcase 414:\n\t\t\treturn L\"infoseek\";\n\n\t\tcase 415:\n\t\t\treturn L\"bnet\";\n\n\t\tcase 417:\n\t\t\treturn L\"onmux\";\n\n\t\tcase 418:\n\t\t\treturn L\"hyper-g\";\n\n\t\tcase 419:\n\t\t\treturn L\"ariel1\";\n\n\t\tcase 420:\n\t\t\treturn L\"smpte\";\n\n\t\tcase 421:\n\t\t\treturn L\"ariel2\";\n\n\t\tcase 422:\n\t\t\treturn L\"ariel3\";\n\n\t\tcase 423:\n\t\t\treturn L\"opc-job-start\";\n\n\t\tcase 424:\n\t\t\treturn L\"opc-job-track\";\n\n\t\tcase 427:\n\t\t\treturn L\"svrloc\";\n\n\t\tcase 428:\n\t\t\treturn L\"ocs_cmu\";\n\n\t\tcase 429:\n\t\t\treturn L\"ocs_amu\";\n\n\t\tcase 430:\n\t\t\treturn L\"utmpsd\";\n\n\t\tcase 431:\n\t\t\treturn L\"utmpcd\";\n\n\t\tcase 433:\n\t\t\treturn L\"nnsp\";\n\n\t\tcase 434:\n\t\t\treturn L\"mobileip-agent\";\n\n\t\tcase 435:\n\t\t\treturn L\"mobilip-mn\";\n\n\t\tcase 437:\n\t\t\treturn L\"comscm\";\n\n\t\tcase 442:\n\t\t\treturn L\"cvc_hostd\";\n\n\t\tcase 443:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t{\n\t\t\t\treturn L\"https\";\n\t\t\t}\n\t\t\telse if (proto == IPPROTO_UDP)\n\t\t\t{\n\t\t\t\treturn L\"quic\";\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 444:\n\t\t\treturn L\"snpp\";\n\n\t\tcase 445:\n\t\t\treturn L\"microsoft-ds\";\n\n\t\tcase 450:\n\t\t\treturn L\"tserver\";\n\n\t\tcase 456:\n\t\t\treturn L\"macon\";\n\n\t\tcase 458:\n\t\t\treturn L\"appleqtc\";\n\n\t\tcase 464:\n\t\t\treturn L\"kpasswd5\"; // kerberos\n\n\t\tcase 465:\n\t\t\treturn L\"smtps\";\n\n\t\tcase 469:\n\t\t\treturn L\"rcp\";\n\n\t\tcase 470:\n\t\t\treturn L\"scx-proxy\";\n\n\t\tcase 471:\n\t\t\treturn L\"mondex\";\n\n\t\tcase 473:\n\t\t\treturn L\"hybrid-pop\";\n\n\t\tcase 475:\n\t\t\treturn L\"tcpnethaspsrv\";\n\n\t\tcase 482:\n\t\t{\n\t\t\tif (proto == IPPROTO_UDP)\n\t\t\t\treturn L\"xlog\";\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 485:\n\t\t\treturn L\"powerburst\";\n\n\t\tcase 486:\n\t\t{\n\t\t\tif (proto == IPPROTO_UDP)\n\t\t\t{\n\t\t\t\treturn L\"sstats\";\n\t\t\t}\n\t\t\telse if (proto == IPPROTO_UDP)\n\t\t\t{\n\t\t\t\treturn L\"avian\";\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 488:\n\t\t\treturn L\"gss-http\";\n\n\t\tcase 489:\n\t\t\treturn L\"nest-protocol\";\n\n\t\tcase 490:\n\t\t\treturn L\"micom-pfs\";\n\n\t\tcase 491:\n\t\t\treturn L\"go-login\";\n\n\t\tcase 494:\n\t\t\treturn L\"pov-ray\";\n\n\t\tcase 495:\n\t\t\treturn L\"intecourier\";\n\n\t\tcase 496:\n\t\t\treturn L\"pim-rp-disc\";\n\n\t\tcase 497:\n\t\t\treturn L\"retrospect\";\n\n\t\tcase 499:\n\t\t\treturn L\"iso-ill\";\n\n\t\tcase 500:\n\t\t\treturn L\"isakmp\";\n\n\t\tcase 501:\n\t\t\treturn L\"stmf\";\n\n\t\tcase 502:\n\t\t\treturn L\"mbap\";\n\n\t\tcase 503:\n\t\t\treturn L\"intrinsa\";\n\n\t\tcase 505:\n\t\t\treturn L\"mailbox-lm\";\n\n\t\tcase 509:\n\t\t\treturn L\"snare\";\n\n\t\tcase 510:\n\t\t\treturn L\"fcp\";\n\n\t\tcase 511:\n\t\t\treturn L\"passgo\";\n\n\t\tcase 512:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t{\n\t\t\t\treturn L\"exec\";\n\t\t\t}\n\t\t\telse if (proto == IPPROTO_TCP)\n\t\t\t{\n\t\t\t\treturn L\"biff\";\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 513:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t{\n\t\t\t\treturn L\"login\";\n\t\t\t}\n\t\t\telse if (proto == IPPROTO_TCP)\n\t\t\t{\n\t\t\t\treturn L\"who\";\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 514:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t{\n\t\t\t\treturn L\"shell\";\n\t\t\t}\n\t\t\telse if (proto == IPPROTO_TCP)\n\t\t\t{\n\t\t\t\treturn L\"syslog\";\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 515:\n\t\t\treturn L\"printer\";\n\n\t\tcase 517:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t{\n\t\t\t\treturn L\"talk\";\n\t\t\t}\n\t\t\telse if (proto == IPPROTO_TCP)\n\t\t\t{\n\t\t\t\treturn L\"talk\";\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 518:\n\t\t\treturn L\"ntalk\";\n\n\t\tcase 519:\n\t\t\treturn L\"utime\";\n\n\t\tcase 520:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t{\n\t\t\t\treturn L\"efs\";\n\t\t\t}\n\t\t\telse if (proto == IPPROTO_TCP)\n\t\t\t{\n\t\t\t\treturn L\"route\";\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 521:\n\t\t\treturn L\"ripng\";\n\n\t\tcase 524:\n\t\t\treturn L\"ncp\";\n\n\t\tcase 525:\n\t\t\treturn L\"timed\";\n\n\t\tcase 526:\n\t\t\treturn L\"tempo\";\n\n\t\tcase 530:\n\t\t\treturn L\"courier\"; // rpc\n\n\t\tcase 531:\n\t\t\treturn L\"conference\";\n\n\t\tcase 532:\n\t\t\treturn L\"netnews\";\n\n\t\tcase 533:\n\t\t\treturn L\"netwall\";\n\n\t\tcase 537:\n\t\t\treturn L\"nmsp\";\n\n\t\tcase 540:\n\t\t\treturn L\"uucp\";\n\n\t\tcase 541:\n\t\t\treturn L\"uucp-rlogin\";\n\n\t\tcase 543:\n\t\t\treturn L\"klogin\";\n\n\t\tcase 544:\n\t\t\treturn L\"kshell\";\n\n\t\tcase 545:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t\treturn L\"ekshell\";\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 546:\n\t\t\treturn L\"dhcpv6-client\";\n\n\t\tcase 547:\n\t\t\treturn L\"dhcpv6-server\";\n\n\t\tcase 548:\n\t\t\treturn L\"afp\";\n\n\t\tcase 550:\n\t\t\treturn L\"new-rwho\";\n\n\t\tcase 554:\n\t\t\treturn L\"rtsp\";\n\n\t\tcase 555:\n\t\t\treturn L\"dsf\";\n\n\t\tcase 556:\n\t\t\treturn L\"remotefs\";\n\n\t\tcase 558:\n\t\t\treturn L\"sdnskmp\";\n\n\t\tcase 560:\n\t\t\treturn L\"rmonitor\";\n\n\t\tcase 561:\n\t\t\treturn L\"monitor\";\n\n\t\tcase 562:\n\t\t\treturn L\"chshell\";\n\n\t\tcase 563:\n\t\t\treturn L\"snews\";\n\n\t\tcase 565:\n\t\t\treturn L\"whoami\";\n\n\t\tcase 568:\n\t\t\treturn L\"ms-shuttle\";\n\n\t\tcase 569:\n\t\t\treturn L\"ms-rome\";\n\n\t\tcase 574:\n\t\t\treturn L\"ftp-agent\";\n\n\t\tcase 580:\n\t\t\treturn L\"sntp-heartbeat\";\n\n\t\tcase 582:\n\t\t\treturn L\"scc-security\";\n\n\t\tcase 584:\n\t\t\treturn L\"keyserver\";\n\n\t\tcase 585:\n\t\t\treturn L\"imap4-ssl\";\n\n\t\tcase 587:\n\t\t\treturn L\"submission\";\n\n\t\tcase 591:\n\t\tcase 8000:\n\t\tcase 8008:\n\t\tcase 8080:\n\t\t\treturn L\"http-alt\";\n\n\t\tcase 593:\n\t\t\treturn L\"http-rpc-epmap\";\n\n\t\tcase 609:\n\t\t\treturn L\"npmp-trap\";\n\n\t\tcase 610:\n\t\t\treturn L\"npmp-local\";\n\n\t\tcase 611:\n\t\t\treturn L\"npmp-gui\";\n\n\t\tcase 614:\n\t\t\treturn L\"sshell\";\n\n\t\tcase 620:\n\t\t\treturn L\"sco-websrvrmgr\";\n\n\t\tcase 624:\n\t\t\treturn L\"cryptoadmin\";\n\n\t\tcase 625:\n\t\t\treturn L\"apple-xsrvr-admin\";\n\n\t\tcase 626:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t{\n\t\t\t\treturn L\"apple-imap-admin\";\n\t\t\t}\n\t\t\telse if (proto == IPPROTO_UDP)\n\t\t\t{\n\t\t\t\treturn L\"serialnumberd\";\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 628:\n\t\t\treturn L\"qmqp\";\n\n\t\tcase 629:\n\t\t\treturn L\"3com-amp3\";\n\n\t\tcase 630:\n\t\t\treturn L\"rda\";\n\n\t\tcase 631:\n\t\t\treturn L\"ipp\";\n\n\t\tcase 633:\n\t\t\treturn L\"servstat\";\n\n\t\tcase 636:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t{\n\t\t\t\treturn L\"ldapssl\";\n\t\t\t}\n\t\t\telse if (proto == IPPROTO_UDP)\n\t\t\t{\n\t\t\t\treturn L\"ldaps\";\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 639:\n\t\t\treturn L\"msdp\";\n\n\t\tcase 646:\n\t\t\treturn L\"ldp\";\n\n\t\tcase 647:\n\t\t\treturn L\"dhcp-failover\";\n\n\t\tcase 648:\n\t\t\treturn L\"rrp\";\n\n\t\tcase 651:\n\t\t\treturn L\"ieee-mms\";\n\n\t\tcase 652:\n\t\t\treturn L\"hello-port\";\n\n\t\tcase 653:\n\t\t\treturn L\"repscmd\";\n\n\t\tcase 656:\n\t\t\treturn L\"spmp\";\n\n\t\tcase 658:\n\t\t\treturn L\"tenfold\";\n\n\t\tcase 660:\n\t\t\treturn L\"mac-srvr-admin\";\n\n\t\tcase 662:\n\t\t\treturn L\"pftp\";\n\n\t\tcase 663:\n\t\t\treturn L\"purenoise\";\n\n\t\tcase 666:\n\t\t\treturn L\"doom\"; // khe-khe-khe!\n\n\t\tcase 667:\n\t\t\treturn L\"disclose\";\n\n\t\tcase 674:\n\t\t\treturn L\"acapc\"; // stalker\n\n\t\tcase 678:\n\t\t\treturn L\"ggf-ncp\";\n\n\t\tcase 687:\n\t\t\treturn L\"asipregistry\";\n\n\t\tcase 691:\n\t\t{\n\t\t\tif (proto == IPPROTO_UDP)\n\t\t\t\treturn L\"msexch-routing\";\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 697:\n\t\t\treturn L\"msexch-routing\";\n\n\t\tcase 699:\n\t\t\treturn L\"accessnetwork\";\n\n\t\tcase 701:\n\t\t\treturn L\"lmp\";\n\n\t\tcase 707:\n\t\t\treturn L\"borland-dsj\";\n\n\t\tcase 709:\n\t\t\treturn L\"entrustmanager\";\n\n\t\tcase 710:\n\t\t\treturn L\"entrust-ash\";\n\n\t\tcase 711:\n\t\t\treturn L\"cisco-tdp\";\n\n\t\tcase 713:\n\t\t\treturn L\"iris-xpc\";\n\n\t\tcase 714:\n\t\t\treturn L\"iris-xpcs\";\n\n\t\tcase 716:\n\t\t\treturn L\"pana\";\n\n\t\tcase 740:\n\t\t\treturn L\"netcp\";\n\n\t\tcase 741:\n\t\t\treturn L\"netgw\";\n\n\t\tcase 742:\n\t\t\treturn L\"netrcs\";\n\n\t\tcase 747:\n\t\t\treturn L\"fujitsu-dev\";\n\n\t\tcase 751:\n\t\t\treturn L\"kadmin\";\n\n\t\tcase 754:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t{\n\t\t\t\treturn L\"krb_prop\";\n\t\t\t}\n\t\t\telse if (proto == IPPROTO_UDP)\n\t\t\t{\n\t\t\t\treturn L\"tell\";\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 758:\n\t\t\treturn L\"nlogin\";\n\n\t\tcase 761:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t{\n\t\t\t\treturn L\"kpasswd\";\n\t\t\t}\n\t\t\telse if (proto == IPPROTO_UDP)\n\t\t\t{\n\t\t\t\treturn L\"rxe\";\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 767:\n\t\t\treturn L\"phonebook\";\n\n\t\tcase 773:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t{\n\t\t\t\treturn L\"submit\";\n\t\t\t}\n\t\t\telse if (proto == IPPROTO_UDP)\n\t\t\t{\n\t\t\t\treturn L\"notify\";\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 777:\n\t\t\treturn L\"multiling-http\";\n\n\t\tcase 783:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t\treturn L\"spamassassin\";\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 799:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t\treturn L\"controlit\";\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 800:\n\t\t\treturn L\"mdbs_daemon\";\n\n\t\tcase 802:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t\treturn L\"mbap-s\";\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 808:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t\treturn L\"ccproxy-http\";\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 810:\n\t\t\treturn L\"fcp-udp\";\n\n\t\tcase 828:\n\t\t\treturn L\"itm-mcell-s\";\n\n\t\tcase 829:\n\t\t\treturn L\"pkix-3-ca-ra\";\n\n\t\tcase 830:\n\t\t\treturn L\"netconf-ssh\";\n\n\t\tcase 831:\n\t\t\treturn L\"netconf-beep\";\n\n\t\tcase 832:\n\t\t\treturn L\"netconfsoaphttp\";\n\n\t\tcase 833:\n\t\t\treturn L\"netconfsoapbeep\";\n\n\t\tcase 847:\n\t\t\treturn L\"dhcp-failover2\";\n\n\t\tcase 853:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t\treturn L\"domain-s\";\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 854:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t\treturn L\"dlep\";\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 860:\n\t\t\treturn L\"iscsi\";\n\n\t\tcase 861:\n\t\t\treturn L\"owamp-control\";\n\n\t\tcase 862:\n\t\t\treturn L\"twamp-control\";\n\n\t\tcase 873:\n\t\t\treturn L\"rsync\";\n\n\t\tcase 888:\n\t\t\treturn L\"accessbuilder\";\n\n\t\tcase 901:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t\treturn L\"samba-swat\";\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 910:\n\t\t\treturn L\"kink\";\n\n\t\tcase 950:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t\treturn L\"oftep-rpc\";\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 989:\n\t\t\treturn L\"ftps-data\";\n\n\t\tcase 990:\n\t\t\treturn L\"ftps\";\n\n\t\tcase 991:\n\t\t\treturn L\"nas\";\n\n\t\tcase 992:\n\t\t\treturn L\"telnets\";\n\n\t\tcase 993:\n\t\t\treturn L\"imaps\";\n\n\t\tcase 994:\n\t\t\treturn L\"ircs\";\n\n\t\tcase 995:\n\t\t\treturn L\"pop3s\";\n\n\t\tcase 1001:\n\t\t\treturn L\"webpush\";\n\n\t\tcase 1002:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t\treturn L\"windows-icfw\";\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 1025:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t{\n\t\t\t\treturn L\"NFS-or-IIS\";\n\t\t\t}\n\t\t\telse if (proto == IPPROTO_UDP)\n\t\t\t{\n\t\t\t\treturn L\"blackjack\";\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 1026:\n\t\t{\n\t\t\tif (proto == IPPROTO_UDP)\n\t\t\t\treturn L\"win-rpc\";\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 1027:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t\treturn L\"IIS\";\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 1028:\n\t\t{\n\t\t\tif (proto == IPPROTO_UDP)\n\t\t\t\treturn L\"ms-lsa\";\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 1029:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t\treturn L\"ms-lsa\";\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 1033:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t{\n\t\t\t\treturn L\"netinfo\";\n\t\t\t}\n\t\t\telse if (proto == IPPROTO_UDP)\n\t\t\t{\n\t\t\t\treturn L\"netinfo-local\";\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 1035:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t{\n\t\t\t\treturn L\"multidropper\";\n\t\t\t}\n\t\t\telse if (proto == IPPROTO_UDP)\n\t\t\t{\n\t\t\t\treturn L\"mxxrlogin\";\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 1050:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t{\n\t\t\t\treturn L\"java-or-OTGfileshare\";\n\t\t\t}\n\t\t\telse if (proto == IPPROTO_UDP)\n\t\t\t{\n\t\t\t\treturn L\"cma\";\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 1080:\n\t\t\treturn L\"socks\";\n\n\t\tcase 1085:\n\t\t\treturn L\"webobjects\";\n\n\t\tcase 1096:\n\t\t\treturn L\"cnrprotocol\";\n\n\t\tcase 1098:\n\t\t\treturn L\"rmiactivation\";\n\n\t\tcase 1099:\n\t\t\treturn L\"rmiregistry\";\n\n\t\tcase 1100:\n\t\t\treturn L\"mctp\";\n\n\t\tcase 1109:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t\treturn L\"kpop\"; // kerberos\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 1110:\n\t\t\treturn L\"nfsd\";\n\n\t\tcase 1111:\n\t\t\treturn L\"lmsocialserver\";\n\n\t\tcase 1112:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t{\n\t\t\t\treturn L\"msql\";\n\t\t\t}\n\t\t\telse if (proto == IPPROTO_UDP)\n\t\t\t{\n\t\t\t\treturn L\"icp\";\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 1114:\n\t\tcase 4333:\n\t\t\treturn L\"mini-sql\";\n\n\t\tcase 1119:\n\t\t\treturn L\"bnetgame\";\n\n\t\tcase 1120:\n\t\t\treturn L\"bnetfile\";\n\n\t\tcase 1121:\n\t\t\treturn L\"rmpp\";\n\n\t\tcase 1123:\n\t\t\treturn L\"murray\";\n\n\t\tcase 1130:\n\t\t\treturn L\"casp\";\n\n\t\tcase 1131:\n\t\t\treturn L\"caspssl\";\n\n\t\tcase 1138:\n\t\t\treturn L\"encrypted_admin\";\n\n\t\tcase 1147:\n\t\t\treturn L\"capioverlan\";\n\n\t\tcase 1150:\n\t\t\treturn L\"blaze\";\n\n\t\tcase 1153:\n\t\t\treturn L\"c1222-acse\";\n\n\t\tcase 1155:\n\t\t\treturn L\"nfa\";\n\n\t\tcase 1159:\n\t\t\treturn L\"oracle-oms\";\n\n\t\tcase 1164:\n\t\t\treturn L\"qsm-proxy\";\n\n\t\tcase 1165:\n\t\t\treturn L\"qsm-gui\";\n\n\t\tcase 1166:\n\t\t\treturn L\"qsm-remote\";\n\n\t\tcase 1168:\n\t\t\treturn L\"vchat\";\n\n\t\tcase 1183:\n\t\t\treturn L\"llsurfup-http\";\n\n\t\tcase 1184:\n\t\t\treturn L\"llsurfup-https\";\n\n\t\tcase 1186:\n\t\t\treturn L\"mysql-cluster\";\n\n\t\tcase 1187:\n\t\t\treturn L\"alias\";\n\n\t\tcase 1188:\n\t\t\treturn L\"hp-webadmin\";\n\n\t\tcase 1194:\n\t\t\treturn L\"openvpn\";\n\n\t\tcase 1214:\n\t\t\treturn L\"fasttrack\"; // kazaa\n\n\t\tcase 1220:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t{\n\t\t\t\treturn L\"quicktime\";\n\t\t\t}\n\t\t\telse if (proto == IPPROTO_UDP)\n\t\t\t{\n\t\t\t\treturn L\"qt-serveradmin\";\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 1234:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t{\n\t\t\t\treturn L\"hotline\";\n\t\t\t}\n\t\t\telse if (proto == IPPROTO_UDP)\n\t\t\t{\n\t\t\t\treturn L\"search-agent\";\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 1257:\n\t\t\treturn L\"shockwave2\";\n\n\t\tcase 1258:\n\t\t\treturn L\"opennl\";\n\n\t\tcase 1259:\n\t\t\treturn L\"opennl-voice\";\n\n\t\tcase 1270:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t{\n\t\t\t\treturn L\"ssserver\";\n\t\t\t}\n\t\t\telse if (proto == IPPROTO_UDP)\n\t\t\t{\n\t\t\t\treturn L\"opsmgr\"; // Microsoft Operations Manager\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 1273:\n\t\t\treturn L\"emc-gateway\";\n\n\t\tcase 1307:\n\t\t\treturn L\"pacmand\";\n\n\t\tcase 1311:\n\t\t\treturn L\"rxmon\";\n\n\t\tcase 1318:\n\t\t\treturn L\"krb5gatekeeper\";\n\n\t\tcase 1321:\n\t\t\treturn L\"pip\";\n\n\t\tcase 1333:\n\t\t\treturn L\"passwrd-policy\";\n\n\t\tcase 1336:\n\t\t\treturn L\"ischat\";\n\n\t\tcase 1337:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t{\n\t\t\t\treturn L\"waste\";\n\t\t\t}\n\t\t\telse if (proto == IPPROTO_UDP)\n\t\t\t{\n\t\t\t\treturn L\"menandmice-dns\";\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 1368:\n\t\t\treturn L\"screencast\";\n\n\t\tcase 1380:\n\t\t\treturn L\"telesis-licman\";\n\n\t\tcase 1381:\n\t\t\treturn L\"apple-licman\";\n\n\t\tcase 1384:\n\t\t\treturn L\"os-licman\";\n\n\t\tcase 1433:\n\t\t\treturn L\"ms-sql-s\";\n\n\t\tcase 1434:\n\t\t\treturn L\"ms-sql-m\";\n\n\t\tcase 1462:\n\t\t\treturn L\"world-lm\";\n\n\t\tcase 1498:\n\t\t\treturn L\"watcom-sql\";\n\n\t\tcase 1525:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t{\n\t\t\t\treturn L\"orasrv\";\n\t\t\t}\n\t\t\telse if (proto == IPPROTO_UDP)\n\t\t\t{\n\t\t\t\treturn L\"oracle\";\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 1529:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t{\n\t\t\t\treturn L\"support\";\n\t\t\t}\n\t\t\telse if (proto == IPPROTO_UDP)\n\t\t\t{\n\t\t\t\treturn L\"coauthor\";\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 1590:\n\t\t\treturn L\"gemini-lm\";\n\n\t\tcase 1630:\n\t\t\treturn L\"oraclenet8cman\";\n\n\t\tcase 1687:\n\t\t\treturn L\"nsjtp-ctrl\";\n\n\t\tcase 1688:\n\t\t\treturn L\"nsjtp-data\";\n\n\t\tcase 1689:\n\t\t\treturn L\"firefox\";\n\n\t\tcase 1701:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t{\n\t\t\t\treturn L\"l2f\";\n\t\t\t}\n\t\t\telse if (proto == IPPROTO_UDP)\n\t\t\t{\n\t\t\t\treturn L\"L2TP\";\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 1702:\n\t\t\treturn L\"deskshare\";\n\n\t\tcase 1720:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t{\n\t\t\t\treturn L\"h323q931\";\n\t\t\t}\n\t\t\telse if (proto == IPPROTO_UDP)\n\t\t\t{\n\t\t\t\treturn L\"h323q931\";\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 1723:\n\t\t\treturn L\"pptp\";\n\n\t\tcase 1726:\n\t\t\treturn L\"iberiagames\";\n\n\t\tcase 1733:\n\t\t\treturn L\"siipat\";\n\n\t\tcase 1745:\n\t\t\treturn L\"remote-winsock\";\n\n\t\tcase 1748:\n\t\t\treturn L\"oracle-em1\";\n\n\t\tcase 1750:\n\t\t\treturn L\"sslp\";\n\n\t\tcase 1755:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t{\n\t\t\t\treturn L\"wms\";\n\t\t\t}\n\t\t\telse if (proto == IPPROTO_UDP)\n\t\t\t{\n\t\t\t\treturn L\"ms-streaming\";\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 1758:\n\t\t\treturn L\"tftp-mcast\";\n\n\t\tcase 1761:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t{\n\t\t\t\treturn L\"landesk-rc\";\n\t\t\t}\n\t\t\telse if (proto == IPPROTO_UDP)\n\t\t\t{\n\t\t\t\treturn L\"cft-0\";\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 1762:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t{\n\t\t\t\treturn L\"landesk-rc\";\n\t\t\t}\n\t\t\telse if (proto == IPPROTO_UDP)\n\t\t\t{\n\t\t\t\treturn L\"cft-1\";\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 1763:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t{\n\t\t\t\treturn L\"landesk-rc\";\n\t\t\t}\n\t\t\telse if (proto == IPPROTO_UDP)\n\t\t\t{\n\t\t\t\treturn L\"cft-2\";\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 1764:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t{\n\t\t\t\treturn L\"landesk-rc\";\n\t\t\t}\n\t\t\telse if (proto == IPPROTO_UDP)\n\t\t\t{\n\t\t\t\treturn L\"cft-3\";\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 1789:\n\t\t\treturn L\"hello\";\n\n\t\tcase 1793:\n\t\t\treturn L\"rsc-robot\";\n\n\t\tcase 1795:\n\t\t\treturn L\"dpi-proxy\";\n\n\t\tcase 1801:\n\t\t\treturn L\"msmq\"; // Microsoft Message Queuing\n\n\t\tcase 1833:\n\t\t\treturn L\"udpradio\";\n\n\t\tcase 1850:\n\t\t\treturn L\"gsi\";\n\n\t\tcase 1862:\n\t\t\treturn L\"mysql-cm-agent\";\n\n\t\tcase 1863:\n\t\t\treturn L\"msnp\"; // MSN Messenger\n\n\t\tcase 1900:\n\t\tcase 5000:\n\t\t\treturn L\"upnp\";\n\n\t\tcase 1931:\n\t\t\treturn L\"amdsched\";\n\n\t\tcase 1981:\n\t\t\treturn L\"p2pq\";\n\n\t\tcase 2000:\n\t\t\treturn L\"cisco-sccp\";\n\n\t\tcase 2001:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t{\n\t\t\t\treturn L\"dc\";\n\t\t\t}\n\t\t\telse if (proto == IPPROTO_UDP)\n\t\t\t{\n\t\t\t\treturn L\"wizard\";\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 2009:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t{\n\t\t\t\treturn L\"news\";\n\t\t\t}\n\t\t\telse if (proto == IPPROTO_UDP)\n\t\t\t{\n\t\t\t\treturn L\"whosockami\";\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 2019:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t{\n\t\t\t\treturn L\"whosockami\";\n\t\t\t}\n\t\t\telse if (proto == IPPROTO_UDP)\n\t\t\t{\n\t\t\t\treturn L\"about\";\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 2054:\n\t\t\treturn L\"weblogin\";\n\n\t\tcase 2086:\n\t\t\treturn L\"gnunet\";\n\n\t\tcase 2105:\n\t\t\treturn L\"eklogin\"; // kerberos\n\n\t\tcase 2106:\n\t\t\treturn L\"ekshell\"; // kerberos\n\n\t\tcase 2115:\n\t\t\treturn L\"kdm\"; // Key Distribution Manager\n\n\t\tcase 2121:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t{\n\t\t\t\treturn L\"ccproxy-ftp\";\n\t\t\t}\n\t\t\telse if (proto == IPPROTO_UDP)\n\t\t\t{\n\t\t\t\treturn L\"scientia-ssdb\";\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 2129:\n\t\t\treturn L\"cs-live\";\n\n\t\tcase 2137:\n\t\t\treturn L\"connect\";\n\n\t\tcase 2142:\n\t\t\treturn L\"tdmoip\";\n\n\t\tcase 2159:\n\t\t\treturn L\"gdbremote\";\n\n\t\tcase 2164:\n\t\t\treturn L\"ddns-v3\"; // Dynamic DNS Version 3\n\n\t\tcase 2167:\n\t\t\treturn L\"raw-serial\"; // Raw Async Serial Link\n\n\t\tcase 2171:\n\t\t\treturn L\"msfw-storage\"; // MS Firewall Storage\n\n\t\tcase 2172:\n\t\t\treturn L\"msfw-s-storage\"; // MS Firewall SecureStorage\n\n\t\tcase 2173:\n\t\t\treturn L\"msfw-replica\"; // MS Firewall Replication\n\n\t\tcase 2174:\n\t\t\treturn L\"msfw-array\"; // MS Firewall Intra Array\n\n\t\tcase 2175:\n\t\t\treturn L\"ms-airsync\"; // Microsoft Desktop AirSync Protocol\n\n\t\tcase 2179:\n\t\t\treturn L\"ms-vmrdp\"; // Microsoft RDP for virtual machines\n\n\t\tcase 2191:\n\t\t\treturn L\"tvbus\";\n\n\t\tcase 2193:\n\t\t\treturn L\"drwcs\"; // Dr.Web Enterprise Management Service\n\n\t\tcase 2213:\n\t\t\treturn L\"kali\";\n\n\t\tcase 2273:\n\t\t\treturn L\"mysql-im\"; // MySQL Instance Manager\n\n\t\tcase 2311:\n\t\t\treturn L\"messageservice\"; // Message Service\n\n\t\tcase 2169:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t\treturn L\"bif-p2p\";\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 2374:\n\t\t\treturn L\"hydra\";\n\n\t\tcase 2375:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t\treturn L\"docker\";\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 2376:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t\treturn L\"docker\";\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 2377:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t\treturn L\"swarm\";\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 2382:\n\t\t\treturn L\"ms-olap3\"; // Microsoft OLAP\n\n\t\tcase 2383:\n\t\t\treturn L\"ms-olap4\"; // Microsoft OLAP\n\n\t\tcase 2525:\n\t\t\treturn L\"ms-v-worlds\"; // MS V-Worlds\n\n\t\tcase 2679:\n\t\t\treturn L\"syncserverssl\";\n\n\t\tcase 2710:\n\t\t\treturn L\"sso-service\";\n\n\t\tcase 2711:\n\t\t\treturn L\"sso-control\";\n\n\t\tcase 2717:\n\t\t\treturn L\"pn-requester\";\n\n\t\tcase 2718:\n\t\t\treturn L\"pn-requester2\";\n\n\t\tcase 2723:\n\t\t\treturn L\"watchdog-nt\";\n\n\t\tcase 2725:\n\t\t\treturn L\"msolap-ptp2\";\n\n\t\tcase 2775:\n\t\t\treturn L\"smpp\";\n\n\t\tcase 2784:\n\t\t\treturn L\"www-dev\";\n\n\t\tcase 2869:\n\t\t\treturn L\"icslap\";\n\n\t\tcase 2948:\n\t\t\treturn L\"wap-push\";\n\n\t\tcase 2949:\n\t\t\treturn L\"wap-pushsecure\";\n\n\t\tcase 2947:\n\t\t\treturn L\"symantec-av\";\n\n\t\tcase 2979:\n\t\t\treturn L\"h263-video\";\n\n\t\tcase 3000:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t{\n\t\t\t\treturn L\"ppp\";\n\t\t\t}\n\t\t\tif (proto == IPPROTO_UDP)\n\t\t\t{\n\t\t\t\treturn L\"hbci\";\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 3074:\n\t\t\treturn L\"xbox\";\n\n\t\tcase 3128:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t\treturn L\"squid-http\";\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 3224:\n\t\t\treturn L\"aes-discovery\";\n\n\t\tcase 3260:\n\t\t\treturn L\"iscsi\";\n\n\t\tcase 3295:\n\t\t\treturn L\"dyniplookup\";\n\n\t\tcase 3306:\n\t\t\treturn L\"mysql\";\n\n\t\tcase 3326:\n\t\t\treturn L\"sftu\"; // ;)\n\n\t\tcase 3343:\n\t\t\treturn L\"ms-cluster-net\";\n\n\t\tcase 3352:\n\t\t\treturn L\"ssql\"; // Scalable SQL\n\n\t\tcase 3389:\n\t\t\treturn L\"ms-wbt-server\"; // Microsoft Remote Display Protocol (aka ms-term-serv, microsoft-rdp)\n\n\t\tcase 3407:\n\t\t\treturn L\"ldap-admin\";\n\n\t\tcase 3476:\n\t\t\treturn L\"nppmp\"; // NVIDIA Mgmt Protocol\n\n\t\tcase 3500:\n\t\t\treturn L\"rtmp-port\";\n\n\t\tcase 3535:\n\t\t\treturn L\"ms-la\";\n\n\t\tcase 3540:\n\t\t\treturn L\"pnrp-port\";\n\n\t\tcase 3544:\n\t\t\treturn L\"teredo\";\n\n\t\tcase 3547:\n\t\t\treturn L\"symantec-sim\";\n\n\t\tcase 3550:\n\t\t\treturn L\"ssmpp\"; // Secure SMPP\n\n\t\tcase 3558:\n\t\t\treturn L\"mcp-port\"; // MCP user port\n\n\t\tcase 3559:\n\t\t\treturn L\"cctv-port\"; // CCTV control port\n\n\t\tcase 3563:\n\t\t\treturn L\"watcomdebug\";\n\n\t\tcase 3587:\n\t\t\treturn L\"p2pgroup\";\n\n\t\tcase 3702:\n\t\t\treturn L\"ws-discovery\";\n\n\t\tcase 3713:\n\t\t\treturn L\"tftps\";\n\n\t\tcase 3721:\n\t\t\treturn L\"xsync\";\n\n\t\tcase 3724:\n\t\t\treturn L\"blizwow\";\n\n\t\tcase 4041:\n\t\t\treturn L\"ltp\"; // Location Tracking Protocol\n\n\t\tcase 4180:\n\t\t\treturn L\"httpx\";\n\n\t\tcase 4317:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t\treturn L\"opentelemetry\";\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 4321:\n\t\t\treturn L\"rwhois\"; // Remote Who Is\n\n\t\tcase 4500:\n\t\t{\n\t\t\tif (proto == IPPROTO_UDP)\n\t\t\t\treturn L\"nat-t-ike\";\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 4554:\n\t\t\treturn L\"msfrs\"; // MS FRS Replication\n\n\t\tcase 4687:\n\t\t\treturn L\"nst\"; // Network Scanner Tool FTP\n\n\t\tcase 4876:\n\t\t\treturn L\"tritium-can\";\n\n\t\tcase 4899:\n\t\t\treturn L\"radmin\";\n\n\t\tcase 5004:\n\t\t\treturn L\"rtp-data\";\n\n\t\tcase 5005:\n\t\t\treturn L\"rtp\";\n\n\t\tcase 5009:\n\t\t\treturn L\"airport-admin\";\n\n\t\tcase 5051:\n\t\t\treturn L\"ida-agent\";\n\n\t\tcase 5060:\n\t\t\treturn L\"sip\";\n\n\t\tcase 5101:\n\t\t\treturn L\"admdog\";\n\n\t\tcase 5145:\n\t\t\treturn L\"rmonitor_secure\";\n\n\t\tcase 5190:\n\t\tcase 5191:\n\t\tcase 5192:\n\t\tcase 5193:\n\t\t\treturn L\"aol\";\n\n\t\tcase 5350:\n\t\t\treturn L\"nat-pmp-status\";\n\n\t\tcase 5351:\n\t\t\treturn L\"nat-pmp\";\n\n\t\tcase 5352:\n\t\t\treturn L\"dns-llq\";\n\n\t\tcase 5353:\n\t\t\treturn L\"mdns\";\n\n\t\tcase 5354:\n\t\t\treturn L\"mdnsresponder\";\n\n\t\tcase 5355:\n\t\t\treturn L\"llmnr\";\n\n\t\tcase 5357:\n\t\t\treturn L\"wsdapi\";\n\n\t\tcase 5358:\n\t\t\treturn L\"wsdapi-s\";\n\n\t\tcase 5359:\n\t\t\treturn L\"ms-alerter\";\n\n\t\tcase 5360:\n\t\t\treturn L\"ms-sideshow\";\n\n\t\tcase 5361:\n\t\t\treturn L\"ms-s-sideshow\";\n\n\t\tcase 5362:\n\t\t\treturn L\"serverwsd2\"; // Microsoft Windows Server WSD2 Service\n\n\t\tcase 5432:\n\t\t\treturn L\"postgresql\";\n\n\t\tcase 5631:\n\t\t\treturn L\"pcanywheredata\";\n\n\t\tcase 5632:\n\t\t\treturn L\"pcanywherestat\";\n\n\t\tcase 5666:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t\treturn L\"nrpe\"; // Nagios Remote Plugin Executor\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 5687:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t\treturn L\"gog-multiplayer\";\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 5741:\n\t\t\treturn L\"ida-discover1\";\n\n\t\tcase 5742:\n\t\t\treturn L\"ida-discover2\";\n\n\t\tcase 5800:\n\t\tcase 5801:\n\t\tcase 5802:\n\t\tcase 5803:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t\treturn L\"vnc-http\";\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 5900:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t\treturn L\"vnc\";\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 5901:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t\treturn L\"vnc-1\";\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 5902:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t\treturn L\"vnc-2\";\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 5903:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t\treturn L\"vnc-3\";\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 5938:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t\treturn L\"teamviewer\";\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 6000:\n\t\tcase 6001:\n\t\tcase 6002:\n\t\tcase 6003:\n\t\tcase 6004:\n\t\tcase 6005:\n\t\tcase 6006:\n\t\tcase 6007:\n\t\tcase 6008:\n\t\tcase 6009:\n\t\tcase 6010:\n\t\tcase 6011:\n\t\tcase 6012:\n\t\tcase 6013:\n\t\tcase 6014:\n\t\tcase 6015:\n\t\tcase 6016:\n\t\tcase 6017:\n\t\tcase 6018:\n\t\tcase 6019:\n\t\tcase 6020:\n\t\tcase 6021:\n\t\tcase 6022:\n\t\tcase 6023:\n\t\tcase 6024:\n\t\tcase 6025:\n\t\tcase 6026:\n\t\tcase 6027:\n\t\tcase 6028:\n\t\tcase 6029:\n\t\tcase 6030:\n\t\tcase 6031:\n\t\tcase 6032:\n\t\tcase 6033:\n\t\tcase 6034:\n\t\tcase 6035:\n\t\tcase 6036:\n\t\tcase 6037:\n\t\tcase 6038:\n\t\tcase 6039:\n\t\tcase 6040:\n\t\tcase 6041:\n\t\tcase 6042:\n\t\tcase 6043:\n\t\tcase 6044:\n\t\tcase 6045:\n\t\tcase 6046:\n\t\tcase 6047:\n\t\tcase 6048:\n\t\tcase 6049:\n\t\tcase 6050:\n\t\tcase 6051:\n\t\tcase 6052:\n\t\tcase 6053:\n\t\tcase 6054:\n\t\tcase 6055:\n\t\tcase 6056:\n\t\tcase 6057:\n\t\tcase 6058:\n\t\tcase 6059:\n\t\tcase 6060:\n\t\tcase 6061:\n\t\tcase 6062:\n\t\tcase 6063:\n\t\t\treturn L\"x11\";\n\n\t\tcase 6074:\n\t\t\treturn L\"max\"; // Microsoft Max\n\n\t\tcase 6076:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t\treturn L\"msft-dpm-cert\"; // Microsoft DPM WCF Certificates\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 6222:\n\t\tcase 6662: // deprecated!\n\t\t\treturn L\"radmind\";\n\n\t\tcase 6346:\n\t\t\treturn L\"gnutella\";\n\n\t\tcase 6347:\n\t\t\treturn L\"gnutella2\";\n\n\t\tcase 6620:\n\t\t\treturn L\"kftp-data\"; // Kerberos V5 FTP Data\n\n\t\tcase 6621:\n\t\t\treturn L\"kftp\"; // Kerberos V5 FTP Control\n\n\t\tcase 6622:\n\t\t\treturn L\"mcftp\";\n\n\t\tcase 6665:\n\t\tcase 6666:\n\t\tcase 6667:\n\t\tcase 6668:\n\t\tcase 6669:\n\t\tcase 6670:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t{\n\t\t\t\treturn L\"irc\";\n\t\t\t}\n\t\t\tif (proto == IPPROTO_UDP)\n\t\t\t{\n\t\t\t\treturn L\"ircu\";\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\n\t\tcase 6881:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t\treturn L\"bittorrent-tracker\";\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 7070:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t\treturn L\"realserver\";\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 7235:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t\treturn L\"aspcoordination\";\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 8021:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t\treturn L\"ftp-proxy\";\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 8333:\n\t\tcase 18333:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t\treturn L\"bitcoin\";\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 8443:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t{\n\t\t\t\treturn L\"https-alt\";\n\n\t\t\t}\n\t\t\telse if (proto == IPPROTO_UDP)\n\t\t\t{\n\t\t\t\treturn L\"pcsync-https\";\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 8444:\n\t\t\treturn L\"pcsync-http\";\n\n\t\tcase 8999:\n\t\t\treturn L\"bctp\";\n\n\t\tcase 9418:\n\t\t\treturn L\"git\";\n\n\t\tcase 9800:\n\t\t\treturn L\"davsrc\"; // WebDav Source Port\n\n\t\tcase 10107:\n\t\t\treturn L\"bctp-server\";\n\n\t\tcase 11371:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t{\n\t\t\t\treturn L\"pksd\";\n\n\t\t\t}\n\t\t\telse if (proto == IPPROTO_UDP)\n\t\t\t{\n\t\t\t\treturn L\"hkp\";\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 25565:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t\treturn L\"minecraft\";\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 26000:\n\t\t\treturn L\"quake\";\n\n\t\tcase 27015:\n\t\t{\n\t\t\tif (proto == IPPROTO_UDP)\n\t\t\t\treturn L\"halflife\";\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 27017:\n\t\tcase 27018:\n\t\tcase 27019:\n\t\tcase 28017:\n\t\t{\n\t\t\tif (proto == IPPROTO_TCP)\n\t\t\t\treturn L\"mongod\";\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 27500:\n\t\t{\n\t\t\tif (proto == IPPROTO_UDP)\n\t\t\t\treturn L\"quakeworld\";\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 27910:\n\t\t{\n\t\t\tif (proto == IPPROTO_UDP)\n\t\t\t\treturn L\"quake2\";\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 27960:\n\t\t{\n\t\t\tif (proto == IPPROTO_UDP)\n\t\t\t\treturn L\"quake3\";\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase 28240:\n\t\t\treturn L\"siemensgsm\";\n\n\t\tcase 33434:\n\t\t\treturn L\"traceroute\";\n\t}\n\n\treturn NULL;\n}\n"
  },
  {
    "path": "src/db.h",
    "content": "// simplewall\n// Copyright (c) 2019-2025 Henry++\n\n#pragma once\n\n// profile types\ntypedef enum _ENUM_TYPE_XML\n{\n\tXML_TYPE_PROFILE = 3,\n\tXML_TYPE_PROFILE_INTERNAL = 4,\n} ENUM_TYPE_XML;\n\n// profile versions\ntypedef enum _ENUM_VERSION_XML\n{\n\t// v3.0.2: first major update, rule attribute \"apps\" now separated by \"|\"\n\tXML_VERSION_3 = 3,\n\n\t// v3.4: added \"rules_custom\" into internal profile and \"os_version\" for rule attributes\n\tXML_VERSION_4 = 4,\n\n\t// v3.7: added hashes support, use encrypted file format and added comments for apps/rules\n\tXML_VERSION_5 = 5,\n} ENUM_VERSION_XML;\n\ntypedef struct _DB_INFORMATION\n{\n\tR_XML_LIBRARY xml_library;\n\n\tPR_BYTE bytes;\n\tPR_BYTE hash;\n\n\tLONG64 timestamp;\n\n\tENUM_VERSION_XML version;\n\tENUM_TYPE_XML type;\n} DB_INFORMATION, *PDB_INFORMATION;\n\n// Offset\tLength\tDescription\n// ------------------------------------------\n// 0\t\t3\t\tFOURCC string 'SWC'\n// 4\t\t1\t\tBody information flag\n// 36\t\t32\t\tSHA256 checksum of the decrypted bytes\n// 68\t\twhole\tBody contained specified data\n\nstatic const BYTE profile2_fourcc[] = {\n\t0x53, 0x57, 0x43, // 'S', 'W', 'C'\n};\n\nstatic const BYTE profile2_fourcc_old[] = {\n\t0x73, 0x77, 0x63, // 's', 'w', 'c'\n};\n\n#define XML_VERSION_MINIMAL XML_VERSION_3\n#define XML_VERSION_CURRENT XML_VERSION_4\n#define XML_VERSION_MAXIMUM XML_VERSION_5\n\n#define XML_PROFILE_FILE L\"profile.xml\"\n#define XML_PROFILE_INTERNAL L\"profile_internal.xml\"\n\n#define PROFILE2_ID_PLAIN ((BYTE)(0x30))\n#define PROFILE2_ID_COMPRESSED ((BYTE)(0x31))\n#define PROFILE2_ID_ENCRYPTED ((BYTE)(0x32))\n\n#define PROFILE2_KEY \"Gc(j1EptodnKP?{ZT!SlMVip[fJIs&Ci3fOqjATfp@h,q0(]QVaGs5Iht3)/b:Ll\"\n\n#define PROFILE2_FOURCC_LENGTH sizeof (profile2_fourcc) + sizeof (BYTE)\n#define PROFILE2_SHA256_LENGTH 32UL\n#define PROFILE2_HEADER_LENGTH (PROFILE2_FOURCC_LENGTH + PROFILE2_SHA256_LENGTH)\n\n_Success_ (SUCCEEDED (return))\nHRESULT _app_db_initialize (\n\t_Out_ PDB_INFORMATION db_info,\n\t_In_ BOOLEAN is_reader\n);\n\nVOID _app_db_destroy (\n\t_Inout_ PDB_INFORMATION db_info\n);\n\n_Success_ (NT_SUCCESS (return))\nNTSTATUS _app_db_encrypt (\n\t_In_ PR_BYTEREF bytes,\n\t_Out_ PR_BYTE_PTR out_buffer\n);\n\n_Success_ (NT_SUCCESS (return))\nNTSTATUS _app_db_decrypt (\n\t_In_ PR_BYTEREF buffer,\n\t_Out_ PR_BYTE_PTR out_buffer\n);\n\n_Success_ (NT_SUCCESS (return))\nNTSTATUS _app_db_gethash (\n\t_In_ PR_BYTEREF bytes,\n\t_Out_ PR_BYTE_PTR out_buffer\n);\n\nBYTE _app_getprofiletype ();\n\n_Success_ (NT_SUCCESS (return))\nNTSTATUS _app_db_ishashvalid (\n\t_In_ PR_BYTEREF buffer,\n\t_In_ PR_BYTEREF hash_bytes\n);\n\n_Success_ (NT_SUCCESS (return))\nNTSTATUS _app_db_openfrombuffer (\n\t_Inout_ PDB_INFORMATION db_info,\n\t_In_ PR_STORAGE buffer,\n\t_In_ ENUM_VERSION_XML min_version,\n\t_In_ ENUM_TYPE_XML type\n);\n\n_Success_ (NT_SUCCESS (return))\nNTSTATUS _app_db_openfromfile (\n\t_Inout_ PDB_INFORMATION db_info,\n\t_In_ PR_STRING path,\n\t_In_ ENUM_VERSION_XML min_version,\n\t_In_ ENUM_TYPE_XML type\n);\n\n_Success_ (NT_SUCCESS (return))\nNTSTATUS _app_db_decodebody (\n\t_Inout_ PDB_INFORMATION db_info\n);\n\n_Success_ (NT_SUCCESS (return))\nNTSTATUS _app_db_encodebody (\n\t_Inout_ PDB_INFORMATION db_info,\n\t_In_ BYTE profile_type,\n\t_Out_ PR_BYTE_PTR out_buffer\n);\n\n_Success_ (NT_SUCCESS (return))\nNTSTATUS _app_db_generatebody (\n\t_In_ BYTE profile_type,\n\t_In_ PR_BYTE hash_value,\n\t_In_ PR_BYTE buffer,\n\t_Out_ PR_BYTE_PTR out_buffer\n);\n\n_Success_ (NT_SUCCESS (return))\nNTSTATUS _app_db_decodebuffer (\n\t_Inout_ PDB_INFORMATION db_info,\n\t_In_ ENUM_TYPE_XML type,\n\t_In_ ENUM_VERSION_XML min_version\n);\n\nBOOLEAN _app_db_parse (\n\t_Inout_ PDB_INFORMATION db_info,\n\t_In_ ENUM_TYPE_XML type\n);\n\nVOID _app_db_parse_app (\n\t_Inout_ PDB_INFORMATION db_info\n);\n\nVOID _app_db_parse_rule (\n\t_Inout_ PDB_INFORMATION db_info,\n\t_In_ ENUM_TYPE_DATA type\n);\n\nVOID _app_db_parse_ruleconfig (\n\t_Inout_ PDB_INFORMATION db_info\n);\n\n_Success_ (NT_SUCCESS (return))\nNTSTATUS _app_db_savetofile (\n\t_Inout_ PDB_INFORMATION db_info,\n\t_In_ PR_STRING path,\n\t_In_ ENUM_VERSION_XML version,\n\t_In_ ENUM_TYPE_XML type,\n\t_In_ LONG64 timestamp\n);\n\n_Success_ (NT_SUCCESS (return))\nNTSTATUS _app_db_save_streamtofile (\n\t_Inout_ PDB_INFORMATION db_info,\n\t_In_ PR_STRING path\n);\n\nVOID _app_db_save_app (\n\t_Inout_ PDB_INFORMATION db_info\n);\n\nVOID _app_db_save_rule (\n\t_Inout_ PDB_INFORMATION db_info\n);\n\nVOID _app_db_save_ruleconfig (\n\t_Inout_ PDB_INFORMATION db_info\n);\n\n_Ret_maybenull_\nLPCWSTR _app_db_getconnectionstatename (\n\t_In_ ULONG state\n);\n\n_Ret_maybenull_\nPR_STRING _app_db_getdirectionname (\n\t_In_ FWP_DIRECTION direction,\n\t_In_ BOOLEAN is_loopback,\n\t_In_ BOOLEAN is_localized\n);\n\nLPCWSTR _app_db_getprotoname (\n\t_In_ ULONG proto,\n\t_In_ ADDRESS_FAMILY af\n);\n\n_Ret_maybenull_\nLPCWSTR _app_db_getservicename (\n\t_In_ UINT16 port,\n\t_In_ UINT8 proto\n);\n"
  },
  {
    "path": "src/editor.c",
    "content": "// simplewall\r\n// Copyright (c) 2016-2025 Henry++\r\n\r\n#include \"global.h\"\r\n\r\n_Ret_maybenull_\r\nPEDITOR_CONTEXT _app_editor_createwindow (\r\n\t_In_ HWND hwnd,\r\n\t_In_ PVOID lparam,\r\n\t_In_ INT page_id,\r\n\t_In_ BOOLEAN is_settorules\r\n)\r\n{\r\n\tPEDITOR_CONTEXT context;\r\n\r\n\tcontext = _r_mem_allocate (sizeof (EDITOR_CONTEXT));\r\n\r\n\tcontext->ptr_app = lparam;\r\n\tcontext->page_id = page_id;\r\n\tcontext->is_settorules = is_settorules;\r\n\r\n\tif (_r_wnd_createmodalwindow (_r_sys_getimagebase (), MAKEINTRESOURCE (IDD_EDITOR), hwnd, &EditorProc, context))\r\n\t\treturn context;\r\n\r\n\t_app_editor_deletewindow (context);\r\n\r\n\treturn NULL;\r\n}\r\n\r\nVOID _app_editor_deletewindow (\r\n\t_In_ PEDITOR_CONTEXT context\r\n)\r\n{\r\n\t_r_mem_free (context);\r\n}\r\n\r\n_Ret_maybenull_\r\nPEDITOR_CONTEXT _app_editor_getcontext (\r\n\t_In_ HWND hwnd\r\n)\r\n{\r\n\tPEDITOR_CONTEXT context;\r\n\r\n\tcontext = _r_wnd_getcontext (hwnd, SHORT_MAX);\r\n\r\n\treturn context;\r\n}\r\n\r\nVOID _app_editor_setcontext (\r\n\t_In_ HWND hwnd,\r\n\t_In_ PEDITOR_CONTEXT context\r\n)\r\n{\r\n\t_r_wnd_setcontext (hwnd, SHORT_MAX, context);\r\n}\r\n\r\nVOID _app_editor_addtabitem (\r\n\t_In_ HWND hwnd,\r\n\t_In_ UINT locale_id,\r\n\t_In_ INT dlg_id,\r\n\t_In_ PEDITOR_CONTEXT context\r\n)\r\n{\r\n\tHWND htab;\r\n\r\n\thtab = _r_wnd_createwindow (_r_sys_getimagebase (), MAKEINTRESOURCE (dlg_id), hwnd, &EditorPagesProc, context);\r\n\r\n\tif (!htab)\r\n\t\treturn;\r\n\r\n\t_r_tab_additem (hwnd, IDC_TAB, INT_ERROR, _r_locale_getstring (locale_id), I_DEFAULT, (LPARAM)htab);\r\n\r\n\t_r_tab_adjustchild (hwnd, IDC_TAB, htab);\r\n\r\n\tBringWindowToTop (htab); // HACK!!!\r\n\r\n\t_r_wnd_sendmessage (htab, 0, RM_INITIALIZE, 0, 0);\r\n}\r\n\r\nVOID _app_editor_settabtitle (\r\n\t_In_ HWND hwnd,\r\n\t_In_ INT listview_id\r\n)\r\n{\r\n\tWCHAR buffer[128];\r\n\tHWND hparent;\r\n\tUINT locale_id;\r\n\tINT checked_count;\r\n\tINT tab_id;\r\n\r\n\tif (listview_id == IDC_RULE_APPS_ID)\r\n\t{\r\n\t\tlocale_id = IDS_TAB_APPS;\r\n\t\ttab_id = 2;\r\n\t}\r\n\telse if (listview_id == IDC_APP_RULES_ID)\r\n\t{\r\n\t\tlocale_id = IDS_TRAY_RULES;\r\n\t\ttab_id = 1;\r\n\t}\r\n\telse\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\r\n\thparent = GetParent (hwnd);\r\n\r\n\tif (!hparent)\r\n\t\treturn;\r\n\r\n\tchecked_count = _r_listview_getitemcheckedcount (hwnd, listview_id);\r\n\r\n\t_r_str_printf (buffer, RTL_NUMBER_OF (buffer), L\"%s (%d)\", _r_locale_getstring (locale_id), checked_count);\r\n\r\n\t_r_tab_setitem (hparent, IDC_TAB, tab_id, buffer, I_DEFAULT, I_DEFAULT);\r\n}\r\n\r\n_Ret_maybenull_\r\nPR_STRING _app_editor_getrulesfromlistview (\r\n\t_In_ HWND hwnd,\r\n\t_In_ INT ctrl_id,\r\n\t_In_ INT exclude_id\r\n)\r\n{\r\n\tR_STRINGREF divider_sr = PR_STRINGREF_INIT (DIVIDER_RULE);\r\n\tR_STRINGBUILDER sb;\r\n\tPR_STRING string;\r\n\tINT item_count;\r\n\r\n\titem_count = _r_listview_getitemcount (hwnd, ctrl_id);\r\n\r\n\tif (!item_count)\r\n\t\treturn NULL;\r\n\r\n\t_r_obj_initializestringbuilder (&sb, 512);\r\n\r\n\tfor (INT i = 0; i < item_count; i++)\r\n\t{\r\n\t\tif (i == exclude_id)\r\n\t\t\tcontinue;\r\n\r\n\t\tstring = _r_listview_getitemtext (hwnd, ctrl_id, i, 0);\r\n\r\n\t\tif (string)\r\n\t\t{\r\n\t\t\t_r_str_trimstring2 (&string->sr, DIVIDER_RULE DIVIDER_TRIM, 0);\r\n\r\n\t\t\tif (!_r_obj_isstringempty2 (string))\r\n\t\t\t{\r\n\t\t\t\t// check maximum length of one rule\r\n\t\t\t\tif ((_r_str_getlength2 (&sb.string->sr) + _r_str_getlength2 (&string->sr)) > RULE_RULE_CCH_MAX)\r\n\t\t\t\t{\r\n\t\t\t\t\t_r_obj_dereference (string);\r\n\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\r\n\t\t\t\t_r_obj_appendstringbuilder2 (&sb, &string->sr);\r\n\t\t\t\t_r_obj_appendstringbuilder2 (&sb, &divider_sr);\r\n\t\t\t}\r\n\r\n\t\t\t_r_obj_dereference (string);\r\n\t\t}\r\n\t}\r\n\r\n\tstring = _r_obj_finalstringbuilder (&sb);\r\n\r\n\t_r_str_trimstring (&string->sr, &divider_sr, PR_TRIM_END_ONLY);\r\n\r\n\tif (_r_obj_isstringempty2 (string))\r\n\t{\r\n\t\t_r_obj_dereference (string);\r\n\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\treturn string;\r\n}\r\n\r\nVOID _app_editor_setrulestolistview (\r\n\t_In_ HWND hwnd,\r\n\t_In_ INT ctrl_id,\r\n\t_In_ PR_STRING rule\r\n)\r\n{\r\n\tPR_STRING rule_string;\r\n\tR_STRINGREF first_part;\r\n\tR_STRINGREF remaining_part;\r\n\tINT item_id = 0;\r\n\r\n\t_r_obj_initializestringref2 (&remaining_part, &rule->sr);\r\n\r\n\twhile (remaining_part.length != 0)\r\n\t{\r\n\t\t_r_str_splitatchar (&remaining_part, DIVIDER_RULE[0], &first_part, &remaining_part);\r\n\r\n\t\trule_string = _r_obj_createstring2 (&first_part);\r\n\r\n\t\t_app_listview_lock (hwnd, ctrl_id, TRUE);\r\n\t\t_r_listview_additem (hwnd, ctrl_id, item_id, rule_string->buffer, I_DEFAULT, I_DEFAULT, I_DEFAULT);\r\n\t\t_app_listview_lock (hwnd, ctrl_id, FALSE);\r\n\r\n\t\titem_id += 1;\r\n\r\n\t\t_r_obj_dereference (rule_string);\r\n\t}\r\n\r\n\t_r_listview_setcolumn (hwnd, ctrl_id, 0, NULL, -100);\r\n}\r\n\r\nINT_PTR CALLBACK EditorRuleProc (\r\n\t_In_ HWND hwnd,\r\n\t_In_ UINT msg,\r\n\t_In_ WPARAM wparam,\r\n\t_In_ LPARAM lparam\r\n)\r\n{\r\n\tPEDITOR_CONTEXT context;\r\n\r\n\tswitch (msg)\r\n\t{\r\n\t\tcase WM_INITDIALOG:\r\n\t\t{\r\n\t\t\tPR_STRING string;\r\n\r\n\t\t\tcontext = (PEDITOR_CONTEXT)lparam;\r\n\r\n\t\t\t_app_editor_setcontext (hwnd, context);\r\n\r\n\t\t\t_r_wnd_center (hwnd, GetParent (hwnd));\r\n\r\n\t\t\t// localize window\r\n\t\t\t_r_ctrl_setstring (hwnd, 0, _r_locale_getstring (IDS_RULE));\r\n\r\n\t\t\t_r_edit_settextlimit (\r\n\t\t\t\thwnd,\r\n\t\t\t\tIDC_RULE_ID,\r\n\t\t\t\t_r_calc_clamp (RULE_RULE_CCH_MAX - (LONG)(context->current_length) - 1, 1, RULE_RULE_CCH_MAX)\r\n\t\t\t);\r\n\r\n\t\t\t_r_edit_setcuebanner (hwnd, IDC_RULE_ID, L\"Example: 192.168.0.1;192.168.0.17\");\r\n\r\n\t\t\tif (context->item_id != INT_ERROR)\r\n\t\t\t{\r\n\t\t\t\tstring = _r_listview_getitemtext (context->hwnd, context->listview_id, context->item_id, 0);\r\n\r\n\t\t\t\tif (string)\r\n\t\t\t\t{\r\n\t\t\t\t\t_r_ctrl_setstring (hwnd, IDC_RULE_ID, string->buffer);\r\n\r\n\t\t\t\t\t_r_obj_dereference (string);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\t_r_ctrl_setstring (\r\n\t\t\t\thwnd,\r\n\t\t\t\tIDC_RULE_HINT,\r\n\t\t\t\tL\"eg. 192.168.0.1; 192.168.0.1; [fc00::]\\r\\neg. 192.168.0.1:80; 192.168.0.1:443; [fc00::]:443;\\r\\n\"\\\r\n\t\t\t\tL\"eg. 192.168.0.1-192.168.0.255; 192.168.0.1-192.168.0.255;\\r\\neg. 192.168.0.1-192.168.0.255:80; 192.168.0.1-192.168.0.255:443;\\r\\n\"\\\r\n\t\t\t\tL\"eg. 192.168.0.0/16; 192.168.0.0/24; fe80::/10;\\r\\n\"\\\r\n\t\t\t\tL\"eg. 20-21; 49152-65534;\\r\\neg. 21; 80; 443\\r\\n\"\r\n\t\t\t);\r\n\r\n\t\t\t_r_ctrl_setstring (\r\n\t\t\t\thwnd,\r\n\t\t\t\tIDC_SAVE,\r\n\t\t\t\t_r_locale_getstring (context->item_id != INT_ERROR ? IDS_SAVE : IDS_ADD)\r\n\t\t\t);\r\n\r\n\t\t\t_r_ctrl_setstring (hwnd, IDC_CLOSE, _r_locale_getstring (IDS_CLOSE));\r\n\r\n\t\t\t// enable save button\r\n\t\t\t_r_ctrl_enable (hwnd, IDC_SAVE, _r_ctrl_getstringlength (hwnd, IDC_RULE_ID) != 0);\r\n\r\n\t\t\t_r_theme_initialize (hwnd);\r\n\r\n\t\t\tSetFocus (NULL);\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase WM_CLOSE:\r\n\t\t{\r\n\t\t\tEndDialog (hwnd, FALSE);\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase WM_PAINT:\r\n\t\t{\r\n\t\t\tPAINTSTRUCT ps;\r\n\t\t\tHDC hdc;\r\n\r\n\t\t\thdc = BeginPaint (hwnd, &ps);\r\n\r\n\t\t\tif (!hdc)\r\n\t\t\t\tbreak;\r\n\r\n\t\t\t_r_dc_drawwindow (hdc, hwnd, TRUE);\r\n\r\n\t\t\tEndPaint (hwnd, &ps);\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase WM_DPICHANGED:\r\n\t\t{\r\n\t\t\t_r_wnd_message_dpichanged (hwnd, wparam, lparam);\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase WM_SETTINGCHANGE:\r\n\t\t{\r\n\t\t\t_r_wnd_message_settingchange (hwnd, wparam, lparam);\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase WM_COMMAND:\r\n\t\t{\r\n\t\t\tINT ctrl_id = LOWORD (wparam);\r\n\t\t\tINT notify_code = HIWORD (wparam);\r\n\r\n\t\t\tif (notify_code == EN_CHANGE)\r\n\t\t\t{\r\n\t\t\t\t// enable save button\r\n\t\t\t\t_r_ctrl_enable (hwnd, IDC_SAVE, _r_ctrl_getstringlength (hwnd, IDC_RULE_ID) != 0);\r\n\r\n\t\t\t\treturn FALSE;\r\n\t\t\t}\r\n\t\t\telse if (notify_code == EN_MAXTEXT)\r\n\t\t\t{\r\n\t\t\t\t_r_ctrl_showballoontip (hwnd, ctrl_id, 0, NULL, _r_locale_getstring (IDS_LIMIT_REACHED));\r\n\r\n\t\t\t\treturn FALSE;\r\n\t\t\t}\r\n\r\n\t\t\tswitch (ctrl_id)\r\n\t\t\t{\r\n\t\t\t\tcase IDOK: // process Enter key\r\n\t\t\t\tcase IDC_SAVE:\r\n\t\t\t\t{\r\n\t\t\t\t\tITEM_ADDRESS address;\r\n\t\t\t\t\tR_STRINGREF remaining_part;\r\n\t\t\t\t\tR_STRINGREF first_part;\r\n\t\t\t\t\tWCHAR rule_string[256];\r\n\t\t\t\t\tPR_STRING string;\r\n\t\t\t\t\tINT item_id;\r\n\r\n\t\t\t\t\tif (!_r_ctrl_isenabled (hwnd, IDC_SAVE))\r\n\t\t\t\t\t\treturn FALSE;\r\n\r\n\t\t\t\t\tstring = _r_ctrl_getstring (hwnd, IDC_RULE_ID);\r\n\r\n\t\t\t\t\tif (!string)\r\n\t\t\t\t\t\treturn FALSE;\r\n\r\n\t\t\t\t\t_r_str_trimstring2 (&string->sr, DIVIDER_TRIM DIVIDER_RULE, 0);\r\n\r\n\t\t\t\t\tif (_r_obj_isstringempty2 (string))\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t_r_ctrl_showballoontip (hwnd, IDC_RULE_ID, 0, NULL, _r_locale_getstring (IDS_STATUS_EMPTY));\r\n\t\t\t\t\t\t_r_ctrl_enable (hwnd, IDC_SAVE, FALSE);\r\n\r\n\t\t\t\t\t\t_r_obj_dereference (string);\r\n\r\n\t\t\t\t\t\treturn FALSE;\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tcontext = _app_editor_getcontext (hwnd);\r\n\r\n\t\t\t\t\tif (!context)\r\n\t\t\t\t\t\treturn FALSE;\r\n\r\n\t\t\t\t\t_r_obj_initializestringref2 (&remaining_part, &string->sr);\r\n\r\n\t\t\t\t\titem_id = _r_listview_getitemcount (context->hwnd, context->listview_id);\r\n\r\n\t\t\t\t\twhile (remaining_part.length != 0)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t_r_str_splitatchar (&remaining_part, DIVIDER_RULE[0], &first_part, &remaining_part);\r\n\r\n\t\t\t\t\t\tif (!_app_parserulestring (&first_part, &address))\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t_r_ctrl_showballoontip (hwnd, IDC_RULE_ID, 0, NULL, _r_locale_getstring (IDS_STATUS_SYNTAX_ERROR));\r\n\r\n\t\t\t\t\t\t\t_r_ctrl_enable (hwnd, IDC_SAVE, FALSE);\r\n\r\n\t\t\t\t\t\t\treturn FALSE;\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t_r_str_copystring (rule_string, RTL_NUMBER_OF (rule_string), &first_part);\r\n\r\n\t\t\t\t\t\t_r_listview_additem (context->hwnd, context->listview_id, item_id, rule_string, I_DEFAULT, I_DEFAULT, I_DEFAULT);\r\n\r\n\t\t\t\t\t\titem_id += 1;\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tif (context->item_id != INT_ERROR)\r\n\t\t\t\t\t\t_r_listview_deleteitem (context->hwnd, context->listview_id, context->item_id);\r\n\r\n\t\t\t\t\t_r_listview_setcolumn (context->hwnd, context->listview_id, 0, NULL, -100);\r\n\r\n\t\t\t\t\t_r_obj_dereference (string);\r\n\r\n\t\t\t\t\tFALLTHROUGH;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tcase IDCANCEL: // process Esc key\r\n\t\t\t\tcase IDC_CLOSE:\r\n\t\t\t\t{\r\n\t\t\t\t\tEndDialog (hwnd, FALSE);\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\r\n\treturn FALSE;\r\n}\r\n\r\nINT_PTR CALLBACK EditorPagesProc (\r\n\t_In_ HWND hwnd,\r\n\t_In_ UINT msg,\r\n\t_In_ WPARAM wparam,\r\n\t_In_ LPARAM lparam\r\n)\r\n{\r\n\tPEDITOR_CONTEXT context;\r\n\r\n\tswitch (msg)\r\n\t{\r\n\t\tcase WM_INITDIALOG:\r\n\t\t{\r\n\t\t\tWCHAR buffer[256];\r\n\t\t\tPITEM_APP ptr_app = NULL;\r\n\t\t\tPITEM_RULE ptr_rule;\r\n\t\t\tPR_STRING string;\r\n\t\t\tHWND hctrl;\r\n\t\t\tINT i;\r\n\t\t\tULONG_PTR enum_key;\r\n\t\t\tBOOLEAN is_enabled;\r\n\r\n\t\t\tcontext = (PEDITOR_CONTEXT)lparam;\r\n\r\n\t\t\t_app_editor_setcontext (hwnd, context);\r\n\r\n\t\t\tEnableThemeDialogTexture (hwnd, ETDT_ENABLETAB);\r\n\r\n\t\t\tSetWindowPos (\r\n\t\t\t\thwnd,\r\n\t\t\t\tHWND_TOP,\r\n\t\t\t\t0,\r\n\t\t\t\t0,\r\n\t\t\t\t0,\r\n\t\t\t\t0,\r\n\t\t\t\tSWP_NOSIZE | SWP_NOMOVE | SWP_FRAMECHANGED\r\n\t\t\t);\r\n\r\n\t\t\t// name\r\n\t\t\tif (GetDlgItem (hwnd, IDC_RULE_NAME_ID))\r\n\t\t\t{\r\n\t\t\t\t_r_ctrl_setstringformat (hwnd, IDC_RULE_NAME, L\"%s:\", _r_locale_getstring (IDS_NAME));\r\n\r\n\t\t\t\tif (!_r_obj_isstringempty (context->ptr_rule->name))\r\n\t\t\t\t\t_r_ctrl_setstring (hwnd, IDC_RULE_NAME_ID, context->ptr_rule->name->buffer);\r\n\r\n\t\t\t\t_r_ctrl_setreadonly (hwnd, IDC_RULE_NAME_ID, !!context->ptr_rule->is_readonly);\r\n\t\t\t\t_r_ctrl_settextlimit (hwnd, IDC_RULE_NAME_ID, RULE_NAME_CCH_MAX - 1);\r\n\t\t\t}\r\n\r\n\t\t\t// comment\r\n\t\t\tif (GetDlgItem (hwnd, IDC_RULE_COMMENT_ID))\r\n\t\t\t{\r\n\t\t\t\t_r_ctrl_setstringformat (hwnd, IDC_RULE_COMMENT, L\"%s:\", _r_locale_getstring (IDS_COMMENT));\r\n\r\n\t\t\t\tif (!_r_obj_isstringempty (context->ptr_rule->comment))\r\n\t\t\t\t\t_r_ctrl_setstring (hwnd, IDC_RULE_COMMENT_ID, context->ptr_rule->comment->buffer);\r\n\r\n\t\t\t\t_r_ctrl_enable (hwnd, IDC_RULE_COMMENT_ID, !context->ptr_rule->is_readonly);\r\n\t\t\t\t_r_ctrl_settextlimit (hwnd, IDC_RULE_COMMENT_ID, RULE_RULE_CCH_MAX - 1);\r\n\t\t\t}\r\n\r\n\t\t\t// direction\r\n\t\t\tif (GetDlgItem (hwnd, IDC_RULE_DIRECTION))\r\n\t\t\t{\r\n\t\t\t\t_r_ctrl_setstringformat (hwnd, IDC_RULE_DIRECTION, L\"%s:\", _r_locale_getstring (IDS_DIRECTION));\r\n\r\n\t\t\t\t_r_combobox_insertitem (hwnd, IDC_RULE_DIRECTION_ID, 0, _r_locale_getstring (IDS_DIRECTION_1), (LPARAM)FWP_DIRECTION_OUTBOUND);\r\n\t\t\t\t_r_combobox_insertitem (hwnd, IDC_RULE_DIRECTION_ID, 1, _r_locale_getstring (IDS_DIRECTION_2), (LPARAM)FWP_DIRECTION_INBOUND);\r\n\t\t\t\t_r_combobox_insertitem (hwnd, IDC_RULE_DIRECTION_ID, 2, _r_locale_getstring (IDS_ANY), (LPARAM)FWP_DIRECTION_MAX);\r\n\r\n\t\t\t\t_r_combobox_setcurrentitembylparam (hwnd, IDC_RULE_DIRECTION_ID, (LPARAM)context->ptr_rule->direction);\r\n\r\n\t\t\t\t_r_ctrl_enable (hwnd, IDC_RULE_DIRECTION_ID, !context->ptr_rule->is_readonly);\r\n\t\t\t}\r\n\r\n\t\t\t// action\r\n\t\t\tif (GetDlgItem (hwnd, IDC_RULE_ACTION))\r\n\t\t\t{\r\n\t\t\t\t_r_ctrl_setstringformat (hwnd, IDC_RULE_ACTION, L\"%s:\", _r_locale_getstring (IDS_ACTION));\r\n\r\n\t\t\t\t_r_combobox_insertitem (hwnd, IDC_RULE_ACTION_ID, 0, _r_locale_getstring (IDS_ACTION_BLOCK), (LPARAM)FWP_ACTION_BLOCK);\r\n\t\t\t\t_r_combobox_insertitem (hwnd, IDC_RULE_ACTION_ID, 1, _r_locale_getstring (IDS_ACTION_ALLOW), (LPARAM)FWP_ACTION_PERMIT);\r\n\r\n\t\t\t\t_r_combobox_setcurrentitembylparam (hwnd, IDC_RULE_ACTION_ID, (LPARAM)context->ptr_rule->action);\r\n\r\n\t\t\t\t_r_ctrl_enable (hwnd, IDC_RULE_ACTION_ID, !context->ptr_rule->is_readonly);\r\n\t\t\t}\r\n\r\n\t\t\t// protocols\r\n\t\t\tif (GetDlgItem (hwnd, IDC_RULE_PROTOCOL_ID))\r\n\t\t\t{\r\n\t\t\t\tUINT8 protos[] = {\r\n\t\t\t\t\tIPPROTO_ICMP,\r\n\t\t\t\t\tIPPROTO_IGMP,\r\n\t\t\t\t\tIPPROTO_IPV4,\r\n\t\t\t\t\tIPPROTO_TCP,\r\n\t\t\t\t\tIPPROTO_UDP,\r\n\t\t\t\t\tIPPROTO_RDP,\r\n\t\t\t\t\tIPPROTO_IPV6,\r\n\t\t\t\t\tIPPROTO_ICMPV6,\r\n\t\t\t\t\tIPPROTO_L2TP,\r\n\t\t\t\t\tIPPROTO_SCTP,\r\n\t\t\t\t\tIPPROTO_RAW,\r\n\t\t\t\t};\r\n\r\n\t\t\t\t_r_ctrl_setstringformat (hwnd, IDC_RULE_PROTOCOL, L\"%s:\", _r_locale_getstring (IDS_PROTOCOL));\r\n\r\n\t\t\t\t_r_combobox_insertitem (hwnd, IDC_RULE_PROTOCOL_ID, 0, _r_locale_getstring (IDS_ANY), 0);\r\n\r\n\t\t\t\tfor (i = 0; i < RTL_NUMBER_OF (protos); i++)\r\n\t\t\t\t{\r\n\t\t\t\t\t_r_str_printf (buffer, RTL_NUMBER_OF (buffer), L\"%s (%\" TEXT (PRIu8) L\")\", _app_db_getprotoname (protos[i], AF_UNSPEC), protos[i]);\r\n\r\n\t\t\t\t\t_r_combobox_insertitem (hwnd, IDC_RULE_PROTOCOL_ID, i + 1, buffer, (LPARAM)protos[i]);\r\n\t\t\t\t}\r\n\r\n\t\t\t\t// unknown protocol\r\n\t\t\t\tif (_r_combobox_getcurrentitem (hwnd, IDC_RULE_PROTOCOL_ID) == CB_ERR && context->ptr_rule->protocol != 0)\r\n\t\t\t\t{\r\n\t\t\t\t\t_r_str_printf (buffer, RTL_NUMBER_OF (buffer), L\"%s (%\" TEXT (PRIu8) L\")\", _app_db_getprotoname (context->ptr_rule->protocol, AF_UNSPEC), context->ptr_rule->protocol);\r\n\r\n\t\t\t\t\t_r_combobox_insertitem (hwnd, IDC_RULE_PROTOCOL_ID, i + 1, buffer, (LPARAM)context->ptr_rule->protocol);\r\n\t\t\t\t}\r\n\r\n\t\t\t\t_r_combobox_setcurrentitembylparam (hwnd, IDC_RULE_PROTOCOL_ID, (LPARAM)context->ptr_rule->protocol);\r\n\r\n\t\t\t\t_r_ctrl_enable (hwnd, IDC_RULE_PROTOCOL_ID, !context->ptr_rule->is_readonly);\r\n\t\t\t}\r\n\r\n\t\t\t// family (ports-only)\r\n\t\t\tif (GetDlgItem (hwnd, IDC_RULE_VERSION_ID))\r\n\t\t\t{\r\n\t\t\t\t_r_ctrl_setstringformat (hwnd, IDC_RULE_VERSION, L\"%s:\", _r_locale_getstring (IDS_PORTVERSION));\r\n\r\n\t\t\t\t_r_combobox_insertitem (hwnd, IDC_RULE_VERSION_ID, 0, _r_locale_getstring (IDS_ANY), (LPARAM)AF_UNSPEC);\r\n\t\t\t\t_r_combobox_insertitem (hwnd, IDC_RULE_VERSION_ID, 1, L\"IPv4\", (LPARAM)AF_INET);\r\n\t\t\t\t_r_combobox_insertitem (hwnd, IDC_RULE_VERSION_ID, 2, L\"IPv6\", (LPARAM)AF_INET6);\r\n\r\n\t\t\t\t_r_combobox_setcurrentitembylparam (hwnd, IDC_RULE_VERSION_ID, (LPARAM)context->ptr_rule->af);\r\n\r\n\t\t\t\t_r_ctrl_enable (hwnd, IDC_RULE_VERSION_ID, !context->ptr_rule->is_readonly);\r\n\t\t\t}\r\n\r\n\t\t\t// rule (remote)\r\n\t\t\tif (GetDlgItem (hwnd, IDC_RULE_REMOTE_ID))\r\n\t\t\t{\r\n\t\t\t\t_r_ctrl_setstringformat (hwnd, IDC_RULE_REMOTE, L\"%s (%s):\", _r_locale_getstring (IDS_RULE), _r_locale_getstring (IDS_DIRECTION_REMOTE));\r\n\r\n\t\t\t\t_r_listview_setstyle (\r\n\t\t\t\t\thwnd,\r\n\t\t\t\t\tIDC_RULE_REMOTE_ID,\r\n\t\t\t\t\tLVS_EX_DOUBLEBUFFER | LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP | LVS_EX_LABELTIP,\r\n\t\t\t\t\tFALSE\r\n\t\t\t\t);\r\n\r\n\t\t\t\t_r_listview_addcolumn (hwnd, IDC_RULE_REMOTE_ID, 0, NULL, -100, 0);\r\n\r\n\t\t\t\tif (!_r_obj_isstringempty (context->ptr_rule->rule_remote))\r\n\t\t\t\t{\r\n\t\t\t\t\t_app_editor_setrulestolistview (hwnd, IDC_RULE_REMOTE_ID, context->ptr_rule->rule_remote);\r\n\r\n\t\t\t\t\t_r_listview_setcolumn (hwnd, IDC_RULE_REMOTE_ID, 0, NULL, -100);\r\n\t\t\t\t}\r\n\r\n\t\t\t\t_r_ctrl_setstringformat (hwnd, IDC_RULE_REMOTE_ADD, L\"%s...\", _r_locale_getstring (IDS_ADD));\r\n\t\t\t\t_r_ctrl_setstringformat (hwnd, IDC_RULE_REMOTE_EDIT, L\"%s...\", _r_locale_getstring (IDS_EDIT2));\r\n\t\t\t\t_r_ctrl_setstringformat (hwnd, IDC_RULE_REMOTE_DELETE, L\"%s...\", _r_locale_getstring (IDS_DELETE));\r\n\r\n\t\t\t\t_r_ctrl_enable (hwnd, IDC_RULE_REMOTE_ADD, !context->ptr_rule->is_readonly);\r\n\t\t\t\t_r_ctrl_enable (hwnd, IDC_RULE_REMOTE_EDIT, FALSE);\r\n\t\t\t\t_r_ctrl_enable (hwnd, IDC_RULE_REMOTE_DELETE, FALSE);\r\n\t\t\t}\r\n\r\n\t\t\t// rule (local)\r\n\t\t\tif (GetDlgItem (hwnd, IDC_RULE_LOCAL_ID))\r\n\t\t\t{\r\n\t\t\t\t_r_ctrl_setstringformat (hwnd, IDC_RULE_LOCAL, L\"%s (%s):\", _r_locale_getstring (IDS_RULE), _r_locale_getstring (IDS_DIRECTION_LOCAL));\r\n\r\n\t\t\t\t_r_listview_setstyle (\r\n\t\t\t\t\thwnd,\r\n\t\t\t\t\tIDC_RULE_LOCAL_ID,\r\n\t\t\t\t\tLVS_EX_DOUBLEBUFFER | LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP | LVS_EX_LABELTIP,\r\n\t\t\t\t\tFALSE\r\n\t\t\t\t);\r\n\r\n\t\t\t\t_r_listview_addcolumn (hwnd, IDC_RULE_LOCAL_ID, 0, NULL, 100, 0);\r\n\r\n\t\t\t\tif (!_r_obj_isstringempty (context->ptr_rule->rule_local))\r\n\t\t\t\t{\r\n\t\t\t\t\t_app_editor_setrulestolistview (hwnd, IDC_RULE_LOCAL_ID, context->ptr_rule->rule_local);\r\n\r\n\t\t\t\t\t_r_listview_setcolumn (hwnd, IDC_RULE_LOCAL_ID, 0, NULL, -100);\r\n\t\t\t\t}\r\n\r\n\t\t\t\t_r_ctrl_setstringformat (hwnd, IDC_RULE_LOCAL_ADD, L\"%s...\", _r_locale_getstring (IDS_ADD));\r\n\t\t\t\t_r_ctrl_setstringformat (hwnd, IDC_RULE_LOCAL_EDIT, L\"%s...\", _r_locale_getstring (IDS_EDIT2));\r\n\t\t\t\t_r_ctrl_setstringformat (hwnd, IDC_RULE_LOCAL_DELETE, L\"%s...\", _r_locale_getstring (IDS_DELETE));\r\n\r\n\t\t\t\t_r_ctrl_enable (hwnd, IDC_RULE_LOCAL_ADD, !context->ptr_rule->is_readonly);\r\n\t\t\t\t_r_ctrl_enable (hwnd, IDC_RULE_LOCAL_EDIT, FALSE);\r\n\t\t\t\t_r_ctrl_enable (hwnd, IDC_RULE_LOCAL_DELETE, FALSE);\r\n\t\t\t}\r\n\r\n\t\t\t// search\r\n\t\t\thctrl = GetDlgItem (hwnd, IDC_SEARCH);\r\n\r\n\t\t\tif (hctrl)\r\n\t\t\t{\r\n\t\t\t\t_app_search_create (hctrl);\r\n\r\n\t\t\t\tSetWindowPos (hctrl, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_FRAMECHANGED); // HACK!!!\r\n\t\t\t}\r\n\r\n\t\t\t// apps\r\n\t\t\tif (GetDlgItem (hwnd, IDC_RULE_APPS_ID))\r\n\t\t\t{\r\n\t\t\t\t_app_listview_setview (hwnd, IDC_RULE_APPS_ID);\r\n\r\n\t\t\t\t_r_listview_setstyle (\r\n\t\t\t\t\thwnd,\r\n\t\t\t\t\tIDC_RULE_APPS_ID,\r\n\t\t\t\t\tLVS_EX_DOUBLEBUFFER | LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP | LVS_EX_LABELTIP | LVS_EX_CHECKBOXES,\r\n\t\t\t\t\tTRUE\r\n\t\t\t\t);\r\n\r\n\t\t\t\t_r_listview_addcolumn (hwnd, IDC_RULE_APPS_ID, 0, _r_locale_getstring (IDS_NAME), 100, LVCFMT_LEFT);\r\n\r\n\t\t\t\t_r_listview_addgroup (hwnd, IDC_RULE_APPS_ID, 0, L\"\", 0, LVGS_COLLAPSIBLE, LVGS_COLLAPSIBLE);\r\n\t\t\t\t_r_listview_addgroup (hwnd, IDC_RULE_APPS_ID, 1, L\"\", 0, LVGS_COLLAPSIBLE, LVGS_COLLAPSIBLE);\r\n\t\t\t\t_r_listview_addgroup (hwnd, IDC_RULE_APPS_ID, 2, L\"\", 0, LVGS_COLLAPSIBLE, LVGS_COLLAPSIBLE);\r\n\r\n\t\t\t\t_r_listview_addgroup (hwnd, IDC_RULE_APPS_ID, LV_HIDDEN_GROUP_ID, L\"\", 3, LVGS_HIDDEN, LVGS_HIDDEN);\r\n\r\n\t\t\t\t// apps (apply to)\r\n\t\t\t\tenum_key = 0;\r\n\r\n\t\t\t\t_r_queuedlock_acquireshared (&lock_apps);\r\n\r\n\t\t\t\twhile (_r_obj_enumhashtablepointer (apps_table, (PVOID_PTR)&ptr_app, NULL, &enum_key))\r\n\t\t\t\t{\r\n\t\t\t\t\t// check for services\r\n\t\t\t\t\tis_enabled = ((_r_obj_findhashtable (context->ptr_rule->apps, ptr_app->app_hash)) || (context->ptr_rule->is_forservices && _app_issystemhash (ptr_app->app_hash)));\r\n\r\n\t\t\t\t\t_app_listview_lock (hwnd, IDC_RULE_APPS_ID, TRUE);\r\n\r\n\t\t\t\t\t_r_listview_additem (hwnd, IDC_RULE_APPS_ID, 0, LPSTR_TEXTCALLBACK, I_IMAGECALLBACK, I_GROUPIDCALLBACK, _app_listview_createcontext (ptr_app->app_hash));\r\n\r\n\t\t\t\t\t_r_listview_setitemcheck (hwnd, IDC_RULE_APPS_ID, 0, is_enabled);\r\n\r\n\t\t\t\t\t_app_listview_lock (hwnd, IDC_RULE_APPS_ID, FALSE);\r\n\t\t\t\t}\r\n\r\n\t\t\t\t_r_queuedlock_releaseshared (&lock_apps);\r\n\r\n\t\t\t\t// resize column\r\n\t\t\t\t_r_listview_setcolumn (hwnd, IDC_RULE_APPS_ID, 0, NULL, -100);\r\n\r\n\t\t\t\t// localize groups\r\n\t\t\t\t_app_listview_refreshgroups (hwnd, IDC_RULE_APPS_ID);\r\n\r\n\t\t\t\t// sort column\r\n\t\t\t\t_app_listview_sort (hwnd, IDC_RULE_APPS_ID, INT_ERROR, FALSE);\r\n\t\t\t}\r\n\r\n\t\t\t// app group\r\n\t\t\tif (GetDlgItem (hwnd, IDC_APP_NAME))\r\n\t\t\t\t_r_ctrl_setstringformat (hwnd, IDC_APP_NAME, L\"%s:\", _r_locale_getstring (IDS_SETTINGS_GENERAL));\r\n\r\n\t\t\t// app path\r\n\t\t\tif (GetDlgItem (hwnd, IDC_APP_PATH))\r\n\t\t\t\t_r_ctrl_setstringformat (hwnd, IDC_APP_PATH, L\"%s:\", _r_locale_getstring (IDS_FILEPATH));\r\n\r\n\t\t\t// app comment\r\n\t\t\tif (GetDlgItem (hwnd, IDC_APP_COMMENT))\r\n\t\t\t\t_r_ctrl_setstringformat (hwnd, IDC_APP_COMMENT, L\"%s:\", _r_locale_getstring (IDS_COMMENT));\r\n\r\n\t\t\t// app icon\r\n\t\t\tif (GetDlgItem (hwnd, IDC_APP_ICON_ID))\r\n\t\t\t{\r\n\t\t\t\tcontext->hicon = _app_icons_getsafeapp_hicon (context->ptr_app->app_hash);\r\n\r\n\t\t\t\t_r_wnd_sendmessage (hwnd, IDC_APP_ICON_ID, STM_SETICON, (WPARAM)context->hicon, 0);\r\n\t\t\t}\r\n\r\n\t\t\t// app display name\r\n\t\t\tif (GetDlgItem (hwnd, IDC_APP_NAME_ID))\r\n\t\t\t{\r\n\t\t\t\tstring = _app_getappdisplayname (context->ptr_app, TRUE);\r\n\r\n\t\t\t\tif (string)\r\n\t\t\t\t{\r\n\t\t\t\t\t_r_ctrl_setstring (hwnd, IDC_APP_NAME_ID, string->buffer);\r\n\r\n\t\t\t\t\t_r_obj_dereference (string);\r\n\t\t\t\t}\r\n\r\n\t\t\t\t_r_ctrl_settextmargin (hwnd, IDC_APP_NAME_ID, 0, 0);\r\n\t\t\t}\r\n\r\n\t\t\t// app comment\r\n\t\t\tif (GetDlgItem (hwnd, IDC_APP_COMMENT_ID))\r\n\t\t\t{\r\n\t\t\t\t_r_ctrl_setstring (hwnd, IDC_APP_COMMENT_ID, _r_obj_getstring (context->ptr_app->comment));\r\n\r\n\t\t\t\t_r_ctrl_settextmargin (hwnd, IDC_APP_COMMENT_ID, 0, 0);\r\n\t\t\t}\r\n\r\n\t\t\t// app signature\r\n\t\t\tif (GetDlgItem (hwnd, IDC_APP_SIGNATURE_ID))\r\n\t\t\t{\r\n\t\t\t\tstring = NULL;\r\n\r\n\t\t\t\t_app_getappinfoparam2 (context->ptr_app->app_hash, 0, INFO_SIGNATURE_STRING, &string, sizeof (PR_STRING));\r\n\r\n\t\t\t\t_r_ctrl_setstringformat (\r\n\t\t\t\t\thwnd,\r\n\t\t\t\t\tIDC_APP_SIGNATURE_ID,\r\n\t\t\t\t\tL\"%s: %s\",\r\n\t\t\t\t\t_r_locale_getstring (IDS_SIGNATURE),\r\n\t\t\t\t\t_r_obj_getstringordefault (string, _r_locale_getstring (IDS_SIGN_UNSIGNED))\r\n\t\t\t\t);\r\n\r\n\t\t\t\t_r_ctrl_settextmargin (hwnd, IDC_APP_NAME_ID, 0, 0);\r\n\r\n\t\t\t\t_r_ctrl_settextmargin (hwnd, IDC_APP_SIGNATURE_ID, 0, 0);\r\n\r\n\t\t\t\tif (string)\r\n\t\t\t\t\t_r_obj_dereference (string);\r\n\t\t\t}\r\n\r\n\t\t\t// app path\r\n\t\t\tif (GetDlgItem (hwnd, IDC_APP_PATH_ID))\r\n\t\t\t{\r\n\t\t\t\tif (_app_isappvalidpath (context->ptr_app->real_path))\r\n\t\t\t\t{\r\n\t\t\t\t\t_r_ctrl_setstring (hwnd, IDC_APP_PATH_ID, context->ptr_app->real_path->buffer);\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\t_r_ctrl_enable (hwnd, IDC_APP_EXPLORE_ID, FALSE);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\t// app hash\r\n\t\t\tif (GetDlgItem (hwnd, IDC_APP_HASH_ID))\r\n\t\t\t\t_r_ctrl_setstring (hwnd, IDC_APP_HASH_ID, _r_obj_getstringordefault (context->ptr_app->hash, L\"<empty>\"));\r\n\r\n\t\t\t// app rules\r\n\t\t\tif (GetDlgItem (hwnd, IDC_APP_RULES_ID))\r\n\t\t\t{\r\n\t\t\t\t// configure listview\r\n\t\t\t\t_app_listview_setview (hwnd, IDC_APP_RULES_ID);\r\n\r\n\t\t\t\t_r_listview_setstyle (\r\n\t\t\t\t\thwnd,\r\n\t\t\t\t\tIDC_APP_RULES_ID,\r\n\t\t\t\t\tLVS_EX_DOUBLEBUFFER | LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP | LVS_EX_LABELTIP | LVS_EX_CHECKBOXES,\r\n\t\t\t\t\tTRUE\r\n\t\t\t\t);\r\n\r\n\t\t\t\t_r_listview_addcolumn (hwnd, IDC_APP_RULES_ID, 0, _r_locale_getstring (IDS_NAME), 100, LVCFMT_LEFT);\r\n\r\n\t\t\t\t_r_listview_addgroup (hwnd, IDC_APP_RULES_ID, 0, _r_locale_getstring (IDS_TRAY_SYSTEM_RULES), 0, LVGS_COLLAPSIBLE, LVGS_COLLAPSIBLE);\r\n\t\t\t\t_r_listview_addgroup (hwnd, IDC_APP_RULES_ID, 1, _r_locale_getstring (IDS_TRAY_USER_RULES), 0, LVGS_COLLAPSIBLE, LVGS_COLLAPSIBLE);\r\n\t\t\t\t_r_listview_addgroup (hwnd, IDC_APP_RULES_ID, LV_HIDDEN_GROUP_ID, L\"\", 2, LVGS_COLLAPSED, LVGS_COLLAPSED);\r\n\r\n\t\t\t\t// initialize\r\n\t\t\t\t_r_queuedlock_acquireshared (&lock_rules);\r\n\r\n\t\t\t\tfor (ULONG_PTR i = 0; i < _r_obj_getlistsize (rules_list); i++)\r\n\t\t\t\t{\r\n\t\t\t\t\tptr_rule = _r_obj_getlistitem (rules_list, i);\r\n\r\n\t\t\t\t\tif (!ptr_rule || ptr_rule->type != DATA_RULE_USER)\r\n\t\t\t\t\t\tcontinue;\r\n\r\n\t\t\t\t\t// check for services\r\n\t\t\t\t\tis_enabled = ((ptr_rule->is_forservices && _app_issystemhash (context->ptr_app->app_hash)) || _r_obj_findhashtable (ptr_rule->apps, context->ptr_app->app_hash));\r\n\r\n\t\t\t\t\t_app_listview_lock (hwnd, IDC_APP_RULES_ID, TRUE);\r\n\r\n\t\t\t\t\t_r_listview_additem (hwnd, IDC_APP_RULES_ID, 0, LPSTR_TEXTCALLBACK, I_IMAGECALLBACK, I_GROUPIDCALLBACK, _app_listview_createcontext ((ULONG)i));\r\n\r\n\t\t\t\t\t_r_listview_setitemcheck (hwnd, IDC_APP_RULES_ID, 0, is_enabled);\r\n\r\n\t\t\t\t\t_app_listview_lock (hwnd, IDC_APP_RULES_ID, FALSE);\r\n\t\t\t\t}\r\n\r\n\t\t\t\t_r_queuedlock_releaseshared (&lock_rules);\r\n\r\n\t\t\t\t// resize column\r\n\t\t\t\t_r_listview_setcolumn (hwnd, IDC_APP_RULES_ID, 0, NULL, -100);\r\n\r\n\t\t\t\t// localize groups\r\n\t\t\t\t_app_listview_refreshgroups (hwnd, IDC_APP_RULES_ID);\r\n\r\n\t\t\t\t// sort column\r\n\t\t\t\t_app_listview_sort (hwnd, IDC_APP_RULES_ID, INT_ERROR, FALSE);\r\n\t\t\t}\r\n\r\n\t\t\t// hints\r\n\t\t\tif (GetDlgItem (hwnd, IDC_RULE_HINT))\r\n\t\t\t\t_r_ctrl_setstring (hwnd, IDC_RULE_HINT, _r_locale_getstring (IDS_RULE_HINT));\r\n\r\n\t\t\tif (GetDlgItem (hwnd, IDC_RULE_APPS_HINT))\r\n\t\t\t\t_r_ctrl_setstring (hwnd, IDC_RULE_APPS_HINT, _r_locale_getstring (IDS_RULE_APPS_HINT));\r\n\r\n\t\t\tif (GetDlgItem (hwnd, IDC_APP_HINT))\r\n\t\t\t\t_r_ctrl_setstring (hwnd, IDC_APP_HINT, _r_locale_getstring (IDS_APP_HINT));\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase RM_INITIALIZE:\r\n\t\t{\r\n\t\t\t// apps\r\n\t\t\tif (GetDlgItem (hwnd, IDC_RULE_APPS_ID))\r\n\t\t\t\t_app_editor_settabtitle (hwnd, IDC_RULE_APPS_ID);\r\n\r\n\t\t\t// rules\r\n\t\t\tif (GetDlgItem (hwnd, IDC_APP_RULES_ID))\r\n\t\t\t\t_app_editor_settabtitle (hwnd, IDC_APP_RULES_ID);\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase WM_DESTROY:\r\n\t\t{\r\n\t\t\t// apps\r\n\t\t\tif (GetDlgItem (hwnd, IDC_RULE_APPS_ID))\r\n\t\t\t\t_r_listview_deleteallitems (hwnd, IDC_RULE_APPS_ID);\r\n\r\n\t\t\t// app rules\r\n\t\t\tif (GetDlgItem (hwnd, IDC_APP_RULES_ID))\r\n\t\t\t\t_r_listview_deleteallitems (hwnd, IDC_APP_RULES_ID);\r\n\r\n\t\t\tcontext = _app_editor_getcontext (hwnd);\r\n\r\n\t\t\tif (!context)\r\n\t\t\t\tbreak;\r\n\r\n\t\t\tif (context->hicon)\r\n\t\t\t\tDestroyIcon (context->hicon);\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase WM_SIZE:\r\n\t\t{\r\n\t\t\tINT listview_ids[] = {\r\n\t\t\t\tIDC_RULE_APPS_ID,\r\n\t\t\t\tIDC_APP_RULES_ID,\r\n\t\t\t\tIDC_RULE_REMOTE_ID,\r\n\t\t\t\tIDC_RULE_LOCAL_ID,\r\n\t\t\t};\r\n\r\n\t\t\tHWND hlistview;\r\n\r\n\t\t\tfor (ULONG_PTR i = 0; i < RTL_NUMBER_OF (listview_ids); i++)\r\n\t\t\t{\r\n\t\t\t\thlistview = GetDlgItem (hwnd, listview_ids[i]);\r\n\r\n\t\t\t\tif (hlistview)\r\n\t\t\t\t\t_r_listview_setcolumn (hwnd, listview_ids[i], 0, NULL, -100);\r\n\t\t\t}\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase WM_NOTIFY:\r\n\t\t{\r\n\t\t\tLPNMHDR nmlp = (LPNMHDR)lparam;\r\n\r\n\t\t\tswitch (nmlp->code)\r\n\t\t\t{\r\n\t\t\t\tcase NM_CUSTOMDRAW:\r\n\t\t\t\t{\r\n\t\t\t\t\tLONG_PTR result;\r\n\r\n\t\t\t\t\tresult = _app_message_custdraw (hwnd, (LPNMLVCUSTOMDRAW)lparam);\r\n\r\n\t\t\t\t\tSetWindowLongPtrW (hwnd, DWLP_MSGRESULT, result);\r\n\r\n\t\t\t\t\treturn result;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tcase NM_DBLCLK:\r\n\t\t\t\t{\r\n\t\t\t\t\tLPNMITEMACTIVATE lpnmlv;\r\n\t\t\t\t\tULONG command_id = 0;\r\n\t\t\t\t\tINT listview_id;\r\n\r\n\t\t\t\t\tlpnmlv = (LPNMITEMACTIVATE)lparam;\r\n\r\n\t\t\t\t\tif (lpnmlv->iItem == INT_ERROR)\r\n\t\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t\tlistview_id = (INT)(INT_PTR)(lpnmlv->hdr.idFrom);\r\n\r\n\t\t\t\t\tif (listview_id == IDC_RULE_REMOTE_ID)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tcommand_id = IDC_RULE_REMOTE_EDIT;\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse if (listview_id == IDC_RULE_LOCAL_ID)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tcommand_id = IDC_RULE_LOCAL_EDIT;\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse if (listview_id == IDC_RULE_APPS_ID || listview_id == IDC_APP_RULES_ID)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tcommand_id = IDM_PROPERTIES;\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tif (command_id)\r\n\t\t\t\t\t\t_r_ctrl_sendcommand (hwnd, command_id, 0);\r\n\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tcase NM_RCLICK:\r\n\t\t\t\t{\r\n\t\t\t\t\tLPNMITEMACTIVATE lpnmlv;\r\n\t\t\t\t\tHMENU hsubmenu;\r\n\t\t\t\t\tPR_STRING localized_string = NULL;\r\n\t\t\t\t\tUINT id_add;\r\n\t\t\t\t\tUINT id_edit;\r\n\t\t\t\t\tUINT id_delete;\r\n\t\t\t\t\tINT listview_id;\r\n\t\t\t\t\tBOOLEAN is_remote;\r\n\t\t\t\t\tBOOLEAN is_selected;\r\n\r\n\t\t\t\t\tlpnmlv = (LPNMITEMACTIVATE)lparam;\r\n\t\t\t\t\tlistview_id = (INT)(INT_PTR)lpnmlv->hdr.idFrom;\r\n\r\n\t\t\t\t\tif (listview_id != IDC_RULE_REMOTE_ID && listview_id != IDC_RULE_LOCAL_ID && listview_id != IDC_RULE_APPS_ID && listview_id != IDC_APP_RULES_ID)\r\n\t\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t\tcontext = _app_editor_getcontext (hwnd);\r\n\r\n\t\t\t\t\tif (!context)\r\n\t\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t\thsubmenu = CreatePopupMenu ();\r\n\r\n\t\t\t\t\tif (!hsubmenu)\r\n\t\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t\tis_selected = _r_listview_getselectedcount (hwnd, listview_id) != 0;\r\n\r\n\t\t\t\t\tif (listview_id == IDC_RULE_REMOTE_ID || listview_id == IDC_RULE_LOCAL_ID)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tis_remote = (listview_id == IDC_RULE_REMOTE_ID);\r\n\r\n\t\t\t\t\t\tid_add = is_remote ? IDC_RULE_REMOTE_ADD : IDC_RULE_LOCAL_ADD;\r\n\t\t\t\t\t\tid_edit = is_remote ? IDC_RULE_REMOTE_EDIT : IDC_RULE_LOCAL_EDIT;\r\n\t\t\t\t\t\tid_delete = is_remote ? IDC_RULE_REMOTE_DELETE : IDC_RULE_LOCAL_DELETE;\r\n\r\n\t\t\t\t\t\t_r_obj_movereference ((PVOID_PTR)&localized_string, _r_obj_concatstrings (2, _r_locale_getstring (IDS_ADD), L\"...\"));\r\n\t\t\t\t\t\t_r_menu_additem (hsubmenu, id_add, localized_string->buffer);\r\n\r\n\t\t\t\t\t\t_r_obj_movereference ((PVOID_PTR)&localized_string, _r_obj_concatstrings (2, _r_locale_getstring (IDS_EDIT2), L\"...\"));\r\n\t\t\t\t\t\t_r_menu_additem (hsubmenu, id_edit, localized_string->buffer);\r\n\r\n\t\t\t\t\t\t_r_menu_additem (hsubmenu, id_delete, _r_locale_getstring (IDS_DELETE));\r\n\t\t\t\t\t\t_r_menu_addseparator (hsubmenu);\r\n\t\t\t\t\t\t_r_menu_additem (hsubmenu, IDM_COPY, _r_locale_getstring (IDS_COPY));\r\n\r\n\t\t\t\t\t\tif (context->ptr_rule->is_readonly)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t_r_menu_enableitem (hsubmenu, id_add, FALSE, FALSE);\r\n\t\t\t\t\t\t\t_r_menu_enableitem (hsubmenu, id_edit, FALSE, FALSE);\r\n\t\t\t\t\t\t\t_r_menu_enableitem (hsubmenu, id_delete, FALSE, FALSE);\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\tif (!is_selected)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t_r_menu_enableitem (hsubmenu, id_edit, FALSE, FALSE);\r\n\t\t\t\t\t\t\t_r_menu_enableitem (hsubmenu, id_delete, FALSE, FALSE);\r\n\t\t\t\t\t\t\t_r_menu_enableitem (hsubmenu, IDM_COPY, FALSE, FALSE);\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t_r_obj_dereference (localized_string);\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse if (listview_id == IDC_RULE_APPS_ID || listview_id == IDC_APP_RULES_ID)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t_r_menu_additem (hsubmenu, IDM_CHECK, _r_locale_getstring (IDS_CHECK));\r\n\t\t\t\t\t\t_r_menu_additem (hsubmenu, IDM_UNCHECK, _r_locale_getstring (IDS_UNCHECK));\r\n\t\t\t\t\t\t_r_menu_addseparator (hsubmenu);\r\n\t\t\t\t\t\t_r_menu_additem (hsubmenu, IDM_COPY, _r_locale_getstring (IDS_COPY));\r\n\r\n\t\t\t\t\t\tif (context->is_settorules && context->ptr_rule->type != DATA_RULE_USER)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t_r_menu_enableitem (hsubmenu, IDM_CHECK, FALSE, FALSE);\r\n\t\t\t\t\t\t\t_r_menu_enableitem (hsubmenu, IDM_UNCHECK, FALSE, FALSE);\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\tif (!is_selected)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t_r_menu_enableitem (hsubmenu, IDM_CHECK, FALSE, FALSE);\r\n\t\t\t\t\t\t\t_r_menu_enableitem (hsubmenu, IDM_UNCHECK, FALSE, FALSE);\r\n\t\t\t\t\t\t\t_r_menu_enableitem (hsubmenu, IDM_COPY, FALSE, FALSE);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\t_r_menu_popup (hsubmenu, hwnd, NULL, TRUE);\r\n\r\n\t\t\t\t\tDestroyMenu (hsubmenu);\r\n\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tcase LVN_DELETEITEM:\r\n\t\t\t\t{\r\n\t\t\t\t\tPITEM_LISTVIEW_CONTEXT listview_context;\r\n\t\t\t\t\tLPNMLISTVIEW lpnmlv;\r\n\t\t\t\t\tINT listview_id;\r\n\r\n\t\t\t\t\tlpnmlv = (LPNMLISTVIEW)lparam;\r\n\t\t\t\t\tlistview_id = (INT)(INT_PTR)lpnmlv->hdr.idFrom;\r\n\r\n\t\t\t\t\tif (!(listview_id == IDC_RULE_APPS_ID || listview_id == IDC_APP_RULES_ID))\r\n\t\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t\tlistview_context = (PITEM_LISTVIEW_CONTEXT)lpnmlv->lParam;\r\n\r\n\t\t\t\t\tif (!listview_context)\r\n\t\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t\t_app_listview_destroycontext (listview_context);\r\n\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tcase LVN_GETDISPINFO:\r\n\t\t\t\t{\r\n\t\t\t\t\tLPNMLVDISPINFOW lpnmlv;\r\n\t\t\t\t\tINT listview_id;\r\n\r\n\t\t\t\t\tlpnmlv = (LPNMLVDISPINFOW)lparam;\r\n\t\t\t\t\tlistview_id = (INT)(INT_PTR)lpnmlv->hdr.idFrom;\r\n\r\n\t\t\t\t\t_app_message_displayinfo (hwnd, listview_id, lpnmlv);\r\n\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tcase LVN_COLUMNCLICK:\r\n\t\t\t\t{\r\n\t\t\t\t\tLPNMLISTVIEW lpnmlv;\r\n\t\t\t\t\tINT listview_id;\r\n\r\n\t\t\t\t\tlpnmlv = (LPNMLISTVIEW)lparam;\r\n\t\t\t\t\tlistview_id = (INT)(INT_PTR)lpnmlv->hdr.idFrom;\r\n\r\n\t\t\t\t\t_app_listview_sort (hwnd, listview_id, lpnmlv->iSubItem, TRUE);\r\n\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tcase LVN_ITEMCHANGING:\r\n\t\t\t\t{\r\n\t\t\t\t\tLPNMLISTVIEW lpnmlv;\r\n\t\t\t\t\tINT listview_id;\r\n\r\n\t\t\t\t\tlpnmlv = (LPNMLISTVIEW)lparam;\r\n\t\t\t\t\tlistview_id = (INT)(INT_PTR)lpnmlv->hdr.idFrom;\r\n\r\n\t\t\t\t\tcontext = _app_editor_getcontext (hwnd);\r\n\r\n\t\t\t\t\tif (!context)\r\n\t\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t\tif ((lpnmlv->uChanged & LVIF_STATE) != 0)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif (listview_id == IDC_RULE_APPS_ID)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tif ((lpnmlv->uNewState & LVIS_STATEIMAGEMASK) == INDEXTOSTATEIMAGEMASK (1) || ((lpnmlv->uNewState & LVIS_STATEIMAGEMASK) == INDEXTOSTATEIMAGEMASK (2)))\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tif (!_app_listview_islocked (hwnd, (INT)(INT_PTR)lpnmlv->hdr.idFrom) && context->ptr_rule->type != DATA_RULE_USER)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tSetWindowLongPtrW (hwnd, DWLP_MSGRESULT, TRUE);\r\n\r\n\t\t\t\t\t\t\t\t\treturn TRUE;\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tcase LVN_ITEMCHANGED:\r\n\t\t\t\t{\r\n\t\t\t\t\tLPNMLISTVIEW lpnmlv;\r\n\t\t\t\t\tINT listview_id;\r\n\t\t\t\t\tBOOLEAN is_selected;\r\n\r\n\t\t\t\t\tlpnmlv = (LPNMLISTVIEW)lparam;\r\n\t\t\t\t\tlistview_id = (INT)(INT_PTR)lpnmlv->hdr.idFrom;\r\n\r\n\t\t\t\t\tcontext = _app_editor_getcontext (hwnd);\r\n\r\n\t\t\t\t\tif (!context)\r\n\t\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t\tif ((lpnmlv->uChanged & LVIF_STATE) != 0)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif (listview_id == IDC_RULE_APPS_ID || listview_id == IDC_APP_RULES_ID)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tif ((lpnmlv->uNewState & LVIS_STATEIMAGEMASK) == INDEXTOSTATEIMAGEMASK (1) || ((lpnmlv->uNewState & LVIS_STATEIMAGEMASK) == INDEXTOSTATEIMAGEMASK (2)))\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tif (_app_listview_islocked (hwnd, (INT)(INT_PTR)lpnmlv->hdr.idFrom))\r\n\t\t\t\t\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t\t\t\t\t_app_editor_settabtitle (hwnd, listview_id);\r\n\r\n\t\t\t\t\t\t\t\t_app_listview_refreshgroups (hwnd, listview_id);\r\n\t\t\t\t\t\t\t\t_app_listview_sort (hwnd, listview_id, INT_ERROR, FALSE);\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\telse if (listview_id == IDC_RULE_REMOTE_ID || listview_id == IDC_RULE_LOCAL_ID)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tif ((lpnmlv->uOldState & LVIS_SELECTED) != 0 || (lpnmlv->uNewState & LVIS_SELECTED) != 0)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tif (!context->ptr_rule->is_readonly)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tis_selected = (lpnmlv->uNewState & LVIS_SELECTED) != 0;\r\n\r\n\t\t\t\t\t\t\t\t\tif (listview_id == IDC_RULE_REMOTE_ID)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t_r_ctrl_enable (hwnd, IDC_RULE_REMOTE_EDIT, is_selected);\r\n\t\t\t\t\t\t\t\t\t\t_r_ctrl_enable (hwnd, IDC_RULE_REMOTE_DELETE, is_selected);\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\telse if (listview_id == IDC_RULE_LOCAL_ID)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t_r_ctrl_enable (hwnd, IDC_RULE_LOCAL_EDIT, is_selected);\r\n\t\t\t\t\t\t\t\t\t\t_r_ctrl_enable (hwnd, IDC_RULE_LOCAL_DELETE, is_selected);\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tcase LVN_GETINFOTIP:\r\n\t\t\t\t{\r\n\t\t\t\t\tLPNMLVGETINFOTIPW lpnmlv;\r\n\t\t\t\t\tPR_STRING string;\r\n\t\t\t\t\tULONG_PTR context;\r\n\t\t\t\t\tINT listview_id;\r\n\r\n\t\t\t\t\tlpnmlv = (LPNMLVGETINFOTIPW)lparam;\r\n\t\t\t\t\tlistview_id = (INT)lpnmlv->hdr.idFrom;\r\n\r\n\t\t\t\t\tif (listview_id != IDC_RULE_APPS_ID && listview_id != IDC_APP_RULES_ID)\r\n\t\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t\tcontext = _app_listview_getitemcontext (hwnd, listview_id, lpnmlv->iItem);\r\n\r\n\t\t\t\t\tstring = _app_gettooltipbylparam (hwnd, listview_id, context);\r\n\r\n\t\t\t\t\tif (!string)\r\n\t\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t\t_r_str_copy (lpnmlv->pszText, lpnmlv->cchTextMax, string->buffer);\r\n\r\n\t\t\t\t\t_r_obj_dereference (string);\r\n\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tcase LVN_GETEMPTYMARKUP:\r\n\t\t\t\t{\r\n\t\t\t\t\tNMLVEMPTYMARKUP* lpnmlv = (NMLVEMPTYMARKUP*)lparam;\r\n\r\n\t\t\t\t\tlpnmlv->dwFlags = EMF_CENTERED;\r\n\r\n\t\t\t\t\t_r_str_copy (lpnmlv->szMarkup, RTL_NUMBER_OF (lpnmlv->szMarkup), _r_locale_getstring (IDS_STATUS_EMPTY));\r\n\r\n\t\t\t\t\tSetWindowLongPtrW (hwnd, DWLP_MSGRESULT, TRUE);\r\n\r\n\t\t\t\t\treturn TRUE;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase WM_COMMAND:\r\n\t\t{\r\n\t\t\tINT notify_code = HIWORD (wparam);\r\n\t\t\tINT ctrl_id = LOWORD (wparam);\r\n\r\n\t\t\tif (notify_code == EN_CHANGE)\r\n\t\t\t{\r\n\t\t\t\tPR_STRING string;\r\n\t\t\t\tINT listview_id;\r\n\r\n\t\t\t\tif (ctrl_id == IDC_RULE_NAME_ID)\r\n\t\t\t\t{\r\n\t\t\t\t\t_r_ctrl_enable (GetParent (hwnd), IDC_SAVE, _r_ctrl_getstringlength (hwnd, ctrl_id) != 0); // enable apply button\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif (ctrl_id != IDC_SEARCH)\r\n\t\t\t\t\tbreak;\r\n\r\n\t\t\t\tif (GetDlgItem (hwnd, IDC_RULE_APPS_ID))\r\n\t\t\t\t{\r\n\t\t\t\t\tlistview_id = IDC_RULE_APPS_ID;\r\n\t\t\t\t}\r\n\t\t\t\telse if (GetDlgItem (hwnd, IDC_APP_RULES_ID))\r\n\t\t\t\t{\r\n\t\t\t\t\tlistview_id = IDC_APP_RULES_ID;\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\treturn FALSE;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tstring = _r_ctrl_getstring (hwnd, IDC_SEARCH);\r\n\r\n\t\t\t\t_app_search_applyfilter (hwnd, listview_id, string);\r\n\r\n\t\t\t\tif (string)\r\n\t\t\t\t\t_r_obj_dereference (string);\r\n\r\n\t\t\t\treturn FALSE;\r\n\t\t\t}\r\n\t\t\telse if (notify_code == EN_MAXTEXT)\r\n\t\t\t{\r\n\t\t\t\t_r_ctrl_showballoontip (hwnd, ctrl_id, 0, NULL, _r_locale_getstring (IDS_LIMIT_REACHED));\r\n\r\n\t\t\t\treturn FALSE;\r\n\t\t\t}\r\n\r\n\t\t\tswitch (ctrl_id)\r\n\t\t\t{\r\n\t\t\t\tcase IDC_RULE_REMOTE_ADD:\r\n\t\t\t\tcase IDC_RULE_LOCAL_ADD:\r\n\t\t\t\tcase IDC_RULE_REMOTE_EDIT:\r\n\t\t\t\tcase IDC_RULE_LOCAL_EDIT:\r\n\t\t\t\t{\r\n\t\t\t\t\tPR_STRING string;\r\n\t\t\t\t\tULONG_PTR current_length;\r\n\t\t\t\t\tINT listview_id;\r\n\t\t\t\t\tINT item_id;\r\n\r\n\t\t\t\t\tif (!_r_ctrl_isenabled (hwnd, ctrl_id))\r\n\t\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t\tlistview_id = (ctrl_id == IDC_RULE_REMOTE_ADD || ctrl_id == IDC_RULE_REMOTE_EDIT) ? IDC_RULE_REMOTE_ID : IDC_RULE_LOCAL_ID;\r\n\r\n\t\t\t\t\tif (ctrl_id == IDC_RULE_REMOTE_EDIT || ctrl_id == IDC_RULE_LOCAL_EDIT)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t// edit rule\r\n\t\t\t\t\t\titem_id = _r_listview_getnextselected (hwnd, listview_id, INT_ERROR);\r\n\r\n\t\t\t\t\t\tif (item_id == INT_ERROR)\r\n\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t// create new rule\r\n\t\t\t\t\t\titem_id = INT_ERROR;\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tstring = _app_editor_getrulesfromlistview (hwnd, listview_id, item_id);\r\n\r\n\t\t\t\t\tif (string)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tcurrent_length = _r_str_getlength2 (&string->sr);\r\n\r\n\t\t\t\t\t\t_r_obj_dereference (string);\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tcurrent_length = 0;\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tif (ctrl_id == IDC_RULE_REMOTE_ADD || ctrl_id == IDC_RULE_LOCAL_ADD)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif (current_length >= RULE_RULE_CCH_MAX)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t_r_show_errormessage (hwnd, NULL, STATUS_IMPLEMENTATION_LIMIT, NULL, ET_NATIVE);\r\n\r\n\t\t\t\t\t\t\treturn FALSE;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tcontext = _app_editor_getcontext (hwnd);\r\n\r\n\t\t\t\t\tif (!context)\r\n\t\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t\tcontext->hwnd = hwnd;\r\n\t\t\t\t\tcontext->listview_id = listview_id;\r\n\t\t\t\t\tcontext->item_id = item_id;\r\n\t\t\t\t\tcontext->current_length = current_length;\r\n\r\n\t\t\t\t\t_r_wnd_createmodalwindow (_r_sys_getimagebase (), MAKEINTRESOURCE (IDD_EDITOR_ADDRULE), hwnd, &EditorRuleProc, context);\r\n\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tcase IDC_RULE_REMOTE_DELETE:\r\n\t\t\t\tcase IDC_RULE_LOCAL_DELETE:\r\n\t\t\t\t{\r\n\t\t\t\t\tINT listview_id;\r\n\t\t\t\t\tINT selected_count;\r\n\t\t\t\t\tINT item_count;\r\n\r\n\t\t\t\t\tlistview_id = ((ctrl_id == IDC_RULE_REMOTE_DELETE) ? IDC_RULE_REMOTE_ID : IDC_RULE_LOCAL_ID);\r\n\r\n\t\t\t\t\tselected_count = _r_listview_getselectedcount (hwnd, listview_id);\r\n\r\n\t\t\t\t\tif (!selected_count)\r\n\t\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t\tif (_r_show_message (hwnd, MB_YESNO | MB_ICONEXCLAMATION, NULL, _r_locale_getstring (IDS_QUESTION_DELETE)) != IDYES)\r\n\t\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t\titem_count = _r_listview_getitemcount (hwnd, listview_id) - 1;\r\n\r\n\t\t\t\t\tfor (INT i = item_count; i != INT_ERROR; i--)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif (_r_listview_isitemselected (hwnd, listview_id, i))\r\n\t\t\t\t\t\t\t_r_listview_deleteitem (hwnd, listview_id, i);\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\t_r_listview_setcolumn (hwnd, listview_id, 0, NULL, -100);\r\n\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tcase IDM_CHECK:\r\n\t\t\t\tcase IDM_UNCHECK:\r\n\t\t\t\t{\r\n\t\t\t\t\tINT listview_id;\r\n\t\t\t\t\tINT item_id = INT_ERROR;\r\n\t\t\t\t\tBOOLEAN new_val;\r\n\r\n\t\t\t\t\tif (GetDlgItem (hwnd, IDC_RULE_APPS_ID))\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tlistview_id = IDC_RULE_APPS_ID;\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse if (GetDlgItem (hwnd, IDC_APP_RULES_ID))\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tlistview_id = IDC_APP_RULES_ID;\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tnew_val = (ctrl_id == IDM_CHECK);\r\n\r\n\t\t\t\t\t_app_listview_lock (hwnd, listview_id, TRUE);\r\n\r\n\t\t\t\t\twhile ((item_id = _r_listview_getnextselected (hwnd, listview_id, item_id)) != INT_ERROR)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t_r_listview_setitemcheck (hwnd, listview_id, item_id, new_val);\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\t_app_listview_lock (hwnd, listview_id, FALSE);\r\n\r\n\t\t\t\t\t_app_listview_refreshgroups (hwnd, listview_id);\r\n\t\t\t\t\t_app_listview_sort (hwnd, listview_id, INT_ERROR, FALSE);\r\n\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tcase IDC_APP_EXPLORE_ID:\r\n\t\t\t\t{\r\n\t\t\t\t\tcontext = _app_editor_getcontext (hwnd);\r\n\r\n\t\t\t\t\tif (!context)\r\n\t\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t\tif (_app_isappvalidpath (context->ptr_app->real_path))\r\n\t\t\t\t\t\t_r_shell_showfile (&context->ptr_app->real_path->sr);\r\n\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tcase IDC_APP_HASH_RECHECK_ID:\r\n\t\t\t\t{\r\n\t\t\t\t\tPR_STRING string;\r\n\t\t\t\t\tHANDLE hfile;\r\n\t\t\t\t\tNTSTATUS status;\r\n\r\n\t\t\t\t\tcontext = _app_editor_getcontext (hwnd);\r\n\r\n\t\t\t\t\tif (!context)\r\n\t\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t\tif (!_app_isappvalidpath (context->ptr_app->real_path))\r\n\t\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t\tstatus = _r_fs_openfile (\r\n\t\t\t\t\t\t&context->ptr_app->real_path->sr,\r\n\t\t\t\t\t\tGENERIC_READ,\r\n\t\t\t\t\t\tFILE_SHARE_READ | FILE_SHARE_DELETE | FILE_SHARE_WRITE,\r\n\t\t\t\t\t\t0,\r\n\t\t\t\t\t\tFALSE,\r\n\t\t\t\t\t\t&hfile\r\n\t\t\t\t\t);\r\n\r\n\t\t\t\t\tif (NT_SUCCESS (status))\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tstring = _app_getfilehashinfo (hfile, context->ptr_app->app_hash);\r\n\r\n\t\t\t\t\t\t_r_ctrl_setstring (hwnd, IDC_APP_HASH_ID, _r_obj_getstringordefault (string, L\"<empty>\"));\r\n\r\n\t\t\t\t\t\tNtClose (hfile);\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tcase IDM_PROPERTIES:\r\n\t\t\t\t{\r\n\t\t\t\t\tULONG_PTR index;\r\n\t\t\t\t\tINT listview_id;\r\n\t\t\t\t\tINT item_id;\r\n\r\n\t\t\t\t\tif (GetDlgItem (hwnd, IDC_RULE_APPS_ID))\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tlistview_id = IDC_RULE_APPS_ID;\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse if (GetDlgItem (hwnd, IDC_APP_RULES_ID))\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tlistview_id = IDC_APP_RULES_ID;\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\titem_id = _r_listview_getnextselected (hwnd, listview_id, INT_ERROR);\r\n\r\n\t\t\t\t\tif (item_id != INT_ERROR)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tindex = _app_listview_getitemcontext (hwnd, listview_id, item_id);\r\n\r\n\t\t\t\t\t\t_app_listview_showitemby_param (_r_app_gethwnd (), index, (listview_id == IDC_RULE_APPS_ID));\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tcase IDM_COPY:\r\n\t\t\t\t{\r\n\t\t\t\t\tR_STRINGBUILDER sb;\r\n\t\t\t\t\tPR_STRING string;\r\n\t\t\t\t\tHWND hlistview;\r\n\t\t\t\t\tINT listview_id;\r\n\t\t\t\t\tINT item_id = INT_ERROR;\r\n\r\n\t\t\t\t\thlistview = GetFocus ();\r\n\r\n\t\t\t\t\tif (!hlistview)\r\n\t\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t\tlistview_id = GetDlgCtrlID (hlistview);\r\n\r\n\t\t\t\t\tif (!listview_id || !_r_listview_getitemcount (hwnd, listview_id))\r\n\t\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t\t_r_obj_initializestringbuilder (&sb, 512);\r\n\r\n\t\t\t\t\twhile ((item_id = _r_listview_getnextselected (hwnd, listview_id, item_id)) != INT_ERROR)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tstring = _r_listview_getitemtext (hwnd, listview_id, item_id, 0);\r\n\r\n\t\t\t\t\t\tif (string)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t_r_obj_appendstringbuilder2 (&sb, &string->sr);\r\n\t\t\t\t\t\t\t_r_obj_appendstringbuilder (&sb, SZ_CRLF);\r\n\r\n\t\t\t\t\t\t\t_r_obj_dereference (string);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tstring = _r_obj_finalstringbuilder (&sb);\r\n\r\n\t\t\t\t\t_r_str_trimstring2 (&string->sr, DIVIDER_TRIM, 0);\r\n\r\n\t\t\t\t\t_r_clipboard_set (hwnd, &string->sr);\r\n\r\n\t\t\t\t\t_r_obj_deletestringbuilder (&sb);\r\n\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\r\n\treturn FALSE;\r\n}\r\n\r\nINT_PTR CALLBACK EditorProc (\r\n\t_In_ HWND hwnd,\r\n\t_In_ UINT msg,\r\n\t_In_ WPARAM wparam,\r\n\t_In_ LPARAM lparam\r\n)\r\n{\r\n\tPEDITOR_CONTEXT context;\r\n\r\n\tswitch (msg)\r\n\t{\r\n\t\tcase WM_INITDIALOG:\r\n\t\t{\r\n\t\t\tWCHAR title[128] = {0};\r\n\t\t\tPR_STRING string;\r\n\r\n\t\t\tcontext = (PEDITOR_CONTEXT)lparam;\r\n\r\n\t\t\t_app_editor_setcontext (hwnd, context);\r\n\r\n\t\t\t// configure tabs\r\n\t\t\tif (context->is_settorules)\r\n\t\t\t{\r\n\t\t\t\t_r_str_copy (title, RTL_NUMBER_OF (title), _r_obj_getstringorempty (context->ptr_rule->name));\r\n\r\n\t\t\t\tif (context->ptr_rule->is_readonly)\r\n\t\t\t\t\t_r_str_appendformat (title, RTL_NUMBER_OF (title), L\" (%s)\", _r_locale_getstring (IDS_INTERNAL_RULE));\r\n\r\n\t\t\t\t_app_editor_addtabitem (hwnd, IDS_SETTINGS_GENERAL, IDD_EDITOR_GENERAL, context);\r\n\t\t\t\t_app_editor_addtabitem (hwnd, IDS_RULE, IDD_EDITOR_RULE, context);\r\n\t\t\t\t_app_editor_addtabitem (hwnd, IDS_TAB_APPS, IDD_EDITOR_APPS, context);\r\n\r\n\t\t\t\t// set state\r\n\t\t\t\t_r_ctrl_setstring (hwnd, IDC_ENABLE_CHK, _r_locale_getstring (IDS_ENABLE_CHK));\r\n\r\n\t\t\t\t_r_ctrl_checkbutton (hwnd, IDC_ENABLE_CHK, !!(context->ptr_rule->is_enabled));\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tstring = _app_getappdisplayname (context->ptr_app, TRUE);\r\n\r\n\t\t\t\tif (string)\r\n\t\t\t\t{\r\n\t\t\t\t\t_r_str_copy (title, RTL_NUMBER_OF (title), string->buffer);\r\n\r\n\t\t\t\t\t_r_obj_dereference (string);\r\n\t\t\t\t}\r\n\r\n\t\t\t\t_app_editor_addtabitem (hwnd, IDS_SETTINGS_GENERAL, IDD_EDITOR_APPINFO, context);\r\n\t\t\t\t_app_editor_addtabitem (hwnd, IDS_TRAY_RULES, IDD_EDITOR_APPRULES, context);\r\n\r\n\t\t\t\t// show state\r\n\t\t\t\t_r_ctrl_setstring (hwnd, IDC_ENABLE_CHK, _r_locale_getstring (IDS_ENABLE_APP_CHK));\r\n\r\n\t\t\t\t_r_ctrl_checkbutton (hwnd, IDC_ENABLE_CHK, !!(context->ptr_app->is_enabled));\r\n\t\t\t}\r\n\r\n\t\t\t// initialize layout\r\n\t\t\t_r_layout_initializemanager (&context->layout_manager, hwnd);\r\n\r\n\t\t\t_r_wnd_top (hwnd, TRUE);\r\n\r\n\t\t\t_r_wnd_center (hwnd, GetParent (hwnd));\r\n\r\n\t\t\t_r_window_restoreposition (hwnd, L\"editor\");\r\n\r\n\t\t\t// set window title\r\n\t\t\t_r_ctrl_setstring (hwnd, 0, title);\r\n\r\n\t\t\t_r_ctrl_setstring (hwnd, IDC_SAVE, _r_locale_getstring (IDS_SAVE));\r\n\t\t\t_r_ctrl_setstring (hwnd, IDC_CLOSE, _r_locale_getstring (IDS_CLOSE));\r\n\r\n\t\t\t_r_tab_selectitem (hwnd, IDC_TAB, _r_calc_clamp (context->page_id, 0, _r_tab_getitemcount (hwnd, IDC_TAB)));\r\n\r\n\t\t\t_r_theme_initialize (hwnd);\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase WM_DESTROY:\r\n\t\t{\r\n\t\t\t_r_window_saveposition (hwnd, L\"editor\");\r\n\r\n\t\t\tcontext = _app_editor_getcontext (hwnd);\r\n\r\n\t\t\tif (context)\r\n\t\t\t\t_r_layout_destroymanager (&context->layout_manager);\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase WM_CLOSE:\r\n\t\t{\r\n\t\t\tEndDialog (hwnd, FALSE);\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase WM_PAINT:\r\n\t\t{\r\n\t\t\tPAINTSTRUCT ps;\r\n\t\t\tHDC hdc;\r\n\r\n\t\t\thdc = BeginPaint (hwnd, &ps);\r\n\r\n\t\t\tif (!hdc)\r\n\t\t\t\tbreak;\r\n\r\n\t\t\t_r_dc_drawwindow (hdc, hwnd, FALSE);\r\n\r\n\t\t\tEndPaint (hwnd, &ps);\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase WM_DPICHANGED:\r\n\t\t{\r\n\t\t\t_r_wnd_message_dpichanged (hwnd, wparam, lparam);\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase WM_SETTINGCHANGE:\r\n\t\t{\r\n\t\t\t_r_wnd_message_settingchange (hwnd, wparam, lparam);\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase WM_SIZE:\r\n\t\t{\r\n\t\t\tHWND hpage;\r\n\t\t\tINT item_id;\r\n\r\n\t\t\tcontext = _app_editor_getcontext (hwnd);\r\n\r\n\t\t\tif (!context)\r\n\t\t\t\tbreak;\r\n\r\n\t\t\t_r_layout_resize (&context->layout_manager, wparam);\r\n\r\n\t\t\titem_id = _r_tab_getcurrentitem (hwnd, IDC_TAB);\r\n\t\t\thpage = (HWND)_r_tab_getitemlparam (hwnd, IDC_TAB, item_id);\r\n\r\n\t\t\tif (hpage)\r\n\t\t\t\t_r_tab_adjustchild (hwnd, IDC_TAB, hpage);\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase WM_GETMINMAXINFO:\r\n\t\t{\r\n\t\t\tcontext = _app_editor_getcontext (hwnd);\r\n\r\n\t\t\tif (!context)\r\n\t\t\t\tbreak;\r\n\r\n\t\t\t_r_layout_resizeminimumsize (&context->layout_manager, lparam);\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase WM_NOTIFY:\r\n\t\t{\r\n\t\t\tLPNMHDR nmlp = (LPNMHDR)lparam;\r\n\r\n\t\t\tswitch (nmlp->code)\r\n\t\t\t{\r\n\t\t\t\tcase TCN_SELCHANGING:\r\n\t\t\t\t{\r\n\t\t\t\t\tHWND hpage;\r\n\t\t\t\t\tINT item_id;\r\n\r\n\t\t\t\t\titem_id = _r_tab_getcurrentitem (hwnd, IDC_TAB);\r\n\t\t\t\t\thpage = (HWND)_r_tab_getitemlparam (hwnd, IDC_TAB, item_id);\r\n\r\n\t\t\t\t\tif (hpage)\r\n\t\t\t\t\t\tShowWindow (hpage, SW_HIDE);\r\n\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tcase TCN_SELCHANGE:\r\n\t\t\t\t{\r\n\t\t\t\t\tHWND hpage;\r\n\t\t\t\t\tINT item_id;\r\n\r\n\t\t\t\t\titem_id = _r_tab_getcurrentitem (hwnd, IDC_TAB);\r\n\t\t\t\t\thpage = (HWND)_r_tab_getitemlparam (hwnd, IDC_TAB, item_id);\r\n\r\n\t\t\t\t\tif (!hpage)\r\n\t\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t\t_r_tab_adjustchild (hwnd, IDC_TAB, hpage);\r\n\r\n\t\t\t\t\tShowWindow (hpage, SW_SHOWNA);\r\n\t\t\t\t\tSetFocus (NULL);\r\n\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase WM_COMMAND:\r\n\t\t{\r\n\t\t\tINT ctrl_id = LOWORD (wparam);\r\n\r\n\t\t\tswitch (ctrl_id)\r\n\t\t\t{\r\n\t\t\t\tcase IDOK: // process Enter key\r\n\t\t\t\tcase IDC_SAVE:\r\n\t\t\t\t{\r\n\t\t\t\t\tHWND hpage_general;\r\n\t\t\t\t\tHWND hpage_rule;\r\n\t\t\t\t\tHWND hpage_apps;\r\n\t\t\t\t\tPR_STRING string;\r\n\t\t\t\t\tPR_LIST rules = NULL;\r\n\t\t\t\t\tPITEM_RULE ptr_rule;\r\n\t\t\t\t\tHANDLE hengine;\r\n\t\t\t\t\tULONG_PTR rule_idx;\r\n\t\t\t\t\tULONG app_hash;\r\n\t\t\t\t\tINT listview_id;\r\n\t\t\t\t\tINT item_id;\r\n\t\t\t\t\tBOOLEAN is_enable;\r\n\r\n\t\t\t\t\tcontext = _app_editor_getcontext (hwnd);\r\n\r\n\t\t\t\t\tif (!context)\r\n\t\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t\thpage_general = (HWND)_r_tab_getitemlparam (hwnd, IDC_TAB, 0);\r\n\t\t\t\t\thpage_rule = (HWND)_r_tab_getitemlparam (hwnd, IDC_TAB, 1);\r\n\r\n\t\t\t\t\tif (context->is_settorules)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\thpage_apps = (HWND)_r_tab_getitemlparam (hwnd, IDC_TAB, 2);\r\n\r\n\t\t\t\t\t\tif (!hpage_general || !_r_ctrl_getstringlength (hpage_general, IDC_RULE_NAME_ID))\r\n\t\t\t\t\t\t\treturn FALSE;\r\n\r\n\t\t\t\t\t\tcontext->ptr_rule->is_haveerrors = FALSE; // reset errors\r\n\r\n\t\t\t\t\t\t// do not change read-only rules\r\n\t\t\t\t\t\tif (!context->ptr_rule->is_readonly)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t// name\r\n\t\t\t\t\t\t\tstring = _r_ctrl_getstring (hpage_general, IDC_RULE_NAME_ID);\r\n\r\n\t\t\t\t\t\t\tif (!string)\r\n\t\t\t\t\t\t\t\treturn FALSE;\r\n\r\n\t\t\t\t\t\t\t_r_str_trimstring2 (&string->sr, DIVIDER_TRIM DIVIDER_RULE, 0);\r\n\r\n\t\t\t\t\t\t\tif (_r_obj_isstringempty2 (string))\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t_r_ctrl_showballoontip (hpage_general, IDC_RULE_NAME_ID, 0, NULL, _r_locale_getstring (IDS_STATUS_EMPTY));\r\n\r\n\t\t\t\t\t\t\t\t_r_obj_dereference (string);\r\n\r\n\t\t\t\t\t\t\t\treturn FALSE;\r\n\t\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t\t_r_obj_movereference ((PVOID_PTR)&context->ptr_rule->name, string);\r\n\r\n\t\t\t\t\t\t\t// comment\r\n\t\t\t\t\t\t\tstring = _r_ctrl_getstring (hpage_general, IDC_RULE_COMMENT_ID);\r\n\r\n\t\t\t\t\t\t\tif (string)\r\n\t\t\t\t\t\t\t\t_r_str_trimstring2 (&string->sr, DIVIDER_TRIM DIVIDER_RULE, 0);\r\n\r\n\t\t\t\t\t\t\t_r_obj_movereference ((PVOID_PTR)&context->ptr_rule->comment, string);\r\n\r\n\t\t\t\t\t\t\tif (hpage_rule)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t// rule (remote)\r\n\t\t\t\t\t\t\t\tstring = _app_editor_getrulesfromlistview (hpage_rule, IDC_RULE_REMOTE_ID, INT_ERROR);\r\n\r\n\t\t\t\t\t\t\t\t_r_obj_movereference ((PVOID_PTR)&context->ptr_rule->rule_remote, string);\r\n\r\n\t\t\t\t\t\t\t\t// rule (local)\r\n\t\t\t\t\t\t\t\tstring = _app_editor_getrulesfromlistview (hpage_rule, IDC_RULE_LOCAL_ID, INT_ERROR);\r\n\r\n\t\t\t\t\t\t\t\t_r_obj_movereference ((PVOID_PTR)&context->ptr_rule->rule_local, string);\r\n\t\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t\titem_id = _r_combobox_getcurrentitem (hpage_general, IDC_RULE_PROTOCOL_ID);\r\n\r\n\t\t\t\t\t\t\tcontext->ptr_rule->protocol = (UINT8)_r_combobox_getitemlparam (hpage_general, IDC_RULE_PROTOCOL_ID, item_id);\r\n\r\n\t\t\t\t\t\t\titem_id = _r_combobox_getcurrentitem (hpage_general, IDC_RULE_VERSION_ID);\r\n\r\n\t\t\t\t\t\t\tcontext->ptr_rule->af = (ADDRESS_FAMILY)_r_combobox_getitemlparam (hpage_general, IDC_RULE_VERSION_ID, item_id);\r\n\r\n\t\t\t\t\t\t\t_r_obj_movereference ((PVOID_PTR)&context->ptr_rule->protocol_str, _r_obj_createstring (_app_db_getprotoname (context->ptr_rule->protocol, context->ptr_rule->af)));\r\n\r\n\t\t\t\t\t\t\titem_id = _r_combobox_getcurrentitem (hpage_general, IDC_RULE_DIRECTION_ID);\r\n\r\n\t\t\t\t\t\t\tcontext->ptr_rule->direction = (FWP_DIRECTION)_r_combobox_getitemlparam (hpage_general, IDC_RULE_DIRECTION_ID, item_id);\r\n\r\n\t\t\t\t\t\t\titem_id = _r_combobox_getcurrentitem (hpage_general, IDC_RULE_ACTION_ID);\r\n\r\n\t\t\t\t\t\t\tcontext->ptr_rule->action = (FWP_ACTION_TYPE)_r_combobox_getitemlparam (hpage_general, IDC_RULE_ACTION_ID, item_id);\r\n\r\n\t\t\t\t\t\t\tif (context->ptr_rule->type == DATA_RULE_USER)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tif (context->ptr_rule->action == FWP_ACTION_BLOCK)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tcontext->ptr_rule->weight = FW_WEIGHT_RULE_USER_BLOCK;\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tcontext->ptr_rule->weight = FW_WEIGHT_RULE_USER;\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t// save rule apps\r\n\t\t\t\t\t\tif (context->ptr_rule->type == DATA_RULE_USER)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t_r_obj_clearhashtable (context->ptr_rule->apps);\r\n\r\n\t\t\t\t\t\t\tfor (INT i = 0; i < _r_listview_getitemcount (hpage_apps, IDC_RULE_APPS_ID); i++)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tif (!_r_listview_isitemchecked (hpage_apps, IDC_RULE_APPS_ID, i))\r\n\t\t\t\t\t\t\t\t\tcontinue;\r\n\r\n\t\t\t\t\t\t\t\tapp_hash = (ULONG)_app_listview_getitemcontext (hpage_apps, IDC_RULE_APPS_ID, i);\r\n\r\n\t\t\t\t\t\t\t\tif (context->ptr_rule->is_forservices && _app_issystemhash (app_hash))\r\n\t\t\t\t\t\t\t\t\tcontinue;\r\n\r\n\t\t\t\t\t\t\t\tif (_app_isappfound (app_hash))\r\n\t\t\t\t\t\t\t\t\t_r_obj_addhashtableitem (context->ptr_rule->apps, app_hash, NULL);\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t// enable rule\r\n\t\t\t\t\t\t_app_ruleenable (context->ptr_rule, _r_ctrl_isbuttonchecked (hwnd, IDC_ENABLE_CHK), TRUE);\r\n\r\n\t\t\t\t\t\trules = _r_obj_createlist (1, NULL);\r\n\r\n\t\t\t\t\t\t_r_obj_addlistitem (rules, context->ptr_rule, NULL);\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tcontext->ptr_app->is_haveerrors = FALSE; // reset errors\r\n\t\t\t\t\t\tcontext->ptr_app->is_enabled = _r_ctrl_isbuttonchecked (hwnd, IDC_ENABLE_CHK);\r\n\r\n\t\t\t\t\t\trules = _r_obj_createlist (1, NULL);\r\n\r\n\t\t\t\t\t\t_r_obj_addlistitem (rules, context->ptr_app, NULL);\r\n\r\n\t\t\t\t\t\t// comment\r\n\t\t\t\t\t\tstring = _r_ctrl_getstring (hpage_general, IDC_APP_COMMENT_ID);\r\n\r\n\t\t\t\t\t\tif (string)\r\n\t\t\t\t\t\t\t_r_str_trimstring2 (&string->sr, DIVIDER_TRIM DIVIDER_RULE, 0);\r\n\r\n\t\t\t\t\t\t_r_obj_movereference ((PVOID_PTR)&context->ptr_app->comment, string);\r\n\r\n\t\t\t\t\t\tif (hpage_rule)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t_r_queuedlock_acquireshared (&lock_rules);\r\n\r\n\t\t\t\t\t\t\tfor (INT i = 0; i < _r_listview_getitemcount (hpage_rule, IDC_APP_RULES_ID); i++)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\trule_idx = _app_listview_getitemcontext (hpage_rule, IDC_APP_RULES_ID, i);\r\n\t\t\t\t\t\t\t\tptr_rule = _r_obj_getlistitem (rules_list, rule_idx);\r\n\r\n\t\t\t\t\t\t\t\tif (!ptr_rule)\r\n\t\t\t\t\t\t\t\t\tcontinue;\r\n\r\n\t\t\t\t\t\t\t\tlistview_id = _app_listview_getbytype (ptr_rule->type);\r\n\t\t\t\t\t\t\t\titem_id = _app_listview_finditem (_r_app_gethwnd (), listview_id, rule_idx);\r\n\r\n\t\t\t\t\t\t\t\tif (item_id != INT_ERROR)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tis_enable = _r_listview_isitemchecked (hpage_rule, IDC_APP_RULES_ID, i);\r\n\r\n\t\t\t\t\t\t\t\t\t_app_setruletoapp (_r_app_gethwnd (), ptr_rule, item_id, context->ptr_app, is_enable);\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t\t_r_queuedlock_releaseshared (&lock_rules);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\t// apply filter\r\n\t\t\t\t\tif (rules)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif (!_r_obj_isempty2 (rules) && _wfp_isfiltersinstalled ())\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\thengine = _wfp_getenginehandle ();\r\n\r\n\t\t\t\t\t\t\tif (context->is_settorules)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t_wfp_create4filters (hengine, rules, DBG_ARG, FALSE);\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t_wfp_create3filters (hengine, rules, DBG_ARG, FALSE);\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t_r_obj_dereference (rules);\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tEndDialog (hwnd, TRUE);\r\n\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tcase IDCANCEL: // process Esc key\r\n\t\t\t\t{\r\n\t\t\t\t\tHWND hpage;\r\n\t\t\t\t\tHWND hsearch;\r\n\t\t\t\t\tINT item_id;\r\n\r\n\t\t\t\t\titem_id = _r_tab_getcurrentitem (hwnd, IDC_TAB);\r\n\t\t\t\t\thpage = (HWND)_r_tab_getitemlparam (hwnd, IDC_TAB, item_id);\r\n\r\n\t\t\t\t\tif (hpage)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\thsearch = GetDlgItem (hpage, IDC_SEARCH);\r\n\r\n\t\t\t\t\t\tif (hsearch)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tif (GetFocus () == hsearch)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t_r_ctrl_setstring (hsearch, 0, L\"\");\r\n\r\n\t\t\t\t\t\t\t\tSetFocus (hwnd);\r\n\r\n\t\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tFALLTHROUGH;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tcase IDC_CLOSE:\r\n\t\t\t\t{\r\n\t\t\t\t\tEndDialog (hwnd, FALSE);\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\r\n\treturn FALSE;\r\n}\r\n"
  },
  {
    "path": "src/editor.h",
    "content": "// simplewall\r\n// Copyright (c) 2016-2025 Henry++\r\n\r\n#pragma once\r\n\r\ntypedef struct _EDITOR_CONTEXT\r\n{\r\n\tR_LAYOUT_MANAGER layout_manager;\r\n\r\n\tHWND hwnd;\r\n\tHICON hicon;\r\n\r\n\tunion\r\n\t{\r\n\t\tPITEM_APP ptr_app;\r\n\t\tPITEM_RULE ptr_rule;\r\n\t};\r\n\r\n\tstruct\r\n\t{\r\n\t\tULONG_PTR current_length;\r\n\t\tINT listview_id;\r\n\t\tINT item_id;\r\n\t};\r\n\r\n\tINT page_id;\r\n\r\n\tBOOLEAN is_settorules;\r\n} EDITOR_CONTEXT, *PEDITOR_CONTEXT;\r\n\r\n_Ret_maybenull_\r\nPEDITOR_CONTEXT _app_editor_createwindow (\r\n\t_In_ HWND hwnd,\r\n\t_In_ PVOID lparam,\r\n\t_In_ INT page_id,\r\n\t_In_ BOOLEAN is_settorules\r\n);\r\n\r\nVOID _app_editor_deletewindow (\r\n\t_In_ PEDITOR_CONTEXT context\r\n);\r\n\r\n_Ret_maybenull_\r\nPEDITOR_CONTEXT _app_editor_getcontext (\r\n\t_In_ HWND hwnd\r\n);\r\n\r\nVOID _app_editor_setcontext (\r\n\t_In_ HWND hwnd,\r\n\t_In_ PEDITOR_CONTEXT context\r\n);\r\n\r\nVOID _app_editor_addtabitem (\r\n\t_In_ HWND hwnd,\r\n\t_In_ UINT locale_id,\r\n\t_In_ INT dlg_id,\r\n\t_In_ PEDITOR_CONTEXT context\r\n);\r\n\r\nVOID _app_editor_settabtitle (\r\n\t_In_ HWND hwnd,\r\n\t_In_ INT listview_id\r\n);\r\n\r\n_Ret_maybenull_\r\nPR_STRING _app_editor_getrulesfromlistview (\r\n\t_In_ HWND hwnd,\r\n\t_In_ INT ctrl_id,\r\n\t_In_ INT exclude_id\r\n);\r\n\r\nVOID _app_editor_setrulestolistview (\r\n\t_In_ HWND hwnd,\r\n\t_In_ INT ctrl_id,\r\n\t_In_ PR_STRING rule\r\n);\r\n\r\nINT_PTR CALLBACK EditorRuleProc (\r\n\t_In_ HWND hwnd,\r\n\t_In_ UINT msg,\r\n\t_In_ WPARAM wparam,\r\n\t_In_ LPARAM lparam\r\n);\r\n\r\nINT_PTR CALLBACK EditorPagesProc (\r\n\t_In_ HWND hwnd,\r\n\t_In_ UINT msg,\r\n\t_In_ WPARAM wparam,\r\n\t_In_ LPARAM lparam\r\n);\r\n\r\nINT_PTR CALLBACK EditorProc (\r\n\t_In_ HWND hwnd,\r\n\t_In_ UINT msg,\r\n\t_In_ WPARAM wparam,\r\n\t_In_ LPARAM lparam\r\n);\r\n"
  },
  {
    "path": "src/global.h",
    "content": "// simplewall\r\n// Copyright (c) 2016-2026 Henry++\r\n\r\n#pragma once\r\n\r\n#include \"routine.h\"\r\n\r\n#include <winsock2.h>\r\n#include <ws2ipdef.h>\r\n#include <ws2tcpip.h>\r\n#include <windns.h>\r\n#include <mstcpip.h>\r\n#include <iphlpapi.h>\r\n#include <aclapi.h>\r\n#include <dbt.h>\r\n#include <fwpmu.h>\r\n#include <mmsystem.h>\r\n#include <netfw.h>\r\n#include <shlguid.h>\r\n#include <shobjidl.h>\r\n#include <softpub.h>\r\n#include <subauth.h>\r\n#include <mscat.h>\r\n\r\n#include \"app.h\"\r\n#include \"rapp.h\"\r\n#include \"main.h\"\r\n\r\n#include \"resource.h\"\r\n\r\nDECLSPEC_SELECTANY STATIC_DATA config = {0};\r\nDECLSPEC_SELECTANY PROFILE_DATA profile_info = {0};\r\n\r\nDECLSPEC_SELECTANY PR_HASHTABLE apps_table = NULL;\r\nDECLSPEC_SELECTANY PR_LIST rules_list = NULL;\r\nDECLSPEC_SELECTANY PR_HASHTABLE rules_config = NULL;\r\nDECLSPEC_SELECTANY PR_HASHTABLE log_table = NULL;\r\n\r\nDECLSPEC_SELECTANY PR_HASHTABLE cache_information = NULL;\r\nDECLSPEC_SELECTANY PR_HASHTABLE cache_resolution = NULL;\r\n\r\nDECLSPEC_SELECTANY PR_HASHTABLE colors_table = NULL;\r\n\r\nDECLSPEC_SELECTANY PR_ARRAY filter_ids = NULL;\r\n\r\nDECLSPEC_SELECTANY R_QUEUED_LOCK lock_apps = PR_QUEUED_LOCK_INIT;\r\nDECLSPEC_SELECTANY R_QUEUED_LOCK lock_apply = PR_QUEUED_LOCK_INIT;\r\nDECLSPEC_SELECTANY R_QUEUED_LOCK lock_rules = PR_QUEUED_LOCK_INIT;\r\nDECLSPEC_SELECTANY R_QUEUED_LOCK lock_rules_config = PR_QUEUED_LOCK_INIT;\r\nDECLSPEC_SELECTANY R_QUEUED_LOCK lock_loglist = PR_QUEUED_LOCK_INIT;\r\nDECLSPEC_SELECTANY R_QUEUED_LOCK lock_notify = PR_QUEUED_LOCK_INIT;\r\nDECLSPEC_SELECTANY R_QUEUED_LOCK lock_profile = PR_QUEUED_LOCK_INIT;\r\nDECLSPEC_SELECTANY R_QUEUED_LOCK lock_transaction = PR_QUEUED_LOCK_INIT;\r\n\r\nDECLSPEC_SELECTANY R_QUEUED_LOCK lock_cache_information = PR_QUEUED_LOCK_INIT;\r\nDECLSPEC_SELECTANY R_QUEUED_LOCK lock_cache_resolution = PR_QUEUED_LOCK_INIT;\r\n\r\nDECLSPEC_SELECTANY R_WORKQUEUE file_queue = {0};\r\nDECLSPEC_SELECTANY R_WORKQUEUE log_queue = {0};\r\nDECLSPEC_SELECTANY R_WORKQUEUE resolver_queue = {0};\r\nDECLSPEC_SELECTANY R_WORKQUEUE resolve_notify_queue = {0};\r\nDECLSPEC_SELECTANY R_WORKQUEUE wfp_queue = {0};\r\n\r\nDECLSPEC_SELECTANY R_FREE_LIST context_free_list = {0};\r\nDECLSPEC_SELECTANY R_FREE_LIST listview_free_list = {0};\r\n\r\n// timers array\r\nDECLSPEC_SELECTANY const LONG64 timer_array[] =\r\n{\r\n\t2 * 60LL, // 2 min\r\n\t5 * 60LL, // 5 min\r\n\t10 * 60LL, // 10 min\r\n\t30 * 60LL, // 30 min\r\n\t1 * 3600LL, // 1 hour\r\n\t2 * 3600LL, // 2 hour\r\n\t4 * 3600LL, // 4 hour\r\n\t6 * 3600LL, // 6 hour\r\n\t12 * 3600LL, // 12 hour\r\n\t24 * 3600LL // 24 hour\r\n};\r\n\r\n// dropped events callback subscription (win7+)\r\n#ifndef FWP_DIRECTION_IN\r\n#define FWP_DIRECTION_IN 0x00003900L\r\n#endif\r\n\r\n#ifndef FWP_DIRECTION_OUT\r\n#define FWP_DIRECTION_OUT 0x00003901L\r\n#endif\r\n\r\n#ifndef FWP_DIRECTION_FORWARD\r\n#define FWP_DIRECTION_FORWARD 0x00003902L\r\n#endif\r\n\r\n#ifndef FWP_DIRECTION_FORWARD2\r\n#define FWP_DIRECTION_FORWARD2 0x00003903L\r\n#endif\r\n\r\n#define WM_NOTIFICATION (WM_APP + 21)\r\n\r\n#include \"controls.h\"\r\n#include \"db.h\"\r\n#include \"editor.h\"\r\n#include \"helper.h\"\r\n#include \"icons.h\"\r\n#include \"listview.h\"\r\n#include \"log.h\"\r\n#include \"messages.h\"\r\n#include \"network.h\"\r\n#include \"notifications.h\"\r\n#include \"packages.h\"\r\n#include \"profile.h\"\r\n#include \"search.h\"\r\n#include \"security.h\"\r\n#include \"timer.h\"\r\n#include \"uwp.h\"\r\n#include \"wfp.h\"\r\n"
  },
  {
    "path": "src/helper.c",
    "content": "// simplewall\r\n// Copyright (c) 2016-2026 Henry++\r\n\r\n#include \"global.h\"\r\n\r\nVOID NTAPI _app_dereferenceapp (\r\n\t_In_ PVOID entry\r\n)\r\n{\r\n\tPITEM_APP ptr_item;\r\n\r\n\tptr_item = entry;\r\n\r\n\tif (ptr_item->display_name)\r\n\t\t_r_obj_dereference (ptr_item->display_name);\r\n\r\n\tif (ptr_item->real_path)\r\n\t\t_r_obj_dereference (ptr_item->real_path);\r\n\r\n\tif (ptr_item->short_name)\r\n\t\t_r_obj_dereference (ptr_item->short_name);\r\n\r\n\tif (ptr_item->original_path)\r\n\t\t_r_obj_dereference (ptr_item->original_path);\r\n\r\n\tif (ptr_item->notification)\r\n\t\t_r_obj_dereference (ptr_item->notification);\r\n\r\n\tif (ptr_item->guids)\r\n\t\t_r_obj_dereference (ptr_item->guids);\r\n}\r\n\r\nVOID NTAPI _app_dereferenceappinfo (\r\n\t_In_ PVOID entry\r\n)\r\n{\r\n\tPITEM_APP_INFO ptr_item;\r\n\r\n\tptr_item = entry;\r\n\r\n\tif (ptr_item->path)\r\n\t\t_r_obj_dereference (ptr_item->path);\r\n\r\n\tif (ptr_item->signature_info)\r\n\t\t_r_obj_dereference (ptr_item->signature_info);\r\n\r\n\tif (ptr_item->version_info)\r\n\t\t_r_obj_dereference (ptr_item->version_info);\r\n}\r\n\r\nVOID NTAPI _app_dereferenceruleconfig (\r\n\t_In_ PVOID entry\r\n)\r\n{\r\n\tPITEM_RULE_CONFIG ptr_item;\r\n\r\n\tptr_item = entry;\r\n\r\n\tif (ptr_item->name)\r\n\t\t_r_obj_dereference (ptr_item->name);\r\n\r\n\tif (ptr_item->apps)\r\n\t\t_r_obj_dereference (ptr_item->apps);\r\n}\r\n\r\nVOID NTAPI _app_dereferencelog (\r\n\t_In_ PVOID entry\r\n)\r\n{\r\n\tPITEM_LOG ptr_item;\r\n\r\n\tptr_item = entry;\r\n\r\n\tif (ptr_item->path)\r\n\t\t_r_obj_dereference (ptr_item->path);\r\n\r\n\tif (ptr_item->filter_name)\r\n\t\t_r_obj_dereference (ptr_item->filter_name);\r\n\r\n\tif (ptr_item->layer_name)\r\n\t\t_r_obj_dereference (ptr_item->layer_name);\r\n\r\n\tif (ptr_item->username)\r\n\t\t_r_obj_dereference (ptr_item->username);\r\n\r\n\tif (ptr_item->protocol_str)\r\n\t\t_r_obj_dereference (ptr_item->protocol_str);\r\n\r\n\tif (ptr_item->local_addr_str)\r\n\t\t_r_obj_dereference (ptr_item->local_addr_str);\r\n\r\n\tif (ptr_item->remote_addr_str)\r\n\t\t_r_obj_dereference (ptr_item->remote_addr_str);\r\n\r\n\tif (ptr_item->local_host_str)\r\n\t\t_r_obj_dereference (ptr_item->local_host_str);\r\n\r\n\tif (ptr_item->remote_host_str)\r\n\t\t_r_obj_dereference (ptr_item->remote_host_str);\r\n}\r\n\r\nVOID NTAPI _app_dereferencenetwork (\r\n\t_In_ PVOID entry\r\n)\r\n{\r\n\tPITEM_NETWORK ptr_item;\r\n\r\n\tptr_item = entry;\r\n\r\n\tif (ptr_item->path)\r\n\t\t_r_obj_dereference (ptr_item->path);\r\n\r\n\tif (ptr_item->protocol_str)\r\n\t\t_r_obj_dereference (ptr_item->protocol_str);\r\n\r\n\tif (ptr_item->local_addr_str)\r\n\t\t_r_obj_dereference (ptr_item->local_addr_str);\r\n\r\n\tif (ptr_item->remote_addr_str)\r\n\t\t_r_obj_dereference (ptr_item->remote_addr_str);\r\n\r\n\tif (ptr_item->local_host_str)\r\n\t\t_r_obj_dereference (ptr_item->local_host_str);\r\n\r\n\tif (ptr_item->remote_host_str)\r\n\t\t_r_obj_dereference (ptr_item->remote_host_str);\r\n}\r\n\r\nVOID NTAPI _app_dereferencerule (\r\n\t_In_ PVOID entry\r\n)\r\n{\r\n\tPITEM_RULE ptr_item;\r\n\r\n\tptr_item = entry;\r\n\r\n\tif (ptr_item->apps)\r\n\t\t_r_obj_dereference (ptr_item->apps);\r\n\r\n\tif (ptr_item->name)\r\n\t\t_r_obj_dereference (ptr_item->name);\r\n\r\n\tif (ptr_item->rule_remote)\r\n\t\t_r_obj_dereference (ptr_item->rule_remote);\r\n\r\n\tif (ptr_item->rule_local)\r\n\t\t_r_obj_dereference (ptr_item->rule_local);\r\n\r\n\tif (ptr_item->protocol_str)\r\n\t\t_r_obj_dereference (ptr_item->protocol_str);\r\n\r\n\tif (ptr_item->guids)\r\n\t\t_r_obj_dereference (ptr_item->guids);\r\n}\r\n\r\nVOID _app_addcachetable (\r\n\t_Inout_ PR_HASHTABLE hashtable,\r\n\t_In_ ULONG hash_code,\r\n\t_In_ PR_QUEUED_LOCK spin_lock,\r\n\t_In_opt_ PR_STRING string\r\n)\r\n{\r\n\tBOOLEAN is_exceed;\r\n\r\n\t// check overflow and do nothing\r\n\t_r_queuedlock_acquireshared (spin_lock);\r\n\tis_exceed = (_r_obj_gethashtablesize (hashtable) >= MAP_CACHE_MAX);\r\n\t_r_queuedlock_releaseshared (spin_lock);\r\n\r\n\tif (is_exceed)\r\n\t\treturn;\r\n\r\n\t_r_queuedlock_acquireexclusive (spin_lock);\r\n\t_r_obj_addhashtablepointer (hashtable, hash_code, string);\r\n\t_r_queuedlock_releaseexclusive (spin_lock);\r\n}\r\n\r\nBOOLEAN _app_getcachetable (\r\n\t_Inout_ PR_HASHTABLE cache_table,\r\n\t_In_ ULONG hash_code,\r\n\t_In_ PR_QUEUED_LOCK spin_lock,\r\n\t_Out_ PR_STRING_PTR string\r\n)\r\n{\r\n\tPR_OBJECT_POINTER object_ptr;\r\n\r\n\t_r_queuedlock_acquireshared (spin_lock);\r\n\tobject_ptr = _r_obj_findhashtable (cache_table, hash_code);\r\n\t_r_queuedlock_releaseshared (spin_lock);\r\n\r\n\tif (object_ptr)\r\n\t{\r\n\t\t*string = _r_obj_referencesafe (object_ptr->object_body);\r\n\r\n\t\treturn TRUE;\r\n\t}\r\n\r\n\t*string = NULL;\r\n\r\n\treturn FALSE;\r\n}\r\n\r\nPR_STRING _app_formatarpa (\r\n\t_In_ ADDRESS_FAMILY af,\r\n\t_In_ LPCVOID address\r\n)\r\n{\r\n\tR_STRINGBUILDER formatted_address;\r\n\tPIN6_ADDR p6addr;\r\n\tPIN_ADDR p4addr;\r\n\r\n\t_r_obj_initializestringbuilder (&formatted_address, 256);\r\n\r\n\tswitch (af)\r\n\t{\r\n\t\tcase AF_INET:\r\n\t\t{\r\n\t\t\tp4addr = (const PIN_ADDR)address;\r\n\r\n\t\t\t_r_obj_appendstringbuilderformat (\r\n\t\t\t\t&formatted_address,\r\n\t\t\t\tL\"%hhu.%hhu.%hhu.%hhu.%s\",\r\n\t\t\t\tp4addr->s_impno,\r\n\t\t\t\tp4addr->s_lh,\r\n\t\t\t\tp4addr->s_host,\r\n\t\t\t\tp4addr->s_net,\r\n\t\t\t\tDNS_IP4_REVERSE_DOMAIN_STRING_W\r\n\t\t\t);\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase AF_INET6:\r\n\t\t{\r\n\t\t\tp6addr = (const PIN6_ADDR)address;\r\n\r\n\t\t\tfor (INT i = sizeof (IN6_ADDR) - 1; i >= 0; i--)\r\n\t\t\t{\r\n\t\t\t\t_r_obj_appendstringbuilderformat (\r\n\t\t\t\t\t&formatted_address,\r\n\t\t\t\t\tL\"%hhx.%hhx.\",\r\n\t\t\t\t\tp6addr->s6_addr[i] & 0xF,\r\n\t\t\t\t\t(p6addr->s6_addr[i] >> 4) & 0xF\r\n\t\t\t\t);\r\n\t\t\t}\r\n\r\n\t\t\t_r_obj_appendstringbuilder (&formatted_address, DNS_IP6_REVERSE_DOMAIN_STRING_W);\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\r\n\treturn _r_obj_finalstringbuilder (&formatted_address);\r\n}\r\n\r\n_Ret_maybenull_\r\nPR_STRING _app_formataddress (\r\n\t_In_ ADDRESS_FAMILY af,\r\n\t_In_ UINT8 proto,\r\n\t_In_ LPCVOID address,\r\n\t_In_opt_ UINT16 port,\r\n\t_In_ ULONG flags\r\n)\r\n{\r\n\tWCHAR addr_str[DNS_MAX_NAME_BUFFER_LENGTH];\r\n\tR_STRINGBUILDER formatted_address;\r\n\tLPCWSTR string;\r\n\tNTSTATUS status;\r\n\r\n\t_r_obj_initializestringbuilder (&formatted_address, 0x100);\r\n\r\n\tif (flags & FMTADDR_USE_PROTOCOL)\r\n\t{\r\n\t\tstring = _app_db_getprotoname (proto, af);\r\n\r\n\t\tif (_r_str_compare (string, L\"n/a\", FALSE) != 0)\r\n\t\t{\r\n\t\t\t_r_obj_appendstringbuilder (&formatted_address, string);\r\n\t\t\t_r_obj_appendstringbuilder (&formatted_address, L\"://\");\r\n\t\t}\r\n\t}\r\n\r\n\tstatus = _app_formatip (af, address, addr_str, RTL_NUMBER_OF (addr_str), !!(flags & FMTADDR_AS_RULE));\r\n\r\n\tif (NT_SUCCESS (status))\r\n\t{\r\n\t\tif (af == AF_INET6 && port)\r\n\t\t{\r\n\t\t\t_r_obj_appendstringbuilderformat (&formatted_address, L\"[%s]\", addr_str);\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\t_r_obj_appendstringbuilder (&formatted_address, addr_str);\r\n\t\t}\r\n\t}\r\n\r\n\tif (port && !(flags & FMTADDR_USE_PROTOCOL))\r\n\t{\r\n\t\t_r_obj_appendstringbuilderformat (&formatted_address, NT_SUCCESS (status) ? L\":%\" TEXT (PRIu16) : L\"%\" TEXT (PRIu16), port);\r\n\r\n\t\tstatus = STATUS_SUCCESS;\r\n\t}\r\n\r\n\tif (NT_SUCCESS (status))\r\n\t\treturn _r_obj_finalstringbuilder (&formatted_address);\r\n\r\n\t_r_obj_deletestringbuilder (&formatted_address);\r\n\r\n\treturn NULL;\r\n}\r\n\r\nPR_STRING _app_formataddress_interlocked (\r\n\t_In_ PVOID volatile *string,\r\n\t_In_ ADDRESS_FAMILY af,\r\n\t_In_ LPCVOID address\r\n)\r\n{\r\n\tPR_STRING current_string;\r\n\tPR_STRING new_string;\r\n\r\n\tcurrent_string = _InterlockedCompareExchangePointer (string, NULL, NULL);\r\n\r\n\tif (current_string)\r\n\t\treturn current_string;\r\n\r\n\tnew_string = _app_formataddress (af, 0, address, 0, 0);\r\n\r\n\tcurrent_string = _InterlockedCompareExchangePointer (string, new_string, NULL);\r\n\r\n\tif (!current_string)\r\n\t{\r\n\t\tcurrent_string = new_string;\r\n\t}\r\n\telse\r\n\t{\r\n\t\tif (new_string)\r\n\t\t\t_r_obj_dereference (new_string);\r\n\t}\r\n\r\n\treturn current_string;\r\n}\r\n\r\n_Success_ (NT_SUCCESS (return))\r\nNTSTATUS _app_formatip (\r\n\t_In_ ADDRESS_FAMILY af,\r\n\t_In_ LPCVOID address,\r\n\t_Out_writes_to_ (buffer_length, buffer_length) LPWSTR buffer,\r\n\t_In_ ULONG buffer_length,\r\n\t_In_ BOOLEAN is_checkempty\r\n)\r\n{\r\n\tPIN_ADDR p4addr;\r\n\tPIN6_ADDR p6addr;\r\n\tNTSTATUS status;\r\n\r\n\tswitch (af)\r\n\t{\r\n\t\tcase AF_INET:\r\n\t\t{\r\n\t\t\tp4addr = (PIN_ADDR)address;\r\n\r\n\t\t\tif (is_checkempty)\r\n\t\t\t{\r\n\t\t\t\tif (IN4_IS_ADDR_UNSPECIFIED (p4addr))\r\n\t\t\t\t\treturn STATUS_INVALID_ADDRESS_COMPONENT;\r\n\t\t\t}\r\n\r\n\t\t\tstatus = RtlIpv4AddressToStringExW (p4addr, 0, buffer, &buffer_length);\r\n\r\n\t\t\treturn status;\r\n\t\t}\r\n\r\n\t\tcase AF_INET6:\r\n\t\t{\r\n\t\t\tp6addr = (PIN6_ADDR)address;\r\n\r\n\t\t\tif (is_checkempty)\r\n\t\t\t{\r\n\t\t\t\tif (IN6_IS_ADDR_UNSPECIFIED (p6addr))\r\n\t\t\t\t\treturn STATUS_INVALID_ADDRESS_COMPONENT;\r\n\t\t\t}\r\n\r\n\t\t\tstatus = RtlIpv6AddressToStringExW (p6addr, 0, 0, buffer, &buffer_length);\r\n\r\n\t\t\treturn status;\r\n\t\t}\r\n\t}\r\n\r\n\treturn STATUS_INVALID_PARAMETER;\r\n}\r\n\r\nPR_STRING _app_formatport (\r\n\t_In_ UINT16 port,\r\n\t_In_ UINT8 proto\r\n)\r\n{\r\n\tLPCWSTR service_string;\r\n\r\n\tservice_string = _app_db_getservicename (port, proto);\r\n\r\n\tif (service_string)\r\n\t\treturn _r_format_string (L\"%\" TEXT (PRIu16) L\" (%s)\", port, service_string);\r\n\r\n\treturn _r_format_string (L\"%\" TEXT (PRIu16), port);\r\n}\r\n\r\n_Ret_maybenull_\r\nPITEM_APP_INFO _app_getappinfobyhash2 (\r\n\t_In_ ULONG app_hash\r\n)\r\n{\r\n\tPITEM_APP_INFO ptr_app_info;\r\n\r\n\t_r_queuedlock_acquireshared (&lock_cache_information);\r\n\tptr_app_info = _r_obj_findhashtablepointer (cache_information, app_hash);\r\n\t_r_queuedlock_releaseshared (&lock_cache_information);\r\n\r\n\treturn ptr_app_info;\r\n}\r\n\r\n_Success_ (return)\r\nBOOLEAN _app_getappinfoparam2 (\r\n\t_In_ ULONG app_hash,\r\n\t_In_opt_ INT listview_id,\r\n\t_In_ ENUM_INFO_DATA2 info_data,\r\n\t_Out_writes_bytes_all_ (length) PVOID buffer,\r\n\t_In_ ULONG_PTR length\r\n)\r\n{\r\n\tPITEM_APP_INFO ptr_app_info;\r\n\r\n\tptr_app_info = _app_getappinfobyhash2 (app_hash);\r\n\r\n\tswitch (info_data)\r\n\t{\r\n\t\tcase INFO_ICON_ID:\r\n\t\t{\r\n\t\t\tLONG icon_id = 0;\r\n\r\n\t\t\tif (length != sizeof (LONG))\r\n\t\t\t{\r\n\t\t\t\tif (ptr_app_info)\r\n\t\t\t\t\t_r_obj_dereference (ptr_app_info);\r\n\r\n\t\t\t\treturn FALSE;\r\n\t\t\t}\r\n\r\n\t\t\tif (ptr_app_info)\r\n\t\t\t\ticon_id = ptr_app_info->icon_id;\r\n\r\n\t\t\tif (!icon_id)\r\n\t\t\t\ticon_id = _app_icons_getdefaultapp_id ((listview_id == IDC_APPS_UWP) ? DATA_APP_UWP : DATA_APP_REGULAR);\r\n\r\n\t\t\tif (icon_id)\r\n\t\t\t{\r\n\t\t\t\tRtlCopyMemory (buffer, &icon_id, length);\r\n\r\n\t\t\t\tif (ptr_app_info)\r\n\t\t\t\t\t_r_obj_dereference (ptr_app_info);\r\n\r\n\t\t\t\treturn TRUE;\r\n\t\t\t}\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase INFO_SIGNATURE_STRING:\r\n\t\t{\r\n\t\t\tPVOID ptr;\r\n\r\n\t\t\tif (length != sizeof (PVOID))\r\n\t\t\t{\r\n\t\t\t\tif (ptr_app_info)\r\n\t\t\t\t\t_r_obj_dereference (ptr_app_info);\r\n\r\n\t\t\t\treturn FALSE;\r\n\t\t\t}\r\n\r\n\t\t\tif (ptr_app_info && !_r_obj_isstringempty (ptr_app_info->signature_info))\r\n\t\t\t{\r\n\t\t\t\tptr = _r_obj_reference (ptr_app_info->signature_info);\r\n\r\n\t\t\t\tRtlCopyMemory (buffer, &ptr, length);\r\n\r\n\t\t\t\t_r_obj_dereference (ptr_app_info);\r\n\r\n\t\t\t\treturn TRUE;\r\n\t\t\t}\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase INFO_VERSION_STRING:\r\n\t\t{\r\n\t\t\tPVOID ptr;\r\n\r\n\t\t\tif (length != sizeof (PVOID))\r\n\t\t\t{\r\n\t\t\t\tif (ptr_app_info)\r\n\t\t\t\t\t_r_obj_dereference (ptr_app_info);\r\n\r\n\t\t\t\treturn FALSE;\r\n\t\t\t}\r\n\r\n\t\t\tif (ptr_app_info && !_r_obj_isstringempty (ptr_app_info->version_info))\r\n\t\t\t{\r\n\t\t\t\tptr = _r_obj_reference (ptr_app_info->version_info);\r\n\r\n\t\t\t\tRtlCopyMemory (buffer, &ptr, length);\r\n\r\n\t\t\t\t_r_obj_dereference (ptr_app_info);\r\n\r\n\t\t\t\treturn TRUE;\r\n\t\t\t}\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\r\n\tif (ptr_app_info)\r\n\t\t_r_obj_dereference (ptr_app_info);\r\n\r\n\treturn FALSE;\r\n}\r\n\r\nBOOLEAN _app_isappsigned (\r\n\t_In_ ULONG app_hash\r\n)\r\n{\r\n\tPR_STRING string = NULL;\r\n\tBOOLEAN is_signed = FALSE;\r\n\r\n\tif (_app_getappinfoparam2 (app_hash, 0, INFO_SIGNATURE_STRING, &string, sizeof (PR_STRING)))\r\n\t{\r\n\t\tis_signed = !_r_obj_isstringempty2 (string);\r\n\r\n\t\t_r_obj_dereference (string);\r\n\t}\r\n\r\n\treturn is_signed;\r\n}\r\n\r\nBOOLEAN _app_isappvalidbinary (\r\n\t_In_opt_ PR_STRING path\r\n)\r\n{\r\n\tif (!path)\r\n\t\treturn FALSE;\r\n\r\n\tif (!_app_isappvalidpath (path))\r\n\t\treturn FALSE;\r\n\r\n\tif (_r_str_isendsswith2 (&path->sr, L\".exe\", TRUE))\r\n\t\treturn TRUE;\r\n\r\n\treturn FALSE;\r\n}\r\n\r\nBOOLEAN _app_isappvalidpath (\r\n\t_In_opt_ PR_STRING path\r\n)\r\n{\r\n\tif (!path)\r\n\t\treturn FALSE;\r\n\r\n\tif (path->length <= (3 * sizeof (WCHAR)))\r\n\t\treturn FALSE;\r\n\r\n\tif (path->buffer[1] != L':' || path->buffer[2] != L'\\\\')\r\n\t\treturn FALSE;\r\n\r\n\treturn TRUE;\r\n}\r\n\r\n_Ret_maybenull_\r\nPR_STRING _app_getappdisplayname (\r\n\t_In_ PITEM_APP ptr_app,\r\n\t_In_ BOOLEAN is_shortened\r\n)\r\n{\r\n\tif (ptr_app->app_hash == config.ntoskrnl_hash)\r\n\t{\r\n\t\tif (!_r_obj_isstringempty (ptr_app->original_path))\r\n\t\t\treturn _r_obj_reference (ptr_app->original_path);\r\n\t}\r\n\r\n\tswitch (ptr_app->type)\r\n\t{\r\n\t\tcase DATA_APP_SERVICE:\r\n\t\t{\r\n\t\t\tif (!_r_obj_isstringempty (ptr_app->original_path))\r\n\t\t\t\treturn _r_obj_reference (ptr_app->original_path);\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase DATA_APP_UWP:\r\n\t\t{\r\n\t\t\tif (!_r_obj_isstringempty (ptr_app->display_name))\r\n\t\t\t\treturn _r_obj_reference (ptr_app->display_name);\r\n\r\n\t\t\tif (!_r_obj_isstringempty (ptr_app->real_path))\r\n\t\t\t\treturn _r_obj_reference (ptr_app->real_path);\r\n\r\n\t\t\tif (!_r_obj_isstringempty (ptr_app->original_path))\r\n\t\t\t\treturn _r_obj_reference (ptr_app->original_path);\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\r\n\tif (is_shortened || _r_config_getboolean (L\"ShowFilenames\", TRUE, NULL))\r\n\t{\r\n\t\tif (!_r_obj_isstringempty (ptr_app->short_name))\r\n\t\t\treturn _r_obj_reference (ptr_app->short_name);\r\n\t}\r\n\r\n\tif (!_r_obj_isstringempty (ptr_app->real_path))\r\n\t\treturn _r_obj_reference (ptr_app->real_path);\r\n\r\n\treturn NULL;\r\n}\r\n\r\n_Ret_maybenull_\r\nPR_STRING _app_getapppath (\r\n\t_In_ PITEM_APP ptr_app,\r\n\t_In_ BOOLEAN is_returnshort\r\n)\r\n{\r\n\tPR_STRING path = NULL;\r\n\tPR_STRING  string;\r\n\r\n\tif (ptr_app->type == DATA_APP_UWP || ptr_app->type == DATA_APP_SERVICE)\r\n\t{\r\n\t\tif (ptr_app->real_path)\r\n\t\t\tpath = _r_obj_reference (ptr_app->real_path);\r\n\r\n\t\tif (ptr_app->display_name)\r\n\t\t\tpath = _r_obj_reference (ptr_app->display_name);\r\n\t}\r\n\r\n\tif (ptr_app->original_path)\r\n\t\tpath = _r_obj_reference (ptr_app->original_path);\r\n\r\n\tif (ptr_app->real_path)\r\n\t\tpath = _r_obj_reference (ptr_app->real_path);\r\n\r\n\tif (is_returnshort && path)\r\n\t{\r\n\t\tstring = _r_str_environmentunexpandstring (&path->sr);\r\n\r\n\t\t_r_obj_movereference ((PVOID_PTR)&path, _r_path_compact (&string->sr, 64));\r\n\r\n\t\t_r_obj_dereference (string);\r\n\t}\r\n\r\n\treturn path;\r\n}\r\n\r\nVOID _app_getfileicon (\r\n\t_Inout_ PITEM_APP_INFO ptr_app_info\r\n)\r\n{\r\n\tLONG icon_id = 0;\r\n\tBOOLEAN is_iconshidded;\r\n\r\n\tis_iconshidded = _r_config_getboolean (L\"IsIconsHidden\", FALSE, NULL);\r\n\r\n\tif (is_iconshidded || !_app_isappvalidbinary (ptr_app_info->path))\r\n\t{\r\n\t\t_app_icons_loadfromfile (NULL, ptr_app_info->type, &icon_id, NULL, TRUE);\r\n\t}\r\n\telse\r\n\t{\r\n\t\t_app_icons_loadfromfile (ptr_app_info->path, ptr_app_info->type, &icon_id, NULL, TRUE);\r\n\t}\r\n\r\n\tptr_app_info->icon_id = icon_id;\r\n}\r\n\r\n_Success_ (return)\r\nBOOLEAN _app_calculatefilehash (\r\n\t_In_ HANDLE hfile,\r\n\t_In_opt_ LPCWSTR algorithm_id,\r\n\t_Out_ PVOID_PTR file_hash_ptr,\r\n\t_Out_ PULONG file_hash_length_ptr,\r\n\t_Out_ HCATADMIN_PTR hcat_admin_ptr\r\n)\r\n{\r\n\tstatic R_INITONCE init_once = PR_INITONCE_INIT;\r\n\tstatic CCAHFFH2 _CryptCATAdminCalcHashFromFileHandle2 = NULL;\r\n\tstatic CCAAC2 _CryptCATAdminAcquireContext2 = NULL;\r\n\r\n\tGUID DriverActionVerify = DRIVER_ACTION_VERIFY;\r\n\tHCATADMIN hcat_admin;\r\n\tPVOID hwintrust;\r\n\tPBYTE file_hash;\r\n\tULONG file_hash_length = 32;\r\n\tNTSTATUS status;\r\n\r\n\tif (_r_initonce_begin (&init_once))\r\n\t{\r\n\t\tstatus = _r_sys_loadlibrary2 (L\"wintrust.dll\", 0, &hwintrust);\r\n\r\n\t\tif (NT_SUCCESS (status))\r\n\t\t{\r\n\t\t\t_CryptCATAdminAcquireContext2 = _r_sys_getprocaddress (hwintrust, \"CryptCATAdminAcquireContext2\", 0);\r\n\t\t\t_CryptCATAdminCalcHashFromFileHandle2 = _r_sys_getprocaddress (hwintrust, \"CryptCATAdminCalcHashFromFileHandle2\", 0);\r\n\r\n\t\t\t// _r_sys_freelibrary (hwintrust, FALSE);\r\n\t\t}\r\n\r\n\t\t_r_initonce_end (&init_once);\r\n\t}\r\n\r\n\tif (_CryptCATAdminAcquireContext2)\r\n\t{\r\n\t\tif (!_CryptCATAdminAcquireContext2 (&hcat_admin, &DriverActionVerify, algorithm_id, NULL, 0))\r\n\t\t\treturn FALSE;\r\n\t}\r\n\telse\r\n\t{\r\n\t\tif (!CryptCATAdminAcquireContext (&hcat_admin, &DriverActionVerify, 0))\r\n\t\t\treturn FALSE;\r\n\t}\r\n\r\n\tfile_hash = _r_mem_allocate (file_hash_length);\r\n\r\n\tif (_CryptCATAdminCalcHashFromFileHandle2)\r\n\t{\r\n\t\tif (!_CryptCATAdminCalcHashFromFileHandle2 (hcat_admin, hfile, &file_hash_length, file_hash, 0))\r\n\t\t{\r\n\t\t\tfile_hash = _r_mem_reallocate (file_hash, file_hash_length);\r\n\r\n\t\t\tif (!_CryptCATAdminCalcHashFromFileHandle2 (hcat_admin, hfile, &file_hash_length, file_hash, 0))\r\n\t\t\t{\r\n\t\t\t\tCryptCATAdminReleaseContext (hcat_admin, 0);\r\n\r\n\t\t\t\t_r_mem_free (file_hash);\r\n\r\n\t\t\t\treturn FALSE;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\telse\r\n\t{\r\n\t\tif (!CryptCATAdminCalcHashFromFileHandle (hfile, &file_hash_length, file_hash, 0))\r\n\t\t{\r\n\t\t\tfile_hash = _r_mem_reallocate (file_hash, file_hash_length);\r\n\r\n\t\t\tif (!CryptCATAdminCalcHashFromFileHandle (hfile, &file_hash_length, file_hash, 0))\r\n\t\t\t{\r\n\t\t\t\tCryptCATAdminReleaseContext (hcat_admin, 0);\r\n\r\n\t\t\t\t_r_mem_free (file_hash);\r\n\r\n\t\t\t\treturn FALSE;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t*file_hash_ptr = file_hash;\r\n\t*file_hash_length_ptr = file_hash_length;\r\n\t*hcat_admin_ptr = hcat_admin;\r\n\r\n\treturn TRUE;\r\n}\r\n\r\n_Ret_maybenull_\r\nPR_STRING _app_verifygetstring (\r\n\t_In_ HANDLE state_data\r\n)\r\n{\r\n\tPCRYPT_PROVIDER_DATA prov_data;\r\n\tPCRYPT_PROVIDER_SGNR prov_signer;\r\n\tPCRYPT_PROVIDER_CERT prov_cert;\r\n\tPR_STRING string;\r\n\tULONG length;\r\n\tULONG idx = 0;\r\n\r\n\tprov_data = WTHelperProvDataFromStateData (state_data);\r\n\r\n\tif (prov_data)\r\n\t{\r\n\t\twhile (TRUE)\r\n\t\t{\r\n\t\t\tprov_signer = WTHelperGetProvSignerFromChain (prov_data, idx, FALSE, 0);\r\n\r\n\t\t\tif (!prov_signer)\r\n\t\t\t\tbreak;\r\n\r\n\t\t\tprov_cert = WTHelperGetProvCertFromChain (prov_signer, idx);\r\n\r\n\t\t\tif (!prov_cert)\r\n\t\t\t\tbreak;\r\n\r\n\t\t\tlength = CertGetNameStringW (prov_cert->pCert, CERT_NAME_ATTR_TYPE, 0, szOID_COMMON_NAME, NULL, 0) - 1;\r\n\r\n\t\t\tif (length > 1)\r\n\t\t\t{\r\n\t\t\t\tstring = _r_obj_createstring_ex (NULL, length * sizeof (WCHAR));\r\n\r\n\t\t\t\tCertGetNameStringW (prov_cert->pCert, CERT_NAME_ATTR_TYPE, 0, szOID_COMMON_NAME, string->buffer, length + 1);\r\n\r\n\t\t\t\t_r_str_trimtonullterminator (&string->sr);\r\n\r\n\t\t\t\treturn string;\r\n\t\t\t}\r\n\r\n\t\t\tidx += 1;\r\n\t\t}\r\n\t}\r\n\r\n\treturn NULL;\r\n}\r\n\r\nLONG _app_verifyfromfile (\r\n\t_In_ ULONG union_choice,\r\n\t_In_ PVOID union_data,\r\n\t_In_ LPGUID action_id,\r\n\t_In_opt_ PVOID policy_callback,\r\n\t_Out_ PR_STRING_PTR signature_string\r\n)\r\n{\r\n\tWINTRUST_DATA trust_data = {0};\r\n\tLONG status;\r\n\r\n\ttrust_data.cbStruct = sizeof (trust_data);\r\n\ttrust_data.dwUIChoice = WTD_UI_NONE;\r\n\ttrust_data.fdwRevocationChecks = WTD_REVOKE_WHOLECHAIN;\r\n\ttrust_data.pPolicyCallbackData = policy_callback;\r\n\ttrust_data.dwUnionChoice = union_choice;\r\n\ttrust_data.dwStateAction = WTD_STATEACTION_VERIFY;\r\n\ttrust_data.dwProvFlags = WTD_SAFER_FLAG | WTD_DISABLE_MD2_MD4;\r\n\r\n\ttrust_data.pFile = union_data;\r\n\r\n\tif (union_choice == WTD_CHOICE_CATALOG)\r\n\t\ttrust_data.pCatalog = union_data;\r\n\r\n\tif (_r_config_getboolean (L\"IsOCSPEnabled\", FALSE, NULL))\r\n\t{\r\n\t\ttrust_data.fdwRevocationChecks = WTD_REVOKE_WHOLECHAIN;\r\n\t\ttrust_data.dwProvFlags = WTD_SAFER_FLAG;\r\n\t}\r\n\telse\r\n\t{\r\n\t\ttrust_data.fdwRevocationChecks = WTD_REVOKE_NONE;\r\n\t\ttrust_data.dwProvFlags = WTD_SAFER_FLAG | WTD_CACHE_ONLY_URL_RETRIEVAL;\r\n\t}\r\n\r\n\ttrust_data.dwStateAction = WTD_STATEACTION_VERIFY;\r\n\tstatus = WinVerifyTrust (INVALID_HANDLE_VALUE, action_id, &trust_data);\r\n\r\n\tif (status == ERROR_SUCCESS && trust_data.hWVTStateData)\r\n\t{\r\n\t\t*signature_string = _app_verifygetstring (trust_data.hWVTStateData);\r\n\t}\r\n\telse\r\n\t{\r\n\t\t*signature_string = NULL;\r\n\t}\r\n\r\n\t// Close state data\r\n\ttrust_data.dwStateAction = WTD_STATEACTION_CLOSE;\r\n\tWinVerifyTrust (INVALID_HANDLE_VALUE, action_id, &trust_data);\r\n\r\n\treturn status;\r\n}\r\n\r\nNTSTATUS _app_verifyfilefromcatalog (\r\n\t_In_ HANDLE hfile,\r\n\t_In_ LPCWSTR path,\r\n\t_In_opt_ LPCWSTR algorithm_id,\r\n\t_Out_ PR_STRING_PTR signature_string\r\n)\r\n{\r\n\tGUID DriverActionVerify = DRIVER_ACTION_VERIFY;\r\n\tWINTRUST_CATALOG_INFO catalog_info = {0};\r\n\tDRIVER_VER_INFO ver_info = {0};\r\n\tCATALOG_INFO ci = {0};\r\n\tHCATADMIN hcat_admin;\r\n\tHCATINFO hcat_info;\r\n\tPR_STRING string = NULL;\r\n\tPR_STRING file_hash_tag;\r\n\tPVOID file_hash;\r\n\tLONG64 file_size;\r\n\tULONG file_hash_length;\r\n\tNTSTATUS status;\r\n\r\n\tstatus = _r_fs_getsize2 (NULL, hfile, &file_size);\r\n\r\n\tif (!NT_SUCCESS (status))\r\n\t{\r\n\t\t*signature_string = NULL;\r\n\r\n\t\treturn status;\r\n\t}\r\n\r\n\tif (!file_size || file_size > _r_calc_megabytes2bytes64 (32))\r\n\t{\r\n\t\t*signature_string = NULL;\r\n\r\n\t\treturn STATUS_FILE_TOO_LARGE;\r\n\t}\r\n\r\n\tif (_app_calculatefilehash (hfile, algorithm_id, &file_hash, &file_hash_length, &hcat_admin))\r\n\t{\r\n\t\thcat_info = CryptCATAdminEnumCatalogFromHash (hcat_admin, file_hash, file_hash_length, 0, NULL);\r\n\r\n\t\tif (hcat_info)\r\n\t\t{\r\n\t\t\tfile_hash_tag = _r_str_fromhex (file_hash, file_hash_length, TRUE);\r\n\r\n\t\t\tif (CryptCATCatalogInfoFromContext (hcat_info, &ci, 0))\r\n\t\t\t{\r\n\t\t\t\t// Disable OS version checking by passing in a DRIVER_VER_INFO structure.\r\n\t\t\t\tver_info.cbStruct = sizeof (DRIVER_VER_INFO);\r\n\r\n\t\t\t\tcatalog_info.cbStruct = sizeof (catalog_info);\r\n\t\t\t\tcatalog_info.pcwszCatalogFilePath = ci.wszCatalogFile;\r\n\t\t\t\tcatalog_info.pcwszMemberFilePath = path;\r\n\t\t\t\tcatalog_info.hMemberFile = hfile;\r\n\t\t\t\tcatalog_info.pcwszMemberTag = file_hash_tag->buffer;\r\n\t\t\t\tcatalog_info.pbCalculatedFileHash = file_hash;\r\n\t\t\t\tcatalog_info.cbCalculatedFileHash = file_hash_length;\r\n\t\t\t\tcatalog_info.hCatAdmin = hcat_admin;\r\n\r\n\t\t\t\tstatus = _app_verifyfromfile (WTD_CHOICE_CATALOG, &catalog_info, &DriverActionVerify, &ver_info, &string);\r\n\r\n\t\t\t\tif (ver_info.pcSignerCertContext)\r\n\t\t\t\t\tCertFreeCertificateContext (ver_info.pcSignerCertContext);\r\n\t\t\t}\r\n\r\n\t\t\tCryptCATAdminReleaseCatalogContext (hcat_admin, hcat_info, 0);\r\n\r\n\t\t\t_r_obj_dereference (file_hash_tag);\r\n\t\t}\r\n\r\n\t\t*signature_string = string;\r\n\r\n\t\tCryptCATAdminReleaseContext (hcat_admin, 0);\r\n\r\n\t\t_r_mem_free (file_hash);\r\n\t}\r\n\telse\r\n\t{\r\n\t\t*signature_string = NULL;\r\n\r\n\t\tstatus = TRUST_E_SUBJECT_FORM_UNKNOWN;\r\n\t}\r\n\r\n\treturn status;\r\n}\r\n\r\nVOID _app_getfilesignatureinfo (\r\n\t_In_ HANDLE hfile,\r\n\t_Inout_ PITEM_APP_INFO ptr_app_info\r\n)\r\n{\r\n\tGUID WinTrustActionGenericVerifyV2 = WINTRUST_ACTION_GENERIC_VERIFY_V2;\r\n\tWINTRUST_FILE_INFO file_info = {0};\r\n\tPR_STRING string = NULL;\r\n\tLONG status;\r\n\r\n\t__try\r\n\t{\r\n\t\tif (ptr_app_info->signature_info)\r\n\t\t\t_r_obj_clearreference ((PVOID_PTR)&ptr_app_info->signature_info);\r\n\t}\r\n\t__except (EXCEPTION_EXECUTE_HANDLER)\r\n\t{\r\n\t\tNOTHING;\r\n\t}\r\n\r\n\tfile_info.cbStruct = sizeof (file_info);\r\n\tfile_info.pcwszFilePath = ptr_app_info->path->buffer;\r\n\tfile_info.hFile = hfile;\r\n\r\n\tstatus = _app_verifyfromfile (WTD_CHOICE_FILE, &file_info, &WinTrustActionGenericVerifyV2, NULL, &string);\r\n\r\n\tif (status == TRUST_E_NOSIGNATURE)\r\n\t{\r\n\t\tif (_r_sys_isosversiongreaterorequal (WINDOWS_8))\r\n\t\t{\r\n\t\t\tstatus = _app_verifyfilefromcatalog (hfile, ptr_app_info->path->buffer, BCRYPT_SHA256_ALGORITHM, &string);\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tstatus = _app_verifyfilefromcatalog (hfile, ptr_app_info->path->buffer, NULL, &string);\r\n\t\t}\r\n\r\n\t\tif (status == TRUST_E_NOSIGNATURE)\r\n\t\t\t_app_verifyfilefromcatalog (hfile, ptr_app_info->path->buffer, BCRYPT_SHA1_ALGORITHM, &string);\r\n\t}\r\n\r\n\t__try\r\n\t{\r\n\t\t_r_obj_movereference ((PVOID_PTR)&ptr_app_info->signature_info, string);\r\n\t}\r\n\t__except (EXCEPTION_EXECUTE_HANDLER)\r\n\t{\r\n\t\tNOTHING;\r\n\t}\r\n}\r\n\r\nVOID _app_getfileversioninfo (\r\n\t_Inout_ PITEM_APP_INFO ptr_app_info\r\n)\r\n{\r\n\tVS_FIXEDFILEINFO *ver_info = NULL;\r\n\tPR_STRING version_string = NULL;\r\n\tR_STRINGBUILDER sb;\r\n\tR_STORAGE ver_block;\r\n\tPR_STRING string;\r\n\tPVOID hlib;\r\n\tULONG lcid;\r\n\tNTSTATUS status;\r\n\r\n\t// clean value\r\n\t__try\r\n\t{\r\n\t\tif (ptr_app_info->version_info)\r\n\t\t\t_r_obj_clearreference ((PVOID_PTR)&ptr_app_info->version_info);\r\n\t}\r\n\t__except (EXCEPTION_EXECUTE_HANDLER)\r\n\t{\r\n\t\tNOTHING;\r\n\t}\r\n\r\n\tstatus = _r_sys_loadlibraryasresource (&ptr_app_info->path->sr, &hlib);\r\n\r\n\tif (!NT_SUCCESS (status))\r\n\t\tgoto CleanupExit;\r\n\r\n\tstatus = _r_res_loadresource (hlib, RT_VERSION, MAKEINTRESOURCE (VS_VERSION_INFO), 0, &ver_block);\r\n\r\n\tif (!NT_SUCCESS (status))\r\n\t\tgoto CleanupExit;\r\n\r\n\t_r_obj_initializestringbuilder (&sb, 256);\r\n\r\n\tlcid = _r_res_querytranslation (ver_block.buffer);\r\n\r\n\t// get file description\r\n\tstring = _r_res_querystring (ver_block.buffer, L\"FileDescription\", lcid);\r\n\r\n\tif (string)\r\n\t{\r\n\t\t_r_obj_appendstringbuilder (&sb, SZ_TAB);\r\n\t\t_r_obj_appendstringbuilder2 (&sb, &string->sr);\r\n\r\n\t\t_r_obj_dereference (string);\r\n\t}\r\n\r\n\t// get file version\r\n\tif (_r_res_queryversion (ver_block.buffer, (PVOID_PTR)&ver_info))\r\n\t{\r\n\t\t_r_obj_appendstringbuilder (&sb, _r_obj_isstringempty2 (sb.string) ? SZ_TAB : L\" \");\r\n\r\n\t\t_r_obj_appendstringbuilderformat (&sb, L\"%d.%d\", HIWORD (ver_info->dwFileVersionMS), LOWORD (ver_info->dwFileVersionMS));\r\n\r\n\t\tif (HIWORD (ver_info->dwFileVersionLS) || LOWORD (ver_info->dwFileVersionLS))\r\n\t\t{\r\n\t\t\t_r_obj_appendstringbuilderformat (&sb, L\".%d\", HIWORD (ver_info->dwFileVersionLS));\r\n\r\n\t\t\tif (LOWORD (ver_info->dwFileVersionLS))\r\n\t\t\t\t_r_obj_appendstringbuilderformat (&sb, L\".%d\", LOWORD (ver_info->dwFileVersionLS));\r\n\t\t}\r\n\t}\r\n\r\n\tif (!_r_obj_isstringempty2 (sb.string))\r\n\t\t_r_obj_appendstringbuilder (&sb, SZ_CRLF);\r\n\r\n\t// get file company\r\n\tstring = _r_res_querystring (ver_block.buffer, L\"CompanyName\", lcid);\r\n\r\n\tif (string)\r\n\t{\r\n\t\t_r_obj_appendstringbuilder (&sb, SZ_TAB);\r\n\t\t_r_obj_appendstringbuilder2 (&sb, &string->sr);\r\n\t\t_r_obj_appendstringbuilder (&sb, SZ_CRLF);\r\n\r\n\t\t_r_obj_dereference (string);\r\n\t}\r\n\r\n\tversion_string = _r_obj_finalstringbuilder (&sb);\r\n\r\n\t_r_str_trimstring2 (&version_string->sr, DIVIDER_TRIM, 0);\r\n\r\nCleanupExit:\r\n\r\n\tptr_app_info->version_info = version_string;\r\n\r\n\tif (hlib)\r\n\t\t_r_sys_freelibrary (hlib);\r\n}\r\n\r\n_Ret_maybenull_\r\nPR_STRING _app_getfilehashinfo (\r\n\t_In_ HANDLE hfile,\r\n\t_In_ ULONG app_hash\r\n)\r\n{\r\n\tPITEM_APP ptr_app;\r\n\tPR_STRING string;\r\n\r\n\tptr_app = _app_getappitem (app_hash);\r\n\r\n\tif (!ptr_app)\r\n\t\treturn NULL;\r\n\r\n\t_r_crypt_getfilehash (BCRYPT_SHA256_ALGORITHM, NULL, hfile, &string);\r\n\r\n\t_r_obj_movereference ((PVOID_PTR)&ptr_app->hash, string);\r\n\r\n\treturn ptr_app->hash;\r\n}\r\n\r\nULONG _app_addcolor (\r\n\t_In_ ULONG locale_id,\r\n\t_In_ LPCWSTR config_name,\r\n\t_In_ LPCWSTR config_value,\r\n\t_In_ COLORREF default_clr,\r\n\t_In_ BOOLEAN is_enabled\r\n)\r\n{\r\n\tITEM_COLOR ptr_clr = {0};\r\n\tULONG hash_code;\r\n\r\n\tptr_clr.config_name = _r_obj_createstring (config_name);\r\n\tptr_clr.config_value = _r_obj_createstring (config_value);\r\n\tptr_clr.new_clr = _r_config_getulong (config_value, default_clr, L\"colors\");\r\n\r\n\tptr_clr.default_clr = default_clr;\r\n\tptr_clr.locale_id = locale_id;\r\n\tptr_clr.is_enabled = is_enabled;\r\n\r\n\thash_code = _r_str_gethash (&ptr_clr.config_name->sr, TRUE);\r\n\r\n\t_r_obj_addhashtableitem (colors_table, hash_code, &ptr_clr);\r\n\r\n\treturn hash_code;\r\n}\r\n\r\nCOLORREF _app_getcolorvalue (\r\n\t_In_ ULONG color_hash\r\n)\r\n{\r\n\tPITEM_COLOR ptr_clr;\r\n\r\n\tptr_clr = _r_obj_findhashtable (colors_table, color_hash);\r\n\r\n\tif (ptr_clr)\r\n\t\treturn ptr_clr->new_clr ? ptr_clr->new_clr : ptr_clr->default_clr;\r\n\r\n\treturn 0;\r\n}\r\n\r\nVOID _app_generate_rulescontrol (\r\n\t_In_ HMENU hsubmenu,\r\n\t_In_ ULONG app_hash,\r\n\t_In_opt_ PITEM_LOG ptr_log\r\n)\r\n{\r\n\tITEM_STATUS status = {0};\r\n\tWCHAR buffer[128];\r\n\tPITEM_RULE ptr_rule;\r\n\tULONG_PTR limit_group;\r\n\tULONG i;\r\n\tBOOLEAN is_global;\r\n\tBOOLEAN is_enabled;\r\n\r\n\t_app_getcount (&status);\r\n\r\n\tif (!status.rules_count)\r\n\t{\r\n\t\t_r_menu_additem_ex (hsubmenu, IDX_RULES_SPECIAL, _r_locale_getstring (IDS_STATUS_EMPTY), MF_DISABLED);\r\n\t}\r\n\telse\r\n\t{\r\n\t\tfor (UINT8 type = 0; type < 2; type++)\r\n\t\t{\r\n\t\t\tif (type == 0)\r\n\t\t\t{\r\n\t\t\t\tif (!status.rules_predefined_count)\r\n\t\t\t\t\tcontinue;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tif (!status.rules_user_count)\r\n\t\t\t\t\tcontinue;\r\n\t\t\t}\r\n\r\n\t\t\tfor (UINT8 loop = 0; loop < 2; loop++)\r\n\t\t\t{\r\n\t\t\t\tlimit_group = 14; // limit rules\r\n\r\n\t\t\t\t_r_queuedlock_acquireshared (&lock_rules);\r\n\r\n\t\t\t\tfor (i = 0; i < (ULONG)_r_obj_getlistsize (rules_list) && limit_group; i++)\r\n\t\t\t\t{\r\n\t\t\t\t\tptr_rule = _r_obj_getlistitem (rules_list, i);\r\n\r\n\t\t\t\t\tif (!ptr_rule)\r\n\t\t\t\t\t\tcontinue;\r\n\r\n\t\t\t\t\tis_global = (ptr_rule->is_enabled && _r_obj_isempty (ptr_rule->apps));\r\n\t\t\t\t\tis_enabled = is_global || (ptr_rule->is_enabled && (_r_obj_findhashtable (ptr_rule->apps, app_hash)));\r\n\r\n\t\t\t\t\tif (ptr_rule->type != DATA_RULE_USER)\r\n\t\t\t\t\t\tcontinue;\r\n\r\n\t\t\t\t\tif ((type == 0 && (!ptr_rule->is_readonly || is_global)) || (type == 1 && (ptr_rule->is_readonly || is_global)))\r\n\t\t\t\t\t\tcontinue;\r\n\r\n\t\t\t\t\tif ((loop == 0 && !is_enabled) || (loop == 1 && is_enabled))\r\n\t\t\t\t\t\tcontinue;\r\n\r\n\t\t\t\t\t_r_str_printf (buffer, RTL_NUMBER_OF (buffer), _r_locale_getstring (IDS_RULE_APPLY_2), _r_obj_getstring (ptr_rule->name));\r\n\r\n\t\t\t\t\tif (ptr_rule->is_readonly)\r\n\t\t\t\t\t\t_r_str_append (buffer, RTL_NUMBER_OF (buffer), SZ_RULE_INTERNAL_MENU);\r\n\r\n\t\t\t\t\t_r_menu_additem_ex (hsubmenu, IDX_RULES_SPECIAL + i, buffer, is_enabled ? MF_CHECKED : MF_UNCHECKED);\r\n\r\n\t\t\t\t\tlimit_group -= 1;\r\n\t\t\t\t}\r\n\r\n\t\t\t\t_r_queuedlock_releaseshared (&lock_rules);\r\n\t\t\t}\r\n\r\n\t\t\tif (!type)\r\n\t\t\t\t_r_menu_addseparator (hsubmenu);\r\n\t\t}\r\n\r\n\t\tif (ptr_log)\r\n\t\t{\r\n\t\t\t_r_menu_addseparator (hsubmenu);\r\n\r\n\t\t\t_r_str_printf (buffer, RTL_NUMBER_OF (buffer), _r_locale_getstring (IDS_RULE_APPLY_2), _r_obj_getstring (ptr_log->remote_addr_str));\r\n\r\n\t\t\t_r_menu_additem (hsubmenu, (IDX_RULES_SPECIAL + i) + 1, buffer);\r\n\t\t}\r\n\t}\r\n\r\n\t_r_str_printf (buffer, RTL_NUMBER_OF (buffer), L\"%s...\", _r_locale_getstring (IDS_OPENRULESEDITOR));\r\n\r\n\t_r_menu_additem (hsubmenu, IDM_OPENRULESEDITOR, buffer);\r\n}\r\n\r\nVOID _app_generate_timerscontrol (\r\n\t_In_ HMENU hsubmenu,\r\n\t_In_ ULONG app_hash\r\n)\r\n{\r\n\tLONG64 current_time;\r\n\tLONG64 app_time = 0;\r\n\tLONG64 timestamp;\r\n\tPR_STRING string;\r\n\tULONG index;\r\n\tBOOLEAN is_checked = FALSE;\r\n\r\n\tcurrent_time = _r_unixtime_now ();\r\n\r\n\t_app_getappinfobyhash (app_hash, INFO_TIMER, &app_time, sizeof (LONG64));\r\n\r\n\tfor (ULONG_PTR i = 0; i < RTL_NUMBER_OF (timer_array); i++)\r\n\t{\r\n\t\ttimestamp = timer_array[i];\r\n\r\n\t\tstring = _r_format_interval (timestamp);\r\n\r\n\t\tif (!string)\r\n\t\t\tcontinue;\r\n\r\n\t\tindex = IDX_TIMER + (ULONG)i;\r\n\r\n\t\t_r_menu_additem (hsubmenu, index, string->buffer);\r\n\r\n\t\tif (!is_checked && (app_time > current_time) && (app_time <= (current_time + timestamp)))\r\n\t\t{\r\n\t\t\t_r_menu_checkitem (hsubmenu, IDX_TIMER, index, MF_BYCOMMAND, index);\r\n\r\n\t\t\tis_checked = TRUE;\r\n\t\t}\r\n\r\n\t\t_r_obj_dereference (string);\r\n\t}\r\n\r\n\tif (!is_checked)\r\n\t\t_r_menu_checkitem (hsubmenu, IDM_DISABLETIMER, IDM_DISABLETIMER, MF_BYCOMMAND, IDM_DISABLETIMER);\r\n}\r\n\r\nBOOLEAN _app_setruletoapp (\r\n\t_In_ HWND hwnd,\r\n\t_Inout_ PITEM_RULE ptr_rule,\r\n\t_In_ INT item_id,\r\n\t_In_ PITEM_APP ptr_app,\r\n\t_In_ BOOLEAN is_enable\r\n)\r\n{\r\n\tINT listview_id;\r\n\r\n\tif (ptr_rule->is_forservices && _app_issystemhash (ptr_app->app_hash))\r\n\t\treturn FALSE;\r\n\r\n\tif (is_enable == (_r_obj_findhashtable (ptr_rule->apps, ptr_app->app_hash) != NULL))\r\n\t\treturn FALSE;\r\n\r\n\tif (is_enable)\r\n\t{\r\n\t\t_r_obj_addhashtableitem (ptr_rule->apps, ptr_app->app_hash, NULL);\r\n\r\n\t\t_app_ruleenable (ptr_rule, TRUE, TRUE);\r\n\t}\r\n\telse\r\n\t{\r\n\t\t_r_obj_removehashtableitem (ptr_rule->apps, ptr_app->app_hash);\r\n\r\n\t\tif (_r_obj_isempty (ptr_rule->apps))\r\n\t\t\t_app_ruleenable (ptr_rule, FALSE, TRUE);\r\n\t}\r\n\r\n\tif (item_id != INT_ERROR)\r\n\t{\r\n\t\tlistview_id = _app_listview_getbytype (ptr_rule->type);\r\n\r\n\t\t_app_listview_updateitemby_param (hwnd, _app_listview_getitemcontext (hwnd, listview_id, item_id), FALSE);\r\n\t}\r\n\r\n\t_app_listview_updateitemby_param (hwnd, ptr_app->app_hash, TRUE);\r\n\r\n\treturn TRUE;\r\n}\r\n\r\n_Success_ (return)\r\nBOOLEAN _app_parsenetworkstring (\r\n\t_In_ LPCWSTR network_string,\r\n\t_Inout_ PITEM_ADDRESS address\r\n)\r\n{\r\n\tNET_ADDRESS_INFO ni;\r\n\tNET_ADDRESS_INFO ni_end;\r\n\tULONG mask;\r\n\tULONG types;\r\n\tUSHORT range_port1 = 0;\r\n\tUSHORT range_port2 = 0;\r\n\tUSHORT port;\r\n\tBYTE prefix_length;\r\n\tULONG status;\r\n\r\n\ttypes = NET_STRING_IP_ADDRESS_NO_SCOPE | NET_STRING_IP_SERVICE | NET_STRING_IP_NETWORK | NET_STRING_IP_ADDRESS_NO_SCOPE | NET_STRING_IP_ADDRESS;\r\n\r\n\tif (address->is_range)\r\n\t{\r\n\t\tstatus = ParseNetworkString (address->range_start, types, &ni, &range_port1, NULL);\r\n\r\n\t\tif (status != ERROR_SUCCESS)\r\n\t\t\tgoto CleanupExit;\r\n\r\n\t\tstatus = ParseNetworkString (address->range_end, types, &ni_end, &range_port2, NULL);\r\n\r\n\t\tif (range_port2)\r\n\t\t{\r\n\t\t\tport = range_port2;\r\n\t\t}\r\n\t\telse if (range_port1)\r\n\t\t{\r\n\t\t\tport = range_port1;\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tport = 0;\r\n\t\t}\r\n\t}\r\n\telse\r\n\t{\r\n\t\tstatus = ParseNetworkString (network_string, types, &ni, &port, &prefix_length);\r\n\t}\r\n\r\n\tif (status != ERROR_SUCCESS)\r\n\t\tgoto CleanupExit;\r\n\r\n\taddress->format = ni.Format;\r\n\taddress->port = port;\r\n\r\n\tif (ni.Format == NET_ADDRESS_IPV4)\r\n\t{\r\n\t\tif (address->is_range)\r\n\t\t{\r\n\t\t\taddress->range.valueLow.type = FWP_UINT32;\r\n\t\t\taddress->range.valueLow.uint32 = _r_byteswap_ulong (ni.Ipv4Address.sin_addr.S_un.S_addr);\r\n\r\n\t\t\taddress->range.valueHigh.type = FWP_UINT32;\r\n\t\t\taddress->range.valueHigh.uint32 = _r_byteswap_ulong (ni_end.Ipv4Address.sin_addr.S_un.S_addr);\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tmask = 0;\r\n\r\n\t\t\tif (ConvertLengthToIpv4Mask (prefix_length, &mask) == NOERROR)\r\n\t\t\t\tmask = _r_byteswap_ulong (mask);\r\n\r\n\t\t\taddress->addr4.addr = _r_byteswap_ulong (ni.Ipv4Address.sin_addr.S_un.S_addr);\r\n\t\t\taddress->addr4.mask = mask;\r\n\t\t}\r\n\r\n\t\treturn TRUE;\r\n\t}\r\n\telse if (ni.Format == NET_ADDRESS_IPV6)\r\n\t{\r\n\t\tif (address->is_range)\r\n\t\t{\r\n\t\t\taddress->range.valueLow.type = FWP_BYTE_ARRAY16_TYPE;\r\n\r\n\t\t\tRtlCopyMemory (address->addr6_low, ni.Ipv6Address.sin6_addr.u.Byte, FWP_V6_ADDR_SIZE);\r\n\t\t\taddress->range.valueLow.byteArray16 = (FWP_BYTE_ARRAY16 *)address->addr6_low;\r\n\r\n\t\t\taddress->range.valueHigh.type = FWP_BYTE_ARRAY16_TYPE;\r\n\r\n\t\t\tRtlCopyMemory (address->addr6_high, ni_end.Ipv6Address.sin6_addr.u.Byte, FWP_V6_ADDR_SIZE);\r\n\t\t\taddress->range.valueHigh.byteArray16 = (FWP_BYTE_ARRAY16 *)address->addr6_high;\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tRtlCopyMemory (address->addr6.addr, ni.Ipv6Address.sin6_addr.u.Byte, FWP_V6_ADDR_SIZE);\r\n\t\t\taddress->addr6.prefixLength = min (prefix_length, 128);\r\n\t\t}\r\n\r\n\t\treturn TRUE;\r\n\t}\r\n\r\nCleanupExit:\r\n\r\n\t_r_log (LOG_LEVEL_INFO, NULL, L\"ParseNetworkString\", status, network_string);\r\n\r\n\treturn FALSE;\r\n}\r\n\r\n_Success_ (return)\r\nBOOLEAN _app_preparserulestring (\r\n\t_In_ PR_STRINGREF rule,\r\n\t_Out_ PITEM_ADDRESS address\r\n)\r\n{\r\n\tstatic WCHAR valid_chars[] = {\r\n\t\tL'.',\r\n\t\tL':',\r\n\t\tL'[',\r\n\t\tL']',\r\n\t\tL'-',\r\n\t\tL'_',\r\n\t\tL'/',\r\n\t};\r\n\r\n\tR_STRINGREF range_start_part;\r\n\tR_STRINGREF range_end_part;\r\n\tWCHAR rule_string[256];\r\n\tULONG_PTR length;\r\n\tULONG types;\r\n\tBOOLEAN is_valid;\r\n\r\n\tlength = _r_str_getlength2 (rule);\r\n\r\n\tfor (ULONG_PTR i = 0; i < length; i++)\r\n\t{\r\n\t\tif (IsCharAlphaNumericW (rule->buffer[i]))\r\n\t\t\tcontinue;\r\n\r\n\t\tis_valid = FALSE;\r\n\r\n\t\tfor (ULONG_PTR j = 0; j < RTL_NUMBER_OF (valid_chars); j++)\r\n\t\t{\r\n\t\t\tif (rule->buffer[i] == valid_chars[j])\r\n\t\t\t{\r\n\t\t\t\tis_valid = TRUE;\r\n\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (!is_valid)\r\n\t\t\treturn FALSE;\r\n\t}\r\n\r\n\t// parse rule range\r\n\taddress->is_range = _r_str_splitatchar (rule, DIVIDER_RULE_RANGE, &range_start_part, &range_end_part);\r\n\r\n\t// extract start and end position of rule\r\n\tif (address->is_range)\r\n\t{\r\n\t\t// there is incorrect range syntax\r\n\t\tif (_r_obj_isstringempty2 (&range_start_part) || _r_obj_isstringempty2 (&range_end_part))\r\n\t\t\treturn FALSE;\r\n\r\n\t\t_r_str_copystring (address->range_start, RTL_NUMBER_OF (address->range_start), &range_start_part);\r\n\t\t_r_str_copystring (address->range_end, RTL_NUMBER_OF (address->range_end), &range_end_part);\r\n\t}\r\n\r\n\t// check rule for port\r\n\tif (address->type == DATA_UNKNOWN)\r\n\t{\r\n\t\taddress->type = DATA_TYPE_PORT;\r\n\r\n\t\tfor (ULONG_PTR i = 0; i < length; i++)\r\n\t\t{\r\n\t\t\tif (!_r_str_isdigit (rule->buffer[i]) && rule->buffer[i] != DIVIDER_RULE_RANGE)\r\n\t\t\t{\r\n\t\t\t\taddress->type = DATA_UNKNOWN;\r\n\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tif (address->type != DATA_UNKNOWN)\r\n\t\treturn TRUE;\r\n\r\n\t_r_str_copystring (rule_string, RTL_NUMBER_OF (rule_string), rule);\r\n\r\n\ttypes = NET_STRING_IP_ADDRESS | NET_STRING_IP_SERVICE | NET_STRING_IP_NETWORK | NET_STRING_IP_ADDRESS_NO_SCOPE | NET_STRING_IP_SERVICE_NO_SCOPE;\r\n\r\n\t// check rule for ip address\r\n\tif (address->is_range)\r\n\t{\r\n\t\tif (ParseNetworkString (address->range_start, types, NULL, NULL, NULL) == ERROR_SUCCESS &&\r\n\t\t\tParseNetworkString (address->range_end, types, NULL, NULL, NULL) == ERROR_SUCCESS)\r\n\t\t{\r\n\t\t\taddress->type = DATA_TYPE_IP;\r\n\r\n\t\t\treturn TRUE;\r\n\t\t}\r\n\t}\r\n\telse\r\n\t{\r\n\t\tif (ParseNetworkString (rule_string, types, NULL, NULL, NULL) == ERROR_SUCCESS)\r\n\t\t{\r\n\t\t\taddress->type = DATA_TYPE_IP;\r\n\r\n\t\t\treturn TRUE;\r\n\t\t}\r\n\t}\r\n\r\n\treturn FALSE;\r\n}\r\n\r\n_Success_ (return)\r\nBOOLEAN _app_parserulestring (\r\n\t_In_opt_ PR_STRINGREF rule,\r\n\t_Out_ PITEM_ADDRESS address\r\n)\r\n{\r\n\tWCHAR rule_string[256];\r\n\tR_STRINGREF sr;\r\n\r\n\tRtlZeroMemory (address, sizeof (ITEM_ADDRESS));\r\n\r\n\tif (_r_obj_isstringempty (rule))\r\n\t\treturn TRUE;\r\n\r\n\t// parse rule type\r\n\tif (!_app_preparserulestring (rule, address))\r\n\t\treturn FALSE;\r\n\r\n\tif (address->type == DATA_TYPE_PORT)\r\n\t{\r\n\t\tif (address->is_range)\r\n\t\t{\r\n\t\t\t// ...port range\r\n\t\t\t_r_obj_initializestringref (&sr, address->range_start);\r\n\r\n\t\t\taddress->range.valueLow.type = FWP_UINT16;\r\n\t\t\taddress->range.valueLow.uint16 = (UINT16)_r_str_toulong (&sr);\r\n\r\n\t\t\t_r_obj_initializestringref (&sr, address->range_end);\r\n\r\n\t\t\taddress->range.valueHigh.type = FWP_UINT16;\r\n\t\t\taddress->range.valueHigh.uint16 = (UINT16)_r_str_toulong (&sr);\r\n\r\n\t\t\tif (address->range.valueLow.uint16 < 1)\r\n\t\t\t\treturn FALSE;\r\n\r\n\t\t\tif (address->range.valueHigh.uint16 > 65535)\r\n\t\t\t\treturn FALSE;\r\n\r\n\t\t\tif (address->range.valueLow.uint16 >= address->range.valueHigh.uint16)\r\n\t\t\t\treturn FALSE;\r\n\r\n\t\t\treturn TRUE;\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\t// ...port\r\n\t\t\taddress->port = (UINT16)_r_str_toulong (rule);\r\n\r\n\t\t\tif (address->port < 1)\r\n\t\t\t\treturn FALSE;\r\n\r\n\t\t\tif (address->port > 65535)\r\n\t\t\t\treturn FALSE;\r\n\r\n\t\t\treturn TRUE;\r\n\t\t}\r\n\t}\r\n\telse if (address->type == DATA_TYPE_IP)\r\n\t{\r\n\t\t_r_str_copystring (rule_string, RTL_NUMBER_OF (rule_string), rule);\r\n\r\n\t\tif (!_app_parsenetworkstring (rule_string, address))\r\n\t\t\treturn FALSE;\r\n\t}\r\n\r\n\treturn TRUE;\r\n}\r\n\r\n_Ret_maybenull_\r\nPR_STRING _app_resolveaddress (\r\n\t_In_ ADDRESS_FAMILY af,\r\n\t_In_ LPCVOID address\r\n)\r\n{\r\n\tPDNS_RECORD dns_records = NULL;\r\n\tPR_STRING string = NULL;\r\n\tPR_STRING arpa_string;\r\n\tDNS_STATUS status;\r\n\tULONG arpa_hash;\r\n\r\n\tarpa_string = _app_formatarpa (af, address);\r\n\tarpa_hash = _r_str_gethash (&arpa_string->sr, TRUE);\r\n\r\n\tif (_app_getcachetable (cache_resolution, arpa_hash, &lock_cache_resolution, &string))\r\n\t{\r\n\t\t_r_obj_dereference (arpa_string);\r\n\r\n\t\treturn string;\r\n\t}\r\n\r\n\tstatus = DnsQuery_W (arpa_string->buffer, DNS_TYPE_PTR, DNS_QUERY_BYPASS_CACHE | DNS_QUERY_NO_HOSTS_FILE | DNS_QUERY_NO_MULTICAST, NULL, &dns_records, NULL);\r\n\r\n\tif (status == ERROR_SUCCESS)\r\n\t{\r\n\t\tif (dns_records)\r\n\t\t{\r\n\t\t\tfor (PDNS_RECORD dns_record = dns_records; dns_record; dns_record = dns_record->pNext)\r\n\t\t\t{\r\n\t\t\t\tif (dns_record->wType == DNS_TYPE_PTR)\r\n\t\t\t\t{\r\n\t\t\t\t\tstring = _r_obj_createstring (dns_record->Data.PTR.pNameHost);\r\n\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tDnsFree (dns_records, DnsFreeRecordList);\r\n\t\t}\r\n\t}\r\n\r\n\t_app_addcachetable (cache_resolution, arpa_hash, &lock_cache_resolution, _r_obj_referencesafe (string));\r\n\r\n\t_r_obj_dereference (arpa_string);\r\n\r\n\treturn string;\r\n}\r\n\r\nPR_STRING _app_resolveaddress_interlocked (\r\n\t_In_ PVOID volatile *string,\r\n\t_In_ ADDRESS_FAMILY af,\r\n\t_In_ LPCVOID address,\r\n\t_In_ BOOLEAN is_resolutionenabled\r\n)\r\n{\r\n\tPR_STRING current_string;\r\n\tPR_STRING new_string;\r\n\r\n\tcurrent_string = _InterlockedCompareExchangePointer (string, NULL, NULL);\r\n\r\n\tif (current_string)\r\n\t\treturn current_string;\r\n\r\n\tif (is_resolutionenabled)\r\n\t{\r\n\t\tnew_string = _app_resolveaddress (af, address);\r\n\r\n\t\tif (!new_string)\r\n\t\t\tnew_string = _r_obj_referenceemptystring ();\r\n\t}\r\n\telse\r\n\t{\r\n\t\tnew_string = _r_obj_referenceemptystring ();\r\n\t}\r\n\r\n\tcurrent_string = _InterlockedCompareExchangePointer (string, new_string, NULL);\r\n\r\n\tif (!current_string)\r\n\t{\r\n\t\tcurrent_string = new_string;\r\n\t}\r\n\telse\r\n\t{\r\n\t\t_r_obj_dereference (new_string);\r\n\t}\r\n\r\n\treturn current_string;\r\n}\r\n\r\nVOID _app_fileloggingenable ()\r\n{\r\n\tBOOLEAN is_enable;\r\n\tNTSTATUS status;\r\n\r\n\tis_enable = _r_config_getboolean (L\"IsEnableAppMonitor\", FALSE, NULL);\r\n\r\n\tif (is_enable)\r\n\t{\r\n\t\tstatus = _r_sys_createthread (&config.hmonitor_thread, NtCurrentProcess (), &_app_timercallback, NULL, NULL, L\"FileMonitor\");\r\n\r\n\t\tif (NT_SUCCESS (status))\r\n\t\t\tNtResumeThread (config.hmonitor_thread, NULL);\r\n\t}\r\n\telse\r\n\t{\r\n\t\tif (config.hmonitor_thread)\r\n\t\t{\r\n\t\t\tNtTerminateThread (config.hmonitor_thread, 0);\r\n\t\t\tNtClose (config.hmonitor_thread);\r\n\r\n\t\t\tconfig.hmonitor_thread = NULL;\r\n\t\t}\r\n\t}\r\n}\r\n\r\nVOID NTAPI _app_timercallback (\r\n\t_In_opt_ PVOID context\r\n)\r\n{\r\n\tPITEM_APP ptr_app = NULL;\r\n\tPR_STRING hash;\r\n\tULONG_PTR enum_key;\r\n\tNTSTATUS status;\r\n\r\n\twhile (TRUE)\r\n\t{\r\n\t\t_r_queuedlock_acquireshared (&lock_apps);\r\n\r\n\t\tenum_key = 0;\r\n\r\n\t\twhile (_r_obj_enumhashtablepointer (apps_table, (PVOID_PTR)&ptr_app, NULL, &enum_key))\r\n\t\t{\r\n\t\t\tif (!ptr_app->hash || !_app_isappvalidbinary (ptr_app->real_path))\r\n\t\t\t\tcontinue;\r\n\r\n\t\t\tif (!_app_isappused (ptr_app))\r\n\t\t\t\tcontinue;\r\n\r\n\t\t\tstatus = _r_crypt_getfilehash (BCRYPT_SHA256_ALGORITHM, &ptr_app->real_path->sr, NULL, &hash);\r\n\r\n\t\t\tif (NT_SUCCESS (status))\r\n\t\t\t{\r\n\t\t\t\tif (!_r_str_isequal (&ptr_app->hash->sr, &hash->sr, TRUE))\r\n\t\t\t\t{\r\n\t\t\t\t\t_r_obj_movereference ((PVOID_PTR)&ptr_app->hash, hash);\r\n\r\n\t\t\t\t\t_app_setappinfo (ptr_app, INFO_DISABLE, NULL);\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\t_r_obj_dereference (hash);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t_r_queuedlock_releaseshared (&lock_apps);\r\n\r\n\t\t_r_sys_waitforsingleobject (NtCurrentThread (), _r_calc_minutes2milliseconds (10));\r\n\t}\r\n}\r\n\r\nVOID _app_getfileinformation (\r\n\t_In_ PR_STRING path,\r\n\t_In_ ULONG app_hash,\r\n\t_In_ ENUM_TYPE_DATA type,\r\n\t_In_ INT listview_id\r\n)\r\n{\r\n\tPITEM_APP_INFO ptr_app_info;\r\n\r\n\tptr_app_info = _app_getappinfobyhash2 (app_hash);\r\n\r\n\tif (_r_obj_isstringempty (path))\r\n\t\treturn;\r\n\r\n\tif (ptr_app_info)\r\n\t{\r\n\t\t// all information is already set\r\n\t\tif (ptr_app_info->is_loaded)\r\n\t\t{\r\n\t\t\t_r_obj_dereference (ptr_app_info);\r\n\r\n\t\t\treturn;\r\n\t\t}\r\n\t}\r\n\telse\r\n\t{\r\n\t\tptr_app_info = _r_obj_allocate (sizeof (ITEM_APP_INFO), &_app_dereferenceappinfo);\r\n\r\n\t\tptr_app_info->path = _r_obj_reference (path);\r\n\t\tptr_app_info->app_hash = app_hash;\r\n\t\tptr_app_info->type = type;\r\n\t\tptr_app_info->listview_id = listview_id;\r\n\r\n\t\t_r_queuedlock_acquireexclusive (&lock_cache_information);\r\n\r\n\t\t_r_obj_addhashtablepointer (cache_information, app_hash, _r_obj_reference (ptr_app_info));\r\n\r\n\t\t_r_queuedlock_releaseexclusive (&lock_cache_information);\r\n\t}\r\n\r\n\t// check for binary path is valid\r\n\tif (_app_isappvalidbinary (path))\r\n\t\t_r_workqueue_queueitem (&file_queue, &_app_queue_fileinformation, ptr_app_info);\r\n}\r\n\r\nVOID _app_queue_resolver (\r\n\t_In_ HWND hwnd,\r\n\t_In_ INT listview_id,\r\n\t_In_ ULONG_PTR hash_code,\r\n\t_In_ PVOID base_address\r\n)\r\n{\r\n\tPITEM_CONTEXT context;\r\n\r\n\tcontext = _r_freelist_allocateitem (&context_free_list);\r\n\r\n\tcontext->hwnd = hwnd;\r\n\tcontext->listview_id = listview_id;\r\n\tcontext->lparam = hash_code;\r\n\tcontext->base_address = _r_obj_reference (base_address);\r\n\r\n\t_r_workqueue_queueitem (&resolver_queue, &_app_queue_resolveinformation, context);\r\n}\r\n\r\nVOID NTAPI _app_queue_fileinformation (\r\n\t_In_ PVOID arglist\r\n)\r\n{\r\n\tPITEM_APP_INFO ptr_app_info;\r\n\tHANDLE hfile;\r\n\tHWND hwnd;\r\n\tNTSTATUS status;\r\n\r\n\tptr_app_info = arglist;\r\n\thwnd = _r_app_gethwnd ();\r\n\r\n\tif (ptr_app_info->is_loaded)\r\n\t\treturn;\r\n\r\n\tstatus = _r_fs_openfile (&ptr_app_info->path->sr, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_DELETE | FILE_SHARE_WRITE, 0, FALSE, &hfile);\r\n\r\n\tif (!NT_SUCCESS (status))\r\n\t{\r\n\t\tif (status != STATUS_OBJECT_NAME_NOT_FOUND && status != STATUS_OBJECT_PATH_NOT_FOUND && status != STATUS_ACCESS_DENIED)\r\n\t\t\t_r_log (LOG_LEVEL_ERROR, NULL, L\"_r_fs_openfile\", status, ptr_app_info->path->buffer);\r\n\r\n\t\treturn;\r\n\t}\r\n\r\n\t// query app icon\r\n\t_app_getfileicon (ptr_app_info);\r\n\r\n\t// query certificate information\r\n\tif (_r_config_getboolean (L\"IsCertificatesEnabled\", TRUE, NULL))\r\n\t\t_app_getfilesignatureinfo (hfile, ptr_app_info);\r\n\r\n\t// query version info\r\n\t_app_getfileversioninfo (ptr_app_info);\r\n\r\n\t// query sha256 info\r\n\tif (_r_config_getboolean (L\"IsHashesEnabled\", FALSE, NULL))\r\n\t\t_app_getfilehashinfo (hfile, ptr_app_info->app_hash);\r\n\r\n\t// redraw listview\r\n\tif (_r_wnd_isvisible (hwnd, FALSE))\r\n\t\t_r_listview_redraw (hwnd, ptr_app_info->listview_id);\r\n\r\n\tptr_app_info->is_loaded = TRUE;\r\n\r\n\t_r_obj_dereference (ptr_app_info);\r\n\r\n\tNtClose (hfile);\r\n}\r\n\r\nVOID NTAPI _app_queue_notifyinformation (\r\n\t_In_ PVOID arglist\r\n)\r\n{\r\n\tPITEM_APP_INFO ptr_app_info;\r\n\tPITEM_CONTEXT context;\r\n\tPITEM_LOG ptr_log;\r\n\tPR_STRING signature_str = NULL;\r\n\tPR_STRING host_str = NULL;\r\n\tPR_STRING localized_string;\r\n\tPR_STRING address_str;\r\n\tHANDLE hfile;\r\n\tHICON hicon;\r\n\tHDWP hdefer;\r\n\tULONG attempts = 6;\r\n\tBOOLEAN is_iconset = FALSE;\r\n\tNTSTATUS status;\r\n\r\n\tcontext = arglist;\r\n\r\n\tptr_log = context->base_address;\r\n\r\n\t// query address string\r\n\taddress_str = _app_formataddress (ptr_log->af, ptr_log->protocol, &ptr_log->remote_addr, 0, FMTADDR_USE_PROTOCOL);\r\n\r\n\t// query notification host name\r\n\tif (_r_config_getboolean (L\"IsNetworkResolutionsEnabled\", FALSE, NULL))\r\n\t{\r\n\t\thost_str = _app_resolveaddress_interlocked ((volatile PVOID_PTR)&ptr_log->remote_host_str, ptr_log->af, &ptr_log->remote_addr, TRUE);\r\n\r\n\t\tif (host_str)\r\n\t\t\thost_str = _r_obj_reference (host_str);\r\n\t}\r\n\r\n\t// query signature\r\n\tif (_r_config_getboolean (L\"IsCertificatesEnabled\", TRUE, NULL))\r\n\t{\r\n\t\tptr_app_info = _app_getappinfobyhash2 (ptr_log->app_hash);\r\n\r\n\t\tif (ptr_app_info)\r\n\t\t{\r\n\t\t\tif (_app_isappvalidbinary (ptr_app_info->path))\r\n\t\t\t{\r\n\t\t\t\tstatus = _r_fs_openfile (&ptr_app_info->path->sr, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_DELETE | FILE_SHARE_WRITE, 0, FALSE, &hfile);\r\n\r\n\t\t\t\tif (NT_SUCCESS (status))\r\n\t\t\t\t{\r\n\t\t\t\t\t_app_getfilesignatureinfo (hfile, ptr_app_info);\r\n\r\n\t\t\t\t\tNtClose (hfile);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\t_r_obj_dereference (ptr_app_info);\r\n\t\t}\r\n\t}\r\n\r\n\t// query file icon\r\n\thicon = _app_icons_getsafeapp_hicon (ptr_log->app_hash);\r\n\r\n\tif (_r_wnd_isvisible (context->hwnd, FALSE))\r\n\t{\r\n\t\tif (ptr_log->app_hash == _app_notify_getapp_id (context->hwnd))\r\n\t\t{\r\n\t\t\t// set file icon\r\n\t\t\t_app_notify_setapp_icon (context->hwnd, hicon);\r\n\r\n\t\t\tis_iconset = TRUE;\r\n\r\n\t\t\t// set signature information\r\n\t\t\tlocalized_string = _r_obj_concatstrings (\r\n\t\t\t\t2,\r\n\t\t\t\t_r_locale_getstring (IDS_SIGNATURE),\r\n\t\t\t\tL\":\"\r\n\t\t\t);\r\n\r\n\t\t\tdo\r\n\t\t\t{\r\n\t\t\t\tif (!_app_getappinfoparam2 (ptr_log->app_hash, 0, INFO_SIGNATURE_STRING, &signature_str, sizeof (signature_str)))\r\n\t\t\t\t{\r\n\t\t\t\t\t_r_sys_sleep (250);\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\twhile (--attempts);\r\n\r\n\t\t\tif (!signature_str)\r\n\t\t\t\t_r_obj_movereference ((PVOID_PTR)&signature_str, _r_locale_getstring_ex (IDS_SIGN_UNSIGNED));\r\n\r\n\t\t\thdefer = BeginDeferWindowPos (2);\r\n\r\n\t\t\t// set signature string\r\n\t\t\t_r_ctrl_settablestring (context->hwnd, &hdefer, IDC_SIGNATURE_ID, &localized_string->sr, IDC_SIGNATURE_TEXT, &signature_str->sr);\r\n\r\n\t\t\t// set address string\r\n\t\t\t_r_obj_movereference ((PVOID_PTR)&localized_string, _r_obj_concatstrings (2, _r_locale_getstring (IDS_ADDRESS), L\":\"));\r\n\r\n\t\t\tif (_r_obj_isstringempty (address_str))\r\n\t\t\t\t_r_obj_movereference ((PVOID_PTR)&address_str, _r_locale_getstring_ex (IDS_STATUS_EMPTY));\r\n\r\n\t\t\t_r_ctrl_settablestring (context->hwnd, &hdefer, IDC_ADDRESS_ID, &localized_string->sr, IDC_ADDRESS_TEXT, &address_str->sr);\r\n\r\n\t\t\t// set host string\r\n\t\t\t_r_obj_movereference ((PVOID_PTR)&localized_string, _r_obj_concatstrings (2, _r_locale_getstring (IDS_HOST), L\":\"));\r\n\r\n\t\t\tif (_r_obj_isstringempty (host_str))\r\n\t\t\t\t_r_obj_movereference ((PVOID_PTR)&host_str, _r_locale_getstring_ex (IDS_STATUS_EMPTY));\r\n\r\n\t\t\t_r_ctrl_settablestring (context->hwnd, &hdefer, IDC_HOST_ID, &localized_string->sr, IDC_HOST_TEXT, &host_str->sr);\r\n\r\n\t\t\t_r_obj_dereference (localized_string);\r\n\r\n\t\t\tif (hdefer)\r\n\t\t\t\tEndDeferWindowPos (hdefer);\r\n\t\t}\r\n\t}\r\n\r\n\t_r_freelist_deleteitem (&context_free_list, context);\r\n\r\n\tif (!is_iconset && hicon)\r\n\t\tDestroyIcon (hicon);\r\n\r\n\tif (signature_str)\r\n\t\t_r_obj_dereference (signature_str);\r\n\r\n\tif (address_str)\r\n\t\t_r_obj_dereference (address_str);\r\n\r\n\tif (host_str)\r\n\t\t_r_obj_dereference (host_str);\r\n\r\n\t_r_obj_dereference (ptr_log);\r\n}\r\n\r\nVOID NTAPI _app_queue_resolveinformation (\r\n\t_In_ PVOID arglist\r\n)\r\n{\r\n\tPITEM_NETWORK ptr_network;\r\n\tPITEM_CONTEXT context;\r\n\tPITEM_LOG ptr_log;\r\n\tBOOLEAN is_resolutionenabled;\r\n\r\n\tcontext = arglist;\r\n\r\n\tis_resolutionenabled = _r_config_getboolean (L\"IsNetworkResolutionsEnabled\", FALSE, NULL);\r\n\r\n\tswitch (context->listview_id)\r\n\t{\r\n\t\tcase IDC_LOG:\r\n\t\t{\r\n\t\t\tptr_log = context->base_address;\r\n\r\n\t\t\t_app_resolveaddress_interlocked ((volatile PVOID_PTR)&ptr_log->local_host_str, ptr_log->af, &ptr_log->local_addr, is_resolutionenabled);\r\n\t\t\t_app_resolveaddress_interlocked ((volatile PVOID_PTR)&ptr_log->remote_host_str, ptr_log->af, &ptr_log->remote_addr, is_resolutionenabled);\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase IDC_NETWORK:\r\n\t\t{\r\n\t\t\tptr_network = context->base_address;\r\n\r\n\t\t\t_app_formataddress_interlocked ((volatile PVOID_PTR)&ptr_network->local_addr_str, ptr_network->af, &ptr_network->local_addr);\r\n\t\t\t_app_formataddress_interlocked ((volatile PVOID_PTR)&ptr_network->remote_addr_str, ptr_network->af, &ptr_network->remote_addr);\r\n\r\n\t\t\t_app_resolveaddress_interlocked ((volatile PVOID_PTR)&ptr_network->local_host_str, ptr_network->af, &ptr_network->local_addr, is_resolutionenabled);\r\n\t\t\t_app_resolveaddress_interlocked ((volatile PVOID_PTR)&ptr_network->remote_host_str, ptr_network->af, &ptr_network->remote_addr, is_resolutionenabled);\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\r\n\t// redraw listview\r\n\tif (_r_wnd_isvisible (context->hwnd, FALSE))\r\n\t\t_r_listview_redraw (context->hwnd, context->listview_id);\r\n\r\n\t_r_obj_dereference (context->base_address);\r\n\r\n\t_r_freelist_deleteitem (&context_free_list, context);\r\n}\r\n\r\nBOOLEAN _app_wufixenabled ()\r\n{\r\n\tWCHAR file_path[256];\r\n\tR_STRINGREF sr;\r\n\r\n\tif (!_r_config_getboolean (L\"IsWUFixEnabled\", FALSE, NULL))\r\n\t\treturn FALSE;\r\n\r\n\t_r_str_printf (file_path, RTL_NUMBER_OF (file_path), L\"%s\\\\wusvc.exe\", _r_sys_getsystemdirectory ()->buffer);\r\n\r\n\t_r_obj_initializestringref (&sr, file_path);\r\n\r\n\tif (_r_fs_isexists (&sr))\r\n\t\treturn TRUE;\r\n\r\n\treturn FALSE;\r\n}\r\n\r\nVOID _app_wufixhelper (\r\n\t_In_ SC_HANDLE hsvcmgr,\r\n\t_In_ LPCWSTR service_name,\r\n\t_In_ LPCWSTR k_value,\r\n\t_In_ BOOLEAN is_enable\r\n)\r\n{\r\n\tSERVICE_STATUS svc_status;\r\n\tWCHAR reg_value[128];\r\n\tWCHAR reg_key[128];\r\n\tPR_STRING image_path;\r\n\tSC_HANDLE hsvc;\r\n\tHANDLE hkey;\r\n\tBOOLEAN is_enabled = FALSE;\r\n\tNTSTATUS status;\r\n\r\n\t_r_str_printf (reg_key, RTL_NUMBER_OF (reg_key), L\"SYSTEM\\\\CurrentControlSet\\\\Services\\\\%s\", service_name);\r\n\r\n\tstatus = _r_reg_openkey (HKEY_LOCAL_MACHINE, reg_key, 0, KEY_READ | KEY_WRITE, &hkey);\r\n\r\n\tif (!NT_SUCCESS (status))\r\n\t\treturn;\r\n\r\n\t// query service path\r\n\tstatus = _r_reg_querystring (hkey, L\"ImagePath\", &image_path, NULL);\r\n\r\n\tif (NT_SUCCESS (status))\r\n\t{\r\n\t\tif (_r_str_isstartswith2 (&image_path->sr, is_enable ? L\"%systemroot%\\\\system32\\\\wusvc.exe\" : L\"%systemroot%\\\\system32\\\\svchost.exe\", TRUE))\r\n\t\t\tis_enabled = TRUE;\r\n\r\n\t\t_r_obj_dereference (image_path);\r\n\t}\r\n\r\n\t// set new image path\r\n\t_r_str_printf (reg_value, RTL_NUMBER_OF (reg_value), L\"%%systemroot%%\\\\system32%s -k %s -p\", is_enable ? PATH_WUSVC : PATH_SVCHOST, k_value);\r\n\r\n\t_r_reg_setvalue (hkey, L\"ImagePath\", REG_EXPAND_SZ, reg_value, (ULONG)(_r_str_getlength (reg_value) * sizeof (WCHAR) + sizeof (UNICODE_NULL)));\r\n\r\n\t// restart service\r\n\tif (is_enable != is_enabled)\r\n\t{\r\n\t\thsvc = OpenServiceW (hsvcmgr, service_name, SERVICE_START | SERVICE_STOP | SERVICE_QUERY_STATUS);\r\n\r\n\t\tif (hsvc)\r\n\t\t{\r\n\t\t\tif (QueryServiceStatus (hsvc, &svc_status))\r\n\t\t\t{\r\n\t\t\t\tif (svc_status.dwCurrentState != SERVICE_STOPPED)\r\n\t\t\t\t\tControlService (hsvc, SERVICE_CONTROL_STOP, &svc_status);\r\n\t\t\t}\r\n\r\n\t\t\tCloseServiceHandle (hsvc);\r\n\t\t}\r\n\t}\r\n\r\n\tNtClose (hkey);\r\n}\r\n\r\nVOID _app_wufixenable (\r\n\t_In_ HWND hwnd,\r\n\t_In_ BOOLEAN is_enable\r\n)\r\n{\r\n\tPR_STRING service_path;\r\n\tSC_HANDLE hsvcmgr;\r\n\tULONG app_hash;\r\n\r\n\thsvcmgr = OpenSCManagerW (NULL, NULL, SC_MANAGER_CONNECT | SERVICE_START | SERVICE_STOP | SERVICE_QUERY_STATUS);\r\n\r\n\tif (!hsvcmgr)\r\n\t\treturn;\r\n\r\n\tif (is_enable)\r\n\t{\r\n\t\tif (_r_fs_isexists (&config.wusvc_path->sr))\r\n\t\t\t_r_fs_deletefile (&config.wusvc_path->sr, NULL);\r\n\r\n\t\t_r_fs_copyfile (&config.svchost_path->sr, &config.wusvc_path->sr, FALSE);\r\n\r\n\t\tservice_path = _r_obj_createstring2 (&config.wusvc_path->sr);\r\n\r\n\t\tapp_hash = _app_addapplication (hwnd, DATA_UNKNOWN, service_path, NULL, NULL);\r\n\r\n\t\tif (app_hash)\r\n\t\t{\r\n\t\t\t_app_setappinfobyhash (app_hash, INFO_IS_ENABLED, LongToPtr (TRUE));\r\n\t\t\t_app_setappinfobyhash (app_hash, INFO_IS_UNDELETABLE, LongToPtr (TRUE));\r\n\t\t}\r\n\r\n\t\t_r_obj_dereference (service_path);\r\n\t}\r\n\telse\r\n\t{\r\n\t\tif (_r_fs_isexists (&config.wusvc_path->sr))\r\n\t\t{\r\n\t\t\tapp_hash = _r_str_gethash (&config.wusvc_path->sr, TRUE);\r\n\r\n\t\t\tif (app_hash)\r\n\t\t\t{\r\n\t\t\t\t_app_setappinfobyhash (app_hash, INFO_IS_ENABLED, LongToPtr (FALSE));\r\n\t\t\t\t_app_setappinfobyhash (app_hash, INFO_IS_UNDELETABLE, LongToPtr (FALSE));\r\n\t\t\t}\r\n\r\n\t\t\t_r_fs_deletefile (&config.wusvc_path->sr, NULL);\r\n\t\t}\r\n\t}\r\n\r\n\t_app_wufixhelper (hsvcmgr, L\"wuauserv\", L\"netsvcs\", is_enable);\r\n\t_app_wufixhelper (hsvcmgr, L\"DoSvc\", L\"NetworkService\", is_enable);\r\n\t_app_wufixhelper (hsvcmgr, L\"UsoSvc\", L\"netsvcs\", is_enable);\r\n\r\n\t_r_config_setboolean (L\"IsWUFixEnabled\", is_enable, NULL);\r\n\r\n\tCloseServiceHandle (hsvcmgr);\r\n}\r\n"
  },
  {
    "path": "src/helper.h",
    "content": "// simplewall\r\n// Copyright (c) 2016-2026 Henry++\r\n\r\n#pragma once\r\n\r\ntypedef struct _ICON_INFORMATION\r\n{\r\n\tHICON app_hicon;\r\n\tHICON service_hicon;\r\n\tHICON uwp_hicon;\r\n\r\n\tLONG app_icon_id;\r\n\tLONG service_icon_id;\r\n\tLONG uwp_icon_id;\r\n} ICON_INFORMATION, *PICON_INFORMATION;\r\n\r\n#define FMTADDR_AS_RULE 0x0001\r\n#define FMTADDR_USE_PROTOCOL 0x0002\r\n\r\nVOID NTAPI _app_dereferenceapp (\r\n\t_In_ PVOID entry\r\n);\r\n\r\nVOID NTAPI _app_dereferenceappinfo (\r\n\t_In_ PVOID entry\r\n);\r\n\r\nVOID NTAPI _app_dereferenceruleconfig (\r\n\t_In_ PVOID entry\r\n);\r\n\r\nVOID NTAPI _app_dereferencenetwork (\r\n\t_In_ PVOID entry\r\n);\r\n\r\nVOID NTAPI _app_dereferencelog (\r\n\t_In_ PVOID entry\r\n);\r\nVOID NTAPI _app_dereferencerule (\r\n\t_In_ PVOID entry\r\n);\r\n\r\nVOID _app_addcachetable (\r\n\t_Inout_ PR_HASHTABLE hashtable,\r\n\t_In_ ULONG hash_code,\r\n\t_In_ PR_QUEUED_LOCK spin_lock,\r\n\t_In_opt_ PR_STRING string\r\n);\r\n\r\nBOOLEAN _app_getcachetable (\r\n\t_Inout_ PR_HASHTABLE cache_table,\r\n\t_In_ ULONG hash_code,\r\n\t_In_ PR_QUEUED_LOCK spin_lock,\r\n\t_Out_ PR_STRING_PTR string\r\n);\r\n\r\nPR_STRING _app_formatarpa (\r\n\t_In_ ADDRESS_FAMILY af,\r\n\t_In_ LPCVOID address\r\n);\r\n\r\n_Ret_maybenull_\r\nPR_STRING _app_formataddress (\r\n\t_In_ ADDRESS_FAMILY af,\r\n\t_In_ UINT8 proto,\r\n\t_In_ LPCVOID address,\r\n\t_In_opt_ UINT16 port,\r\n\t_In_ ULONG flags\r\n);\r\n\r\nPR_STRING _app_formataddress_interlocked (\r\n\t_In_ PVOID volatile *string,\r\n\t_In_ ADDRESS_FAMILY af,\r\n\t_In_ LPCVOID address\r\n);\r\n\r\n_Success_ (NT_SUCCESS (return))\r\nNTSTATUS _app_formatip (\r\n\t_In_ ADDRESS_FAMILY af,\r\n\t_In_ LPCVOID address,\r\n\t_Out_writes_to_ (buffer_length, buffer_length) LPWSTR buffer,\r\n\t_In_ ULONG buffer_length,\r\n\t_In_ BOOLEAN is_checkempty\r\n);\r\n\r\nPR_STRING _app_formatport (\r\n\t_In_ UINT16 port,\r\n\t_In_ UINT8 proto\r\n);\r\n\r\n_Ret_maybenull_\r\nPITEM_APP_INFO _app_getappinfobyhash2 (\r\n\t_In_ ULONG app_hash\r\n);\r\n\r\n_Success_ (return)\r\nBOOLEAN _app_getappinfoparam2 (\r\n\t_In_ ULONG app_hash,\r\n\t_In_opt_ INT listview_id,\r\n\t_In_ ENUM_INFO_DATA2 info_data,\r\n\t_Out_writes_bytes_all_ (length) PVOID buffer,\r\n\t_In_ ULONG_PTR length\r\n);\r\n\r\nBOOLEAN _app_isappsigned (\r\n\t_In_ ULONG app_hash\r\n);\r\n\r\nBOOLEAN _app_isappvalidbinary (\r\n\t_In_opt_ PR_STRING path\r\n);\r\n\r\nBOOLEAN _app_isappvalidpath (\r\n\t_In_opt_ PR_STRING path\r\n);\r\n\r\n_Ret_maybenull_\r\nPR_STRING _app_getappdisplayname (\r\n\t_In_ PITEM_APP ptr_app,\r\n\t_In_ BOOLEAN is_shortened\r\n);\r\n\r\n_Ret_maybenull_\r\nPR_STRING _app_getapppath (\r\n\t_In_ PITEM_APP ptr_app,\r\n\t_In_ BOOLEAN is_returnshort\r\n);\r\n\r\nVOID _app_getfileicon (\r\n\t_Inout_ PITEM_APP_INFO ptr_app_info\r\n);\r\n\r\nVOID _app_getfilesignatureinfo (\r\n\t_In_ HANDLE hfile,\r\n\t_Inout_ PITEM_APP_INFO ptr_app_info\r\n);\r\n\r\nVOID _app_getfileversioninfo (\r\n\t_Inout_ PITEM_APP_INFO ptr_app_info\r\n);\r\n\r\n_Ret_maybenull_\r\nPR_STRING _app_getfilehashinfo (\r\n\t_In_ HANDLE hfile,\r\n\t_In_ ULONG app_hash\r\n);\r\n\r\nULONG _app_addcolor (\r\n\t_In_ ULONG locale_id,\r\n\t_In_ LPCWSTR config_name,\r\n\t_In_ LPCWSTR config_value,\r\n\t_In_ COLORREF default_clr,\r\n\t_In_ BOOLEAN is_enabled\r\n);\r\n\r\nCOLORREF _app_getcolorvalue (\r\n\t_In_ ULONG color_hash\r\n);\r\n\r\nVOID _app_generate_rulescontrol (\r\n\t_In_ HMENU hsubmenu,\r\n\t_In_ ULONG app_hash,\r\n\t_In_opt_ PITEM_LOG ptr_log\r\n);\r\n\r\nVOID _app_generate_timerscontrol (\r\n\t_In_ HMENU hsubmenu,\r\n\t_In_ ULONG app_hash\r\n);\r\n\r\nBOOLEAN _app_setruletoapp (\r\n\t_In_ HWND hwnd,\r\n\t_Inout_ PITEM_RULE ptr_rule,\r\n\t_In_ INT item_id,\r\n\t_In_ PITEM_APP ptr_app,\r\n\t_In_ BOOLEAN is_enable\r\n);\r\n\r\n_Success_ (return)\r\nBOOLEAN _app_parsenetworkstring (\r\n\t_In_ LPCWSTR network_string,\r\n\t_Inout_ PITEM_ADDRESS address\r\n);\r\n\r\n_Success_ (return)\r\nBOOLEAN _app_preparserulestring (\r\n\t_In_ PR_STRINGREF rule,\r\n\t_Out_ PITEM_ADDRESS address\r\n);\r\n\r\n_Success_ (return)\r\nBOOLEAN _app_parserulestring (\r\n\t_In_opt_ PR_STRINGREF rule,\r\n\t_Out_ PITEM_ADDRESS address\r\n);\r\n\r\n_Ret_maybenull_\r\nPR_STRING _app_resolveaddress (\r\n\t_In_ ADDRESS_FAMILY af,\r\n\t_In_ LPCVOID address\r\n);\r\n\r\nPR_STRING _app_resolveaddress_interlocked (\r\n\t_In_ PVOID volatile *string,\r\n\t_In_ ADDRESS_FAMILY af,\r\n\t_In_ LPCVOID address,\r\n\t_In_ BOOLEAN is_resolutionenabled\r\n);\r\n\r\nVOID _app_fileloggingenable ();\r\n\r\nVOID NTAPI _app_timercallback (\r\n\t_In_opt_ PVOID context\r\n);\r\n\r\nVOID _app_getfileinformation (\r\n\t_In_ PR_STRING path,\r\n\t_In_ ULONG app_hash,\r\n\t_In_ ENUM_TYPE_DATA type,\r\n\t_In_ INT listview_id\r\n);\r\n\r\nVOID _app_queue_resolver (\r\n\t_In_ HWND hwnd,\r\n\t_In_ INT listview_id,\r\n\t_In_ ULONG_PTR hash_code,\r\n\t_In_ PVOID base_address\r\n);\r\n\r\nVOID NTAPI _app_queue_fileinformation (\r\n\t_In_ PVOID arglist\r\n);\r\n\r\nVOID NTAPI _app_queue_notifyinformation (\r\n\t_In_ PVOID arglist\r\n);\r\n\r\nVOID NTAPI _app_queue_resolveinformation (\r\n\t_In_ PVOID arglist\r\n);\r\n\r\nBOOLEAN _app_wufixenabled ();\r\n\r\nVOID _app_wufixhelper (\r\n\t_In_ SC_HANDLE hsvcmgr,\r\n\t_In_ LPCWSTR service_name,\r\n\t_In_ LPCWSTR k_value,\r\n\t_In_ BOOLEAN is_enable\r\n);\r\n\r\nVOID _app_wufixenable (\r\n\t_In_ HWND hwnd,\r\n\t_In_ BOOLEAN is_install\r\n);\r\n"
  },
  {
    "path": "src/icons.c",
    "content": "// simplewall\n// Copyright (c) 2016-2025 Henry++\n\n#include \"global.h\"\n\nPICON_INFORMATION _app_icons_getdefault ()\n{\n\tstatic R_INITONCE init_once = PR_INITONCE_INIT;\n\tstatic ICON_INFORMATION icon_info = {0};\n\n\tPR_STRING path;\n\n\tif (_r_initonce_begin (&init_once))\n\t{\n\t\t// load default icons\n\t\tpath = _r_obj_concatstrings (\n\t\t\t2,\n\t\t\t_r_sys_getsystemdirectory ()->buffer,\n\t\t\tPATH_SVCHOST\n\t\t);\n\n\t\t_app_icons_loadfromfile (path, 0, &icon_info.app_icon_id, &icon_info.app_hicon, FALSE);\n\n\t\t// load default service icons\n\t\t_r_obj_dereference (path);\n\n\t\tpath = _r_obj_concatstrings (\n\t\t\t2,\n\t\t\t_r_sys_getsystemdirectory ()->buffer,\n\t\t\tL\"\\\\shell32.dll\"\n\t\t);\n\n\t\t_app_icons_loadfromfile (path, 0, &icon_info.service_icon_id, &icon_info.service_hicon, FALSE);\n\n\t\t_r_obj_dereference (path);\n\n\t\t// load uwp icons\n\t\tif (_r_sys_isosversiongreaterorequal (WINDOWS_8))\n\t\t{\n\t\t\tpath = _r_obj_concatstrings (\n\t\t\t\t2,\n\t\t\t\t_r_sys_getsystemdirectory ()->buffer,\n\t\t\t\tL\"\\\\wsreset.exe\"\n\t\t\t);\n\n\t\t\t_app_icons_loadfromfile (path, 0, &icon_info.uwp_icon_id, &icon_info.uwp_hicon, FALSE);\n\n\t\t\t_r_obj_dereference (path);\n\t\t}\n\n\t\t_r_initonce_end (&init_once);\n\t}\n\n\treturn &icon_info;\n}\n\n_Ret_maybenull_\nHICON _app_icons_getdefaultapp_hicon ()\n{\n\tPICON_INFORMATION icon_info;\n\n\ticon_info = _app_icons_getdefault ();\n\n\tif (icon_info->app_hicon)\n\t\treturn CopyIcon (icon_info->app_hicon);\n\n\treturn NULL;\n}\n\n_Ret_maybenull_\nHICON _app_icons_getdefaulttype_hicon (\n\t_In_ ENUM_TYPE_DATA type,\n\t_In_ PICON_INFORMATION icon_info\n)\n{\n\tif (type == DATA_APP_SERVICE)\n\t{\n\t\tif (icon_info->service_hicon)\n\t\t\treturn CopyIcon (icon_info->service_hicon);\n\t}\n\telse if (type == DATA_APP_UWP)\n\t{\n\t\tif (icon_info->uwp_hicon)\n\t\t\treturn CopyIcon (icon_info->uwp_hicon);\n\t}\n\tif (icon_info->app_hicon)\n\t\treturn CopyIcon (icon_info->app_hicon);\n\n\treturn NULL;\n}\n\nLONG _app_icons_getdefaultapp_id (\n\t_In_ ENUM_TYPE_DATA type\n)\n{\n\tPICON_INFORMATION icon_info;\n\n\ticon_info = _app_icons_getdefault ();\n\n\tif (type == DATA_APP_SERVICE)\n\t{\n\t\treturn icon_info->service_icon_id;\n\t}\n\telse if (type == DATA_APP_UWP)\n\t{\n\t\treturn icon_info->uwp_icon_id;\n\t}\n\n\treturn icon_info->app_icon_id;\n}\n\n_Ret_maybenull_\nHICON _app_icons_getsafeapp_hicon (\n\t_In_ ULONG app_hash\n)\n{\n\tPICON_INFORMATION icon_info;\n\tPITEM_APP ptr_app;\n\tHICON hicon;\n\tLONG icon_id;\n\tBOOLEAN is_iconshidded;\n\n\ticon_info = _app_icons_getdefault ();\n\tptr_app = _app_getappitem (app_hash);\n\n\tif (!ptr_app)\n\t{\n\t\tif (icon_info->app_hicon)\n\t\t\treturn CopyIcon (icon_info->app_hicon);\n\n\t\treturn NULL;\n\t}\n\n\tis_iconshidded = _r_config_getboolean (L\"IsIconsHidden\", FALSE, NULL);\n\n\tif (is_iconshidded || !_app_isappvalidbinary (ptr_app->real_path))\n\t{\n\t\thicon = _app_icons_getdefaulttype_hicon (ptr_app->type, icon_info);\n\n\t\t_r_obj_dereference (ptr_app);\n\n\t\treturn hicon;\n\t}\n\n\t_app_icons_loadfromfile (ptr_app->real_path, ptr_app->type, &icon_id, &hicon, TRUE);\n\n\tif (!icon_id || ((ptr_app->type == DATA_APP_UWP || ptr_app->type == DATA_APP_SERVICE) && icon_id == icon_info->app_icon_id))\n\t{\n\t\tif (hicon)\n\t\t\tDestroyIcon (hicon);\n\n\t\thicon = _app_icons_getdefaulttype_hicon (ptr_app->type, icon_info);\n\t}\n\n\t_r_obj_dereference (ptr_app);\n\n\treturn hicon;\n}\n\nVOID _app_icons_loaddefaults (\n\t_In_ ENUM_TYPE_DATA type,\n\t_Inout_opt_ HICON_PTR hicon_ptr,\n\t_Inout_opt_ PLONG icon_id_ptr\n)\n{\n\tPICON_INFORMATION icon_info;\n\n\ticon_info = _app_icons_getdefault ();\n\n\tif (icon_id_ptr)\n\t{\n\t\tif (*icon_id_ptr == 0 || (type == DATA_APP_UWP && *icon_id_ptr == icon_info->app_icon_id) || (type == DATA_APP_SERVICE && *icon_id_ptr == icon_info->app_icon_id))\n\t\t{\n\t\t\tif (type == DATA_APP_UWP)\n\t\t\t{\n\t\t\t\t*icon_id_ptr = icon_info->uwp_icon_id;\n\t\t\t}\n\t\t\telse if (type == DATA_APP_SERVICE)\n\t\t\t{\n\t\t\t\t*icon_id_ptr = icon_info->service_icon_id;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t*icon_id_ptr = icon_info->app_icon_id;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (hicon_ptr)\n\t{\n\t\tif (*hicon_ptr == NULL || type == DATA_APP_UWP)\n\t\t{\n\t\t\tif (type == DATA_APP_UWP)\n\t\t\t{\n\t\t\t\tif (icon_info->uwp_hicon)\n\t\t\t\t\t*hicon_ptr = CopyIcon (icon_info->uwp_hicon);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tif (icon_info->app_hicon)\n\t\t\t\t\t*hicon_ptr = CopyIcon (icon_info->app_hicon);\n\t\t\t}\n\t\t}\n\t}\n}\n\nVOID _app_icons_loadfromfile (\n\t_In_opt_ PR_STRING path,\n\t_In_ ENUM_TYPE_DATA type,\n\t_Out_opt_ PLONG icon_id_ptr,\n\t_Out_opt_ HICON_PTR hicon_ptr,\n\t_In_ BOOLEAN is_loaddefaults\n)\n{\n\tif (!icon_id_ptr && !hicon_ptr)\n\t\treturn;\n\n\tif (icon_id_ptr)\n\t\t*icon_id_ptr = 0;\n\n\tif (hicon_ptr)\n\t\t*hicon_ptr = NULL;\n\n\tif (!_r_obj_isstringempty (path))\n\t\t_r_path_geticon (&path->sr, hicon_ptr, icon_id_ptr);\n\n\tif (is_loaddefaults)\n\t\t_app_icons_loaddefaults (type, hicon_ptr, icon_id_ptr);\n}\n"
  },
  {
    "path": "src/icons.h",
    "content": "// simplewall\n// Copyright (c) 2016-2025 Henry++\n\n#pragma once\n\nPICON_INFORMATION _app_icons_getdefault ();\n\n_Ret_maybenull_\nHICON _app_icons_getdefaultapp_hicon ();\n\n_Ret_maybenull_\nHICON _app_icons_getdefaulttype_hicon (\n\t_In_ ENUM_TYPE_DATA type,\n\t_In_ PICON_INFORMATION icon_info\n);\n\nLONG _app_icons_getdefaultapp_id (\n\t_In_ ENUM_TYPE_DATA type\n);\n\n_Ret_maybenull_\nHICON _app_icons_getsafeapp_hicon (\n\t_In_ ULONG app_hash\n);\n\nVOID _app_icons_loaddefaults (\n\t_In_ ENUM_TYPE_DATA type,\n\t_Inout_opt_ HICON_PTR hicon_ptr,\n\t_Inout_opt_ PLONG icon_id_ptr\n);\n\nVOID _app_icons_loadfromfile (\n\t_In_opt_ PR_STRING path,\n\t_In_ ENUM_TYPE_DATA type,\n\t_Out_opt_ PLONG icon_id_ptr,\n\t_Out_opt_ HICON_PTR hicon_ptr,\n\t_In_ BOOLEAN is_loaddefaults\n);\n"
  },
  {
    "path": "src/listview.c",
    "content": "// simplewall\n// Copyright (c) 2016-2025 Henry++\n\n#include \"global.h\"\n\n_Ret_maybenull_\nPITEM_TAB_CONTEXT _app_listview_getcontext (\n\t_In_ HWND hwnd,\n\t_In_ INT tab_id\n)\n{\n\tif (tab_id == INT_ERROR)\n\t{\n\t\ttab_id = _r_tab_getcurrentitem (hwnd, IDC_TAB);\n\n\t\tif (tab_id == INT_ERROR)\n\t\t\ttab_id = 0;\n\t}\n\n\treturn (PITEM_TAB_CONTEXT)_r_tab_getitemlparam (hwnd, IDC_TAB, tab_id);\n}\n\n_Success_ (return != 0)\nINT _app_listview_getbytype (\n\t_In_ ENUM_TYPE_DATA type\n)\n{\n\tswitch (type)\n\t{\n\t\tcase DATA_APP_REGULAR:\n\t\tcase DATA_APP_DEVICE:\n\t\tcase DATA_APP_NETWORK:\n\t\tcase DATA_APP_PICO:\n\t\t{\n\t\t\treturn IDC_APPS_PROFILE;\n\t\t}\n\n\t\tcase DATA_APP_SERVICE:\n\t\t{\n\t\t\treturn IDC_APPS_SERVICE;\n\t\t}\n\n\t\tcase DATA_APP_UWP:\n\t\t{\n\t\t\treturn IDC_APPS_UWP;\n\t\t}\n\n\t\tcase DATA_RULE_BLOCKLIST:\n\t\t{\n\t\t\treturn IDC_RULES_BLOCKLIST;\n\t\t}\n\n\t\tcase DATA_RULE_SYSTEM:\n\t\t{\n\t\t\treturn IDC_RULES_SYSTEM;\n\t\t}\n\n\t\tcase DATA_RULE_SYSTEM_USER:\n\t\tcase DATA_RULE_USER:\n\t\t{\n\t\t\treturn IDC_RULES_CUSTOM;\n\t\t}\n\n\t\tdefault:\n\t\t{\n\t\t\tFALLTHROUGH;\n\t\t}\n\t}\n\n\treturn 0;\n}\n\nVOID _app_listview_additems (\n\t_In_ HWND hwnd\n)\n{\n\tPITEM_APP ptr_app = NULL;\n\tPITEM_RULE ptr_rule;\n\tLONG64 current_time;\n\tULONG_PTR enum_key = 0;\n\n\tcurrent_time = _r_unixtime_now ();\n\n\t// add apps\n\t_r_queuedlock_acquireshared (&lock_apps);\n\n\twhile (_r_obj_enumhashtablepointer (apps_table, (PVOID_PTR)&ptr_app, NULL, &enum_key))\n\t{\n\t\t_app_listview_addappitem (hwnd, ptr_app);\n\n\t\t// install timer\n\t\tif (ptr_app->timer)\n\t\t\t_app_timer_set (hwnd, ptr_app, ptr_app->timer - current_time);\n\t}\n\n\t_r_queuedlock_releaseshared (&lock_apps);\n\n\t// add rules\n\t_r_queuedlock_acquireshared (&lock_rules);\n\n\tfor (ULONG_PTR i = 0; i < _r_obj_getlistsize (rules_list); i++)\n\t{\n\t\tptr_rule = _r_obj_getlistitem (rules_list, i);\n\n\t\tif (ptr_rule)\n\t\t\t_app_listview_addruleitem (hwnd, ptr_rule, (ULONG)i, FALSE);\n\t}\n\n\t_r_queuedlock_releaseshared (&lock_rules);\n}\n\nVOID _app_listview_clearitems (\n\t_In_ HWND hwnd\n)\n{\n\tfor (INT i = IDC_APPS_PROFILE; i <= IDC_RULES_CUSTOM; i++)\n\t{\n\t\t_r_listview_deleteallitems (hwnd, i);\n\t}\n}\n\nVOID _app_listview_addappitem (\n\t_In_ HWND hwnd,\n\t_In_ PITEM_APP ptr_app\n)\n{\n\tINT listview_id;\n\tINT item_id;\n\n\tlistview_id = _app_listview_getbytype (ptr_app->type);\n\n\tif (!listview_id)\n\t\treturn;\n\n\titem_id = _r_listview_getitemcount (hwnd, listview_id);\n\n\t_app_listview_lock (hwnd, listview_id, TRUE);\n\n\t_r_listview_additem (hwnd, listview_id, item_id, LPSTR_TEXTCALLBACK, I_IMAGECALLBACK, I_GROUPIDCALLBACK, _app_listview_createcontext (ptr_app->app_hash));\n\n\t_app_setappiteminfo (hwnd, listview_id, item_id, ptr_app);\n\n\t_app_listview_lock (hwnd, listview_id, FALSE);\n}\n\nVOID _app_listview_addruleitem (\n\t_In_ HWND hwnd,\n\t_In_ PITEM_RULE ptr_rule,\n\t_In_ ULONG_PTR rule_idx,\n\t_In_ BOOLEAN is_forapp\n)\n{\n\tINT listview_id;\n\tINT item_id;\n\n\tlistview_id = _app_listview_getbytype (ptr_rule->type);\n\n\tif (!listview_id)\n\t\treturn;\n\n\titem_id = _r_listview_getitemcount (hwnd, listview_id);\n\n\t_app_listview_lock (hwnd, listview_id, TRUE);\n\n\t_r_listview_additem (hwnd, listview_id, item_id, LPSTR_TEXTCALLBACK, I_IMAGECALLBACK, I_GROUPIDCALLBACK, _app_listview_createcontext (rule_idx));\n\n\t_app_setruleiteminfo (hwnd, listview_id, item_id, ptr_rule, is_forapp);\n\n\t_app_listview_lock (hwnd, listview_id, FALSE);\n}\n\nVOID _app_listview_addnetworkitem (\n\t_In_ HWND hwnd,\n\t_In_ ULONG network_hash\n)\n{\n\t_r_listview_additem (hwnd, IDC_NETWORK, INT_ERROR, LPSTR_TEXTCALLBACK, I_IMAGECALLBACK, I_GROUPIDCALLBACK, _app_listview_createcontext (network_hash));\n}\n\nVOID _app_listview_addlogitem (\n\t_In_ HWND hwnd,\n\t_In_ PITEM_LOG ptr_log,\n\t_In_ ULONG log_hash\n)\n{\n\t// increment value\n\t_InterlockedIncrement (&config.log_id);\n\n\tptr_log->log_id = _InterlockedCompareExchange (&config.log_id, 0, 0);\n\n\t_r_listview_additem (hwnd, IDC_LOG, INT_ERROR, LPSTR_TEXTCALLBACK, I_IMAGECALLBACK, 0, _app_listview_createcontext (log_hash));\n}\n\nBOOLEAN _app_listview_islocked (\n\t_In_ HWND hwnd,\n\t_In_ INT ctrl_id\n)\n{\n\tPVOID context;\n\tULONG property_id;\n\n\tproperty_id = (USHORT_MAX - ctrl_id);\n\n\tcontext = _r_wnd_getcontext (hwnd, property_id);\n\n\treturn (context != NULL);\n}\n\nVOID _app_listview_lock (\n\t_In_ HWND hwnd,\n\t_In_ INT ctrl_id,\n\t_In_ BOOLEAN is_lock\n)\n{\n\tULONG property_id;\n\n\tproperty_id = (USHORT_MAX - ctrl_id);\n\n\tif (is_lock)\n\t{\n\t\t_r_wnd_setcontext (hwnd, property_id, INVALID_HANDLE_VALUE);\n\t}\n\telse\n\t{\n\t\t_r_wnd_removecontext (hwnd, property_id);\n\t}\n}\n\nLONG_PTR _app_listview_createcontext (\n\t_In_ ULONG_PTR id_code\n)\n{\n\tPITEM_LISTVIEW_CONTEXT context;\n\n\tcontext = _r_freelist_allocateitem (&listview_free_list);\n\n\tcontext->id_code = id_code;\n\n\treturn (LONG_PTR)context;\n}\n\nVOID _app_listview_destroycontext (\n\t_In_ PITEM_LISTVIEW_CONTEXT context\n)\n{\n\t_r_freelist_deleteitem (&listview_free_list, context);\n}\n\nULONG_PTR _app_listview_getcontextcode (\n\t_In_ LONG_PTR lparam\n)\n{\n\tPITEM_LISTVIEW_CONTEXT context;\n\n\tcontext = (PITEM_LISTVIEW_CONTEXT)lparam;\n\n\treturn context->id_code;\n}\n\n_Success_ (return != 0)\nULONG _app_listview_getappcontext (\n\t_In_ HWND hwnd,\n\t_In_ INT listview_id,\n\t_In_ INT item_id\n)\n{\n\tPITEM_NETWORK ptr_network;\n\tPITEM_LOG ptr_log;\n\tLONG_PTR context;\n\tULONG app_hash = 0;\n\n\tcontext = _r_listview_getitemlparam (hwnd, listview_id, item_id);\n\n\tif (!context)\n\t\treturn 0;\n\n\tcontext = _app_listview_getcontextcode (context);\n\n\tswitch (listview_id)\n\t{\n\t\tcase IDC_NETWORK:\n\t\t{\n\t\t\tptr_network = _app_network_getitem ((ULONG)context);\n\n\t\t\tif (ptr_network)\n\t\t\t{\n\t\t\t\tapp_hash = ptr_network->app_hash;\n\n\t\t\t\t_r_obj_dereference (ptr_network);\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase IDC_LOG:\n\t\t{\n\t\t\tptr_log = _app_getlogitem ((ULONG)context);\n\n\t\t\tif (ptr_log)\n\t\t\t{\n\t\t\t\tapp_hash = ptr_log->app_hash;\n\n\t\t\t\t_r_obj_dereference (ptr_log);\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tdefault:\n\t\t{\n\t\t\tapp_hash = (ULONG)context;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn app_hash;\n}\n\nULONG_PTR _app_listview_getitemcontext (\n\t_In_ HWND hwnd,\n\t_In_ INT listview_id,\n\t_In_ INT item_id\n)\n{\n\tLONG_PTR lparam;\n\n\tlparam = _r_listview_getitemlparam (hwnd, listview_id, item_id);\n\n\tif (!lparam)\n\t\treturn 0;\n\n\treturn _app_listview_getcontextcode (lparam);\n}\n\nBOOLEAN _app_listview_isitemhidden (\n\t_In_ LPARAM lparam\n)\n{\n\tPITEM_LISTVIEW_CONTEXT context;\n\n\tcontext = (PITEM_LISTVIEW_CONTEXT)lparam;\n\n\tif (!context)\n\t\treturn FALSE;\n\n\treturn !!context->is_hidden;\n}\n\n_Success_ (return != INT_ERROR)\nINT _app_listview_finditem (\n\t_In_ HWND hwnd,\n\t_In_ INT listview_id,\n\t_In_ ULONG_PTR id_code\n)\n{\n\tULONG_PTR current_code;\n\tINT item_count;\n\n\tif ((listview_id >= IDC_APPS_PROFILE && listview_id <= IDC_LOG) || listview_id == IDC_RULE_APPS_ID || listview_id == IDC_APP_RULES_ID)\n\t{\n\t\titem_count = _r_listview_getitemcount (hwnd, listview_id);\n\n\t\tfor (INT i = 0; i < item_count; i++)\n\t\t{\n\t\t\tcurrent_code = _app_listview_getitemcontext (hwnd, listview_id, i);\n\n\t\t\tif (current_code == id_code)\n\t\t\t\treturn i;\n\t\t}\n\t}\n\telse\n\t{\n\t\treturn _r_listview_finditem (hwnd, listview_id, INT_ERROR, id_code);\n\t}\n\n\treturn INT_ERROR;\n}\n\nVOID _app_listview_removeitem (\n\t_In_ HWND hwnd,\n\t_In_ ULONG_PTR id_code,\n\t_In_ ENUM_TYPE_DATA type\n)\n{\n\tINT listview_id;\n\tINT item_id;\n\n\tif (!hwnd)\n\t\treturn;\n\n\tlistview_id = _app_listview_getbytype (type);\n\n\tif (!listview_id)\n\t\treturn;\n\n\titem_id = _app_listview_finditem (hwnd, listview_id, id_code);\n\n\tif (item_id != INT_ERROR)\n\t\t_r_listview_deleteitem (hwnd, listview_id, item_id);\n}\n\nVOID _app_listview_showitemby_id (\n\t_In_ HWND hwnd,\n\t_In_ INT listview_id,\n\t_In_ INT item_id,\n\t_In_ INT scroll_pos\n)\n{\n\tINT total_count;\n\n\t_app_settab_id (hwnd, listview_id);\n\n\ttotal_count = _r_listview_getitemcount (hwnd, listview_id);\n\n\tif (!total_count)\n\t\treturn;\n\n\tif (item_id != INT_ERROR)\n\t{\n\t\titem_id = _r_calc_clamp (item_id, 0, total_count - 1);\n\n\t\t_r_listview_setitemvisible (hwnd, listview_id, item_id);\n\t}\n\n\t// restore scroll position\n\tif (scroll_pos > 0)\n\t\t_r_listview_scroll (hwnd, listview_id, scroll_pos);\n}\n\nVOID _app_listview_showitemby_param (\n\t_In_ HWND hwnd,\n\t_In_ ULONG_PTR lparam,\n\t_In_ BOOLEAN is_app\n)\n{\n\tPITEM_TAB_CONTEXT tab_context;\n\tINT listview_id = 0;\n\tINT item_id;\n\n\tif (is_app)\n\t{\n\t\t_app_getappinfobyhash ((ULONG)lparam, INFO_LISTVIEW_ID, &listview_id, sizeof (INT));\n\t}\n\telse\n\t{\n\t\t_app_getruleinfobyid (lparam, INFO_LISTVIEW_ID, &listview_id, sizeof (INT));\n\t}\n\n\tif (!listview_id)\n\t\treturn;\n\n\ttab_context = _app_listview_getcontext (hwnd, INT_ERROR);\n\n\tif (tab_context)\n\t{\n\t\tif (listview_id != tab_context->listview_id)\n\t\t{\n\t\t\t_app_listview_sort (hwnd, listview_id, INT_ERROR, FALSE);\n\n\t\t\t_app_listview_resize (hwnd, listview_id, FALSE);\n\t\t}\n\t}\n\n\titem_id = _app_listview_finditem (hwnd, listview_id, lparam);\n\n\tif (item_id != INT_ERROR)\n\t{\n\t\t_app_listview_showitemby_id (hwnd, listview_id, item_id, INT_ERROR);\n\n\t\t_r_wnd_toggle (hwnd, TRUE);\n\t}\n}\n\nVOID _app_listview_updateby_id (\n\t_In_ HWND hwnd,\n\t_In_ INT lparam,\n\t_In_ ULONG flags\n)\n{\n\tPITEM_TAB_CONTEXT tab_context;\n\tENUM_TYPE_DATA type;\n\tINT listview_id;\n\n\ttab_context = _app_listview_getcontext (hwnd, INT_ERROR);\n\n\tif (!tab_context)\n\t\treturn;\n\n\tif (flags & PR_UPDATE_TYPE)\n\t{\n\t\ttype = lparam;\n\n\t\tif (type == DATA_LISTVIEW_CURRENT)\n\t\t{\n\t\t\tlistview_id = tab_context->listview_id;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tlistview_id = _app_listview_getbytype (type);\n\t\t}\n\t}\n\telse\n\t{\n\t\tlistview_id = lparam;\n\t}\n\n\tif ((flags & PR_UPDATE_FORCE) || (listview_id == tab_context->listview_id))\n\t{\n\t\tif (!(flags & PR_UPDATE_NOREDRAW))\n\t\t\t_r_listview_redraw (hwnd, listview_id);\n\n\t\tif (!(flags & PR_UPDATE_NOSETVIEW))\n\t\t{\n\t\t\t_app_listview_setfont (hwnd, listview_id);\n\n\t\t\t_app_listview_setview (hwnd, listview_id);\n\t\t}\n\n\t\tif (!(flags & PR_UPDATE_NOREFRESH))\n\t\t\t_app_listview_refreshgroups (hwnd, listview_id);\n\n\t\tif (!(flags & PR_UPDATE_NOSORT))\n\t\t\t_app_listview_sort (hwnd, listview_id, INT_ERROR, FALSE);\n\n\t\tif (!(flags & PR_UPDATE_NORESIZE))\n\t\t\t_app_listview_resize (hwnd, listview_id, FALSE);\n\t}\n\n\t_app_refreshstatus (hwnd);\n}\n\nVOID _app_listview_updateby_param (\n\t_In_ HWND hwnd,\n\t_In_ ULONG_PTR lparam,\n\t_In_ ULONG flags,\n\t_In_ BOOLEAN is_app\n)\n{\n\tPITEM_TAB_CONTEXT tab_context;\n\tINT listview_id = 0;\n\n\tif (is_app)\n\t{\n\t\t_app_getappinfobyhash ((ULONG)lparam, INFO_LISTVIEW_ID, &listview_id, sizeof (INT));\n\t}\n\telse\n\t{\n\t\t_app_getruleinfobyid (lparam, INFO_LISTVIEW_ID, &listview_id, sizeof (INT));\n\t}\n\n\tif (!listview_id)\n\t\treturn;\n\n\tif ((flags & PR_SETITEM_UPDATE))\n\t\t_app_listview_updateby_id (hwnd, listview_id, 0);\n\n\tif ((flags & PR_SETITEM_REDRAW))\n\t{\n\t\ttab_context = _app_listview_getcontext (hwnd, INT_ERROR);\n\n\t\tif (tab_context)\n\t\t{\n\t\t\tif (listview_id == tab_context->listview_id)\n\t\t\t\t_r_listview_redraw (hwnd, listview_id);\n\t\t}\n\t}\n}\n\nVOID _app_listview_updateitemby_param (\n\t_In_ HWND hwnd,\n\t_In_ ULONG_PTR lparam,\n\t_In_ BOOLEAN is_app\n)\n{\n\tPITEM_RULE ptr_rule;\n\tPITEM_APP ptr_app;\n\tINT listview_id = 0;\n\tINT item_id;\n\n\tif (is_app)\n\t{\n\t\t_app_getappinfobyhash ((ULONG)lparam, INFO_LISTVIEW_ID, &listview_id, sizeof (INT));\n\t}\n\telse\n\t{\n\t\t_app_getruleinfobyid (lparam, INFO_LISTVIEW_ID, &listview_id, sizeof (INT));\n\t}\n\n\tif (!listview_id)\n\t\treturn;\n\n\titem_id = _app_listview_finditem (hwnd, listview_id, lparam);\n\n\tif (item_id == INT_ERROR)\n\t\treturn;\n\n\tif (is_app)\n\t{\n\t\tptr_app = _app_getappitem ((ULONG)lparam);\n\n\t\tif (!ptr_app)\n\t\t\treturn;\n\n\t\t_app_listview_lock (hwnd, listview_id, TRUE);\n\t\t_app_setappiteminfo (hwnd, listview_id, item_id, ptr_app);\n\t\t_app_listview_lock (hwnd, listview_id, FALSE);\n\n\t\t_r_obj_dereference (ptr_app);\n\t}\n\telse\n\t{\n\t\tptr_rule = _app_getrulebyid (lparam);\n\n\t\tif (!ptr_rule)\n\t\t\treturn;\n\n\t\t_app_listview_lock (hwnd, listview_id, TRUE);\n\t\t_app_setruleiteminfo (hwnd, listview_id, item_id, ptr_rule, FALSE);\n\t\t_app_listview_lock (hwnd, listview_id, FALSE);\n\n\t\t_r_obj_dereference (ptr_rule);\n\t}\n}\n\nVOID _app_listview_updateitemby_id (\n\t_In_ HWND hwnd,\n\t_In_ INT listview_id,\n\t_In_ INT item_id\n)\n{\n\t_r_listview_setitem (hwnd, listview_id, item_id, 0, LPSTR_TEXTCALLBACK, I_IMAGECALLBACK, I_GROUPIDCALLBACK, I_DEFAULT);\n}\n\nVOID _app_listview_loadfont (\n\t_In_ LONG dpi_value,\n\t_In_ BOOLEAN is_forced\n)\n{\n\tLOGFONT logfont = {0};\n\n\tif (is_forced || !config.hfont)\n\t{\n\t\tSAFE_DELETE_OBJECT (config.hfont);\n\n\t\t_r_config_getfont (L\"Font\", &logfont, dpi_value, NULL);\n\n\t\tconfig.hfont = _app_createfont (&logfont, 0, FALSE, 0);\n\t}\n}\n\nVOID _app_listview_refreshgroups (\n\t_In_ HWND hwnd,\n\t_In_ INT listview_id\n)\n{\n\tWCHAR buffer1[128];\n\tWCHAR buffer2[128];\n\tUINT group1_title;\n\tUINT group2_title;\n\tUINT group3_title;\n\tUINT group4_title;\n\tUINT group5_title;\n\tINT total_count;\n\tINT group1_count = 0;\n\tINT group2_count = 0;\n\tINT group3_count = 0;\n\tINT group4_count = 0;\n\tINT group5_count = 0;\n\tINT group_id;\n\tBOOLEAN is_rules;\n\n\tif (!_r_listview_isgroupviewenabled (hwnd, listview_id))\n\t\treturn;\n\n\tis_rules = (listview_id >= IDC_RULES_BLOCKLIST && listview_id <= IDC_RULES_CUSTOM);\n\n\tif (listview_id >= IDC_APPS_PROFILE && listview_id <= IDC_APPS_UWP)\n\t{\n\t\tgroup1_title = IDS_GROUP_ALLOWED;\n\t\tgroup2_title = IDS_GROUP_TIMER;\n\t\tgroup3_title = IDS_GROUP_SPECIAL_APPS;\n\t\tgroup4_title = IDS_GROUP_BLOCKED;\n\t\tgroup5_title = IDS_GROUP_BLOCKED;\n\t}\n\telse if (is_rules)\n\t{\n\t\tgroup1_title = IDS_GROUP_ENABLED;\n\t\tgroup2_title = IDS_GROUP_ENABLED;\n\t\tgroup3_title = IDS_GROUP_DISABLED;\n\t\tgroup4_title = 0;\n\t\tgroup5_title = 0;\n\t}\n\telse if (listview_id == IDC_RULE_APPS_ID || listview_id == IDC_NETWORK)\n\t{\n\t\tgroup1_title = IDS_TAB_APPS;\n\t\tgroup2_title = IDS_TAB_SERVICES;\n\t\tgroup3_title = IDS_TAB_PACKAGES;\n\t\tgroup4_title = 0;\n\t\tgroup5_title = 0;\n\t}\n\telse if (listview_id == IDC_APP_RULES_ID)\n\t{\n\t\tgroup1_title = IDS_TRAY_SYSTEM_RULES;\n\t\tgroup2_title = IDS_TRAY_USER_RULES;\n\t\tgroup3_title = 0;\n\t\tgroup4_title = 0;\n\t\tgroup5_title = 0;\n\t}\n\telse\n\t{\n\t\treturn;\n\t}\n\n\ttotal_count = _r_listview_getitemcount (hwnd, listview_id);\n\n\tfor (INT i = 0; i < total_count; i++)\n\t{\n\t\tif (listview_id == IDC_RULE_APPS_ID || listview_id == IDC_APP_RULES_ID)\n\t\t{\n\t\t\tif (_r_listview_isitemchecked (hwnd, listview_id, i))\n\t\t\t\tgroup1_count = group2_count = group3_count += 1;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tgroup_id = _r_listview_getitemgroup (hwnd, listview_id, i);\n\n\t\t\tif (group_id == 4)\n\t\t\t{\n\t\t\t\tgroup5_count += 1;\n\t\t\t}\n\t\t\telse if (group_id == 3)\n\t\t\t{\n\t\t\t\tgroup4_count += 1;\n\t\t\t}\n\t\t\telse if (group_id == 2)\n\t\t\t{\n\t\t\t\tgroup3_count += 1;\n\t\t\t}\n\t\t\telse if (group_id == 1)\n\t\t\t{\n\t\t\t\tgroup2_count += 1;\n\t\t\t}\n\t\t\telse if (group_id == 0)\n\t\t\t{\n\t\t\t\tgroup1_count += 1;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (total_count)\n\t{\n\t\t// set group titles\n\t\tif (is_rules)\n\t\t{\n\t\t\t_r_str_printf (buffer1, RTL_NUMBER_OF (buffer1), L\"%s (%d/%d) [%s]\", _r_locale_getstring (group1_title), group1_count, total_count, _r_locale_getstring (IDS_RULE_FOR_ALL));\n\t\t\t_r_str_printf (buffer2, RTL_NUMBER_OF (buffer2), L\"%s (%d/%d) [%s]\", _r_locale_getstring (group2_title), group2_count, total_count, _r_locale_getstring (IDS_RULE_FOR_ALL));\n\t\t}\n\t\telse\n\t\t{\n\t\t\t_r_str_printf (buffer1, RTL_NUMBER_OF (buffer1), L\"%s (%d/%d)\", _r_locale_getstring (group1_title), group1_count, total_count);\n\t\t\t_r_str_printf (buffer2, RTL_NUMBER_OF (buffer2), L\"%s (%d/%d)\", _r_locale_getstring (group2_title), group2_count, total_count);\n\t\t}\n\n\t\t_r_listview_setgroup (hwnd, listview_id, 0, buffer1, 0, 0);\n\t\t_r_listview_setgroup (hwnd, listview_id, 1, buffer2, 0, 0);\n\n\t\tif (group3_title)\n\t\t{\n\t\t\t_r_str_printf (buffer1, RTL_NUMBER_OF (buffer1), L\"%s (%d/%d)\", _r_locale_getstring (group3_title), group3_count, total_count);\n\n\t\t\t_r_listview_setgroup (hwnd, listview_id, 2, buffer1, 0, 0);\n\t\t}\n\n\t\tif (group4_title)\n\t\t{\n\t\t\t_r_str_printf (buffer1, RTL_NUMBER_OF (buffer1), L\"%s (%d/%d)\", _r_locale_getstring (group4_title), group4_count, total_count);\n\n\t\t\t_r_listview_setgroup (hwnd, listview_id, 3, buffer1, 0, 0);\n\t\t}\n\n\t\t// set group #5 title\n\t\tif (group5_title)\n\t\t{\n\t\t\t_r_str_printf (buffer1, RTL_NUMBER_OF (buffer1), L\"%s (%d/%d) [silent]\", _r_locale_getstring (group5_title), group5_count, total_count);\n\n\t\t\t_r_listview_setgroup (hwnd, listview_id, 4, buffer1, 0, 0);\n\t\t}\n\t}\n}\n\nVOID _app_listview_resize (\n\t_In_ HWND hwnd,\n\t_In_ INT listview_id,\n\t_In_ BOOLEAN is_forced\n)\n{\n\tPR_STRING string;\n\tHWND hlistview;\n\tHWND header = NULL;\n\tHDC hdc_listview = NULL;\n\tHDC hdc_header = NULL;\n\tLONG column_general_id = 0; // set general column id\n\tLONG calculated_width = 0;\n\tLONG column_count;\n\tLONG column_width;\n\tLONG total_width;\n\tLONG item_count;\n\tLONG text_width;\n\tLONG dpi_value;\n\tLONG max_width;\n\tLONG spacing;\n\tBOOLEAN is_tableview;\n\n\tif (!is_forced && !_r_config_getboolean (L\"AutoSizeColumns\", TRUE, NULL))\n\t\treturn;\n\n\thlistview = GetDlgItem (hwnd, listview_id);\n\n\tif (!hlistview)\n\t\treturn;\n\n\tcolumn_count = _r_listview_getcolumncount (hwnd, listview_id);\n\n\tif (!column_count)\n\t\treturn;\n\n\t// get device context\n\thdc_listview = GetDC (hlistview);\n\n\tif (!hdc_listview)\n\t\tgoto CleanupExit;\n\n\theader = _r_listview_getheader (hwnd, listview_id);\n\n\tif (!header)\n\t\tgoto CleanupExit;\n\n\thdc_header = GetDC (header);\n\n\tif (!hdc_header)\n\t\tgoto CleanupExit;\n\n\t_r_dc_fixfont (hdc_listview, hwnd, listview_id); // fix font set\n\t_r_dc_fixfont (hdc_header, header, 0); // fix font set\n\n\tis_tableview = (_r_listview_getview (hwnd, listview_id) == LV_VIEW_DETAILS);\n\n\tdpi_value = _r_dc_getwindowdpi (hwnd);\n\n\tmax_width = _r_dc_getdpi (158, dpi_value);\n\tspacing = _r_dc_getsystemmetrics (SM_CXSMICON, dpi_value);\n\n\ttotal_width = _r_ctrl_getwidth (hwnd, listview_id);\n\titem_count = _r_listview_getitemcount (hwnd, listview_id);\n\n\tif (listview_id == IDC_LOG)\n\t\tcolumn_general_id = 1;\n\n\tfor (LONG i = 0; i < column_count; i++)\n\t{\n\t\tif (i == column_general_id)\n\t\t\tcontinue;\n\n\t\t// get column text width\n\t\tstring = _r_listview_getcolumntext (hwnd, listview_id, i);\n\n\t\tif (!string)\n\t\t\tcontinue;\n\n\t\tcolumn_width = _r_dc_getfontwidth (hdc_header, &string->sr, NULL) + spacing;\n\n\t\t_r_obj_dereference (string);\n\n\t\tif (column_width >= max_width)\n\t\t{\n\t\t\tcolumn_width = max_width;\n\t\t}\n\t\telse\n\t\t{\n\t\t\t// calculate max width of listview subitems (only for details view)\n\t\t\tif (is_tableview)\n\t\t\t{\n\t\t\t\tfor (INT j = 0; j < item_count; j++)\n\t\t\t\t{\n\t\t\t\t\t// check for number column\n\t\t\t\t\tif ((i == 0) && (listview_id == IDC_LOG))\n\t\t\t\t\t{\n\t\t\t\t\t\ttext_width = _r_dc_getdpi (50, dpi_value);\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tstring = _r_listview_getitemtext (hwnd, listview_id, j, i);\n\n\t\t\t\t\t\tif (!string)\n\t\t\t\t\t\t\tcontinue;\n\n\t\t\t\t\t\ttext_width = _r_dc_getfontwidth (hdc_listview, &string->sr, NULL) + spacing;\n\n\t\t\t\t\t\t_r_obj_dereference (string);\n\t\t\t\t\t}\n\n\t\t\t\t\t// do not continue reaching higher and higher values for performance reason!\n\t\t\t\t\tif (text_width >= max_width)\n\t\t\t\t\t{\n\t\t\t\t\t\tcolumn_width = max_width;\n\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (text_width > column_width)\n\t\t\t\t\t\tcolumn_width = text_width;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t_r_listview_setcolumn (hwnd, listview_id, i, NULL, column_width);\n\n\t\tcalculated_width += column_width;\n\t}\n\n\t// set general column width\n\t_r_listview_setcolumn (hwnd, listview_id, column_general_id, NULL, max (total_width - calculated_width, max_width));\n\nCleanupExit:\n\n\tif (hdc_listview)\n\t\tReleaseDC (hlistview, hdc_listview);\n\n\tif (hdc_header)\n\t\tReleaseDC (header, hdc_header);\n}\n\nVOID _app_listview_setfont (\n\t_In_ HWND hwnd,\n\t_In_ INT listview_id\n)\n{\n\tif (config.hfont)\n\t\t_r_ctrl_setfont (hwnd, listview_id, config.hfont);\n}\n\nVOID _app_listview_setview (\n\t_In_ HWND hwnd,\n\t_In_ INT listview_id\n)\n{\n\tHIMAGELIST himg = NULL;\n\tLONG view_type;\n\tLONG icons_size;\n\tBOOLEAN is_mainview;\n\n\tis_mainview = (listview_id >= IDC_APPS_PROFILE) && (listview_id <= IDC_RULES_CUSTOM);\n\n\tif (is_mainview)\n\t{\n\t\tview_type = _r_calc_clamp (_r_config_getlong (L\"ViewType\", LV_VIEW_DETAILS, NULL), LV_VIEW_ICON, LV_VIEW_MAX);\n\t}\n\telse\n\t{\n\t\tview_type = LV_VIEW_DETAILS;\n\t}\n\n\tif (is_mainview)\n\t{\n\t\ticons_size = _r_calc_clamp (_r_config_getlong (L\"IconSize\", SHIL_SMALL, NULL), SHIL_LARGE, SHIL_LAST);\n\t}\n\telse\n\t{\n\t\ticons_size = SHIL_SMALL;\n\t}\n\n\tif ((listview_id >= IDC_RULES_BLOCKLIST && listview_id <= IDC_RULES_CUSTOM) || listview_id == IDC_APP_RULES_ID)\n\t{\n\t\tif (icons_size == SHIL_SMALL || icons_size == SHIL_SYSSMALL)\n\t\t{\n\t\t\thimg = config.himg_rules_small;\n\t\t}\n\t\telse\n\t\t{\n\t\t\thimg = config.himg_rules_large;\n\t\t}\n\t}\n\telse\n\t{\n\t\t_r_imagelist_getsystem (icons_size, &himg);\n\t}\n\n\tif (himg)\n\t\t_r_listview_setimagelist (hwnd, listview_id, himg);\n\n\t_r_listview_setview (hwnd, listview_id, view_type);\n}\n\nINT CALLBACK _app_listview_compare_callback (\n\t_In_ LPARAM lparam1,\n\t_In_ LPARAM lparam2,\n\t_In_ LPARAM lparam\n)\n{\n\tPR_STRING item_text_1;\n\tPR_STRING item_text_2;\n\tPITEM_LOG ptr_log1;\n\tPITEM_LOG ptr_log2;\n\tWCHAR section_name[128];\n\tHWND hwnd;\n\tLONG64 timestamp1 = 0;\n\tLONG64 timestamp2 = 0;\n\tULONG context1;\n\tULONG context2;\n\tLONG column_id;\n\tINT listview_id;\n\tINT result = 0;\n\tINT item_id1;\n\tINT item_id2;\n\tBOOLEAN is_success1;\n\tBOOLEAN is_success2;\n\tBOOLEAN is_checked1;\n\tBOOLEAN is_checked2;\n\tBOOLEAN is_descend;\n\n\thwnd = GetParent ((HWND)lparam);\n\n\tif (!hwnd)\n\t\treturn 0;\n\n\tlistview_id = GetDlgCtrlID ((HWND)lparam);\n\n\tif (!listview_id)\n\t\treturn 0;\n\n\titem_id1 = (INT)(INT_PTR)lparam1;\n\titem_id2 = (INT)(INT_PTR)lparam2;\n\n\t_r_str_printf (section_name, RTL_NUMBER_OF (section_name), L\"listview\\\\%04\" TEXT (PRIX32), listview_id);\n\n\tcolumn_id = _r_config_getlong (L\"SortColumn\", 0, section_name);\n\tis_descend = _r_config_getboolean (L\"SortIsDescending\", FALSE, section_name);\n\n\tif ((_r_listview_getstyle_ex (hwnd, listview_id) & LVS_EX_CHECKBOXES) != 0)\n\t{\n\t\tis_checked1 = _r_listview_isitemchecked (hwnd, listview_id, item_id1);\n\t\tis_checked2 = _r_listview_isitemchecked (hwnd, listview_id, item_id2);\n\n\t\tif (is_checked1 != is_checked2)\n\t\t{\n\t\t\tif (is_checked1 && !is_checked2)\n\t\t\t{\n\t\t\t\tresult = is_descend ? 1 : -1;\n\t\t\t}\n\t\t\telse if (!is_checked1 && is_checked2)\n\t\t\t{\n\t\t\t\tresult = is_descend ? -1 : 1;\n\t\t\t}\n\t\t}\n\t}\n\n\tcontext1 = (ULONG)_app_listview_getitemcontext (hwnd, listview_id, item_id1);\n\tcontext2 = (ULONG)_app_listview_getitemcontext (hwnd, listview_id, item_id2);\n\n\tif (!result)\n\t{\n\t\t// timestamp sorting\n\t\tif ((listview_id >= IDC_APPS_PROFILE && listview_id <= IDC_APPS_UWP) && column_id == 1)\n\t\t{\n\t\t\tis_success1 = _app_getappinfobyhash (context1, INFO_TIMESTAMP, &timestamp1, sizeof (LONG64));\n\t\t\tis_success2 = _app_getappinfobyhash (context2, INFO_TIMESTAMP, &timestamp2, sizeof (LONG64));\n\n\t\t\tif (is_success1 && is_success2)\n\t\t\t{\n\t\t\t\tif (timestamp1 < timestamp2)\n\t\t\t\t{\n\t\t\t\t\tresult = -1;\n\t\t\t\t}\n\t\t\t\telse if (timestamp1 > timestamp2)\n\t\t\t\t{\n\t\t\t\t\tresult = 1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\telse if (listview_id == IDC_LOG && column_id == 1)\n\t\t{\n\t\t\tptr_log1 = _app_getlogitem (context1);\n\t\t\tptr_log2 = _app_getlogitem (context2);\n\n\t\t\tif (ptr_log1 && ptr_log2)\n\t\t\t{\n\t\t\t\tif (ptr_log1->timestamp < ptr_log2->timestamp)\n\t\t\t\t{\n\t\t\t\t\tresult = -1;\n\t\t\t\t}\n\t\t\t\telse if (ptr_log1->timestamp > ptr_log2->timestamp)\n\t\t\t\t{\n\t\t\t\t\tresult = 1;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (ptr_log1)\n\t\t\t\t_r_obj_dereference (ptr_log1);\n\n\t\t\tif (ptr_log2)\n\t\t\t\t_r_obj_dereference (ptr_log2);\n\t\t}\n\t}\n\n\tif (!result)\n\t{\n\t\titem_text_1 = _r_listview_getitemtext (hwnd, listview_id, item_id1, column_id);\n\t\titem_text_2 = _r_listview_getitemtext (hwnd, listview_id, item_id2, column_id);\n\n\t\tif (item_text_1 && item_text_2)\n\t\t\tresult = _r_str_compare_logical (item_text_1->buffer, item_text_2->buffer);\n\n\t\tif (item_text_1)\n\t\t\t_r_obj_dereference (item_text_1);\n\n\t\tif (item_text_2)\n\t\t\t_r_obj_dereference (item_text_2);\n\t}\n\n\treturn is_descend ? -result : result;\n}\n\nVOID _app_listview_sort (\n\t_In_ HWND hwnd,\n\t_In_ INT listview_id,\n\t_In_ LONG column_id,\n\t_In_ BOOLEAN is_notifycode\n)\n{\n\tWCHAR config_name[128];\n\tHWND hlistview;\n\tINT column_count;\n\tBOOLEAN is_descend;\n\n\thlistview = GetDlgItem (hwnd, listview_id);\n\n\tif (!hlistview)\n\t\treturn;\n\n\tif ((GetWindowLongPtrW (hlistview, GWL_STYLE) & (LVS_NOSORTHEADER | LVS_OWNERDATA)) != 0)\n\t\treturn;\n\n\tcolumn_count = _r_listview_getcolumncount (hwnd, listview_id);\n\n\tif (!column_count)\n\t\treturn;\n\n\t_r_str_printf (config_name, RTL_NUMBER_OF (config_name), L\"listview\\\\%04\" TEXT (PRIX32), listview_id);\n\n\tis_descend = _r_config_getboolean (L\"SortIsDescending\", FALSE, config_name);\n\n\tif (is_notifycode)\n\t\tis_descend = !is_descend;\n\n\tif (column_id == INT_ERROR)\n\t\tcolumn_id = _r_config_getlong (L\"SortColumn\", 0, config_name);\n\n\tcolumn_id = _r_calc_clamp (column_id, 0, column_count - 1); // set range\n\n\tif (is_notifycode)\n\t{\n\t\t_r_config_setboolean (L\"SortIsDescending\", is_descend, config_name);\n\t\t_r_config_setlong (L\"SortColumn\", column_id, config_name);\n\t}\n\n\tfor (INT i = 0; i < column_count; i++)\n\t\t_r_listview_setcolumnsortindex (hwnd, listview_id, i, 0);\n\n\t_r_listview_setcolumnsortindex (hwnd, listview_id, column_id, is_descend ? -1 : 1);\n\n\t_r_listview_sort (hwnd, listview_id, &_app_listview_compare_callback, (WPARAM)hlistview);\n}\n"
  },
  {
    "path": "src/listview.h",
    "content": "// simplewall\n// Copyright (c) 2016-2025 Henry++\n\n#pragma once\n\ntypedef struct _ITEM_LISTVIEW_CONTEXT\n{\n\tULONG_PTR id_code;\n\n\tstruct\n\t{\n\t\tULONG is_hidden : 1;\n\t\tULONG spare_bits : 31;\n\t} DUMMYSTRUCTNAME;\n} ITEM_LISTVIEW_CONTEXT, *PITEM_LISTVIEW_CONTEXT;\n\n#define PR_SETITEM_REDRAW 0x0001\n#define PR_SETITEM_UPDATE 0x0002\n\n#define PR_UPDATE_TYPE 0x0001\n#define PR_UPDATE_FORCE 0x0002\n#define PR_UPDATE_NOREFRESH 0x0004\n#define PR_UPDATE_NOSORT 0x0008\n#define PR_UPDATE_NORESIZE 0x0010\n#define PR_UPDATE_NOREDRAW 0x0020\n#define PR_UPDATE_NOSETVIEW 0x0040\n\n_Ret_maybenull_\nPITEM_TAB_CONTEXT _app_listview_getcontext (\n\t_In_ HWND hwnd,\n\t_In_ INT tab_id\n);\n\n_Success_ (return != 0)\nINT _app_listview_getbytype (\n\t_In_ ENUM_TYPE_DATA type\n);\n\nVOID _app_listview_additems (\n\t_In_ HWND hwnd\n);\n\nVOID _app_listview_clearitems (\n\t_In_ HWND hwnd\n);\n\nVOID _app_listview_addappitem (\n\t_In_ HWND hwnd,\n\t_In_ PITEM_APP ptr_app\n);\n\nVOID _app_listview_addruleitem (\n\t_In_ HWND hwnd,\n\t_In_ PITEM_RULE ptr_rule,\n\t_In_ ULONG_PTR rule_idx,\n\t_In_ BOOLEAN is_forapp\n);\n\nVOID _app_listview_addnetworkitem (\n\t_In_ HWND hwnd,\n\t_In_ ULONG network_hash\n);\n\nVOID _app_listview_addlogitem (\n\t_In_ HWND hwnd,\n\t_In_ PITEM_LOG ptr_log,\n\t_In_ ULONG log_hash\n);\n\nBOOLEAN _app_listview_islocked (\n\t_In_ HWND hwnd,\n\t_In_ INT ctrl_id\n);\n\nVOID _app_listview_lock (\n\t_In_ HWND hwnd,\n\t_In_ INT ctrl_id,\n\t_In_ BOOLEAN is_lock\n);\n\nLONG_PTR _app_listview_createcontext (\n\t_In_ ULONG_PTR id_code\n);\n\nVOID _app_listview_destroycontext (\n\t_In_ PITEM_LISTVIEW_CONTEXT context\n);\n\nULONG_PTR _app_listview_getcontextcode (\n\t_In_ LONG_PTR lparam\n);\n\n_Success_ (return != 0)\nULONG _app_listview_getappcontext (\n\t_In_ HWND hwnd,\n\t_In_ INT listview_id,\n\t_In_ INT item_id\n);\n\nULONG_PTR _app_listview_getitemcontext (\n\t_In_ HWND hwnd,\n\t_In_ INT listview_id,\n\t_In_ INT item_id\n);\n\nBOOLEAN _app_listview_isitemhidden (\n\t_In_ LPARAM lparam\n);\n\n_Success_ (return != INT_ERROR)\nINT _app_listview_finditem (\n\t_In_ HWND hwnd,\n\t_In_ INT listview_id,\n\t_In_ ULONG_PTR id_code\n);\n\nVOID _app_listview_removeitem (\n\t_In_ HWND hwnd,\n\t_In_ ULONG_PTR id_code,\n\t_In_ ENUM_TYPE_DATA type\n);\n\nVOID _app_listview_showitemby_id (\n\t_In_ HWND hwnd,\n\t_In_ INT listview_id,\n\t_In_ INT item_id,\n\t_In_ INT scroll_pos\n);\n\nVOID _app_listview_showitemby_param (\n\t_In_ HWND hwnd,\n\t_In_ ULONG_PTR lparam,\n\t_In_ BOOLEAN is_app\n);\n\nVOID _app_listview_updateby_id (\n\t_In_ HWND hwnd,\n\t_In_ INT lparam,\n\t_In_ ULONG flags\n);\n\nVOID _app_listview_updateby_param (\n\t_In_ HWND hwnd,\n\t_In_ ULONG_PTR lparam,\n\t_In_ ULONG flags,\n\t_In_ BOOLEAN is_app\n);\n\nVOID _app_listview_updateitemby_param (\n\t_In_ HWND hwnd,\n\t_In_ ULONG_PTR lparam,\n\t_In_ BOOLEAN is_app\n);\n\nVOID _app_listview_updateitemby_id (\n\t_In_ HWND hwnd,\n\t_In_ INT listview_id,\n\t_In_ INT item_id\n);\n\nVOID _app_listview_loadfont (\n\t_In_ LONG dpi_value,\n\t_In_ BOOLEAN is_forced\n);\n\nVOID _app_listview_refreshgroups (\n\t_In_ HWND hwnd,\n\t_In_ INT listview_id\n);\n\nVOID _app_listview_resize (\n\t_In_ HWND hwnd,\n\t_In_ INT listview_id,\n\t_In_ BOOLEAN is_forced\n);\n\nVOID _app_listview_setfont (\n\t_In_ HWND hwnd,\n\t_In_ INT listview_id\n);\n\nVOID _app_listview_setview (\n\t_In_ HWND hwnd,\n\t_In_ INT listview_id\n);\n\nINT CALLBACK _app_listview_compare_callback (\n\t_In_ LPARAM lparam1,\n\t_In_ LPARAM lparam2,\n\t_In_ LPARAM lparam\n);\n\nVOID _app_listview_sort (\n\t_In_ HWND hwnd,\n\t_In_ INT listview_id,\n\t_In_ LONG column_id,\n\t_In_ BOOLEAN is_notifycode\n);\n"
  },
  {
    "path": "src/log.c",
    "content": "// simplewall\r\n// Copyright (c) 2016-2026 Henry++\r\n\r\n#include \"global.h\"\r\n\r\nVOID _app_loginit (\r\n\t_In_ BOOLEAN is_install\r\n)\r\n{\r\n\tHANDLE current_handle;\r\n\tHANDLE new_handle;\r\n\tPR_STRING log_path;\r\n\tNTSTATUS status;\r\n\r\n\tcurrent_handle = _InterlockedCompareExchangePointer ((volatile PVOID_PTR)&config.hlogfile, NULL, config.hlogfile);\r\n\r\n\t// reset log handle\r\n\tif (current_handle)\r\n\t\tNtClose (current_handle);\r\n\r\n\tif (!is_install || !_r_config_getboolean (L\"IsLogEnabled\", FALSE, NULL))\r\n\t\treturn; // already closed or not enabled\r\n\r\n\tlog_path = _app_getlogpath ();\r\n\r\n\tif (!log_path)\r\n\t\treturn;\r\n\r\n\tstatus = _r_fs_createfile (\r\n\t\t&log_path->sr,\r\n\t\tFILE_OPEN_IF,\r\n\t\tGENERIC_READ | GENERIC_WRITE,\r\n\t\tFILE_SHARE_READ,\r\n\t\tFILE_ATTRIBUTE_NORMAL,\r\n\t\t0,\r\n\t\tFALSE,\r\n\t\tNULL,\r\n\t\t&new_handle\r\n\t);\r\n\r\n\tif (NT_SUCCESS (status))\r\n\t{\r\n\t\t_app_loginitfile (new_handle);\r\n\r\n\t\tcurrent_handle = _InterlockedCompareExchangePointer ((volatile PVOID_PTR)&config.hlogfile, new_handle, NULL);\r\n\r\n\t\tif (current_handle)\r\n\t\t\tNtClose (new_handle);\r\n\t}\r\n\r\n\t_r_obj_dereference (log_path);\r\n}\r\n\r\nVOID _app_loginitfile (\r\n\t_In_ HANDLE hfile\r\n)\r\n{\r\n\tBYTE bom[] = {0xFF, 0xFE};\r\n\tLARGE_INTEGER file_size;\r\n\r\n\t_r_fs_getsize (NULL, hfile, &file_size);\r\n\r\n\tif (!file_size.QuadPart)\r\n\t{\r\n\t\t// write utf-16 le byte order mask\r\n\t\t_r_fs_writefile (hfile, bom, sizeof (bom));\r\n\r\n\t\t// write csv header\r\n\t\t_r_fs_writefile (hfile, SZ_LOG_TITLE, (ULONG)(_r_str_getlength (SZ_LOG_TITLE) * sizeof (WCHAR)));\r\n\t}\r\n\telse\r\n\t{\r\n\t\t// move to eof\r\n\t\t_r_fs_setpos (hfile, &file_size);\r\n\t}\r\n}\r\n\r\nULONG _app_getloghash (\r\n\t_In_ PITEM_LOG ptr_log\r\n)\r\n{\r\n\tPR_STRING string;\r\n\tULONG log_hash;\r\n\r\n\tstring = _r_format_string (\r\n\t\tL\"%\" TEXT (PRIu8) L\"_%\" TEXT (PR_ULONG) L\"_%\" TEXT (PRIu8) L\"_%\" \\\r\n\t\tTEXT (PRIu8) L\"_%\" TEXT (PRIu16) L\"_%\" TEXT (PRIu16) L\"_%s_%s_IJAHudm4*^(uaokUH_!&%#!\",\r\n\t\tptr_log->af,\r\n\t\tptr_log->app_hash,\r\n\t\tptr_log->protocol,\r\n\t\tptr_log->direction,\r\n\t\tptr_log->local_port,\r\n\t\tptr_log->remote_port,\r\n\t\t_r_obj_getstring (ptr_log->local_addr_str),\r\n\t\t_r_obj_getstring (ptr_log->remote_addr_str)\r\n\t);\r\n\r\n\tlog_hash = _r_str_gethash (&string->sr, TRUE);\r\n\r\n\t_r_obj_dereference (string);\r\n\r\n\treturn log_hash;\r\n}\r\n\r\n_Ret_maybenull_\r\nPR_STRING _app_getlogpath ()\r\n{\r\n\tPR_STRING path;\r\n\r\n\tpath = _r_config_getstringexpand (L\"LogPath\", LOG_PATH_DEFAULT, NULL);\r\n\r\n\treturn path;\r\n}\r\n\r\n_Ret_maybenull_\r\nPR_STRING _app_getlogviewer ()\r\n{\r\n\tR_STRINGREF sr;\r\n\tPR_STRING path;\r\n\r\n\tpath = _r_config_getstringexpand (L\"LogViewer\", LOG_VIEWER_DEFAULT, NULL);\r\n\r\n\tif (!path || !_r_fs_isexists (&path->sr))\r\n\t{\r\n\t\tif (path)\r\n\t\t\t_r_obj_dereference (path);\r\n\r\n\t\t_r_obj_initializestringref (&sr, LOG_VIEWER_DEFAULT);\r\n\r\n\t\t_r_str_environmentexpandstring (NULL, &sr, &path);\r\n\t}\r\n\r\n\treturn path;\r\n}\r\n\r\nBOOLEAN _app_islogfound (\r\n\t_In_ ULONG log_hash\r\n)\r\n{\r\n\tBOOLEAN is_found;\r\n\r\n\t_r_queuedlock_acquireshared (&lock_loglist);\r\n\tis_found = (_r_obj_findhashtable (log_table, log_hash) != NULL);\r\n\t_r_queuedlock_releaseshared (&lock_loglist);\r\n\r\n\treturn is_found;\r\n}\r\n\r\nBOOLEAN _app_logislimitreached (\r\n\t_In_ HANDLE hfile\r\n)\r\n{\r\n\tLONG64 file_size;\r\n\tLONG64 limit;\r\n\r\n\tlimit = _r_config_getlong64 (L\"LogSizeLimitKb\", LOG_SIZE_LIMIT_DEFAULT, NULL);\r\n\r\n\tif (!limit)\r\n\t\treturn FALSE;\r\n\r\n\t_r_fs_getsize2 (NULL, hfile, &file_size);\r\n\r\n\treturn (file_size >= (_r_calc_kilobytes2bytes64 (limit)));\r\n}\r\n\r\nVOID _app_logclear (\r\n\t_In_opt_ HANDLE hfile\r\n)\r\n{\r\n\tPR_STRING log_path;\r\n\r\n\tif (hfile)\r\n\t{\r\n\t\t_r_fs_clearfile (hfile);\r\n\r\n\t\t_app_loginitfile (hfile);\r\n\t}\r\n\r\n\tlog_path = _app_getlogpath ();\r\n\r\n\tif (!log_path)\r\n\t\treturn;\r\n\r\n\t_r_fs_deletefile (&log_path->sr, NULL);\r\n\r\n\t_r_obj_dereference (log_path);\r\n}\r\n\r\nVOID _app_logclear_ui (\r\n\t_In_ HWND hwnd\r\n)\r\n{\r\n\t_InterlockedExchange (&config.log_id, 0);\r\n\r\n\t_r_listview_deleteallitems (hwnd, IDC_LOG);\r\n\r\n\t_app_listview_resize (hwnd, IDC_LOG, FALSE);\r\n\r\n\t_r_queuedlock_acquireexclusive (&lock_loglist);\r\n\t_r_obj_clearhashtable (log_table);\r\n\t_r_queuedlock_releaseexclusive (&lock_loglist);\r\n}\r\n\r\nVOID _app_logwrite (\r\n\t_In_ PITEM_LOG ptr_log\r\n)\r\n{\r\n\tPR_STRING remote_port_string;\r\n\tPR_STRING local_port_string;\r\n\tPR_STRING direction_string;\r\n\tPR_STRING date_string;\r\n\tPR_STRING path = NULL;\r\n\tPR_STRING buffer;\r\n\tPITEM_APP ptr_app;\r\n\tHANDLE current_handle;\r\n\r\n\tcurrent_handle = _InterlockedCompareExchangePointer ((volatile PVOID_PTR)&config.hlogfile, NULL, NULL);\r\n\r\n\tif (!current_handle)\r\n\t\treturn;\r\n\r\n\t// parse path\r\n\tptr_app = _app_getappitem (ptr_log->app_hash);\r\n\r\n\tif (ptr_app)\r\n\t{\r\n\t\tpath = _app_getapppath (ptr_app, _r_config_getboolean (L\"IsShortPath\", TRUE, NULL));\r\n\r\n\t\t_r_obj_dereference (ptr_app);\r\n\t}\r\n\r\n\tdate_string = _r_format_unixtime (ptr_log->timestamp, FDTF_SHORTDATE | FDTF_LONGTIME);\r\n\r\n\tlocal_port_string = _app_formatport (ptr_log->local_port, ptr_log->protocol);\r\n\tremote_port_string = _app_formatport (ptr_log->remote_port, ptr_log->protocol);\r\n\r\n\tdirection_string = _app_db_getdirectionname (ptr_log->direction, ptr_log->is_loopback, FALSE);\r\n\r\n\tbuffer = _r_format_string (\r\n\t\tSZ_LOG_BODY,\r\n\t\t_r_obj_getstringordefault (date_string, _r_locale_getstring (IDS_STATUS_EMPTY)),\r\n\t\t_r_obj_getstringordefault (ptr_log->username, _r_locale_getstring (IDS_STATUS_EMPTY)),\r\n\t\t_r_obj_getstringordefault (path, _r_locale_getstring (IDS_STATUS_EMPTY)),\r\n\t\t_r_obj_getstringordefault (ptr_log->local_addr_str, _r_locale_getstring (IDS_STATUS_EMPTY)),\r\n\t\tlocal_port_string->buffer,\r\n\t\t_r_obj_getstringordefault (ptr_log->remote_addr_str, _r_locale_getstring (IDS_STATUS_EMPTY)),\r\n\t\tremote_port_string->buffer,\r\n\t\t_r_obj_getstringordefault (ptr_log->protocol_str, SZ_DIRECTION_ANY),\r\n\t\t_r_obj_getstringordefault (ptr_log->layer_name, _r_locale_getstring (IDS_STATUS_EMPTY)),\r\n\t\t_r_obj_getstringordefault (ptr_log->filter_name, _r_locale_getstring (IDS_STATUS_EMPTY)),\r\n\t\tptr_log->filter_id,\r\n\t\t_r_obj_getstringordefault (direction_string, _r_locale_getstring (IDS_STATUS_EMPTY)),\r\n\t\t(ptr_log->is_allow ? SZ_STATE_ALLOW : SZ_STATE_BLOCK)\r\n\t);\r\n\r\n\tif (_app_logislimitreached (current_handle))\r\n\t\t_app_logclear (current_handle);\r\n\r\n\t_r_fs_writefile (current_handle, buffer->buffer, (ULONG)buffer->length);\r\n\r\n\tif (date_string)\r\n\t\t_r_obj_dereference (date_string);\r\n\r\n\tif (direction_string)\r\n\t\t_r_obj_dereference (direction_string);\r\n\r\n\tif (path)\r\n\t\t_r_obj_dereference (path);\r\n\r\n\t_r_obj_dereference (local_port_string);\r\n\t_r_obj_dereference (remote_port_string);\r\n\r\n\t_r_obj_dereference (buffer);\r\n}\r\n\r\nVOID _app_logwrite_ui (\r\n\t_In_ HWND hwnd,\r\n\t_In_ PITEM_LOG ptr_log\r\n)\r\n{\r\n\tULONG_PTR table_size;\r\n\tULONG log_hash;\r\n\tULONG hash_code;\r\n\tINT item_id;\r\n\r\n\tlog_hash = _app_getloghash (ptr_log);\r\n\r\n\tif (!log_hash)\r\n\t\treturn;\r\n\r\n\t// log was already in list, so skip it...\r\n\tif (_app_islogfound (log_hash))\r\n\t\treturn;\r\n\r\n\t_r_queuedlock_acquireshared (&lock_loglist);\r\n\ttable_size = _r_obj_gethashtablesize (log_table);\r\n\t_r_queuedlock_releaseshared (&lock_loglist);\r\n\r\n\tif (table_size >= MAP_CACHE_MAX)\r\n\t{\r\n\t\titem_id = _r_listview_getitemcount (hwnd, IDC_LOG) - 1;\r\n\r\n\t\thash_code = (ULONG)_app_listview_getitemcontext (hwnd, IDC_LOG, item_id);\r\n\r\n\t\t_r_listview_deleteitem (hwnd, IDC_LOG, item_id);\r\n\r\n\t\tif (hash_code)\r\n\t\t{\r\n\t\t\t_r_queuedlock_acquireexclusive (&lock_loglist);\r\n\t\t\t_r_obj_removehashtableitem (log_table, hash_code);\r\n\t\t\t_r_queuedlock_releaseexclusive (&lock_loglist);\r\n\t\t}\r\n\t}\r\n\r\n\t_r_queuedlock_acquireexclusive (&lock_loglist);\r\n\t_r_obj_addhashtablepointer (log_table, log_hash, _r_obj_reference (ptr_log));\r\n\t_r_queuedlock_releaseexclusive (&lock_loglist);\r\n\r\n\t_app_listview_addlogitem (hwnd, ptr_log, log_hash);\r\n\r\n\t_app_queue_resolver (hwnd, IDC_LOG, log_hash, ptr_log);\r\n\r\n\t_app_listview_updateby_id (hwnd, IDC_LOG, 0);\r\n}\r\n\r\nVOID _wfp_logsubscribe (\r\n\t_In_opt_ HWND hwnd,\r\n\t_In_ HANDLE engine_handle\r\n)\r\n{\r\n\tstatic R_INITONCE init_once = PR_INITONCE_INIT;\r\n\tstatic FWPMNES4 _FwpmNetEventSubscribe4 = NULL;\r\n\tstatic FWPMNES3 _FwpmNetEventSubscribe3 = NULL;\r\n\tstatic FWPMNES2 _FwpmNetEventSubscribe2 = NULL;\r\n\tstatic FWPMNES1 _FwpmNetEventSubscribe1 = NULL;\r\n\r\n\tFWPM_NET_EVENT_ENUM_TEMPLATE0 enum_template = {0};\r\n\tFWPM_NET_EVENT_SUBSCRIPTION0 subscription = {0};\r\n\tHANDLE new_handle = NULL;\r\n\tHANDLE current_handle;\r\n\tPVOID hfwpuclnt;\r\n\tBOOLEAN is_success = FALSE;\r\n\tNTSTATUS status;\r\n\r\n\tcurrent_handle = _InterlockedCompareExchangePointer ((volatile PVOID_PTR)&config.hnetevent, NULL, NULL);\r\n\r\n\tif (current_handle)\r\n\t\treturn; // already subscribed\r\n\r\n\tif (_r_initonce_begin (&init_once))\r\n\t{\r\n\t\tstatus = _r_sys_loadlibrary2 (L\"fwpuclnt.dll\", 0, &hfwpuclnt);\r\n\r\n\t\tif (NT_SUCCESS (status))\r\n\t\t{\r\n\t\t\t_FwpmNetEventSubscribe4 = _r_sys_getprocaddress (hfwpuclnt, \"FwpmNetEventSubscribe4\", 0);\r\n\t\t\t_FwpmNetEventSubscribe3 = _r_sys_getprocaddress (hfwpuclnt, \"FwpmNetEventSubscribe3\", 0);\r\n\t\t\t_FwpmNetEventSubscribe2 = _r_sys_getprocaddress (hfwpuclnt, \"FwpmNetEventSubscribe2\", 0);\r\n\t\t\t_FwpmNetEventSubscribe1 = _r_sys_getprocaddress (hfwpuclnt, \"FwpmNetEventSubscribe1\", 0);\r\n\r\n\t\t\t_r_sys_freelibrary (hfwpuclnt);\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tif (hwnd)\r\n\t\t\t{\r\n\t\t\t\t_r_show_errormessage (hwnd, L\"Could not load \\\"fwpuclnt.dll\\\" library!\", status, NULL, ET_NATIVE);\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\t_r_log (LOG_LEVEL_WARNING, NULL, L\"_r_sys_loadlibrary\", status, L\"fwpuclnt.dll\");\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t_r_initonce_end (&init_once);\r\n\t}\r\n\r\n\tsubscription.enumTemplate = &enum_template;\r\n\tsubscription.sessionKey = config.session_key;\r\n\r\n\t// win10rs3+\r\n\tif (!is_success && _FwpmNetEventSubscribe4)\r\n\t{\r\n\t\tstatus = _FwpmNetEventSubscribe4 (engine_handle, &subscription, &_wfp_logcallback4, NULL, &new_handle);\r\n\r\n\t\tis_success = (status == STATUS_SUCCESS);\r\n\t}\r\n\r\n\t// win10rs1+\r\n\tif (!is_success && _FwpmNetEventSubscribe3)\r\n\t{\r\n\t\tstatus = _FwpmNetEventSubscribe3 (engine_handle, &subscription, &_wfp_logcallback3, NULL, &new_handle);\r\n\r\n\t\tis_success = (status == STATUS_SUCCESS);\r\n\t}\r\n\r\n\t// win10rs1+\r\n\tif (!is_success && _FwpmNetEventSubscribe2)\r\n\t{\r\n\t\tstatus = _FwpmNetEventSubscribe2 (engine_handle, &subscription, &_wfp_logcallback2, NULL, &new_handle);\r\n\r\n\t\tis_success = (status == STATUS_SUCCESS);\r\n\t}\r\n\r\n\t// win8+\r\n\tif (!is_success && _FwpmNetEventSubscribe1)\r\n\t{\r\n\t\tstatus = _FwpmNetEventSubscribe1 (engine_handle, &subscription, &_wfp_logcallback1, NULL, &new_handle);\r\n\r\n\t\tis_success = (status == STATUS_SUCCESS);\r\n\t}\r\n\r\n\t// win7+\r\n\tif (!is_success)\r\n\t{\r\n\t\tstatus = FwpmNetEventSubscribe0 (engine_handle, &subscription, &_wfp_logcallback0, NULL, &new_handle);\r\n\r\n\t\tis_success = (status == STATUS_SUCCESS);\r\n\t}\r\n\r\n\tif (!is_success)\r\n\t{\r\n\t\tif (hwnd && status != ERROR_PATH_NOT_FOUND)\r\n\t\t{\r\n\t\t\t_r_show_errormessage (hwnd, L\"Log subscribe failed. Try again later!\", status, NULL, ET_WINDOWS);\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\t_r_log (LOG_LEVEL_WARNING, NULL, L\"FwpmNetEventSubscribe\", status, NULL);\r\n\t\t}\r\n\t}\r\n\r\n\t_r_toolbar_enablebutton (config.hrebar, IDC_TOOLBAR, IDM_TRAY_ENABLENOTIFICATIONS_CHK, is_success);\r\n\t_r_toolbar_enablebutton (config.hrebar, IDC_TOOLBAR, IDM_TRAY_ENABLELOG_CHK, is_success);\r\n\t_r_toolbar_enablebutton (config.hrebar, IDC_TOOLBAR, IDM_TRAY_ENABLEUILOG_CHK, is_success);\r\n\r\n\tcurrent_handle = _InterlockedCompareExchangePointer ((volatile PVOID_PTR)&config.hnetevent, new_handle, NULL);\r\n\r\n\tif (current_handle)\r\n\t{\r\n\t\tif (new_handle)\r\n\t\t\tFwpmNetEventUnsubscribe0 (engine_handle, new_handle);\r\n\t}\r\n\r\n\t// initialize log file\r\n\tif (_r_config_getboolean (L\"IsLogEnabled\", FALSE, NULL))\r\n\t\t_app_loginit (TRUE);\r\n}\r\n\r\nVOID _wfp_logunsubscribe (\r\n\t_In_ HANDLE engine_handle\r\n)\r\n{\r\n\tHANDLE current_handle;\r\n\tULONG status;\r\n\r\n\t_app_loginit (FALSE); // destroy log file handle if present\r\n\r\n\tcurrent_handle = _InterlockedCompareExchangePointer ((volatile PVOID_PTR)&config.hnetevent, NULL, config.hnetevent);\r\n\r\n\tif (!current_handle)\r\n\t\treturn;\r\n\r\n\tstatus = FwpmNetEventUnsubscribe0 (engine_handle, current_handle);\r\n\r\n\tif (status != ERROR_SUCCESS)\r\n\t\t_r_log (LOG_LEVEL_WARNING, NULL, L\"FwpmNetEventUnsubscribe\", status, NULL);\r\n}\r\n\r\nVOID _wfp_logsetoption (\r\n\t_In_ HANDLE engine_handle\r\n)\r\n{\r\n\tFWP_VALUE0 val;\r\n\tUINT32 mask = 0;\r\n\tULONG status;\r\n\r\n\t// configure dropped packets logging (win8+)\r\n\tif (!_r_sys_isosversiongreaterorequal (WINDOWS_8))\r\n\t\treturn;\r\n\r\n\t// add allowed connections monitor\r\n\tif (!_r_config_getboolean (L\"IsExcludeClassifyAllow\", TRUE, NULL))\r\n\t\tmask |= FWPM_NET_EVENT_KEYWORD_CLASSIFY_ALLOW;\r\n\r\n\t// add inbound multicast and broadcast connections monitor\r\n\tif (!_r_config_getboolean (L\"IsExcludeInbound\", FALSE, NULL))\r\n\t\tmask |= FWPM_NET_EVENT_KEYWORD_INBOUND_MCAST | FWPM_NET_EVENT_KEYWORD_INBOUND_BCAST;\r\n\r\n\t// add port scanning drop connections monitor (19H1+)\r\n\tif (_r_sys_isosversiongreaterorequal (WINDOWS_10_19H1))\r\n\t{\r\n\t\tif (!_r_config_getboolean (L\"IsExcludePortScanningDrop\", FALSE, NULL))\r\n\t\t\tmask |= FWPM_NET_EVENT_KEYWORD_PORT_SCANNING_DROP;\r\n\t}\r\n\r\n\t// the filter engine will collect wfp network events that match any supplied key words\r\n\tRtlZeroMemory (&val, sizeof (FWP_VALUE0));\r\n\r\n\tval.type = FWP_UINT32;\r\n\tval.uint32 = mask;\r\n\r\n\tstatus = FwpmEngineSetOption0 (engine_handle, FWPM_ENGINE_NET_EVENT_MATCH_ANY_KEYWORDS, &val);\r\n\r\n\tif (status != ERROR_SUCCESS)\r\n\t\t_r_log (LOG_LEVEL_WARNING, NULL, L\"FwpmEngineSetOption0\", status, L\"FWPM_ENGINE_NET_EVENT_MATCH_ANY_KEYWORDS\");\r\n\r\n\t// enables the connection monitoring feature and starts logging creation and deletion events (and notifying any subscribers)\r\n\tRtlZeroMemory (&val, sizeof (FWP_VALUE0));\r\n\r\n\tval.type = FWP_UINT32;\r\n\tval.uint32 = !_r_config_getboolean (L\"IsExcludeIPSecConnections\", FALSE, NULL);\r\n\r\n\tstatus = FwpmEngineSetOption0 (engine_handle, FWPM_ENGINE_MONITOR_IPSEC_CONNECTIONS, &val);\r\n\r\n\tif (status != ERROR_SUCCESS)\r\n\t\t_r_log (LOG_LEVEL_WARNING, NULL, L\"FwpmEngineSetOption0\", status, L\"FWPM_ENGINE_MONITOR_IPSEC_CONNECTIONS\");\r\n}\r\n\r\nVOID CALLBACK _wfp_logcallback (\r\n\t_In_ PITEM_LOG_CALLBACK log\r\n)\r\n{\r\n\tHANDLE engine_handle;\r\n\tPITEM_LOG ptr_log;\r\n\tGUID layer_guid;\r\n\tPR_STRING filter_name = NULL;\r\n\tPR_STRING sid_string = NULL;\r\n\tPR_STRING resolved_path;\r\n\tPR_STRING layer_name;\r\n\tPR_STRING path;\r\n\tFWPM_FILTER0 *filter_ptr;\r\n\tFWPM_LAYER0 *layer_ptr;\r\n\tUINT8 filter_weight = 0;\r\n\tBOOLEAN is_myprovider = FALSE;\r\n\tNTSTATUS status;\r\n\r\n\tif (!log->filter_id || !log->layer_id)\r\n\t\treturn;\r\n\r\n\tif (log->is_allow && _r_config_getboolean (L\"IsExcludeClassifyAllow\", TRUE, NULL))\r\n\t\treturn;\r\n\r\n\tengine_handle = _wfp_getenginehandle ();\r\n\r\n\t// do not parse when tcp connection has been established, or when non-tcp traffic has been authorized\r\n\tif (FwpmLayerGetById0 (engine_handle, log->layer_id, &layer_ptr) != ERROR_SUCCESS || !layer_ptr)\r\n\t\treturn;\r\n\r\n\tif (IsEqualGUID (&layer_ptr->layerKey, &FWPM_LAYER_ALE_FLOW_ESTABLISHED_V4) || IsEqualGUID (&layer_ptr->layerKey, &FWPM_LAYER_ALE_FLOW_ESTABLISHED_V6))\r\n\t{\r\n\t\tFwpmFreeMemory0 ((PVOID_PTR)&layer_ptr);\r\n\r\n\t\treturn;\r\n\t}\r\n\r\n\tif (IsEqualGUID (&layer_ptr->layerKey, &FWPM_LAYER_ALE_AUTH_RECV_ACCEPT_V4) || IsEqualGUID (&layer_ptr->layerKey, &FWPM_LAYER_ALE_AUTH_RECV_ACCEPT_V6))\r\n\t\tlog->direction = FWP_DIRECTION_INBOUND; // HACK!!! (issue #581)\r\n\r\n\tRtlCopyMemory (&layer_guid, &layer_ptr->layerKey, sizeof (GUID));\r\n\r\n\tFwpmFreeMemory0 ((PVOID_PTR)&layer_ptr);\r\n\r\n\t// get filter information\r\n\tif (FwpmFilterGetById0 (engine_handle, log->filter_id, &filter_ptr) != ERROR_SUCCESS || !filter_ptr)\r\n\t\treturn;\r\n\r\n\tlayer_name = _wfp_getlayername (&layer_guid);\r\n\r\n\tif (!_r_str_isempty (filter_ptr->displayData.description))\r\n\t{\r\n\t\tfilter_name = _r_obj_createstring (filter_ptr->displayData.description);\r\n\t}\r\n\telse if (!_r_str_isempty (filter_ptr->displayData.name))\r\n\t{\r\n\t\tfilter_name = _r_obj_createstring (filter_ptr->displayData.name);\r\n\t}\r\n\r\n\tif (filter_ptr->weight.type == FWP_UINT8)\r\n\t\tfilter_weight = filter_ptr->weight.uint8;\r\n\r\n\tif (filter_ptr->providerKey)\r\n\t{\r\n\t\tif (IsEqualGUID (filter_ptr->providerKey, &GUID_WfpProvider))\r\n\t\t\tis_myprovider = TRUE;\r\n\t}\r\n\r\n\tFwpmFreeMemory0 ((PVOID_PTR)&filter_ptr);\r\n\r\n\t// allocate log object\r\n\tptr_log = _r_obj_allocate (sizeof (ITEM_LOG), &_app_dereferencelog);\r\n\r\n\t// copy date and time\r\n\tptr_log->timestamp = _r_unixtime_from_filetime (&log->timestamp);\r\n\r\n\t// check token for null (not an appcontainer) (HACK!!!)\r\n\tif ((log->flags & FWPM_NET_EVENT_FLAG_PACKAGE_ID_SET) == FWPM_NET_EVENT_FLAG_PACKAGE_ID_SET && log->package_id)\r\n\t{\r\n\t\tif (RtlEqualSid (log->package_id, &SeNobodySid))\r\n\t\t{\r\n\t\t\tlog->flags &= ~(FWPM_NET_EVENT_FLAG_PACKAGE_ID_SET);\r\n\t\t\tlog->package_id = NULL;\r\n\t\t}\r\n\t}\r\n\r\n\t// get package id (win8+)\r\n\tif ((log->flags & FWPM_NET_EVENT_FLAG_PACKAGE_ID_SET) == FWPM_NET_EVENT_FLAG_PACKAGE_ID_SET && log->package_id)\r\n\t{\r\n\t\tstatus = _r_str_fromsid (log->package_id, &sid_string);\r\n\r\n\t\tif (NT_SUCCESS (status))\r\n\t\t{\r\n\t\t\tif (!_app_package_isnotexists (sid_string))\r\n\t\t\t\t_r_obj_clearreference ((PVOID_PTR)&sid_string);\r\n\t\t}\r\n\t}\r\n\r\n\t// copy converted nt device path into win32\r\n\tif ((log->flags & FWPM_NET_EVENT_FLAG_PACKAGE_ID_SET) == FWPM_NET_EVENT_FLAG_PACKAGE_ID_SET && sid_string)\r\n\t{\r\n\t\t_r_obj_swapreference ((PVOID_PTR)&ptr_log->path, sid_string);\r\n\r\n\t\tptr_log->app_hash = _r_str_gethash (&ptr_log->path->sr, TRUE);\r\n\t}\r\n\telse if ((log->flags & FWPM_NET_EVENT_FLAG_APP_ID_SET) == FWPM_NET_EVENT_FLAG_APP_ID_SET && log->app_id)\r\n\t{\r\n\t\tpath = _r_obj_createstring ((LPCWSTR)(log->app_id));\r\n\r\n\t\tresolved_path = _r_path_dospathfromnt (&path->sr);\r\n\r\n\t\tif (resolved_path)\r\n\t\t\t_r_obj_movereference ((PVOID_PTR)&path, resolved_path);\r\n\r\n\t\tif (path)\r\n\t\t{\r\n\t\t\t_r_obj_movereference ((PVOID_PTR)&ptr_log->path, path);\r\n\r\n\t\t\tptr_log->app_hash = _r_str_gethash (&ptr_log->path->sr, TRUE);\r\n\t\t}\r\n\t}\r\n\telse\r\n\t{\r\n\t\tptr_log->app_hash = 0;\r\n\t}\r\n\r\n\t// get username information\r\n\tif ((log->flags & FWPM_NET_EVENT_FLAG_USER_ID_SET) == FWPM_NET_EVENT_FLAG_USER_ID_SET && log->user_id)\r\n\t\t_r_sys_getusername (log->user_id, TRUE, &ptr_log->username);\r\n\r\n\t// destination\r\n\tif ((log->flags & FWPM_NET_EVENT_FLAG_IP_VERSION_SET) == FWPM_NET_EVENT_FLAG_IP_VERSION_SET)\r\n\t{\r\n\t\tif (log->version == FWP_IP_VERSION_V4)\r\n\t\t{\r\n\t\t\tptr_log->af = AF_INET;\r\n\r\n\t\t\t// local address\r\n\t\t\tif ((log->flags & FWPM_NET_EVENT_FLAG_LOCAL_ADDR_SET) == FWPM_NET_EVENT_FLAG_LOCAL_ADDR_SET)\r\n\t\t\t\tptr_log->local_addr.S_un.S_addr = _r_byteswap_ulong ((ULONG)log->local_addr4);\r\n\r\n\t\t\t// remote address\r\n\t\t\tif ((log->flags & FWPM_NET_EVENT_FLAG_REMOTE_ADDR_SET) == FWPM_NET_EVENT_FLAG_REMOTE_ADDR_SET)\r\n\t\t\t\tptr_log->remote_addr.S_un.S_addr = _r_byteswap_ulong ((ULONG)log->remote_addr4);\r\n\r\n\t\t}\r\n\t\telse if (log->version == FWP_IP_VERSION_V6)\r\n\t\t{\r\n\t\t\tptr_log->af = AF_INET6;\r\n\r\n\t\t\t// remote address\r\n\t\t\tif ((log->flags & FWPM_NET_EVENT_FLAG_REMOTE_ADDR_SET) == FWPM_NET_EVENT_FLAG_REMOTE_ADDR_SET && log->remote_addr6)\r\n\t\t\t\tRtlCopyMemory (ptr_log->remote_addr6.u.Byte, log->remote_addr6->byteArray16, FWP_V6_ADDR_SIZE);\r\n\r\n\t\t\t// local address\r\n\t\t\tif ((log->flags & FWPM_NET_EVENT_FLAG_LOCAL_ADDR_SET) == FWPM_NET_EVENT_FLAG_LOCAL_ADDR_SET && log->local_addr6)\r\n\t\t\t\tRtlCopyMemory (ptr_log->local_addr6.u.Byte, log->local_addr6->byteArray16, FWP_V6_ADDR_SIZE);\r\n\t\t}\r\n\t}\r\n\r\n\t// ports\r\n\tif ((log->flags & FWPM_NET_EVENT_FLAG_LOCAL_PORT_SET) == FWPM_NET_EVENT_FLAG_LOCAL_PORT_SET)\r\n\t\tptr_log->local_port = log->local_port;\r\n\r\n\tif ((log->flags & FWPM_NET_EVENT_FLAG_REMOTE_PORT_SET) == FWPM_NET_EVENT_FLAG_REMOTE_PORT_SET)\r\n\t\tptr_log->remote_port = log->remote_port;\r\n\r\n\t// protocol\r\n\tif ((log->flags & FWPM_NET_EVENT_FLAG_IP_PROTOCOL_SET) == FWPM_NET_EVENT_FLAG_IP_PROTOCOL_SET)\r\n\t{\r\n\t\tptr_log->protocol = log->protocol;\r\n\r\n\t\tptr_log->protocol_str = _r_obj_createstring (_app_db_getprotoname (ptr_log->protocol, ptr_log->af));\r\n\t}\r\n\r\n\t// indicates FWPM_NET_EVENT_TYPE_CLASSIFY_ALLOW state\r\n\tptr_log->is_allow = log->is_allow;\r\n\r\n\t// indicates whether the packet originated from (or was heading to) the loopback adapter\r\n\tptr_log->is_loopback = log->is_loopback;\r\n\r\n\t// set filter information\r\n\tptr_log->filter_id = log->filter_id;\r\n\tptr_log->direction = log->direction;\r\n\r\n\tptr_log->is_myprovider = is_myprovider;\r\n\r\n\tptr_log->filter_name = filter_name;\r\n\tptr_log->layer_name = layer_name;\r\n\r\n\tptr_log->is_blocklist = (filter_weight == FW_WEIGHT_RULE_BLOCKLIST);\r\n\tptr_log->is_system = (filter_weight == FW_WEIGHT_HIGHEST) || (filter_weight == FW_WEIGHT_HIGHEST_IMPORTANT);\r\n\tptr_log->is_custom = (filter_weight == FW_WEIGHT_RULE_USER) || (filter_weight == FW_WEIGHT_RULE_USER_BLOCK);\r\n\r\n\t_r_workqueue_queueitem (&log_queue, &_app_logthread, ptr_log);\r\n\r\n\tif (sid_string)\r\n\t\t_r_obj_dereference (sid_string);\r\n}\r\n\r\nFORCEINLINE BOOLEAN log_struct_to_f (\r\n\t_Out_ PITEM_LOG_CALLBACK log,\r\n\t_In_ ULONG version,\r\n\t_In_ LPCVOID event_data\r\n)\r\n{\r\n\tRtlSecureZeroMemory (log, sizeof (ITEM_LOG_CALLBACK));\r\n\r\n\tswitch (version)\r\n\t{\r\n\t\tcase WINDOWS_10_RS3:\r\n\t\t{\r\n\t\t\tconst FWPM_NET_EVENT5 *evt = event_data;\r\n\r\n\t\t\tif (evt->type == FWPM_NET_EVENT_TYPE_CLASSIFY_DROP && evt->classifyDrop)\r\n\t\t\t{\r\n\t\t\t\tlog->layer_id = evt->classifyDrop->layerId;\r\n\t\t\t\tlog->filter_id = evt->classifyDrop->filterId;\r\n\t\t\t\tlog->direction = evt->classifyDrop->msFwpDirection;\r\n\t\t\t\tlog->is_loopback = !!evt->classifyDrop->isLoopback;\r\n\t\t\t}\r\n\t\t\telse if (evt->type == FWPM_NET_EVENT_TYPE_IPSEC_KERNEL_DROP && evt->ipsecDrop)\r\n\t\t\t{\r\n\t\t\t\tlog->layer_id = evt->ipsecDrop->layerId;\r\n\t\t\t\tlog->filter_id = evt->ipsecDrop->filterId;\r\n\t\t\t\tlog->direction = evt->ipsecDrop->direction;\r\n\t\t\t}\r\n\t\t\telse if (evt->type == FWPM_NET_EVENT_TYPE_CLASSIFY_ALLOW && evt->classifyAllow)\r\n\t\t\t{\r\n\t\t\t\tlog->layer_id = evt->classifyAllow->layerId;\r\n\t\t\t\tlog->filter_id = evt->classifyAllow->filterId;\r\n\t\t\t\tlog->direction = evt->classifyAllow->msFwpDirection;\r\n\t\t\t\tlog->is_loopback = !!evt->classifyAllow->isLoopback;\r\n\r\n\t\t\t\tlog->is_allow = TRUE;\r\n\t\t\t}\r\n\t\t\telse if (evt->type == FWPM_NET_EVENT_TYPE_CLASSIFY_DROP_MAC && evt->classifyDropMac)\r\n\t\t\t{\r\n\t\t\t\tlog->layer_id = evt->classifyDropMac->layerId;\r\n\t\t\t\tlog->filter_id = evt->classifyDropMac->filterId;\r\n\t\t\t\tlog->direction = evt->classifyDropMac->msFwpDirection;\r\n\t\t\t\tlog->is_loopback = !!evt->classifyDropMac->isLoopback;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\treturn FALSE;\r\n\t\t\t}\r\n\r\n\t\t\t// indicates the direction of the packet transmission and set valid directions\r\n\t\t\tswitch (log->direction)\r\n\t\t\t{\r\n\t\t\t\tcase FWP_DIRECTION_IN:\r\n\t\t\t\tcase FWP_DIRECTION_INBOUND:\r\n\t\t\t\t{\r\n\t\t\t\t\tlog->direction = FWP_DIRECTION_INBOUND;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tcase FWP_DIRECTION_OUT:\r\n\t\t\t\tcase FWP_DIRECTION_OUTBOUND:\r\n\t\t\t\t{\r\n\t\t\t\t\tlog->direction = FWP_DIRECTION_OUTBOUND;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tdefault:\r\n\t\t\t\t{\r\n\t\t\t\t\treturn FALSE;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tlog->flags = evt->header.flags;\r\n\r\n\t\t\tRtlCopyMemory (&log->timestamp, &evt->header.timeStamp, sizeof (FILETIME));\r\n\r\n\t\t\tif ((evt->header.flags & FWPM_NET_EVENT_FLAG_APP_ID_SET) == FWPM_NET_EVENT_FLAG_APP_ID_SET)\r\n\t\t\t\tlog->app_id = evt->header.appId.data;\r\n\r\n\t\t\tif ((evt->header.flags & FWPM_NET_EVENT_FLAG_PACKAGE_ID_SET) == FWPM_NET_EVENT_FLAG_PACKAGE_ID_SET)\r\n\t\t\t\tlog->package_id = evt->header.packageSid;\r\n\r\n\t\t\tif ((evt->header.flags & FWPM_NET_EVENT_FLAG_USER_ID_SET) == FWPM_NET_EVENT_FLAG_USER_ID_SET)\r\n\t\t\t\tlog->user_id = evt->header.userId;\r\n\r\n\t\t\tif ((evt->header.flags & FWPM_NET_EVENT_FLAG_IP_PROTOCOL_SET) == FWPM_NET_EVENT_FLAG_IP_PROTOCOL_SET)\r\n\t\t\t\tlog->protocol = evt->header.ipProtocol;\r\n\r\n\t\t\tif ((evt->header.flags & FWPM_NET_EVENT_FLAG_LOCAL_PORT_SET) == FWPM_NET_EVENT_FLAG_LOCAL_PORT_SET)\r\n\t\t\t\tlog->local_port = evt->header.localPort;\r\n\r\n\t\t\tif ((evt->header.flags & FWPM_NET_EVENT_FLAG_REMOTE_PORT_SET) == FWPM_NET_EVENT_FLAG_REMOTE_PORT_SET)\r\n\t\t\t\tlog->remote_port = evt->header.remotePort;\r\n\r\n\t\t\tif ((evt->header.flags & FWPM_NET_EVENT_FLAG_IP_VERSION_SET) == FWPM_NET_EVENT_FLAG_IP_VERSION_SET)\r\n\t\t\t{\r\n\t\t\t\tlog->version = evt->header.ipVersion;\r\n\r\n\t\t\t\tif (evt->header.ipVersion == FWP_IP_VERSION_V4)\r\n\t\t\t\t{\r\n\t\t\t\t\tif ((evt->header.flags & FWPM_NET_EVENT_FLAG_LOCAL_ADDR_SET) == FWPM_NET_EVENT_FLAG_LOCAL_ADDR_SET)\r\n\t\t\t\t\t\tlog->local_addr4 = evt->header.localAddrV4;\r\n\r\n\t\t\t\t\tif ((evt->header.flags & FWPM_NET_EVENT_FLAG_REMOTE_ADDR_SET) == FWPM_NET_EVENT_FLAG_REMOTE_ADDR_SET)\r\n\t\t\t\t\t\tlog->remote_addr4 = evt->header.remoteAddrV4;\r\n\t\t\t\t}\r\n\t\t\t\telse if (evt->header.ipVersion == FWP_IP_VERSION_V6)\r\n\t\t\t\t{\r\n\t\t\t\t\tif ((evt->header.flags & FWPM_NET_EVENT_FLAG_LOCAL_ADDR_SET) == FWPM_NET_EVENT_FLAG_LOCAL_ADDR_SET)\r\n\t\t\t\t\t\tlog->local_addr6 = &evt->header.localAddrV6;\r\n\r\n\t\t\t\t\tif ((evt->header.flags & FWPM_NET_EVENT_FLAG_REMOTE_ADDR_SET) == FWPM_NET_EVENT_FLAG_REMOTE_ADDR_SET)\r\n\t\t\t\t\t\tlog->remote_addr6 = &evt->header.remoteAddrV6;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tlog->version = FWP_IP_VERSION_NONE;\r\n\t\t\t}\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase WINDOWS_10_RS1:\r\n\t\t{\r\n\t\t\tconst FWPM_NET_EVENT4 *evt = (const FWPM_NET_EVENT4*)event_data;\r\n\r\n\t\t\tif (evt->type == FWPM_NET_EVENT_TYPE_CLASSIFY_DROP && evt->classifyDrop)\r\n\t\t\t{\r\n\t\t\t\tlog->layer_id = evt->classifyDrop->layerId;\r\n\t\t\t\tlog->filter_id = evt->classifyDrop->filterId;\r\n\t\t\t\tlog->direction = evt->classifyDrop->msFwpDirection;\r\n\t\t\t\tlog->is_loopback = !!evt->classifyDrop->isLoopback;\r\n\t\t\t}\r\n\t\t\telse if (evt->type == FWPM_NET_EVENT_TYPE_IPSEC_KERNEL_DROP && evt->ipsecDrop)\r\n\t\t\t{\r\n\t\t\t\tlog->layer_id = evt->ipsecDrop->layerId;\r\n\t\t\t\tlog->filter_id = evt->ipsecDrop->filterId;\r\n\t\t\t\tlog->direction = evt->ipsecDrop->direction;\r\n\t\t\t}\r\n\t\t\telse if (evt->type == FWPM_NET_EVENT_TYPE_CLASSIFY_ALLOW && evt->classifyAllow)\r\n\t\t\t{\r\n\t\t\t\tlog->layer_id = evt->classifyAllow->layerId;\r\n\t\t\t\tlog->filter_id = evt->classifyAllow->filterId;\r\n\t\t\t\tlog->direction = evt->classifyAllow->msFwpDirection;\r\n\t\t\t\tlog->is_loopback = !!evt->classifyAllow->isLoopback;\r\n\r\n\t\t\t\tlog->is_allow = TRUE;\r\n\t\t\t}\r\n\t\t\telse if (evt->type == FWPM_NET_EVENT_TYPE_CLASSIFY_DROP_MAC && evt->classifyDropMac)\r\n\t\t\t{\r\n\t\t\t\tlog->layer_id = evt->classifyDropMac->layerId;\r\n\t\t\t\tlog->filter_id = evt->classifyDropMac->filterId;\r\n\t\t\t\tlog->direction = evt->classifyDropMac->msFwpDirection;\r\n\t\t\t\tlog->is_loopback = !!evt->classifyDropMac->isLoopback;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\treturn FALSE;\r\n\t\t\t}\r\n\r\n\t\t\t// indicates the direction of the packet transmission and set valid directions\r\n\t\t\tswitch (log->direction)\r\n\t\t\t{\r\n\t\t\t\tcase FWP_DIRECTION_IN:\r\n\t\t\t\tcase FWP_DIRECTION_INBOUND:\r\n\t\t\t\t{\r\n\t\t\t\t\tlog->direction = FWP_DIRECTION_INBOUND;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tcase FWP_DIRECTION_OUT:\r\n\t\t\t\tcase FWP_DIRECTION_OUTBOUND:\r\n\t\t\t\t{\r\n\t\t\t\t\tlog->direction = FWP_DIRECTION_OUTBOUND;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tdefault:\r\n\t\t\t\t{\r\n\t\t\t\t\treturn FALSE;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tlog->flags = evt->header.flags;\r\n\r\n\t\t\tRtlCopyMemory (&log->timestamp, &evt->header.timeStamp, sizeof (FILETIME));\r\n\r\n\t\t\tif ((evt->header.flags & FWPM_NET_EVENT_FLAG_APP_ID_SET) == FWPM_NET_EVENT_FLAG_APP_ID_SET)\r\n\t\t\t\tlog->app_id = evt->header.appId.data;\r\n\r\n\t\t\tif ((evt->header.flags & FWPM_NET_EVENT_FLAG_PACKAGE_ID_SET) == FWPM_NET_EVENT_FLAG_PACKAGE_ID_SET)\r\n\t\t\t\tlog->package_id = evt->header.packageSid;\r\n\r\n\t\t\tif ((evt->header.flags & FWPM_NET_EVENT_FLAG_USER_ID_SET) == FWPM_NET_EVENT_FLAG_USER_ID_SET)\r\n\t\t\t\tlog->user_id = evt->header.userId;\r\n\r\n\t\t\tif ((evt->header.flags & FWPM_NET_EVENT_FLAG_IP_PROTOCOL_SET) == FWPM_NET_EVENT_FLAG_IP_PROTOCOL_SET)\r\n\t\t\t\tlog->protocol = evt->header.ipProtocol;\r\n\r\n\t\t\tif ((evt->header.flags & FWPM_NET_EVENT_FLAG_LOCAL_PORT_SET) == FWPM_NET_EVENT_FLAG_LOCAL_PORT_SET)\r\n\t\t\t\tlog->local_port = evt->header.localPort;\r\n\r\n\t\t\tif ((evt->header.flags & FWPM_NET_EVENT_FLAG_REMOTE_PORT_SET) == FWPM_NET_EVENT_FLAG_REMOTE_PORT_SET)\r\n\t\t\t\tlog->remote_port = evt->header.remotePort;\r\n\r\n\t\t\tif ((evt->header.flags & FWPM_NET_EVENT_FLAG_IP_VERSION_SET) == FWPM_NET_EVENT_FLAG_IP_VERSION_SET)\r\n\t\t\t{\r\n\t\t\t\tlog->version = evt->header.ipVersion;\r\n\r\n\t\t\t\tif (evt->header.ipVersion == FWP_IP_VERSION_V4)\r\n\t\t\t\t{\r\n\t\t\t\t\tif ((evt->header.flags & FWPM_NET_EVENT_FLAG_LOCAL_ADDR_SET) == FWPM_NET_EVENT_FLAG_LOCAL_ADDR_SET)\r\n\t\t\t\t\t\tlog->local_addr4 = evt->header.localAddrV4;\r\n\r\n\t\t\t\t\tif ((evt->header.flags & FWPM_NET_EVENT_FLAG_REMOTE_ADDR_SET) == FWPM_NET_EVENT_FLAG_REMOTE_ADDR_SET)\r\n\t\t\t\t\t\tlog->remote_addr4 = evt->header.remoteAddrV4;\r\n\t\t\t\t}\r\n\t\t\t\telse if (evt->header.ipVersion == FWP_IP_VERSION_V6)\r\n\t\t\t\t{\r\n\t\t\t\t\tif ((evt->header.flags & FWPM_NET_EVENT_FLAG_LOCAL_ADDR_SET) == FWPM_NET_EVENT_FLAG_LOCAL_ADDR_SET)\r\n\t\t\t\t\t\tlog->local_addr6 = &evt->header.localAddrV6;\r\n\r\n\t\t\t\t\tif ((evt->header.flags & FWPM_NET_EVENT_FLAG_REMOTE_ADDR_SET) == FWPM_NET_EVENT_FLAG_REMOTE_ADDR_SET)\r\n\t\t\t\t\t\tlog->remote_addr6 = &evt->header.remoteAddrV6;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tlog->version = FWP_IP_VERSION_NONE;\r\n\t\t\t}\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase WINDOWS_10_RS2:\r\n\t\t{\r\n\t\t\tconst FWPM_NET_EVENT3 *evt = event_data;\r\n\r\n\t\t\tif (evt->type == FWPM_NET_EVENT_TYPE_CLASSIFY_DROP && evt->classifyDrop)\r\n\t\t\t{\r\n\t\t\t\tlog->layer_id = evt->classifyDrop->layerId;\r\n\t\t\t\tlog->filter_id = evt->classifyDrop->filterId;\r\n\t\t\t\tlog->direction = evt->classifyDrop->msFwpDirection;\r\n\t\t\t\tlog->is_loopback = !!evt->classifyDrop->isLoopback;\r\n\t\t\t}\r\n\t\t\telse if (evt->type == FWPM_NET_EVENT_TYPE_IPSEC_KERNEL_DROP && evt->ipsecDrop)\r\n\t\t\t{\r\n\t\t\t\tlog->layer_id = evt->ipsecDrop->layerId;\r\n\t\t\t\tlog->filter_id = evt->ipsecDrop->filterId;\r\n\t\t\t\tlog->direction = evt->ipsecDrop->direction;\r\n\t\t\t}\r\n\t\t\telse if (evt->type == FWPM_NET_EVENT_TYPE_CLASSIFY_ALLOW && evt->classifyAllow)\r\n\t\t\t{\r\n\t\t\t\tlog->layer_id = evt->classifyAllow->layerId;\r\n\t\t\t\tlog->filter_id = evt->classifyAllow->filterId;\r\n\t\t\t\tlog->direction = evt->classifyAllow->msFwpDirection;\r\n\t\t\t\tlog->is_loopback = !!evt->classifyAllow->isLoopback;\r\n\r\n\t\t\t\tlog->is_allow = TRUE;\r\n\t\t\t}\r\n\t\t\telse if (evt->type == FWPM_NET_EVENT_TYPE_CLASSIFY_DROP_MAC && evt->classifyDropMac)\r\n\t\t\t{\r\n\t\t\t\tlog->layer_id = evt->classifyDropMac->layerId;\r\n\t\t\t\tlog->filter_id = evt->classifyDropMac->filterId;\r\n\t\t\t\tlog->direction = evt->classifyDropMac->msFwpDirection;\r\n\t\t\t\tlog->is_loopback = !!evt->classifyDropMac->isLoopback;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\treturn FALSE;\r\n\t\t\t}\r\n\r\n\t\t\t// indicates the direction of the packet transmission and set valid directions\r\n\t\t\tswitch (log->direction)\r\n\t\t\t{\r\n\t\t\t\tcase FWP_DIRECTION_IN:\r\n\t\t\t\tcase FWP_DIRECTION_INBOUND:\r\n\t\t\t\t{\r\n\t\t\t\t\tlog->direction = FWP_DIRECTION_INBOUND;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tcase FWP_DIRECTION_OUT:\r\n\t\t\t\tcase FWP_DIRECTION_OUTBOUND:\r\n\t\t\t\t{\r\n\t\t\t\t\tlog->direction = FWP_DIRECTION_OUTBOUND;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tdefault:\r\n\t\t\t\t{\r\n\t\t\t\t\treturn FALSE;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tlog->flags = evt->header.flags;\r\n\r\n\t\t\tRtlCopyMemory (&log->timestamp, &evt->header.timeStamp, sizeof (FILETIME));\r\n\r\n\t\t\tif ((evt->header.flags & FWPM_NET_EVENT_FLAG_APP_ID_SET) == FWPM_NET_EVENT_FLAG_APP_ID_SET)\r\n\t\t\t\tlog->app_id = evt->header.appId.data;\r\n\r\n\t\t\tif ((evt->header.flags & FWPM_NET_EVENT_FLAG_PACKAGE_ID_SET) == FWPM_NET_EVENT_FLAG_PACKAGE_ID_SET)\r\n\t\t\t\tlog->package_id = evt->header.packageSid;\r\n\r\n\t\t\tif ((evt->header.flags & FWPM_NET_EVENT_FLAG_USER_ID_SET) == FWPM_NET_EVENT_FLAG_USER_ID_SET)\r\n\t\t\t\tlog->user_id = evt->header.userId;\r\n\r\n\t\t\tif ((evt->header.flags & FWPM_NET_EVENT_FLAG_IP_PROTOCOL_SET) == FWPM_NET_EVENT_FLAG_IP_PROTOCOL_SET)\r\n\t\t\t\tlog->protocol = evt->header.ipProtocol;\r\n\r\n\t\t\tif ((evt->header.flags & FWPM_NET_EVENT_FLAG_LOCAL_PORT_SET) == FWPM_NET_EVENT_FLAG_LOCAL_PORT_SET)\r\n\t\t\t\tlog->local_port = evt->header.localPort;\r\n\r\n\t\t\tif ((evt->header.flags & FWPM_NET_EVENT_FLAG_REMOTE_PORT_SET) == FWPM_NET_EVENT_FLAG_REMOTE_PORT_SET)\r\n\t\t\t\tlog->remote_port = evt->header.remotePort;\r\n\r\n\t\t\tif ((evt->header.flags & FWPM_NET_EVENT_FLAG_IP_VERSION_SET) == FWPM_NET_EVENT_FLAG_IP_VERSION_SET)\r\n\t\t\t{\r\n\t\t\t\tlog->version = evt->header.ipVersion;\r\n\r\n\t\t\t\tif (evt->header.ipVersion == FWP_IP_VERSION_V4)\r\n\t\t\t\t{\r\n\t\t\t\t\tif ((evt->header.flags & FWPM_NET_EVENT_FLAG_LOCAL_ADDR_SET) == FWPM_NET_EVENT_FLAG_LOCAL_ADDR_SET)\r\n\t\t\t\t\t\tlog->local_addr4 = evt->header.localAddrV4;\r\n\r\n\t\t\t\t\tif ((evt->header.flags & FWPM_NET_EVENT_FLAG_REMOTE_ADDR_SET) == FWPM_NET_EVENT_FLAG_REMOTE_ADDR_SET)\r\n\t\t\t\t\t\tlog->remote_addr4 = evt->header.remoteAddrV4;\r\n\t\t\t\t}\r\n\t\t\t\telse if (evt->header.ipVersion == FWP_IP_VERSION_V6)\r\n\t\t\t\t{\r\n\t\t\t\t\tif ((evt->header.flags & FWPM_NET_EVENT_FLAG_LOCAL_ADDR_SET) == FWPM_NET_EVENT_FLAG_LOCAL_ADDR_SET)\r\n\t\t\t\t\t\tlog->local_addr6 = &evt->header.localAddrV6;\r\n\r\n\t\t\t\t\tif ((evt->header.flags & FWPM_NET_EVENT_FLAG_REMOTE_ADDR_SET) == FWPM_NET_EVENT_FLAG_REMOTE_ADDR_SET)\r\n\t\t\t\t\t\tlog->remote_addr6 = &evt->header.remoteAddrV6;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tlog->version = FWP_IP_VERSION_NONE;\r\n\t\t\t}\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase WINDOWS_8:\r\n\t\t{\r\n\t\t\tconst FWPM_NET_EVENT2 *evt = event_data;\r\n\r\n\t\t\tif (evt->type == FWPM_NET_EVENT_TYPE_CLASSIFY_DROP && evt->classifyDrop)\r\n\t\t\t{\r\n\t\t\t\tlog->layer_id = evt->classifyDrop->layerId;\r\n\t\t\t\tlog->filter_id = evt->classifyDrop->filterId;\r\n\t\t\t\tlog->direction = evt->classifyDrop->msFwpDirection;\r\n\t\t\t\tlog->is_loopback = !!evt->classifyDrop->isLoopback;\r\n\t\t\t}\r\n\t\t\telse if (evt->type == FWPM_NET_EVENT_TYPE_IPSEC_KERNEL_DROP && evt->ipsecDrop)\r\n\t\t\t{\r\n\t\t\t\tlog->layer_id = evt->ipsecDrop->layerId;\r\n\t\t\t\tlog->filter_id = evt->ipsecDrop->filterId;\r\n\t\t\t\tlog->direction = evt->ipsecDrop->direction;\r\n\t\t\t}\r\n\t\t\telse if (evt->type == FWPM_NET_EVENT_TYPE_CLASSIFY_ALLOW && evt->classifyAllow)\r\n\t\t\t{\r\n\t\t\t\tlog->layer_id = evt->classifyAllow->layerId;\r\n\t\t\t\tlog->filter_id = evt->classifyAllow->filterId;\r\n\t\t\t\tlog->direction = evt->classifyAllow->msFwpDirection;\r\n\t\t\t\tlog->is_loopback = !!evt->classifyAllow->isLoopback;\r\n\r\n\t\t\t\tlog->is_allow = TRUE;\r\n\t\t\t}\r\n\t\t\telse if (evt->type == FWPM_NET_EVENT_TYPE_CLASSIFY_DROP_MAC && evt->classifyDropMac)\r\n\t\t\t{\r\n\t\t\t\tlog->layer_id = evt->classifyDropMac->layerId;\r\n\t\t\t\tlog->filter_id = evt->classifyDropMac->filterId;\r\n\t\t\t\tlog->direction = evt->classifyDropMac->msFwpDirection;\r\n\t\t\t\tlog->is_loopback = !!evt->classifyDropMac->isLoopback;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\treturn FALSE;\r\n\t\t\t}\r\n\r\n\t\t\t// indicates the direction of the packet transmission and set valid directions\r\n\t\t\tswitch (log->direction)\r\n\t\t\t{\r\n\t\t\t\tcase FWP_DIRECTION_IN:\r\n\t\t\t\tcase FWP_DIRECTION_INBOUND:\r\n\t\t\t\t{\r\n\t\t\t\t\tlog->direction = FWP_DIRECTION_INBOUND;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tcase FWP_DIRECTION_OUT:\r\n\t\t\t\tcase FWP_DIRECTION_OUTBOUND:\r\n\t\t\t\t{\r\n\t\t\t\t\tlog->direction = FWP_DIRECTION_OUTBOUND;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tdefault:\r\n\t\t\t\t{\r\n\t\t\t\t\treturn FALSE;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tlog->flags = evt->header.flags;\r\n\r\n\t\t\tRtlCopyMemory (&log->timestamp, &evt->header.timeStamp, sizeof (FILETIME));\r\n\r\n\t\t\tif ((evt->header.flags & FWPM_NET_EVENT_FLAG_APP_ID_SET) == FWPM_NET_EVENT_FLAG_APP_ID_SET)\r\n\t\t\t\tlog->app_id = evt->header.appId.data;\r\n\r\n\t\t\tif ((evt->header.flags & FWPM_NET_EVENT_FLAG_PACKAGE_ID_SET) == FWPM_NET_EVENT_FLAG_PACKAGE_ID_SET)\r\n\t\t\t\tlog->package_id = evt->header.packageSid;\r\n\r\n\t\t\tif ((evt->header.flags & FWPM_NET_EVENT_FLAG_USER_ID_SET) == FWPM_NET_EVENT_FLAG_USER_ID_SET)\r\n\t\t\t\tlog->user_id = evt->header.userId;\r\n\r\n\t\t\tif ((evt->header.flags & FWPM_NET_EVENT_FLAG_IP_PROTOCOL_SET) == FWPM_NET_EVENT_FLAG_IP_PROTOCOL_SET)\r\n\t\t\t\tlog->protocol = evt->header.ipProtocol;\r\n\r\n\t\t\tif ((evt->header.flags & FWPM_NET_EVENT_FLAG_LOCAL_PORT_SET) == FWPM_NET_EVENT_FLAG_LOCAL_PORT_SET)\r\n\t\t\t\tlog->local_port = evt->header.localPort;\r\n\r\n\t\t\tif ((evt->header.flags & FWPM_NET_EVENT_FLAG_REMOTE_PORT_SET) == FWPM_NET_EVENT_FLAG_REMOTE_PORT_SET)\r\n\t\t\t\tlog->remote_port = evt->header.remotePort;\r\n\r\n\t\t\tif ((evt->header.flags & FWPM_NET_EVENT_FLAG_IP_VERSION_SET) == FWPM_NET_EVENT_FLAG_IP_VERSION_SET)\r\n\t\t\t{\r\n\t\t\t\tlog->version = evt->header.ipVersion;\r\n\r\n\t\t\t\tif (evt->header.ipVersion == FWP_IP_VERSION_V4)\r\n\t\t\t\t{\r\n\t\t\t\t\tif ((evt->header.flags & FWPM_NET_EVENT_FLAG_LOCAL_ADDR_SET) == FWPM_NET_EVENT_FLAG_LOCAL_ADDR_SET)\r\n\t\t\t\t\t\tlog->local_addr4 = evt->header.localAddrV4;\r\n\r\n\t\t\t\t\tif ((evt->header.flags & FWPM_NET_EVENT_FLAG_REMOTE_ADDR_SET) == FWPM_NET_EVENT_FLAG_REMOTE_ADDR_SET)\r\n\t\t\t\t\t\tlog->remote_addr4 = evt->header.remoteAddrV4;\r\n\t\t\t\t}\r\n\t\t\t\telse if (evt->header.ipVersion == FWP_IP_VERSION_V6)\r\n\t\t\t\t{\r\n\t\t\t\t\tif ((evt->header.flags & FWPM_NET_EVENT_FLAG_LOCAL_ADDR_SET) == FWPM_NET_EVENT_FLAG_LOCAL_ADDR_SET)\r\n\t\t\t\t\t\tlog->local_addr6 = &evt->header.localAddrV6;\r\n\r\n\t\t\t\t\tif ((evt->header.flags & FWPM_NET_EVENT_FLAG_REMOTE_ADDR_SET) == FWPM_NET_EVENT_FLAG_REMOTE_ADDR_SET)\r\n\t\t\t\t\t\tlog->remote_addr6 = &evt->header.remoteAddrV6;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tlog->version = FWP_IP_VERSION_NONE;\r\n\t\t\t}\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase WINDOWS_7:\r\n\t\t{\r\n\t\t\tconst FWPM_NET_EVENT1 *evt = event_data;\r\n\r\n\t\t\tif (evt->type == FWPM_NET_EVENT_TYPE_CLASSIFY_DROP && evt->classifyDrop)\r\n\t\t\t{\r\n\t\t\t\tlog->layer_id = evt->classifyDrop->layerId;\r\n\t\t\t\tlog->filter_id = evt->classifyDrop->filterId;\r\n\t\t\t\tlog->direction = evt->classifyDrop->msFwpDirection;\r\n\t\t\t\tlog->is_loopback = !!evt->classifyDrop->isLoopback;\r\n\t\t\t}\r\n\t\t\telse if (evt->type == FWPM_NET_EVENT_TYPE_IPSEC_KERNEL_DROP && evt->ipsecDrop)\r\n\t\t\t{\r\n\t\t\t\tlog->layer_id = evt->ipsecDrop->layerId;\r\n\t\t\t\tlog->filter_id = evt->ipsecDrop->filterId;\r\n\t\t\t\tlog->direction = evt->ipsecDrop->direction;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\treturn FALSE;\r\n\t\t\t}\r\n\r\n\t\t\t// indicates the direction of the packet transmission and set valid directions\r\n\t\t\tswitch (log->direction)\r\n\t\t\t{\r\n\t\t\t\tcase FWP_DIRECTION_IN:\r\n\t\t\t\tcase FWP_DIRECTION_INBOUND:\r\n\t\t\t\t{\r\n\t\t\t\t\tlog->direction = FWP_DIRECTION_INBOUND;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tcase FWP_DIRECTION_OUT:\r\n\t\t\t\tcase FWP_DIRECTION_OUTBOUND:\r\n\t\t\t\t{\r\n\t\t\t\t\tlog->direction = FWP_DIRECTION_OUTBOUND;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tdefault:\r\n\t\t\t\t{\r\n\t\t\t\t\treturn FALSE;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tlog->flags = evt->header.flags;\r\n\r\n\t\t\tRtlCopyMemory (&log->timestamp, &evt->header.timeStamp, sizeof (FILETIME));\r\n\r\n\t\t\tif ((evt->header.flags & FWPM_NET_EVENT_FLAG_APP_ID_SET) == FWPM_NET_EVENT_FLAG_APP_ID_SET)\r\n\t\t\t\tlog->app_id = evt->header.appId.data;\r\n\r\n\t\t\tif ((evt->header.flags & FWPM_NET_EVENT_FLAG_USER_ID_SET) == FWPM_NET_EVENT_FLAG_USER_ID_SET)\r\n\t\t\t\tlog->user_id = evt->header.userId;\r\n\r\n\t\t\tif ((evt->header.flags & FWPM_NET_EVENT_FLAG_IP_PROTOCOL_SET) == FWPM_NET_EVENT_FLAG_IP_PROTOCOL_SET)\r\n\t\t\t\tlog->protocol = evt->header.ipProtocol;\r\n\r\n\t\t\tif ((evt->header.flags & FWPM_NET_EVENT_FLAG_LOCAL_PORT_SET) == FWPM_NET_EVENT_FLAG_LOCAL_PORT_SET)\r\n\t\t\t\tlog->local_port = evt->header.localPort;\r\n\r\n\t\t\tif ((evt->header.flags & FWPM_NET_EVENT_FLAG_REMOTE_PORT_SET) == FWPM_NET_EVENT_FLAG_REMOTE_PORT_SET)\r\n\t\t\t\tlog->remote_port = evt->header.remotePort;\r\n\r\n\t\t\tif ((evt->header.flags & FWPM_NET_EVENT_FLAG_IP_VERSION_SET) == FWPM_NET_EVENT_FLAG_IP_VERSION_SET)\r\n\t\t\t{\r\n\t\t\t\tlog->version = evt->header.ipVersion;\r\n\r\n\t\t\t\tif (evt->header.ipVersion == FWP_IP_VERSION_V4)\r\n\t\t\t\t{\r\n\t\t\t\t\tif ((evt->header.flags & FWPM_NET_EVENT_FLAG_LOCAL_ADDR_SET) == FWPM_NET_EVENT_FLAG_LOCAL_ADDR_SET)\r\n\t\t\t\t\t\tlog->local_addr4 = evt->header.localAddrV4;\r\n\r\n\t\t\t\t\tif ((evt->header.flags & FWPM_NET_EVENT_FLAG_REMOTE_ADDR_SET) == FWPM_NET_EVENT_FLAG_REMOTE_ADDR_SET)\r\n\t\t\t\t\t\tlog->remote_addr4 = evt->header.remoteAddrV4;\r\n\t\t\t\t}\r\n\t\t\t\telse if (evt->header.ipVersion == FWP_IP_VERSION_V6)\r\n\t\t\t\t{\r\n\t\t\t\t\tif ((evt->header.flags & FWPM_NET_EVENT_FLAG_LOCAL_ADDR_SET) == FWPM_NET_EVENT_FLAG_LOCAL_ADDR_SET)\r\n\t\t\t\t\t\tlog->local_addr6 = &evt->header.localAddrV6;\r\n\r\n\t\t\t\t\tif ((evt->header.flags & FWPM_NET_EVENT_FLAG_REMOTE_ADDR_SET) == FWPM_NET_EVENT_FLAG_REMOTE_ADDR_SET)\r\n\t\t\t\t\t\tlog->remote_addr6 = &evt->header.remoteAddrV6;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tlog->version = FWP_IP_VERSION_NONE;\r\n\t\t\t}\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tdefault:\r\n\t\t{\r\n\t\t\treturn FALSE;\r\n\t\t}\r\n\t}\r\n\r\n\treturn TRUE;\r\n}\r\n\r\n// win7+ callback\r\nVOID CALLBACK _wfp_logcallback0 (\r\n\t_Inout_ PVOID context,\r\n\t_In_ const FWPM_NET_EVENT1* event_data\r\n)\r\n{\r\n\tITEM_LOG_CALLBACK log;\r\n\r\n\tif (log_struct_to_f (&log, WINDOWS_7, event_data))\r\n\t\t_wfp_logcallback (&log);\r\n}\r\n\r\n// win8+ callback\r\nVOID CALLBACK _wfp_logcallback1 (\r\n\t_Inout_ PVOID context,\r\n\t_In_ const FWPM_NET_EVENT2* event_data\r\n)\r\n{\r\n\tITEM_LOG_CALLBACK log;\r\n\r\n\tif (log_struct_to_f (&log, WINDOWS_8, event_data))\r\n\t\t_wfp_logcallback (&log);\r\n}\r\n\r\n// win10rs1+ callback\r\nVOID CALLBACK _wfp_logcallback2 (\r\n\t_Inout_ PVOID context,\r\n\t_In_ const FWPM_NET_EVENT3* event_data\r\n)\r\n{\r\n\tITEM_LOG_CALLBACK log;\r\n\r\n\tif (log_struct_to_f (&log, WINDOWS_10_RS1, event_data))\r\n\t\t_wfp_logcallback (&log);\r\n}\r\n\r\n// win10rs1+ callback\r\nVOID CALLBACK _wfp_logcallback3 (\r\n\t_Inout_ PVOID context,\r\n\t_In_ const FWPM_NET_EVENT4* event_data\r\n)\r\n{\r\n\tITEM_LOG_CALLBACK log;\r\n\r\n\tif (log_struct_to_f (&log, WINDOWS_10_RS2, event_data))\r\n\t\t_wfp_logcallback (&log);\r\n}\r\n\r\n// win10rs3+ callback\r\nVOID CALLBACK _wfp_logcallback4 (\r\n\t_Inout_ PVOID context,\r\n\t_In_ const FWPM_NET_EVENT5* event_data\r\n)\r\n{\r\n\tITEM_LOG_CALLBACK log;\r\n\r\n\tif (log_struct_to_f (&log, WINDOWS_10_RS3, event_data))\r\n\t\t_wfp_logcallback (&log);\r\n}\r\n\r\nVOID NTAPI _app_logthread (\r\n\t_In_ PVOID arglist\r\n)\r\n{\r\n\tPITEM_APP ptr_app = NULL;\r\n\tPITEM_LOG ptr_log;\r\n\tHWND hwnd;\r\n\tBOOLEAN is_notificationenabled;\r\n\tBOOLEAN is_exludeblocklist;\r\n\tBOOLEAN is_exludestealth;\r\n\tBOOLEAN is_loguienabled;\r\n\tBOOLEAN is_exludeallow;\r\n\tBOOLEAN is_silent = FALSE;\r\n\tBOOLEAN is_logenabled;\r\n\tBOOLEAN is_notexist;\r\n\r\n\thwnd = _r_app_gethwnd ();\r\n\r\n\tptr_log = arglist;\r\n\r\n\t// apps collector\r\n\tis_notexist = ptr_log->app_hash && !ptr_log->is_allow && !_app_isappfound (ptr_log->app_hash);\r\n\r\n\tif (is_notexist)\r\n\t{\r\n\t\tptr_log->app_hash = _app_addapplication (hwnd, DATA_UNKNOWN, ptr_log->path, NULL, NULL);\r\n\r\n\t\tif (ptr_log->app_hash)\r\n\t\t{\r\n\t\t\tptr_app = _app_getappitem (ptr_log->app_hash);\r\n\r\n\t\t\tif (ptr_app)\r\n\t\t\t\t_app_listview_updateby_id (hwnd, ptr_app->type, PR_UPDATE_TYPE);\r\n\r\n\t\t\t_app_profile_save (hwnd);\r\n\t\t}\r\n\t}\r\n\r\n\tif (!ptr_app)\r\n\t\tptr_app = _app_getappitem (ptr_log->app_hash);\r\n\r\n\tis_logenabled = _r_config_getboolean (L\"IsLogEnabled\", FALSE, NULL);\r\n\tis_loguienabled = _r_config_getboolean (L\"IsLogUiEnabled\", FALSE, NULL);\r\n\tis_notificationenabled = _r_config_getboolean (L\"IsNotificationsEnabled\", TRUE, NULL);\r\n\r\n\tis_exludeallow = !(ptr_log->is_allow && _r_config_getboolean (L\"IsExcludeClassifyAllow\", TRUE, NULL));\r\n\tis_exludestealth = !(ptr_log->is_system && _r_config_getboolean (L\"IsExcludeStealth\", TRUE, NULL));\r\n\r\n\tis_exludeblocklist = !(ptr_log->is_blocklist && _r_config_getboolean (L\"IsExcludeBlocklist\", TRUE, NULL)) && !(ptr_log->is_custom && _r_config_getboolean (L\"IsExcludeCustomRules\", TRUE, NULL));\r\n\r\n\tif ((is_logenabled || is_loguienabled || is_notificationenabled) && is_exludestealth && is_exludeallow)\r\n\t{\r\n\t\t// get network string\r\n\t\tptr_log->remote_addr_str = _app_formataddress (ptr_log->af, ptr_log->protocol, &ptr_log->remote_addr, 0, 0);\r\n\t\tptr_log->local_addr_str = _app_formataddress (ptr_log->af, ptr_log->protocol, &ptr_log->local_addr, 0, 0);\r\n\r\n\t\t// display notification\r\n\t\tif (is_notificationenabled)\r\n\t\t{\r\n\t\t\tif (ptr_app && !ptr_log->is_allow && is_exludeblocklist)\r\n\t\t\t{\r\n\t\t\t\tif (_app_getappinfo (ptr_app, INFO_IS_SILENT, &is_silent, sizeof (BOOLEAN)))\r\n\t\t\t\t{\r\n\t\t\t\t\tif (!is_silent)\r\n\t\t\t\t\t\t_app_notify_addobject (hwnd, ptr_log, ptr_app);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// write log to a file\r\n\t\tif (is_logenabled)\r\n\t\t\t_app_logwrite (ptr_log);\r\n\r\n\t\t// only for my own provider\r\n\t\tif (ptr_log->is_myprovider)\r\n\t\t{\r\n\t\t\t// write log to a ui\r\n\t\t\tif (is_loguienabled)\r\n\t\t\t\t_app_logwrite_ui (hwnd, ptr_log); // write to a ui\r\n\t\t}\r\n\t}\r\n\r\n\tif (ptr_app)\r\n\t\t_r_obj_dereference (ptr_app);\r\n\r\n\t_r_obj_dereference (ptr_log);\r\n}\r\n"
  },
  {
    "path": "src/log.h",
    "content": "// simplewall\r\n// Copyright (c) 2016-2026 Henry++\r\n\r\n#pragma once\r\n\r\n// FwpmNetEventSubscribe4 (win10rs5+)\r\ntypedef ULONG (WINAPI *FWPMNES4)(\r\n\t_In_ HANDLE engine_handle,\r\n\t_In_ const FWPM_NET_EVENT_SUBSCRIPTION0 *subscription,\r\n\t_In_ FWPM_NET_EVENT_CALLBACK4 callback,\r\n\t_In_opt_ PVOID context,\r\n\t_Out_ PHANDLE events_handle\r\n\t);\r\n\r\n// FwpmNetEventSubscribe3 (win10rs4+)\r\ntypedef ULONG (WINAPI *FWPMNES3)(\r\n\t_In_ HANDLE engine_handle,\r\n\t_In_ const FWPM_NET_EVENT_SUBSCRIPTION0 *subscription,\r\n\t_In_ FWPM_NET_EVENT_CALLBACK3 callback,\r\n\t_In_opt_ PVOID context,\r\n\t_Out_ PHANDLE events_handle\r\n\t);\r\n\r\n// FwpmNetEventSubscribe2 (win10rs1+)\r\ntypedef ULONG (WINAPI *FWPMNES2)(\r\n\t_In_ HANDLE engine_handle,\r\n\t_In_ const FWPM_NET_EVENT_SUBSCRIPTION0 *subscription,\r\n\t_In_ FWPM_NET_EVENT_CALLBACK2 callback,\r\n\t_In_opt_ PVOID context,\r\n\t_Out_ PHANDLE events_handle\r\n\t);\r\n\r\n// FwpmNetEventSubscribe1 (win8+)\r\ntypedef ULONG (WINAPI *FWPMNES1)(\r\n\t_In_ HANDLE engine_handle,\r\n\t_In_ const FWPM_NET_EVENT_SUBSCRIPTION0 *subscription,\r\n\t_In_ FWPM_NET_EVENT_CALLBACK1 callback,\r\n\t_In_opt_ PVOID context,\r\n\t_Out_ PHANDLE events_handle\r\n\t);\r\n\r\nVOID _app_loginit (\r\n\t_In_ BOOLEAN is_install\r\n);\r\n\r\nVOID _app_loginitfile (\r\n\t_In_ HANDLE hfile\r\n);\r\n\r\nULONG _app_getloghash (\r\n\t_In_ PITEM_LOG ptr_log\r\n);\r\n\r\n_Ret_maybenull_\r\nPR_STRING _app_getlogpath ();\r\n\r\n_Ret_maybenull_\r\nPR_STRING _app_getlogviewer ();\r\n\r\nBOOLEAN _app_islogfound (\r\n\t_In_ ULONG log_hash\r\n);\r\n\r\nBOOLEAN _app_logislimitreached (\r\n\t_In_ HANDLE hfile\r\n);\r\n\r\nVOID _app_logclear (\r\n\t_In_opt_ HANDLE hfile\r\n);\r\n\r\nVOID _app_logclear_ui (\r\n\t_In_ HWND hwnd\r\n);\r\n\r\nVOID _app_logwrite (\r\n\t_In_ PITEM_LOG ptr_log\r\n);\r\n\r\nVOID _app_logwrite_ui (\r\n\t_In_ HWND hwnd,\r\n\t_In_ PITEM_LOG ptr_log\r\n);\r\n\r\nVOID _wfp_logsubscribe (\r\n\t_In_opt_ HWND hwnd,\r\n\t_In_ HANDLE engine_handle\r\n);\r\n\r\nVOID _wfp_logunsubscribe (\r\n\t_In_ HANDLE engine_handle\r\n);\r\n\r\nVOID _wfp_logsetoption (\r\n\t_In_ HANDLE engine_handle\r\n);\r\n\r\nVOID CALLBACK _wfp_logcallback (\r\n\t_In_ PITEM_LOG_CALLBACK log\r\n);\r\n\r\n// win7+ callback\r\nVOID CALLBACK _wfp_logcallback0 (\r\n\t_Inout_ PVOID context,\r\n\t_In_ const FWPM_NET_EVENT1* event_data\r\n);\r\n\r\n// win8+ callback\r\nVOID CALLBACK _wfp_logcallback1 (\r\n\t_Inout_ PVOID context,\r\n\t_In_ const FWPM_NET_EVENT2* event_data\r\n);\r\n\r\n// win10rs1+ callback\r\nVOID CALLBACK _wfp_logcallback2 (\r\n\t_Inout_ PVOID context,\r\n\t_In_ const FWPM_NET_EVENT3* event_data\r\n);\r\n\r\n// win10rs4+ callback\r\nVOID CALLBACK _wfp_logcallback3 (\r\n\t_Inout_ PVOID context,\r\n\t_In_ const FWPM_NET_EVENT4* event_data\r\n);\r\n\r\n// win10rs5+ callback\r\nVOID CALLBACK _wfp_logcallback4 (\r\n\t_Inout_ PVOID context,\r\n\t_In_ const FWPM_NET_EVENT5* event_data\r\n);\r\n\r\nVOID NTAPI _app_logthread (\r\n\t_In_ PVOID arglist\r\n);\r\n"
  },
  {
    "path": "src/main.c",
    "content": "// simplewall\n// Copyright (c) 2016-2026 Henry++\n\n#include \"global.h\"\n\nBOOLEAN _app_changefilters (\n\t_In_ HWND hwnd,\n\t_In_ BOOLEAN is_install,\n\t_In_ BOOLEAN is_forced\n)\n{\n\tPITEM_TAB_CONTEXT tab_context;\n\tPITEM_CONTEXT context;\n\n\ttab_context = _app_listview_getcontext (hwnd, INT_ERROR);\n\n\tif (!tab_context)\n\t\treturn FALSE;\n\n\t_app_listview_sort (hwnd, tab_context->listview_id, INT_ERROR, FALSE);\n\n\tif (is_forced || _wfp_isfiltersinstalled ())\n\t{\n\t\t_app_initinterfacestate (hwnd, TRUE);\n\n\t\tcontext = _r_freelist_allocateitem (&context_free_list);\n\n\t\tcontext->hwnd = hwnd;\n\t\tcontext->is_install = is_install;\n\n\t\t_r_workqueue_queueitem (&wfp_queue, &_wfp_applythread, context);\n\n\t\treturn TRUE;\n\t}\n\n\t_r_listview_redraw (hwnd, tab_context->listview_id);\n\n\t_app_profile_save (hwnd);\n\n\treturn FALSE;\n}\n\nBOOLEAN _app_installmessage (\n\t_In_opt_ HWND hwnd,\n\t_In_ BOOLEAN is_install\n)\n{\n\tTASKDIALOGCONFIG tdc = {0};\n\tWCHAR str_main[256];\n\tWCHAR radio_text_1[128];\n\tWCHAR radio_text_2[128];\n\tWCHAR str_flag[128];\n\tWCHAR str_button_text_1[64];\n\tWCHAR str_button_text_2[64];\n\tTASKDIALOG_BUTTON td_buttons[2] = {0};\n\tTASKDIALOG_BUTTON td_radios[2] = {0};\n\tINT command_id;\n\tINT radio_id;\n\tBOOL is_flagchecked;\n\tHRESULT status;\n\n\ttdc.cbSize = sizeof (TASKDIALOGCONFIG);\n\ttdc.dwFlags = TDF_ENABLE_HYPERLINKS | TDF_ALLOW_DIALOG_CANCELLATION | TDF_NO_SET_FOREGROUND;\n\ttdc.hwndParent = hwnd;\n\ttdc.pszWindowTitle = _r_app_getname ();\n\ttdc.pszMainIcon = is_install ? TD_INFORMATION_ICON : TD_WARNING_ICON;\n\t//tdc.dwCommonButtons = TDCBF_YES_BUTTON | TDCBF_NO_BUTTON;\n\ttdc.pfCallback = &_r_msg_callback;\n\ttdc.lpCallbackData = MAKELONG (0, TRUE); // on top\n\n\tif (_r_config_getboolean (L\"WF_State\", TRUE, NULL))\n\t\ttdc.dwFlags |= TDF_VERIFICATION_FLAG_CHECKED;\n\n\ttdc.pButtons = td_buttons;\n\ttdc.cButtons = RTL_NUMBER_OF (td_buttons);\n\n\ttdc.nDefaultButton = IDYES;\n\n\t_r_str_copy (\n\t\tstr_button_text_1,\n\t\tRTL_NUMBER_OF (str_button_text_1),\n\t\t_app_getstateaction (is_install ? INSTALL_DISABLED : INSTALL_ENABLED)\n\t);\n\n\t_r_str_copy (str_button_text_2, RTL_NUMBER_OF (str_button_text_2), _r_locale_getstring (IDS_CLOSE));\n\n\ttd_buttons[0].nButtonID = IDYES;\n\ttd_buttons[0].pszButtonText = str_button_text_1;\n\n\ttd_buttons[1].nButtonID = IDNO;\n\ttd_buttons[1].pszButtonText = str_button_text_2;\n\n\tif (is_install)\n\t{\n\t\t_r_str_copy (str_main, RTL_NUMBER_OF (str_main), _r_locale_getstring (IDS_QUESTION_START));\n\t\t_r_str_copy (str_flag, RTL_NUMBER_OF (str_flag), _r_locale_getstring (IDS_DISABLEWINDOWSFIREWALL_CHK));\n\n\t\ttdc.pRadioButtons = td_radios;\n\t\ttdc.cRadioButtons = RTL_NUMBER_OF (td_radios);\n\n\t\ttdc.nDefaultRadioButton = IDYES;\n\n\t\t_r_str_copy (radio_text_1, RTL_NUMBER_OF (radio_text_1), _r_locale_getstring (IDS_INSTALL_PERMANENT));\n\t\t_r_str_copy (radio_text_2, RTL_NUMBER_OF (radio_text_2), _r_locale_getstring (IDS_INSTALL_TEMPORARY));\n\n\t\ttd_radios[0].nButtonID = IDYES;\n\t\ttd_radios[0].pszButtonText = radio_text_1;\n\n\t\ttd_radios[1].nButtonID = IDNO;\n\t\ttd_radios[1].pszButtonText = radio_text_2;\n\t}\n\telse\n\t{\n\t\t_r_str_copy (str_main, RTL_NUMBER_OF (str_main), _r_locale_getstring (IDS_QUESTION_STOP));\n\t\t_r_str_copy (str_flag, RTL_NUMBER_OF (str_flag), _r_locale_getstring (IDS_ENABLEWINDOWSFIREWALL_CHK));\n\t}\n\n\ttdc.pszMainInstruction = str_main;\n\ttdc.pszVerificationText = str_flag;\n\n\tstatus = _r_msg_taskdialog (&tdc, &command_id, &radio_id, &is_flagchecked);\n\n\tif (SUCCEEDED (status))\n\t{\n\t\t_r_config_setboolean (L\"WF_State\", is_flagchecked ? TRUE : FALSE, NULL);\n\n\t\tif (command_id == IDYES)\n\t\t{\n\t\t\tif (is_install)\n\t\t\t{\n\t\t\t\tconfig.is_filterstemporary = (radio_id == IDNO);\n\n\t\t\t\tif (is_flagchecked)\n\t\t\t\t\t_wfp_firewallenable (FALSE);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tconfig.is_filterstemporary = FALSE;\n\n\t\t\t\tif (is_flagchecked)\n\t\t\t\t\t_wfp_firewallenable (TRUE);\n\t\t\t}\n\n\t\t\treturn TRUE;\n\t\t}\n\t}\n\n\treturn FALSE;\n}\n\nVOID _app_config_apply (\n\t_In_ HWND hwnd,\n\t_In_opt_ HWND hsettings,\n\t_In_ INT ctrl_id\n)\n{\n\tHMENU hmenu;\n\tBOOLEAN is_enabled;\n\tBOOLEAN new_val;\n\n\tswitch (ctrl_id)\n\t{\n\t\tcase IDC_LOADONSTARTUP_CHK:\n\t\tcase IDM_LOADONSTARTUP_CHK:\n\t\t{\n\t\t\tnew_val = !_r_autorun_isenabled ();\n\t\t\tbreak;\n\t\t}\n\n\t\tcase IDC_STARTMINIMIZED_CHK:\n\t\tcase IDM_STARTMINIMIZED_CHK:\n\t\t{\n\t\t\tnew_val = !_r_config_getboolean (L\"IsStartMinimized\", FALSE, NULL);\n\t\t\tbreak;\n\t\t}\n\n\t\tcase IDC_SKIPUACWARNING_CHK:\n\t\tcase IDM_SKIPUACWARNING_CHK:\n\t\t{\n\t\t\tnew_val = !_r_skipuac_isenabled ();\n\t\t\tbreak;\n\t\t}\n\n\t\tcase IDC_CHECKUPDATES_CHK:\n\t\tcase IDM_CHECKUPDATES_CHK:\n\t\t{\n\t\t\tnew_val = !_r_update_isenabled (FALSE);\n\t\t\tbreak;\n\t\t}\n\n\t\tcase IDC_RULE_BLOCKOUTBOUND:\n\t\tcase IDM_RULE_BLOCKOUTBOUND:\n\t\t{\n\t\t\tnew_val = !_r_config_getboolean (L\"BlockOutboundConnections\", TRUE, NULL);\n\t\t\tbreak;\n\t\t}\n\n\t\tcase IDC_RULE_BLOCKINBOUND:\n\t\tcase IDM_RULE_BLOCKINBOUND:\n\t\t{\n\t\t\tnew_val = !_r_config_getboolean (L\"BlockInboundConnections\", TRUE, NULL);\n\t\t\tbreak;\n\t\t}\n\n\t\tcase IDC_RULE_ALLOWLOOPBACK:\n\t\tcase IDM_RULE_ALLOWLOOPBACK:\n\t\t{\n\t\t\tnew_val = !_r_config_getboolean (L\"AllowLoopbackConnections\", TRUE, NULL);\n\t\t\tbreak;\n\t\t}\n\n\t\tcase IDC_RULE_ALLOW6TO4:\n\t\tcase IDM_RULE_ALLOW6TO4:\n\t\t{\n\t\t\tnew_val = !_r_config_getboolean (L\"AllowIPv6\", TRUE, NULL);\n\t\t\tbreak;\n\t\t}\n\n\t\tcase IDM_RULE_ALLOWWINDOWSUPDATE:\n\t\t{\n\t\t\tnew_val = !_app_wufixenabled ();\n\t\t\tbreak;\n\t\t}\n\n\t\tcase IDC_USESTEALTHMODE_CHK:\n\t\t{\n\t\t\tnew_val = !_r_config_getboolean (L\"UseStealthMode\", TRUE, NULL);\n\t\t\tbreak;\n\t\t}\n\n\t\tcase IDC_USECERTIFICATES_CHK:\n\t\tcase IDM_USECERTIFICATES_CHK:\n\t\t{\n\t\t\tnew_val = !_r_config_getboolean (L\"IsCertificatesEnabled\", TRUE, NULL);\n\t\t\tbreak;\n\t\t}\n\n\t\tcase IDM_KEEPUNUSED_CHK:\n\t\t{\n\t\t\tnew_val = !_r_config_getboolean (L\"IsKeepUnusedApps\", TRUE, NULL);\n\t\t\tbreak;\n\t\t}\n\n\t\tcase IDC_USEHASHES_CHK:\n\t\tcase IDM_USEHASHES_CHK:\n\t\t{\n\t\t\tnew_val = !_r_config_getboolean (L\"IsHashesEnabled\", FALSE, NULL);\n\t\t\tbreak;\n\t\t}\n\n\t\tcase IDC_INSTALLBOOTTIMEFILTERS_CHK:\n\t\t{\n\t\t\tnew_val = !_r_config_getboolean (L\"InstallBoottimeFilters\", TRUE, NULL);\n\t\t\tbreak;\n\t\t}\n\n\t\tcase IDC_USENETWORKRESOLUTION_CHK:\n\t\tcase IDM_USENETWORKRESOLUTION_CHK:\n\t\t{\n\t\t\tnew_val = !_r_config_getboolean (L\"IsNetworkResolutionsEnabled\", FALSE, NULL);\n\t\t\tbreak;\n\t\t}\n\n\t\tcase IDM_USEAPPMONITOR_CHK:\n\t\t{\n\t\t\tnew_val = !_r_config_getboolean (L\"IsEnableAppMonitor\", FALSE, NULL);\n\t\t\tbreak;\n\t\t}\n\n\t\tcase IDM_USEDARKTHEME_CHK:\n\t\t{\n\t\t\tnew_val = !_r_theme_isenabled ();\n\t\t\tbreak;\n\t\t}\n\n\t\tcase IDM_PROFILETYPE_PLAIN:\n\t\tcase IDM_PROFILETYPE_COMPRESSED:\n\t\tcase IDM_PROFILETYPE_ENCRYPTED:\n\t\t{\n\t\t\tbreak;\n\t\t}\n\n\t\tdefault:\n\t\t{\n\t\t\treturn;\n\t\t}\n\t}\n\n\thmenu = GetMenu (hwnd);\n\n\tif (!hmenu)\n\t\treturn;\n\n\tswitch (ctrl_id)\n\t{\n\t\tcase IDC_LOADONSTARTUP_CHK:\n\t\tcase IDM_LOADONSTARTUP_CHK:\n\t\t{\n\t\t\t_r_autorun_enable (hsettings ? hsettings : hwnd, new_val);\n\n\t\t\tis_enabled = _r_autorun_isenabled ();\n\n\t\t\t_r_menu_checkitem (hmenu, IDM_LOADONSTARTUP_CHK, 0, MF_BYCOMMAND, is_enabled);\n\n\t\t\tif (hsettings)\n\t\t\t\t_r_ctrl_checkbutton (hsettings, IDC_LOADONSTARTUP_CHK, is_enabled);\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase IDC_STARTMINIMIZED_CHK:\n\t\tcase IDM_STARTMINIMIZED_CHK:\n\t\t{\n\t\t\t_r_config_setboolean (L\"IsStartMinimized\", new_val, NULL);\n\n\t\t\t_r_menu_checkitem (hmenu, IDM_STARTMINIMIZED_CHK, 0, MF_BYCOMMAND, new_val);\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase IDC_SKIPUACWARNING_CHK:\n\t\tcase IDM_SKIPUACWARNING_CHK:\n\t\t{\n\t\t\t_r_skipuac_enable (hsettings ? hsettings : hwnd, new_val);\n\n\t\t\tis_enabled = _r_skipuac_isenabled ();\n\n\t\t\t_r_menu_checkitem (hmenu, IDM_SKIPUACWARNING_CHK, 0, MF_BYCOMMAND, is_enabled);\n\n\t\t\tif (hsettings)\n\t\t\t\t_r_ctrl_checkbutton (hsettings, IDC_SKIPUACWARNING_CHK, is_enabled);\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase IDC_CHECKUPDATES_CHK:\n\t\tcase IDM_CHECKUPDATES_CHK:\n\t\t{\n\t\t\t_r_update_enable (new_val);\n\n\t\t\t_r_menu_checkitem (hmenu, IDM_CHECKUPDATES_CHK, 0, MF_BYCOMMAND, new_val);\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase IDC_RULE_BLOCKOUTBOUND:\n\t\tcase IDM_RULE_BLOCKOUTBOUND:\n\t\t{\n\t\t\t_r_config_setboolean (L\"BlockOutboundConnections\", new_val, NULL);\n\n\t\t\t_r_menu_checkitem (hmenu, IDM_RULE_BLOCKOUTBOUND, 0, MF_BYCOMMAND, new_val);\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase IDC_RULE_BLOCKINBOUND:\n\t\tcase IDM_RULE_BLOCKINBOUND:\n\t\t{\n\t\t\t_r_config_setboolean (L\"BlockInboundConnections\", new_val, NULL);\n\n\t\t\t_r_menu_checkitem (hmenu, IDM_RULE_BLOCKINBOUND, 0, MF_BYCOMMAND, new_val);\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase IDC_RULE_ALLOWLOOPBACK:\n\t\tcase IDM_RULE_ALLOWLOOPBACK:\n\t\t{\n\t\t\t_r_config_setboolean (L\"AllowLoopbackConnections\", new_val, NULL);\n\n\t\t\t_r_menu_checkitem (hmenu, IDM_RULE_ALLOWLOOPBACK, 0, MF_BYCOMMAND, new_val);\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase IDC_RULE_ALLOW6TO4:\n\t\tcase IDM_RULE_ALLOW6TO4:\n\t\t{\n\t\t\t_r_config_setboolean (L\"AllowIPv6\", new_val, NULL);\n\n\t\t\t_r_menu_checkitem (hmenu, IDM_RULE_ALLOW6TO4, 0, MF_BYCOMMAND, new_val);\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase IDM_RULE_ALLOWWINDOWSUPDATE:\n\t\t{\n\t\t\t_r_config_setboolean (L\"IsWUFixEnabled\", new_val, NULL);\n\n\t\t\t_r_menu_checkitem (hmenu, IDM_RULE_ALLOWWINDOWSUPDATE, 0, MF_BYCOMMAND, new_val);\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase IDM_PROFILETYPE_PLAIN:\n\t\t{\n\t\t\t_r_config_setlong (L\"ProfileType\", 0, NULL);\n\n\t\t\t_r_menu_checkitem (hmenu, IDM_PROFILETYPE_PLAIN, IDM_PROFILETYPE_ENCRYPTED, MF_BYCOMMAND, IDM_PROFILETYPE_PLAIN);\n\n\t\t\t_app_profile_save (hwnd);\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase IDM_PROFILETYPE_COMPRESSED:\n\t\t{\n\t\t\t_r_config_setlong (L\"ProfileType\", 1, NULL);\n\n\t\t\t_r_menu_checkitem (hmenu, IDM_PROFILETYPE_PLAIN, IDM_PROFILETYPE_ENCRYPTED, MF_BYCOMMAND, IDM_PROFILETYPE_COMPRESSED);\n\n\t\t\t_app_profile_save (hwnd);\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase IDM_PROFILETYPE_ENCRYPTED:\n\t\t{\n\t\t\t_r_config_setlong (L\"ProfileType\", 2, NULL);\n\n\t\t\t_r_menu_checkitem (hmenu, IDM_PROFILETYPE_PLAIN, IDM_PROFILETYPE_ENCRYPTED, MF_BYCOMMAND, IDM_PROFILETYPE_ENCRYPTED);\n\n\t\t\t_app_profile_save (hwnd);\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase IDC_USESTEALTHMODE_CHK:\n\t\t{\n\t\t\t_r_config_setboolean (L\"UseStealthMode\", new_val, NULL);\n\t\t\tbreak;\n\t\t}\n\n\t\tcase IDC_INSTALLBOOTTIMEFILTERS_CHK:\n\t\t{\n\t\t\t_r_config_setboolean (L\"InstallBoottimeFilters\", new_val, NULL);\n\t\t\tbreak;\n\t\t}\n\n\t\tcase IDC_USECERTIFICATES_CHK:\n\t\tcase IDM_USECERTIFICATES_CHK:\n\t\t{\n\t\t\tPITEM_APP ptr_app = NULL;\n\t\t\tULONG_PTR enum_key = 0;\n\t\t\tINT listview_id;\n\n\t\t\t_r_config_setboolean (L\"IsCertificatesEnabled\", new_val, NULL);\n\n\t\t\t_r_menu_checkitem (hmenu, IDM_USECERTIFICATES_CHK, 0, MF_BYCOMMAND, new_val);\n\n\t\t\tif (new_val)\n\t\t\t{\n\t\t\t\t_r_queuedlock_acquireshared (&lock_apps);\n\n\t\t\t\twhile (_r_obj_enumhashtablepointer (apps_table, (PVOID_PTR)&ptr_app, NULL, &enum_key))\n\t\t\t\t{\n\t\t\t\t\tif (!ptr_app->real_path)\n\t\t\t\t\t\tcontinue;\n\n\t\t\t\t\tlistview_id = _app_listview_getbytype (ptr_app->type);\n\n\t\t\t\t\t_app_getfileinformation (ptr_app->real_path, ptr_app->app_hash, ptr_app->type, listview_id);\n\t\t\t\t}\n\n\t\t\t\t_r_queuedlock_releaseshared (&lock_apps);\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase IDM_KEEPUNUSED_CHK:\n\t\t{\n\t\t\t_r_config_setboolean (L\"IsKeepUnusedApps\", new_val, NULL);\n\n\t\t\t_r_menu_checkitem (hmenu, IDM_KEEPUNUSED_CHK, 0, MF_BYCOMMAND, new_val);\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase IDC_USEHASHES_CHK:\n\t\tcase IDM_USEHASHES_CHK:\n\t\t{\n\t\t\tPITEM_APP ptr_app = NULL;\n\t\t\tULONG_PTR enum_key = 0;\n\t\t\tINT listview_id;\n\n\t\t\t_r_config_setboolean (L\"IsHashesEnabled\", new_val, NULL);\n\n\t\t\t_r_menu_checkitem (hmenu, IDM_USEHASHES_CHK, 0, MF_BYCOMMAND, new_val);\n\n\t\t\t_r_menu_enableitem (hmenu, IDM_USEAPPMONITOR_CHK, FALSE, new_val);\n\n\t\t\tif (new_val)\n\t\t\t{\n\t\t\t\t_r_queuedlock_acquireshared (&lock_apps);\n\n\t\t\t\twhile (_r_obj_enumhashtablepointer (apps_table, (PVOID_PTR)&ptr_app, NULL, &enum_key))\n\t\t\t\t{\n\t\t\t\t\tif (!ptr_app->real_path)\n\t\t\t\t\t\tcontinue;\n\n\t\t\t\t\tlistview_id = _app_listview_getbytype (ptr_app->type);\n\n\t\t\t\t\t_app_getfileinformation (ptr_app->real_path, ptr_app->app_hash, ptr_app->type, listview_id);\n\t\t\t\t}\n\n\t\t\t\t_r_queuedlock_releaseshared (&lock_apps);\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase IDC_USENETWORKRESOLUTION_CHK:\n\t\tcase IDM_USENETWORKRESOLUTION_CHK:\n\t\t{\n\t\t\t_r_config_setboolean (L\"IsNetworkResolutionsEnabled\", new_val, NULL);\n\n\t\t\t_r_menu_checkitem (hmenu, IDM_USENETWORKRESOLUTION_CHK, 0, MF_BYCOMMAND, new_val);\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase IDM_USEAPPMONITOR_CHK:\n\t\t{\n\t\t\t_r_config_setboolean (L\"IsEnableAppMonitor\", new_val, NULL);\n\n\t\t\t_r_menu_checkitem (hmenu, IDM_USEAPPMONITOR_CHK, 0, MF_BYCOMMAND, new_val);\n\n\t\t\t_app_fileloggingenable ();\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase IDM_USEDARKTHEME_CHK:\n\t\t{\n\t\t\t_r_menu_checkitem (hmenu, IDM_USEDARKTHEME_CHK, 0, MF_BYCOMMAND, new_val);\n\n\t\t\t_r_theme_enable (hwnd, new_val);\n\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tswitch (ctrl_id)\n\t{\n\t\tcase IDM_LOADONSTARTUP_CHK:\n\t\tcase IDC_LOADONSTARTUP_CHK:\n\t\tcase IDM_STARTMINIMIZED_CHK:\n\t\tcase IDC_STARTMINIMIZED_CHK:\n\t\tcase IDM_SKIPUACWARNING_CHK:\n\t\tcase IDC_SKIPUACWARNING_CHK:\n\t\tcase IDM_CHECKUPDATES_CHK:\n\t\tcase IDC_CHECKUPDATES_CHK:\n\t\tcase IDM_PROFILETYPE_PLAIN:\n\t\tcase IDM_PROFILETYPE_COMPRESSED:\n\t\tcase IDM_PROFILETYPE_ENCRYPTED:\n\t\tcase IDC_USENETWORKRESOLUTION_CHK:\n\t\tcase IDM_USENETWORKRESOLUTION_CHK:\n\t\tcase IDC_USECERTIFICATES_CHK:\n\t\tcase IDM_USECERTIFICATES_CHK:\n\t\tcase IDM_KEEPUNUSED_CHK:\n\t\tcase IDC_USEHASHES_CHK:\n\t\tcase IDM_USEHASHES_CHK:\n\t\tcase IDM_USEAPPMONITOR_CHK:\n\t\tcase IDM_USEDARKTHEME_CHK:\n\t\t{\n\t\t\treturn;\n\t\t}\n\t}\n\n\tif (_wfp_isfiltersinstalled ())\n\t\t_app_changefilters (hwnd, TRUE, TRUE);\n}\n\nINT_PTR CALLBACK SettingsProc (\n\t_In_ HWND hwnd,\n\t_In_ UINT msg,\n\t_In_ WPARAM wparam,\n\t_In_ LPARAM lparam\n)\n{\n\tswitch (msg)\n\t{\n\t\tcase RM_INITIALIZE:\n\t\t{\n\t\t\tINT dialog_id = (INT)wparam;\n\n\t\t\tswitch (dialog_id)\n\t\t\t{\n\t\t\t\tcase IDD_SETTINGS_GENERAL:\n\t\t\t\t{\n\t\t\t\t\t_r_ctrl_checkbutton (hwnd, IDC_ALWAYSONTOP_CHK, _r_config_getboolean (L\"AlwaysOnTop\", FALSE, NULL));\n\n#if defined(APP_HAVE_AUTORUN)\n\t\t\t\t\t_r_ctrl_checkbutton (hwnd, IDC_LOADONSTARTUP_CHK, _r_autorun_isenabled ());\n#endif // APP_HAVE_AUTORUN\n\n\t\t\t\t\t_r_ctrl_checkbutton (hwnd, IDC_STARTMINIMIZED_CHK, _r_config_getboolean (L\"IsStartMinimized\", FALSE, NULL));\n\n#if defined(APP_HAVE_SKIPUAC)\n\t\t\t\t\t_r_ctrl_checkbutton (hwnd, IDC_SKIPUACWARNING_CHK, _r_skipuac_isenabled ());\n#endif // APP_HAVE_SKIPUAC\n\n\t\t\t\t\t_r_ctrl_checkbutton (hwnd, IDC_CHECKUPDATES_CHK, _r_update_isenabled (FALSE));\n\n\t\t\t\t\t_r_locale_enum (hwnd, IDC_LANGUAGE, 0);\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDD_SETTINGS_RULES:\n\t\t\t\t{\n\t\t\t\t\tHWND htip;\n\n\t\t\t\t\t_r_ctrl_checkbutton (hwnd, IDC_RULE_BLOCKOUTBOUND, _r_config_getboolean (L\"BlockOutboundConnections\", TRUE, NULL));\n\t\t\t\t\t_r_ctrl_checkbutton (hwnd, IDC_RULE_BLOCKINBOUND, _r_config_getboolean (L\"BlockInboundConnections\", TRUE, NULL));\n\t\t\t\t\t_r_ctrl_checkbutton (hwnd, IDC_RULE_ALLOWLOOPBACK, _r_config_getboolean (L\"AllowLoopbackConnections\", TRUE, NULL));\n\t\t\t\t\t_r_ctrl_checkbutton (hwnd, IDC_RULE_ALLOW6TO4, _r_config_getboolean (L\"AllowIPv6\", TRUE, NULL));\n\t\t\t\t\t_r_ctrl_checkbutton (hwnd, IDC_USESTEALTHMODE_CHK, _r_config_getboolean (L\"UseStealthMode\", TRUE, NULL));\n\t\t\t\t\t_r_ctrl_checkbutton (hwnd, IDC_INSTALLBOOTTIMEFILTERS_CHK, _r_config_getboolean (L\"InstallBoottimeFilters\", TRUE, NULL));\n\t\t\t\t\t_r_ctrl_checkbutton (hwnd, IDC_USECERTIFICATES_CHK, _r_config_getboolean (L\"IsCertificatesEnabled\", TRUE, NULL));\n\t\t\t\t\t_r_ctrl_checkbutton (hwnd, IDC_USEHASHES_CHK, _r_config_getboolean (L\"IsHashesEnabled\", FALSE, NULL));\n\t\t\t\t\t_r_ctrl_checkbutton (hwnd, IDC_USENETWORKRESOLUTION_CHK, _r_config_getboolean (L\"IsNetworkResolutionsEnabled\", FALSE, NULL));\n\n\t\t\t\t\thtip = _r_ctrl_createtip (hwnd);\n\n\t\t\t\t\tif (!htip)\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t_r_ctrl_settiptext (htip, hwnd, IDC_RULE_BLOCKOUTBOUND, LPSTR_TEXTCALLBACK);\n\t\t\t\t\t_r_ctrl_settiptext (htip, hwnd, IDC_RULE_BLOCKINBOUND, LPSTR_TEXTCALLBACK);\n\t\t\t\t\t_r_ctrl_settiptext (htip, hwnd, IDC_RULE_ALLOWLOOPBACK, LPSTR_TEXTCALLBACK);\n\t\t\t\t\t_r_ctrl_settiptext (htip, hwnd, IDC_RULE_ALLOW6TO4, LPSTR_TEXTCALLBACK);\n\n\t\t\t\t\t_r_ctrl_settiptext (htip, hwnd, IDC_USESTEALTHMODE_CHK, LPSTR_TEXTCALLBACK);\n\t\t\t\t\t_r_ctrl_settiptext (htip, hwnd, IDC_INSTALLBOOTTIMEFILTERS_CHK, LPSTR_TEXTCALLBACK);\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDD_SETTINGS_BLOCKLIST:\n\t\t\t\t{\n\t\t\t\t\t_r_ctrl_checkradio (\n\t\t\t\t\t\thwnd,\n\t\t\t\t\t\tIDC_BLOCKLIST_SPY_DISABLE, IDC_BLOCKLIST_SPY_BLOCK, IDC_BLOCKLIST_SPY_DISABLE + _r_calc_clamp (_r_config_getlong (L\"BlocklistSpyState\", 2, NULL), 0, 2)\n\t\t\t\t\t);\n\n\t\t\t\t\t_r_ctrl_checkradio (\n\t\t\t\t\t\thwnd,\n\t\t\t\t\t\tIDC_BLOCKLIST_UPDATE_DISABLE, IDC_BLOCKLIST_UPDATE_BLOCK, IDC_BLOCKLIST_UPDATE_DISABLE + _r_calc_clamp (_r_config_getlong (L\"BlocklistUpdateState\", 0, NULL), 0, 2)\n\t\t\t\t\t);\n\n\t\t\t\t\t_r_ctrl_checkradio (\n\t\t\t\t\t\thwnd,\n\t\t\t\t\t\tIDC_BLOCKLIST_EXTRA_DISABLE, IDC_BLOCKLIST_EXTRA_BLOCK, IDC_BLOCKLIST_EXTRA_DISABLE + _r_calc_clamp (_r_config_getlong (L\"BlocklistExtraState\", 0, NULL), 0, 2)\n\t\t\t\t\t);\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDD_SETTINGS_INTERFACE:\n\t\t\t\t{\n\t\t\t\t\t_r_ctrl_checkbutton (hwnd, IDC_CONFIRMEXIT_CHK, _r_config_getboolean (L\"ConfirmExit2\", TRUE, NULL));\n\t\t\t\t\t_r_ctrl_checkbutton (hwnd, IDC_CONFIRMEXITTIMER_CHK, _r_config_getboolean (L\"ConfirmExitTimer\", TRUE, NULL));\n\t\t\t\t\t_r_ctrl_checkbutton (hwnd, IDC_CONFIRMLOGCLEAR_CHK, _r_config_getboolean (L\"ConfirmLogClear\", TRUE, NULL));\n\t\t\t\t\t_r_ctrl_checkbutton (hwnd, IDC_CONFIRMALLOW_CHK, _r_config_getboolean (L\"ConfirmAllow\", TRUE, NULL));\n\t\t\t\t\t_r_ctrl_checkbutton (hwnd, IDC_TRAYICONSINGLECLICK_CHK, _r_config_getboolean (L\"IsTrayIconSingleClick\", TRUE, NULL));\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDD_SETTINGS_HIGHLIGHTING:\n\t\t\t\t{\n\t\t\t\t\tPITEM_COLOR ptr_clr = NULL;\n\t\t\t\t\tULONG_PTR enum_key = 0;\n\t\t\t\t\tBOOLEAN val;\n\t\t\t\t\tLONG icon_id;\n\t\t\t\t\tINT item_id = 0;\n\n\t\t\t\t\t// configure listview\n\t\t\t\t\t_r_listview_setstyle (hwnd, IDC_COLORS, LVS_EX_DOUBLEBUFFER | LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP | LVS_EX_LABELTIP | LVS_EX_CHECKBOXES, FALSE);\n\n\t\t\t\t\t_app_listview_setview (hwnd, IDC_COLORS);\n\n\t\t\t\t\t_r_listview_deleteallitems (hwnd, IDC_COLORS);\n\t\t\t\t\t_r_listview_deleteallcolumns (hwnd, IDC_COLORS);\n\n\t\t\t\t\t_r_listview_addcolumn (hwnd, IDC_COLORS, 0, L\"\", 0, LVCFMT_LEFT);\n\n\t\t\t\t\ticon_id = _app_icons_getdefaultapp_id (DATA_APP_REGULAR);\n\n\t\t\t\t\t_app_listview_lock (hwnd, IDC_COLORS, TRUE);\n\n\t\t\t\t\twhile (_r_obj_enumhashtable (colors_table, (PVOID_PTR)&ptr_clr, NULL, &enum_key))\n\t\t\t\t\t{\n\t\t\t\t\t\tptr_clr->new_clr = _r_config_getulong (ptr_clr->config_value->buffer, ptr_clr->default_clr, L\"colors\");\n\n\t\t\t\t\t\t_r_listview_additem (\n\t\t\t\t\t\t\thwnd,\n\t\t\t\t\t\t\tIDC_COLORS,\n\t\t\t\t\t\t\titem_id,\n\t\t\t\t\t\t\t_r_locale_getstring (ptr_clr->locale_id),\n\t\t\t\t\t\t\ticon_id,\n\t\t\t\t\t\t\tI_GROUPIDNONE,\n\t\t\t\t\t\t\t(LPARAM)ptr_clr\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tval = _r_config_getboolean (ptr_clr->config_name->buffer, ptr_clr->is_enabled, L\"colors\");\n\n\t\t\t\t\t\t_r_listview_setitemcheck (hwnd, IDC_COLORS, item_id, val);\n\n\t\t\t\t\t\titem_id += 1;\n\t\t\t\t\t}\n\n\t\t\t\t\t_app_listview_lock (hwnd, IDC_COLORS, FALSE);\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDD_SETTINGS_NOTIFICATIONS:\n\t\t\t\t{\n\t\t\t\t\t_r_ctrl_checkbutton (hwnd, IDC_ENABLENOTIFICATIONS_CHK, _r_config_getboolean (L\"IsNotificationsEnabled\", TRUE, NULL));\n\t\t\t\t\t_r_ctrl_checkbutton (hwnd, IDC_NOTIFICATIONSOUND_CHK, _r_config_getboolean (L\"IsNotificationsSound\", TRUE, NULL));\n\t\t\t\t\t_r_ctrl_checkbutton (hwnd, IDC_NOTIFICATIONFULLSCREENSILENTMODE_CHK, _r_config_getboolean (L\"IsNotificationsFullscreenSilentMode\", TRUE, NULL));\n\t\t\t\t\t_r_ctrl_checkbutton (hwnd, IDC_NOTIFICATIONONTRAY_CHK, _r_config_getboolean (L\"IsNotificationsOnTray\", FALSE, NULL));\n\n\t\t\t\t\t_r_updown_setrange (hwnd, IDC_NOTIFICATIONTIMEOUT, 0, _r_calc_days2seconds (7));\n\n\t\t\t\t\t_r_updown_setvalue (hwnd, IDC_NOTIFICATIONTIMEOUT, _r_config_getulong (L\"NotificationsTimeout\", NOTIFY_TIMEOUT_DEFAULT, NULL));\n\n\t\t\t\t\t_r_ctrl_sendcommand (hwnd, IDC_ENABLENOTIFICATIONS_CHK, WM_APP);\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDD_SETTINGS_LOGGING:\n\t\t\t\t{\n\t\t\t\t\tPR_STRING path;\n\n\t\t\t\t\t_r_ctrl_checkbutton (hwnd, IDC_ENABLELOG_CHK, _r_config_getboolean (L\"IsLogEnabled\", FALSE, NULL));\n\n\t\t\t\t\tpath = _app_getlogpath ();\n\n\t\t\t\t\tif (path)\n\t\t\t\t\t{\n\t\t\t\t\t\t_r_ctrl_setstring (hwnd, IDC_LOGPATH, path->buffer);\n\n\t\t\t\t\t\t_r_obj_dereference (path);\n\t\t\t\t\t}\n\n\t\t\t\t\tpath = _r_config_getstringexpand (L\"LogViewer\", LOG_VIEWER_DEFAULT, NULL);\n\n\t\t\t\t\tif (path)\n\t\t\t\t\t{\n\t\t\t\t\t\t_r_ctrl_setstring (hwnd, IDC_LOGVIEWER, path->buffer);\n\n\t\t\t\t\t\t_r_obj_dereference (path);\n\t\t\t\t\t}\n\n\t\t\t\t\t_r_ctrl_setacceleration (hwnd, IDC_LOGSIZELIMIT, 64); // set step to 64kb\n\n\t\t\t\t\t_r_updown_setrange (hwnd, IDC_LOGSIZELIMIT, 64, _r_calc_kilobytes2bytes (512));\n\n\t\t\t\t\t_r_updown_setvalue (hwnd, IDC_LOGSIZELIMIT, _r_config_getulong (L\"LogSizeLimitKb\", LOG_SIZE_LIMIT_DEFAULT, NULL));\n\n\t\t\t\t\t_r_ctrl_checkbutton (hwnd, IDC_ENABLEUILOG_CHK, _r_config_getboolean (L\"IsLogUiEnabled\", FALSE, NULL));\n\n\t\t\t\t\t_r_ctrl_sendcommand (hwnd, IDC_ENABLELOG_CHK, WM_APP);\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDD_SETTINGS_EXCLUDE:\n\t\t\t\t{\n\t\t\t\t\t_r_ctrl_checkbutton (hwnd, IDC_EXCLUDEBLOCKLIST_CHK, _r_config_getboolean (L\"IsExcludeBlocklist\", TRUE, NULL));\n\t\t\t\t\t_r_ctrl_checkbutton (hwnd, IDC_EXCLUDECUSTOM_CHK, _r_config_getboolean (L\"IsExcludeCustomRules\", TRUE, NULL));\n\t\t\t\t\t_r_ctrl_checkbutton (hwnd, IDC_EXCLUDESTEALTH_CHK, _r_config_getboolean (L\"IsExcludeStealth\", TRUE, NULL));\n\t\t\t\t\t_r_ctrl_checkbutton (hwnd, IDC_EXCLUDECLASSIFYALLOW_CHK, _r_config_getboolean (L\"IsExcludeClassifyAllow\", TRUE, NULL));\n\n\t\t\t\t\t// win8+\n\t\t\t\t\tif (_r_sys_isosversionlower (WINDOWS_8))\n\t\t\t\t\t\t_r_ctrl_enable (hwnd, IDC_EXCLUDECLASSIFYALLOW_CHK, FALSE);\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase RM_LOCALIZE:\n\t\t{\n\t\t\tINT dialog_id = (INT)wparam;\n\n\t\t\t// localize titles\n\t\t\t_r_ctrl_setstringformat (\n\t\t\t\thwnd,\n\t\t\t\tIDC_TITLE_GENERAL,\n\t\t\t\tL\"%s:\",\n\t\t\t\t_r_locale_getstring (IDS_TITLE_GENERAL)\n\t\t\t);\n\n\t\t\t_r_ctrl_setstringformat (\n\t\t\t\thwnd,\n\t\t\t\tIDC_TITLE_LANGUAGE,\n\t\t\t\tL\"%s: (Language)\",\n\t\t\t\t_r_locale_getstring (IDS_TITLE_LANGUAGE)\n\t\t\t);\n\n\t\t\t_r_ctrl_setstringformat (\n\t\t\t\thwnd,\n\t\t\t\tIDC_TITLE_BLOCKLIST_SPY,\n\t\t\t\tL\"%s:\",\n\t\t\t\t_r_locale_getstring (IDS_BLOCKLIST_SPY)\n\t\t\t);\n\n\t\t\t_r_ctrl_setstringformat (\n\t\t\t\thwnd,\n\t\t\t\tIDC_TITLE_BLOCKLIST_UPDATE,\n\t\t\t\tL\"%s:\",\n\t\t\t\t_r_locale_getstring (IDS_BLOCKLIST_UPDATE)\n\t\t\t);\n\n\t\t\t_r_ctrl_setstringformat (\n\t\t\t\thwnd,\n\t\t\t\tIDC_TITLE_BLOCKLIST_EXTRA,\n\t\t\t\tL\"%s: (Skype, Bing, Live, Outlook, etc.)\",\n\t\t\t\t_r_locale_getstring (IDS_BLOCKLIST_EXTRA)\n\t\t\t);\n\n\t\t\t_r_ctrl_setstringformat (\n\t\t\t\thwnd,\n\t\t\t\tIDC_TITLE_CONNECTIONS,\n\t\t\t\tL\"%s:\",\n\t\t\t\t_r_locale_getstring (IDS_TAB_NETWORK)\n\t\t\t);\n\n\t\t\t_r_ctrl_setstringformat (\n\t\t\t\thwnd,\n\t\t\t\tIDC_TITLE_SECURITY,\n\t\t\t\tL\"%s:\",\n\t\t\t\t_r_locale_getstring (IDS_TITLE_SECURITY)\n\t\t\t);\n\n\t\t\t_r_ctrl_setstringformat (\n\t\t\t\thwnd,\n\t\t\t\tIDC_TITLE_CONFIRMATIONS,\n\t\t\t\tL\"%s:\",\n\t\t\t\t_r_locale_getstring (IDS_TITLE_CONFIRMATIONS)\n\t\t\t);\n\n\t\t\t_r_ctrl_setstringformat (\n\t\t\t\thwnd,\n\t\t\t\tIDC_TITLE_TRAY,\n\t\t\t\tL\"%s:\",\n\t\t\t\t_r_locale_getstring (IDS_TITLE_TRAY)\n\t\t\t);\n\n\t\t\t_r_ctrl_setstringformat (\n\t\t\t\thwnd,\n\t\t\t\tIDC_TITLE_HIGHLIGHTING,\n\t\t\t\tL\"%s:\",\n\t\t\t\t_r_locale_getstring (IDS_TITLE_HIGHLIGHTING)\n\t\t\t);\n\n\t\t\t_r_ctrl_setstringformat (\n\t\t\t\thwnd,\n\t\t\t\tIDC_TITLE_LOGVIEWER,\n\t\t\t\tL\"%s:\",\n\t\t\t\t_r_locale_getstring (IDS_LOGVIEWER_HINT)\n\t\t\t);\n\n\t\t\t_r_ctrl_setstringformat (\n\t\t\t\thwnd,\n\t\t\t\tIDC_TITLE_INTERFACE,\n\t\t\t\tL\"%s:\",\n\t\t\t\t_r_locale_getstring (IDS_TITLE_INTERFACE)\n\t\t\t);\n\n\t\t\t_r_ctrl_setstringformat (\n\t\t\t\thwnd,\n\t\t\t\tIDC_TITLE_NOTIFICATIONS,\n\t\t\t\tL\"%s:\",\n\t\t\t\t_r_locale_getstring (IDS_TITLE_NOTIFICATIONS)\n\t\t\t);\n\n\t\t\t_r_ctrl_setstringformat (\n\t\t\t\thwnd, IDC_TITLE_LOGGING,\n\t\t\t\tL\"%s:\",\n\t\t\t\t_r_locale_getstring (IDS_TITLE_LOGGING)\n\t\t\t);\n\n\t\t\t_r_ctrl_setstringformat (\n\t\t\t\thwnd,\n\t\t\t\tIDC_TITLE_ADVANCED,\n\t\t\t\tL\"%s:\",\n\t\t\t\t_r_locale_getstring (IDS_TITLE_ADVANCED)\n\t\t\t);\n\n\t\t\tswitch (dialog_id)\n\t\t\t{\n\t\t\t\tcase IDD_SETTINGS_GENERAL:\n\t\t\t\t{\n\t\t\t\t\t_r_ctrl_setstring (hwnd, IDC_ALWAYSONTOP_CHK, _r_locale_getstring (IDS_ALWAYSONTOP_CHK));\n\t\t\t\t\t_r_ctrl_setstring (hwnd, IDC_LOADONSTARTUP_CHK, _r_locale_getstring (IDS_LOADONSTARTUP_CHK));\n\t\t\t\t\t_r_ctrl_setstring (hwnd, IDC_STARTMINIMIZED_CHK, _r_locale_getstring (IDS_STARTMINIMIZED_CHK));\n\t\t\t\t\t_r_ctrl_setstring (hwnd, IDC_SKIPUACWARNING_CHK, _r_locale_getstring (IDS_SKIPUACWARNING_CHK));\n\t\t\t\t\t_r_ctrl_setstring (hwnd, IDC_CHECKUPDATES_CHK, _r_locale_getstring (IDS_CHECKUPDATES_CHK));\n\n\t\t\t\t\t_r_ctrl_setstring (hwnd, IDC_LANGUAGE_HINT, _r_locale_getstring (IDS_LANGUAGE_HINT));\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDD_SETTINGS_RULES:\n\t\t\t\t{\n\t\t\t\t\tLPCWSTR recommended_string;\n\n\t\t\t\t\trecommended_string = _r_locale_getstring (IDS_RECOMMENDED);\n\n\t\t\t\t\t_r_ctrl_setstringformat (\n\t\t\t\t\t\thwnd,\n\t\t\t\t\t\tIDC_RULE_BLOCKOUTBOUND,\n\t\t\t\t\t\tL\"%s (%s)\",\n\t\t\t\t\t\t_r_locale_getstring (IDS_RULE_BLOCKOUTBOUND),\n\t\t\t\t\t\trecommended_string\n\t\t\t\t\t);\n\n\t\t\t\t\t_r_ctrl_setstringformat (\n\t\t\t\t\t\thwnd,\n\t\t\t\t\t\tIDC_RULE_BLOCKINBOUND,\n\t\t\t\t\t\tL\"%s (%s)\",\n\t\t\t\t\t\t_r_locale_getstring (IDS_RULE_BLOCKINBOUND),\n\t\t\t\t\t\trecommended_string\n\t\t\t\t\t);\n\n\t\t\t\t\t_r_ctrl_setstringformat (\n\t\t\t\t\t\thwnd,\n\t\t\t\t\t\tIDC_RULE_ALLOWLOOPBACK,\n\t\t\t\t\t\tL\"%s (%s)\",\n\t\t\t\t\t\t_r_locale_getstring (IDS_RULE_ALLOWLOOPBACK),\n\t\t\t\t\t\trecommended_string\n\t\t\t\t\t);\n\n\t\t\t\t\t_r_ctrl_setstringformat (\n\t\t\t\t\t\thwnd,\n\t\t\t\t\t\tIDC_RULE_ALLOW6TO4,\n\t\t\t\t\t\tL\"%s (%s)\",\n\t\t\t\t\t\t_r_locale_getstring (IDS_RULE_ALLOW6TO4),\n\t\t\t\t\t\trecommended_string\n\t\t\t\t\t);\n\n\t\t\t\t\t_r_ctrl_setstringformat (\n\t\t\t\t\t\thwnd,\n\t\t\t\t\t\tIDC_USESTEALTHMODE_CHK,\n\t\t\t\t\t\tL\"%s (%s)\",\n\t\t\t\t\t\t_r_locale_getstring (IDS_USESTEALTHMODE_CHK),\n\t\t\t\t\t\trecommended_string\n\t\t\t\t\t);\n\n\t\t\t\t\t_r_ctrl_setstringformat (\n\t\t\t\t\t\thwnd,\n\t\t\t\t\t\tIDC_INSTALLBOOTTIMEFILTERS_CHK,\n\t\t\t\t\t\tL\"%s (%s)\",\n\t\t\t\t\t\t_r_locale_getstring (IDS_INSTALLBOOTTIMEFILTERS_CHK),\n\t\t\t\t\t\trecommended_string\n\t\t\t\t\t);\n\n\t\t\t\t\t_r_ctrl_setstring (hwnd, IDC_USECERTIFICATES_CHK, _r_locale_getstring (IDS_USECERTIFICATES_CHK));\n\t\t\t\t\t_r_ctrl_setstring (hwnd, IDC_USEHASHES_CHK, _r_locale_getstring (IDS_USEHASHES_CHK));\n\n\t\t\t\t\t_r_ctrl_setstring (\n\t\t\t\t\t\thwnd,\n\t\t\t\t\t\tIDC_USENETWORKRESOLUTION_CHK,\n\t\t\t\t\t\t_r_locale_getstring (IDS_USENETWORKRESOLUTION_CHK)\n\t\t\t\t\t);\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDD_SETTINGS_BLOCKLIST:\n\t\t\t\t{\n\t\t\t\t\tLPCWSTR recommended_string;\n\t\t\t\t\tLPCWSTR disable_string;\n\t\t\t\t\tLPCWSTR allow_string;\n\t\t\t\t\tLPCWSTR block_string;\n\n\t\t\t\t\trecommended_string = _r_locale_getstring (IDS_RECOMMENDED);\n\t\t\t\t\tdisable_string = _r_locale_getstring (IDS_DISABLE);\n\t\t\t\t\tallow_string = _r_locale_getstring (IDS_ACTION_ALLOW);\n\t\t\t\t\tblock_string = _r_locale_getstring (IDS_ACTION_BLOCK);\n\n\t\t\t\t\t_r_ctrl_setstring (hwnd, IDC_BLOCKLIST_SPY_DISABLE, disable_string);\n\t\t\t\t\t_r_ctrl_setstring (hwnd, IDC_BLOCKLIST_SPY_ALLOW, allow_string);\n\n\t\t\t\t\t_r_ctrl_setstringformat (\n\t\t\t\t\t\thwnd,\n\t\t\t\t\t\tIDC_BLOCKLIST_SPY_BLOCK,\n\t\t\t\t\t\tL\"%s (%s)\",\n\t\t\t\t\t\tblock_string,\n\t\t\t\t\t\trecommended_string\n\t\t\t\t\t);\n\n\t\t\t\t\t_r_ctrl_setstringformat (\n\t\t\t\t\t\thwnd,\n\t\t\t\t\t\tIDC_BLOCKLIST_UPDATE_DISABLE,\n\t\t\t\t\t\tL\"%s (%s)\",\n\t\t\t\t\t\tdisable_string,\n\t\t\t\t\t\trecommended_string\n\t\t\t\t\t);\n\n\t\t\t\t\t_r_ctrl_setstring (hwnd, IDC_BLOCKLIST_UPDATE_ALLOW, allow_string);\n\t\t\t\t\t_r_ctrl_setstring (hwnd, IDC_BLOCKLIST_UPDATE_BLOCK, block_string);\n\n\t\t\t\t\t_r_ctrl_setstringformat (\n\t\t\t\t\t\thwnd,\n\t\t\t\t\t\tIDC_BLOCKLIST_EXTRA_DISABLE,\n\t\t\t\t\t\tL\"%s (%s)\",\n\t\t\t\t\t\tdisable_string,\n\t\t\t\t\t\trecommended_string\n\t\t\t\t\t);\n\n\t\t\t\t\t_r_ctrl_setstring (hwnd, IDC_BLOCKLIST_EXTRA_ALLOW, allow_string);\n\t\t\t\t\t_r_ctrl_setstring (hwnd, IDC_BLOCKLIST_EXTRA_BLOCK, block_string);\n\n\t\t\t\t\t_r_ctrl_setstringformat (\n\t\t\t\t\t\thwnd,\n\t\t\t\t\t\tIDC_BLOCKLIST_INFO,\n\t\t\t\t\t\tL\"Author: <a href=\\\"%s\\\">WindowsSpyBlocker</a> - block spying and tracking on Windows systems.\",\n\t\t\t\t\t\tWINDOWSSPYBLOCKER_URL\n\t\t\t\t\t);\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDD_SETTINGS_INTERFACE:\n\t\t\t\t{\n\t\t\t\t\t_r_ctrl_setstring (hwnd, IDC_CONFIRMEXIT_CHK, _r_locale_getstring (IDS_CONFIRMEXIT_CHK));\n\t\t\t\t\t_r_ctrl_setstring (hwnd, IDC_CONFIRMEXITTIMER_CHK, _r_locale_getstring (IDS_CONFIRMEXITTIMER_CHK));\n\t\t\t\t\t_r_ctrl_setstring (hwnd, IDC_CONFIRMLOGCLEAR_CHK, _r_locale_getstring (IDS_CONFIRMLOGCLEAR_CHK));\n\t\t\t\t\t_r_ctrl_setstring (hwnd, IDC_CONFIRMALLOW_CHK, _r_locale_getstring (IDS_CONFIRMALLOW_CHK));\n\n\t\t\t\t\t_r_ctrl_setstring (\n\t\t\t\t\t\thwnd,\n\t\t\t\t\t\tIDC_TRAYICONSINGLECLICK_CHK,\n\t\t\t\t\t\t_r_locale_getstring (IDS_TRAYICONSINGLECLICK_CHK)\n\t\t\t\t\t);\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDD_SETTINGS_HIGHLIGHTING:\n\t\t\t\t{\n\t\t\t\t\tPITEM_COLOR ptr_clr;\n\n\t\t\t\t\t_r_listview_setcolumn (hwnd, IDC_COLORS, 0, NULL, -100);\n\n\t\t\t\t\tfor (INT i = 0; i < _r_listview_getitemcount (hwnd, IDC_COLORS); i++)\n\t\t\t\t\t{\n\t\t\t\t\t\tptr_clr = (PITEM_COLOR)_r_listview_getitemlparam (hwnd, IDC_COLORS, i);\n\n\t\t\t\t\t\tif (ptr_clr)\n\t\t\t\t\t\t\t_r_listview_setitem (hwnd, IDC_COLORS, i, 0, _r_locale_getstring (ptr_clr->locale_id), I_DEFAULT, I_DEFAULT, I_DEFAULT);\n\t\t\t\t\t}\n\n\t\t\t\t\t_r_ctrl_setstring (hwnd, IDC_COLORS_HINT, _r_locale_getstring (IDS_COLORS_HINT));\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDD_SETTINGS_NOTIFICATIONS:\n\t\t\t\t{\n\t\t\t\t\t_r_ctrl_setstring (\n\t\t\t\t\t\thwnd,\n\t\t\t\t\t\tIDC_ENABLENOTIFICATIONS_CHK,\n\t\t\t\t\t\t_r_locale_getstring (IDS_ENABLENOTIFICATIONS_CHK)\n\t\t\t\t\t);\n\n\t\t\t\t\t_r_ctrl_setstring (\n\t\t\t\t\t\thwnd,\n\t\t\t\t\t\tIDC_NOTIFICATIONSOUND_CHK,\n\t\t\t\t\t\t_r_locale_getstring (IDS_NOTIFICATIONSOUND_CHK)\n\t\t\t\t\t);\n\n\t\t\t\t\t_r_ctrl_setstring (\n\t\t\t\t\t\thwnd,\n\t\t\t\t\t\tIDC_NOTIFICATIONFULLSCREENSILENTMODE_CHK,\n\t\t\t\t\t\t_r_locale_getstring (IDS_NOTIFICATIONFULLSCREENSILENTMODE_CHK)\n\t\t\t\t\t);\n\n\t\t\t\t\t_r_ctrl_setstring (\n\t\t\t\t\t\thwnd,\n\t\t\t\t\t\tIDC_NOTIFICATIONONTRAY_CHK,\n\t\t\t\t\t\t_r_locale_getstring (IDS_NOTIFICATIONONTRAY_CHK)\n\t\t\t\t\t);\n\n\t\t\t\t\t_r_ctrl_setstring (\n\t\t\t\t\t\thwnd,\n\t\t\t\t\t\tIDC_NOTIFICATIONTIMEOUT_HINT,\n\t\t\t\t\t\t_r_locale_getstring (IDS_NOTIFICATIONTIMEOUT_HINT)\n\t\t\t\t\t);\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDD_SETTINGS_LOGGING:\n\t\t\t\t{\n\t\t\t\t\t_r_ctrl_setstring (hwnd, IDC_ENABLELOG_CHK, _r_locale_getstring (IDS_ENABLELOG_CHK));\n\n\t\t\t\t\t_r_ctrl_setstring (hwnd, IDC_LOGSIZELIMIT_HINT, _r_locale_getstring (IDS_LOGSIZELIMIT_HINT));\n\n\t\t\t\t\t_r_ctrl_setstringformat (\n\t\t\t\t\t\thwnd,\n\t\t\t\t\t\tIDC_ENABLEUILOG_CHK,\n\t\t\t\t\t\tL\"%s (%s)\",\n\t\t\t\t\t\t_r_locale_getstring (IDS_ENABLEUILOG_CHK),\n\t\t\t\t\t\t_r_locale_getstring (IDS_SESSION_ONLY)\n\t\t\t\t\t);\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDD_SETTINGS_EXCLUDE:\n\t\t\t\t{\n\t\t\t\t\t_r_ctrl_setstringformat (\n\t\t\t\t\t\thwnd,\n\t\t\t\t\t\tIDC_EXCLUDEBLOCKLIST_CHK,\n\t\t\t\t\t\tL\"%s %s\",\n\t\t\t\t\t\t_r_locale_getstring (IDS_TITLE_EXCLUDE),\n\t\t\t\t\t\t_r_locale_getstring (IDS_EXCLUDEBLOCKLIST_CHK)\n\t\t\t\t\t);\n\n\t\t\t\t\t_r_ctrl_setstringformat (\n\t\t\t\t\t\thwnd,\n\t\t\t\t\t\tIDC_EXCLUDECUSTOM_CHK,\n\t\t\t\t\t\tL\"%s %s\",\n\t\t\t\t\t\t_r_locale_getstring (IDS_TITLE_EXCLUDE),\n\t\t\t\t\t\t_r_locale_getstring (IDS_EXCLUDECUSTOM_CHK)\n\t\t\t\t\t);\n\n\t\t\t\t\t_r_ctrl_setstringformat (\n\t\t\t\t\t\thwnd,\n\t\t\t\t\t\tIDC_EXCLUDESTEALTH_CHK,\n\t\t\t\t\t\tL\"%s %s\",\n\t\t\t\t\t\t_r_locale_getstring (IDS_TITLE_EXCLUDE),\n\t\t\t\t\t\t_r_locale_getstring (IDS_EXCLUDESTEALTH_CHK)\n\t\t\t\t\t);\n\n\t\t\t\t\t_r_ctrl_setstringformat (\n\t\t\t\t\t\thwnd,\n\t\t\t\t\t\tIDC_EXCLUDECLASSIFYALLOW_CHK,\n\t\t\t\t\t\tL\"%s %s [win8+]\",\n\t\t\t\t\t\t_r_locale_getstring (IDS_TITLE_EXCLUDE),\n\t\t\t\t\t\t_r_locale_getstring (IDS_EXCLUDECLASSIFYALLOW_CHK)\n\t\t\t\t\t);\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase WM_SIZE:\n\t\t{\n\t\t\tRECT rect;\n\t\t\tHWND hlistview;\n\n\t\t\thlistview = GetDlgItem (hwnd, IDC_COLORS);\n\n\t\t\tif (!hlistview)\n\t\t\t\tbreak;\n\n\t\t\tif (GetClientRect (hlistview, &rect))\n\t\t\t\t_r_listview_setcolumn (hwnd, IDC_COLORS, 0, NULL, rect.right);\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase WM_VSCROLL:\n\t\tcase WM_HSCROLL:\n\t\t{\n\t\t\tLONG value;\n\t\t\tINT ctrl_id;\n\n\t\t\tctrl_id = GetDlgCtrlID ((HWND)lparam);\n\n\t\t\tif (ctrl_id == IDC_LOGSIZELIMIT)\n\t\t\t{\n\t\t\t\tvalue = _r_updown_getvalue (hwnd, ctrl_id);\n\n\t\t\t\t_r_config_setlong (L\"LogSizeLimitKb\", value, NULL);\n\t\t\t}\n\t\t\telse if (ctrl_id == IDC_NOTIFICATIONTIMEOUT)\n\t\t\t{\n\t\t\t\tvalue = _r_updown_getvalue (hwnd, ctrl_id);\n\n\t\t\t\t_r_config_setlong (L\"NotificationsTimeout\", value, NULL);\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase WM_NOTIFY:\n\t\t{\n\t\t\tLPNMHDR nmlp;\n\n\t\t\tnmlp = (LPNMHDR)lparam;\n\n\t\t\tswitch (nmlp->code)\n\t\t\t{\n\t\t\t\tcase TTN_GETDISPINFO:\n\t\t\t\t{\n\t\t\t\t\tLPNMTTDISPINFOW lpnmdi = (LPNMTTDISPINFOW)lparam;\n\t\t\t\t\tWCHAR buffer[1024] = {0};\n\t\t\t\t\tINT locale_id;\n\t\t\t\t\tINT ctrl_id;\n\n\t\t\t\t\tif ((lpnmdi->uFlags & TTF_IDISHWND) != TTF_IDISHWND)\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tctrl_id = GetDlgCtrlID ((HWND)(lpnmdi->hdr.idFrom));\n\n\t\t\t\t\tif (ctrl_id == IDC_RULE_BLOCKOUTBOUND)\n\t\t\t\t\t{\n\t\t\t\t\t\tlocale_id = IDS_RULE_BLOCKOUTBOUND;\n\t\t\t\t\t}\n\t\t\t\t\telse if (ctrl_id == IDC_RULE_BLOCKINBOUND)\n\t\t\t\t\t{\n\t\t\t\t\t\tlocale_id = IDS_RULE_BLOCKINBOUND;\n\t\t\t\t\t}\n\t\t\t\t\telse if (ctrl_id == IDC_RULE_ALLOWLOOPBACK)\n\t\t\t\t\t{\n\t\t\t\t\t\tlocale_id = IDS_RULE_ALLOWLOOPBACK_HINT;\n\t\t\t\t\t}\n\t\t\t\t\telse if (ctrl_id == IDC_USESTEALTHMODE_CHK)\n\t\t\t\t\t{\n\t\t\t\t\t\tlocale_id = IDS_USESTEALTHMODE_HINT;\n\t\t\t\t\t}\n\t\t\t\t\telse if (ctrl_id == IDC_INSTALLBOOTTIMEFILTERS_CHK)\n\t\t\t\t\t{\n\t\t\t\t\t\tlocale_id = IDS_INSTALLBOOTTIMEFILTERS_HINT;\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\t\t_r_str_copy (buffer, RTL_NUMBER_OF (buffer), _r_locale_getstring (locale_id));\n\n\t\t\t\t\tlpnmdi->lpszText = buffer;\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase LVN_ITEMCHANGED:\n\t\t\t\t{\n\t\t\t\t\tPITEM_TAB_CONTEXT tab_context;\n\t\t\t\t\tLPNMLISTVIEW lpnmlv;\n\t\t\t\t\tPITEM_COLOR ptr_clr;\n\t\t\t\t\tINT listview_id;\n\t\t\t\t\tBOOLEAN is_enabled;\n\n\t\t\t\t\tlpnmlv = (LPNMLISTVIEW)lparam;\n\t\t\t\t\tlistview_id = (INT)(INT_PTR)lpnmlv->hdr.idFrom;\n\n\t\t\t\t\tif (listview_id != IDC_COLORS)\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tif ((lpnmlv->uChanged & LVIF_STATE) == 0)\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tif ((lpnmlv->uNewState & LVIS_STATEIMAGEMASK) == INDEXTOSTATEIMAGEMASK (1) || ((lpnmlv->uNewState & LVIS_STATEIMAGEMASK) == INDEXTOSTATEIMAGEMASK (2)))\n\t\t\t\t\t{\n\t\t\t\t\t\tif (_app_listview_islocked (hwnd, (INT)(INT_PTR)lpnmlv->hdr.idFrom))\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tptr_clr = (PITEM_COLOR)lpnmlv->lParam;\n\n\t\t\t\t\t\tif (ptr_clr)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tis_enabled = (lpnmlv->uNewState & LVIS_STATEIMAGEMASK) == INDEXTOSTATEIMAGEMASK (2);\n\n\t\t\t\t\t\t\t_r_config_setboolean (ptr_clr->config_name->buffer, is_enabled, L\"colors\");\n\n\t\t\t\t\t\t\ttab_context = _app_listview_getcontext (_r_app_gethwnd (), INT_ERROR);\n\n\t\t\t\t\t\t\tif (tab_context)\n\t\t\t\t\t\t\t\t_r_listview_redraw (_r_app_gethwnd (), tab_context->listview_id);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase NM_CUSTOMDRAW:\n\t\t\t\t{\n\t\t\t\t\tLONG_PTR result;\n\n\t\t\t\t\tresult = _app_message_custdraw (hwnd, (LPNMLVCUSTOMDRAW)lparam);\n\n\t\t\t\t\tSetWindowLongPtrW (hwnd, DWLP_MSGRESULT, result);\n\n\t\t\t\t\treturn result;\n\t\t\t\t}\n\n\t\t\t\tcase NM_DBLCLK:\n\t\t\t\t{\n\t\t\t\t\tLPNMITEMACTIVATE lpnmlv;\n\t\t\t\t\tPITEM_TAB_CONTEXT tab_context;\n\t\t\t\t\tPITEM_COLOR ptr_clr_crnt;\n\t\t\t\t\tPITEM_COLOR ptr_clr = NULL;\n\t\t\t\t\tCHOOSECOLOR cc = {0};\n\t\t\t\t\tCOLORREF cust[16] = {0};\n\t\t\t\t\tULONG_PTR enum_key = 0;\n\t\t\t\t\tULONG_PTR index = 0;\n\t\t\t\t\tINT listview_id;\n\n\t\t\t\t\tlpnmlv = (LPNMITEMACTIVATE)lparam;\n\t\t\t\t\tlistview_id = (INT)(INT_PTR)lpnmlv->hdr.idFrom;\n\n\t\t\t\t\tif (lpnmlv->iItem == INT_ERROR)\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tif (listview_id != IDC_COLORS)\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tptr_clr_crnt = (PITEM_COLOR)_r_listview_getitemlparam (hwnd, listview_id, lpnmlv->iItem);\n\n\t\t\t\t\tif (!ptr_clr_crnt)\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\twhile (_r_obj_enumhashtable (colors_table, (PVOID_PTR)&ptr_clr, NULL, &enum_key))\n\t\t\t\t\t{\n\t\t\t\t\t\tcust[index++] = ptr_clr->default_clr;\n\t\t\t\t\t}\n\n\t\t\t\t\tcc.lStructSize = sizeof (CHOOSECOLOR);\n\t\t\t\t\tcc.Flags = CC_RGBINIT | CC_FULLOPEN;\n\t\t\t\t\tcc.hwndOwner = hwnd;\n\t\t\t\t\tcc.lpCustColors = cust;\n\t\t\t\t\tcc.rgbResult = ptr_clr_crnt->new_clr;\n\n\t\t\t\t\tif (ChooseColorW (&cc))\n\t\t\t\t\t{\n\t\t\t\t\t\tptr_clr_crnt->new_clr = cc.rgbResult;\n\n\t\t\t\t\t\t_r_config_setulong (ptr_clr_crnt->config_value->buffer, cc.rgbResult, L\"colors\");\n\n\t\t\t\t\t\t_r_listview_redraw (hwnd, IDC_COLORS);\n\n\t\t\t\t\t\ttab_context = _app_listview_getcontext (_r_app_gethwnd (), INT_ERROR);\n\n\t\t\t\t\t\tif (tab_context)\n\t\t\t\t\t\t\t_r_listview_redraw (_r_app_gethwnd (), tab_context->listview_id);\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase NM_CLICK:\n\t\t\t\tcase NM_RETURN:\n\t\t\t\t{\n\t\t\t\t\tPNMLINK pnmlink;\n\n\t\t\t\t\tpnmlink = (PNMLINK)lparam;\n\n\t\t\t\t\tif (!_r_str_isempty (pnmlink->item.szUrl))\n\t\t\t\t\t\t_r_shell_opendefault (pnmlink->item.szUrl);\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase WM_COMMAND:\n\t\t{\n\t\t\tINT ctrl_id = LOWORD (wparam);\n\t\t\tINT notify_code = HIWORD (wparam);\n\n\t\t\tswitch (ctrl_id)\n\t\t\t{\n\t\t\t\tcase IDC_ALWAYSONTOP_CHK:\n\t\t\t\t{\n\t\t\t\t\tBOOLEAN is_enabled;\n\n\t\t\t\t\tis_enabled = _r_ctrl_isbuttonchecked (hwnd, ctrl_id);\n\n\t\t\t\t\t_r_config_setboolean (L\"AlwaysOnTop\", is_enabled, NULL);\n\t\t\t\t\t_r_menu_checkitem (GetMenu (_r_app_gethwnd ()), IDM_ALWAYSONTOP_CHK, 0, MF_BYCOMMAND, is_enabled);\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDC_LANGUAGE:\n\t\t\t\t{\n\t\t\t\t\tif (notify_code != CBN_SELCHANGE)\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t_r_locale_apply (hwnd, ctrl_id, 0);\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDC_CONFIRMEXIT_CHK:\n\t\t\t\t{\n\t\t\t\t\t_r_config_setboolean (L\"ConfirmExit2\", _r_ctrl_isbuttonchecked (hwnd, ctrl_id), NULL);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDC_CONFIRMEXITTIMER_CHK:\n\t\t\t\t{\n\t\t\t\t\t_r_config_setboolean (L\"ConfirmExitTimer\", _r_ctrl_isbuttonchecked (hwnd, ctrl_id), NULL);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDC_CONFIRMLOGCLEAR_CHK:\n\t\t\t\t{\n\t\t\t\t\t_r_config_setboolean (L\"ConfirmLogClear\", _r_ctrl_isbuttonchecked (hwnd, ctrl_id), NULL);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDC_CONFIRMALLOW_CHK:\n\t\t\t\t{\n\t\t\t\t\t_r_config_setboolean (L\"ConfirmAllow\", _r_ctrl_isbuttonchecked (hwnd, ctrl_id), NULL);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDC_TRAYICONSINGLECLICK_CHK:\n\t\t\t\t{\n\t\t\t\t\t_r_config_setboolean (L\"IsTrayIconSingleClick\", _r_ctrl_isbuttonchecked (hwnd, ctrl_id), NULL);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDC_LOADONSTARTUP_CHK:\n\t\t\t\tcase IDC_STARTMINIMIZED_CHK:\n\t\t\t\tcase IDC_SKIPUACWARNING_CHK:\n\t\t\t\tcase IDC_CHECKUPDATES_CHK:\n\t\t\t\tcase IDC_RULE_BLOCKOUTBOUND:\n\t\t\t\tcase IDC_RULE_BLOCKINBOUND:\n\t\t\t\tcase IDC_RULE_ALLOWLOOPBACK:\n\t\t\t\tcase IDC_RULE_ALLOW6TO4:\n\t\t\t\tcase IDC_USESTEALTHMODE_CHK:\n\t\t\t\tcase IDC_INSTALLBOOTTIMEFILTERS_CHK:\n\t\t\t\tcase IDC_USECERTIFICATES_CHK:\n\t\t\t\tcase IDC_USEHASHES_CHK:\n\t\t\t\tcase IDC_USENETWORKRESOLUTION_CHK:\n\t\t\t\t{\n\t\t\t\t\t_app_config_apply (_r_app_gethwnd (), hwnd, ctrl_id);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDC_BLOCKLIST_SPY_DISABLE:\n\t\t\t\tcase IDC_BLOCKLIST_SPY_ALLOW:\n\t\t\t\tcase IDC_BLOCKLIST_SPY_BLOCK:\n\t\t\t\tcase IDC_BLOCKLIST_UPDATE_DISABLE:\n\t\t\t\tcase IDC_BLOCKLIST_UPDATE_ALLOW:\n\t\t\t\tcase IDC_BLOCKLIST_UPDATE_BLOCK:\n\t\t\t\tcase IDC_BLOCKLIST_EXTRA_DISABLE:\n\t\t\t\tcase IDC_BLOCKLIST_EXTRA_ALLOW:\n\t\t\t\tcase IDC_BLOCKLIST_EXTRA_BLOCK:\n\t\t\t\t{\n\t\t\t\t\tHMENU hmenu;\n\t\t\t\t\tLONG new_state;\n\n\t\t\t\t\thmenu = GetMenu (_r_app_gethwnd ());\n\n\t\t\t\t\tif (ctrl_id >= IDC_BLOCKLIST_SPY_DISABLE && ctrl_id <= IDC_BLOCKLIST_SPY_BLOCK)\n\t\t\t\t\t{\n\t\t\t\t\t\tnew_state = _r_calc_clamp (\n\t\t\t\t\t\t\t_r_ctrl_isradiochecked (hwnd, IDC_BLOCKLIST_SPY_DISABLE, IDC_BLOCKLIST_SPY_BLOCK) - IDC_BLOCKLIST_SPY_DISABLE,\n\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t\t2\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\t_r_menu_checkitem (hmenu, IDM_BLOCKLIST_SPY_DISABLE, IDM_BLOCKLIST_SPY_BLOCK, MF_BYCOMMAND, IDM_BLOCKLIST_SPY_DISABLE + new_state);\n\n\t\t\t\t\t\t_r_config_setlong (L\"BlocklistSpyState\", new_state, NULL);\n\n\t\t\t\t\t\t_app_ruleblocklistset (_r_app_gethwnd (), new_state, INT_ERROR, INT_ERROR, TRUE);\n\t\t\t\t\t}\n\t\t\t\t\telse if (ctrl_id >= IDC_BLOCKLIST_UPDATE_DISABLE && ctrl_id <= IDC_BLOCKLIST_UPDATE_BLOCK)\n\t\t\t\t\t{\n\t\t\t\t\t\tnew_state = _r_calc_clamp (\n\t\t\t\t\t\t\t_r_ctrl_isradiochecked (hwnd, IDC_BLOCKLIST_UPDATE_DISABLE, IDC_BLOCKLIST_UPDATE_BLOCK) - IDC_BLOCKLIST_UPDATE_DISABLE,\n\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t\t2\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\t_r_menu_checkitem (hmenu, IDM_BLOCKLIST_UPDATE_DISABLE, IDM_BLOCKLIST_UPDATE_BLOCK, MF_BYCOMMAND, IDM_BLOCKLIST_UPDATE_DISABLE + new_state);\n\n\t\t\t\t\t\t_r_config_setlong (L\"BlocklistUpdateState\", new_state, NULL);\n\n\t\t\t\t\t\t_app_ruleblocklistset (_r_app_gethwnd (), INT_ERROR, new_state, INT_ERROR, TRUE);\n\t\t\t\t\t}\n\t\t\t\t\telse if (ctrl_id >= IDC_BLOCKLIST_EXTRA_DISABLE && ctrl_id <= IDC_BLOCKLIST_EXTRA_BLOCK)\n\t\t\t\t\t{\n\t\t\t\t\t\tnew_state = _r_calc_clamp (\n\t\t\t\t\t\t\t_r_ctrl_isradiochecked (hwnd, IDC_BLOCKLIST_EXTRA_DISABLE, IDC_BLOCKLIST_EXTRA_BLOCK) - IDC_BLOCKLIST_EXTRA_DISABLE,\n\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t\t2\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\t_r_menu_checkitem (hmenu, IDM_BLOCKLIST_EXTRA_DISABLE, IDM_BLOCKLIST_EXTRA_BLOCK, MF_BYCOMMAND, IDM_BLOCKLIST_EXTRA_DISABLE + new_state);\n\n\t\t\t\t\t\t_r_config_setlong (L\"BlocklistExtraState\", new_state, NULL);\n\n\t\t\t\t\t\t_app_ruleblocklistset (_r_app_gethwnd (), INT_ERROR, INT_ERROR, new_state, TRUE);\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDC_ENABLELOG_CHK:\n\t\t\t\t{\n\t\t\t\t\tHWND hctrl;\n\t\t\t\t\tBOOLEAN is_postmessage;\n\t\t\t\t\tBOOLEAN is_enabled;\n\t\t\t\t\t//BOOLEAN is_logging_enabled;\n\n\t\t\t\t\tis_postmessage = (lparam == WM_APP);\n\t\t\t\t\tis_enabled = _r_ctrl_isbuttonchecked (hwnd, ctrl_id);\n\t\t\t\t\t//is_logging_enabled = is_enabled || _r_ctrl_isbuttonchecked (hwnd, IDC_ENABLEUILOG_CHK);\n\n\t\t\t\t\tif (!is_postmessage)\n\t\t\t\t\t{\n\t\t\t\t\t\t_r_config_setboolean (L\"IsLogEnabled\", is_enabled, NULL);\n\n\t\t\t\t\t\t_app_loginit (is_enabled);\n\t\t\t\t\t}\n\n\t\t\t\t\t_r_toolbar_pressbutton (config.hrebar, IDC_TOOLBAR, IDM_TRAY_ENABLELOG_CHK, is_enabled);\n\n\t\t\t\t\t_r_ctrl_enable (hwnd, IDC_LOGPATH, is_enabled); // input\n\t\t\t\t\t_r_ctrl_enable (hwnd, IDC_LOGPATH_BTN, is_enabled); // button\n\n\t\t\t\t\thctrl = _r_updown_getbuddy (hwnd, IDC_LOGSIZELIMIT);\n\n\t\t\t\t\tif (hctrl)\n\t\t\t\t\t\t_r_ctrl_enable (hctrl, 0, is_enabled);\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDC_ENABLEUILOG_CHK:\n\t\t\t\t{\n\t\t\t\t\tBOOLEAN is_enabled;\n\n\t\t\t\t\tis_enabled = _r_ctrl_isbuttonchecked (hwnd, ctrl_id);\n\n\t\t\t\t\t_r_config_setboolean (L\"IsLogUiEnabled\", is_enabled, NULL);\n\n\t\t\t\t\t_r_toolbar_pressbutton (config.hrebar, IDC_TOOLBAR, IDM_TRAY_ENABLEUILOG_CHK, is_enabled);\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDC_LOGPATH:\n\t\t\t\t{\n\t\t\t\t\tPR_STRING log_path;\n\n\t\t\t\t\tif (notify_code == EN_KILLFOCUS)\n\t\t\t\t\t{\n\t\t\t\t\t\tlog_path = _r_ctrl_getstring (hwnd, ctrl_id);\n\n\t\t\t\t\t\tif (log_path)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t_r_config_setstringexpand (L\"LogPath\", log_path->buffer, NULL);\n\n\t\t\t\t\t\t\tif (_r_config_getboolean (L\"IsLogEnabled\", FALSE, NULL))\n\t\t\t\t\t\t\t\t_app_loginit (TRUE);\n\n\t\t\t\t\t\t\t_r_obj_dereference (log_path);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDC_LOGPATH_BTN:\n\t\t\t\t{\n\t\t\t\t\tCOMDLG_FILTERSPEC filters[] = {\n\t\t\t\t\t\t{L\"Log files (*.log, *.csv)\", L\"*.log;*.csv\"},\n\t\t\t\t\t\t{L\"All files (*.*)\", L\"*.*\"},\n\t\t\t\t\t};\n\n\t\t\t\t\tR_FILE_DIALOG file_dialog;\n\t\t\t\t\tPR_STRING path;\n\t\t\t\t\tHRESULT status;\n\n\t\t\t\t\tstatus = _r_filedialog_initialize (&file_dialog, PR_FILEDIALOG_SAVEFILE);\n\n\t\t\t\t\tif (SUCCEEDED (status))\n\t\t\t\t\t{\n\t\t\t\t\t\t_r_filedialog_setfilter (&file_dialog, filters, RTL_NUMBER_OF (filters));\n\n\t\t\t\t\t\tpath = _r_ctrl_getstring (hwnd, IDC_LOGPATH);\n\n\t\t\t\t\t\tif (path)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t_r_filedialog_setpath (&file_dialog, &path->sr);\n\n\t\t\t\t\t\t\t_r_obj_dereference (path);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tstatus = _r_filedialog_show (hwnd, &file_dialog);\n\n\t\t\t\t\t\tif (SUCCEEDED (status))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tstatus = _r_filedialog_getpath (&file_dialog, &path);\n\n\t\t\t\t\t\t\tif (SUCCEEDED (status))\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t_r_config_setstringexpand (L\"LogPath\", path->buffer, NULL);\n\t\t\t\t\t\t\t\t_r_ctrl_setstring (hwnd, IDC_LOGPATH, path->buffer);\n\n\t\t\t\t\t\t\t\t_app_loginit (_r_config_getboolean (L\"IsLogEnabled\", FALSE, NULL));\n\n\t\t\t\t\t\t\t\t_r_obj_dereference (path);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t_r_filedialog_destroy (&file_dialog);\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDC_LOGVIEWER:\n\t\t\t\t{\n\t\t\t\t\tPR_STRING log_viewer;\n\n\t\t\t\t\tif (notify_code != EN_KILLFOCUS)\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tlog_viewer = _r_ctrl_getstring (hwnd, ctrl_id);\n\n\t\t\t\t\tif (!log_viewer)\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t_r_config_setstringexpand (L\"LogViewer\", log_viewer->buffer, NULL);\n\n\t\t\t\t\t_r_obj_dereference (log_viewer);\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDC_LOGVIEWER_BTN:\n\t\t\t\t{\n\t\t\t\t\tCOMDLG_FILTERSPEC filters[] = {\n\t\t\t\t\t\t{L\"Executable files (*.exe)\", L\"*.exe\"},\n\t\t\t\t\t\t{L\"All files (*.*)\", L\"*.*\"},\n\t\t\t\t\t};\n\n\t\t\t\t\tR_FILE_DIALOG file_dialog;\n\t\t\t\t\tPR_STRING path;\n\t\t\t\t\tHRESULT status;\n\n\t\t\t\t\tstatus = _r_filedialog_initialize (&file_dialog, PR_FILEDIALOG_OPENFILE);\n\n\t\t\t\t\tif (SUCCEEDED (status))\n\t\t\t\t\t{\n\t\t\t\t\t\t_r_filedialog_setfilter (&file_dialog, filters, RTL_NUMBER_OF (filters));\n\n\t\t\t\t\t\tpath = _r_ctrl_getstring (hwnd, IDC_LOGVIEWER);\n\n\t\t\t\t\t\tif (path)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t_r_filedialog_setpath (&file_dialog, &path->sr);\n\n\t\t\t\t\t\t\t_r_obj_dereference (path);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tstatus = _r_filedialog_show (hwnd, &file_dialog);\n\n\t\t\t\t\t\tif (SUCCEEDED (status))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tstatus = _r_filedialog_getpath (&file_dialog, &path);\n\n\t\t\t\t\t\t\tif (SUCCEEDED (status))\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t_r_config_setstringexpand (L\"LogViewer\", path->buffer, NULL);\n\t\t\t\t\t\t\t\t_r_ctrl_setstring (hwnd, IDC_LOGVIEWER, path->buffer);\n\n\t\t\t\t\t\t\t\t_r_obj_dereference (path);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t_r_filedialog_destroy (&file_dialog);\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDC_LOGSIZELIMIT_CTRL:\n\t\t\t\t{\n\t\t\t\t\tLONG value;\n\n\t\t\t\t\tif (notify_code != EN_KILLFOCUS)\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tvalue = _r_updown_getvalue (hwnd, IDC_LOGSIZELIMIT);\n\n\t\t\t\t\t_r_config_setlong (L\"LogSizeLimitKb\", value, NULL);\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDC_ENABLENOTIFICATIONS_CHK:\n\t\t\t\t{\n\t\t\t\t\tHWND hctrl;\n\t\t\t\t\tBOOLEAN is_postmessage;\n\t\t\t\t\tBOOLEAN is_enabled;\n\n\t\t\t\t\tis_postmessage = ((INT)lparam == WM_APP);\n\t\t\t\t\tis_enabled = _r_ctrl_isbuttonchecked (hwnd, ctrl_id);\n\n\t\t\t\t\tif (!is_postmessage)\n\t\t\t\t\t\t_r_config_setboolean (L\"IsNotificationsEnabled\", is_enabled, NULL);\n\n\t\t\t\t\t_r_toolbar_pressbutton (config.hrebar, IDC_TOOLBAR, IDM_TRAY_ENABLENOTIFICATIONS_CHK, is_enabled);\n\n\t\t\t\t\t_r_ctrl_enable (hwnd, IDC_NOTIFICATIONSOUND_CHK, is_enabled);\n\t\t\t\t\t_r_ctrl_enable (hwnd, IDC_NOTIFICATIONONTRAY_CHK, is_enabled);\n\n\t\t\t\t\thctrl = _r_updown_getbuddy (hwnd, IDC_NOTIFICATIONTIMEOUT);\n\n\t\t\t\t\tif (hctrl)\n\t\t\t\t\t\t_r_ctrl_enable (hctrl, 0, is_enabled);\n\n\t\t\t\t\t_r_ctrl_sendcommand (hwnd, IDC_NOTIFICATIONSOUND_CHK, WM_APP);\n\n\t\t\t\t\tif (is_postmessage)\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\thctrl = _app_notify_getwindow (NULL);\n\n\t\t\t\t\tif (hctrl)\n\t\t\t\t\t\t_app_notify_refresh (hctrl);\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDC_NOTIFICATIONSOUND_CHK:\n\t\t\t\t{\n\t\t\t\t\tBOOLEAN is_postmessage;\n\t\t\t\t\tBOOLEAN is_checked;\n\n\t\t\t\t\tis_postmessage = ((INT)lparam == WM_APP);\n\t\t\t\t\tis_checked = _r_ctrl_isbuttonchecked (hwnd, ctrl_id);\n\n\t\t\t\t\t_r_ctrl_checkbutton (hwnd, IDC_NOTIFICATIONFULLSCREENSILENTMODE_CHK, _r_config_getboolean (L\"IsNotificationsFullscreenSilentMode\", TRUE, NULL));\n\n\t\t\t\t\tif (!is_postmessage)\n\t\t\t\t\t\t_r_config_setboolean (L\"IsNotificationsSound\", is_checked, NULL);\n\n\t\t\t\t\t_r_ctrl_enable (hwnd, IDC_NOTIFICATIONFULLSCREENSILENTMODE_CHK, _r_ctrl_isenabled (hwnd, ctrl_id) && is_checked);\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDC_NOTIFICATIONFULLSCREENSILENTMODE_CHK:\n\t\t\t\t{\n\t\t\t\t\t_r_config_setboolean (L\"IsNotificationsFullscreenSilentMode\", _r_ctrl_isbuttonchecked (hwnd, ctrl_id), NULL);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDC_NOTIFICATIONONTRAY_CHK:\n\t\t\t\t{\n\t\t\t\t\tHWND hnotify;\n\n\t\t\t\t\t_r_config_setboolean (L\"IsNotificationsOnTray\", _r_ctrl_isbuttonchecked (hwnd, ctrl_id), NULL);\n\n\t\t\t\t\thnotify = _app_notify_getwindow (NULL);\n\n\t\t\t\t\tif (hnotify)\n\t\t\t\t\t\t_app_notify_setposition (hnotify, TRUE);\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDC_NOTIFICATIONTIMEOUT_CTRL:\n\t\t\t\t{\n\t\t\t\t\tif (notify_code == EN_KILLFOCUS)\n\t\t\t\t\t\t_r_config_setlong (L\"NotificationsTimeout\", _r_updown_getvalue (hwnd, IDC_NOTIFICATIONTIMEOUT), NULL);\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDC_EXCLUDESTEALTH_CHK:\n\t\t\t\t{\n\t\t\t\t\t_r_config_setboolean (L\"IsExcludeStealth\", _r_ctrl_isbuttonchecked (hwnd, ctrl_id), NULL);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDC_EXCLUDECLASSIFYALLOW_CHK:\n\t\t\t\t{\n\t\t\t\t\tHANDLE hengine;\n\n\t\t\t\t\t_r_config_setboolean (L\"IsExcludeClassifyAllow\", _r_ctrl_isbuttonchecked (hwnd, ctrl_id), NULL);\n\n\t\t\t\t\thengine = _wfp_getenginehandle ();\n\n\t\t\t\t\t_wfp_logsetoption (hengine);\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDC_EXCLUDEBLOCKLIST_CHK:\n\t\t\t\t{\n\t\t\t\t\t_r_config_setboolean (L\"IsExcludeBlocklist\", _r_ctrl_isbuttonchecked (hwnd, ctrl_id), NULL);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDC_EXCLUDECUSTOM_CHK:\n\t\t\t\t{\n\t\t\t\t\t_r_config_setboolean (L\"IsExcludeCustomRules\", _r_ctrl_isbuttonchecked (hwnd, ctrl_id), NULL);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn FALSE;\n}\n\nVOID _app_addwindowtabs (\n\t_In_ HWND hwnd\n)\n{\n\tPITEM_TAB_CONTEXT context;\n\n\t// apps profile tab\n\tcontext = _r_mem_allocate (sizeof (ITEM_TAB_CONTEXT));\n\n\tcontext->listview_id = IDC_APPS_PROFILE;\n\tcontext->locale_id = IDS_TAB_APPS;\n\n\t_r_tab_additem (hwnd, IDC_TAB, INT_MAX, L\"\", I_DEFAULT, (LPARAM)context);\n\n\t// apps services tab\n\tcontext = _r_mem_allocate (sizeof (ITEM_TAB_CONTEXT));\n\n\tcontext->listview_id = IDC_APPS_SERVICE;\n\tcontext->locale_id = IDS_TAB_SERVICES;\n\n\t_r_tab_additem (hwnd, IDC_TAB, INT_MAX, L\"\", I_DEFAULT, (LPARAM)context);\n\n\t// uwp apps (win8+)\n\tif (_r_sys_isosversiongreaterorequal (WINDOWS_8))\n\t{\n\t\tcontext = _r_mem_allocate (sizeof (ITEM_TAB_CONTEXT));\n\n\t\tcontext->listview_id = IDC_APPS_UWP;\n\t\tcontext->locale_id = IDS_TAB_PACKAGES;\n\n\t\t_r_tab_additem (hwnd, IDC_TAB, INT_MAX, L\"\", I_DEFAULT, (LPARAM)context);\n\t}\n\n\tif (!_r_config_getboolean (L\"IsInternalRulesDisabled\", FALSE, NULL))\n\t{\n\t\t// rules blocklist tab\n\t\tcontext = _r_mem_allocate (sizeof (ITEM_TAB_CONTEXT));\n\n\t\tcontext->listview_id = IDC_RULES_BLOCKLIST;\n\t\tcontext->locale_id = IDS_TRAY_BLOCKLIST_RULES;\n\n\t\t_r_tab_additem (hwnd, IDC_TAB, INT_MAX, L\"\", I_DEFAULT, (LPARAM)context);\n\n\t\t// rules system tab\n\t\tcontext = _r_mem_allocate (sizeof (ITEM_TAB_CONTEXT));\n\n\t\tcontext->listview_id = IDC_RULES_SYSTEM;\n\t\tcontext->locale_id = IDS_TRAY_SYSTEM_RULES;\n\n\t\t_r_tab_additem (hwnd, IDC_TAB, INT_MAX, L\"\", I_DEFAULT, (LPARAM)context);\n\t}\n\n\t// rules user tab\n\tcontext = _r_mem_allocate (sizeof (ITEM_TAB_CONTEXT));\n\n\tcontext->listview_id = IDC_RULES_CUSTOM;\n\tcontext->locale_id = IDS_TRAY_USER_RULES;\n\n\t_r_tab_additem (hwnd, IDC_TAB, INT_MAX, L\"\", I_DEFAULT, (LPARAM)context);\n\n\t// network tab\n\tcontext = _r_mem_allocate (sizeof (ITEM_TAB_CONTEXT));\n\n\tcontext->listview_id = IDC_NETWORK;\n\tcontext->locale_id = IDS_TAB_NETWORK;\n\n\t_r_tab_additem (hwnd, IDC_TAB, INT_MAX, L\"\", I_DEFAULT, (LPARAM)context);\n\n\t// log tab\n\tcontext = _r_mem_allocate (sizeof (ITEM_TAB_CONTEXT));\n\n\tcontext->listview_id = IDC_LOG;\n\tcontext->locale_id = IDS_TITLE_LOGGING;\n\n\t_r_tab_additem (hwnd, IDC_TAB, INT_MAX, L\"\", I_DEFAULT, (LPARAM)context);\n}\n\nVOID _app_tabs_init (\n\t_In_ HWND hwnd,\n\t_In_ LONG dpi_value\n)\n{\n\tPITEM_TAB_CONTEXT tab_context;\n\tRECT rect = {0};\n\tLONG statusbar_height;\n\tLONG rebar_height;\n\tULONG style;\n\tHWND hlistview;\n\n\tstatusbar_height = _r_status_getheight (hwnd, IDC_STATUSBAR);\n\trebar_height = _r_rebar_getheight (hwnd, IDC_REBAR);\n\n\tGetClientRect (hwnd, &rect);\n\n\tSetWindowPos (\n\t\tconfig.hrebar,\n\t\tNULL,\n\t\t0,\n\t\t0,\n\t\trect.right,\n\t\trebar_height,\n\t\tSWP_NOZORDER | SWP_NOACTIVATE | SWP_NOOWNERZORDER\n\t);\n\n\tSetWindowPos (\n\t\tGetDlgItem (hwnd, IDC_TAB),\n\t\tNULL\n\t\t,\n\t\t0,\n\t\trebar_height,\n\t\trect.right,\n\t\trect.bottom - rebar_height - statusbar_height,\n\t\tSWP_NOZORDER | SWP_NOACTIVATE | SWP_NOOWNERZORDER\n\t);\n\n\t_app_listview_loadfont (dpi_value, TRUE);\n\n\tstyle = LVS_EX_DOUBLEBUFFER | LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP | LVS_EX_LABELTIP | LVS_EX_HEADERINALLVIEWS | LVS_EX_HEADERDRAGDROP;\n\n\t_app_addwindowtabs (hwnd);\n\n\tfor (INT i = 0; i < _r_tab_getitemcount (hwnd, IDC_TAB); i++)\n\t{\n\t\ttab_context = _app_listview_getcontext (hwnd, i);\n\n\t\tif (!tab_context)\n\t\t\tcontinue;\n\n\t\thlistview = GetDlgItem (hwnd, tab_context->listview_id);\n\n\t\tif (!hlistview)\n\t\t\tcontinue;\n\n\t\t_r_tab_adjustchild (hwnd, IDC_TAB, hlistview);\n\n\t\tif (tab_context->listview_id >= IDC_APPS_PROFILE && tab_context->listview_id <= IDC_RULES_CUSTOM)\n\t\t{\n\t\t\t_r_listview_setstyle (hwnd, tab_context->listview_id, style | LVS_EX_CHECKBOXES, TRUE); // with checkboxes\n\n\t\t\tif (tab_context->listview_id >= IDC_APPS_PROFILE && tab_context->listview_id <= IDC_APPS_UWP)\n\t\t\t{\n\t\t\t\t_r_listview_addcolumn (hwnd, tab_context->listview_id, 0, L\"\", -80, LVCFMT_LEFT);\n\t\t\t\t_r_listview_addcolumn (hwnd, tab_context->listview_id, 1, L\"\", -20, LVCFMT_RIGHT);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t_r_listview_addcolumn (hwnd, tab_context->listview_id, 0, L\"\", -80, LVCFMT_LEFT);\n\t\t\t\t_r_listview_addcolumn (hwnd, tab_context->listview_id, 1, L\"\", -10, LVCFMT_RIGHT);\n\t\t\t\t_r_listview_addcolumn (hwnd, tab_context->listview_id, 2, L\"\", -10, LVCFMT_RIGHT);\n\t\t\t}\n\n\t\t\t_r_listview_addgroup (hwnd, tab_context->listview_id, 0, L\"\", 0, LVGS_COLLAPSIBLE, LVGS_COLLAPSIBLE);\n\t\t\t_r_listview_addgroup (hwnd, tab_context->listview_id, 1, L\"\", 0, LVGS_COLLAPSIBLE, LVGS_COLLAPSIBLE);\n\t\t\t_r_listview_addgroup (hwnd, tab_context->listview_id, 2, L\"\", 0, LVGS_COLLAPSIBLE, LVGS_COLLAPSIBLE);\n\t\t\t_r_listview_addgroup (hwnd, tab_context->listview_id, 3, L\"\", 0, LVGS_COLLAPSIBLE, LVGS_COLLAPSIBLE);\n\t\t\t_r_listview_addgroup (hwnd, tab_context->listview_id, 4, L\"\", 0, LVGS_COLLAPSIBLE, LVGS_COLLAPSIBLE);\n\t\t}\n\t\telse if (tab_context->listview_id == IDC_NETWORK)\n\t\t{\n\t\t\t_r_listview_setstyle (hwnd, tab_context->listview_id, style, TRUE);\n\n\t\t\t_r_listview_addcolumn (hwnd, tab_context->listview_id, 0, L\"\", -20, LVCFMT_LEFT);\n\t\t\t_r_listview_addcolumn (hwnd, tab_context->listview_id, 1, L\"\", -10, LVCFMT_LEFT);\n\t\t\t_r_listview_addcolumn (hwnd, tab_context->listview_id, 2, L\"\", -10, LVCFMT_LEFT);\n\t\t\t_r_listview_addcolumn (hwnd, tab_context->listview_id, 3, L\"\", -10, LVCFMT_RIGHT);\n\t\t\t_r_listview_addcolumn (hwnd, tab_context->listview_id, 4, L\"\", -10, LVCFMT_LEFT);\n\t\t\t_r_listview_addcolumn (hwnd, tab_context->listview_id, 5, L\"\", -10, LVCFMT_LEFT);\n\t\t\t_r_listview_addcolumn (hwnd, tab_context->listview_id, 6, L\"\", -10, LVCFMT_RIGHT);\n\t\t\t_r_listview_addcolumn (hwnd, tab_context->listview_id, 7, L\"\", -10, LVCFMT_RIGHT);\n\t\t\t_r_listview_addcolumn (hwnd, tab_context->listview_id, 8, L\"\", -10, LVCFMT_RIGHT);\n\n\t\t\t_r_listview_addgroup (hwnd, tab_context->listview_id, 0, L\"\", 0, LVGS_COLLAPSIBLE, LVGS_COLLAPSIBLE);\n\t\t\t_r_listview_addgroup (hwnd, tab_context->listview_id, 1, L\"\", 0, LVGS_COLLAPSIBLE, LVGS_COLLAPSIBLE);\n\t\t\t_r_listview_addgroup (hwnd, tab_context->listview_id, 2, L\"\", 0, LVGS_COLLAPSIBLE, LVGS_COLLAPSIBLE);\n\t\t}\n\t\telse if (tab_context->listview_id == IDC_LOG)\n\t\t{\n\t\t\t_r_listview_setstyle (hwnd, tab_context->listview_id, style, TRUE);\n\n\t\t\t_r_listview_addcolumn (hwnd, tab_context->listview_id, 0, L\"#\", -10, LVCFMT_LEFT);\n\t\t\t_r_listview_addcolumn (hwnd, tab_context->listview_id, 1, L\"\", -10, LVCFMT_LEFT);\n\t\t\t_r_listview_addcolumn (hwnd, tab_context->listview_id, 2, L\"\", -10, LVCFMT_LEFT);\n\t\t\t_r_listview_addcolumn (hwnd, tab_context->listview_id, 3, L\"\", -10, LVCFMT_LEFT);\n\t\t\t_r_listview_addcolumn (hwnd, tab_context->listview_id, 4, L\"\", -10, LVCFMT_RIGHT);\n\t\t\t_r_listview_addcolumn (hwnd, tab_context->listview_id, 5, L\"\", -10, LVCFMT_LEFT);\n\t\t\t_r_listview_addcolumn (hwnd, tab_context->listview_id, 6, L\"\", -10, LVCFMT_LEFT);\n\t\t\t_r_listview_addcolumn (hwnd, tab_context->listview_id, 7, L\"\", -10, LVCFMT_RIGHT);\n\t\t\t_r_listview_addcolumn (hwnd, tab_context->listview_id, 8, L\"\", -10, LVCFMT_LEFT);\n\t\t\t_r_listview_addcolumn (hwnd, tab_context->listview_id, 9, L\"\", -10, LVCFMT_RIGHT);\n\t\t\t_r_listview_addcolumn (hwnd, tab_context->listview_id, 10, L\"\", -10, LVCFMT_LEFT);\n\t\t\t_r_listview_addcolumn (hwnd, tab_context->listview_id, 11, L\"\", -10, LVCFMT_LEFT);\n\n\t\t\t_r_listview_addgroup (hwnd, tab_context->listview_id, 0, L\"\", 0, LVGS_COLLAPSIBLE, LVGS_COLLAPSIBLE);\n\t\t}\n\n\t\t// add filter group\n\t\t_r_listview_addgroup (hwnd, tab_context->listview_id, LV_HIDDEN_GROUP_ID, L\"\", 0, LVGS_HIDDEN | LVGS_NOHEADER | LVGS_COLLAPSED, LVGS_HIDDEN | LVGS_NOHEADER | LVGS_COLLAPSED);\n\n\t\t_app_listview_setfont (hwnd, tab_context->listview_id);\n\n\t\tBringWindowToTop (hlistview); // HACK!!!\n\t}\n}\n\nVOID _app_initialize (\n\t_In_opt_ HWND hwnd\n)\n{\n\tULONG privileges[] = {\n\t\tSE_SECURITY_PRIVILEGE,\n\t\tSE_TAKE_OWNERSHIP_PRIVILEGE,\n\t\tSE_INC_BASE_PRIORITY_PRIVILEGE,\n\t\tSE_BACKUP_PRIVILEGE,\n\t\tSE_RESTORE_PRIVILEGE,\n\t\tSE_DEBUG_PRIVILEGE,\n\t};\n\n\tR_ENVIRONMENT environment;\n\n\t// set privileges\n\t_r_sys_setprocessprivilege (NtCurrentProcess (), privileges, RTL_NUMBER_OF (privileges), TRUE);\n\n\t// set process priority\n\t_r_sys_setenvironment (&environment, PROCESS_PRIORITY_CLASS_HIGH, IoPriorityHigh, MEMORY_PRIORITY_NORMAL);\n\n\t_r_sys_setprocessenvironment (NtCurrentProcess (), &environment);\n\n\t// initialize workqueue\n\t_r_sys_setenvironment (&environment, THREAD_PRIORITY_ABOVE_NORMAL, IoPriorityHigh, MEMORY_PRIORITY_NORMAL);\n\n\t_r_workqueue_initialize (&file_queue, 12, &environment, L\"FilesQueue\");\n\t_r_workqueue_initialize (&resolve_notify_queue, 2, &environment, L\"NotificationQueue\");\n\n\t_r_sys_setenvironment (&environment, THREAD_PRIORITY_BELOW_NORMAL, IoPriorityLow, MEMORY_PRIORITY_NORMAL);\n\n\t_r_workqueue_initialize (&log_queue, 6, &environment, L\"PacketsQueue\");\n\t_r_workqueue_initialize (&resolver_queue, 6, &environment, L\"ResolverQueue\");\n\n\t_r_sys_setenvironment (&environment, THREAD_PRIORITY_HIGHEST, IoPriorityHigh, MEMORY_PRIORITY_NORMAL);\n\n\t_r_workqueue_initialize (&wfp_queue, 1, &environment, L\"FiltersQueue\");\n\n\t// static initializer\n\t_r_sys_getsystemroot (&config.windows_dir);\n\n\t_app_profile_initialize ();\n\n\tconfig.my_path = _r_obj_createstring3 (&NtCurrentPeb ()->ProcessParameters->ImagePathName);\n\n\tconfig.svchost_path = _r_obj_concatstrings (\n\t\t2,\n\t\t_r_sys_getsystemdirectory ()->buffer,\n\t\tPATH_SVCHOST\n\t);\n\n\tconfig.wusvc_path = _r_obj_concatstrings (\n\t\t2,\n\t\t_r_sys_getsystemdirectory ()->buffer,\n\t\tPATH_WUSVC\n\t);\n\n\tconfig.system_path = _r_obj_createstring (PROC_SYSTEM_NAME);\n\n\tconfig.ntoskrnl_path = _r_sys_getkernelfilename (TRUE);\n\n\tif (!config.ntoskrnl_path)\n\t\tconfig.ntoskrnl_path = _r_obj_referenceemptystring ();\n\n\tconfig.my_hash = _r_str_gethash (&config.my_path->sr, TRUE);\n\tconfig.ntoskrnl_hash = _r_str_gethash (&config.system_path->sr, TRUE);\n\tconfig.svchost_hash = _r_str_gethash (&config.svchost_path->sr, TRUE);\n\tconfig.wusvc_hash = _r_str_gethash (&config.wusvc_path->sr, TRUE);\n\n\t// initialize free list\n\t_r_freelist_initialize (&context_free_list, sizeof (ITEM_CONTEXT), 0x20);\n\t_r_freelist_initialize (&listview_free_list, sizeof (ITEM_LISTVIEW_CONTEXT), 0x800);\n\n\t// initialize colors array\n\tcolors_table = _r_obj_createhashtable (sizeof (ITEM_COLOR), 0x08, NULL);\n\n\t// initialize colors\n\tconfig.color_invalid = _app_addcolor (IDS_HIGHLIGHT_INVALID, L\"IsHighlightInvalid\", L\"ColorInvalid\", LV_COLOR_INVALID, TRUE);\n\tconfig.color_special = _app_addcolor (IDS_HIGHLIGHT_SPECIAL, L\"IsHighlightSpecial\", L\"ColorSpecial\", LV_COLOR_SPECIAL, TRUE);\n\tconfig.color_signed = _app_addcolor (IDS_HIGHLIGHT_SIGNED, L\"IsHighlightSigned\", L\"ColorSigned\", LV_COLOR_SIGNED, TRUE);\n\tconfig.color_pico = _app_addcolor (IDS_HIGHLIGHT_PICO, L\"IsHighlightPico\", L\"ColorPico\", LV_COLOR_PICO, TRUE);\n\tconfig.color_system = _app_addcolor (IDS_HIGHLIGHT_SYSTEM, L\"IsHighlightSystem\", L\"ColorSystem\", LV_COLOR_SYSTEM, TRUE);\n\tconfig.color_network = _app_addcolor (IDS_HIGHLIGHT_CONNECTION, L\"IsHighlightConnection\", L\"ColorConnection\", LV_COLOR_CONNECTION, TRUE);\n\tconfig.color_nonremovable = _app_addcolor (IDS_DISABLEREMOVAL, L\"IsHighlightUndelete\", L\"ColorUndelete\", LV_COLOR_UNDELETE, TRUE);\n\n\t_app_generate_credentials ();\n\n\t// load default icons\n\t_app_icons_getdefault ();\n\n\t// initialize global filters array object\n\tfilter_ids = _r_obj_createarray (sizeof (GUID), 0x0A, NULL);\n\n\t// initialize apps table\n\tapps_table = _r_obj_createhashtablepointer (0x20);\n\n\t// initialize rules array object\n\trules_list = _r_obj_createlist (0x0A, &_r_obj_dereference);\n\n\t// initialize rules configuration table\n\trules_config = _r_obj_createhashtable (sizeof (ITEM_RULE_CONFIG), 8, &_app_dereferenceruleconfig);\n\n\t// initialize log hashtable object\n\tlog_table = _r_obj_createhashtablepointer (0x20);\n\n\t// initialize cache table\n\tcache_information = _r_obj_createhashtablepointer (0x20);\n\n\tcache_resolution = _r_obj_createhashtablepointer (0x20);\n\n\tNtCreateEvent (&config.hnotify_evt, EVENT_ALL_ACCESS, NULL, NotificationEvent, TRUE);\n\n\tif (hwnd)\n\t\t_r_sys_createthread (NULL, NtCurrentProcess (), &_app_package_threadproc, hwnd, &environment, L\"ServicesMonitor\");\n}\n\nINT FirstDriveFromMask (\n\t_In_ ULONG unitmask\n)\n{\n\tINT i;\n\n\tfor (i = 0; i < PR_DEVICE_COUNT; ++i)\n\t{\n\t\tif (unitmask & 0x1)\n\t\t\tbreak;\n\n\t\tunitmask = unitmask >> 1;\n\t}\n\n\treturn i;\n}\n\nINT_PTR CALLBACK DlgProc (\n\t_In_ HWND hwnd,\n\t_In_ UINT msg,\n\t_In_ WPARAM wparam,\n\t_In_ LPARAM lparam\n)\n{\n\tswitch (msg)\n\t{\n\t\tcase WM_INITDIALOG:\n\t\t{\n\t\t\tWCHAR internal_profile_version[64];\n\t\t\tENUM_INSTALL_TYPE install_type;\n\t\t\tLONG dpi_value;\n\n\t\t\t// initialize vars\n\t\t\tdpi_value = _r_dc_getwindowdpi (hwnd);\n\n\t\t\t_r_app_sethwnd (hwnd); // HACK!!!\n\n\t\t\t_app_initialize (hwnd);\n\n\t\t\t// init buffered paint\n\t\t\tBufferedPaintInit ();\n\n\t\t\t// allow drag&drop support\n\t\t\tDragAcceptFiles (hwnd, TRUE);\n\n\t\t\t// restore window position (required!)\n\t\t\t_r_window_restoreposition (hwnd, L\"window\");\n\n\t\t\t// initialize imagelist\n\t\t\t_app_imagelist_init (hwnd, dpi_value);\n\n\t\t\t// initialize toolbar\n\t\t\t_app_toolbar_init (hwnd, dpi_value);\n\t\t\t_app_toolbar_resize (hwnd, dpi_value);\n\n\t\t\t// initialize tabs\n\t\t\t_app_tabs_init (hwnd, dpi_value);\n\n\t\t\t// load profile\n\t\t\t_app_profile_load (hwnd, NULL);\n\n\t\t\t// install filters\n\t\t\tinstall_type = _wfp_isfiltersinstalled ();\n\n\t\t\tif (install_type != INSTALL_DISABLED)\n\t\t\t{\n\t\t\t\tif (install_type == INSTALL_ENABLED_TEMPORARY)\n\t\t\t\t\tconfig.is_filterstemporary = TRUE;\n\n\t\t\t\t_app_changefilters (hwnd, TRUE, TRUE);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t_r_status_settext (hwnd, IDC_STATUSBAR, 0, _app_getstatelocale (install_type));\n\t\t\t}\n\n\t\t\t// initialize settings\n\t\t\t_r_settings_addpage (IDD_SETTINGS_GENERAL, IDS_SETTINGS_GENERAL);\n\t\t\t_r_settings_addpage (IDD_SETTINGS_INTERFACE, IDS_TITLE_INTERFACE);\n\t\t\t_r_settings_addpage (IDD_SETTINGS_HIGHLIGHTING, IDS_TITLE_HIGHLIGHTING);\n\t\t\t_r_settings_addpage (IDD_SETTINGS_RULES, IDS_TRAY_RULES);\n\n\t\t\tif (!_r_config_getboolean (L\"IsInternalRulesDisabled\", FALSE, NULL))\n\t\t\t\t_r_settings_addpage (IDD_SETTINGS_BLOCKLIST, IDS_TRAY_BLOCKLIST_RULES);\n\n\t\t\t// dropped packets logging (win7+)\n\t\t\t_r_settings_addpage (IDD_SETTINGS_NOTIFICATIONS, IDS_TITLE_NOTIFICATIONS);\n\t\t\t_r_settings_addpage (IDD_SETTINGS_LOGGING, IDS_TITLE_LOGGING);\n\t\t\t_r_settings_addpage (IDD_SETTINGS_EXCLUDE, IDS_TITLE_EXCLUDE);\n\n\t\t\t// add blocklist to update\n\t\t\tif (!_r_config_getboolean (L\"IsInternalRulesDisabled\", FALSE, NULL))\n\t\t\t{\n\t\t\t\t_r_str_fromlong64 (internal_profile_version, RTL_NUMBER_OF (internal_profile_version), profile_info.profile_internal_timestamp);\n\n\t\t\t\t_r_update_addcomponent (L\"Internal rules\", L\"rules_internal\", internal_profile_version, &profile_info.profile_path_internal->sr, FALSE);\n\t\t\t}\n\n\t\t\t_app_network_initialize (hwnd);\n\n\t\t\t// initialize tab\n\t\t\t_app_settab_id (hwnd, _r_config_getlong (L\"CurrentTab\", IDC_APPS_PROFILE, NULL));\n\n\t\t\t_app_fileloggingenable ();\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase RM_INITIALIZE:\n\t\t{\n\t\t\t_app_message_initialize (hwnd);\n\t\t\tbreak;\n\t\t}\n\n\t\tcase RM_UNINITIALIZE:\n\t\t{\n\t\t\t_app_message_uninitialize (hwnd);\n\t\t\tbreak;\n\t\t}\n\n\t\tcase RM_LOCALIZE:\n\t\t{\n\t\t\t_app_message_localize (hwnd);\n\t\t\tbreak;\n\t\t}\n\n\t\tcase RM_TASKBARCREATED:\n\t\t{\n\t\t\tENUM_INSTALL_TYPE install_type;\n\n\t\t\tinstall_type = _wfp_getinstalltype ();\n\n\t\t\t// refresh tray icon\n\t\t\t_r_tray_create (hwnd, &GUID_TrayIcon, RM_TRAYICON, NULL, NULL, FALSE);\n\n\t\t\t_app_settrayicon (hwnd, install_type);\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase RM_CONFIG_UPDATE:\n\t\t{\n\t\t\t_app_profile_load (hwnd, NULL);\n\n\t\t\t_app_changefilters (hwnd, TRUE, FALSE);\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase RM_CONFIG_RESET:\n\t\t{\n\t\t\t_r_queuedlock_acquireexclusive (&lock_rules_config);\n\t\t\t_r_obj_clearhashtable (rules_config);\n\t\t\t_r_queuedlock_releaseexclusive (&lock_rules_config);\n\n\t\t\t_r_path_makebackup (&profile_info.profile_path->sr, TRUE);\n\n\t\t\t_app_profile_initialize ();\n\t\t\t_app_profile_load (hwnd, NULL);\n\n\t\t\t_app_changefilters (hwnd, TRUE, FALSE);\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase RM_TRAYICON:\n\t\t{\n\t\t\tswitch (LOWORD (lparam))\n\t\t\t{\n\t\t\t\tcase NIN_KEYSELECT:\n\t\t\t\t{\n\t\t\t\t\tif (GetForegroundWindow () != hwnd)\n\t\t\t\t\t\t_r_wnd_toggle (hwnd, TRUE);\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase WM_MBUTTONUP:\n\t\t\t\t{\n\t\t\t\t\t_r_ctrl_sendcommand (hwnd, IDM_TRAY_LOGSHOW, 0);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase WM_LBUTTONUP:\n\t\t\t\t{\n\t\t\t\t\tif (_r_config_getboolean (L\"IsTrayIconSingleClick\", TRUE, NULL))\n\t\t\t\t\t{\n\t\t\t\t\t\t_r_wnd_toggle (hwnd, FALSE);\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tSetForegroundWindow (hwnd);\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase WM_LBUTTONDBLCLK:\n\t\t\t\t{\n\t\t\t\t\tif (!_r_config_getboolean (L\"IsTrayIconSingleClick\", TRUE, NULL))\n\t\t\t\t\t\t_r_wnd_toggle (hwnd, FALSE);\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase WM_CONTEXTMENU:\n\t\t\t\t{\n\t\t\t\t\t_app_message_traycontextmenu (hwnd);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase WM_NOTIFICATION:\n\t\t{\n\t\t\tPITEM_LOG ptr_log;\n\t\t\tHWND hnotify;\n\n\t\t\tif (_r_queuedlock_tryacquireexclusive (&lock_notify))\n\t\t\t{\n\t\t\t\tptr_log = _r_obj_reference ((PITEM_LOG)lparam);\n\t\t\t\thnotify = _app_notify_getwindow (ptr_log);\n\n\t\t\t\t_r_queuedlock_releaseexclusive (&lock_notify);\n\n\t\t\t\tSetWindowLongPtrW (hwnd, DWLP_MSGRESULT, (LONG_PTR)hnotify);\n\n\t\t\t\treturn (INT_PTR)hnotify;\n\t\t\t}\n\n\t\t\treturn 0;\n\t\t}\n\n\t\tcase WM_CLOSE:\n\t\t{\n\t\t\tLPCWSTR cfg_name;\n\t\t\tUINT locale_id;\n\n\t\t\tif (_wfp_isfiltersinstalled ())\n\t\t\t{\n\t\t\t\tif (_app_istimersactive ())\n\t\t\t\t{\n\t\t\t\t\tcfg_name = L\"ConfirmExitTimer\";\n\t\t\t\t\tlocale_id = IDS_QUESTION_TIMER;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tcfg_name = L\"ConfirmExit2\";\n\t\t\t\t\tlocale_id = IDS_QUESTION_EXIT;\n\t\t\t\t}\n\n\t\t\t\tif (!_r_show_confirmmessage (hwnd, _r_locale_getstring (locale_id), NULL, cfg_name, FALSE))\n\t\t\t\t{\n\t\t\t\t\tSetWindowLongPtrW (hwnd, DWLP_MSGRESULT, TRUE);\n\n\t\t\t\t\treturn TRUE;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tDestroyWindow (hwnd);\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase WM_DESTROY:\n\t\t{\n\t\t\tHANDLE hengine;\n\n\t\t\t_app_loginit (FALSE);\n\n\t\t\tif (_r_queuedlock_islocked (&lock_apply))\n\t\t\t{\n\t\t\t\t_r_workqueue_waitforfinish (&wfp_queue);\n\t\t\t\t_r_workqueue_destroy (&wfp_queue);\n\t\t\t}\n\n\t\t\t_r_tray_destroy (hwnd, &GUID_TrayIcon);\n\n\t\t\thengine = _wfp_getenginehandle ();\n\n\t\t\t_wfp_uninitialize (hengine, FALSE);\n\n\t\t\t_r_imagelist_destroy (config.himg_rules_small);\n\t\t\t_r_imagelist_destroy (config.himg_rules_large);\n\t\t\t_r_imagelist_destroy (config.himg_toolbar);\n\n\t\t\tBufferedPaintUnInit ();\n\n\t\t\tPostQuitMessage (0);\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase WM_DROPFILES:\n\t\t{\n\t\t\tPR_STRING path;\n\t\t\tHDROP hdrop;\n\t\t\tULONG app_hash = 0;\n\t\t\tULONG numfiles;\n\t\t\tULONG length;\n\n\t\t\thdrop = (HDROP)wparam;\n\t\t\tnumfiles = DragQueryFileW (hdrop, UINT32_MAX, NULL, 0);\n\n\t\t\tfor (ULONG i = 0; i < numfiles; i++)\n\t\t\t{\n\t\t\t\tlength = DragQueryFileW (hdrop, i, NULL, 0);\n\t\t\t\tpath = _r_obj_createstring_ex (NULL, length * sizeof (WCHAR));\n\n\t\t\t\tif (DragQueryFileW (hdrop, i, path->buffer, length + 1))\n\t\t\t\t{\n\t\t\t\t\t_r_str_trimtonullterminator (&path->sr);\n\n\t\t\t\t\tapp_hash = _app_addapplication (hwnd, DATA_UNKNOWN, path, NULL, NULL);\n\t\t\t\t}\n\n\t\t\t\t_r_obj_dereference (path);\n\t\t\t}\n\n\t\t\tDragFinish (hdrop);\n\n\t\t\t_app_profile_save (hwnd);\n\n\t\t\tif (!app_hash)\n\t\t\t\tbreak;\n\n\t\t\t_app_listview_updateby_param (hwnd, app_hash, PR_SETITEM_UPDATE, TRUE);\n\t\t\t_app_listview_showitemby_param (hwnd, app_hash, TRUE);\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase WM_DPICHANGED:\n\t\t{\n\t\t\t_r_wnd_message_dpichanged (hwnd, wparam, lparam);\n\n\t\t\t_app_message_dpichanged (hwnd, LOWORD (wparam));\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase WM_THEMECHANGED:\n\t\t{\n\t\t\tLONG dpi_value;\n\n\t\t\tdpi_value = _r_dc_getwindowdpi (hwnd);\n\n\t\t\t_app_windowloadfont (dpi_value);\n\t\t\t_app_listview_loadfont (dpi_value, TRUE);\n\n\t\t\t_app_listview_updateby_id (hwnd, DATA_LISTVIEW_CURRENT, PR_UPDATE_TYPE | PR_UPDATE_FORCE);\n\n\t\t\t_r_wnd_sendmessage (hwnd, 0, WM_SIZE, 0, 0);\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase WM_SIZE:\n\t\t{\n\t\t\tRECT rect;\n\t\t\tLONG dpi_value;\n\n\t\t\tif (!GetClientRect (hwnd, &rect))\n\t\t\t\tbreak;\n\n\t\t\tdpi_value = _r_dc_getwindowdpi (hwnd);\n\n\t\t\t_app_window_resize (hwnd, &rect, dpi_value);\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase WM_GETMINMAXINFO:\n\t\t{\n\t\t\tLPMINMAXINFO minmax;\n\t\t\tR_SIZE point = {0};\n\t\t\tLONG dpi_value;\n\n\t\t\tminmax = (LPMINMAXINFO)lparam;\n\n\t\t\tpoint.cx = 500;\n\t\t\tpoint.cy = 220;\n\n\t\t\tdpi_value = _r_dc_getwindowdpi (hwnd);\n\n\t\t\t_r_dc_getsizedpivalue (&point, dpi_value, TRUE);\n\n\t\t\tminmax->ptMinTrackSize.x = point.cx;\n\t\t\tminmax->ptMinTrackSize.y = point.cy;\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase WM_NOTIFY:\n\t\t{\n\t\t\tLPNMHDR nmlp;\n\n\t\t\tnmlp = (LPNMHDR)lparam;\n\n\t\t\tswitch (nmlp->code)\n\t\t\t{\n\t\t\t\tcase RBN_HEIGHTCHANGE:\n\t\t\t\t{\n\t\t\t\t\t_r_wnd_sendmessage (hwnd, 0, WM_SIZE, 0, 0);\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase TCN_SELCHANGING:\n\t\t\t\t{\n\t\t\t\t\tPITEM_TAB_CONTEXT tab_context;\n\t\t\t\t\tHWND hlistview;\n\n\t\t\t\t\ttab_context = _app_listview_getcontext (hwnd, INT_ERROR);\n\n\t\t\t\t\tif (!tab_context)\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\thlistview = GetDlgItem (hwnd, tab_context->listview_id);\n\n\t\t\t\t\tif (!hlistview)\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tShowWindow (hlistview, SW_HIDE);\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase TCN_SELCHANGE:\n\t\t\t\t{\n\t\t\t\t\tPITEM_TAB_CONTEXT tab_context;\n\t\t\t\t\tHWND hlistview;\n\n\t\t\t\t\ttab_context = _app_listview_getcontext (hwnd, INT_ERROR);\n\n\t\t\t\t\tif (!tab_context)\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\thlistview = GetDlgItem (hwnd, tab_context->listview_id);\n\n\t\t\t\t\tif (!hlistview)\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t_app_search_applyfilter (hwnd, tab_context->listview_id, config.search_string);\n\n\t\t\t\t\t_app_listview_updateby_id (hwnd, tab_context->listview_id, PR_UPDATE_FORCE | PR_UPDATE_NORESIZE);\n\n\t\t\t\t\tShowWindow (hlistview, SW_SHOWNA);\n\n\t\t\t\t\tif (_r_wnd_isvisible (hwnd, TRUE)) // HACK!!!\n\t\t\t\t\t\tSetFocus (hlistview);\n\n\t\t\t\t\t_app_listview_resize (hwnd, tab_context->listview_id, FALSE);\n\n\t\t\t\t\t_r_config_setlong (L\"CurrentTab\", tab_context->listview_id, NULL);\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase NM_CUSTOMDRAW:\n\t\t\t\t{\n\t\t\t\t\tLONG_PTR result;\n\n\t\t\t\t\tresult = _app_message_custdraw (hwnd, (LPNMLVCUSTOMDRAW)lparam);\n\n\t\t\t\t\tSetWindowLongPtrW (hwnd, DWLP_MSGRESULT, result);\n\n\t\t\t\t\treturn result;\n\t\t\t\t}\n\n\t\t\t\tcase LVN_INSERTITEM:\n\t\t\t\t{\n\t\t\t\t\tPITEM_LISTVIEW_CONTEXT context;\n\t\t\t\t\tLPNMLISTVIEW lpnmlv;\n\t\t\t\t\tINT listview_id;\n\n\t\t\t\t\tlpnmlv = (LPNMLISTVIEW)lparam;\n\t\t\t\t\tlistview_id = (INT)(INT_PTR)lpnmlv->hdr.idFrom;\n\n\t\t\t\t\tif (!(listview_id >= IDC_APPS_PROFILE && listview_id <= IDC_LOG))\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tif (_r_obj_isstringempty (config.search_string))\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcontext = (PITEM_LISTVIEW_CONTEXT)_r_listview_getitemlparam (hwnd, listview_id, lpnmlv->iItem);\n\n\t\t\t\t\tif (!context)\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t_app_search_applyfilteritem (hwnd, listview_id, lpnmlv->iItem, context, config.search_string);\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase LVN_DELETEITEM:\n\t\t\t\t{\n\t\t\t\t\tPITEM_LISTVIEW_CONTEXT context;\n\t\t\t\t\tLPNMLISTVIEW lpnmlv;\n\t\t\t\t\tINT listview_id;\n\n\t\t\t\t\tlpnmlv = (LPNMLISTVIEW)lparam;\n\t\t\t\t\tlistview_id = (INT)(INT_PTR)lpnmlv->hdr.idFrom;\n\n\t\t\t\t\tif (!(listview_id >= IDC_APPS_PROFILE && listview_id <= IDC_LOG))\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcontext = (PITEM_LISTVIEW_CONTEXT)lpnmlv->lParam;\n\n\t\t\t\t\tif (!context)\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t_app_listview_destroycontext (context);\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase LVN_COLUMNCLICK:\n\t\t\t\t{\n\t\t\t\t\tLPNMLISTVIEW lpnmlv;\n\t\t\t\t\tINT ctrl_id;\n\n\t\t\t\t\tlpnmlv = (LPNMLISTVIEW)lparam;\n\t\t\t\t\tctrl_id = (INT)(INT_PTR)lpnmlv->hdr.idFrom;\n\n\t\t\t\t\t_app_listview_sort (hwnd, ctrl_id, lpnmlv->iSubItem, TRUE);\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase LVN_GETINFOTIP:\n\t\t\t\t{\n\t\t\t\t\tLPNMLVGETINFOTIPW lpnmlv;\n\t\t\t\t\tPR_STRING string;\n\t\t\t\t\tINT listview_id;\n\n\t\t\t\t\tlpnmlv = (LPNMLVGETINFOTIPW)lparam;\n\t\t\t\t\tlistview_id = (INT)(INT_PTR)lpnmlv->hdr.idFrom;\n\n\t\t\t\t\tlparam = _app_listview_getitemcontext (hwnd, listview_id, lpnmlv->iItem);\n\n\t\t\t\t\tstring = _app_gettooltipbylparam (hwnd, listview_id, lparam);\n\n\t\t\t\t\tif (!string)\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t_r_str_copy (lpnmlv->pszText, lpnmlv->cchTextMax, string->buffer);\n\n\t\t\t\t\t_r_obj_dereference (string);\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase LVN_ITEMCHANGING:\n\t\t\t\t{\n\t\t\t\t\tLPNMLISTVIEW lpnmlv;\n\t\t\t\t\tINT listview_id;\n\t\t\t\t\tULONG_PTR app_hash;\n\n\t\t\t\t\tlpnmlv = (LPNMLISTVIEW)lparam;\n\n\t\t\t\t\tlistview_id = (INT)(INT_PTR)lpnmlv->hdr.idFrom;\n\n\t\t\t\t\tif (_app_listview_islocked (hwnd, listview_id))\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tif (!(lpnmlv->uChanged & LVIF_STATE) || !lpnmlv->lParam)\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tif ((listview_id >= IDC_APPS_PROFILE && listview_id <= IDC_APPS_UWP))\n\t\t\t\t\t{\n\t\t\t\t\t\tapp_hash = _app_listview_getcontextcode (lpnmlv->lParam);\n\n\t\t\t\t\t\tif ((lpnmlv->uNewState & LVIS_STATEIMAGEMASK) == INDEXTOSTATEIMAGEMASK (1))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif (app_hash == config.my_hash)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tif (!_r_show_confirmmessage (hwnd, L\"WARNING!\", SZ_WARNING_ME, NULL, FALSE))\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tSetWindowLongPtrW (hwnd, DWLP_MSGRESULT, TRUE);\n\n\t\t\t\t\t\t\t\t\treturn TRUE;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if ((lpnmlv->uNewState & LVIS_STATEIMAGEMASK) == INDEXTOSTATEIMAGEMASK (2))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif (app_hash == config.svchost_hash)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tif (!_r_show_confirmmessage (hwnd, L\"WARNING!\", SZ_WARNING_SVCHOST, NULL, FALSE))\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tSetWindowLongPtrW (hwnd, DWLP_MSGRESULT, TRUE);\n\n\t\t\t\t\t\t\t\t\treturn TRUE;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse if (app_hash != config.my_hash)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tif (!_r_show_confirmmessage (hwnd, NULL, _r_locale_getstring (IDS_QUESTION_ALLOW), L\"ConfirmAllow\", FALSE))\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tSetWindowLongPtrW (hwnd, DWLP_MSGRESULT, TRUE);\n\n\t\t\t\t\t\t\t\t\treturn TRUE;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase LVN_ITEMCHANGED:\n\t\t\t\t{\n\t\t\t\t\tLPNMLISTVIEW lpnmlv;\n\t\t\t\t\tHANDLE hengine;\n\t\t\t\t\tPR_LIST rules;\n\t\t\t\t\tPITEM_APP ptr_app;\n\t\t\t\t\tPITEM_RULE ptr_rule;\n\t\t\t\t\tULONG_PTR rule_idx;\n\t\t\t\t\tULONG app_hash;\n\t\t\t\t\tINT listview_id;\n\t\t\t\t\tBOOLEAN is_changed = FALSE;\n\t\t\t\t\tBOOLEAN is_enabled;\n\n\t\t\t\t\tlpnmlv = (LPNMLISTVIEW)lparam;\n\t\t\t\t\tlistview_id = (INT)(INT_PTR)lpnmlv->hdr.idFrom;\n\n\t\t\t\t\tif ((lpnmlv->uChanged & LVIF_STATE) == 0)\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tif ((lpnmlv->uNewState & LVIS_STATEIMAGEMASK) == INDEXTOSTATEIMAGEMASK (1) || ((lpnmlv->uNewState & LVIS_STATEIMAGEMASK) == INDEXTOSTATEIMAGEMASK (2)))\n\t\t\t\t\t{\n\t\t\t\t\t\tif (_app_listview_islocked (hwnd, listview_id))\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tis_enabled = (lpnmlv->uNewState & LVIS_STATEIMAGEMASK) == INDEXTOSTATEIMAGEMASK (2);\n\n\t\t\t\t\t\tif (listview_id >= IDC_APPS_PROFILE && listview_id <= IDC_APPS_UWP)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tapp_hash = (ULONG)_app_listview_getcontextcode (lpnmlv->lParam);\n\t\t\t\t\t\t\tptr_app = _app_getappitem (app_hash);\n\n\t\t\t\t\t\t\tif (!ptr_app)\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tif (ptr_app->is_enabled != is_enabled)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tptr_app->is_enabled = is_enabled;\n\n\t\t\t\t\t\t\t\t_app_listview_lock (hwnd, listview_id, TRUE);\n\t\t\t\t\t\t\t\t_app_setappiteminfo (hwnd, listview_id, lpnmlv->iItem, ptr_app);\n\t\t\t\t\t\t\t\t_app_listview_lock (hwnd, listview_id, FALSE);\n\n\t\t\t\t\t\t\t\tif (is_enabled)\n\t\t\t\t\t\t\t\t\t_app_notify_freeobject (NULL, ptr_app);\n\n\t\t\t\t\t\t\t\tif (!is_enabled && _app_istimerset (ptr_app))\n\t\t\t\t\t\t\t\t\t_app_timer_reset (hwnd, ptr_app);\n\n\t\t\t\t\t\t\t\tif (_wfp_isfiltersinstalled ())\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\thengine = _wfp_getenginehandle ();\n\n\t\t\t\t\t\t\t\t\trules = _r_obj_createlist (1, NULL);\n\n\t\t\t\t\t\t\t\t\t_r_obj_addlistitem (rules, ptr_app, NULL);\n\n\t\t\t\t\t\t\t\t\t_wfp_create3filters (hengine, rules, DBG_ARG, FALSE);\n\n\t\t\t\t\t\t\t\t\t_r_obj_dereference (rules);\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tis_changed = TRUE;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t_r_obj_dereference (ptr_app);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if (listview_id >= IDC_RULES_BLOCKLIST && listview_id <= IDC_RULES_CUSTOM)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\trule_idx = _app_listview_getcontextcode (lpnmlv->lParam);\n\t\t\t\t\t\t\tptr_rule = _app_getrulebyid (rule_idx);\n\n\t\t\t\t\t\t\tif (!ptr_rule)\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tif (ptr_rule->is_enabled != is_enabled)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t_app_listview_lock (hwnd, listview_id, TRUE);\n\n\t\t\t\t\t\t\t\t_app_ruleenable (ptr_rule, is_enabled, TRUE);\n\t\t\t\t\t\t\t\t_app_setruleiteminfo (hwnd, listview_id, lpnmlv->iItem, ptr_rule, TRUE);\n\n\t\t\t\t\t\t\t\t_app_listview_lock (hwnd, listview_id, FALSE);\n\n\t\t\t\t\t\t\t\tif (_wfp_isfiltersinstalled ())\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\thengine = _wfp_getenginehandle ();\n\n\t\t\t\t\t\t\t\t\trules = _r_obj_createlist (1, NULL);\n\n\t\t\t\t\t\t\t\t\t_r_obj_addlistitem (rules, ptr_rule, NULL);\n\n\t\t\t\t\t\t\t\t\t_wfp_create4filters (hengine, rules, DBG_ARG, FALSE);\n\n\t\t\t\t\t\t\t\t\t_r_obj_dereference (rules);\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tis_changed = TRUE;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t_r_obj_dereference (ptr_rule);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (is_changed)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t_app_listview_updateby_id (hwnd, listview_id, 0);\n\n\t\t\t\t\t\t\t_app_profile_save (hwnd);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase LVN_GETDISPINFO:\n\t\t\t\t{\n\t\t\t\t\tLPNMLVDISPINFOW lpnmlv;\n\t\t\t\t\tINT listview_id;\n\n\t\t\t\t\tlpnmlv = (LPNMLVDISPINFOW)lparam;\n\t\t\t\t\tlistview_id = (INT)(INT_PTR)lpnmlv->hdr.idFrom;\n\n\t\t\t\t\t_app_message_displayinfo (hwnd, listview_id, lpnmlv);\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase LVN_GETEMPTYMARKUP:\n\t\t\t\t{\n\t\t\t\t\tNMLVEMPTYMARKUP* lpnmlv = (NMLVEMPTYMARKUP*)lparam;\n\n\t\t\t\t\tlpnmlv->dwFlags = EMF_CENTERED;\n\n\t\t\t\t\t_r_str_copy (lpnmlv->szMarkup, RTL_NUMBER_OF (lpnmlv->szMarkup), _r_locale_getstring (IDS_STATUS_EMPTY));\n\n\t\t\t\t\tSetWindowLongPtrW (hwnd, DWLP_MSGRESULT, TRUE);\n\n\t\t\t\t\treturn TRUE;\n\t\t\t\t}\n\n\t\t\t\tcase NM_DBLCLK:\n\t\t\t\t{\n\t\t\t\t\tLPNMITEMACTIVATE lpnmlv;\n\t\t\t\t\tLPNMMOUSE lpmouse;\n\t\t\t\t\tINT command_id = 0;\n\t\t\t\t\tINT listview_id;\n\n\t\t\t\t\tlpnmlv = (LPNMITEMACTIVATE)lparam;\n\n\t\t\t\t\tif (lpnmlv->iItem == INT_ERROR)\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tlistview_id = (INT)(INT_PTR)lpnmlv->hdr.idFrom;\n\n\t\t\t\t\tif (listview_id >= IDC_APPS_PROFILE && listview_id <= IDC_LOG)\n\t\t\t\t\t{\n\t\t\t\t\t\tcommand_id = IDM_PROPERTIES;\n\t\t\t\t\t}\n\t\t\t\t\telse if (listview_id == IDC_STATUSBAR)\n\t\t\t\t\t{\n\t\t\t\t\t\tlpmouse = (LPNMMOUSE)lparam;\n\n\t\t\t\t\t\tif (lpmouse->dwItemSpec == 0)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcommand_id = IDM_SELECT_ALL;\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if (lpmouse->dwItemSpec == 1)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcommand_id = IDM_PURGE_UNUSED;\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if (lpmouse->dwItemSpec == 2)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcommand_id = IDM_PURGE_TIMERS;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (command_id)\n\t\t\t\t\t\t_r_ctrl_sendcommand (hwnd, command_id, 0);\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase NM_RCLICK:\n\t\t\t\t{\n\t\t\t\t\tLPNMITEMACTIVATE lpnmlv;\n\n\t\t\t\t\tif (nmlp->idFrom)\n\t\t\t\t\t{\n\t\t\t\t\t\tlpnmlv = (LPNMITEMACTIVATE)lparam;\n\n\t\t\t\t\t\t_app_message_contextmenu (hwnd, lpnmlv);\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\t_app_message_contextmenu_columns (hwnd, nmlp);\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase WM_POWERBROADCAST:\n\t\t{\n\t\t\tif (_wfp_isfiltersapplying ())\n\t\t\t\tbreak;\n\n\t\t\tswitch (wparam)\n\t\t\t{\n\t\t\t\tcase PBT_APMSUSPEND:\n\t\t\t\t{\n\t\t\t\t\tHANDLE engine_handle;\n\n\t\t\t\t\t_app_logclear_ui (hwnd);\n\n\t\t\t\t\tif (config.is_neteventset)\n\t\t\t\t\t{\n\t\t\t\t\t\tengine_handle = _wfp_getenginehandle ();\n\n\t\t\t\t\t\t_wfp_logunsubscribe (engine_handle);\n\t\t\t\t\t}\n\n\t\t\t\t\tSetWindowLongPtrW (hwnd, DWLP_MSGRESULT, TRUE);\n\n\t\t\t\t\treturn TRUE;\n\t\t\t\t}\n\n\t\t\t\tcase PBT_APMRESUMECRITICAL:\n\t\t\t\tcase PBT_APMRESUMESUSPEND:\n\t\t\t\t{\n\t\t\t\t\tHANDLE engine_handle;\n\n\t\t\t\t\tif (config.is_neteventset)\n\t\t\t\t\t{\n\t\t\t\t\t\tengine_handle = _wfp_getenginehandle ();\n\n\t\t\t\t\t\t_wfp_logsubscribe (hwnd, engine_handle);\n\t\t\t\t\t}\n\n\t\t\t\t\tSetWindowLongPtrW (hwnd, DWLP_MSGRESULT, TRUE);\n\n\t\t\t\t\treturn TRUE;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase WM_DEVICECHANGE:\n\t\t{\n\t\t\tswitch (wparam)\n\t\t\t{\n\t\t\t\tcase DBT_DEVICEARRIVAL:\n\t\t\t\t{\n\t\t\t\t\tPDEV_BROADCAST_HDR lbhdr;\n\t\t\t\t\tPDEV_BROADCAST_VOLUME lpdbv;\n\t\t\t\t\tBOOLEAN is_appexist;\n\n\t\t\t\t\tif (_wfp_isfiltersapplying () || !_wfp_isfiltersinstalled ())\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tlbhdr = (PDEV_BROADCAST_HDR)lparam;\n\n\t\t\t\t\tif (lbhdr && lbhdr->dbch_devicetype == DBT_DEVTYP_VOLUME)\n\t\t\t\t\t{\n\t\t\t\t\t\tlpdbv = (PDEV_BROADCAST_VOLUME)lparam;\n\n\t\t\t\t\t\tis_appexist = _app_isapphavedrive (FirstDriveFromMask (lpdbv->dbcv_unitmask));\n\n\t\t\t\t\t\tif (is_appexist)\n\t\t\t\t\t\t\t_app_changefilters (hwnd, TRUE, FALSE);\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase WM_COMMAND:\n\t\t{\n\t\t\tINT ctrl_id = LOWORD (wparam);\n\t\t\tINT notify_code = HIWORD (wparam);\n\n\t\t\tif (notify_code == EN_CHANGE)\n\t\t\t{\n\t\t\t\tPITEM_TAB_CONTEXT tab_context;\n\t\t\t\tPR_STRING string;\n\n\t\t\t\tif (ctrl_id != IDC_SEARCH)\n\t\t\t\t\tbreak;\n\n\t\t\t\ttab_context = _app_listview_getcontext (hwnd, INT_ERROR);\n\n\t\t\t\tif (!tab_context)\n\t\t\t\t\treturn 0;\n\n\t\t\t\tstring = _r_ctrl_getstring (config.hrebar, IDC_SEARCH);\n\n\t\t\t\t_r_obj_movereference ((PVOID_PTR)&config.search_string, string);\n\n\t\t\t\t_app_search_applyfilter (hwnd, tab_context->listview_id, string);\n\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\telse if (notify_code == 0)\n\t\t\t{\n\t\t\t\tif (ctrl_id >= IDX_LANGUAGE && ctrl_id <= IDX_LANGUAGE + (INT)(INT_PTR)_r_locale_getcount () + 1)\n\t\t\t\t{\n\t\t\t\t\tHMENU hsubmenu;\n\t\t\t\t\tHMENU hmenu;\n\n\t\t\t\t\thmenu = GetMenu (hwnd);\n\n\t\t\t\t\tif (hmenu)\n\t\t\t\t\t{\n\t\t\t\t\t\thsubmenu = GetSubMenu (GetSubMenu (hmenu, 2), LANG_MENU);\n\n\t\t\t\t\t\tif (hsubmenu)\n\t\t\t\t\t\t\t_r_locale_apply (hsubmenu, ctrl_id, IDX_LANGUAGE);\n\t\t\t\t\t}\n\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\telse if (ctrl_id >= IDX_RULES_SPECIAL && ctrl_id <= (IDX_RULES_SPECIAL + (INT)(INT_PTR)_r_obj_getlistsize (rules_list)))\n\t\t\t\t{\n\t\t\t\t\t_app_command_idtorules (hwnd, ctrl_id);\n\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\telse if (ctrl_id >= IDX_TIMER && ctrl_id <= (IDX_TIMER + (RTL_NUMBER_OF (timer_array) - 1)))\n\t\t\t\t{\n\t\t\t\t\t_app_command_idtotimers (hwnd, ctrl_id);\n\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tswitch (ctrl_id)\n\t\t\t{\n\t\t\t\tcase IDCANCEL: // process Esc key\n\t\t\t\t{\n\t\t\t\t\tif (GetFocus () == config.hsearchbar)\n\t\t\t\t\t{\n\t\t\t\t\t\t_r_ctrl_setstring (config.hsearchbar, 0, L\"\");\n\n\t\t\t\t\t\tSetFocus (hwnd);\n\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\t\t// fall through\n\t\t\t\t}\n\n\t\t\t\tcase IDM_TRAY_SHOW:\n\t\t\t\t{\n\t\t\t\t\t_r_wnd_toggle (hwnd, FALSE);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDM_SETTINGS:\n\t\t\t\tcase IDM_TRAY_SETTINGS:\n\t\t\t\t{\n\t\t\t\t\t_r_settings_createwindow (hwnd, &SettingsProc, 0);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDM_EXIT:\n\t\t\t\tcase IDM_TRAY_EXIT:\n\t\t\t\t{\n\t\t\t\t\t_r_wnd_sendmessage (hwnd, 0, WM_CLOSE, 0, 0);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDM_WEBSITE:\n\t\t\t\tcase IDM_TRAY_WEBSITE:\n\t\t\t\t{\n\t\t\t\t\t_r_shell_opendefault (_r_app_getwebsite_url ());\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDM_CHECKUPDATES:\n\t\t\t\t{\n\t\t\t\t\t_r_update_check (hwnd);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDM_DONATE:\n\t\t\t\t{\n\t\t\t\t\t_r_shell_opendefault (_r_app_getdonate_url ());\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDM_ABOUT:\n\t\t\t\tcase IDM_TRAY_ABOUT:\n\t\t\t\t{\n\t\t\t\t\t_r_show_aboutmessage (hwnd);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDM_IMPORT:\n\t\t\t\t{\n\t\t\t\t\tCOMDLG_FILTERSPEC filters[] = {\n\t\t\t\t\t\t{L\"Profile files (*.xml)\", L\"*.xml\"},\n\t\t\t\t\t\t{L\"All files (*.*)\", L\"*.*\"},\n\t\t\t\t\t};\n\n\t\t\t\t\tR_FILE_DIALOG file_dialog;\n\t\t\t\t\tR_STRINGREF sr;\n\t\t\t\t\tPR_STRING path;\n\t\t\t\t\tHRESULT status;\n\n\t\t\t\t\tstatus = _r_filedialog_initialize (&file_dialog, PR_FILEDIALOG_OPENFILE);\n\n\t\t\t\t\tif (SUCCEEDED (status))\n\t\t\t\t\t{\n\t\t\t\t\t\t_r_obj_initializestringref (&sr, XML_PROFILE_FILE);\n\n\t\t\t\t\t\t_r_filedialog_setfilter (&file_dialog, filters, RTL_NUMBER_OF (filters));\n\t\t\t\t\t\t_r_filedialog_setpath (&file_dialog, &sr);\n\n\t\t\t\t\t\tstatus = _r_filedialog_show (hwnd, &file_dialog);\n\n\t\t\t\t\t\tif (SUCCEEDED (status))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tstatus = _r_filedialog_getpath (&file_dialog, &path);\n\n\t\t\t\t\t\t\tif (SUCCEEDED (status))\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tstatus = _app_profile_load (hwnd, path);\n\n\t\t\t\t\t\t\t\tif (NT_SUCCESS (status))\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t_app_profile_save (hwnd);\n\n\t\t\t\t\t\t\t\t\t_app_changefilters (hwnd, TRUE, FALSE);\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t_r_obj_dereference (path);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t_r_filedialog_destroy (&file_dialog);\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDM_EXPORT:\n\t\t\t\t{\n\t\t\t\t\tCOMDLG_FILTERSPEC filters[] = {\n\t\t\t\t\t\t{L\"Profile files (*.xml)\", L\"*.xml\"},\n\t\t\t\t\t\t{L\"All files (*.*)\", L\"*.*\"},\n\t\t\t\t\t};\n\n\t\t\t\t\tR_FILE_DIALOG file_dialog;\n\t\t\t\t\tR_STRINGREF sr;\n\t\t\t\t\tPR_STRING path;\n\t\t\t\t\tNTSTATUS status;\n\n\t\t\t\t\tstatus = _r_filedialog_initialize (&file_dialog, PR_FILEDIALOG_SAVEFILE);\n\n\t\t\t\t\tif (SUCCEEDED (status))\n\t\t\t\t\t{\n\t\t\t\t\t\t_r_obj_initializestringref (&sr, XML_PROFILE_FILE);\n\n\t\t\t\t\t\t_r_filedialog_setfilter (&file_dialog, filters, RTL_NUMBER_OF (filters));\n\t\t\t\t\t\t_r_filedialog_setpath (&file_dialog, &sr);\n\n\t\t\t\t\t\tstatus = _r_filedialog_show (hwnd, &file_dialog);\n\n\t\t\t\t\t\tif (SUCCEEDED (status))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tstatus = _r_filedialog_getpath (&file_dialog, &path);\n\n\t\t\t\t\t\t\tif (SUCCEEDED (status))\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t_app_profile_save (hwnd);\n\n\t\t\t\t\t\t\t\t// added information for export profile failure (issue #707)\n\t\t\t\t\t\t\t\tstatus = _r_fs_copyfile (&profile_info.profile_path->sr, &path->sr, FALSE);\n\n\t\t\t\t\t\t\t\tif (!NT_SUCCESS (status))\n\t\t\t\t\t\t\t\t\t_r_show_errormessage (hwnd, NULL, status, path->buffer, ET_NATIVE);\n\n\t\t\t\t\t\t\t\t_r_obj_dereference (path);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t_r_filedialog_destroy (&file_dialog);\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDM_ALWAYSONTOP_CHK:\n\t\t\t\t{\n\t\t\t\t\tBOOLEAN new_val;\n\n\t\t\t\t\tnew_val = !_r_config_getboolean (L\"AlwaysOnTop\", FALSE, NULL);\n\n\t\t\t\t\t_r_menu_checkitem (GetMenu (hwnd), ctrl_id, 0, MF_BYCOMMAND, new_val);\n\t\t\t\t\t_r_config_setboolean (L\"AlwaysOnTop\", new_val, NULL);\n\n\t\t\t\t\t_r_wnd_top (hwnd, new_val);\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDM_AUTOSIZECOLUMNS_CHK:\n\t\t\t\t{\n\t\t\t\t\tPITEM_TAB_CONTEXT tab_context;\n\t\t\t\t\tBOOLEAN new_val;\n\n\t\t\t\t\tnew_val = !_r_config_getboolean (L\"AutoSizeColumns\", TRUE, NULL);\n\n\t\t\t\t\t_r_menu_checkitem (GetMenu (hwnd), ctrl_id, 0, MF_BYCOMMAND, new_val);\n\t\t\t\t\t_r_config_setboolean (L\"AutoSizeColumns\", new_val, NULL);\n\n\t\t\t\t\tif (new_val)\n\t\t\t\t\t{\n\t\t\t\t\t\ttab_context = _app_listview_getcontext (hwnd, INT_ERROR);\n\n\t\t\t\t\t\tif (tab_context)\n\t\t\t\t\t\t\t_app_listview_resize (hwnd, tab_context->listview_id, FALSE);\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDM_SHOWFILENAMESONLY_CHK:\n\t\t\t\t{\n\t\t\t\t\tPITEM_TAB_CONTEXT tab_context;\n\t\t\t\t\tBOOLEAN new_val;\n\n\t\t\t\t\tnew_val = !_r_config_getboolean (L\"ShowFilenames\", TRUE, NULL);\n\n\t\t\t\t\t_r_menu_checkitem (GetMenu (hwnd), ctrl_id, 0, MF_BYCOMMAND, new_val);\n\t\t\t\t\t_r_config_setboolean (L\"ShowFilenames\", new_val, NULL);\n\n\t\t\t\t\ttab_context = _app_listview_getcontext (hwnd, INT_ERROR);\n\n\t\t\t\t\tif (tab_context)\n\t\t\t\t\t{\n\t\t\t\t\t\t_r_listview_redraw (hwnd, tab_context->listview_id);\n\t\t\t\t\t\t_app_listview_sort (hwnd, tab_context->listview_id, INT_ERROR, FALSE);\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDM_SHOWSEARCHBAR_CHK:\n\t\t\t\t{\n\t\t\t\t\tBOOLEAN new_val;\n\n\t\t\t\t\tnew_val = !_r_config_getboolean (L\"IsShowSearchBar\", TRUE, NULL);\n\n\t\t\t\t\t_r_menu_checkitem (GetMenu (hwnd), ctrl_id, 0, MF_BYCOMMAND, new_val);\n\n\t\t\t\t\t_r_config_setboolean (L\"IsShowSearchBar\", new_val, NULL);\n\n\t\t\t\t\tif (config.hsearchbar)\n\t\t\t\t\t\t_app_search_setvisible (hwnd, config.hsearchbar, _r_dc_getwindowdpi (hwnd));\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDM_VIEW_DETAILS:\n\t\t\t\tcase IDM_VIEW_ICON:\n\t\t\t\tcase IDM_VIEW_TILE:\n\t\t\t\t{\n\t\t\t\t\tLONG view_type;\n\n\t\t\t\t\tif (ctrl_id == IDM_VIEW_ICON)\n\t\t\t\t\t{\n\t\t\t\t\t\tview_type = LV_VIEW_ICON;\n\t\t\t\t\t}\n\t\t\t\t\telse if (ctrl_id == IDM_VIEW_TILE)\n\t\t\t\t\t{\n\t\t\t\t\t\tview_type = LV_VIEW_TILE;\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tview_type = LV_VIEW_DETAILS;\n\t\t\t\t\t}\n\n\t\t\t\t\t_r_menu_checkitem (GetMenu (hwnd), IDM_VIEW_DETAILS, IDM_VIEW_TILE, MF_BYCOMMAND, ctrl_id);\n\n\t\t\t\t\t_r_config_setlong (L\"ViewType\", view_type, NULL);\n\n\t\t\t\t\t_app_listview_updateby_id (hwnd, DATA_LISTVIEW_CURRENT, PR_UPDATE_TYPE);\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDM_SIZE_SMALL:\n\t\t\t\tcase IDM_SIZE_LARGE:\n\t\t\t\tcase IDM_SIZE_EXTRALARGE:\n\t\t\t\t{\n\t\t\t\t\tLONG icon_size;\n\n\t\t\t\t\tif (ctrl_id == IDM_SIZE_LARGE)\n\t\t\t\t\t{\n\t\t\t\t\t\ticon_size = SHIL_LARGE;\n\t\t\t\t\t}\n\t\t\t\t\telse if (ctrl_id == IDM_SIZE_EXTRALARGE)\n\t\t\t\t\t{\n\t\t\t\t\t\ticon_size = SHIL_EXTRALARGE;\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\ticon_size = SHIL_SMALL;\n\t\t\t\t\t}\n\n\t\t\t\t\t_r_menu_checkitem (GetMenu (hwnd), IDM_SIZE_SMALL, IDM_SIZE_EXTRALARGE, MF_BYCOMMAND, ctrl_id);\n\n\t\t\t\t\t_r_config_setlong (L\"IconSize\", icon_size, NULL);\n\n\t\t\t\t\t_app_listview_updateby_id (hwnd, DATA_LISTVIEW_CURRENT, PR_UPDATE_TYPE);\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDM_ICONSISHIDDEN:\n\t\t\t\t{\n\t\t\t\t\tPITEM_APP ptr_app = NULL;\n\t\t\t\t\tULONG_PTR enum_key = 0;\n\t\t\t\t\tINT listview_id;\n\t\t\t\t\tBOOLEAN new_val;\n\n\t\t\t\t\tnew_val = !_r_config_getboolean (L\"IsIconsHidden\", FALSE, NULL);\n\n\t\t\t\t\t_r_menu_checkitem (GetMenu (hwnd), ctrl_id, 0, MF_BYCOMMAND, new_val);\n\t\t\t\t\t_r_config_setboolean (L\"IsIconsHidden\", new_val, NULL);\n\n\t\t\t\t\tif (!new_val)\n\t\t\t\t\t{\n\t\t\t\t\t\t_r_queuedlock_acquireshared (&lock_apps);\n\n\t\t\t\t\t\twhile (_r_obj_enumhashtablepointer (apps_table, (PVOID_PTR)&ptr_app, NULL, &enum_key))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif (!ptr_app->real_path)\n\t\t\t\t\t\t\t\tcontinue;\n\n\t\t\t\t\t\t\tlistview_id = _app_listview_getbytype (ptr_app->type);\n\n\t\t\t\t\t\t\t_app_getfileinformation (ptr_app->real_path, ptr_app->app_hash, ptr_app->type, listview_id);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t_r_queuedlock_releaseshared (&lock_apps);\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDM_FONT:\n\t\t\t\t{\n\t\t\t\t\t_app_command_selectfont (hwnd);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDM_FIND:\n\t\t\t\t{\n\t\t\t\t\tif (!config.hsearchbar || !_r_wnd_isvisible (config.hsearchbar, FALSE))\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tSetFocus (config.hsearchbar);\n\n\t\t\t\t\t_r_ctrl_setselection (config.hsearchbar, 0, 0, -1);\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDM_REFRESH:\n\t\t\t\t{\n\t\t\t\t\tif (_wfp_isfiltersapplying ())\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t_app_profile_load (hwnd, NULL);\n\t\t\t\t\t_app_changefilters (hwnd, TRUE, FALSE);\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDM_LOADONSTARTUP_CHK:\n\t\t\t\tcase IDM_STARTMINIMIZED_CHK:\n\t\t\t\tcase IDM_SKIPUACWARNING_CHK:\n\t\t\t\tcase IDM_CHECKUPDATES_CHK:\n\t\t\t\tcase IDM_RULE_BLOCKOUTBOUND:\n\t\t\t\tcase IDM_RULE_BLOCKINBOUND:\n\t\t\t\tcase IDM_RULE_ALLOWLOOPBACK:\n\t\t\t\tcase IDM_RULE_ALLOW6TO4:\n\t\t\t\tcase IDM_RULE_ALLOWWINDOWSUPDATE:\n\t\t\t\tcase IDM_PROFILETYPE_PLAIN:\n\t\t\t\tcase IDM_PROFILETYPE_COMPRESSED:\n\t\t\t\tcase IDM_PROFILETYPE_ENCRYPTED:\n\t\t\t\tcase IDM_USENETWORKRESOLUTION_CHK:\n\t\t\t\tcase IDM_USECERTIFICATES_CHK:\n\t\t\t\tcase IDM_KEEPUNUSED_CHK:\n\t\t\t\tcase IDM_USEHASHES_CHK:\n\t\t\t\tcase IDM_USEAPPMONITOR_CHK:\n\t\t\t\tcase IDM_USEDARKTHEME_CHK:\n\t\t\t\t{\n\t\t\t\t\t_app_config_apply (hwnd, NULL, ctrl_id);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDM_BLOCKLIST_SPY_DISABLE:\n\t\t\t\tcase IDM_BLOCKLIST_SPY_ALLOW:\n\t\t\t\tcase IDM_BLOCKLIST_SPY_BLOCK:\n\t\t\t\tcase IDM_BLOCKLIST_UPDATE_DISABLE:\n\t\t\t\tcase IDM_BLOCKLIST_UPDATE_ALLOW:\n\t\t\t\tcase IDM_BLOCKLIST_UPDATE_BLOCK:\n\t\t\t\tcase IDM_BLOCKLIST_EXTRA_DISABLE:\n\t\t\t\tcase IDM_BLOCKLIST_EXTRA_ALLOW:\n\t\t\t\tcase IDM_BLOCKLIST_EXTRA_BLOCK:\n\t\t\t\t{\n\t\t\t\t\tHMENU hmenu;\n\t\t\t\t\tLONG new_state;\n\n\t\t\t\t\thmenu = GetMenu (hwnd);\n\n\t\t\t\t\tif (!hmenu)\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tif (ctrl_id >= IDM_BLOCKLIST_SPY_DISABLE && ctrl_id <= IDM_BLOCKLIST_SPY_BLOCK)\n\t\t\t\t\t{\n\t\t\t\t\t\t_r_menu_checkitem (hmenu, IDM_BLOCKLIST_SPY_DISABLE, IDM_BLOCKLIST_SPY_BLOCK, MF_BYCOMMAND, ctrl_id);\n\n\t\t\t\t\t\tnew_state = _r_calc_clamp (ctrl_id - IDM_BLOCKLIST_SPY_DISABLE, 0, 2);\n\n\t\t\t\t\t\t_r_config_setlong (L\"BlocklistSpyState\", new_state, NULL);\n\n\t\t\t\t\t\t_app_ruleblocklistset (hwnd, new_state, INT_ERROR, INT_ERROR, TRUE);\n\t\t\t\t\t}\n\t\t\t\t\telse if (ctrl_id >= IDM_BLOCKLIST_UPDATE_DISABLE && ctrl_id <= IDM_BLOCKLIST_UPDATE_BLOCK)\n\t\t\t\t\t{\n\t\t\t\t\t\t_r_menu_checkitem (hmenu, IDM_BLOCKLIST_UPDATE_DISABLE, IDM_BLOCKLIST_UPDATE_BLOCK, MF_BYCOMMAND, ctrl_id);\n\n\t\t\t\t\t\tnew_state = _r_calc_clamp (ctrl_id - IDM_BLOCKLIST_UPDATE_DISABLE, 0, 2);\n\n\t\t\t\t\t\t_r_config_setlong (L\"BlocklistUpdateState\", new_state, NULL);\n\n\t\t\t\t\t\t_app_ruleblocklistset (hwnd, INT_ERROR, new_state, INT_ERROR, TRUE);\n\t\t\t\t\t}\n\t\t\t\t\telse if (ctrl_id >= IDM_BLOCKLIST_EXTRA_DISABLE && ctrl_id <= IDM_BLOCKLIST_EXTRA_BLOCK)\n\t\t\t\t\t{\n\t\t\t\t\t\t_r_menu_checkitem (hmenu, IDM_BLOCKLIST_EXTRA_DISABLE, IDM_BLOCKLIST_EXTRA_BLOCK, MF_BYCOMMAND, ctrl_id);\n\n\t\t\t\t\t\tnew_state = _r_calc_clamp (ctrl_id - IDM_BLOCKLIST_EXTRA_DISABLE, 0, 2);\n\n\t\t\t\t\t\t_r_config_setlong (L\"BlocklistExtraState\", new_state, NULL);\n\n\t\t\t\t\t\t_app_ruleblocklistset (hwnd, INT_ERROR, INT_ERROR, new_state, TRUE);\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDM_TRAY_ENABLELOG_CHK:\n\t\t\t\t{\n\t\t\t\t\tBOOLEAN new_val;\n\n\t\t\t\t\tnew_val = !_r_config_getboolean (L\"IsLogEnabled\", FALSE, NULL);\n\n\t\t\t\t\t_r_toolbar_setbutton (config.hrebar, IDC_TOOLBAR, ctrl_id, NULL, 0, new_val ? TBSTATE_PRESSED | TBSTATE_ENABLED : TBSTATE_ENABLED, I_IMAGENONE);\n\n\t\t\t\t\t_r_config_setboolean (L\"IsLogEnabled\", new_val, NULL);\n\n\t\t\t\t\t_app_loginit (new_val);\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDM_TRAY_ENABLEUILOG_CHK:\n\t\t\t\t{\n\t\t\t\t\tBOOLEAN new_val;\n\n\t\t\t\t\tnew_val = !_r_config_getboolean (L\"IsLogUiEnabled\", FALSE, NULL);\n\n\t\t\t\t\t_r_toolbar_setbutton (config.hrebar, IDC_TOOLBAR, ctrl_id, NULL, 0, new_val ? TBSTATE_PRESSED | TBSTATE_ENABLED : TBSTATE_ENABLED, I_IMAGENONE);\n\n\t\t\t\t\t_r_config_setboolean (L\"IsLogUiEnabled\", new_val, NULL);\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDM_TRAY_ENABLENOTIFICATIONS_CHK:\n\t\t\t\t{\n\t\t\t\t\tHWND hnotify;\n\t\t\t\t\tBOOLEAN new_val;\n\n\t\t\t\t\tnew_val = !_r_config_getboolean (L\"IsNotificationsEnabled\", TRUE, NULL);\n\n\t\t\t\t\t_r_toolbar_setbutton (config.hrebar, IDC_TOOLBAR, ctrl_id, NULL, 0, new_val ? TBSTATE_PRESSED | TBSTATE_ENABLED : TBSTATE_ENABLED, I_IMAGENONE);\n\n\t\t\t\t\t_r_config_setboolean (L\"IsNotificationsEnabled\", new_val, NULL);\n\n\t\t\t\t\thnotify = _app_notify_getwindow (NULL);\n\n\t\t\t\t\tif (hnotify)\n\t\t\t\t\t\t_app_notify_refresh (hnotify);\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDM_TRAY_ENABLENOTIFICATIONSSOUND_CHK:\n\t\t\t\t{\n\t\t\t\t\tBOOLEAN new_val;\n\n\t\t\t\t\tnew_val = !_r_config_getboolean (L\"IsNotificationsSound\", TRUE, NULL);\n\n\t\t\t\t\t_r_config_setboolean (L\"IsNotificationsSound\", new_val, NULL);\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDM_TRAY_NOTIFICATIONFULLSCREENSILENTMODE_CHK:\n\t\t\t\t{\n\t\t\t\t\tBOOLEAN new_val;\n\n\t\t\t\t\tnew_val = !_r_config_getboolean (L\"IsNotificationsFullscreenSilentMode\", TRUE, NULL);\n\n\t\t\t\t\t_r_config_setboolean (L\"IsNotificationsFullscreenSilentMode\", new_val, NULL);\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDM_TRAY_NOTIFICATIONONTRAY_CHK:\n\t\t\t\t{\n\t\t\t\t\tHWND hnotify;\n\t\t\t\t\tBOOLEAN new_val;\n\n\t\t\t\t\tnew_val = !_r_config_getboolean (L\"IsNotificationsOnTray\", FALSE, NULL);\n\n\t\t\t\t\t_r_config_setboolean (L\"IsNotificationsOnTray\", new_val, NULL);\n\n\t\t\t\t\thnotify = _app_notify_getwindow (NULL);\n\n\t\t\t\t\tif (hnotify)\n\t\t\t\t\t\t_app_notify_setposition (hnotify, TRUE);\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDM_TRAY_LOGSHOW:\n\t\t\t\t{\n\t\t\t\t\t_app_command_logshow (hwnd);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDM_TRAY_LOGCLEAR:\n\t\t\t\tcase IDM_LOGCLEAR:\n\t\t\t\t{\n\t\t\t\t\t_app_command_logclear (hwnd);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDM_TRAY_LOGSHOW_ERR:\n\t\t\t\t{\n\t\t\t\t\t_app_command_logerrshow (hwnd);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDM_TRAY_LOGCLEAR_ERR:\n\t\t\t\t{\n\t\t\t\t\t_app_command_logerrclear (hwnd);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDM_TRAY_START:\n\t\t\t\t{\n\t\t\t\t\tBOOLEAN is_filtersinstalled;\n\n\t\t\t\t\tif (_wfp_isfiltersapplying ())\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tis_filtersinstalled = !_wfp_isfiltersinstalled ();\n\n\t\t\t\t\tif (_app_installmessage (hwnd, is_filtersinstalled))\n\t\t\t\t\t\t_app_changefilters (hwnd, is_filtersinstalled, TRUE);\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDM_ADD_FILE:\n\t\t\t\t{\n\t\t\t\t\tCOMDLG_FILTERSPEC filters[] = {\n\t\t\t\t\t\t{L\"Executable files (*.exe)\", L\"*.exe\"},\n\t\t\t\t\t\t{L\"All files (*.*)\", L\"*.*\"},\n\t\t\t\t\t};\n\n\t\t\t\t\tR_FILE_DIALOG file_dialog;\n\t\t\t\t\tPR_STRING path;\n\t\t\t\t\tULONG_PTR app_hash;\n\t\t\t\t\tHRESULT status;\n\n\t\t\t\t\tstatus = _r_filedialog_initialize (&file_dialog, PR_FILEDIALOG_OPENFILE);\n\n\t\t\t\t\tif (SUCCEEDED (status))\n\t\t\t\t\t{\n\t\t\t\t\t\t_r_filedialog_setfilter (&file_dialog, filters, RTL_NUMBER_OF (filters));\n\n\t\t\t\t\t\tstatus = _r_filedialog_show (hwnd, &file_dialog);\n\n\t\t\t\t\t\tif (SUCCEEDED (status))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tstatus = _r_filedialog_getpath (&file_dialog, &path);\n\n\t\t\t\t\t\t\tif (SUCCEEDED (status))\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tapp_hash = _app_addapplication (hwnd, DATA_UNKNOWN, path, NULL, NULL);\n\n\t\t\t\t\t\t\t\tif (app_hash)\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t_app_listview_updateby_param (hwnd, app_hash, PR_SETITEM_UPDATE, TRUE);\n\t\t\t\t\t\t\t\t\t_app_listview_showitemby_param (hwnd, app_hash, TRUE);\n\n\t\t\t\t\t\t\t\t\t_app_profile_save (hwnd);\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t_r_obj_dereference (path);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t_r_filedialog_destroy (&file_dialog);\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDM_DISABLENOTIFICATIONS:\n\t\t\t\tcase IDM_DISABLEREMOVAL:\n\t\t\t\tcase IDM_DISABLETIMER:\n\t\t\t\t{\n\t\t\t\t\t_app_command_disable (hwnd, ctrl_id);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDM_COPY:\n\t\t\t\tcase IDM_COPY_VALUE:\n\t\t\t\t{\n\t\t\t\t\t_app_command_copy (hwnd, ctrl_id, (INT)lparam);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDM_EXPLORE:\n\t\t\t\t{\n\t\t\t\t\tPITEM_TAB_CONTEXT tab_context;\n\t\t\t\t\tPITEM_NETWORK ptr_network;\n\t\t\t\t\tPITEM_APP ptr_app;\n\t\t\t\t\tPITEM_LOG ptr_log;\n\t\t\t\t\tULONG hash_code;\n\t\t\t\t\tINT item_id = INT_ERROR;\n\t\t\t\t\tHRESULT status;\n\n\t\t\t\t\ttab_context = _app_listview_getcontext (hwnd, INT_ERROR);\n\n\t\t\t\t\tif (!tab_context)\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tif (tab_context->listview_id >= IDC_APPS_PROFILE && tab_context->listview_id <= IDC_APPS_UWP)\n\t\t\t\t\t{\n\t\t\t\t\t\twhile ((item_id = _r_listview_getnextselected (hwnd, tab_context->listview_id, item_id)) != INT_ERROR)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\thash_code = (ULONG)_app_listview_getitemcontext (hwnd, tab_context->listview_id, item_id);\n\t\t\t\t\t\t\tptr_app = _app_getappitem (hash_code);\n\n\t\t\t\t\t\t\tif (ptr_app)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tif (ptr_app->real_path)\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tif (_app_isappvalidpath (ptr_app->real_path))\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tstatus = _r_shell_showfile (&ptr_app->real_path->sr);\n\n\t\t\t\t\t\t\t\t\t\tif (FAILED (status))\n\t\t\t\t\t\t\t\t\t\t\t_r_show_errormessage (hwnd, L\"Cannot open file!\", status, ptr_app->real_path->buffer, ET_WINDOWS);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t_r_obj_dereference (ptr_app);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\telse if (tab_context->listview_id == IDC_NETWORK)\n\t\t\t\t\t{\n\t\t\t\t\t\twhile ((item_id = _r_listview_getnextselected (hwnd, tab_context->listview_id, item_id)) != INT_ERROR)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\thash_code = (ULONG)_app_listview_getitemcontext (hwnd, tab_context->listview_id, item_id);\n\t\t\t\t\t\t\tptr_network = _app_network_getitem (hash_code);\n\n\t\t\t\t\t\t\tif (ptr_network)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tif (ptr_network->path)\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tif (_app_isappvalidpath (ptr_network->path))\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tstatus = _r_shell_showfile (&ptr_network->path->sr);\n\n\t\t\t\t\t\t\t\t\t\tif (FAILED (status))\n\t\t\t\t\t\t\t\t\t\t\t_r_show_errormessage (hwnd, L\"Cannot open file!\", status, ptr_network->path->buffer, ET_WINDOWS);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t_r_obj_dereference (ptr_network);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\telse if (tab_context->listview_id == IDC_LOG)\n\t\t\t\t\t{\n\t\t\t\t\t\twhile ((item_id = _r_listview_getnextselected (hwnd, tab_context->listview_id, item_id)) != INT_ERROR)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\thash_code = (ULONG)_app_listview_getitemcontext (hwnd, tab_context->listview_id, item_id);\n\t\t\t\t\t\t\tptr_log = _app_getlogitem (hash_code);\n\n\t\t\t\t\t\t\tif (ptr_log)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tif (ptr_log->path)\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tif (_app_isappvalidpath (ptr_log->path))\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tstatus = _r_shell_showfile (&ptr_log->path->sr);\n\n\t\t\t\t\t\t\t\t\t\tif (FAILED (status))\n\t\t\t\t\t\t\t\t\t\t\t_r_show_errormessage (hwnd, L\"Cannot open file!\", status, ptr_log->path->buffer, ET_WINDOWS);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t_r_obj_dereference (ptr_log);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDM_OPENRULESEDITOR:\n\t\t\t\t{\n\t\t\t\t\t_app_command_openeditor (hwnd);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDM_CHECK:\n\t\t\t\tcase IDM_UNCHECK:\n\t\t\t\t{\n\t\t\t\t\t_app_command_checkbox (hwnd, ctrl_id);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDM_DELETE:\n\t\t\t\t{\n\t\t\t\t\t_app_command_delete (hwnd);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDM_PROPERTIES:\n\t\t\t\t{\n\t\t\t\t\t_app_command_properties (hwnd);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDM_PURGE_UNUSED:\n\t\t\t\t{\n\t\t\t\t\t_app_command_purgeunused (hwnd);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDM_PURGE_TIMERS:\n\t\t\t\t{\n\t\t\t\t\t_app_command_purgetimers (hwnd);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDM_SELECT_ALL:\n\t\t\t\t{\n\t\t\t\t\tPITEM_TAB_CONTEXT tab_context;\n\n\t\t\t\t\ttab_context = _app_listview_getcontext (hwnd, INT_ERROR);\n\n\t\t\t\t\tif (!tab_context)\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tif (GetFocus () == GetDlgItem (hwnd, tab_context->listview_id))\n\t\t\t\t\t\t_r_listview_setitemstate (hwnd, tab_context->listview_id, INT_ERROR, LVIS_SELECTED, LVIS_SELECTED);\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDM_ZOOM:\n\t\t\t\t{\n\t\t\t\t\tShowWindow (hwnd, IsZoomed (hwnd) ? SW_RESTORE : SW_MAXIMIZE);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase IDM_TAB_NEXT:\n\t\t\t\tcase IDM_TAB_PREV:\n\t\t\t\t{\n\t\t\t\t\tINT tabs_count;\n\t\t\t\t\tINT item_id;\n\n\t\t\t\t\ttabs_count = _r_tab_getitemcount (hwnd, IDC_TAB);\n\n\t\t\t\t\tif (!tabs_count)\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\titem_id = _r_tab_getcurrentitem (hwnd, IDC_TAB);\n\n\t\t\t\t\tif (item_id == INT_ERROR)\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tif (ctrl_id == IDM_TAB_NEXT)\n\t\t\t\t\t{\n\t\t\t\t\t\titem_id += 1;\n\n\t\t\t\t\t\tif (item_id >= tabs_count)\n\t\t\t\t\t\t\titem_id = 0;\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\titem_id -= 1;\n\n\t\t\t\t\t\tif (item_id == INT_ERROR)\n\t\t\t\t\t\t\titem_id = tabs_count - 1;\n\t\t\t\t\t}\n\n\t\t\t\t\t_r_tab_selectitem (hwnd, IDC_TAB, item_id);\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn FALSE;\n}\n\nBOOLEAN NTAPI _app_parseargs (\n\t_In_ R_CMDLINE_INFO_CLASS info_class\n)\n{\n\tHANDLE hengine;\n\n\t_app_initialize (NULL);\n\n\thengine = _wfp_getenginehandle ();\n\n\tswitch (info_class)\n\t{\n\t\tcase CmdlineHelp:\n\t\t{\n\t\t\t_r_show_message (\n\t\t\t\tNULL,\n\t\t\t\tMB_OK | MB_ICONINFORMATION,\n\t\t\t\tL\"Available options:\",\n\t\t\t\tL\"simplewall.exe -install - enable filtering.\\r\\n\"\n\t\t\t\tL\"simplewall.exe -install -temp - enable filtering until reboot.\\r\\n\"\n\t\t\t\tL\"simplewall.exe -install -silent - enable filtering without prompt.\\r\\n\"\n\t\t\t\tL\"simplewall.exe -uninstall - remove all installed filters.\\r\\n\"\n\t\t\t\tL\"simplewall.exe -help - show this message.\"\n\t\t\t);\n\n\t\t\treturn TRUE;\n\t\t}\n\n\t\tcase CmdlineInstall:\n\t\t{\n\t\t\tif (_r_sys_getopt (_r_sys_getcommandline (), L\"silent\", NULL) || _app_installmessage (NULL, TRUE))\n\t\t\t{\n\t\t\t\tif (_r_sys_getopt (_r_sys_getcommandline (), L\"temp\", NULL))\n\t\t\t\t\tconfig.is_filterstemporary = TRUE;\n\n\t\t\t\t_app_profile_initialize ();\n\t\t\t\t_app_profile_load (NULL, NULL);\n\n\t\t\t\tif (_wfp_initialize (NULL, hengine))\n\t\t\t\t\t_wfp_installfilters (hengine);\n\n\t\t\t\t_wfp_uninitialize (hengine, FALSE);\n\t\t\t}\n\n\t\t\treturn TRUE;\n\t\t}\n\n\t\tcase CmdlineUninstall:\n\t\t{\n\t\t\tif (_wfp_isfiltersinstalled () && _app_installmessage (NULL, FALSE))\n\t\t\t{\n\t\t\t\t_wfp_destroyfilters (hengine);\n\t\t\t\t_wfp_uninitialize (hengine, TRUE);\n\t\t\t}\n\n\t\t\treturn TRUE;\n\t\t}\n\n\t\tdefault:\n\t\t{\n\t\t\tFALLTHROUGH;\n\t\t}\n\t}\n\n\treturn FALSE;\n}\n\nINT APIENTRY wWinMain (\n\t_In_ HINSTANCE hinst,\n\t_In_opt_ HINSTANCE prev_hinst,\n\t_In_ LPWSTR cmdline,\n\t_In_ INT show_cmd\n)\n{\n\tHWND hwnd;\n\tULONG result;\n\n\tif (!_r_app_initialize (&_app_parseargs))\n\t\treturn ERROR_APP_INIT_FAILURE;\n\n\thwnd = _r_app_createwindow (hinst, MAKEINTRESOURCE (IDD_MAIN), MAKEINTRESOURCE (IDI_MAIN), &DlgProc);\n\n\tif (!hwnd)\n\t\treturn ERROR_APP_INIT_FAILURE;\n\n\tresult = _r_wnd_message_callback (hwnd, MAKEINTRESOURCE (IDA_MAIN));\n\n\treturn result;\n}\n"
  },
  {
    "path": "src/main.h",
    "content": "// simplewall\r\n// Copyright (c) 2016-2026 Henry++\r\n\r\n#pragma once\r\n\r\n#include \"routine.h\"\r\n\r\n#include \"resource.h\"\r\n#include \"app.h\"\r\n#include \"global.h\"\r\n\r\n// libs\r\n#pragma comment(lib, \"msimg32.lib\")\r\n#pragma comment(lib, \"crypt32.lib\")\r\n#pragma comment(lib, \"dnsapi.lib\")\r\n#pragma comment(lib, \"fwpuclnt.lib\")\r\n#pragma comment(lib, \"iphlpapi.lib\")\r\n#pragma comment(lib, \"rpcrt4.lib\")\r\n#pragma comment(lib, \"version.lib\")\r\n#pragma comment(lib, \"ws2_32.lib\")\r\n#pragma comment(lib, \"winmm.lib\")\r\n#pragma comment(lib, \"wintrust.lib\")\r\n\r\n// log\r\n#define DBG_ARG TEXT (__FILE__), __LINE__\r\n#define DBG_ARG_VAR file_name, line\r\n\r\n// guids\r\nDEFINE_GUID (GUID_TrayIcon, 0xDAB4837E, 0xCB0F, 0x47DA, 0x92, 0x22, 0x21, 0x20, 0x74, 0x9F, 0x5C, 0x41);\r\n\r\n// enums\r\ntypedef enum _ENUM_TYPE_DATA\r\n{\r\n\tDATA_UNKNOWN = 0,\r\n\tDATA_APP_REGULAR,\r\n\tDATA_APP_DEVICE,\r\n\tDATA_APP_NETWORK,\r\n\tDATA_APP_SERVICE,\r\n\tDATA_APP_UWP, // win8+\r\n\tDATA_APP_PICO, // win10+\r\n\tDATA_RULE_BLOCKLIST,\r\n\tDATA_RULE_SYSTEM,\r\n\tDATA_RULE_SYSTEM_USER,\r\n\tDATA_RULE_USER,\r\n\tDATA_RULE_CONFIG,\r\n\tDATA_TYPE_PORT,\r\n\tDATA_TYPE_IP,\r\n\tDATA_FILTER_GENERAL,\r\n\tDATA_LISTVIEW_CURRENT,\r\n} ENUM_TYPE_DATA;\r\n\r\ntypedef enum _ENUM_INSTALL_TYPE\r\n{\r\n\tINSTALL_DISABLED = 0,\r\n\tINSTALL_ENABLED,\r\n\tINSTALL_ENABLED_TEMPORARY,\r\n} ENUM_INSTALL_TYPE;\r\n\r\ntypedef enum _ENUM_INFO_DATA\r\n{\r\n\tINFO_PATH = 1,\r\n\tINFO_BYTES_DATA,\r\n\tINFO_DISPLAY_NAME,\r\n\tINFO_COMMENT,\r\n\tINFO_HASH,\r\n\tINFO_TIMESTAMP,\r\n\tINFO_TIMER,\r\n\tINFO_LISTVIEW_ID,\r\n\tINFO_DISABLE,\r\n\tINFO_IS_ENABLED,\r\n\tINFO_IS_READONLY,\r\n\tINFO_IS_SILENT,\r\n\tINFO_IS_UNDELETABLE,\r\n} ENUM_INFO_DATA;\r\n\r\ntypedef enum _ENUM_INFO_DATA2\r\n{\r\n\tINFO_ICON_ID,\r\n\tINFO_SIGNATURE_STRING, // dereference required\r\n\tINFO_VERSION_STRING, // dereference required\r\n} ENUM_INFO_DATA2;\r\n\r\n#define LOG_PATH_DEFAULT L\"%USERPROFILE%\\\\\" APP_NAME_SHORT L\".log\"\r\n#define LOG_VIEWER_DEFAULT L\"%SystemRoot%\\\\notepad.exe\"\r\n#define LOG_SIZE_LIMIT_DEFAULT _r_calc_kilobytes2bytes (1)\r\n\r\n#define PROC_WAITING_PID 0\r\n#define PROC_WAITING_NAME L\"Waiting connections\"\r\n\r\n#define PROC_SYSTEM_PID 4\r\n#define PROC_SYSTEM_NAME L\"System\"\r\n\r\n#define PATH_SVCHOST L\"\\\\svchost.exe\"\r\n#define PATH_WUSVC L\"\\\\wusvc.exe\"\r\n\r\n#define WINDOWSSPYBLOCKER_URL L\"https://github.com/crazy-max/WindowsSpyBlocker\"\r\n\r\n#define SZ_TAB L\"    \"\r\n#define SZ_CRLF L\"\\r\\n\"\r\n#define SZ_TAB_CRLF SZ_CRLF SZ_TAB\r\n#define SZ_RULE_INTERNAL_MENU L\"*\"\r\n\r\n#define SZ_STATE_ALLOW L\"Allowed\"\r\n#define SZ_STATE_BLOCK L\"Blocked\"\r\n#define SZ_DIRECTION_IN L\"Inbound\"\r\n#define SZ_DIRECTION_OUT L\"Outbound\"\r\n#define SZ_DIRECTION_ANY L\"Any\"\r\n#define SZ_DIRECTION_LOOPBACK L\"Loopback\"\r\n\r\n#define SZ_LOG_TITLE L\"Date,Username,Path,Address (Local),\" \\\r\n\tL\"Port (Local),Address (Remote),Port (Remote),\" \\\r\n\tL\"Protocol,Layer,Filter name,Filter ID,Direction,State\" SZ_CRLF\r\n\r\n#define SZ_LOG_BODY L\"\\\"%s\\\",\\\"%s\\\",\\\"%s\\\",\\\"%s\\\",\\\"%s\\\",\\\"%s\\\",\\\"%s\\\",\\\"%s\\\",\" \\\r\n\tL\"\\\"%s\\\",\\\"%s\\\",\\\"#%\" TEXT (PRIu64) L\"\\\",\\\"%s\\\",\\\"%s\\\"\" SZ_CRLF\r\n\r\n#define SZ_WARNING_ME L\"If you disallow this, you cannot use resolve network addresses option. Continue?\"\r\n#define SZ_WARNING_SVCHOST L\"Be careful, through service host (svchost.exe)\" \\\r\n\tL\"internet traffic can let out through unexpected ways. Continue?\"\r\n\r\n#define SZ_HELP L\"\\\"simplewall.exe -install\\\" - enable filtering.\" SZ_CRLF \\\r\n\tL\"\\\"simplewall.exe -install -temp\\\" - enable filtering until reboot.\" SZ_CRLF \\\r\n\tL\"\\\"simplewall.exe -install -silent\\\" - enable filtering without prompt.\" SZ_CRLF \\\r\n\tL\"\\\"simplewall.exe -uninstall\\\" - remove all installed filters.\" SZ_CRLF \\\r\n\tL\"\\\"simlewall.exe -help\\\" - show this message.\"\r\n\r\n#define DIVIDER_COPY L\", \"\r\n#define DIVIDER_APP L\"|\"\r\n#define DIVIDER_RULE L\";\"\r\n#define DIVIDER_RULE_RANGE L'-'\r\n#define DIVIDER_TRIM SZ_CRLF L\" \"\r\n\r\n#define BACKUP_HOURS_PERIOD _r_calc_hours2seconds (4) // make backup every X hour(s) (default)\r\n\r\n#define LEN_IP_MAX 68\r\n#define MAP_CACHE_MAX 900 // limit for caching hashtable\r\n\r\n#define TRANSACTION_TIMEOUT 9000\r\n\r\n// ui\r\n#define ICONS_MENU 6\r\n#define LANG_MENU 7\r\n#define NOTIFICATIONS_ID 4\r\n#define LOGGING_ID 5\r\n#define ERRLOG_ID 6\r\n\r\n#define REBAR_TOOLBAR_ID 0\r\n#define REBAR_SEARCH_ID 1\r\n\r\n#define LV_HIDDEN_GROUP_ID 13\r\n\r\n#define STATUSBAR_PARTS_COUNT 3\r\n\r\n// notifications\r\n#define NOTIFY_TIMER_SAFETY_TIMEOUT 900\r\n#define NOTIFY_TIMER_SAFETY_ID 666\r\n\r\n#define NOTIFY_TIMEOUT_DEFAULT 60 // sec.\r\n\r\n#define NOTIFY_SOUND_NAME L\"MailBeep\"\r\n\r\n// default colors\r\n#define LV_COLOR_INVALID RGB(255, 125, 148)\r\n#define LV_COLOR_SPECIAL RGB(255, 255, 170)\r\n#define LV_COLOR_SIGNED RGB(175, 228, 163)\r\n#define LV_COLOR_PICO RGB(51, 153, 255)\r\n#define LV_COLOR_SYSTEM RGB(151, 196, 251)\r\n#define LV_COLOR_CONNECTION RGB(255, 168, 242)\r\n#define LV_COLOR_UNDELETE RGB(211, 211, 211)\r\n\r\n// memory limitation for 1 rule\r\n#define RULE_NAME_CCH_MAX 0x0040 // 64\r\n#define RULE_RULE_CCH_MAX 0x0400 // 1024\r\n\r\ntypedef struct _STATIC_DATA\r\n{\r\n\tWCHAR windows_dir_buffer[256];\r\n\tR_STRINGREF windows_dir;\r\n\r\n\tGUID session_key;\r\n\r\n\tPR_STRING search_string;\r\n\r\n\tPR_STRING my_path;\r\n\tPR_STRING ntoskrnl_path;\r\n\tPR_STRING svchost_path;\r\n\tPR_STRING wusvc_path;\r\n\tPR_STRING system_path;\r\n\r\n\tPR_BYTE service_wdiservicehost_sid;\r\n\tPR_BYTE service_policyagent_sid;\r\n\tPR_BYTE service_mpssvc_sid;\r\n\tPR_BYTE service_nlasvc_sid;\r\n\tPR_BYTE service_rpcss_sid;\r\n\r\n\tHIMAGELIST himg_rules_small;\r\n\tHIMAGELIST himg_rules_large;\r\n\tHIMAGELIST himg_toolbar;\r\n\r\n\tHBITMAP hbmp_disable;\r\n\tHBITMAP hbmp_enable;\r\n\tHBITMAP hbmp_allow;\r\n\tHBITMAP hbmp_block;\r\n\r\n\tHANDLE hmonitor_thread;\r\n\tHANDLE hnotify_evt;\r\n\r\n\tHFONT wnd_font;\r\n\tHFONT hfont;\r\n\r\n\tHWND hsearchbar;\r\n\tHWND htoolbar;\r\n\tHWND hrebar;\r\n\r\n\tPSID builtin_current_sid;\r\n\tPSID builtin_netops_sid;\r\n\tPSID builtin_admins_sid;\r\n\r\n\tvolatile HWND hnotification;\r\n\tvolatile HICON htray_icon;\r\n\tvolatile HANDLE hnetevent;\r\n\tvolatile HANDLE hlogfile;\r\n\tvolatile LONG log_id;\r\n\r\n\tULONG color_nonremovable;\r\n\tULONG color_network;\r\n\tULONG color_invalid;\r\n\tULONG color_special;\r\n\tULONG color_signed;\r\n\tULONG color_system;\r\n\tULONG color_pico;\r\n\r\n\tULONG ntoskrnl_hash;\r\n\tULONG svchost_hash;\r\n\tULONG wusvc_hash;\r\n\tULONG my_hash;\r\n\r\n\tBOOLEAN is_filterstemporary;\r\n\tBOOLEAN is_neteventenabled;\r\n\tBOOLEAN is_notifytimeout;\r\n\tBOOLEAN is_notifymouse;\r\n\tBOOLEAN is_neteventset;\r\n} STATIC_DATA, *PSTATIC_DATA;\r\n\r\ntypedef struct _PROFILE_DATA\r\n{\r\n\tPR_STRING profile_path_internal;\r\n\tPR_STRING profile_path_backup;\r\n\tPR_STRING profile_path;\r\n\r\n\tLONG64 profile_internal_timestamp;\r\n} PROFILE_DATA, *PPROFILE_DATA;\r\n\r\ntypedef struct _ITEM_APP\r\n{\r\n\tPR_ARRAY guids;\r\n\r\n\tPR_STRING original_path;\r\n\tPR_STRING display_name;\r\n\tPR_STRING short_name;\r\n\tPR_STRING real_path;\r\n\tPR_STRING comment;\r\n\tPR_STRING hash;\r\n\r\n\tPVOID notification; // PITEM_LOG\r\n\tPR_BYTE bytes; // service - PSECURITY_DESCRIPTOR / uwp - PSID (win8+)\r\n\r\n\tPTP_TIMER htimer;\r\n\r\n\tLONG64 last_notify;\r\n\tLONG64 timestamp;\r\n\tLONG64 timer;\r\n\r\n\tULONG app_hash;\r\n\r\n\tENUM_TYPE_DATA type;\r\n\r\n\tUINT8 profile; // reserved ffu!\r\n\r\n\tstruct\r\n\t{\r\n\t\tULONG is_undeletable : 1;\r\n\t\tULONG is_haveerrors : 1;\r\n\t\tULONG is_enabled : 1;\r\n\t\tULONG is_silent : 1;\r\n\t\tULONG spare_bits : 28;\r\n\t} DUMMYSTRUCTNAME;\r\n} ITEM_APP, *PITEM_APP;\r\n\r\ntypedef struct _ITEM_APP_INFO\r\n{\r\n\tPR_STRING signature_info;\r\n\tPR_STRING version_info;\r\n\r\n\tPR_STRING path;\r\n\r\n\tULONG app_hash;\r\n\r\n\tLONG icon_id;\r\n\r\n\tENUM_TYPE_DATA type;\r\n\r\n\tINT listview_id;\r\n\r\n\tBOOLEAN is_loaded;\r\n} ITEM_APP_INFO, *PITEM_APP_INFO;\r\n\r\ntypedef struct _ITEM_FILTER_CONFIG\r\n{\r\n\tFWP_DIRECTION direction;\r\n\tUINT8 protocol;\r\n\tADDRESS_FAMILY af;\r\n} ITEM_FILTER_CONFIG, *PITEM_FILTER_CONFIG;\r\n\r\ntypedef struct _ITEM_RULE\r\n{\r\n\tPR_HASHTABLE apps;\r\n\tPR_ARRAY guids;\r\n\r\n\tPR_STRING name;\r\n\tPR_STRING comment;\r\n\tPR_STRING rule_remote;\r\n\tPR_STRING rule_local;\r\n\tPR_STRING protocol_str;\r\n\r\n\tstruct\r\n\t{\r\n\t\tULONG is_enabled_default : 1;\r\n\t\tULONG is_forservices : 1;\r\n\t\tULONG is_haveerrors : 1;\r\n\t\tULONG is_readonly : 1;\r\n\t\tULONG is_enabled : 1;\r\n\t\tULONG spare_bits : 27;\r\n\t} DUMMYSTRUCTNAME;\r\n\r\n\tunion\r\n\t{\r\n\t\tITEM_FILTER_CONFIG config;\r\n\r\n\t\tstruct\r\n\t\t{\r\n\t\t\tFWP_DIRECTION direction;\r\n\t\t\tUINT8 protocol;\r\n\t\t\tADDRESS_FAMILY af;\r\n\t\t} DUMMYSTRUCTNAME2;\r\n\t} DUMMYUNIONNAME;\r\n\r\n\tENUM_TYPE_DATA type;\r\n\r\n\tFWP_ACTION_TYPE action;\r\n\r\n\tUINT8 profile; // reserved ffu!\r\n\tUINT8 weight;\r\n} ITEM_RULE, *PITEM_RULE;\r\n\r\ntypedef struct _ITEM_RULE_CONFIG\r\n{\r\n\tPR_STRING name;\r\n\tPR_STRING apps;\r\n\r\n\tBOOLEAN is_enabled;\r\n} ITEM_RULE_CONFIG, *PITEM_RULE_CONFIG;\r\n\r\ntypedef struct _ITEM_NETWORK\r\n{\r\n\tunion\r\n\t{\r\n\t\tIN_ADDR remote_addr;\r\n\t\tIN6_ADDR remote_addr6;\r\n\t} DUMMYUNIONNAME;\r\n\r\n\tunion\r\n\t{\r\n\t\tIN_ADDR local_addr;\r\n\t\tIN6_ADDR local_addr6;\r\n\t} DUMMYUNIONNAME2;\r\n\r\n\tPR_STRING path;\r\n\r\n\tvolatile PR_STRING local_addr_str;\r\n\tvolatile PR_STRING remote_addr_str;\r\n\r\n\tvolatile PR_STRING local_host_str;\r\n\tvolatile PR_STRING remote_host_str;\r\n\r\n\tPR_STRING protocol_str;\r\n\r\n\tULONG app_hash;\r\n\tULONG state;\r\n\r\n\tFWP_DIRECTION direction;\r\n\tENUM_TYPE_DATA type;\r\n\tADDRESS_FAMILY af;\r\n\r\n\tUINT16 remote_port;\r\n\tUINT16 local_port;\r\n\r\n\tUINT8 protocol;\r\n\r\n\tBOOLEAN is_connection;\r\n} ITEM_NETWORK, *PITEM_NETWORK;\r\n\r\ntypedef struct _ITEM_LOG\r\n{\r\n\tunion\r\n\t{\r\n\t\tIN_ADDR remote_addr;\r\n\t\tIN6_ADDR remote_addr6;\r\n\t} DUMMYUNIONNAME;\r\n\r\n\tunion\r\n\t{\r\n\t\tIN_ADDR local_addr;\r\n\t\tIN6_ADDR local_addr6;\r\n\t} DUMMYUNIONNAME2;\r\n\r\n\tPR_STRING path;\r\n\tPR_STRING filter_name;\r\n\tPR_STRING layer_name;\r\n\tPR_STRING username;\r\n\tPR_STRING protocol_str;\r\n\r\n\tvolatile PR_STRING local_addr_str;\r\n\tvolatile PR_STRING remote_addr_str;\r\n\r\n\tvolatile PR_STRING local_host_str;\r\n\tvolatile PR_STRING remote_host_str;\r\n\r\n\tLONG64 timestamp;\r\n\r\n\tUINT64 filter_id;\r\n\r\n\tULONG app_hash;\r\n\r\n\tvolatile LONG log_id;\r\n\r\n\tFWP_DIRECTION direction;\r\n\r\n\tADDRESS_FAMILY af;\r\n\r\n\tUINT16 remote_port;\r\n\tUINT16 local_port;\r\n\r\n\tUINT8 protocol;\r\n\r\n\tBOOLEAN is_allow;\r\n\tBOOLEAN is_loopback;\r\n\tBOOLEAN is_blocklist;\r\n\tBOOLEAN is_custom;\r\n\tBOOLEAN is_system;\r\n\tBOOLEAN is_myprovider;\r\n} ITEM_LOG, *PITEM_LOG;\r\n\r\ntypedef struct _ITEM_STATUS\r\n{\r\n\tULONG_PTR apps_count;\r\n\tULONG_PTR apps_timer_count;\r\n\tULONG_PTR apps_unused_count;\r\n\tULONG_PTR rules_count;\r\n\tULONG_PTR rules_global_count;\r\n\tULONG_PTR rules_predefined_count;\r\n\tULONG_PTR rules_user_count;\r\n} ITEM_STATUS, *PITEM_STATUS;\r\n\r\ntypedef struct _ITEM_CONTEXT\r\n{\r\n\tHWND hwnd;\r\n\tINT listview_id;\r\n\r\n\tunion\r\n\t{\r\n\t\tstruct\r\n\t\t{\r\n\t\t\tPVOID base_address;\r\n\t\t\tLPARAM lparam;\r\n\t\t} DUMMYSTRUCTNAME;\r\n\r\n\t\tULONG_PTR is_install;\r\n\t} DUMMYUNIONNAME;\r\n} ITEM_CONTEXT, *PITEM_CONTEXT;\r\n\r\ntypedef struct _ITEM_COLOR\r\n{\r\n\tPR_STRING config_name;\r\n\tPR_STRING config_value;\r\n\tCOLORREF default_clr;\r\n\tCOLORREF new_clr;\r\n\tULONG locale_id;\r\n\tBOOLEAN is_enabled;\r\n} ITEM_COLOR, *PITEM_COLOR;\r\n\r\ntypedef struct _ITEM_ADDRESS\r\n{\r\n\tWCHAR range_start[LEN_IP_MAX];\r\n\tWCHAR range_end[LEN_IP_MAX];\r\n\r\n\tunion\r\n\t{\r\n\t\tFWP_V4_ADDR_AND_MASK addr4;\r\n\t\tFWP_V6_ADDR_AND_MASK addr6;\r\n\r\n\t\tstruct\r\n\t\t{\r\n\t\t\tFWP_RANGE range;\r\n\r\n\t\t\tUINT8 addr6_low[FWP_V6_ADDR_SIZE];\r\n\t\t\tUINT8 addr6_high[FWP_V6_ADDR_SIZE];\r\n\t\t} DUMMYSTRUCTNAME;\r\n\t} DUMMYUNIONNAME;\r\n\r\n\tUINT16 port;\r\n\r\n\tENUM_TYPE_DATA type;\r\n\tNET_ADDRESS_FORMAT format;\r\n\r\n\tBOOLEAN is_range;\r\n} ITEM_ADDRESS, *PITEM_ADDRESS;\r\n\r\ntypedef struct _ITEM_LOG_CALLBACK\r\n{\r\n\tunion\r\n\t{\r\n\t\tconst FWP_BYTE_ARRAY16 *remote_addr6;\r\n\t\tULONG_PTR remote_addr4;\r\n\t} DUMMYUNIONNAME;\r\n\r\n\tunion\r\n\t{\r\n\t\tconst FWP_BYTE_ARRAY16 *local_addr6;\r\n\t\tULONG_PTR local_addr4;\r\n\t} DUMMYUNIONNAME2;\r\n\r\n\tFILETIME timestamp;\r\n\tPUINT8 app_id;\r\n\tPSID package_id;\r\n\tPSID user_id;\r\n\r\n\tUINT64 filter_id;\r\n\r\n\tFWP_IP_VERSION version;\r\n\r\n\tUINT32 flags;\r\n\tUINT32 direction;\r\n\r\n\tUINT16 remote_port;\r\n\tUINT16 local_port;\r\n\tUINT16 layer_id;\r\n\tUINT8 protocol;\r\n\r\n\tBOOLEAN is_allow;\r\n\tBOOLEAN is_loopback;\r\n} ITEM_LOG_CALLBACK, *PITEM_LOG_CALLBACK;\r\n\r\ntypedef struct _ITEM_TAB_CONTEXT\r\n{\r\n\tINT listview_id;\r\n\tINT locale_id;\r\n} ITEM_TAB_CONTEXT, *PITEM_TAB_CONTEXT;\r\n"
  },
  {
    "path": "src/messages.c",
    "content": "// simplewall\r\n// Copyright (c) 2021-2026 Henry++\r\n\r\n#include \"global.h\"\r\n\r\nVOID _app_message_initialize (\r\n\t_In_ HWND hwnd\r\n)\r\n{\r\n\tENUM_INSTALL_TYPE install_type;\r\n\tHMENU hmenu;\r\n\tLONG icon_size;\r\n\tLONG view_type;\r\n\tUINT menu_id;\r\n\tBOOLEAN is_enabled;\r\n\r\n\tinstall_type = _wfp_getinstalltype ();\r\n\r\n\t_r_tray_create (hwnd, &GUID_TrayIcon, RM_TRAYICON, NULL, NULL, FALSE);\r\n\r\n\t_app_settrayicon (hwnd, install_type);\r\n\r\n\thmenu = GetMenu (hwnd);\r\n\r\n\tif (hmenu)\r\n\t{\r\n\t\tif (_r_config_getboolean (L\"IsInternalRulesDisabled\", FALSE, NULL))\r\n\t\t\t_r_menu_enableitem (hmenu, 4, FALSE, FALSE);\r\n\r\n\t\t_r_menu_checkitem (hmenu, IDM_ALWAYSONTOP_CHK, 0, MF_BYCOMMAND, _r_config_getboolean (L\"AlwaysOnTop\", FALSE, NULL));\r\n\t\t_r_menu_checkitem (hmenu, IDM_AUTOSIZECOLUMNS_CHK, 0, MF_BYCOMMAND, _r_config_getboolean (L\"AutoSizeColumns\", TRUE, NULL));\r\n\t\t_r_menu_checkitem (hmenu, IDM_SHOWFILENAMESONLY_CHK, 0, MF_BYCOMMAND, _r_config_getboolean (L\"ShowFilenames\", TRUE, NULL));\r\n\t\t_r_menu_checkitem (hmenu, IDM_SHOWSEARCHBAR_CHK, 0, MF_BYCOMMAND, _r_config_getboolean (L\"IsShowSearchBar\", TRUE, NULL));\r\n\r\n\t\tview_type = _r_calc_clamp (_r_config_getlong (L\"ViewType\", LV_VIEW_DETAILS, NULL), LV_VIEW_ICON, LV_VIEW_MAX);\r\n\r\n\t\tif (view_type == LV_VIEW_ICON)\r\n\t\t{\r\n\t\t\tmenu_id = IDM_VIEW_ICON;\r\n\t\t}\r\n\t\telse if (view_type == LV_VIEW_TILE)\r\n\t\t{\r\n\t\t\tmenu_id = IDM_VIEW_TILE;\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tmenu_id = IDM_VIEW_DETAILS;\r\n\t\t}\r\n\r\n\t\t_r_menu_checkitem (hmenu, IDM_VIEW_DETAILS, IDM_VIEW_TILE, MF_BYCOMMAND, menu_id);\r\n\r\n\t\ticon_size = _r_calc_clamp (_r_config_getlong (L\"IconSize\", SHIL_SMALL, NULL), SHIL_LARGE, SHIL_LAST);\r\n\r\n\t\tif (icon_size == SHIL_EXTRALARGE)\r\n\t\t{\r\n\t\t\tmenu_id = IDM_SIZE_EXTRALARGE;\r\n\t\t}\r\n\t\telse if (icon_size == SHIL_LARGE)\r\n\t\t{\r\n\t\t\tmenu_id = IDM_SIZE_LARGE;\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tmenu_id = IDM_SIZE_SMALL;\r\n\t\t}\r\n\r\n\t\t_r_menu_checkitem (hmenu, IDM_SIZE_SMALL, IDM_SIZE_EXTRALARGE, MF_BYCOMMAND, menu_id);\r\n\t\t_r_menu_checkitem (hmenu, IDM_ICONSISHIDDEN, 0, MF_BYCOMMAND, _r_config_getboolean (L\"IsIconsHidden\", FALSE, NULL));\r\n\t\t_r_menu_checkitem (hmenu, IDM_USEDARKTHEME_CHK, 0, MF_BYCOMMAND, _r_theme_isenabled ());\r\n\t\t_r_menu_checkitem (hmenu, IDM_LOADONSTARTUP_CHK, 0, MF_BYCOMMAND, _r_autorun_isenabled ());\r\n\t\t_r_menu_checkitem (hmenu, IDM_STARTMINIMIZED_CHK, 0, MF_BYCOMMAND, _r_config_getboolean (L\"IsStartMinimized\", FALSE, NULL));\r\n\t\t_r_menu_checkitem (hmenu, IDM_SKIPUACWARNING_CHK, 0, MF_BYCOMMAND, _r_skipuac_isenabled ());\r\n\t\t_r_menu_checkitem (hmenu, IDM_CHECKUPDATES_CHK, 0, MF_BYCOMMAND, _r_update_isenabled (FALSE));\r\n\t\t_r_menu_checkitem (hmenu, IDM_RULE_BLOCKOUTBOUND, 0, MF_BYCOMMAND, _r_config_getboolean (L\"BlockOutboundConnections\", TRUE, NULL));\r\n\t\t_r_menu_checkitem (hmenu, IDM_RULE_BLOCKINBOUND, 0, MF_BYCOMMAND, _r_config_getboolean (L\"BlockInboundConnections\", TRUE, NULL));\r\n\t\t_r_menu_checkitem (hmenu, IDM_RULE_ALLOWLOOPBACK, 0, MF_BYCOMMAND, _r_config_getboolean (L\"AllowLoopbackConnections\", TRUE, NULL));\r\n\t\t_r_menu_checkitem (hmenu, IDM_RULE_ALLOW6TO4, 0, MF_BYCOMMAND, _r_config_getboolean (L\"AllowIPv6\", TRUE, NULL));\r\n\t\t_r_menu_checkitem (hmenu, IDM_RULE_ALLOWWINDOWSUPDATE, 0, MF_BYCOMMAND, _app_wufixenabled ());\r\n\r\n\t\tif (!_r_sys_isosversiongreaterorequal (WINDOWS_10))\r\n\t\t\t_r_menu_enableitem (hmenu, IDM_RULE_ALLOWWINDOWSUPDATE, FALSE, FALSE);\r\n\r\n\t\t_r_menu_checkitem (hmenu, IDM_PROFILETYPE_PLAIN, IDM_PROFILETYPE_ENCRYPTED, MF_BYCOMMAND, IDM_PROFILETYPE_PLAIN + _r_calc_clamp (_r_config_getlong (L\"ProfileType\", 0, NULL), 0, 2));\r\n\r\n\t\tis_enabled = _r_config_getboolean (L\"IsHashesEnabled\", FALSE, NULL);\r\n\r\n\t\t_r_menu_checkitem (hmenu, IDM_USECERTIFICATES_CHK, 0, MF_BYCOMMAND, _r_config_getboolean (L\"IsCertificatesEnabled\", TRUE, NULL));\r\n\t\t_r_menu_checkitem (hmenu, IDM_KEEPUNUSED_CHK, 0, MF_BYCOMMAND, _r_config_getboolean (L\"IsKeepUnusedApps\", TRUE, NULL));\r\n\t\t_r_menu_checkitem (hmenu, IDM_USEHASHES_CHK, 0, MF_BYCOMMAND, is_enabled);\r\n\t\t_r_menu_checkitem (hmenu, IDM_USENETWORKRESOLUTION_CHK, 0, MF_BYCOMMAND, _r_config_getboolean (L\"IsNetworkResolutionsEnabled\", FALSE, NULL));\r\n\t\t_r_menu_checkitem (hmenu, IDM_USEAPPMONITOR_CHK, 0, MF_BYCOMMAND, _r_config_getboolean (L\"IsEnableAppMonitor\", FALSE, NULL));\r\n\r\n\t\t_r_menu_enableitem (hmenu, IDM_USEAPPMONITOR_CHK, FALSE, is_enabled);\r\n\r\n\t\t_r_menu_checkitem (\r\n\t\t\thmenu,\r\n\t\t\tIDM_BLOCKLIST_SPY_DISABLE,\r\n\t\t\tIDM_BLOCKLIST_SPY_BLOCK,\r\n\t\t\tMF_BYCOMMAND,\r\n\t\t\tIDM_BLOCKLIST_SPY_DISABLE + _r_calc_clamp (_r_config_getlong (L\"BlocklistSpyState\", 2, NULL), 0, 2)\r\n\t\t);\r\n\r\n\t\t_r_menu_checkitem (\r\n\t\t\thmenu,\r\n\t\t\tIDM_BLOCKLIST_UPDATE_DISABLE,\r\n\t\t\tIDM_BLOCKLIST_UPDATE_BLOCK,\r\n\t\t\tMF_BYCOMMAND,\r\n\t\t\tIDM_BLOCKLIST_UPDATE_DISABLE + _r_calc_clamp (_r_config_getlong (L\"BlocklistUpdateState\", 0, NULL), 0, 2)\r\n\t\t);\r\n\r\n\t\t_r_menu_checkitem (\r\n\t\t\thmenu,\r\n\t\t\tIDM_BLOCKLIST_EXTRA_DISABLE,\r\n\t\t\tIDM_BLOCKLIST_EXTRA_BLOCK,\r\n\t\t\tMF_BYCOMMAND,\r\n\t\t\tIDM_BLOCKLIST_EXTRA_DISABLE + _r_calc_clamp (_r_config_getlong (L\"BlocklistExtraState\", 0, NULL), 0, 2)\r\n\t\t);\r\n\t}\r\n\r\n\t_r_toolbar_setbutton (\r\n\t\tconfig.hrebar,\r\n\t\tIDC_TOOLBAR,\r\n\t\tIDM_TRAY_ENABLENOTIFICATIONS_CHK,\r\n\t\tNULL,\r\n\t\t0,\r\n\t\t_r_config_getboolean (L\"IsNotificationsEnabled\", TRUE, NULL) ? TBSTATE_PRESSED | TBSTATE_ENABLED : TBSTATE_ENABLED,\r\n\t\tI_IMAGENONE\r\n\t);\r\n\r\n\t_r_toolbar_setbutton (\r\n\t\tconfig.hrebar,\r\n\t\tIDC_TOOLBAR,\r\n\t\tIDM_TRAY_ENABLELOG_CHK,\r\n\t\tNULL,\r\n\t\t0,\r\n\t\t_r_config_getboolean (L\"IsLogEnabled\", FALSE, NULL) ? TBSTATE_PRESSED | TBSTATE_ENABLED : TBSTATE_ENABLED,\r\n\t\tI_IMAGENONE\r\n\t);\r\n\r\n\t_r_toolbar_setbutton (\r\n\t\tconfig.hrebar,\r\n\t\tIDC_TOOLBAR,\r\n\t\tIDM_TRAY_ENABLEUILOG_CHK,\r\n\t\tNULL,\r\n\t\t0,\r\n\t\t_r_config_getboolean (L\"IsLogUiEnabled\", FALSE, NULL) ? TBSTATE_PRESSED | TBSTATE_ENABLED : TBSTATE_ENABLED,\r\n\t\tI_IMAGENONE\r\n\t);\r\n}\r\n\r\nVOID _app_message_localize (\r\n\t_In_ HWND hwnd\r\n)\r\n{\r\n\tPITEM_TAB_CONTEXT tab_context;\r\n\tPR_STRING localized_string = NULL;\r\n\tLPCWSTR recommended_string;\r\n\tHMENU hmenu;\r\n\tHMENU hsubmenu;\r\n\tLONG dpi_value;\r\n\r\n\thmenu = GetMenu (hwnd);\r\n\r\n\tdpi_value = _r_dc_getwindowdpi (hwnd);\r\n\r\n\tif (hmenu)\r\n\t{\r\n\t\t_r_menu_setitemtext (hmenu, 0, TRUE, _r_locale_getstring (IDS_FILE));\r\n\t\t_r_menu_setitemtext (hmenu, 1, TRUE, _r_locale_getstring (IDS_EDIT));\r\n\t\t_r_menu_setitemtext (hmenu, 2, TRUE, _r_locale_getstring (IDS_VIEW));\r\n\t\t_r_menu_setitemtext (hmenu, 3, TRUE, _r_locale_getstring (IDS_SETTINGS));\r\n\t\t_r_menu_setitemtext (hmenu, 4, TRUE, _r_locale_getstring (IDS_TRAY_BLOCKLIST_RULES));\r\n\t\t_r_menu_setitemtext (hmenu, 5, TRUE, _r_locale_getstring (IDS_HELP));\r\n\r\n\t\t// file submenu\r\n\t\t_r_menu_setitemtextformat (\r\n\t\t\thmenu,\r\n\t\t\tIDM_SETTINGS,\r\n\t\t\tFALSE,\r\n\t\t\tL\"%s...\\tF2\",\r\n\t\t\t_r_locale_getstring (IDS_SETTINGS)\r\n\t\t);\r\n\r\n\t\t_r_menu_setitemtextformat (\r\n\t\t\thmenu,\r\n\t\t\tIDM_ADD_FILE,\r\n\t\t\tFALSE,\r\n\t\t\tL\"%s...\",\r\n\t\t\t_r_locale_getstring (IDS_ADD_FILE)\r\n\t\t);\r\n\r\n\t\t_r_menu_setitemtextformat (\r\n\t\t\thmenu,\r\n\t\t\tIDM_IMPORT,\r\n\t\t\tFALSE,\r\n\t\t\tL\"%s...\\tCtrl+O\",\r\n\t\t\t_r_locale_getstring (IDS_IMPORT)\r\n\t\t);\r\n\r\n\t\t_r_menu_setitemtextformat (\r\n\t\t\thmenu,\r\n\t\t\tIDM_EXPORT,\r\n\t\t\tFALSE,\r\n\t\t\tL\"%s...\\tCtrl+S\",\r\n\t\t\t_r_locale_getstring (IDS_EXPORT)\r\n\t\t);\r\n\r\n\t\t_r_menu_setitemtextformat (\r\n\t\t\thmenu,\r\n\t\t\tIDM_EXIT,\r\n\t\t\tFALSE,\r\n\t\t\t_r_locale_getstring (IDS_EXIT)\r\n\t\t);\r\n\r\n\t\t// edit submenu\r\n\t\t_r_menu_setitemtextformat (\r\n\t\t\thmenu,\r\n\t\t\tIDM_PURGE_UNUSED,\r\n\t\t\tFALSE,\r\n\t\t\tL\"%s\\tCtrl+Shift+X\",\r\n\t\t\t_r_locale_getstring (IDS_PURGE_UNUSED)\r\n\t\t);\r\n\r\n\t\t_r_menu_setitemtextformat (\r\n\t\t\thmenu,\r\n\t\t\tIDM_PURGE_TIMERS,\r\n\t\t\tFALSE,\r\n\t\t\tL\"%s\\tCtrl+Shift+T\",\r\n\t\t\t_r_locale_getstring (IDS_PURGE_TIMERS)\r\n\t\t);\r\n\r\n\t\t_r_menu_setitemtextformat (\r\n\t\t\thmenu,\r\n\t\t\tIDM_LOGCLEAR,\r\n\t\t\tFALSE,\r\n\t\t\tL\"%s\\tCtrl+X\",\r\n\t\t\t_r_locale_getstring (IDS_LOGCLEAR)\r\n\t\t);\r\n\r\n\t\t_r_menu_setitemtextformat (\r\n\t\t\thmenu,\r\n\t\t\tIDM_REFRESH,\r\n\t\t\tFALSE,\r\n\t\t\tL\"%s\\tF5\",\r\n\t\t\t_r_locale_getstring (IDS_REFRESH)\r\n\t\t);\r\n\r\n\t\t// view submenu\r\n\t\t_r_menu_setitemtext (hmenu, IDM_ALWAYSONTOP_CHK, FALSE, _r_locale_getstring (IDS_ALWAYSONTOP_CHK));\r\n\t\t_r_menu_setitemtext (hmenu, IDM_AUTOSIZECOLUMNS_CHK, FALSE, _r_locale_getstring (IDS_AUTOSIZECOLUMNS_CHK));\r\n\t\t_r_menu_setitemtext (hmenu, IDM_SHOWFILENAMESONLY_CHK, FALSE, _r_locale_getstring (IDS_SHOWFILENAMESONLY_CHK));\r\n\t\t_r_menu_setitemtext (hmenu, IDM_SHOWSEARCHBAR_CHK, FALSE, _r_locale_getstring (IDS_SHOWSEARCHBAR_CHK));\r\n\r\n\t\t_r_menu_setitemtext (hmenu, IDM_SIZE_SMALL, FALSE, _r_locale_getstring (IDS_ICONSSMALL));\r\n\t\t_r_menu_setitemtext (hmenu, IDM_SIZE_LARGE, FALSE, _r_locale_getstring (IDS_ICONSLARGE));\r\n\t\t_r_menu_setitemtext (hmenu, IDM_SIZE_EXTRALARGE, FALSE, _r_locale_getstring (IDS_ICONSEXTRALARGE));\r\n\r\n\t\t_r_menu_setitemtext (hmenu, IDM_VIEW_DETAILS, FALSE, _r_locale_getstring (IDS_VIEW_DETAILS));\r\n\t\t_r_menu_setitemtext (hmenu, IDM_VIEW_ICON, FALSE, _r_locale_getstring (IDS_VIEW_ICON));\r\n\t\t_r_menu_setitemtext (hmenu, IDM_VIEW_TILE, FALSE, _r_locale_getstring (IDS_VIEW_TILE));\r\n\r\n\t\t_r_menu_setitemtext (hmenu, IDM_ICONSISHIDDEN, FALSE, _r_locale_getstring (IDS_ICONSISHIDDEN));\r\n\r\n\t\t_r_menu_setitemtext (hmenu, IDM_USEDARKTHEME_CHK, FALSE, _r_locale_getstring (IDS_USEDARKTHEME));\r\n\r\n\t\thsubmenu = GetSubMenu (hmenu, 2);\r\n\r\n\t\tif (hsubmenu)\r\n\t\t{\r\n\t\t\t_r_menu_setitemtext (hsubmenu, ICONS_MENU, TRUE, _r_locale_getstring (IDS_ICONS));\r\n\r\n\t\t\t_r_menu_setitemtextformat (\r\n\t\t\t\thsubmenu,\r\n\t\t\t\tLANG_MENU,\r\n\t\t\t\tTRUE,\r\n\t\t\t\tL\"%s (Language)\",\r\n\t\t\t\t_r_locale_getstring (IDS_LANGUAGE)\r\n\t\t\t);\r\n\r\n\t\t\t_r_locale_enum (hsubmenu, LANG_MENU, IDX_LANGUAGE); // enum localizations\r\n\t\t}\r\n\r\n\t\t_r_menu_setitemtextformat (hmenu, IDM_FONT, FALSE, L\"%s...\", _r_locale_getstring (IDS_FONT));\r\n\r\n\t\t// settings submenu\r\n\t\t_r_menu_setitemtext (hmenu, IDM_LOADONSTARTUP_CHK, FALSE, _r_locale_getstring (IDS_LOADONSTARTUP_CHK));\r\n\t\t_r_menu_setitemtext (hmenu, IDM_STARTMINIMIZED_CHK, FALSE, _r_locale_getstring (IDS_STARTMINIMIZED_CHK));\r\n\t\t_r_menu_setitemtext (hmenu, IDM_SKIPUACWARNING_CHK, FALSE, _r_locale_getstring (IDS_SKIPUACWARNING_CHK));\r\n\t\t_r_menu_setitemtext (hmenu, IDM_CHECKUPDATES_CHK, FALSE, _r_locale_getstring (IDS_CHECKUPDATES_CHK));\r\n\r\n\t\t_r_menu_setitemtext (hmenu, IDM_RULE_BLOCKOUTBOUND, FALSE, _r_locale_getstring (IDS_RULE_BLOCKOUTBOUND));\r\n\t\t_r_menu_setitemtext (hmenu, IDM_RULE_BLOCKINBOUND, FALSE, _r_locale_getstring (IDS_RULE_BLOCKINBOUND));\r\n\t\t_r_menu_setitemtext (hmenu, IDM_RULE_ALLOWLOOPBACK, FALSE, _r_locale_getstring (IDS_RULE_ALLOWLOOPBACK));\r\n\t\t_r_menu_setitemtext (hmenu, IDM_RULE_ALLOW6TO4, FALSE, _r_locale_getstring (IDS_RULE_ALLOW6TO4));\r\n\r\n\t\t_r_menu_setitemtext (hmenu, IDM_RULE_ALLOWWINDOWSUPDATE, FALSE, _r_locale_getstring (IDS_RULE_ALLOWWINDOWSUPDATE));\r\n\r\n\t\t_r_menu_setitemtext (hmenu, IDM_PROFILETYPE_PLAIN, FALSE, _r_locale_getstring (IDS_PROFILE_TYPE_PLAIN));\r\n\t\t_r_menu_setitemtext (hmenu, IDM_PROFILETYPE_COMPRESSED, FALSE, _r_locale_getstring (IDS_PROFILE_TYPE_COMPRESSED));\r\n\t\t_r_menu_setitemtext (hmenu, IDM_PROFILETYPE_ENCRYPTED, FALSE, _r_locale_getstring (IDS_PROFILE_TYPE_ENCRYPTED));\r\n\r\n\t\t_r_menu_setitemtext (hmenu, IDM_USENETWORKRESOLUTION_CHK, FALSE, _r_locale_getstring (IDS_USENETWORKRESOLUTION_CHK));\r\n\t\t_r_menu_setitemtext (hmenu, IDM_USECERTIFICATES_CHK, FALSE, _r_locale_getstring (IDS_USECERTIFICATES_CHK));\r\n\t\t_r_menu_setitemtext (hmenu, IDM_KEEPUNUSED_CHK, FALSE, _r_locale_getstring (IDS_KEEPUNUSED_CHK));\r\n\t\t_r_menu_setitemtext (hmenu, IDM_USEHASHES_CHK, FALSE, _r_locale_getstring (IDS_USEHASHES_CHK));\r\n\t\t_r_menu_setitemtext (hmenu, IDM_USEAPPMONITOR_CHK, FALSE, _r_locale_getstring (IDS_USEAPPMONITOR_CHK));\r\n\r\n\t\thsubmenu = GetSubMenu (hmenu, 3);\r\n\r\n\t\tif (hsubmenu)\r\n\t\t{\r\n\t\t\t_r_menu_setitemtext (hsubmenu, 5, TRUE, _r_locale_getstring (IDS_TRAY_RULES));\r\n\t\t\t_r_menu_setitemtext (hsubmenu, 6, TRUE, _r_locale_getstring (IDS_PROFILE_TYPE));\r\n\t\t}\r\n\r\n\t\trecommended_string = _r_locale_getstring (IDS_RECOMMENDED);\r\n\r\n\t\t// blocklist submenu\r\n\t\t_r_menu_setitemtext (hmenu, IDM_BLOCKLIST_SPY_DISABLE, FALSE, _r_locale_getstring (IDS_DISABLE));\r\n\t\t_r_menu_setitemtext (hmenu, IDM_BLOCKLIST_SPY_ALLOW, FALSE, _r_locale_getstring (IDS_ACTION_ALLOW));\r\n\t\t_r_menu_setitemtextformat (hmenu, IDM_BLOCKLIST_SPY_BLOCK, FALSE, L\"%s (%s)\", _r_locale_getstring (IDS_ACTION_BLOCK), recommended_string);\r\n\r\n\t\t_r_menu_setitemtextformat (hmenu, IDM_BLOCKLIST_UPDATE_DISABLE, FALSE, L\"%s (%s)\", _r_locale_getstring (IDS_DISABLE), recommended_string);\r\n\t\t_r_menu_setitemtext (hmenu, IDM_BLOCKLIST_UPDATE_ALLOW, FALSE, _r_locale_getstring (IDS_ACTION_ALLOW));\r\n\t\t_r_menu_setitemtext (hmenu, IDM_BLOCKLIST_UPDATE_BLOCK, FALSE, _r_locale_getstring (IDS_ACTION_BLOCK));\r\n\r\n\t\t_r_menu_setitemtextformat (hmenu, IDM_BLOCKLIST_EXTRA_DISABLE, FALSE, L\"%s (%s)\", _r_locale_getstring (IDS_DISABLE), recommended_string);\r\n\t\t_r_menu_setitemtext (hmenu, IDM_BLOCKLIST_EXTRA_ALLOW, FALSE, _r_locale_getstring (IDS_ACTION_ALLOW));\r\n\t\t_r_menu_setitemtext (hmenu, IDM_BLOCKLIST_EXTRA_BLOCK, FALSE, _r_locale_getstring (IDS_ACTION_BLOCK));\r\n\r\n\t\thsubmenu = GetSubMenu (hmenu, 4);\r\n\r\n\t\tif (hsubmenu)\r\n\t\t{\r\n\t\t\t_r_menu_setitemtext (hsubmenu, 0, TRUE, _r_locale_getstring (IDS_BLOCKLIST_SPY));\r\n\t\t\t_r_menu_setitemtext (hsubmenu, 1, TRUE, _r_locale_getstring (IDS_BLOCKLIST_UPDATE));\r\n\t\t\t_r_menu_setitemtext (hsubmenu, 2, TRUE, _r_locale_getstring (IDS_BLOCKLIST_EXTRA));\r\n\t\t}\r\n\r\n\t\t// help submenu\r\n\t\t_r_menu_setitemtext (hmenu, IDM_WEBSITE, FALSE, _r_locale_getstring (IDS_WEBSITE));\r\n\t\t_r_menu_setitemtext (hmenu, IDM_CHECKUPDATES, FALSE, _r_locale_getstring (IDS_CHECKUPDATES));\r\n\t\t_r_menu_setitemtextformat (hmenu, IDM_ABOUT, FALSE, L\"%s\\tF1\", _r_locale_getstring (IDS_ABOUT));\r\n\t}\r\n\r\n\t// localize toolbar\r\n\t_app_setinterfacestate (hwnd, dpi_value);\r\n\r\n\t_r_toolbar_setbutton (config.hrebar, IDC_TOOLBAR, IDM_REFRESH, _r_locale_getstring (IDS_REFRESH), BTNS_BUTTON | BTNS_AUTOSIZE | BTNS_SHOWTEXT, 0, I_IMAGENONE);\r\n\t_r_toolbar_setbutton (config.hrebar, IDC_TOOLBAR, IDM_SETTINGS, _r_locale_getstring (IDS_SETTINGS), BTNS_BUTTON | BTNS_AUTOSIZE | BTNS_SHOWTEXT, 0, I_IMAGENONE);\r\n\r\n\t_r_obj_movereference ((PVOID_PTR)&localized_string, _r_format_string (L\"%s...\", _r_locale_getstring (IDS_OPENRULESEDITOR)));\r\n\t_r_toolbar_setbutton (config.hrebar, IDC_TOOLBAR, IDM_OPENRULESEDITOR, localized_string->buffer, BTNS_BUTTON | BTNS_AUTOSIZE, 0, I_IMAGENONE);\r\n\r\n\t_r_toolbar_setbutton (config.hrebar, IDC_TOOLBAR, IDM_TRAY_ENABLENOTIFICATIONS_CHK, _r_locale_getstring (IDS_ENABLENOTIFICATIONS_CHK), BTNS_CHECK | BTNS_AUTOSIZE, 0, I_IMAGENONE);\r\n\t_r_toolbar_setbutton (config.hrebar, IDC_TOOLBAR, IDM_TRAY_ENABLELOG_CHK, _r_locale_getstring (IDS_ENABLELOG_CHK), BTNS_CHECK | BTNS_AUTOSIZE, 0, I_IMAGENONE);\r\n\r\n\t_r_obj_movereference ((PVOID_PTR)&localized_string, _r_format_string (L\"%s (%s)\", _r_locale_getstring (IDS_ENABLEUILOG_CHK), _r_locale_getstring (IDS_SESSION_ONLY)));\r\n\t_r_toolbar_setbutton (config.hrebar, IDC_TOOLBAR, IDM_TRAY_ENABLEUILOG_CHK, localized_string->buffer, BTNS_CHECK | BTNS_AUTOSIZE, 0, I_IMAGENONE);\r\n\r\n\t_r_obj_movereference ((PVOID_PTR)&localized_string, _r_format_string (L\"%s (Ctrl+I)\", _r_locale_getstring (IDS_LOGSHOW)));\r\n\t_r_toolbar_setbutton (config.hrebar, IDC_TOOLBAR, IDM_TRAY_LOGSHOW, localized_string->buffer, BTNS_BUTTON | BTNS_AUTOSIZE, 0, I_IMAGENONE);\r\n\r\n\t_r_obj_movereference ((PVOID_PTR)&localized_string, _r_format_string (L\"%s (Ctrl+X)\", _r_locale_getstring (IDS_LOGCLEAR)));\r\n\t_r_toolbar_setbutton (config.hrebar, IDC_TOOLBAR, IDM_TRAY_LOGCLEAR, localized_string->buffer, BTNS_BUTTON | BTNS_AUTOSIZE, 0, I_IMAGENONE);\r\n\r\n\t_r_toolbar_setbutton (config.hrebar, IDC_TOOLBAR, IDM_DONATE, _r_locale_getstring (IDS_DONATE), BTNS_BUTTON | BTNS_AUTOSIZE, 0, I_IMAGENONE);\r\n\r\n\t_r_obj_movereference ((PVOID_PTR)&localized_string, _r_format_string (L\"%s... (Ctrl+F)\", _r_locale_getstring (IDS_FIND)));\r\n\t_r_edit_setcuebanner (config.hrebar, IDC_SEARCH, localized_string->buffer);\r\n\r\n\t// set rebar size\r\n\t_app_toolbar_resize (hwnd, dpi_value);\r\n\r\n\t// localize tabs\r\n\tfor (INT i = 0; i < _r_tab_getitemcount (hwnd, IDC_TAB); i++)\r\n\t{\r\n\t\ttab_context = _app_listview_getcontext (hwnd, i);\r\n\r\n\t\tif (!tab_context)\r\n\t\t\tcontinue;\r\n\r\n\t\t_r_tab_setitem (hwnd, IDC_TAB, i, _r_locale_getstring (tab_context->locale_id), I_DEFAULT, I_DEFAULT);\r\n\r\n\t\tswitch (tab_context->listview_id)\r\n\t\t{\r\n\t\t\tcase IDC_APPS_PROFILE:\r\n\t\t\tcase IDC_APPS_SERVICE:\r\n\t\t\tcase IDC_APPS_UWP:\r\n\t\t\t{\r\n\t\t\t\t_r_listview_setcolumn (hwnd, tab_context->listview_id, 0, _r_locale_getstring (IDS_NAME), 0);\r\n\t\t\t\t_r_listview_setcolumn (hwnd, tab_context->listview_id, 1, _r_locale_getstring (IDS_ADDED), 0);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\r\n\t\t\tcase IDC_RULES_BLOCKLIST:\r\n\t\t\tcase IDC_RULES_SYSTEM:\r\n\t\t\tcase IDC_RULES_CUSTOM:\r\n\t\t\t{\r\n\t\t\t\t_r_listview_setcolumn (hwnd, tab_context->listview_id, 0, _r_locale_getstring (IDS_NAME), 0);\r\n\t\t\t\t_r_listview_setcolumn (hwnd, tab_context->listview_id, 1, _r_locale_getstring (IDS_PROTOCOL), 0);\r\n\t\t\t\t_r_listview_setcolumn (hwnd, tab_context->listview_id, 2, _r_locale_getstring (IDS_DIRECTION), 0);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\r\n\t\t\tcase IDC_NETWORK:\r\n\t\t\t{\r\n\t\t\t\t_r_listview_setcolumn (hwnd, tab_context->listview_id, 0, _r_locale_getstring (IDS_NAME), 0);\r\n\r\n\t\t\t\t_r_obj_movereference ((PVOID_PTR)&localized_string, _r_format_string (L\"%s (%s)\", _r_locale_getstring (IDS_ADDRESS), _r_locale_getstring (IDS_DIRECTION_LOCAL)));\r\n\t\t\t\t_r_listview_setcolumn (hwnd, tab_context->listview_id, 1, localized_string->buffer, 0);\r\n\r\n\t\t\t\t_r_obj_movereference ((PVOID_PTR)&localized_string, _r_format_string (L\"%s (%s)\", _r_locale_getstring (IDS_HOST), _r_locale_getstring (IDS_DIRECTION_LOCAL)));\r\n\t\t\t\t_r_listview_setcolumn (hwnd, tab_context->listview_id, 2, localized_string->buffer, 0);\r\n\r\n\t\t\t\t_r_obj_movereference ((PVOID_PTR)&localized_string, _r_format_string (L\"%s (%s)\", _r_locale_getstring (IDS_PORT), _r_locale_getstring (IDS_DIRECTION_LOCAL)));\r\n\t\t\t\t_r_listview_setcolumn (hwnd, tab_context->listview_id, 3, localized_string->buffer, 0);\r\n\r\n\t\t\t\t_r_obj_movereference ((PVOID_PTR)&localized_string, _r_format_string (L\"%s (%s)\", _r_locale_getstring (IDS_ADDRESS), _r_locale_getstring (IDS_DIRECTION_REMOTE)));\r\n\t\t\t\t_r_listview_setcolumn (hwnd, tab_context->listview_id, 4, localized_string->buffer, 0);\r\n\r\n\t\t\t\t_r_obj_movereference ((PVOID_PTR)&localized_string, _r_format_string (L\"%s (%s)\", _r_locale_getstring (IDS_HOST), _r_locale_getstring (IDS_DIRECTION_REMOTE)));\r\n\t\t\t\t_r_listview_setcolumn (hwnd, tab_context->listview_id, 5, localized_string->buffer, 0);\r\n\r\n\t\t\t\t_r_obj_movereference ((PVOID_PTR)&localized_string, _r_format_string (L\"%s (%s)\", _r_locale_getstring (IDS_PORT), _r_locale_getstring (IDS_DIRECTION_REMOTE)));\r\n\t\t\t\t_r_listview_setcolumn (hwnd, tab_context->listview_id, 6, localized_string->buffer, 0);\r\n\r\n\t\t\t\t_r_listview_setcolumn (hwnd, tab_context->listview_id, 7, _r_locale_getstring (IDS_PROTOCOL), 0);\r\n\t\t\t\t_r_listview_setcolumn (hwnd, tab_context->listview_id, 8, _r_locale_getstring (IDS_STATE), 0);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\r\n\t\t\tcase IDC_LOG:\r\n\t\t\t{\r\n\t\t\t\t_r_listview_setcolumn (hwnd, tab_context->listview_id, 1, _r_locale_getstring (IDS_NAME), 0);\r\n\t\t\t\t_r_listview_setcolumn (hwnd, tab_context->listview_id, 2, _r_locale_getstring (IDS_DATE), 0);\r\n\r\n\t\t\t\t_r_obj_movereference ((PVOID_PTR)&localized_string, _r_format_string (L\"%s (%s)\", _r_locale_getstring (IDS_ADDRESS), _r_locale_getstring (IDS_DIRECTION_LOCAL)));\r\n\t\t\t\t_r_listview_setcolumn (hwnd, tab_context->listview_id, 3, localized_string->buffer, 0);\r\n\r\n\t\t\t\t_r_obj_movereference ((PVOID_PTR)&localized_string, _r_format_string (L\"%s (%s)\", _r_locale_getstring (IDS_HOST), _r_locale_getstring (IDS_DIRECTION_LOCAL)));\r\n\t\t\t\t_r_listview_setcolumn (hwnd, tab_context->listview_id, 4, localized_string->buffer, 0);\r\n\r\n\t\t\t\t_r_obj_movereference ((PVOID_PTR)&localized_string, _r_format_string (L\"%s (%s)\", _r_locale_getstring (IDS_PORT), _r_locale_getstring (IDS_DIRECTION_LOCAL)));\r\n\t\t\t\t_r_listview_setcolumn (hwnd, tab_context->listview_id, 5, localized_string->buffer, 0);\r\n\r\n\t\t\t\t_r_obj_movereference ((PVOID_PTR)&localized_string, _r_format_string (L\"%s (%s)\", _r_locale_getstring (IDS_ADDRESS), _r_locale_getstring (IDS_DIRECTION_REMOTE)));\r\n\t\t\t\t_r_listview_setcolumn (hwnd, tab_context->listview_id, 6, localized_string->buffer, 0);\r\n\r\n\t\t\t\t_r_obj_movereference ((PVOID_PTR)&localized_string, _r_format_string (L\"%s (%s)\", _r_locale_getstring (IDS_HOST), _r_locale_getstring (IDS_DIRECTION_REMOTE)));\r\n\t\t\t\t_r_listview_setcolumn (hwnd, tab_context->listview_id, 7, localized_string->buffer, 0);\r\n\r\n\t\t\t\t_r_obj_movereference ((PVOID_PTR)&localized_string, _r_format_string (L\"%s (%s)\", _r_locale_getstring (IDS_PORT), _r_locale_getstring (IDS_DIRECTION_REMOTE)));\r\n\t\t\t\t_r_listview_setcolumn (hwnd, tab_context->listview_id, 8, localized_string->buffer, 0);\r\n\r\n\t\t\t\t_r_listview_setcolumn (hwnd, tab_context->listview_id, 9, _r_locale_getstring (IDS_PROTOCOL), 0);\r\n\t\t\t\t_r_listview_setcolumn (hwnd, tab_context->listview_id, 10, _r_locale_getstring (IDS_DIRECTION), 0);\r\n\t\t\t\t_r_listview_setcolumn (hwnd, tab_context->listview_id, 11, _r_locale_getstring (IDS_FILTER), 0);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t_app_listview_updateby_id (hwnd, DATA_LISTVIEW_CURRENT, PR_UPDATE_TYPE | PR_UPDATE_FORCE);\r\n\r\n\tif (localized_string)\r\n\t\t_r_obj_dereference (localized_string);\r\n}\r\n\r\nVOID _app_message_uninitialize (\r\n\t_In_ HWND hwnd\r\n)\r\n{\r\n\t_r_tray_destroy (hwnd, &GUID_TrayIcon);\r\n}\r\n\r\nVOID _app_generate_appmenu (\r\n\t_In_ HMENU hmenu,\r\n\t_In_opt_ HMENU hsubmenu_rules,\r\n\t_In_opt_ HMENU hsubmenu_timers,\r\n\t_In_ ULONG app_hash\r\n)\r\n{\r\n\t_r_menu_addseparator (hmenu);\r\n\r\n\t// show rules\r\n\tif (hsubmenu_rules)\r\n\t{\r\n\t\t_r_menu_addsubmenu (hmenu, INT_ERROR, hsubmenu_rules, _r_locale_getstring (IDS_TRAY_RULES));\r\n\r\n\t\t_r_menu_additem (hsubmenu_rules, IDM_DISABLENOTIFICATIONS, _r_locale_getstring (IDS_DISABLENOTIFICATIONS));\r\n\t\t_r_menu_additem (hsubmenu_rules, IDM_DISABLEREMOVAL, _r_locale_getstring (IDS_DISABLEREMOVAL));\r\n\r\n\t\tif (_app_isdisabledremoval (app_hash))\r\n\t\t\t_r_menu_enableitem (hsubmenu_rules, IDM_DISABLEREMOVAL, FALSE, FALSE);\r\n\r\n\t\t_r_menu_addseparator (hsubmenu_rules);\r\n\r\n\t\t_app_generate_rulescontrol (hsubmenu_rules, app_hash, NULL);\r\n\t}\r\n\r\n\t// show timers\r\n\tif (hsubmenu_timers)\r\n\t{\r\n\t\t_r_menu_addsubmenu (hmenu, INT_ERROR, hsubmenu_timers, _r_locale_getstring (IDS_TIMER));\r\n\r\n\t\t_r_menu_additem (hsubmenu_timers, IDM_DISABLETIMER, _r_locale_getstring (IDS_DISABLETIMER));\r\n\t\t_r_menu_addseparator (hsubmenu_timers);\r\n\r\n\t\t_app_generate_timerscontrol (hsubmenu_timers, app_hash);\r\n\t}\r\n\r\n\t_r_menu_addseparator (hmenu);\r\n}\r\n\r\nVOID _app_message_contextmenu (\r\n\t_In_ HWND hwnd,\r\n\t_In_ LPNMITEMACTIVATE lpnmlv\r\n)\r\n{\r\n\tPR_STRING localized_string = NULL;\r\n\tPR_STRING column_text = NULL;\r\n\tHMENU hsubmenu_timers = NULL;\r\n\tHMENU hsubmenu_rules = NULL;\r\n\tHMENU hmenu;\r\n\tPITEM_NETWORK ptr_network;\r\n\tPITEM_APP ptr_app = NULL;\r\n\tULONG hash_code;\r\n\tULONG app_hash;\r\n\tINT listview_id;\r\n\tINT command_id;\r\n\tBOOLEAN is_readonly = FALSE;\r\n\tBOOLEAN is_checked = FALSE;\r\n\r\n\tif (lpnmlv->iItem == INT_ERROR)\r\n\t\treturn;\r\n\r\n\tlistview_id = (INT)(INT_PTR)lpnmlv->hdr.idFrom;\r\n\r\n\tif (!(listview_id >= IDC_APPS_PROFILE && listview_id <= IDC_LOG))\r\n\t\treturn;\r\n\r\n\thmenu = CreatePopupMenu ();\r\n\r\n\tif (!hmenu)\r\n\t\treturn;\r\n\r\n\tapp_hash = _app_listview_getappcontext (hwnd, listview_id, lpnmlv->iItem);\r\n\r\n\tswitch (listview_id)\r\n\t{\r\n\t\tcase IDC_APPS_PROFILE:\r\n\t\tcase IDC_APPS_SERVICE:\r\n\t\tcase IDC_APPS_UWP:\r\n\t\t{\r\n\t\t\tptr_app = _app_getappitem (app_hash);\r\n\r\n\t\t\t_r_obj_movereference ((PVOID_PTR)&localized_string, _r_obj_concatstrings (2, _r_locale_getstring (IDS_EDIT2), L\"...\\tEnter\"));\r\n\r\n\t\t\t_r_menu_additem_ex (hmenu, IDM_PROPERTIES, localized_string->buffer, MF_DEFAULT);\r\n\r\n\t\t\thsubmenu_rules = CreatePopupMenu ();\r\n\t\t\thsubmenu_timers = CreatePopupMenu ();\r\n\r\n\t\t\t_app_generate_appmenu (hmenu, hsubmenu_rules, hsubmenu_timers, app_hash);\r\n\r\n\t\t\t_r_obj_movereference ((PVOID_PTR)&localized_string, _r_obj_concatstrings (2, _r_locale_getstring (IDS_EXPLORE), L\"\\tCtrl+E\"));\r\n\t\t\t_r_menu_additem (hmenu, IDM_EXPLORE, localized_string->buffer);\r\n\r\n\t\t\t_r_obj_movereference ((PVOID_PTR)&localized_string, _r_obj_concatstrings (2, _r_locale_getstring (IDS_DELETE), L\"\\tDel\"));\r\n\t\t\t_r_menu_additem (hmenu, IDM_DELETE, localized_string->buffer);\r\n\r\n\t\t\t_r_menu_addseparator (hmenu);\r\n\t\t\t_r_menu_additem (hmenu, IDM_CHECK, _r_locale_getstring (IDS_CHECK));\r\n\t\t\t_r_menu_additem (hmenu, IDM_UNCHECK, _r_locale_getstring (IDS_UNCHECK));\r\n\t\t\t_r_menu_addseparator (hmenu);\r\n\r\n\t\t\t_r_obj_movereference ((PVOID_PTR)&localized_string, _r_obj_concatstrings (2, _r_locale_getstring (IDS_SELECT_ALL), L\"\\tCtrl+A\"));\r\n\t\t\t_r_menu_additem (hmenu, IDM_SELECT_ALL, localized_string->buffer);\r\n\r\n\t\t\t_r_menu_addseparator (hmenu);\r\n\r\n\t\t\t_r_obj_movereference ((PVOID_PTR)&localized_string, _r_obj_concatstrings (2, _r_locale_getstring (IDS_COPY), L\"\\tCtrl+C\"));\r\n\t\t\t_r_menu_additem (hmenu, IDM_COPY, localized_string->buffer);\r\n\r\n\t\t\tcolumn_text = _r_listview_getcolumntext (hwnd, listview_id, lpnmlv->iSubItem);\r\n\r\n\t\t\tif (column_text)\r\n\t\t\t{\r\n\t\t\t\t_r_obj_movereference ((PVOID_PTR)&localized_string, _r_obj_concatstrings (4, _r_locale_getstring (IDS_COPY), L\" \\\"\", column_text->buffer, L\"\\\"\"));\r\n\t\t\t\t_r_menu_additem (hmenu, IDM_COPY_VALUE, localized_string->buffer);\r\n\r\n\t\t\t\t_r_obj_dereference (column_text);\r\n\t\t\t}\r\n\r\n\t\t\tif (ptr_app)\r\n\t\t\t{\r\n\t\t\t\tif (_app_getappinfo (ptr_app, INFO_IS_SILENT, &is_checked, sizeof (BOOLEAN)))\r\n\t\t\t\t{\r\n\t\t\t\t\tif (is_checked)\r\n\t\t\t\t\t\t_r_menu_checkitem (hmenu, IDM_DISABLENOTIFICATIONS, 0, MF_BYCOMMAND, is_checked);\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif (_app_getappinfo (ptr_app, INFO_IS_UNDELETABLE, &is_checked, sizeof (BOOLEAN)))\r\n\t\t\t\t{\r\n\t\t\t\t\tif (is_checked)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t_r_menu_checkitem (hmenu, IDM_DISABLEREMOVAL, 0, MF_BYCOMMAND, is_checked);\r\n\r\n\t\t\t\t\t\t_r_menu_enableitem (hmenu, IDM_DELETE, FALSE, FALSE);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase IDC_RULES_BLOCKLIST:\r\n\t\tcase IDC_RULES_SYSTEM:\r\n\t\tcase IDC_RULES_CUSTOM:\r\n\t\t{\r\n\t\t\tif (listview_id == IDC_RULES_CUSTOM)\r\n\t\t\t{\r\n\t\t\t\t_r_obj_movereference ((PVOID_PTR)&localized_string, _r_obj_concatstrings (2, _r_locale_getstring (IDS_ADD), L\"...\"));\r\n\t\t\t\t_r_menu_additem (hmenu, IDM_OPENRULESEDITOR, localized_string->buffer);\r\n\t\t\t}\r\n\r\n\t\t\t_r_obj_movereference ((PVOID_PTR)&localized_string, _r_obj_concatstrings (2, _r_locale_getstring (IDS_EDIT2), L\"...\\tEnter\"));\r\n\t\t\t_r_menu_additem_ex (hmenu, IDM_PROPERTIES, localized_string->buffer, MF_DEFAULT);\r\n\r\n\t\t\tif (listview_id == IDC_RULES_CUSTOM)\r\n\t\t\t{\r\n\t\t\t\t_r_obj_movereference ((PVOID_PTR)&localized_string, _r_obj_concatstrings (2, _r_locale_getstring (IDS_DELETE), L\"\\tDel\"));\r\n\t\t\t\t_r_menu_additem (hmenu, IDM_DELETE, localized_string->buffer);\r\n\r\n\t\t\t\thash_code = (ULONG)_app_listview_getitemcontext (hwnd, listview_id, lpnmlv->iItem);\r\n\r\n\t\t\t\tif (_app_getruleinfobyid (hash_code, INFO_IS_READONLY, &is_readonly, sizeof (BOOLEAN)))\r\n\t\t\t\t{\r\n\t\t\t\t\tif (is_readonly)\r\n\t\t\t\t\t\t_r_menu_enableitem (hmenu, IDM_DELETE, FALSE, FALSE);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\t_r_menu_addseparator (hmenu);\r\n\t\t\t_r_menu_additem (hmenu, IDM_CHECK, _r_locale_getstring (IDS_CHECK));\r\n\t\t\t_r_menu_additem (hmenu, IDM_UNCHECK, _r_locale_getstring (IDS_UNCHECK));\r\n\t\t\t_r_menu_addseparator (hmenu);\r\n\r\n\t\t\t_r_obj_movereference ((PVOID_PTR)&localized_string, _r_obj_concatstrings (2, _r_locale_getstring (IDS_SELECT_ALL), L\"\\tCtrl+A\"));\r\n\r\n\t\t\t_r_menu_additem (hmenu, IDM_SELECT_ALL, localized_string->buffer);\r\n\t\t\t_r_menu_addseparator (hmenu);\r\n\r\n\t\t\t_r_obj_movereference ((PVOID_PTR)&localized_string, _r_obj_concatstrings (2, _r_locale_getstring (IDS_COPY), L\"\\tCtrl+C\"));\r\n\r\n\t\t\t_r_menu_additem (hmenu, IDM_COPY, localized_string->buffer);\r\n\r\n\t\t\tcolumn_text = _r_listview_getcolumntext (hwnd, listview_id, lpnmlv->iSubItem);\r\n\r\n\t\t\tif (column_text)\r\n\t\t\t{\r\n\t\t\t\t_r_obj_movereference ((PVOID_PTR)&localized_string, _r_obj_concatstrings (4, _r_locale_getstring (IDS_COPY), L\" \\\"\", column_text->buffer, L\"\\\"\"));\r\n\r\n\t\t\t\t_r_menu_additem (hmenu, IDM_COPY_VALUE, localized_string->buffer);\r\n\r\n\t\t\t\t_r_obj_dereference (column_text);\r\n\t\t\t}\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase IDC_NETWORK:\r\n\t\t{\r\n\t\t\t_r_obj_movereference ((PVOID_PTR)&localized_string, _r_obj_concatstrings (2, _r_locale_getstring (IDS_SHOWINLIST), L\"\\tEnter\"));\r\n\t\t\t_r_menu_additem_ex (hmenu, IDM_PROPERTIES, localized_string->buffer, MF_DEFAULT);\r\n\r\n\t\t\t_r_obj_movereference ((PVOID_PTR)&localized_string, _r_obj_concatstrings (2, _r_locale_getstring (IDS_OPENRULESEDITOR), L\"...\"));\r\n\t\t\t_r_menu_additem (hmenu, IDM_OPENRULESEDITOR, localized_string->buffer);\r\n\r\n\t\t\t_r_menu_addseparator (hmenu);\r\n\r\n\t\t\t_r_obj_movereference ((PVOID_PTR)&localized_string, _r_obj_concatstrings (2, _r_locale_getstring (IDS_EXPLORE), L\"\\tCtrl+E\"));\r\n\t\t\t_r_menu_additem (hmenu, IDM_EXPLORE, localized_string->buffer);\r\n\r\n\t\t\t_r_menu_additem (hmenu, IDM_DELETE, _r_locale_getstring (IDS_NETWORK_CLOSE));\r\n\t\t\t_r_menu_addseparator (hmenu);\r\n\r\n\t\t\t_r_obj_movereference ((PVOID_PTR)&localized_string, _r_obj_concatstrings (2, _r_locale_getstring (IDS_SELECT_ALL), L\"\\tCtrl+A\"));\r\n\t\t\t_r_menu_additem (hmenu, IDM_SELECT_ALL, localized_string->buffer);\r\n\r\n\t\t\t_r_menu_addseparator (hmenu);\r\n\r\n\t\t\t_r_obj_movereference ((PVOID_PTR)&localized_string, _r_obj_concatstrings (2, _r_locale_getstring (IDS_COPY), L\"\\tCtrl+C\"));\r\n\t\t\t_r_menu_additem (hmenu, IDM_COPY, localized_string->buffer);\r\n\r\n\t\t\tcolumn_text = _r_listview_getcolumntext (hwnd, listview_id, lpnmlv->iSubItem);\r\n\r\n\t\t\tif (column_text)\r\n\t\t\t{\r\n\t\t\t\t_r_obj_movereference ((PVOID_PTR)&localized_string, _r_obj_concatstrings (4, _r_locale_getstring (IDS_COPY), L\" \\\"\", column_text->buffer, L\"\\\"\"));\r\n\r\n\t\t\t\t_r_menu_additem (hmenu, IDM_COPY_VALUE, localized_string->buffer);\r\n\r\n\t\t\t\t_r_obj_dereference (column_text);\r\n\t\t\t}\r\n\r\n\t\t\thash_code = (ULONG)_app_listview_getitemcontext (hwnd, listview_id, lpnmlv->iItem);\r\n\r\n\t\t\tptr_network = _app_network_getitem (hash_code);\r\n\r\n\t\t\tif (ptr_network)\r\n\t\t\t{\r\n\t\t\t\tif (ptr_network->af != AF_INET || ptr_network->state != MIB_TCP_STATE_ESTAB)\r\n\t\t\t\t\t_r_menu_enableitem (hmenu, IDM_DELETE, FALSE, FALSE);\r\n\r\n\t\t\t\t_r_obj_dereference (ptr_network);\r\n\t\t\t}\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase IDC_LOG:\r\n\t\t{\r\n\t\t\t_r_obj_movereference ((PVOID_PTR)&localized_string, _r_obj_concatstrings (2, _r_locale_getstring (IDS_SHOWINLIST), L\"\\tEnter\"));\r\n\t\t\t_r_menu_additem_ex (hmenu, IDM_PROPERTIES, localized_string->buffer, MF_DEFAULT);\r\n\r\n\t\t\t_r_obj_movereference ((PVOID_PTR)&localized_string, _r_obj_concatstrings (2, _r_locale_getstring (IDS_OPENRULESEDITOR), L\"...\"));\r\n\t\t\t_r_menu_additem (hmenu, IDM_OPENRULESEDITOR, localized_string->buffer);\r\n\r\n\t\t\thsubmenu_rules = CreatePopupMenu ();\r\n\t\t\thsubmenu_timers = CreatePopupMenu ();\r\n\r\n\t\t\t_app_generate_appmenu (hmenu, hsubmenu_rules, hsubmenu_timers, app_hash);\r\n\r\n\t\t\t_r_obj_movereference ((PVOID_PTR)&localized_string, _r_obj_concatstrings (2, _r_locale_getstring (IDS_EXPLORE), L\"\\tCtrl+E\"));\r\n\t\t\t_r_menu_additem (hmenu, IDM_EXPLORE, localized_string->buffer);\r\n\r\n\t\t\t_r_obj_movereference ((PVOID_PTR)&localized_string, _r_obj_concatstrings (2, _r_locale_getstring (IDS_LOGCLEAR), L\"\\tCtrl+X\"));\r\n\t\t\t_r_menu_additem (hmenu, IDM_TRAY_LOGCLEAR, localized_string->buffer);\r\n\r\n\t\t\t_r_menu_addseparator (hmenu);\r\n\r\n\t\t\t_r_obj_movereference ((PVOID_PTR)&localized_string, _r_obj_concatstrings (2, _r_locale_getstring (IDS_SELECT_ALL), L\"\\tCtrl+A\"));\r\n\t\t\t_r_menu_additem (hmenu, IDM_SELECT_ALL, localized_string->buffer);\r\n\r\n\t\t\t_r_menu_addseparator (hmenu);\r\n\r\n\t\t\t_r_obj_movereference ((PVOID_PTR)&localized_string, _r_obj_concatstrings (2, _r_locale_getstring (IDS_COPY), L\"\\tCtrl+C\"));\r\n\t\t\t_r_menu_additem (hmenu, IDM_COPY, localized_string->buffer);\r\n\r\n\t\t\tcolumn_text = _r_listview_getcolumntext (hwnd, listview_id, lpnmlv->iSubItem);\r\n\r\n\t\t\tif (column_text)\r\n\t\t\t{\r\n\t\t\t\t_r_obj_movereference ((PVOID_PTR)&localized_string, _r_obj_concatstrings (4, _r_locale_getstring (IDS_COPY), L\" \\\"\", column_text->buffer, L\"\\\"\"));\r\n\t\t\t\t_r_menu_additem (hmenu, IDM_COPY_VALUE, localized_string->buffer);\r\n\r\n\t\t\t\t_r_obj_dereference (column_text);\r\n\t\t\t}\r\n\r\n\t\t\tptr_app = _app_getappitem (app_hash);\r\n\r\n\t\t\tif (ptr_app)\r\n\t\t\t{\r\n\t\t\t\tif (_app_getappinfo (ptr_app, INFO_IS_SILENT, &is_checked, sizeof (BOOLEAN)))\r\n\t\t\t\t{\r\n\t\t\t\t\tif (is_checked)\r\n\t\t\t\t\t\t_r_menu_checkitem (hmenu, IDM_DISABLENOTIFICATIONS, 0, MF_BYCOMMAND, is_checked);\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif (_app_getappinfo (ptr_app, INFO_IS_UNDELETABLE, &is_checked, sizeof (BOOLEAN)))\r\n\t\t\t\t{\r\n\t\t\t\t\tif (is_checked)\r\n\t\t\t\t\t\t_r_menu_checkitem (hmenu, IDM_DISABLEREMOVAL, 0, MF_BYCOMMAND, is_checked);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\r\n\tcommand_id = _r_menu_popup (hmenu, hwnd, NULL, FALSE);\r\n\r\n\tif (command_id)\r\n\t\t_r_ctrl_sendcommand (hwnd, command_id, (LPARAM)lpnmlv->iSubItem);\r\n\r\n\tif (hsubmenu_rules)\r\n\t\tDestroyMenu (hsubmenu_rules);\r\n\r\n\tif (hsubmenu_timers)\r\n\t\tDestroyMenu (hsubmenu_timers);\r\n\r\n\tDestroyMenu (hmenu);\r\n\r\n\tif (localized_string)\r\n\t\t_r_obj_dereference (localized_string);\r\n\r\n\tif (ptr_app)\r\n\t\t_r_obj_dereference (ptr_app);\r\n}\r\n\r\nVOID _app_message_contextmenu_columns (\r\n\t_In_ HWND hwnd,\r\n\t_In_ LPNMHDR nmlp\r\n)\r\n{\r\n\tPR_STRING column_text;\r\n\tHWND hlistview;\r\n\tHMENU hmenu;\r\n\tINT listview_id;\r\n\r\n\thlistview = GetParent (nmlp->hwndFrom);\r\n\r\n\tif (!hlistview)\r\n\t\treturn;\r\n\r\n\tlistview_id = GetDlgCtrlID (hlistview);\r\n\r\n\tif (!(listview_id >= IDC_APPS_PROFILE && listview_id <= IDC_LOG))\r\n\t\treturn;\r\n\r\n\thmenu = CreatePopupMenu ();\r\n\r\n\tif (!hmenu)\r\n\t\treturn;\r\n\r\n\tfor (INT i = 0; i < _r_listview_getcolumncount (hwnd, listview_id); i++)\r\n\t{\r\n\t\tcolumn_text = _r_listview_getcolumntext (hwnd, listview_id, i);\r\n\r\n\t\tif (column_text)\r\n\t\t{\r\n\t\t\t_r_menu_additem (hmenu, IDX_COLUMN + i, column_text->buffer);\r\n\r\n\t\t\t_r_menu_checkitem (hmenu, IDX_COLUMN + i, 0, MF_BYCOMMAND, TRUE);\r\n\r\n\t\t\t_r_obj_dereference (column_text);\r\n\t\t}\r\n\r\n\t}\r\n\r\n\t_r_menu_popup (hmenu, hwnd, NULL, TRUE);\r\n\r\n\tDestroyMenu (hmenu);\r\n}\r\n\r\nVOID _app_message_traycontextmenu (\r\n\t_In_ HWND hwnd\r\n)\r\n{\r\n\tENUM_INSTALL_TYPE install_type;\r\n\tHMENU hsubmenu;\r\n\tHMENU hmenu;\r\n\r\n\thmenu = LoadMenuW (NULL, MAKEINTRESOURCE (IDM_TRAY));\r\n\r\n\tif (!hmenu)\r\n\t\treturn;\r\n\r\n\thsubmenu = GetSubMenu (hmenu, 0);\r\n\r\n\tif (!hsubmenu)\r\n\t{\r\n\t\tDestroyMenu (hmenu);\r\n\r\n\t\treturn;\r\n\t}\r\n\r\n\tinstall_type = _wfp_getinstalltype ();\r\n\r\n\t_r_menu_setitembitmap (hsubmenu, IDM_TRAY_START, FALSE, _app_getstatebitmap (install_type));\r\n\r\n\t// localize\r\n\t_r_menu_setitemtext (hsubmenu, IDM_TRAY_SHOW, FALSE, _r_locale_getstring (IDS_TRAY_SHOW));\r\n\t_r_menu_setitemtext (hsubmenu, IDM_TRAY_START, FALSE, _app_getstateaction (install_type));\r\n\t_r_menu_setitemtext (hsubmenu, NOTIFICATIONS_ID, TRUE, _r_locale_getstring (IDS_TITLE_NOTIFICATIONS));\r\n\t_r_menu_setitemtext (hsubmenu, LOGGING_ID, TRUE, _r_locale_getstring (IDS_TITLE_LOGGING));\r\n\t_r_menu_setitemtext (hsubmenu, IDM_TRAY_ENABLENOTIFICATIONS_CHK, FALSE, _r_locale_getstring (IDS_ENABLENOTIFICATIONS_CHK));\r\n\t_r_menu_setitemtext (hsubmenu, IDM_TRAY_ENABLENOTIFICATIONSSOUND_CHK, FALSE, _r_locale_getstring (IDS_NOTIFICATIONSOUND_CHK));\r\n\t_r_menu_setitemtext (hsubmenu, IDM_TRAY_NOTIFICATIONFULLSCREENSILENTMODE_CHK, FALSE, _r_locale_getstring (IDS_NOTIFICATIONFULLSCREENSILENTMODE_CHK));\r\n\t_r_menu_setitemtext (hsubmenu, IDM_TRAY_NOTIFICATIONONTRAY_CHK, FALSE, _r_locale_getstring (IDS_NOTIFICATIONONTRAY_CHK));\r\n\t_r_menu_setitemtext (hsubmenu, IDM_TRAY_ENABLELOG_CHK, FALSE, _r_locale_getstring (IDS_ENABLELOG_CHK));\r\n\t_r_menu_setitemtextformat (hsubmenu, IDM_TRAY_ENABLEUILOG_CHK, FALSE, L\"%s (%s)\", _r_locale_getstring (IDS_ENABLEUILOG_CHK), _r_locale_getstring (IDS_SESSION_ONLY));\r\n\r\n\t_r_menu_setitemtext (hsubmenu, IDM_TRAY_LOGSHOW, FALSE, _r_locale_getstring (IDS_LOGSHOW));\r\n\t_r_menu_setitemtext (hsubmenu, IDM_TRAY_LOGCLEAR, FALSE, _r_locale_getstring (IDS_LOGCLEAR));\r\n\r\n\tif (_r_fs_isexists (&_r_app_getlogpath ()->sr))\r\n\t{\r\n\t\t_r_menu_setitemtext (hsubmenu, ERRLOG_ID, TRUE, _r_locale_getstring (IDS_TRAY_LOGERR));\r\n\r\n\t\t_r_menu_setitemtext (hsubmenu, IDM_TRAY_LOGSHOW_ERR, FALSE, _r_locale_getstring (IDS_LOGSHOW));\r\n\t\t_r_menu_setitemtext (hsubmenu, IDM_TRAY_LOGCLEAR_ERR, FALSE, _r_locale_getstring (IDS_LOGCLEAR));\r\n\t}\r\n\telse\r\n\t{\r\n\t\tDeleteMenu (hsubmenu, ERRLOG_ID, MF_BYPOSITION);\r\n\t}\r\n\r\n\t_r_menu_setitemtextformat (hsubmenu, IDM_TRAY_SETTINGS, FALSE, L\"%s...\", _r_locale_getstring (IDS_SETTINGS));\r\n\t_r_menu_setitemtext (hsubmenu, IDM_TRAY_WEBSITE, FALSE, _r_locale_getstring (IDS_WEBSITE));\r\n\t_r_menu_setitemtext (hsubmenu, IDM_TRAY_ABOUT, FALSE, _r_locale_getstring (IDS_ABOUT));\r\n\t_r_menu_setitemtext (hsubmenu, IDM_TRAY_EXIT, FALSE, _r_locale_getstring (IDS_EXIT));\r\n\t_r_menu_checkitem (hsubmenu, IDM_TRAY_ENABLENOTIFICATIONS_CHK, 0, MF_BYCOMMAND, _r_config_getboolean (L\"IsNotificationsEnabled\", TRUE, NULL));\r\n\t_r_menu_checkitem (hsubmenu, IDM_TRAY_ENABLENOTIFICATIONSSOUND_CHK, 0, MF_BYCOMMAND, _r_config_getboolean (L\"IsNotificationsSound\", TRUE, NULL));\r\n\t_r_menu_checkitem (hsubmenu, IDM_TRAY_NOTIFICATIONFULLSCREENSILENTMODE_CHK, 0, MF_BYCOMMAND, _r_config_getboolean (L\"IsNotificationsFullscreenSilentMode\", TRUE, NULL));\r\n\t_r_menu_checkitem (hsubmenu, IDM_TRAY_NOTIFICATIONONTRAY_CHK, 0, MF_BYCOMMAND, _r_config_getboolean (L\"IsNotificationsOnTray\", FALSE, NULL));\r\n\t_r_menu_checkitem (hsubmenu, IDM_TRAY_ENABLELOG_CHK, 0, MF_BYCOMMAND, _r_config_getboolean (L\"IsLogEnabled\", FALSE, NULL));\r\n\t_r_menu_checkitem (hsubmenu, IDM_TRAY_ENABLEUILOG_CHK, 0, MF_BYCOMMAND, _r_config_getboolean (L\"IsLogUiEnabled\", FALSE, NULL));\r\n\r\n\tif (!_r_config_getboolean (L\"IsNotificationsEnabled\", TRUE, NULL))\r\n\t{\r\n\t\t_r_menu_enableitem (hsubmenu, IDM_TRAY_ENABLENOTIFICATIONSSOUND_CHK, FALSE, FALSE);\r\n\t\t_r_menu_enableitem (hsubmenu, IDM_TRAY_NOTIFICATIONFULLSCREENSILENTMODE_CHK, FALSE, FALSE);\r\n\t\t_r_menu_enableitem (hsubmenu, IDM_TRAY_NOTIFICATIONONTRAY_CHK, FALSE, FALSE);\r\n\t}\r\n\telse if (!_r_config_getboolean (L\"IsNotificationsSound\", TRUE, NULL))\r\n\t{\r\n\t\t_r_menu_enableitem (hsubmenu, IDM_TRAY_NOTIFICATIONFULLSCREENSILENTMODE_CHK, FALSE, FALSE);\r\n\t}\r\n\r\n\tif (_wfp_isfiltersapplying ())\r\n\t\t_r_menu_enableitem (hsubmenu, IDM_TRAY_START, FALSE, FALSE);\r\n\r\n\tSetForegroundWindow (hwnd); // don't touch\r\n\r\n\t_r_menu_popup (hsubmenu, hwnd, NULL, TRUE);\r\n\r\n\tDestroyMenu (hmenu);\r\n}\r\n\r\nVOID _app_message_dpichanged (\r\n\t_In_ HWND hwnd,\r\n\t_In_ LONG dpi_value\r\n)\r\n{\r\n\tPR_STRING localized_string = NULL;\r\n\r\n\t_app_windowloadfont (dpi_value);\r\n\r\n\t_app_imagelist_init (hwnd, dpi_value);\r\n\r\n\t// reset toolbar information\r\n\t_app_setinterfacestate (hwnd, dpi_value);\r\n\r\n\t_r_toolbar_setbutton (config.hrebar, IDC_TOOLBAR, IDM_REFRESH, _r_locale_getstring (IDS_REFRESH), BTNS_BUTTON | BTNS_AUTOSIZE | BTNS_SHOWTEXT, 0, I_IMAGENONE);\r\n\t_r_toolbar_setbutton (config.hrebar, IDC_TOOLBAR, IDM_SETTINGS, _r_locale_getstring (IDS_SETTINGS), BTNS_BUTTON | BTNS_AUTOSIZE | BTNS_SHOWTEXT, 0, I_IMAGENONE);\r\n\r\n\t_r_obj_movereference ((PVOID_PTR)&localized_string, _r_obj_concatstrings (2, _r_locale_getstring (IDS_OPENRULESEDITOR), L\"...\"));\r\n\t_r_toolbar_setbutton (config.hrebar, IDC_TOOLBAR, IDM_OPENRULESEDITOR, localized_string->buffer, BTNS_BUTTON | BTNS_AUTOSIZE, 0, I_IMAGENONE);\r\n\r\n\t_r_toolbar_setbutton (config.hrebar, IDC_TOOLBAR, IDM_TRAY_ENABLENOTIFICATIONS_CHK, _r_locale_getstring (IDS_ENABLENOTIFICATIONS_CHK), BTNS_CHECK | BTNS_AUTOSIZE, 0, I_IMAGENONE);\r\n\t_r_toolbar_setbutton (config.hrebar, IDC_TOOLBAR, IDM_TRAY_ENABLELOG_CHK, _r_locale_getstring (IDS_ENABLELOG_CHK), BTNS_CHECK | BTNS_AUTOSIZE, 0, I_IMAGENONE);\r\n\t_r_toolbar_setbutton (config.hrebar, IDC_TOOLBAR, IDM_TRAY_ENABLEUILOG_CHK, _r_locale_getstring (IDS_ENABLEUILOG_CHK), BTNS_CHECK | BTNS_AUTOSIZE, 0, I_IMAGENONE);\r\n\r\n\t_r_obj_movereference ((PVOID_PTR)&localized_string, _r_obj_concatstrings (2, _r_locale_getstring (IDS_LOGSHOW), L\" (Ctrl+I)\"));\r\n\t_r_toolbar_setbutton (config.hrebar, IDC_TOOLBAR, IDM_TRAY_LOGSHOW, localized_string->buffer, BTNS_BUTTON | BTNS_AUTOSIZE, 0, I_IMAGENONE);\r\n\r\n\t_r_obj_movereference ((PVOID_PTR)&localized_string, _r_obj_concatstrings (2, _r_locale_getstring (IDS_LOGCLEAR), L\" (Ctrl+X)\"));\r\n\t_r_toolbar_setbutton (config.hrebar, IDC_TOOLBAR, IDM_TRAY_LOGCLEAR, localized_string->buffer, BTNS_BUTTON | BTNS_AUTOSIZE, 0, I_IMAGENONE);\r\n\r\n\t_r_toolbar_setbutton (config.hrebar, IDC_TOOLBAR, IDM_DONATE, _r_locale_getstring (IDS_DONATE), BTNS_BUTTON | BTNS_AUTOSIZE, 0, I_IMAGENONE);\r\n\r\n\t_app_listview_loadfont (dpi_value, TRUE);\r\n\t_app_listview_updateby_id (hwnd, DATA_LISTVIEW_CURRENT, PR_UPDATE_TYPE | PR_UPDATE_FORCE);\r\n\r\n\t_r_wnd_sendmessage (hwnd, 0, WM_SIZE, 0, 0);\r\n\r\n\t_r_obj_dereference (localized_string);\r\n}\r\n\r\nLONG_PTR _app_message_custdraw (\r\n\t_In_ HWND hwnd,\r\n\t_In_ LPNMLVCUSTOMDRAW lpnmlv\r\n)\r\n{\r\n\tPR_STRING real_path = NULL;\r\n\tPITEM_NETWORK ptr_network;\r\n\tPITEM_COLOR ptr_clr;\r\n\tPITEM_LOG ptr_log;\r\n\tCOLORREF new_clr = 0;\r\n\tULONG app_hash = 0;\r\n\tULONG index;\r\n\tINT listview_id;\r\n\tBOOLEAN is_validconnection = FALSE;\r\n\tBOOLEAN is_systemapp = FALSE;\r\n\r\n\tswitch (lpnmlv->nmcd.dwDrawStage)\r\n\t{\r\n\t\tcase CDDS_PREPAINT:\r\n\t\t{\r\n\t\t\treturn CDRF_NOTIFYITEMDRAW;\r\n\t\t}\r\n\r\n\t\tcase CDDS_ITEMPREPAINT:\r\n\t\t{\r\n\t\t\tlistview_id = (INT)(INT_PTR)lpnmlv->nmcd.hdr.idFrom;\r\n\r\n\t\t\tif (lpnmlv->dwItemType != LVCDI_ITEM)\r\n\t\t\t\treturn CDRF_DODEFAULT;\r\n\r\n\t\t\tif (!lpnmlv->nmcd.lItemlParam)\r\n\t\t\t\treturn CDRF_DODEFAULT;\r\n\r\n\t\t\tif (!_r_config_getboolean (L\"IsEnableHighlighting\", TRUE, NULL))\r\n\t\t\t\treturn CDRF_DODEFAULT;\r\n\r\n\t\t\tswitch (listview_id)\r\n\t\t\t{\r\n\t\t\t\tcase IDC_APPS_PROFILE:\r\n\t\t\t\tcase IDC_APPS_SERVICE:\r\n\t\t\t\tcase IDC_APPS_UWP:\r\n\t\t\t\tcase IDC_RULE_APPS_ID:\r\n\t\t\t\tcase IDC_NETWORK:\r\n\t\t\t\tcase IDC_LOG:\r\n\t\t\t\t{\r\n\t\t\t\t\tindex = (ULONG)_app_listview_getcontextcode (lpnmlv->nmcd.lItemlParam);\r\n\r\n\t\t\t\t\tif (listview_id == IDC_NETWORK)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tptr_network = _app_network_getitem (index);\r\n\r\n\t\t\t\t\t\tif (ptr_network)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tapp_hash = ptr_network->app_hash;\r\n\t\t\t\t\t\t\tis_systemapp = _app_isappfromsystem (ptr_network->path, app_hash);\r\n\t\t\t\t\t\t\tis_validconnection = ptr_network->is_connection;\r\n\t\t\t\t\t\t\t//is_validconnection = FALSE; // do not highlight connections\r\n\r\n\t\t\t\t\t\t\t_r_obj_dereference (ptr_network);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse if (listview_id == IDC_LOG)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tptr_log = _app_getlogitem (index);\r\n\r\n\t\t\t\t\t\tif (ptr_log)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tapp_hash = _app_getlogapp (index);\r\n\t\t\t\t\t\t\tis_systemapp = _app_isappfromsystem (ptr_log->path, app_hash);\r\n\r\n\t\t\t\t\t\t\t_r_obj_dereference (ptr_log);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tapp_hash = index;\r\n\t\t\t\t\t\tis_validconnection = _app_network_isapphaveconnection (app_hash);\r\n\r\n\t\t\t\t\t\tif (_app_getappinfobyhash (app_hash, INFO_PATH, &real_path, sizeof (PR_STRING)))\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tis_systemapp = _app_isappfromsystem (real_path, app_hash);\r\n\r\n\t\t\t\t\t\t\t_r_obj_dereference (real_path);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tif (app_hash)\r\n\t\t\t\t\t\tnew_clr = _app_getappcolor (listview_id, app_hash, is_systemapp, is_validconnection);\r\n\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tcase IDC_RULES_BLOCKLIST:\r\n\t\t\t\tcase IDC_RULES_SYSTEM:\r\n\t\t\t\tcase IDC_RULES_CUSTOM:\r\n\t\t\t\tcase IDC_APP_RULES_ID:\r\n\t\t\t\t{\r\n\t\t\t\t\tindex = (ULONG)_app_listview_getcontextcode (lpnmlv->nmcd.lItemlParam);\r\n\r\n\t\t\t\t\tnew_clr = _app_getrulecolor (listview_id, index);\r\n\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tcase IDC_COLORS:\r\n\t\t\t\t{\r\n\t\t\t\t\tptr_clr = (PITEM_COLOR)lpnmlv->nmcd.lItemlParam;\r\n\r\n\t\t\t\t\tnew_clr = ptr_clr->new_clr ? ptr_clr->new_clr : ptr_clr->default_clr;\r\n\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tdefault:\r\n\t\t\t\t{\r\n\t\t\t\t\treturn CDRF_DODEFAULT;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tif (new_clr)\r\n\t\t\t{\r\n\t\t\t\tlpnmlv->clrText = _r_dc_getcolorbrightness (new_clr);\r\n\t\t\t\tlpnmlv->clrTextBk = new_clr;\r\n\r\n\t\t\t\t_r_dc_fillrect (lpnmlv->nmcd.hdc, &lpnmlv->nmcd.rc, new_clr);\r\n\r\n\t\t\t\treturn CDRF_NEWFONT;\r\n\t\t\t}\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\r\n\treturn CDRF_DODEFAULT;\r\n}\r\n\r\nVOID _app_displayinfoapp_callback (\r\n\t_In_ PITEM_APP ptr_app,\r\n\t_Inout_ LPNMLVDISPINFOW lpnmlv\r\n)\r\n{\r\n\tPR_STRING string;\r\n\tLONG icon_id = 0;\r\n\r\n\t// set text\r\n\tif (lpnmlv->item.mask & LVIF_TEXT)\r\n\t{\r\n\t\tswitch (lpnmlv->item.iSubItem)\r\n\t\t{\r\n\t\t\tcase 0:\r\n\t\t\t{\r\n\t\t\t\tstring = _app_getappdisplayname (ptr_app, FALSE);\r\n\r\n\t\t\t\tif (string)\r\n\t\t\t\t{\r\n\t\t\t\t\t_r_str_copy (lpnmlv->item.pszText, lpnmlv->item.cchTextMax, string->buffer);\r\n\r\n\t\t\t\t\t_r_obj_dereference (string);\r\n\t\t\t\t}\r\n\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\r\n\t\t\tcase 1:\r\n\t\t\t{\r\n\t\t\t\tstring = _r_format_unixtime (ptr_app->timestamp, FDTF_SHORTDATE | FDTF_LONGTIME);\r\n\r\n\t\t\t\tif (string)\r\n\t\t\t\t{\r\n\t\t\t\t\t_r_str_copy (lpnmlv->item.pszText, lpnmlv->item.cchTextMax, string->buffer);\r\n\r\n\t\t\t\t\t_r_obj_dereference (string);\r\n\t\t\t\t}\r\n\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t// set image\r\n\tif (lpnmlv->item.mask & LVIF_IMAGE)\r\n\t{\r\n\t\tif (_app_getappinfoparam2 (ptr_app->app_hash, (INT)lpnmlv->hdr.idFrom, INFO_ICON_ID, &icon_id, sizeof (LONG)))\r\n\t\t\tlpnmlv->item.iImage = icon_id;\r\n\t}\r\n\r\n\t// set group id\r\n\tif (lpnmlv->item.mask & LVIF_GROUPID)\r\n\t{\r\n\t\tif (_app_listview_isitemhidden (lpnmlv->item.lParam))\r\n\t\t{\r\n\t\t\tlpnmlv->item.iGroupId = LV_HIDDEN_GROUP_ID;\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tif (lpnmlv->hdr.idFrom == IDC_RULE_APPS_ID)\r\n\t\t\t{\r\n\t\t\t\tif (ptr_app->type == DATA_APP_UWP)\r\n\t\t\t\t{\r\n\t\t\t\t\tlpnmlv->item.iGroupId = 2;\r\n\t\t\t\t}\r\n\t\t\t\telse if (ptr_app->type == DATA_APP_SERVICE)\r\n\t\t\t\t{\r\n\t\t\t\t\tlpnmlv->item.iGroupId = 1;\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\tlpnmlv->item.iGroupId = 0;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\t// apps with special rule\r\n\t\t\t\tif (_app_isapphaverule (ptr_app->app_hash, FALSE))\r\n\t\t\t\t{\r\n\t\t\t\t\tlpnmlv->item.iGroupId = 2;\r\n\t\t\t\t}\r\n\t\t\t\telse if (_app_istimerset (ptr_app))\r\n\t\t\t\t{\r\n\t\t\t\t\tlpnmlv->item.iGroupId = 1;\r\n\t\t\t\t}\r\n\t\t\t\telse if (ptr_app->is_enabled)\r\n\t\t\t\t{\r\n\t\t\t\t\tlpnmlv->item.iGroupId = 0;\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\t// silent apps without rules and not enabled added into silent group\r\n\t\t\t\t\tif (ptr_app->is_silent)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tlpnmlv->item.iGroupId = 4;\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tlpnmlv->item.iGroupId = 3;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n\r\nVOID _app_displayinforule_callback (\r\n\t_In_ INT listview_id,\r\n\t_In_ PITEM_RULE ptr_rule,\r\n\t_Inout_ LPNMLVDISPINFOW lpnmlv\r\n)\r\n{\r\n\tPR_STRING string;\r\n\r\n\t// set text\r\n\tif (lpnmlv->item.mask & LVIF_TEXT)\r\n\t{\r\n\t\tswitch (lpnmlv->item.iSubItem)\r\n\t\t{\r\n\t\t\tcase 0:\r\n\t\t\t{\r\n\t\t\t\tif (ptr_rule->name)\r\n\t\t\t\t{\r\n\t\t\t\t\tif (ptr_rule->is_readonly && ptr_rule->type == DATA_RULE_USER)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t_r_str_printf (lpnmlv->item.pszText, lpnmlv->item.cchTextMax, L\"%s\" SZ_RULE_INTERNAL_MENU, ptr_rule->name->buffer);\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t_r_str_copy (lpnmlv->item.pszText, lpnmlv->item.cchTextMax, ptr_rule->name->buffer);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\t_r_str_copy (lpnmlv->item.pszText, lpnmlv->item.cchTextMax, _r_locale_getstring (IDS_STATUS_EMPTY));\r\n\t\t\t\t}\r\n\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\r\n\t\t\tcase 1:\r\n\t\t\t{\r\n\t\t\t\tif (ptr_rule->protocol_str)\r\n\t\t\t\t{\r\n\t\t\t\t\t_r_str_copy (lpnmlv->item.pszText, lpnmlv->item.cchTextMax, ptr_rule->protocol_str->buffer);\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\t_r_str_copy (lpnmlv->item.pszText, lpnmlv->item.cchTextMax, _r_locale_getstring (IDS_ANY));\r\n\t\t\t\t}\r\n\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\r\n\t\t\tcase 2:\r\n\t\t\t{\r\n\t\t\t\tstring = _app_db_getdirectionname (ptr_rule->direction, FALSE, TRUE);\r\n\r\n\t\t\t\tif (string)\r\n\t\t\t\t{\r\n\t\t\t\t\t_r_str_copy (lpnmlv->item.pszText, lpnmlv->item.cchTextMax, string->buffer);\r\n\r\n\t\t\t\t\t_r_obj_dereference (string);\r\n\t\t\t\t}\r\n\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t// set image\r\n\tif (lpnmlv->item.mask & LVIF_IMAGE)\r\n\t\tlpnmlv->item.iImage = (ptr_rule->action == FWP_ACTION_BLOCK) ? 1 : 0;\r\n\r\n\t// set group id\r\n\tif (lpnmlv->item.mask & LVIF_GROUPID)\r\n\t{\r\n\t\tif (_app_listview_isitemhidden (lpnmlv->item.lParam))\r\n\t\t{\r\n\t\t\tlpnmlv->item.iGroupId = LV_HIDDEN_GROUP_ID;\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tif (listview_id == IDC_APP_RULES_ID)\r\n\t\t\t{\r\n\t\t\t\tlpnmlv->item.iGroupId = ptr_rule->is_readonly ? 0 : 1;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tif (ptr_rule->is_enabled)\r\n\t\t\t\t{\r\n\t\t\t\t\tif (ptr_rule->is_forservices || !_r_obj_isempty (ptr_rule->apps))\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tlpnmlv->item.iGroupId = 1;\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tlpnmlv->item.iGroupId = 0;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\tlpnmlv->item.iGroupId = 2;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n\r\nVOID _app_displayinfonetwork_callback (\r\n\t_In_ PITEM_NETWORK ptr_network,\r\n\t_Inout_ LPNMLVDISPINFOW lpnmlv\r\n)\r\n{\r\n\tPITEM_APP ptr_app;\r\n\tPR_STRING string;\r\n\tLPCWSTR name;\r\n\tLONG icon_id = 0;\r\n\r\n\t// set text\r\n\tif (lpnmlv->item.mask & LVIF_TEXT)\r\n\t{\r\n\t\tswitch (lpnmlv->item.iSubItem)\r\n\t\t{\r\n\t\t\tcase 0:\r\n\t\t\t{\r\n\t\t\t\tptr_app = _app_getappitem (ptr_network->app_hash);\r\n\r\n\t\t\t\tif (ptr_app)\r\n\t\t\t\t{\r\n\t\t\t\t\tstring = _app_getappdisplayname (ptr_app, TRUE);\r\n\r\n\t\t\t\t\tif (string)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t_r_str_copy (lpnmlv->item.pszText, lpnmlv->item.cchTextMax, string->buffer);\r\n\r\n\t\t\t\t\t\t_r_obj_dereference (string);\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\t_r_obj_dereference (ptr_app);\r\n\t\t\t\t}\r\n\t\t\t\telse if (ptr_network->path)\r\n\t\t\t\t{\r\n\t\t\t\t\t_r_str_copy (lpnmlv->item.pszText, lpnmlv->item.cchTextMax, _r_path_getbasename (&ptr_network->path->sr));\r\n\t\t\t\t}\r\n\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\r\n\t\t\tcase 1:\r\n\t\t\t{\r\n\t\t\t\tstring = _InterlockedCompareExchangePointer ((volatile PVOID_PTR)&ptr_network->local_addr_str, NULL, NULL);\r\n\r\n\t\t\t\tif (string)\r\n\t\t\t\t\t_r_str_copy (lpnmlv->item.pszText, lpnmlv->item.cchTextMax, string->buffer);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\r\n\t\t\tcase 2:\r\n\t\t\t{\r\n\t\t\t\tstring = _InterlockedCompareExchangePointer ((volatile PVOID_PTR)&ptr_network->local_host_str, NULL, NULL);\r\n\r\n\t\t\t\tif (string)\r\n\t\t\t\t{\r\n\t\t\t\t\t_r_str_copy (lpnmlv->item.pszText, lpnmlv->item.cchTextMax, string->buffer);\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\t_r_str_copy (lpnmlv->item.pszText, lpnmlv->item.cchTextMax, _r_locale_getstring (IDS_LOADING));\r\n\t\t\t\t}\r\n\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\r\n\t\t\tcase 3:\r\n\t\t\t{\r\n\t\t\t\tif (ptr_network->local_port)\r\n\t\t\t\t{\r\n\t\t\t\t\tstring = _app_formatport (ptr_network->local_port, ptr_network->protocol);\r\n\r\n\t\t\t\t\tif (string)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t_r_str_copy (lpnmlv->item.pszText, lpnmlv->item.cchTextMax, string->buffer);\r\n\r\n\t\t\t\t\t\t_r_obj_dereference (string);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\r\n\t\t\tcase 4:\r\n\t\t\t{\r\n\t\t\t\tstring = _InterlockedCompareExchangePointer ((volatile PVOID_PTR)&ptr_network->remote_addr_str, NULL, NULL);\r\n\r\n\t\t\t\tif (string)\r\n\t\t\t\t\t_r_str_copy (lpnmlv->item.pszText, lpnmlv->item.cchTextMax, string->buffer);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\r\n\t\t\tcase 5:\r\n\t\t\t{\r\n\t\t\t\tstring = _InterlockedCompareExchangePointer ((volatile PVOID_PTR)&ptr_network->remote_host_str, NULL, NULL);\r\n\r\n\t\t\t\tif (string)\r\n\t\t\t\t{\r\n\t\t\t\t\t_r_str_copy (lpnmlv->item.pszText, lpnmlv->item.cchTextMax, string->buffer);\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\t_r_str_copy (lpnmlv->item.pszText, lpnmlv->item.cchTextMax, _r_locale_getstring (IDS_LOADING));\r\n\t\t\t\t}\r\n\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\r\n\t\t\tcase 6:\r\n\t\t\t{\r\n\t\t\t\tif (ptr_network->remote_port)\r\n\t\t\t\t{\r\n\t\t\t\t\tstring = _app_formatport (ptr_network->remote_port, ptr_network->protocol);\r\n\r\n\t\t\t\t\tif (string)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t_r_str_copy (lpnmlv->item.pszText, lpnmlv->item.cchTextMax, string->buffer);\r\n\r\n\t\t\t\t\t\t_r_obj_dereference (string);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\r\n\t\t\tcase 7:\r\n\t\t\t{\r\n\t\t\t\tif (ptr_network->protocol_str)\r\n\t\t\t\t{\r\n\t\t\t\t\t_r_str_copy (lpnmlv->item.pszText, lpnmlv->item.cchTextMax, ptr_network->protocol_str->buffer);\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\t_r_str_copy (lpnmlv->item.pszText, lpnmlv->item.cchTextMax, _r_locale_getstring (IDS_ANY));\r\n\t\t\t\t}\r\n\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\r\n\t\t\tcase 8:\r\n\t\t\t{\r\n\t\t\t\tname = _app_db_getconnectionstatename (ptr_network->state);\r\n\r\n\t\t\t\tif (name)\r\n\t\t\t\t\t_r_str_copy (lpnmlv->item.pszText, lpnmlv->item.cchTextMax, name);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t// set image\r\n\tif (lpnmlv->item.mask & LVIF_IMAGE)\r\n\t{\r\n\t\tif (_app_getappinfoparam2 (ptr_network->app_hash, (INT)lpnmlv->hdr.idFrom, INFO_ICON_ID, &icon_id, sizeof (LONG)))\r\n\t\t\tlpnmlv->item.iImage = icon_id;\r\n\t}\r\n\r\n\t// set group id\r\n\tif (lpnmlv->item.mask & LVIF_GROUPID)\r\n\t{\r\n\t\tif (_app_listview_isitemhidden (lpnmlv->item.lParam))\r\n\t\t{\r\n\t\t\tlpnmlv->item.iGroupId = LV_HIDDEN_GROUP_ID;\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tif (ptr_network->type == DATA_APP_SERVICE)\r\n\t\t\t{\r\n\t\t\t\tlpnmlv->item.iGroupId = 1;\r\n\t\t\t}\r\n\t\t\telse if (ptr_network->type == DATA_APP_UWP)\r\n\t\t\t{\r\n\t\t\t\tlpnmlv->item.iGroupId = 2;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tlpnmlv->item.iGroupId = 0;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n\r\nVOID _app_displayinfolog_callback (\r\n\t_Inout_ LPNMLVDISPINFOW lpnmlv,\r\n\t_In_opt_ PITEM_APP ptr_app,\r\n\t_In_ PITEM_LOG ptr_log\r\n)\r\n{\r\n\tPR_STRING string;\r\n\tLONG icon_id = 0;\r\n\r\n\t// set text\r\n\tif (lpnmlv->item.mask & LVIF_TEXT)\r\n\t{\r\n\t\tswitch (lpnmlv->item.iSubItem)\r\n\t\t{\r\n\t\t\tcase 0:\r\n\t\t\t{\r\n\t\t\t\t_r_str_printf (lpnmlv->item.pszText, lpnmlv->item.cchTextMax, L\"%d\", _InterlockedCompareExchange (&ptr_log->log_id, 0, 0));\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\r\n\t\t\tcase 1:\r\n\t\t\t{\r\n\t\t\t\tif (ptr_app)\r\n\t\t\t\t{\r\n\t\t\t\t\tstring = _app_getappdisplayname (ptr_app, TRUE);\r\n\r\n\t\t\t\t\tif (string)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t_r_str_copy (lpnmlv->item.pszText, lpnmlv->item.cchTextMax, string->buffer);\r\n\r\n\t\t\t\t\t\t_r_obj_dereference (string);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\telse if (ptr_log->path)\r\n\t\t\t\t{\r\n\t\t\t\t\t_r_str_copy (lpnmlv->item.pszText, lpnmlv->item.cchTextMax, _r_path_getbasename (&ptr_log->path->sr));\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\t_r_str_copy (lpnmlv->item.pszText, lpnmlv->item.cchTextMax, _r_locale_getstring (IDS_STATUS_EMPTY));\r\n\t\t\t\t}\r\n\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\r\n\t\t\tcase 2:\r\n\t\t\t{\r\n\t\t\t\tstring = _r_format_unixtime (ptr_log->timestamp, FDTF_SHORTDATE | FDTF_LONGTIME);\r\n\r\n\t\t\t\tif (string)\r\n\t\t\t\t{\r\n\t\t\t\t\t_r_str_copy (lpnmlv->item.pszText, lpnmlv->item.cchTextMax, string->buffer);\r\n\r\n\t\t\t\t\t_r_obj_dereference (string);\r\n\t\t\t\t}\r\n\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\r\n\t\t\tcase 3:\r\n\t\t\t{\r\n\t\t\t\tstring = _InterlockedCompareExchangePointer ((volatile PVOID_PTR)&ptr_log->local_addr_str, NULL, NULL);\r\n\r\n\t\t\t\tif (string)\r\n\t\t\t\t\t_r_str_copy (lpnmlv->item.pszText, lpnmlv->item.cchTextMax, string->buffer);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\r\n\t\t\tcase 4:\r\n\t\t\t{\r\n\t\t\t\tstring = _InterlockedCompareExchangePointer ((volatile PVOID_PTR)&ptr_log->local_host_str, NULL, NULL);\r\n\r\n\t\t\t\tif (string)\r\n\t\t\t\t{\r\n\t\t\t\t\t_r_str_copy (lpnmlv->item.pszText, lpnmlv->item.cchTextMax, string->buffer);\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\t_r_str_copy (lpnmlv->item.pszText, lpnmlv->item.cchTextMax, _r_locale_getstring (IDS_LOADING));\r\n\t\t\t\t}\r\n\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\r\n\t\t\tcase 5:\r\n\t\t\t{\r\n\t\t\t\tif (ptr_log->local_port)\r\n\t\t\t\t{\r\n\t\t\t\t\tstring = _app_formatport (ptr_log->local_port, ptr_log->protocol);\r\n\r\n\t\t\t\t\tif (string)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t_r_str_copy (lpnmlv->item.pszText, lpnmlv->item.cchTextMax, string->buffer);\r\n\r\n\t\t\t\t\t\t_r_obj_dereference (string);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\r\n\t\t\tcase 6:\r\n\t\t\t{\r\n\t\t\t\tstring = _InterlockedCompareExchangePointer ((volatile PVOID_PTR)&ptr_log->remote_addr_str, NULL, NULL);\r\n\r\n\t\t\t\tif (string)\r\n\t\t\t\t\t_r_str_copy (lpnmlv->item.pszText, lpnmlv->item.cchTextMax, string->buffer);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\r\n\t\t\tcase 7:\r\n\t\t\t{\r\n\t\t\t\tstring = _InterlockedCompareExchangePointer ((volatile PVOID_PTR)&ptr_log->remote_host_str, NULL, NULL);\r\n\r\n\t\t\t\tif (string)\r\n\t\t\t\t{\r\n\t\t\t\t\t_r_str_copy (lpnmlv->item.pszText, lpnmlv->item.cchTextMax, string->buffer);\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\t_r_str_copy (lpnmlv->item.pszText, lpnmlv->item.cchTextMax, _r_locale_getstring (IDS_LOADING));\r\n\t\t\t\t}\r\n\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\r\n\t\t\tcase 8:\r\n\t\t\t{\r\n\t\t\t\tif (ptr_log->remote_port)\r\n\t\t\t\t{\r\n\t\t\t\t\tstring = _app_formatport (ptr_log->remote_port, ptr_log->protocol);\r\n\r\n\t\t\t\t\tif (string)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t_r_str_copy (lpnmlv->item.pszText, lpnmlv->item.cchTextMax, string->buffer);\r\n\r\n\t\t\t\t\t\t_r_obj_dereference (string);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\r\n\t\t\tcase 9:\r\n\t\t\t{\r\n\t\t\t\tif (ptr_log->protocol_str)\r\n\t\t\t\t{\r\n\t\t\t\t\t_r_str_copy (lpnmlv->item.pszText, lpnmlv->item.cchTextMax, ptr_log->protocol_str->buffer);\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\t_r_str_copy (lpnmlv->item.pszText, lpnmlv->item.cchTextMax, _r_locale_getstring (IDS_ANY));\r\n\t\t\t\t}\r\n\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\r\n\t\t\tcase 10:\r\n\t\t\t{\r\n\t\t\t\tstring = _app_db_getdirectionname (ptr_log->direction, ptr_log->is_loopback, FALSE);\r\n\r\n\t\t\t\tif (string)\r\n\t\t\t\t{\r\n\t\t\t\t\t_r_str_copy (lpnmlv->item.pszText, lpnmlv->item.cchTextMax, string->buffer);\r\n\r\n\t\t\t\t\t_r_obj_dereference (string);\r\n\t\t\t\t}\r\n\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\r\n\t\t\tcase 11:\r\n\t\t\t{\r\n\t\t\t\tstring = _r_obj_concatstrings (\r\n\t\t\t\t\t2,\r\n\t\t\t\t\tptr_log->is_allow ? L\"[A] \" : L\"[B] \",\r\n\t\t\t\t\t_r_obj_getstringordefault (ptr_log->filter_name, _r_locale_getstring (IDS_STATUS_EMPTY))\r\n\t\t\t\t);\r\n\r\n\t\t\t\t_r_str_copy (lpnmlv->item.pszText, lpnmlv->item.cchTextMax, string->buffer);\r\n\r\n\t\t\t\t_r_obj_dereference (string);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t// set image\r\n\tif (lpnmlv->item.mask & LVIF_IMAGE)\r\n\t{\r\n\t\tif (_app_getappinfoparam2 (ptr_log->app_hash, (INT)lpnmlv->hdr.idFrom, INFO_ICON_ID, &icon_id, sizeof (LONG)))\r\n\t\t\tlpnmlv->item.iImage = icon_id;\r\n\t}\r\n\r\n\t// set group id\r\n\tif (lpnmlv->item.mask & LVIF_GROUPID)\r\n\t{\r\n\t\tif (_app_listview_isitemhidden (lpnmlv->item.lParam))\r\n\t\t{\r\n\t\t\tlpnmlv->item.iGroupId = LV_HIDDEN_GROUP_ID;\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tlpnmlv->item.iGroupId = 0;\r\n\t\t}\r\n\t}\r\n}\r\n\r\nBOOLEAN _app_message_displayinfo (\r\n\t_In_ HWND hwnd,\r\n\t_In_ INT listview_id,\r\n\t_Inout_ LPNMLVDISPINFOW lpnmlv\r\n)\r\n{\r\n\tPITEM_NETWORK ptr_network;\r\n\tPITEM_RULE ptr_rule;\r\n\tPITEM_APP ptr_app;\r\n\tPITEM_LOG ptr_log;\r\n\tULONG_PTR index;\r\n\r\n\tindex = _app_listview_getitemcontext (hwnd, listview_id, lpnmlv->item.iItem);\r\n\r\n\tswitch (listview_id)\r\n\t{\r\n\t\tcase IDC_APPS_PROFILE:\r\n\t\tcase IDC_APPS_SERVICE:\r\n\t\tcase IDC_APPS_UWP:\r\n\t\tcase IDC_RULE_APPS_ID:\r\n\t\t{\r\n\t\t\tptr_app = _app_getappitem ((ULONG)index);\r\n\r\n\t\t\tif (ptr_app)\r\n\t\t\t{\r\n\t\t\t\t_app_displayinfoapp_callback (ptr_app, lpnmlv);\r\n\r\n\t\t\t\t_r_obj_dereference (ptr_app);\r\n\r\n\t\t\t\treturn TRUE;\r\n\t\t\t}\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase IDC_RULES_BLOCKLIST:\r\n\t\tcase IDC_RULES_SYSTEM:\r\n\t\tcase IDC_RULES_CUSTOM:\r\n\t\tcase IDC_APP_RULES_ID:\r\n\t\t{\r\n\t\t\tptr_rule = _app_getrulebyid (index);\r\n\r\n\t\t\tif (ptr_rule)\r\n\t\t\t{\r\n\t\t\t\t_app_displayinforule_callback (listview_id, ptr_rule, lpnmlv);\r\n\r\n\t\t\t\t_r_obj_dereference (ptr_rule);\r\n\r\n\t\t\t\treturn TRUE;\r\n\t\t\t}\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase IDC_NETWORK:\r\n\t\t{\r\n\t\t\tptr_network = _app_network_getitem ((ULONG)index);\r\n\r\n\t\t\tif (ptr_network)\r\n\t\t\t{\r\n\t\t\t\t_app_displayinfonetwork_callback (ptr_network, lpnmlv);\r\n\r\n\t\t\t\t_r_obj_dereference (ptr_network);\r\n\r\n\t\t\t\treturn TRUE;\r\n\t\t\t}\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase IDC_LOG:\r\n\t\t{\r\n\t\t\tptr_log = _app_getlogitem ((ULONG)index);\r\n\r\n\t\t\tif (ptr_log)\r\n\t\t\t{\r\n\t\t\t\tptr_app = _app_getappitem (ptr_log->app_hash);\r\n\r\n\t\t\t\t_app_displayinfolog_callback (lpnmlv, ptr_app, ptr_log);\r\n\r\n\t\t\t\tif (ptr_app)\r\n\t\t\t\t\t_r_obj_dereference (ptr_app);\r\n\r\n\t\t\t\t_r_obj_dereference (ptr_log);\r\n\r\n\t\t\t\treturn TRUE;\r\n\t\t\t}\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\r\n\treturn FALSE;\r\n}\r\n\r\nVOID _app_command_idtorules (\r\n\t_In_ HWND hwnd,\r\n\t_In_ INT ctrl_id\r\n)\r\n{\r\n\tPITEM_TAB_CONTEXT tab_context;\r\n\tPITEM_RULE ptr_rule;\r\n\tPITEM_APP ptr_app;\r\n\tPR_LIST rules;\r\n\tHANDLE hengine;\r\n\tULONG_PTR rule_idx;\r\n\tULONG app_hash;\r\n\tINT item_id = INT_ERROR;\r\n\tBOOL is_remove = INT_ERROR;\r\n\r\n\ttab_context = _app_listview_getcontext (hwnd, INT_ERROR);\r\n\r\n\tif (!tab_context || !_r_listview_getselectedcount (hwnd, tab_context->listview_id))\r\n\t\treturn;\r\n\r\n\trule_idx = (ULONG_PTR)ctrl_id - IDX_RULES_SPECIAL;\r\n\tptr_rule = _app_getrulebyid (rule_idx);\r\n\r\n\tif (!ptr_rule)\r\n\t\treturn;\r\n\r\n\twhile ((item_id = _r_listview_getnextselected (hwnd, tab_context->listview_id, item_id)) != INT_ERROR)\r\n\t{\r\n\t\tapp_hash = _app_listview_getappcontext (hwnd, tab_context->listview_id, item_id);\r\n\r\n\t\tif (ptr_rule->is_forservices && _app_issystemhash (app_hash))\r\n\t\t\tcontinue;\r\n\r\n\t\tptr_app = _app_getappitem (app_hash);\r\n\r\n\t\tif (!ptr_app)\r\n\t\t\tcontinue;\r\n\r\n\t\t_app_notify_freeobject (NULL, ptr_app);\r\n\r\n\t\tif (is_remove == INT_ERROR)\r\n\t\t\tis_remove = !!(ptr_rule->is_enabled && _r_obj_findhashtable (ptr_rule->apps, app_hash));\r\n\r\n\t\t_app_setruletoapp (hwnd, ptr_rule, item_id, ptr_app, !is_remove);\r\n\r\n\t\t_r_obj_dereference (ptr_app);\r\n\t}\r\n\r\n\tif (_wfp_isfiltersinstalled ())\r\n\t{\r\n\t\thengine = _wfp_getenginehandle ();\r\n\r\n\t\trules = _r_obj_createlist (10, NULL);\r\n\r\n\t\t_r_obj_addlistitem (rules, ptr_rule, NULL);\r\n\r\n\t\t_wfp_create4filters (hengine, rules, DBG_ARG, FALSE);\r\n\r\n\t\t_r_obj_dereference (rules);\r\n\t}\r\n\r\n\t_app_listview_updateby_id (hwnd, tab_context->listview_id, 0);\r\n\t_app_listview_updateitemby_param (hwnd, rule_idx, FALSE);\r\n\r\n\t_r_obj_dereference (ptr_rule);\r\n\r\n\t_app_profile_save (hwnd);\r\n}\r\n\r\nVOID _app_command_idtotimers (\r\n\t_In_ HWND hwnd,\r\n\t_In_ INT ctrl_id\r\n)\r\n{\r\n\tPITEM_TAB_CONTEXT tab_context;\r\n\tPITEM_APP ptr_app;\r\n\tPR_LIST rules;\r\n\tHANDLE hengine;\r\n\tULONG_PTR timer_idx;\r\n\tULONG app_hash;\r\n\tLONG64 seconds;\r\n\tINT item_id = INT_ERROR;\r\n\r\n\ttab_context = _app_listview_getcontext (hwnd, INT_ERROR);\r\n\r\n\tif (!tab_context || !_r_listview_getselectedcount (hwnd, tab_context->listview_id))\r\n\t\treturn;\r\n\r\n\ttimer_idx = (ULONG_PTR)ctrl_id - IDX_TIMER;\r\n\tseconds = timer_array[timer_idx];\r\n\r\n\tif (_wfp_isfiltersinstalled ())\r\n\t{\r\n\t\thengine = _wfp_getenginehandle ();\r\n\r\n\t\trules = _r_obj_createlist (8, &_r_obj_dereference);\r\n\r\n\t\twhile ((item_id = _r_listview_getnextselected (hwnd, tab_context->listview_id, item_id)) != INT_ERROR)\r\n\t\t{\r\n\t\t\tapp_hash = _app_listview_getappcontext (hwnd, tab_context->listview_id, item_id);\r\n\t\t\tptr_app = _app_getappitem (app_hash);\r\n\r\n\t\t\tif (ptr_app)\r\n\t\t\t{\r\n\t\t\t\t_app_timer_set (hwnd, ptr_app, seconds);\r\n\r\n\t\t\t\t_r_obj_addlistitem (rules, ptr_app, NULL);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t_wfp_create3filters (hengine, rules, TEXT (__FILE__), __LINE__, FALSE);\r\n\r\n\t\t_r_obj_dereference (rules);\r\n\t}\r\n\r\n\t_app_listview_updateby_id (hwnd, tab_context->listview_id, PR_UPDATE_FORCE);\r\n\r\n\t_app_profile_save (hwnd);\r\n}\r\n\r\nVOID _app_command_logshow (\r\n\t_In_ HWND hwnd\r\n)\r\n{\r\n\tHANDLE current_handle;\r\n\tPR_STRING viewer_path;\r\n\tPR_STRING log_path;\r\n\tPR_STRING cmdline;\r\n\tINT item_count;\r\n\tNTSTATUS status;\r\n\r\n\tif (_r_config_getboolean (L\"IsLogUiEnabled\", FALSE, NULL))\r\n\t{\r\n\t\titem_count = _r_listview_getitemcount (hwnd, IDC_LOG);\r\n\r\n\t\t_r_wnd_toggle (hwnd, TRUE);\r\n\r\n\t\t_app_settab_id (hwnd, IDC_LOG);\r\n\r\n\t\tif (item_count)\r\n\t\t\t_r_listview_ensurevisible (hwnd, IDC_LOG, item_count - 1);\r\n\t}\r\n\telse\r\n\t{\r\n\t\tlog_path = _r_config_getstringexpand (L\"LogPath\", LOG_PATH_DEFAULT, NULL);\r\n\r\n\t\tviewer_path = _app_getlogviewer ();\r\n\r\n\t\tif (!log_path || !_r_fs_isexists (&log_path->sr) || !viewer_path || !_r_fs_isexists (&viewer_path->sr))\r\n\t\t{\r\n\t\t\tif (log_path)\r\n\t\t\t\t_r_obj_dereference (log_path);\r\n\r\n\t\t\tif (viewer_path)\r\n\t\t\t\t_r_obj_dereference (viewer_path);\r\n\r\n\t\t\t_r_wnd_toggle (hwnd, TRUE);\r\n\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tcurrent_handle = _InterlockedCompareExchangePointer (&config.hlogfile, NULL, NULL);\r\n\r\n\t\tif (current_handle)\r\n\t\t\t_r_fs_flushfile (current_handle);\r\n\r\n\t\tcmdline = _r_obj_concatstrings (\r\n\t\t\t5,\r\n\t\t\tL\"\\\"\",\r\n\t\t\tviewer_path->buffer,\r\n\t\t\tL\"\\\" \\\"\",\r\n\t\t\tlog_path->buffer,\r\n\t\t\tL\"\\\"\"\r\n\t\t);\r\n\r\n\t\tstatus = _r_sys_createprocess (&viewer_path->sr, &cmdline->sr, NULL, FALSE);\r\n\r\n\t\tif (status != STATUS_SUCCESS)\r\n\t\t\t_r_show_errormessage (hwnd, NULL, status, cmdline->buffer, ET_NATIVE);\r\n\r\n\t\t_r_obj_dereference (viewer_path);\r\n\t\t_r_obj_dereference (log_path);\r\n\t\t_r_obj_dereference (cmdline);\r\n\t}\r\n}\r\n\r\nVOID _app_command_logclear (\r\n\t_In_ HWND hwnd\r\n)\r\n{\r\n\tHANDLE current_handle;\r\n\tPR_STRING log_path;\r\n\tLONG64 file_size;\r\n\tBOOLEAN is_valid;\r\n\r\n\tlog_path = _r_config_getstringexpand (L\"LogPath\", LOG_PATH_DEFAULT, NULL);\r\n\r\n\tcurrent_handle = _InterlockedCompareExchangePointer (&config.hlogfile, NULL, NULL);\r\n\r\n\tif (current_handle)\r\n\t\t_r_fs_getsize2 (NULL, current_handle, &file_size);\r\n\r\n\tis_valid = (current_handle && file_size > 2) || (log_path && _r_fs_isexists (&log_path->sr));\r\n\r\n\tif (!is_valid)\r\n\t{\r\n\t\t_r_queuedlock_acquireshared (&lock_loglist);\r\n\t\tis_valid = !_r_obj_isempty (log_table);\r\n\t\t_r_queuedlock_releaseshared (&lock_loglist);\r\n\t}\r\n\r\n\tif (is_valid)\r\n\t{\r\n\t\tif (_r_show_confirmmessage (hwnd, _r_locale_getstring (IDS_QUESTION), NULL, L\"ConfirmLogClear\", FALSE))\r\n\t\t{\r\n\t\t\t_app_logclear (current_handle);\r\n\r\n\t\t\t_app_logclear_ui (hwnd);\r\n\t\t}\r\n\t}\r\n\r\n\tif (log_path)\r\n\t\t_r_obj_dereference (log_path);\r\n}\r\n\r\nVOID _app_command_logerrshow (\r\n\t_In_opt_ HWND hwnd\r\n)\r\n{\r\n\tPR_STRING process_path;\r\n\tPR_STRING viewer_path;\r\n\tPR_STRING path;\r\n\tNTSTATUS status;\r\n\r\n\tpath = _r_app_getlogpath ();\r\n\r\n\tif (!_r_fs_isexists (&path->sr))\r\n\t\treturn;\r\n\r\n\tviewer_path = _app_getlogviewer ();\r\n\r\n\tif (!viewer_path)\r\n\t\treturn;\r\n\r\n\tprocess_path = _r_obj_concatstrings (\r\n\t\t5,\r\n\t\tL\"\\\"\",\r\n\t\tviewer_path->buffer,\r\n\t\tL\"\\\" \\\"\",\r\n\t\tpath->buffer,\r\n\t\tL\"\\\"\"\r\n\t);\r\n\r\n\tstatus = _r_sys_createprocess (&viewer_path->sr, &process_path->sr, NULL, FALSE);\r\n\r\n\tif (status != STATUS_SUCCESS)\r\n\t\t_r_show_errormessage (hwnd, NULL, status, viewer_path->buffer, ET_NATIVE);\r\n\r\n\t_r_obj_dereference (process_path);\r\n\t_r_obj_dereference (viewer_path);\r\n}\r\n\r\nVOID _app_command_logerrclear (\r\n\t_In_opt_ HWND hwnd\r\n)\r\n{\r\n\tPR_STRING path;\r\n\r\n\tpath = _r_app_getlogpath ();\r\n\r\n\tif (!_r_fs_isexists (&path->sr))\r\n\t\treturn;\r\n\r\n\tif (!_r_show_confirmmessage (hwnd, _r_locale_getstring (IDS_QUESTION), NULL, L\"ConfirmLogClear\", FALSE))\r\n\t\treturn;\r\n\r\n\t_r_fs_deletefile (&path->sr, NULL);\r\n}\r\n\r\nVOID _app_command_copy (\r\n\t_In_ HWND hwnd,\r\n\t_In_ INT ctrl_id,\r\n\t_In_ INT column_id\r\n)\r\n{\r\n\tR_STRINGREF divider_sr = PR_STRINGREF_INIT (DIVIDER_COPY);\r\n\tPITEM_TAB_CONTEXT tab_context;\r\n\tR_STRINGBUILDER sb;\r\n\tPR_STRING string;\r\n\tINT column_count;\r\n\tINT item_id = INT_ERROR;\r\n\r\n\ttab_context = _app_listview_getcontext (hwnd, INT_ERROR);\r\n\r\n\tif (!tab_context)\r\n\t\treturn;\r\n\r\n\tcolumn_count = _r_listview_getcolumncount (hwnd, tab_context->listview_id);\r\n\r\n\t_r_obj_initializestringbuilder (&sb, 512);\r\n\r\n\twhile ((item_id = _r_listview_getnextselected (hwnd, tab_context->listview_id, item_id)) != INT_ERROR)\r\n\t{\r\n\t\tif (ctrl_id == IDM_COPY)\r\n\t\t{\r\n\t\t\tfor (INT i = 0; i < column_count; i++)\r\n\t\t\t{\r\n\t\t\t\tstring = _r_listview_getitemtext (hwnd, tab_context->listview_id, item_id, i);\r\n\r\n\t\t\t\tif (string)\r\n\t\t\t\t{\r\n\t\t\t\t\t_r_obj_appendstringbuilder2 (&sb, &string->sr);\r\n\t\t\t\t\t_r_obj_appendstringbuilder2 (&sb, &divider_sr);\r\n\r\n\t\t\t\t\t_r_obj_dereference (string);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tstring = _r_obj_finalstringbuilder (&sb);\r\n\r\n\t\t\t_r_str_trimstring (&string->sr, &divider_sr, 0);\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tstring = _r_listview_getitemtext (hwnd, tab_context->listview_id, item_id, column_id);\r\n\r\n\t\t\tif (string)\r\n\t\t\t{\r\n\t\t\t\t_r_obj_appendstringbuilder2 (&sb, &string->sr);\r\n\r\n\t\t\t\t_r_obj_dereference (string);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t_r_obj_appendstringbuilder (&sb, SZ_CRLF);\r\n\t}\r\n\r\n\tstring = _r_obj_finalstringbuilder (&sb);\r\n\r\n\t_r_str_trimstring2 (&string->sr, DIVIDER_TRIM, 0);\r\n\r\n\t_r_clipboard_set (hwnd, &string->sr);\r\n\r\n\t_r_obj_deletestringbuilder (&sb);\r\n}\r\n\r\nVOID _app_command_checkbox (\r\n\t_In_ HWND hwnd,\r\n\t_In_ INT ctrl_id\r\n)\r\n{\r\n\tPITEM_TAB_CONTEXT tab_context;\r\n\tPITEM_APP ptr_app;\r\n\tPITEM_RULE ptr_rule;\r\n\tPR_LIST rules;\r\n\tHANDLE hengine;\r\n\tULONG hash_code;\r\n\tINT item_id = INT_ERROR;\r\n\tBOOLEAN new_val = (ctrl_id == IDM_CHECK);\r\n\tBOOLEAN is_changed = FALSE;\r\n\r\n\ttab_context = _app_listview_getcontext (hwnd, INT_ERROR);\r\n\r\n\tif (!tab_context)\r\n\t\treturn;\r\n\r\n\trules = _r_obj_createlist (8, &_r_obj_dereference);\r\n\r\n\tif (tab_context->listview_id >= IDC_APPS_PROFILE && tab_context->listview_id <= IDC_APPS_UWP)\r\n\t{\r\n\t\twhile ((item_id = _r_listview_getnextselected (hwnd, tab_context->listview_id, item_id)) != INT_ERROR)\r\n\t\t{\r\n\t\t\thash_code = (ULONG)_app_listview_getitemcontext (hwnd, tab_context->listview_id, item_id);\r\n\t\t\tptr_app = _app_getappitem (hash_code);\r\n\r\n\t\t\tif (!ptr_app)\r\n\t\t\t\tcontinue;\r\n\r\n\t\t\tif (ptr_app->is_enabled != new_val)\r\n\t\t\t{\r\n\t\t\t\tif (!new_val)\r\n\t\t\t\t{\r\n\t\t\t\t\t_app_timer_reset (hwnd, ptr_app);\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\t_app_notify_freeobject (NULL, ptr_app);\r\n\t\t\t\t}\r\n\r\n\t\t\t\tptr_app->is_enabled = new_val;\r\n\r\n\t\t\t\t_app_listview_lock (hwnd, tab_context->listview_id, TRUE);\r\n\t\t\t\t_app_setappiteminfo (hwnd, tab_context->listview_id, item_id, ptr_app);\r\n\t\t\t\t_app_listview_lock (hwnd, tab_context->listview_id, FALSE);\r\n\r\n\t\t\t\t_r_obj_addlistitem (rules, ptr_app, NULL);\r\n\r\n\t\t\t\tis_changed = TRUE;\r\n\r\n\t\t\t\t// do not reset reference counter\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\t_r_obj_dereference (ptr_app);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (is_changed)\r\n\t\t{\r\n\t\t\tif (_wfp_isfiltersinstalled ())\r\n\t\t\t{\r\n\t\t\t\thengine = _wfp_getenginehandle ();\r\n\r\n\t\t\t\t_wfp_create3filters (hengine, rules, DBG_ARG, FALSE);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\telse if (tab_context->listview_id >= IDC_RULES_BLOCKLIST && tab_context->listview_id <= IDC_RULES_CUSTOM)\r\n\t{\r\n\t\twhile ((item_id = _r_listview_getnextselected (hwnd, tab_context->listview_id, item_id)) != INT_ERROR)\r\n\t\t{\r\n\t\t\thash_code = (ULONG)_app_listview_getitemcontext (hwnd, tab_context->listview_id, item_id);\r\n\t\t\tptr_rule = _app_getrulebyid (hash_code);\r\n\r\n\t\t\tif (!ptr_rule)\r\n\t\t\t\tcontinue;\r\n\r\n\t\t\tif (ptr_rule->is_enabled != new_val)\r\n\t\t\t{\r\n\t\t\t\t_app_ruleenable (ptr_rule, new_val, TRUE);\r\n\r\n\t\t\t\t_app_listview_lock (hwnd, tab_context->listview_id, TRUE);\r\n\t\t\t\t_app_setruleiteminfo (hwnd, tab_context->listview_id, item_id, ptr_rule, TRUE);\r\n\t\t\t\t_app_listview_lock (hwnd, tab_context->listview_id, FALSE);\r\n\r\n\t\t\t\t_r_obj_addlistitem (rules, ptr_rule, NULL);\r\n\r\n\t\t\t\tis_changed = TRUE;\r\n\r\n\t\t\t\t// do not reset reference counter\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\t_r_obj_dereference (ptr_rule);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (is_changed)\r\n\t\t{\r\n\t\t\tif (_wfp_isfiltersinstalled ())\r\n\t\t\t{\r\n\t\t\t\thengine = _wfp_getenginehandle ();\r\n\r\n\t\t\t\t_wfp_create4filters (hengine, rules, DBG_ARG, FALSE);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t_r_obj_dereference (rules);\r\n\r\n\tif (is_changed)\r\n\t{\r\n\t\t_app_listview_updateby_id (hwnd, tab_context->listview_id, PR_UPDATE_FORCE);\r\n\r\n\t\t_app_profile_save (hwnd);\r\n\t}\r\n}\r\n\r\nVOID _app_command_delete (\r\n\t_In_ HWND hwnd\r\n)\r\n{\r\n\tR_STRINGREF crlf = PR_STRINGREF_INIT (SZ_CRLF);\r\n\tPITEM_TAB_CONTEXT tab_context;\r\n\tR_STRINGBUILDER sb;\r\n\tPR_ARRAY guids = NULL;\r\n\tPITEM_NETWORK ptr_network;\r\n\tPR_HASHTABLE apps_checker;\r\n\tMIB_TCPROW tcprow;\r\n\tPR_STRING string;\r\n\tHANDLE hengine;\r\n\tPITEM_APP ptr_app;\r\n\tPITEM_RULE ptr_rule;\r\n\tULONG_PTR rule_idx;\r\n\tULONG_PTR enum_key;\r\n\tULONG hash_code;\r\n\tINT selected_count;\r\n\tLPARAM lparam;\r\n\tINT item_count;\r\n\r\n\ttab_context = _app_listview_getcontext (hwnd, INT_ERROR);\r\n\r\n\tif (!tab_context || (tab_context->listview_id != IDC_APPS_PROFILE && tab_context->listview_id != IDC_RULES_CUSTOM && tab_context->listview_id != IDC_NETWORK))\r\n\t\treturn;\r\n\r\n\tselected_count = _r_listview_getselectedcount (hwnd, tab_context->listview_id);\r\n\r\n\tif (!selected_count)\r\n\t\treturn;\r\n\r\n\titem_count = _r_listview_getitemcount (hwnd, tab_context->listview_id);\r\n\r\n\tif (tab_context->listview_id != IDC_NETWORK)\r\n\t{\r\n\t\t_r_obj_initializestringbuilder (&sb, 256);\r\n\r\n\t\tstring = _r_locale_getstring_ex (IDS_QUESTION_DELETE);\r\n\r\n\t\tif (string)\r\n\t\t{\r\n\t\t\t_r_obj_appendstringbuilder2 (&sb, &string->sr);\r\n\t\t\t_r_obj_appendstringbuilder2 (&sb, &crlf);\r\n\t\t\t_r_obj_appendstringbuilder2 (&sb, &crlf);\r\n\r\n\t\t\t_r_obj_dereference (string);\r\n\t\t}\r\n\r\n\t\tfor (INT i = 0, j = 1; i < item_count; i++)\r\n\t\t{\r\n\t\t\tif (!_r_listview_isitemselected (hwnd, tab_context->listview_id, i))\r\n\t\t\t\tcontinue;\r\n\r\n\t\t\tlparam = _r_listview_getitemlparam (hwnd, tab_context->listview_id, i);\r\n\r\n\t\t\tif (_app_listview_isitemhidden (lparam))\r\n\t\t\t\tcontinue;\r\n\r\n\t\t\tstring = _r_listview_getitemtext (hwnd, tab_context->listview_id, i, 0);\r\n\r\n\t\t\tif (string)\r\n\t\t\t{\r\n\t\t\t\t_r_obj_appendstringbuilderformat (&sb, L\"%\" TEXT (PRId32) \") \", j);\r\n\t\t\t\t_r_obj_appendstringbuilder2 (&sb, &string->sr);\r\n\t\t\t\t_r_obj_appendstringbuilder2 (&sb, &crlf);\r\n\r\n\t\t\t\t_r_obj_dereference (string);\r\n\t\t\t}\r\n\r\n\t\t\tj += 1;\r\n\t\t}\r\n\r\n\t\tstring = _r_obj_finalstringbuilder (&sb);\r\n\r\n\t\t_r_str_trimstring (&string->sr, &crlf, PR_TRIM_END_ONLY);\r\n\r\n\t\tif (_r_show_message (hwnd, MB_YESNO | MB_ICONEXCLAMATION, NULL, string->buffer) != IDYES)\r\n\t\t{\r\n\t\t\t_r_obj_dereference (string);\r\n\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tguids = _r_obj_createarray (sizeof (GUID), 10, NULL);\r\n\r\n\t\t_r_obj_dereference (string);\r\n\t}\r\n\r\n\tfor (INT i = item_count - 1; i != INT_ERROR; i--)\r\n\t{\r\n\t\tif (!_r_listview_isitemselected (hwnd, tab_context->listview_id, i))\r\n\t\t\tcontinue;\r\n\r\n\t\tif (tab_context->listview_id == IDC_APPS_PROFILE)\r\n\t\t{\r\n\t\t\thash_code = (ULONG)_app_listview_getitemcontext (hwnd, tab_context->listview_id, i);\r\n\t\t\tptr_app = _app_getappitem (hash_code);\r\n\r\n\t\t\tif (!ptr_app)\r\n\t\t\t\tcontinue;\r\n\r\n\t\t\tif (!ptr_app->is_undeletable) // skip \"undeletable\" apps\r\n\t\t\t{\r\n\t\t\t\tif (!_r_obj_isempty (ptr_app->guids))\r\n\t\t\t\t\t_r_obj_addarrayitems (guids, ptr_app->guids->items, ptr_app->guids->count);\r\n\r\n\t\t\t\t_r_listview_deleteitem (hwnd, tab_context->listview_id, i);\r\n\r\n\t\t\t\t_app_timer_reset (hwnd, ptr_app);\r\n\t\t\t\t_app_notify_freeobject (NULL, ptr_app);\r\n\r\n\t\t\t\t_r_queuedlock_acquireexclusive (&lock_apps);\r\n\t\t\t\t_app_freeapplication (hwnd, hash_code);\r\n\t\t\t\t_r_queuedlock_releaseexclusive (&lock_apps);\r\n\t\t\t}\r\n\r\n\t\t\t_r_obj_dereference (ptr_app);\r\n\t\t}\r\n\t\telse if (tab_context->listview_id == IDC_RULES_CUSTOM)\r\n\t\t{\r\n\t\t\trule_idx = _app_listview_getitemcontext (hwnd, tab_context->listview_id, i);\r\n\t\t\tptr_rule = _app_getrulebyid (rule_idx);\r\n\r\n\t\t\tif (!ptr_rule)\r\n\t\t\t\tcontinue;\r\n\r\n\t\t\tif (!ptr_rule->is_readonly) // skip \"read-only\" rules\r\n\t\t\t{\r\n\t\t\t\tapps_checker = _r_obj_createhashtable (sizeof (SHORT), 6, NULL);\r\n\r\n\t\t\t\tif (!_r_obj_isempty (ptr_rule->guids))\r\n\t\t\t\t\t_r_obj_addarrayitems (guids, ptr_rule->guids->items, ptr_rule->guids->count);\r\n\r\n\t\t\t\tenum_key = 0;\r\n\r\n\t\t\t\twhile (_r_obj_enumhashtable (ptr_rule->apps, NULL, &hash_code, &enum_key))\r\n\t\t\t\t{\r\n\t\t\t\t\t_r_obj_addhashtableitem (apps_checker, hash_code, NULL);\r\n\t\t\t\t}\r\n\r\n\t\t\t\t_r_listview_deleteitem (hwnd, tab_context->listview_id, i);\r\n\r\n\t\t\t\t_r_obj_reference (ptr_rule); // required to dereference later\r\n\r\n\t\t\t\t_r_queuedlock_acquireexclusive (&lock_rules);\r\n\t\t\t\t_r_obj_setlistitem (rules_list, rule_idx, NULL);\r\n\t\t\t\t_r_queuedlock_releaseexclusive (&lock_rules);\r\n\r\n\t\t\t\tenum_key = 0;\r\n\r\n\t\t\t\twhile (_r_obj_enumhashtable (apps_checker, NULL, &hash_code, &enum_key))\r\n\t\t\t\t{\r\n\t\t\t\t\t_app_listview_updateitemby_param (hwnd, hash_code, TRUE);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\t_r_obj_dereference (ptr_rule);\r\n\t\t}\r\n\t\telse if (tab_context->listview_id == IDC_NETWORK)\r\n\t\t{\r\n\t\t\thash_code = (ULONG)_app_listview_getitemcontext (hwnd, tab_context->listview_id, i);\r\n\t\t\tptr_network = _app_network_getitem (hash_code);\r\n\r\n\t\t\tif (!ptr_network)\r\n\t\t\t\tcontinue;\r\n\r\n\t\t\tif (ptr_network->af == AF_INET && ptr_network->state == MIB_TCP_STATE_ESTAB)\r\n\t\t\t{\r\n\t\t\t\tRtlZeroMemory (&tcprow, sizeof (MIB_TCPROW));\r\n\r\n\t\t\t\ttcprow.dwState = MIB_TCP_STATE_DELETE_TCB;\r\n\t\t\t\ttcprow.dwLocalAddr = ptr_network->local_addr.S_un.S_addr;\r\n\t\t\t\ttcprow.dwLocalPort = _r_byteswap_ushort ((USHORT)ptr_network->local_port);\r\n\t\t\t\ttcprow.dwRemoteAddr = ptr_network->remote_addr.S_un.S_addr;\r\n\t\t\t\ttcprow.dwRemotePort = _r_byteswap_ushort ((USHORT)ptr_network->remote_port);\r\n\r\n\t\t\t\tif (SetTcpEntry (&tcprow) == NO_ERROR)\r\n\t\t\t\t{\r\n\t\t\t\t\t_r_listview_deleteitem (hwnd, tab_context->listview_id, i);\r\n\r\n\t\t\t\t\t_app_network_removeitem (hash_code);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\t_r_obj_dereference (ptr_network);\r\n\t\t}\r\n\t}\r\n\r\n\tif (guids)\r\n\t{\r\n\t\tif (!_r_obj_isempty (guids))\r\n\t\t{\r\n\t\t\tif (_wfp_isfiltersinstalled ())\r\n\t\t\t{\r\n\t\t\t\thengine = _wfp_getenginehandle ();\r\n\r\n\t\t\t\t_wfp_destroyfilters_array (hengine, guids, DBG_ARG);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t_r_obj_dereference (guids);\r\n\t}\r\n\r\n\t_app_listview_updateby_id (hwnd, tab_context->listview_id, 0);\r\n\r\n\t_app_profile_save (hwnd);\r\n}\r\n\r\nVOID _app_command_disable (\r\n\t_In_ HWND hwnd,\r\n\t_In_ INT ctrl_id\r\n)\r\n{\r\n\tPITEM_TAB_CONTEXT tab_context;\r\n\tPITEM_APP ptr_app;\r\n\tULONG app_hash;\r\n\tLONG new_val = INT_ERROR;\r\n\tINT item_id = INT_ERROR;\r\n\r\n\ttab_context = _app_listview_getcontext (hwnd, INT_ERROR);\r\n\r\n\t// note: these commands only for apps...\r\n\tif (!tab_context || (!(tab_context->listview_id >= IDC_APPS_PROFILE && tab_context->listview_id <= IDC_APPS_UWP) && tab_context->listview_id != IDC_LOG))\r\n\t\treturn;\r\n\r\n\twhile ((item_id = _r_listview_getnextselected (hwnd, tab_context->listview_id, item_id)) != INT_ERROR)\r\n\t{\r\n\t\tapp_hash = _app_listview_getappcontext (hwnd, tab_context->listview_id, item_id);\r\n\r\n\t\tptr_app = _app_getappitem (app_hash);\r\n\r\n\t\tif (!ptr_app)\r\n\t\t\tcontinue;\r\n\r\n\t\tif (ctrl_id == IDM_DISABLENOTIFICATIONS)\r\n\t\t{\r\n\t\t\tif (new_val == INT_ERROR)\r\n\t\t\t\tnew_val = !ptr_app->is_silent;\r\n\r\n\t\t\t_app_setappinfo (ptr_app, INFO_IS_SILENT, LongToPtr (new_val));\r\n\t\t}\r\n\t\telse if (ctrl_id == IDM_DISABLEREMOVAL)\r\n\t\t{\r\n\t\t\tif (_app_isdisabledremoval (app_hash))\r\n\t\t\t\tcontinue;\r\n\r\n\t\t\tif (new_val == INT_ERROR)\r\n\t\t\t\tnew_val = !ptr_app->is_undeletable;\r\n\r\n\t\t\t_app_setappinfo (ptr_app, INFO_IS_UNDELETABLE, LongToPtr (new_val));\r\n\t\t}\r\n\t\telse if (ctrl_id == IDM_DISABLETIMER)\r\n\t\t{\r\n\t\t\t_app_timer_reset (hwnd, ptr_app);\r\n\t\t}\r\n\r\n\t\t_app_listview_updateitemby_id (hwnd, tab_context->listview_id, item_id);\r\n\r\n\t\t_r_obj_dereference (ptr_app);\r\n\t}\r\n\r\n\t_app_listview_updateby_id (hwnd, tab_context->listview_id, 0);\r\n\r\n\t_app_profile_save (hwnd);\r\n}\r\n\r\nVOID _app_command_openeditor (\r\n\t_In_ HWND hwnd\r\n)\r\n{\r\n\tPITEM_TAB_CONTEXT tab_context;\r\n\tPITEM_NETWORK ptr_network;\r\n\tPEDITOR_CONTEXT context;\r\n\tPITEM_RULE ptr_rule;\r\n\tPITEM_LOG ptr_log;\r\n\tPR_STRING string;\r\n\tULONG_PTR id_code;\r\n\tULONG hash_code;\r\n\tINT item_id = INT_ERROR;\r\n\r\n\tptr_rule = _app_addrule (NULL, NULL, NULL, FWP_DIRECTION_OUTBOUND, FWP_ACTION_PERMIT, 0, 0);\r\n\r\n\t_app_ruleenable (ptr_rule, TRUE, FALSE);\r\n\r\n\ttab_context = _app_listview_getcontext (hwnd, INT_ERROR);\r\n\r\n\tif (!tab_context)\r\n\t\treturn;\r\n\r\n\tswitch (tab_context->listview_id)\r\n\t{\r\n\t\tcase IDC_APPS_PROFILE:\r\n\t\tcase IDC_APPS_SERVICE:\r\n\t\tcase IDC_APPS_UWP:\r\n\t\t{\r\n\t\t\twhile ((item_id = _r_listview_getnextselected (hwnd, tab_context->listview_id, item_id)) != INT_ERROR)\r\n\t\t\t{\r\n\t\t\t\thash_code = (ULONG)_app_listview_getitemcontext (hwnd, tab_context->listview_id, item_id);\r\n\r\n\t\t\t\tif (_app_isappfound (hash_code))\r\n\t\t\t\t\t_r_obj_addhashtableitem (ptr_rule->apps, hash_code, NULL);\r\n\t\t\t}\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase IDC_NETWORK:\r\n\t\t{\r\n\t\t\tptr_rule->action = FWP_ACTION_BLOCK;\r\n\r\n\t\t\titem_id = _r_listview_getnextselected (hwnd, tab_context->listview_id, INT_ERROR);\r\n\r\n\t\t\tif (item_id != INT_ERROR)\r\n\t\t\t{\r\n\t\t\t\thash_code = (ULONG)_app_listview_getitemcontext (hwnd, tab_context->listview_id, item_id);\r\n\t\t\t\tptr_network = _app_network_getitem (hash_code);\r\n\r\n\t\t\t\tif (ptr_network)\r\n\t\t\t\t{\r\n\t\t\t\t\tif (!ptr_rule->name)\r\n\t\t\t\t\t\tptr_rule->name = _r_listview_getitemtext (hwnd, tab_context->listview_id, item_id, 0);\r\n\r\n\t\t\t\t\tif (ptr_network->app_hash && !_r_obj_isstringempty (ptr_network->path))\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif (!_app_isappfound (ptr_network->app_hash))\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tptr_network->app_hash = _app_addapplication (hwnd, DATA_UNKNOWN, ptr_network->path, NULL, NULL);\r\n\r\n\t\t\t\t\t\t\tif (ptr_network->app_hash)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t_app_listview_updateby_param (hwnd, ptr_network->app_hash, PR_SETITEM_UPDATE, TRUE);\r\n\r\n\t\t\t\t\t\t\t\t_app_profile_save (hwnd);\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t_r_obj_addhashtableitem (ptr_rule->apps, ptr_network->app_hash, NULL);\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tptr_rule->protocol = ptr_network->protocol;\r\n\r\n\t\t\t\t\tstring = _app_formataddress (ptr_network->af, 0, &ptr_network->remote_addr, ptr_network->remote_port, FMTADDR_AS_RULE);\r\n\t\t\t\t\t_r_obj_movereference ((PVOID_PTR)&ptr_rule->rule_remote, string);\r\n\r\n\t\t\t\t\tstring = _app_formataddress (ptr_network->af, 0, &ptr_network->local_addr, ptr_network->local_port, FMTADDR_AS_RULE);\r\n\t\t\t\t\t_r_obj_movereference ((PVOID_PTR)&ptr_rule->rule_local, string);\r\n\r\n\t\t\t\t\t_r_obj_dereference (ptr_network);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase IDC_LOG:\r\n\t\t{\r\n\t\t\titem_id = _r_listview_getnextselected (hwnd, tab_context->listview_id, INT_ERROR);\r\n\r\n\t\t\tif (item_id != INT_ERROR)\r\n\t\t\t{\r\n\t\t\t\thash_code = (ULONG)_app_listview_getitemcontext (hwnd, tab_context->listview_id, item_id);\r\n\t\t\t\tptr_log = _app_getlogitem (hash_code);\r\n\r\n\t\t\t\tif (ptr_log)\r\n\t\t\t\t{\r\n\t\t\t\t\tif (!ptr_rule->name)\r\n\t\t\t\t\t\tptr_rule->name = _r_listview_getitemtext (hwnd, tab_context->listview_id, item_id, 0);\r\n\r\n\t\t\t\t\tif (ptr_log->app_hash && !_r_obj_isstringempty (ptr_log->path))\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif (!_app_isappfound (ptr_log->app_hash))\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tptr_log->app_hash = _app_addapplication (hwnd, DATA_UNKNOWN, ptr_log->path, NULL, NULL);\r\n\r\n\t\t\t\t\t\t\tif (ptr_log->app_hash)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t_app_listview_updateby_param (hwnd, ptr_log->app_hash, PR_SETITEM_UPDATE, TRUE);\r\n\r\n\t\t\t\t\t\t\t\t_app_profile_save (hwnd);\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t_r_obj_addhashtableitem (ptr_rule->apps, ptr_log->app_hash, NULL);\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tptr_rule->protocol = ptr_log->protocol;\r\n\t\t\t\t\tptr_rule->direction = ptr_log->direction;\r\n\r\n\t\t\t\t\tstring = _app_formataddress (ptr_log->af, 0, &ptr_log->remote_addr, ptr_log->remote_port, FMTADDR_AS_RULE);\r\n\t\t\t\t\t_r_obj_movereference ((PVOID_PTR)&ptr_rule->rule_remote, string);\r\n\r\n\t\t\t\t\tstring = _app_formataddress (ptr_log->af, 0, &ptr_log->local_addr, ptr_log->local_port, FMTADDR_AS_RULE);\r\n\t\t\t\t\t_r_obj_movereference ((PVOID_PTR)&ptr_rule->rule_local, string);\r\n\r\n\t\t\t\t\t_r_obj_dereference (ptr_log);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\r\n\tcontext = _app_editor_createwindow (hwnd, ptr_rule, 0, TRUE);\r\n\r\n\tif (context)\r\n\t{\r\n\t\t_r_queuedlock_acquireexclusive (&lock_rules);\r\n\t\t_r_obj_addlistitem (rules_list, _r_obj_reference (ptr_rule), &id_code);\r\n\t\t_r_queuedlock_releaseexclusive (&lock_rules);\r\n\r\n\t\tif (id_code != SIZE_MAX)\r\n\t\t{\r\n\t\t\t_app_listview_addruleitem (hwnd, ptr_rule, id_code, TRUE);\r\n\t\t\t_app_listview_updateby_id (hwnd, DATA_LISTVIEW_CURRENT, PR_UPDATE_TYPE);\r\n\r\n\t\t\t_app_profile_save (hwnd);\r\n\t\t}\r\n\r\n\t\t_app_editor_deletewindow (context);\r\n\t}\r\n\r\n\t_r_obj_dereference (ptr_rule);\r\n}\r\n\r\nVOID _app_command_properties (\r\n\t_In_ HWND hwnd\r\n)\r\n{\r\n\tPITEM_TAB_CONTEXT tab_context;\r\n\tPEDITOR_CONTEXT context;\r\n\tPITEM_NETWORK ptr_network;\r\n\tPITEM_RULE ptr_rule;\r\n\tPITEM_APP ptr_app;\r\n\tPITEM_LOG ptr_log;\r\n\tULONG hash_code;\r\n\tINT item_id;\r\n\r\n\ttab_context = _app_listview_getcontext (hwnd, INT_ERROR);\r\n\r\n\tif (!tab_context)\r\n\t\treturn;\r\n\r\n\titem_id = _r_listview_getnextselected (hwnd, tab_context->listview_id, INT_ERROR);\r\n\r\n\tif (item_id == INT_ERROR)\r\n\t\treturn;\r\n\r\n\tswitch (tab_context->listview_id)\r\n\t{\r\n\t\tcase IDC_APPS_PROFILE:\r\n\t\tcase IDC_APPS_SERVICE:\r\n\t\tcase IDC_APPS_UWP:\r\n\t\t{\r\n\t\t\thash_code = (ULONG)_app_listview_getitemcontext (hwnd, tab_context->listview_id, item_id);\r\n\t\t\tptr_app = _app_getappitem (hash_code);\r\n\r\n\t\t\tif (!ptr_app)\r\n\t\t\t\treturn;\r\n\r\n\t\t\tcontext = _app_editor_createwindow (hwnd, ptr_app, 0, FALSE);\r\n\r\n\t\t\tif (context)\r\n\t\t\t{\r\n\t\t\t\t_app_listview_lock (hwnd, tab_context->listview_id, TRUE);\r\n\t\t\t\t_app_setappiteminfo (hwnd, tab_context->listview_id, item_id, ptr_app);\r\n\t\t\t\t_app_listview_lock (hwnd, tab_context->listview_id, FALSE);\r\n\r\n\t\t\t\t_app_listview_updateby_id (hwnd, tab_context->listview_id, 0);\r\n\r\n\t\t\t\t_app_profile_save (hwnd);\r\n\r\n\t\t\t\t_app_editor_deletewindow (context);\r\n\t\t\t}\r\n\r\n\t\t\t_r_obj_dereference (ptr_app);\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\tcase IDC_RULES_BLOCKLIST:\r\n\t\tcase IDC_RULES_SYSTEM:\r\n\t\tcase IDC_RULES_CUSTOM:\r\n\t\t{\r\n\t\t\thash_code = (ULONG)_app_listview_getitemcontext (hwnd, tab_context->listview_id, item_id);\r\n\t\t\tptr_rule = _app_getrulebyid (hash_code);\r\n\r\n\t\t\tif (!ptr_rule)\r\n\t\t\t\treturn;\r\n\r\n\t\t\tcontext = _app_editor_createwindow (hwnd, ptr_rule, 0, TRUE);\r\n\r\n\t\t\tif (context)\r\n\t\t\t{\r\n\t\t\t\t_app_listview_lock (hwnd, tab_context->listview_id, TRUE);\r\n\t\t\t\t_app_setruleiteminfo (hwnd, tab_context->listview_id, item_id, ptr_rule, TRUE);\r\n\t\t\t\t_app_listview_lock (hwnd, tab_context->listview_id, FALSE);\r\n\r\n\t\t\t\t_app_listview_updateby_id (hwnd, tab_context->listview_id, 0);\r\n\r\n\t\t\t\t_app_profile_save (hwnd);\r\n\r\n\t\t\t\t_app_editor_deletewindow (context);\r\n\t\t\t}\r\n\r\n\t\t\t_r_obj_dereference (ptr_rule);\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase IDC_NETWORK:\r\n\t\t{\r\n\t\t\thash_code = (ULONG)_app_listview_getitemcontext (hwnd, tab_context->listview_id, item_id);\r\n\t\t\tptr_network = _app_network_getitem (hash_code);\r\n\r\n\t\t\tif (!ptr_network)\r\n\t\t\t\treturn;\r\n\r\n\t\t\tif (ptr_network->app_hash && !_r_obj_isstringempty (ptr_network->path))\r\n\t\t\t{\r\n\t\t\t\tif (!_app_isappfound (ptr_network->app_hash))\r\n\t\t\t\t{\r\n\t\t\t\t\tptr_network->app_hash = _app_addapplication (hwnd, DATA_UNKNOWN, ptr_network->path, NULL, NULL);\r\n\r\n\t\t\t\t\tif (ptr_network->app_hash)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t_app_listview_updateby_param (hwnd, ptr_network->app_hash, PR_SETITEM_UPDATE, TRUE);\r\n\r\n\t\t\t\t\t\t_app_profile_save (hwnd);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif (ptr_network->app_hash)\r\n\t\t\t\t\t_app_listview_showitemby_param (hwnd, ptr_network->app_hash, TRUE);\r\n\t\t\t}\r\n\r\n\t\t\t_r_obj_dereference (ptr_network);\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase IDC_LOG:\r\n\t\t{\r\n\t\t\thash_code = (ULONG)_app_listview_getitemcontext (hwnd, tab_context->listview_id, item_id);\r\n\t\t\tptr_log = _app_getlogitem (hash_code);\r\n\r\n\t\t\tif (!ptr_log)\r\n\t\t\t\treturn;\r\n\r\n\t\t\tif (ptr_log->app_hash && !_r_obj_isstringempty (ptr_log->path))\r\n\t\t\t{\r\n\t\t\t\tif (!_app_isappfound (ptr_log->app_hash))\r\n\t\t\t\t{\r\n\t\t\t\t\tptr_log->app_hash = _app_addapplication (hwnd, DATA_UNKNOWN, ptr_log->path, NULL, NULL);\r\n\r\n\t\t\t\t\tif (ptr_log->app_hash)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t_app_listview_updateby_param (hwnd, ptr_log->app_hash, PR_SETITEM_UPDATE, TRUE);\r\n\r\n\t\t\t\t\t\t_app_profile_save (hwnd);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif (ptr_log->app_hash)\r\n\t\t\t\t\t_app_listview_showitemby_param (hwnd, ptr_log->app_hash, TRUE);\r\n\t\t\t}\r\n\r\n\t\t\t_r_obj_dereference (ptr_log);\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n}\r\n\r\nVOID _app_command_purgeunused (\r\n\t_In_ HWND hwnd\r\n)\r\n{\r\n\tR_STRINGBUILDER sb;\r\n\tPITEM_APP ptr_app = NULL;\r\n\tPR_STRING string = NULL;\r\n\tPR_HASHTABLE apps_list;\r\n\tPR_ARRAY guids;\r\n\tHANDLE hengine;\r\n\tULONG_PTR enum_key = 0;\r\n\tULONG hash_code;\r\n\r\n\tapps_list = _r_obj_createhashtable (sizeof (ULONG_PTR), 8, NULL);\r\n\tguids = _r_obj_createarray (sizeof (GUID), 10, NULL);\r\n\r\n\t_r_obj_initializestringbuilder (&sb, 256);\r\n\r\n\t_r_queuedlock_acquireshared (&lock_apps);\r\n\r\n\twhile (_r_obj_enumhashtablepointer (apps_table, (PVOID_PTR)&ptr_app, &hash_code, &enum_key))\r\n\t{\r\n\t\tif (!_app_isappunused (ptr_app) || ptr_app->type == DATA_APP_SERVICE || ptr_app->type == DATA_APP_UWP)\r\n\t\t\tcontinue;\r\n\r\n\t\t_app_deleteappitem (hwnd, ptr_app->type, hash_code);\r\n\r\n\t\t_app_timer_reset (NULL, ptr_app);\r\n\r\n\t\t_app_notify_freeobject (NULL, ptr_app);\r\n\r\n\t\tif (!_r_obj_isempty (ptr_app->guids))\r\n\t\t\t_r_obj_addarrayitems (guids, ptr_app->guids->items, ptr_app->guids->count);\r\n\r\n\t\t_r_obj_addhashtableitem (apps_list, hash_code, NULL);\r\n\r\n\t\tstring = _app_getapppath (ptr_app, _r_config_getboolean (L\"IsShortPath\", TRUE, NULL));\r\n\r\n\t\tif (string)\r\n\t\t{\r\n\t\t\t_r_obj_appendstringbuilder (&sb, L\"- \");\r\n\r\n\t\t\t_r_obj_appendstringbuilder2 (&sb, &string->sr);\r\n\t\t\t_r_obj_appendstringbuilder (&sb, SZ_CRLF);\r\n\r\n\t\t\t_r_obj_dereference (string);\r\n\t\t}\r\n\t}\r\n\r\n\t_r_queuedlock_releaseshared (&lock_apps);\r\n\r\n\tif (_r_obj_gethashtablesize (apps_list))\r\n\t{\r\n\t\tenum_key = 0;\r\n\r\n\t\tstring = _r_obj_finalstringbuilder (&sb);\r\n\r\n\t\t_r_str_trimstring2 (&string->sr, SZ_CRLF, PR_TRIM_END_ONLY);\r\n\r\n\t\tif (_r_show_confirmmessage (hwnd, _r_locale_getstring (IDS_PURGE_UNUSED), string->buffer, L\"ConfirmUnused\", FALSE))\r\n\t\t{\r\n\t\t\t_r_queuedlock_acquireexclusive (&lock_apps);\r\n\r\n\t\t\twhile (_r_obj_enumhashtable (apps_list, NULL, &hash_code, &enum_key))\r\n\t\t\t{\r\n\t\t\t\t_app_freeapplication (hwnd, hash_code);\r\n\t\t\t}\r\n\r\n\t\t\t_r_queuedlock_releaseexclusive (&lock_apps);\r\n\r\n\t\t\tif (!_r_obj_isempty2 (guids) && _wfp_isfiltersinstalled ())\r\n\t\t\t{\r\n\t\t\t\thengine = _wfp_getenginehandle ();\r\n\r\n\t\t\t\t_wfp_destroyfilters_array (hengine, guids, DBG_ARG);\r\n\t\t\t}\r\n\r\n\t\t\t_app_listview_updateby_id (hwnd, DATA_LISTVIEW_CURRENT, PR_UPDATE_TYPE | PR_UPDATE_FORCE);\r\n\r\n\t\t\t_app_profile_save (hwnd);\r\n\t\t}\r\n\t}\r\n\r\n\t_r_obj_deletestringbuilder (&sb);\r\n\r\n\t_r_obj_dereference (apps_list);\r\n\t_r_obj_dereference (guids);\r\n}\r\n\r\nVOID _app_command_purgetimers (\r\n\t_In_ HWND hwnd\r\n)\r\n{\r\n\tPITEM_APP ptr_app = NULL;\r\n\tR_STRINGBUILDER sb;\r\n\tPR_STRING string;\r\n\tPR_STRING path;\r\n\tHANDLE hengine;\r\n\tPR_LIST rules;\r\n\tULONG_PTR enum_key = 0;\r\n\r\n\tif (!_app_istimersactive ())\r\n\t\treturn;\r\n\r\n\trules = _r_obj_createlist (10, NULL);\r\n\r\n\t_r_obj_initializestringbuilder (&sb, 0x100);\r\n\r\n\t_r_queuedlock_acquireshared (&lock_apps);\r\n\r\n\twhile (_r_obj_enumhashtablepointer (apps_table, (PVOID_PTR)&ptr_app, NULL, &enum_key))\r\n\t{\r\n\t\tif (_app_istimerset (ptr_app))\r\n\t\t{\r\n\t\t\t_r_obj_addlistitem (rules, ptr_app, NULL);\r\n\r\n\t\t\tpath = _app_getapppath (ptr_app, _r_config_getboolean (L\"IsShortPath\", TRUE, NULL));\r\n\r\n\t\t\tif (path)\r\n\t\t\t{\r\n\t\t\t\t_r_obj_appendstringbuilder (&sb, L\"- \");\r\n\r\n\t\t\t\t_r_obj_appendstringbuilder2 (&sb, &path->sr);\r\n\r\n\t\t\t\tstring = _r_format_interval (ptr_app->timer - _r_unixtime_now ());\r\n\r\n\t\t\t\tif (string)\r\n\t\t\t\t{\r\n\t\t\t\t\t_r_obj_appendstringbuilder (&sb, L\" (\");\r\n\t\t\t\t\t_r_obj_appendstringbuilder2 (&sb, &string->sr);\r\n\t\t\t\t\t_r_obj_appendstringbuilder (&sb, L\")\");\r\n\r\n\t\t\t\t\t_r_obj_dereference (string);\r\n\t\t\t\t}\r\n\r\n\t\t\t\t_r_obj_appendstringbuilder (&sb, SZ_CRLF);\r\n\r\n\t\t\t\t_r_obj_dereference (path);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t_r_queuedlock_releaseshared (&lock_apps);\r\n\r\n\tif (!_r_obj_isempty2 (rules))\r\n\t{\r\n\t\tstring = _r_obj_finalstringbuilder (&sb);\r\n\r\n\t\t_r_str_trimstring2 (&string->sr, SZ_CRLF, PR_TRIM_END_ONLY);\r\n\r\n\t\tif (_r_show_confirmmessage (hwnd, _r_locale_getstring (IDS_QUESTION_TIMERS), string->buffer, L\"ConfirmTimers\", FALSE))\r\n\t\t{\r\n\t\t\tif (_wfp_isfiltersinstalled ())\r\n\t\t\t{\r\n\t\t\t\thengine = _wfp_getenginehandle ();\r\n\r\n\t\t\t\t_wfp_create3filters (hengine, rules, DBG_ARG, FALSE);\r\n\t\t\t}\r\n\r\n\t\t\tfor (ULONG_PTR i = 0; i < _r_obj_getlistsize (rules); i++)\r\n\t\t\t{\r\n\t\t\t\tptr_app = _r_obj_getlistitem (rules, i);\r\n\r\n\t\t\t\tif (ptr_app)\r\n\t\t\t\t\t_app_timer_reset (hwnd, ptr_app);\r\n\t\t\t}\r\n\r\n\t\t\t_app_listview_updateby_id (hwnd, DATA_LISTVIEW_CURRENT, PR_UPDATE_TYPE | PR_UPDATE_FORCE);\r\n\r\n\t\t\t_app_profile_save (hwnd);\r\n\t\t}\r\n\t}\r\n\r\n\t_r_obj_deletestringbuilder (&sb);\r\n\r\n\t_r_obj_dereference (rules);\r\n}\r\n\r\nVOID _app_command_selectfont (\r\n\t_In_ HWND hwnd\r\n)\r\n{\r\n\tCHOOSEFONT cf = {0};\r\n\tLOGFONT lf = {0};\r\n\tLONG dpi_value;\r\n\tUINT flags;\r\n\r\n\tcf.lStructSize = sizeof (CHOOSEFONT);\r\n\tcf.hwndOwner = hwnd;\r\n\tcf.Flags = CF_INITTOLOGFONTSTRUCT | CF_NOSCRIPTSEL | CF_LIMITSIZE | CF_NOVERTFONTS;\r\n\tcf.nSizeMax = 16;\r\n\tcf.nSizeMin = 8;\r\n\tcf.lpLogFont = &lf;\r\n\r\n\tdpi_value = _r_dc_getwindowdpi (hwnd);\r\n\r\n\t_r_config_getfont (L\"Font\", &lf, dpi_value, NULL);\r\n\r\n\tif (!ChooseFontW (&cf))\r\n\t\treturn;\r\n\r\n\t_r_config_setfont (L\"Font\", &lf, dpi_value, NULL);\r\n\r\n\t_app_listview_loadfont (dpi_value, TRUE);\r\n\t_app_listview_updateby_id (hwnd, DATA_LISTVIEW_CURRENT, PR_UPDATE_TYPE | PR_UPDATE_FORCE);\r\n\r\n\tflags = RDW_NOFRAME | RDW_NOINTERNALPAINT | RDW_ERASE | RDW_INVALIDATE | RDW_ALLCHILDREN;\r\n\r\n\tRedrawWindow (hwnd, NULL, NULL, flags);\r\n}\r\n"
  },
  {
    "path": "src/messages.h",
    "content": "// simplewall\r\n// Copyright (c) 2021-2026 Henry++\r\n\r\n#pragma once\r\n\r\nVOID _app_message_initialize (\r\n\t_In_ HWND hwnd\r\n);\r\n\r\nVOID _app_message_localize (\r\n\t_In_ HWND hwnd\r\n);\r\n\r\nVOID _app_message_uninitialize (\r\n\t_In_ HWND hwnd\r\n);\r\n\r\nVOID _app_generate_appmenu (\r\n\t_In_ HMENU hmenu,\r\n\t_In_opt_ HMENU hsubmenu_rules,\r\n\t_In_opt_ HMENU hsubmenu_timers,\r\n\t_In_ ULONG app_hash\r\n);\r\n\r\nVOID _app_message_contextmenu (\r\n\t_In_ HWND hwnd,\r\n\t_In_ LPNMITEMACTIVATE lpnmlv\r\n);\r\n\r\nVOID _app_message_contextmenu_columns (\r\n\t_In_ HWND hwnd,\r\n\t_In_ LPNMHDR nmlp\r\n);\r\n\r\nVOID _app_message_traycontextmenu (\r\n\t_In_ HWND hwnd\r\n);\r\n\r\nLONG_PTR _app_message_custdraw (\r\n\t_In_ HWND hwnd,\r\n\t_In_ LPNMLVCUSTOMDRAW lpnmlv\r\n);\r\n\r\nVOID _app_message_dpichanged (\r\n\t_In_ HWND hwnd,\r\n\t_In_ LONG dpi_value\r\n);\r\n\r\nBOOLEAN _app_message_displayinfo (\r\n\t_In_ HWND hwnd,\r\n\t_In_ INT listview_id,\r\n\t_Inout_ LPNMLVDISPINFOW lpnmlv\r\n);\r\n\r\nVOID _app_command_idtorules (\r\n\t_In_ HWND hwnd,\r\n\t_In_ INT ctrl_id\r\n);\r\n\r\nVOID _app_command_idtotimers (\r\n\t_In_ HWND hwnd,\r\n\t_In_ INT ctrl_id\r\n);\r\n\r\nVOID _app_command_logshow (\r\n\t_In_ HWND hwnd\r\n);\r\n\r\nVOID _app_command_logclear (\r\n\t_In_ HWND hwnd\r\n);\r\n\r\nVOID _app_command_logerrshow (\r\n\t_In_opt_ HWND hwnd\r\n);\r\n\r\nVOID _app_command_logerrclear (\r\n\t_In_opt_ HWND hwnd\r\n);\r\n\r\nVOID _app_command_copy (\r\n\t_In_ HWND hwnd,\r\n\t_In_ INT ctrl_id,\r\n\t_In_ INT column_id\r\n);\r\n\r\nVOID _app_command_checkbox (\r\n\t_In_ HWND hwnd,\r\n\t_In_ INT ctrl_id\r\n);\r\n\r\nVOID _app_command_delete (\r\n\t_In_ HWND hwnd\r\n);\r\n\r\nVOID _app_command_disable (\r\n\t_In_ HWND hwnd,\r\n\t_In_ INT ctrl_id\r\n);\r\n\r\nVOID _app_command_openeditor (\r\n\t_In_ HWND hwnd\r\n);\r\n\r\nVOID _app_command_properties (\r\n\t_In_ HWND hwnd\r\n);\r\n\r\nVOID _app_command_purgeunused (\r\n\t_In_ HWND hwnd\r\n);\r\n\r\nVOID _app_command_purgetimers (\r\n\t_In_ HWND hwnd\r\n);\r\n\r\nVOID _app_command_selectfont (\r\n\t_In_ HWND hwnd\r\n);\r\n"
  },
  {
    "path": "src/network.c",
    "content": "// simplewall\n// Copyright (c) 2019-2025 Henry++\n\n#include \"global.h\"\n\n_Ret_maybenull_\nPITEM_NETWORK_CONTEXT _app_network_getcontext ()\n{\n\tstatic R_INITONCE init_once = PR_INITONCE_INIT;\n\tstatic PITEM_NETWORK_CONTEXT network_context = NULL;\n\n\tif (_r_initonce_begin (&init_once))\n\t{\n\t\tnetwork_context = _r_mem_allocate (sizeof (ITEM_NETWORK_CONTEXT));\n\n\t\tnetwork_context->network_ptr = _r_obj_createhashtablepointer (256);\n\t\tnetwork_context->checker_ptr = _r_obj_createhashtablepointer (256);\n\n\t\t_r_initonce_end (&init_once);\n\t}\n\n\treturn network_context;\n}\n\nVOID _app_network_initialize (\n\t_In_ HWND hwnd\n)\n{\n\tPITEM_NETWORK_CONTEXT network_context;\n\tR_ENVIRONMENT environment;\n\tBOOLEAN is_enabled;\n\n\tis_enabled = _r_config_getboolean (L\"IsNetworkMonitorEnabled\", TRUE, NULL);\n\n\tif (!is_enabled)\n\t\treturn;\n\n\tnetwork_context = _app_network_getcontext ();\n\n\tif (!network_context)\n\t\treturn;\n\n\tnetwork_context->hwnd = hwnd;\n\n\t_r_queuedlock_acquireexclusive (&network_context->lock_network);\n\t_r_obj_clearhashtable (network_context->network_ptr);\n\t_r_queuedlock_releaseexclusive (&network_context->lock_network);\n\n\t_r_queuedlock_acquireexclusive (&network_context->lock_checker);\n\t_r_obj_clearhashtable (network_context->checker_ptr);\n\t_r_queuedlock_releaseexclusive (&network_context->lock_checker);\n\n\t// create network monitor thread\n\t_r_sys_setenvironment (&environment, THREAD_PRIORITY_ABOVE_NORMAL, IoPriorityNormal, MEMORY_PRIORITY_NORMAL);\n\n\t_r_sys_createthread (NULL, NtCurrentProcess (), &_app_network_threadproc, network_context, &environment, L\"NetworkMonitor\");\n}\n\nVOID _app_network_uninitialize (\n\t_In_ PITEM_NETWORK_CONTEXT context\n)\n{\n\t_r_queuedlock_acquireexclusive (&context->lock_network);\n\t_r_obj_clearhashtable (context->network_ptr);\n\t_r_queuedlock_releaseexclusive (&context->lock_network);\n\n\t_r_queuedlock_acquireexclusive (&context->lock_checker);\n\t_r_obj_clearhashtable (context->checker_ptr);\n\t_r_queuedlock_releaseexclusive (&context->lock_checker);\n}\n\nVOID _app_network_generatetable (\n\t_Inout_ PITEM_NETWORK_CONTEXT network_context\n)\n{\n\tPMIB_TCPTABLE_OWNER_MODULE tcp4_table;\n\tPMIB_TCP6TABLE_OWNER_MODULE tcp6_table;\n\tPMIB_UDPTABLE_OWNER_MODULE udp4_table;\n\tPMIB_UDP6TABLE_OWNER_MODULE udp6_table;\n\tPITEM_NETWORK ptr_network;\n\tIN_ADDR remote_addr;\n\tIN_ADDR local_addr;\n\tPVOID buffer;\n\tULONG network_hash;\n\tULONG allocated_size;\n\tULONG required_size;\n\tULONG status;\n\n\t_r_queuedlock_acquireexclusive (&network_context->lock_checker);\n\t_r_obj_clearhashtable (network_context->checker_ptr);\n\t_r_queuedlock_releaseexclusive (&network_context->lock_checker);\n\n\trequired_size = 0;\n\tGetExtendedTcpTable (NULL, &required_size, FALSE, AF_INET, TCP_TABLE_OWNER_MODULE_ALL, 0);\n\n\tallocated_size = required_size;\n\tbuffer = _r_mem_allocate (allocated_size);\n\n\tif (required_size)\n\t{\n\t\ttcp4_table = buffer;\n\t\tstatus = GetExtendedTcpTable (tcp4_table, &required_size, FALSE, AF_INET, TCP_TABLE_OWNER_MODULE_ALL, 0);\n\n\t\tif (status == NO_ERROR)\n\t\t{\n\t\t\tfor (ULONG i = 0; i < tcp4_table->dwNumEntries; i++)\n\t\t\t{\n\t\t\t\tRtlZeroMemory (&remote_addr, sizeof (remote_addr));\n\t\t\t\tRtlZeroMemory (&local_addr, sizeof (local_addr));\n\n\t\t\t\tremote_addr.S_un.S_addr = tcp4_table->table[i].dwRemoteAddr;\n\t\t\t\tlocal_addr.S_un.S_addr = tcp4_table->table[i].dwLocalAddr;\n\n\t\t\t\tnetwork_hash = _app_network_gethash (\n\t\t\t\t\tAF_INET,\n\t\t\t\t\ttcp4_table->table[i].dwOwningPid,\n\t\t\t\t\t&remote_addr,\n\t\t\t\t\ttcp4_table->table[i].dwRemotePort,\n\t\t\t\t\t&local_addr,\n\t\t\t\t\ttcp4_table->table[i].dwLocalPort,\n\t\t\t\t\tIPPROTO_TCP,\n\t\t\t\t\ttcp4_table->table[i].dwState\n\t\t\t\t);\n\n\t\t\t\tif (_app_network_isitemfound (network_hash))\n\t\t\t\t{\n\t\t\t\t\t_r_queuedlock_acquireexclusive (&network_context->lock_checker);\n\n\t\t\t\t\t_r_obj_addhashtablepointer (network_context->checker_ptr, network_hash, NULL);\n\n\t\t\t\t\t_r_queuedlock_releaseexclusive (&network_context->lock_checker);\n\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tptr_network = _r_obj_allocate (sizeof (ITEM_NETWORK), &_app_dereferencenetwork);\n\n\t\t\t\tif (!_app_network_getpath (ptr_network, tcp4_table->table[i].dwOwningPid, tcp4_table->table[i].OwningModuleInfo))\n\t\t\t\t{\n\t\t\t\t\t_r_obj_dereference (ptr_network);\n\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tptr_network->af = AF_INET;\n\t\t\t\tptr_network->protocol = IPPROTO_TCP;\n\t\t\t\tptr_network->protocol_str = _r_obj_createstring (_app_db_getprotoname (ptr_network->protocol, ptr_network->af));\n\n\t\t\t\tptr_network->remote_addr.S_un.S_addr = tcp4_table->table[i].dwRemoteAddr;\n\t\t\t\tptr_network->remote_port = _r_byteswap_ushort ((USHORT)tcp4_table->table[i].dwRemotePort);\n\n\t\t\t\tptr_network->local_addr.S_un.S_addr = tcp4_table->table[i].dwLocalAddr;\n\t\t\t\tptr_network->local_port = _r_byteswap_ushort ((USHORT)tcp4_table->table[i].dwLocalPort);\n\n\t\t\t\tptr_network->state = tcp4_table->table[i].dwState;\n\n\t\t\t\tif (tcp4_table->table[i].dwState == MIB_TCP_STATE_ESTAB)\n\t\t\t\t{\n\t\t\t\t\tif (_app_network_isvalidconnection (ptr_network->af, &ptr_network->remote_addr) || _app_network_isvalidconnection (ptr_network->af, &ptr_network->local_addr))\n\t\t\t\t\t\tptr_network->is_connection = TRUE;\n\t\t\t\t}\n\n\t\t\t\t_r_queuedlock_acquireexclusive (&network_context->lock_network);\n\t\t\t\t_r_obj_addhashtablepointer (network_context->network_ptr, network_hash, ptr_network);\n\t\t\t\t_r_queuedlock_releaseexclusive (&network_context->lock_network);\n\n\t\t\t\t_r_queuedlock_acquireexclusive (&network_context->lock_checker);\n\t\t\t\t_r_obj_addhashtablepointer (network_context->checker_ptr, network_hash, _r_obj_reference (ptr_network->path));\n\t\t\t\t_r_queuedlock_releaseexclusive (&network_context->lock_checker);\n\t\t\t}\n\t\t}\n\t}\n\n\trequired_size = 0;\n\tGetExtendedTcpTable (NULL, &required_size, FALSE, AF_INET6, TCP_TABLE_OWNER_MODULE_ALL, 0);\n\n\tif (required_size)\n\t{\n\t\tif (allocated_size < required_size)\n\t\t{\n\t\t\tbuffer = _r_mem_reallocate (buffer, required_size);\n\n\t\t\tallocated_size = required_size;\n\t\t}\n\n\t\ttcp6_table = buffer;\n\t\tstatus = GetExtendedTcpTable (tcp6_table, &required_size, FALSE, AF_INET6, TCP_TABLE_OWNER_MODULE_ALL, 0);\n\n\t\tif (status == NO_ERROR)\n\t\t{\n\t\t\tfor (ULONG i = 0; i < tcp6_table->dwNumEntries; i++)\n\t\t\t{\n\t\t\t\tnetwork_hash = _app_network_gethash (\n\t\t\t\t\tAF_INET6,\n\t\t\t\t\ttcp6_table->table[i].dwOwningPid,\n\t\t\t\t\ttcp6_table->table[i].ucRemoteAddr,\n\t\t\t\t\ttcp6_table->table[i].dwRemotePort,\n\t\t\t\t\ttcp6_table->table[i].ucLocalAddr,\n\t\t\t\t\ttcp6_table->table[i].dwLocalPort,\n\t\t\t\t\tIPPROTO_TCP,\n\t\t\t\t\ttcp6_table->table[i].dwState\n\t\t\t\t);\n\n\t\t\t\tif (_app_network_isitemfound (network_hash))\n\t\t\t\t{\n\t\t\t\t\t_r_queuedlock_acquireexclusive (&network_context->lock_checker);\n\t\t\t\t\t_r_obj_addhashtablepointer (network_context->checker_ptr, network_hash, NULL);\n\t\t\t\t\t_r_queuedlock_releaseexclusive (&network_context->lock_checker);\n\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tptr_network = _r_obj_allocate (sizeof (ITEM_NETWORK), &_app_dereferencenetwork);\n\n\t\t\t\tif (!_app_network_getpath (ptr_network, tcp6_table->table[i].dwOwningPid, tcp6_table->table[i].OwningModuleInfo))\n\t\t\t\t{\n\t\t\t\t\t_r_obj_dereference (ptr_network);\n\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tptr_network->af = AF_INET6;\n\t\t\t\tptr_network->protocol = IPPROTO_TCP;\n\t\t\t\tptr_network->protocol_str = _r_obj_createstring (_app_db_getprotoname (ptr_network->protocol, ptr_network->af));\n\n\t\t\t\tRtlCopyMemory (ptr_network->remote_addr6.u.Byte, tcp6_table->table[i].ucRemoteAddr, FWP_V6_ADDR_SIZE);\n\t\t\t\tptr_network->remote_port = _r_byteswap_ushort ((USHORT)tcp6_table->table[i].dwRemotePort);\n\n\t\t\t\tRtlCopyMemory (ptr_network->local_addr6.u.Byte, tcp6_table->table[i].ucLocalAddr, FWP_V6_ADDR_SIZE);\n\t\t\t\tptr_network->local_port = _r_byteswap_ushort ((USHORT)tcp6_table->table[i].dwLocalPort);\n\n\t\t\t\tptr_network->state = tcp6_table->table[i].dwState;\n\n\t\t\t\tif (tcp6_table->table[i].dwState == MIB_TCP_STATE_ESTAB)\n\t\t\t\t{\n\t\t\t\t\tif (_app_network_isvalidconnection (ptr_network->af, &ptr_network->remote_addr6) || _app_network_isvalidconnection (ptr_network->af, &ptr_network->local_addr6))\n\t\t\t\t\t\tptr_network->is_connection = TRUE;\n\t\t\t\t}\n\n\t\t\t\t_r_queuedlock_acquireexclusive (&network_context->lock_network);\n\t\t\t\t_r_obj_addhashtablepointer (network_context->network_ptr, network_hash, ptr_network);\n\t\t\t\t_r_queuedlock_releaseexclusive (&network_context->lock_network);\n\n\t\t\t\t_r_queuedlock_acquireexclusive (&network_context->lock_checker);\n\t\t\t\t_r_obj_addhashtablepointer (network_context->checker_ptr, network_hash, _r_obj_reference (ptr_network->path));\n\t\t\t\t_r_queuedlock_releaseexclusive (&network_context->lock_checker);\n\t\t\t}\n\t\t}\n\t}\n\n\trequired_size = 0;\n\tGetExtendedUdpTable (NULL, &required_size, FALSE, AF_INET, UDP_TABLE_OWNER_MODULE, 0);\n\n\tif (required_size)\n\t{\n\t\tif (allocated_size < required_size)\n\t\t{\n\t\t\tbuffer = _r_mem_reallocate (buffer, required_size);\n\t\t\tallocated_size = required_size;\n\t\t}\n\n\t\tudp4_table = buffer;\n\t\tstatus = GetExtendedUdpTable (udp4_table, &required_size, FALSE, AF_INET, UDP_TABLE_OWNER_MODULE, 0);\n\n\t\tif (status == NO_ERROR)\n\t\t{\n\t\t\tfor (ULONG i = 0; i < udp4_table->dwNumEntries; i++)\n\t\t\t{\n\t\t\t\tRtlZeroMemory (&local_addr, sizeof (local_addr));\n\n\t\t\t\tlocal_addr.S_un.S_addr = udp4_table->table[i].dwLocalAddr;\n\n\t\t\t\tnetwork_hash = _app_network_gethash (\n\t\t\t\t\tAF_INET,\n\t\t\t\t\tudp4_table->table[i].dwOwningPid,\n\t\t\t\t\tNULL,\n\t\t\t\t\t0,\n\t\t\t\t\t&local_addr,\n\t\t\t\t\tudp4_table->table[i].dwLocalPort,\n\t\t\t\t\tIPPROTO_UDP,\n\t\t\t\t\t0\n\t\t\t\t);\n\n\t\t\t\tif (_app_network_isitemfound (network_hash))\n\t\t\t\t{\n\t\t\t\t\t_r_queuedlock_acquireexclusive (&network_context->lock_checker);\n\t\t\t\t\t_r_obj_addhashtablepointer (network_context->checker_ptr, network_hash, NULL);\n\t\t\t\t\t_r_queuedlock_releaseexclusive (&network_context->lock_checker);\n\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tptr_network = _r_obj_allocate (sizeof (ITEM_NETWORK), &_app_dereferencenetwork);\n\n\t\t\t\tif (!_app_network_getpath (ptr_network, udp4_table->table[i].dwOwningPid, udp4_table->table[i].OwningModuleInfo))\n\t\t\t\t{\n\t\t\t\t\t_r_obj_dereference (ptr_network);\n\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tptr_network->af = AF_INET;\n\t\t\t\tptr_network->protocol = IPPROTO_UDP;\n\t\t\t\tptr_network->protocol_str = _r_obj_createstring (_app_db_getprotoname (ptr_network->protocol, ptr_network->af));\n\n\t\t\t\tptr_network->local_addr.S_un.S_addr = udp4_table->table[i].dwLocalAddr;\n\t\t\t\tptr_network->local_port = _r_byteswap_ushort ((USHORT)udp4_table->table[i].dwLocalPort);\n\n\t\t\t\tif (_app_network_isvalidconnection (ptr_network->af, &ptr_network->local_addr))\n\t\t\t\t\tptr_network->is_connection = TRUE;\n\n\t\t\t\t_r_queuedlock_acquireexclusive (&network_context->lock_network);\n\t\t\t\t_r_obj_addhashtablepointer (network_context->network_ptr, network_hash, ptr_network);\n\t\t\t\t_r_queuedlock_releaseexclusive (&network_context->lock_network);\n\n\t\t\t\t_r_queuedlock_acquireexclusive (&network_context->lock_checker);\n\t\t\t\t_r_obj_addhashtablepointer (network_context->checker_ptr, network_hash, _r_obj_reference (ptr_network->path));\n\t\t\t\t_r_queuedlock_releaseexclusive (&network_context->lock_checker);\n\t\t\t}\n\t\t}\n\t}\n\n\trequired_size = 0;\n\tGetExtendedUdpTable (NULL, &required_size, FALSE, AF_INET6, UDP_TABLE_OWNER_MODULE, 0);\n\n\tif (required_size)\n\t{\n\t\tif (allocated_size < required_size)\n\t\t{\n\t\t\tbuffer = _r_mem_reallocate (buffer, required_size);\n\t\t\tallocated_size = required_size;\n\t\t}\n\n\t\tudp6_table = buffer;\n\t\tstatus = GetExtendedUdpTable (udp6_table, &required_size, FALSE, AF_INET6, UDP_TABLE_OWNER_MODULE, 0);\n\n\t\tif (status == NO_ERROR)\n\t\t{\n\t\t\tfor (ULONG i = 0; i < udp6_table->dwNumEntries; i++)\n\t\t\t{\n\t\t\t\tnetwork_hash = _app_network_gethash (\n\t\t\t\t\tAF_INET6,\n\t\t\t\t\tudp6_table->table[i].dwOwningPid,\n\t\t\t\t\tNULL,\n\t\t\t\t\t0,\n\t\t\t\t\tudp6_table->table[i].ucLocalAddr,\n\t\t\t\t\tudp6_table->table[i].dwLocalPort,\n\t\t\t\t\tIPPROTO_UDP,\n\t\t\t\t\t0\n\t\t\t\t);\n\n\t\t\t\tif (_app_network_isitemfound (network_hash))\n\t\t\t\t{\n\t\t\t\t\t_r_queuedlock_acquireexclusive (&network_context->lock_checker);\n\t\t\t\t\t_r_obj_addhashtablepointer (network_context->checker_ptr, network_hash, NULL);\n\t\t\t\t\t_r_queuedlock_releaseexclusive (&network_context->lock_checker);\n\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tptr_network = _r_obj_allocate (sizeof (ITEM_NETWORK), &_app_dereferencenetwork);\n\n\t\t\t\tif (!_app_network_getpath (ptr_network, udp6_table->table[i].dwOwningPid, udp6_table->table[i].OwningModuleInfo))\n\t\t\t\t{\n\t\t\t\t\t_r_obj_dereference (ptr_network);\n\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tptr_network->af = AF_INET6;\n\t\t\t\tptr_network->protocol = IPPROTO_UDP;\n\t\t\t\tptr_network->protocol_str = _r_obj_createstring (_app_db_getprotoname (ptr_network->protocol, ptr_network->af));\n\n\t\t\t\tRtlCopyMemory (ptr_network->local_addr6.u.Byte, udp6_table->table[i].ucLocalAddr, FWP_V6_ADDR_SIZE);\n\t\t\t\tptr_network->local_port = _r_byteswap_ushort ((USHORT)udp6_table->table[i].dwLocalPort);\n\n\t\t\t\tif (_app_network_isvalidconnection (ptr_network->af, &ptr_network->local_addr6))\n\t\t\t\t\tptr_network->is_connection = TRUE;\n\n\t\t\t\t_r_queuedlock_acquireexclusive (&network_context->lock_network);\n\t\t\t\t_r_obj_addhashtablepointer (network_context->network_ptr, network_hash, ptr_network);\n\t\t\t\t_r_queuedlock_releaseexclusive (&network_context->lock_network);\n\n\t\t\t\t_r_queuedlock_acquireexclusive (&network_context->lock_checker);\n\t\t\t\t_r_obj_addhashtablepointer (network_context->checker_ptr, network_hash, _r_obj_reference (ptr_network->path));\n\t\t\t\t_r_queuedlock_releaseexclusive (&network_context->lock_checker);\n\t\t\t}\n\t\t}\n\t}\n\n\tif (buffer)\n\t\t_r_mem_free (buffer);\n}\n\n_Ret_maybenull_\nPITEM_NETWORK _app_network_getitem (\n\t_In_ ULONG network_hash\n)\n{\n\tPITEM_NETWORK_CONTEXT network_context;\n\tPITEM_NETWORK ptr_network;\n\n\tnetwork_context = _app_network_getcontext ();\n\n\tif (!network_context)\n\t\treturn NULL;\n\n\t_r_queuedlock_acquireshared (&network_context->lock_network);\n\tptr_network = _r_obj_findhashtablepointer (network_context->network_ptr, network_hash);\n\t_r_queuedlock_releaseshared (&network_context->lock_network);\n\n\treturn ptr_network;\n}\n\n_Success_ (return != 0)\nULONG _app_network_getappitem (\n\t_In_ ULONG network_hash\n)\n{\n\tPITEM_NETWORK ptr_network;\n\tULONG hash_code;\n\n\tptr_network = _app_network_getitem (network_hash);\n\n\tif (!ptr_network)\n\t\treturn 0;\n\n\thash_code = ptr_network->app_hash;\n\n\t_r_obj_dereference (ptr_network);\n\n\treturn hash_code;\n}\n\nULONG _app_network_gethash (\n\t_In_ ADDRESS_FAMILY af,\n\t_In_ ULONG pid,\n\t_In_opt_ LPCVOID remote_addr,\n\t_In_opt_ ULONG remote_port,\n\t_In_opt_ LPCVOID local_addr,\n\t_In_opt_ ULONG local_port,\n\t_In_ UINT8 proto,\n\t_In_opt_ ULONG state\n)\n{\n\tWCHAR remote_address[LEN_IP_MAX] = {0};\n\tWCHAR local_address[LEN_IP_MAX] = {0};\n\tPR_STRING network_string;\n\tULONG network_hash;\n\n\tif (remote_addr)\n\t\t_app_formatip (af, remote_addr, remote_address, RTL_NUMBER_OF (remote_address), FALSE);\n\n\tif (local_addr)\n\t\t_app_formatip (af, local_addr, local_address, RTL_NUMBER_OF (local_address), FALSE);\n\n\tnetwork_string = _r_format_string (\n\t\tL\"%\" TEXT (PRIu8) L\"_%\" TEXT (PR_ULONG) L\"_%s_%\" TEXT (PR_ULONG) L\"_%s_%\" TEXT (PR_ULONG) L\"_%\" TEXT (PRIu8) L\"_%\" TEXT (PR_ULONG),\n\t\taf,\n\t\tpid,\n\t\tremote_address,\n\t\tremote_port,\n\t\tlocal_address,\n\t\tlocal_port,\n\t\tproto,\n\t\tstate\n\t);\n\n\tnetwork_hash = _r_str_gethash (&network_string->sr, TRUE);\n\n\t_r_obj_dereference (network_string);\n\n\treturn network_hash;\n}\n\nBOOLEAN _app_network_getpath (\n\t_Inout_ PITEM_NETWORK ptr_network,\n\t_In_ ULONG pid,\n\t_In_opt_ PULONG64 modules\n)\n{\n\tPTOKEN_APPCONTAINER_INFORMATION app_container = NULL;\n\tPR_STRING process_name = NULL;\n\tHANDLE hprocess;\n\tHANDLE htoken;\n\tNTSTATUS status;\n\n\tif (pid == PROC_WAITING_PID)\n\t{\n\t\tptr_network->app_hash = 0;\n\t\tptr_network->type = DATA_APP_REGULAR;\n\t\tptr_network->path = _r_obj_createstring (PROC_WAITING_NAME);\n\n\t\treturn TRUE;\n\t}\n\telse if (pid == PROC_SYSTEM_PID)\n\t{\n\t\tptr_network->app_hash = config.ntoskrnl_hash;\n\t\tptr_network->type = DATA_APP_REGULAR;\n\t\tptr_network->path = _r_obj_createstring (PROC_SYSTEM_NAME);\n\n\t\treturn TRUE;\n\t}\n\n\tif (modules)\n\t{\n\t\tprocess_name = _r_sys_querytaginformation (pid, ULongToPtr (*(PULONG)modules));\n\n\t\tif (process_name)\n\t\t\tptr_network->type = DATA_APP_SERVICE;\n\t}\n\n\tif (!process_name)\n\t{\n\t\tstatus = _r_sys_openprocess (pid, PROCESS_QUERY_LIMITED_INFORMATION, &hprocess);\n\n\t\tif (NT_SUCCESS (status))\n\t\t{\n\t\t\tif (_r_sys_isprocessimmersive (hprocess))\n\t\t\t{\n\t\t\t\tptr_network->type = DATA_APP_UWP;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tptr_network->type = DATA_APP_REGULAR;\n\t\t\t}\n\n\t\t\tif (ptr_network->type == DATA_APP_UWP)\n\t\t\t{\n\t\t\t\tstatus = NtOpenProcessTokenEx (hprocess, TOKEN_QUERY, 0, &htoken);\n\n\t\t\t\tif (NT_SUCCESS (status))\n\t\t\t\t{\n\t\t\t\t\tstatus = _r_sys_querytokeninformation (htoken, TokenAppContainerSid, (PVOID_PTR)&app_container);\n\n\t\t\t\t\tif (NT_SUCCESS (status))\n\t\t\t\t\t{\n\t\t\t\t\t\t_r_str_fromsid (app_container->TokenAppContainer, &process_name);\n\n\t\t\t\t\t\t_r_mem_free (app_container);\n\t\t\t\t\t}\n\n\t\t\t\t\tNtClose (htoken);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (!process_name)\n\t\t\t{\n\t\t\t\tstatus = _r_sys_queryprocessstring (hprocess, ProcessImageFileNameWin32, &process_name);\n\n\t\t\t\t// fix for WSL processes (issue #606)\n\t\t\t\tif (status == STATUS_UNSUCCESSFUL)\n\t\t\t\t\tstatus = _r_sys_queryprocessstring (hprocess, ProcessImageFileName, &process_name);\n\t\t\t}\n\n\t\t\tNtClose (hprocess);\n\t\t}\n\t}\n\n\tif (process_name)\n\t{\n\t\tptr_network->app_hash = _r_str_gethash (&process_name->sr, TRUE);\n\t\tptr_network->path = process_name;\n\n\t\treturn TRUE;\n\t}\n\n\treturn FALSE;\n}\n\nBOOLEAN _app_network_isapphaveconnection (\n\t_In_ ULONG app_hash\n)\n{\n\tPITEM_NETWORK_CONTEXT network_context;\n\tPITEM_NETWORK ptr_network = NULL;\n\tULONG_PTR enum_key = 0;\n\n\tnetwork_context = _app_network_getcontext ();\n\n\tif (!network_context)\n\t\treturn FALSE;\n\n\t_r_queuedlock_acquireshared (&network_context->lock_network);\n\n\twhile (_r_obj_enumhashtablepointer (network_context->network_ptr, (PVOID_PTR)&ptr_network, NULL, &enum_key))\n\t{\n\t\tif (ptr_network->app_hash != app_hash)\n\t\t\tcontinue;\n\n\t\tif (ptr_network->is_connection)\n\t\t{\n\t\t\t_r_queuedlock_releaseshared (&network_context->lock_network);\n\n\t\t\treturn TRUE;\n\t\t}\n\t}\n\n\t_r_queuedlock_releaseshared (&network_context->lock_network);\n\n\treturn FALSE;\n}\n\nBOOLEAN _app_network_isitemfound (\n\t_In_ ULONG network_hash\n)\n{\n\tPITEM_NETWORK_CONTEXT network_context;\n\tBOOLEAN is_found;\n\n\tnetwork_context = _app_network_getcontext ();\n\n\tif (!network_context)\n\t\treturn FALSE;\n\n\t_r_queuedlock_acquireshared (&network_context->lock_network);\n\tis_found = (_r_obj_findhashtable (network_context->network_ptr, network_hash) != NULL);\n\t_r_queuedlock_releaseshared (&network_context->lock_network);\n\n\treturn is_found;\n}\n\nBOOLEAN _app_network_isvalidconnection (\n\t_In_ ADDRESS_FAMILY af,\n\t_In_ LPCVOID address\n)\n{\n\tPIN_ADDR p4addr;\n\tPIN6_ADDR p6addr;\n\n\tswitch (af)\n\t{\n\t\tcase AF_INET:\n\t\t{\n\t\t\tp4addr = (PIN_ADDR)address;\n\n\t\t\treturn (!IN4_IS_ADDR_UNSPECIFIED (p4addr) &&\n\t\t\t\t\t!IN4_IS_ADDR_LOOPBACK (p4addr) &&\n\t\t\t\t\t!IN4_IS_ADDR_LINKLOCAL (p4addr) &&\n\t\t\t\t\t!IN4_IS_ADDR_MULTICAST (p4addr) &&\n\t\t\t\t\t!IN4_IS_ADDR_MC_ADMINLOCAL (p4addr) &&\n\t\t\t\t\t!IN4_IS_ADDR_RFC1918 (p4addr));\n\t\t}\n\n\t\tcase AF_INET6:\n\t\t{\n\t\t\tp6addr = (PIN6_ADDR)address;\n\n\t\t\treturn (!IN6_IS_ADDR_UNSPECIFIED (p6addr) &&\n\t\t\t\t\t!IN6_IS_ADDR_LOOPBACK (p6addr) &&\n\t\t\t\t\t!IN6_IS_ADDR_LINKLOCAL (p6addr) &&\n\t\t\t\t\t!IN6_IS_ADDR_MULTICAST (p6addr) &&\n\t\t\t\t\t!IN6_IS_ADDR_SITELOCAL (p6addr) &&\n\t\t\t\t\t!IN6_IS_ADDR_ANYCAST (p6addr));\n\t\t}\n\t}\n\n\treturn FALSE;\n}\n\nVOID _app_network_printlistviewtable (\n\t_Inout_ PITEM_NETWORK_CONTEXT network_context\n)\n{\n\tPITEM_NETWORK ptr_network = NULL;\n\tPR_STRING string;\n\tULONG_PTR enum_key = 0;\n\tULONG_PTR app_hash;\n\tULONG network_hash;\n\tINT item_count;\n\tBOOLEAN is_highlight = FALSE;\n\tBOOLEAN is_refresh = FALSE;\n\n\tif (_r_config_getboolean (L\"IsEnableHighlighting\", TRUE, NULL) && _r_config_getboolean (L\"IsHighlightConnection\", TRUE, L\"colors\"))\n\t\tis_highlight = TRUE;\n\n\t// add new connections into listview\n\t_r_queuedlock_acquireshared (&network_context->lock_network);\n\n\twhile (_r_obj_enumhashtablepointer (network_context->network_ptr, (PVOID_PTR)&ptr_network, &network_hash, &enum_key))\n\t{\n\t\tstring = _r_obj_findhashtablepointer (network_context->checker_ptr, network_hash);\n\n\t\tif (!string)\n\t\t\tcontinue;\n\n\t\t_app_listview_addnetworkitem (network_context->hwnd, network_hash);\n\n\t\tif (ptr_network->path && ptr_network->app_hash)\n\t\t\t_app_getfileinformation (ptr_network->path, ptr_network->app_hash, ptr_network->type, IDC_NETWORK);\n\n\t\t// resolve network address\n\t\t_app_queue_resolver (network_context->hwnd, IDC_NETWORK, network_hash, ptr_network);\n\n\t\t_r_obj_dereference (string);\n\n\t\tis_refresh = TRUE;\n\t}\n\n\t_r_queuedlock_releaseshared (&network_context->lock_network);\n\n\t// refresh network tab\n\tif (is_refresh)\n\t\t_app_listview_updateby_id (network_context->hwnd, IDC_NETWORK, PR_UPDATE_NORESIZE);\n\n\t// remove closed connections from list\n\titem_count = _r_listview_getitemcount (network_context->hwnd, IDC_NETWORK);\n\n\tif (!item_count)\n\t\treturn;\n\n\tfor (INT i = item_count - 1; i != INT_ERROR; i--)\n\t{\n\t\tnetwork_hash = (ULONG)_app_listview_getitemcontext (network_context->hwnd, IDC_NETWORK, i);\n\n\t\tif (_r_obj_findhashtable (network_context->checker_ptr, network_hash))\n\t\t\tcontinue;\n\n\t\t_r_listview_deleteitem (network_context->hwnd, IDC_NETWORK, i);\n\n\t\tapp_hash = _app_network_getappitem (network_hash);\n\n\t\t_app_network_removeitem (network_hash);\n\n\t\t// redraw listview item\n\t\tif (!is_highlight || !app_hash)\n\t\t\tcontinue;\n\n\t\t_app_listview_updateby_param (network_context->hwnd, app_hash, PR_SETITEM_REDRAW, TRUE);\n\t}\n}\n\nVOID _app_network_removeitem (\n\t_In_ ULONG network_hash\n)\n{\n\tPITEM_NETWORK_CONTEXT network_context;\n\n\tnetwork_context = _app_network_getcontext ();\n\n\tif (!network_context)\n\t\treturn;\n\n\t_r_queuedlock_acquireexclusive (&network_context->lock_network);\n\t_r_obj_removehashtableitem (network_context->network_ptr, network_hash);\n\t_r_queuedlock_releaseexclusive (&network_context->lock_network);\n}\n\nVOID NTAPI _app_network_threadproc (\n\t_In_ PVOID arglist\n)\n{\n\tPITEM_NETWORK_CONTEXT network_context;\n\n\tnetwork_context = (PITEM_NETWORK_CONTEXT)arglist;\n\n\twhile (TRUE)\n\t{\n\t\t// update network table\n\t\t_app_network_generatetable (network_context);\n\t\t_app_network_printlistviewtable (network_context);\n\n\t\t_r_sys_waitforsingleobject (NtCurrentThread (), 3000);\n\t}\n\n\t_app_network_uninitialize (network_context);\n}\n"
  },
  {
    "path": "src/network.h",
    "content": "// simplewall\n// Copyright (c) 2019-2025 Henry++\n\n#pragma once\n\ntypedef struct _ITEM_NETWORK_CONTEXT\n{\n\tHWND hwnd;\n\n\tR_QUEUED_LOCK lock_network;\n\tR_QUEUED_LOCK lock_checker;\n\n\tPR_HASHTABLE network_ptr;\n\tPR_HASHTABLE checker_ptr;\n} ITEM_NETWORK_CONTEXT, *PITEM_NETWORK_CONTEXT;\n\nVOID _app_network_initialize (\n\t_In_ HWND hwnd\n);\n\nVOID _app_network_uninitialize (\n\t_In_ PITEM_NETWORK_CONTEXT context\n);\n\nVOID _app_network_generatetable (\n\t_Inout_ PITEM_NETWORK_CONTEXT context\n);\n\n_Ret_maybenull_\nPITEM_NETWORK _app_network_getitem (\n\t_In_ ULONG network_hash\n);\n\n_Success_ (return != 0)\nULONG _app_network_getappitem (\n\t_In_ ULONG network_hash\n);\n\nULONG _app_network_gethash (\n\t_In_ ADDRESS_FAMILY af,\n\t_In_ ULONG pid,\n\t_In_opt_ LPCVOID remote_addr,\n\t_In_opt_ ULONG remote_port,\n\t_In_opt_ LPCVOID local_addr,\n\t_In_opt_ ULONG local_port,\n\t_In_ UINT8 proto,\n\t_In_opt_ ULONG state\n);\n\nBOOLEAN _app_network_getpath (\n\t_Inout_ PITEM_NETWORK ptr_network,\n\t_In_ ULONG pid,\n\t_In_opt_ PULONG64 modules\n);\n\nBOOLEAN _app_network_isapphaveconnection (\n\t_In_ ULONG app_hash\n);\n\nBOOLEAN _app_network_isitemfound (\n\t_In_ ULONG network_hash\n);\n\nBOOLEAN _app_network_isvalidconnection (\n\t_In_ ADDRESS_FAMILY af,\n\t_In_ LPCVOID address\n);\n\nVOID _app_network_printlistviewtable (\n\t_Inout_ PITEM_NETWORK_CONTEXT context\n);\n\nVOID _app_network_removeitem (\n\t_In_ ULONG network_hash\n);\n\nVOID NTAPI _app_network_threadproc (\n\t_In_ PVOID arglist\n);\n"
  },
  {
    "path": "src/notifications.c",
    "content": "// simplewall\r\n// Copyright (c) 2016-2026 Henry++\r\n\r\n#include \"global.h\"\r\n\r\n_Ret_maybenull_\r\nHWND _app_notify_getwindow (\r\n\t_In_opt_ PITEM_LOG ptr_log\r\n)\r\n{\r\n\tHWND hwnd;\r\n\r\n\thwnd = _InterlockedCompareExchangePointer ((volatile PVOID_PTR)&config.hnotification, NULL, NULL);\r\n\r\n\tif (hwnd)\r\n\t{\r\n\t\tif (ptr_log)\r\n\t\t\t_app_notify_show (hwnd, ptr_log);\r\n\r\n\t\treturn hwnd;\r\n\t}\r\n\r\n\tif (!ptr_log)\r\n\t\treturn NULL;\r\n\r\n\t_r_wnd_createwindow (_r_sys_getimagebase (), MAKEINTRESOURCE (IDD_NOTIFICATION), NULL, &NotificationProc, ptr_log);\r\n\r\n\t_r_sys_waitforsingleobject (config.hnotify_evt, 2000);\r\n\r\n\treturn _InterlockedCompareExchangePointer ((volatile PVOID_PTR)&config.hnotification, NULL, NULL);\r\n}\r\n\r\n_Ret_maybenull_\r\nPNOTIFY_CONTEXT _app_notify_getcontext (\r\n\t_In_ HWND hwnd\r\n)\r\n{\r\n\tPNOTIFY_CONTEXT context;\r\n\r\n\tcontext = _r_wnd_getcontext (hwnd, SHORT_MAX);\r\n\r\n\treturn context;\r\n}\r\n\r\nVOID _app_notify_setcontext (\r\n\t_In_ HWND hwnd,\r\n\t_In_opt_ PNOTIFY_CONTEXT context\r\n)\r\n{\r\n\tif (context)\r\n\t\tcontext->hwnd = hwnd;\r\n\r\n\tif (context)\r\n\t{\r\n\t\t_r_wnd_setcontext (hwnd, SHORT_MAX, context);\r\n\t}\r\n\telse\r\n\t{\r\n\t\t_r_wnd_removecontext (hwnd, SHORT_MAX);\r\n\t}\r\n}\r\n\r\nBOOLEAN _app_notify_command (\r\n\t_In_ HWND hwnd,\r\n\t_In_ INT button_id,\r\n\t_In_opt_ LONG64 seconds\r\n)\r\n{\r\n\tPITEM_APP ptr_app;\r\n\tPR_LIST rules;\r\n\tHANDLE hengine;\r\n\tULONG app_hash;\r\n\r\n\tapp_hash = _app_notify_getapp_id (hwnd);\r\n\tptr_app = _app_getappitem (app_hash);\r\n\r\n\tif (!ptr_app)\r\n\t\treturn FALSE;\r\n\r\n\t_app_notify_freeobject (hwnd, ptr_app);\r\n\r\n\trules = _r_obj_createlist (4, NULL);\r\n\r\n\tif (button_id == IDC_ALLOW_BTN || button_id == IDC_BLOCK_BTN)\r\n\t{\r\n\t\tptr_app->is_enabled = (button_id == IDC_ALLOW_BTN);\r\n\t\tptr_app->is_silent = (button_id == IDC_BLOCK_BTN);\r\n\r\n\t\tif (ptr_app->is_enabled && seconds)\r\n\t\t{\r\n\t\t\t_app_timer_set (_r_app_gethwnd (), ptr_app, seconds);\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\t_app_listview_updateitemby_param (_r_app_gethwnd (), app_hash, TRUE);\r\n\t\t}\r\n\r\n\t\t_r_obj_addlistitem (rules, ptr_app, NULL);\r\n\t}\r\n\telse if (button_id == IDC_NEXT_BTN)\r\n\t{\r\n\t\t// NOTHING!\r\n\t}\r\n\telse if (button_id == IDM_DISABLENOTIFICATIONS)\r\n\t{\r\n\t\tptr_app->is_silent = TRUE;\r\n\t}\r\n\r\n\tptr_app->last_notify = _r_unixtime_now ();\r\n\r\n\tif (rules->count)\r\n\t{\r\n\t\tif (_wfp_isfiltersinstalled ())\r\n\t\t{\r\n\t\t\thengine = _wfp_getenginehandle ();\r\n\r\n\t\t\t_wfp_create3filters (hengine, rules, DBG_ARG, FALSE);\r\n\t\t}\r\n\t}\r\n\r\n\t_app_listview_updateby_id (_r_app_gethwnd (), ptr_app->type, PR_UPDATE_TYPE);\r\n\r\n\t_r_obj_dereference (ptr_app);\r\n\t_r_obj_dereference (rules);\r\n\r\n\t_app_profile_save (hwnd);\r\n\r\n\treturn TRUE;\r\n}\r\n\r\nBOOLEAN _app_notify_addobject (\r\n\t_In_ HWND hwnd,\r\n\t_In_ PITEM_LOG ptr_log,\r\n\t_Inout_ PITEM_APP ptr_app\r\n)\r\n{\r\n\tLONG64 current_time;\r\n\tLONG64 notification_timeout;\r\n\r\n\tcurrent_time = _r_unixtime_now ();\r\n\tnotification_timeout = _r_config_getlong64 (L\"NotificationsTimeout\", NOTIFY_TIMEOUT_DEFAULT, NULL);\r\n\r\n\t// check for last display time\r\n\tif (notification_timeout && ((current_time - ptr_app->last_notify) <= notification_timeout))\r\n\t\treturn FALSE;\r\n\r\n\tptr_app->last_notify = current_time;\r\n\r\n\t_r_obj_swapreference (&ptr_app->notification, ptr_log);\r\n\r\n\tif (_r_wnd_sendmessage (hwnd, 0, WM_NOTIFICATION, 0, (LPARAM)ptr_app->notification))\r\n\t{\r\n\t\tif (_r_config_getboolean (L\"IsNotificationsSound\", TRUE, NULL))\r\n\t\t{\r\n\t\t\tif (!_r_config_getboolean (L\"IsNotificationsFullscreenSilentMode\", TRUE, NULL) || !_r_wnd_isfullscreenmode ())\r\n\t\t\t\t_app_notify_playsound ();\r\n\t\t}\r\n\r\n\t\treturn TRUE;\r\n\t}\r\n\r\n\treturn FALSE;\r\n}\r\n\r\nVOID _app_notify_freeobject (\r\n\t_In_opt_ HWND hwnd,\r\n\t_Inout_ PITEM_APP ptr_app\r\n)\r\n{\r\n\tULONG_PTR app_hash;\r\n\r\n\tif (!hwnd)\r\n\t\thwnd = _app_notify_getwindow (NULL);\r\n\r\n\tif (ptr_app->notification)\r\n\t\t_r_obj_clearreference (&ptr_app->notification);\r\n\r\n\tif (!hwnd)\r\n\t\treturn;\r\n\r\n\tapp_hash = _app_notify_getnextapp_id (hwnd);\r\n\r\n\tif (app_hash)\r\n\t{\r\n\t\t_app_notify_refresh (hwnd);\r\n\t}\r\n\telse\r\n\t{\r\n\t\tDestroyWindow (hwnd);\r\n\t}\r\n}\r\n\r\n_Ret_maybenull_\r\nPITEM_LOG _app_notify_getobject (\r\n\t_In_ ULONG app_hash\r\n)\r\n{\r\n\tPITEM_APP ptr_app;\r\n\tPITEM_LOG ptr_log;\r\n\r\n\tptr_app = _app_getappitem (app_hash);\r\n\r\n\tif (!ptr_app)\r\n\t\treturn NULL;\r\n\r\n\tptr_log = _r_obj_referencesafe (ptr_app->notification);\r\n\r\n\t_r_obj_dereference (ptr_app);\r\n\r\n\treturn ptr_log;\r\n}\r\n\r\n_Ret_maybenull_\r\nHICON _app_notify_getapp_icon (\r\n\t_In_ HWND hwnd\r\n)\r\n{\r\n\tPNOTIFY_CONTEXT context;\r\n\r\n\tcontext = _app_notify_getcontext (hwnd);\r\n\r\n\tif (!context)\r\n\t\treturn NULL;\r\n\r\n\treturn context->hicon;\r\n}\r\n\r\nULONG _app_notify_getapp_id (\r\n\t_In_ HWND hwnd\r\n)\r\n{\r\n\tPNOTIFY_CONTEXT context;\r\n\r\n\tcontext = _app_notify_getcontext (hwnd);\r\n\r\n\tif (!context)\r\n\t\treturn 0;\r\n\r\n\treturn context->app_hash;\r\n}\r\n\r\nULONG _app_notify_getnextapp_id (\r\n\t_In_ HWND hwnd\r\n)\r\n{\r\n\tPNOTIFY_CONTEXT context;\r\n\tPITEM_APP ptr_app = NULL;\r\n\tULONG_PTR enum_key = 0;\r\n\tULONG app_hash = 0;\r\n\r\n\tcontext = _app_notify_getcontext (hwnd);\r\n\r\n\tif (context)\r\n\t\tapp_hash = context->app_hash;\r\n\r\n\t_r_queuedlock_acquireshared (&lock_apps);\r\n\r\n\twhile (_r_obj_enumhashtablepointer (apps_table, (PVOID_PTR)&ptr_app, NULL, &enum_key))\r\n\t{\r\n\t\tif (!ptr_app->notification)\r\n\t\t\tcontinue;\r\n\r\n\t\t// exclude current app from enumeration\r\n\t\tif (ptr_app->app_hash == app_hash)\r\n\t\t\tcontinue;\r\n\r\n\t\tapp_hash = ptr_app->app_hash;\r\n\t\tbreak;\r\n\t}\r\n\r\n\t_r_queuedlock_releaseshared (&lock_apps);\r\n\r\n\tif (context)\r\n\t\tcontext->app_hash = app_hash;\r\n\r\n\treturn app_hash;\r\n}\r\n\r\nVOID _app_notify_setapp_icon (\r\n\t_In_ HWND hwnd,\r\n\t_In_opt_ HICON hicon\r\n)\r\n{\r\n\tPNOTIFY_CONTEXT context;\r\n\tHICON hicon_prev;\r\n\r\n\tcontext = _app_notify_getcontext (hwnd);\r\n\r\n\tif (!context)\r\n\t\treturn;\r\n\r\n\tif (!hicon)\r\n\t\thicon = _app_icons_getdefaultapp_hicon ();\r\n\r\n\thicon_prev = context->hicon;\r\n\tcontext->hicon = hicon;\r\n\r\n\tRedrawWindow (hwnd, NULL, NULL, RDW_ALLCHILDREN | RDW_ERASE | RDW_INVALIDATE);\r\n\r\n\tif (hicon_prev)\r\n\t\tDestroyIcon (hicon_prev);\r\n}\r\n\r\nVOID _app_notify_setapp_id (\r\n\t_In_ HWND hwnd,\r\n\t_In_opt_ ULONG app_hash\r\n)\r\n{\r\n\tPNOTIFY_CONTEXT context;\r\n\r\n\tcontext = _app_notify_getcontext (hwnd);\r\n\r\n\tif (!context)\r\n\t\treturn;\r\n\r\n\tcontext->app_hash = app_hash;\r\n}\r\n\r\nVOID _app_notify_show (\r\n\t_In_ HWND hwnd,\r\n\t_In_ PITEM_LOG ptr_log\r\n)\r\n{\r\n\tPR_STRING localized_string = NULL;\r\n\tPR_STRING string = NULL;\r\n\tPR_STRING loading;\r\n\tPR_STRING empty;\r\n\tWCHAR window_title[128];\r\n\tPITEM_APP ptr_app;\r\n\tHDWP hdefer;\r\n\tBOOLEAN is_fullscreenmode;\r\n\r\n\tptr_app = _app_getappitem (ptr_log->app_hash);\r\n\r\n\tif (!ptr_app)\r\n\t{\r\n\t\tDestroyWindow (hwnd);\r\n\r\n\t\treturn;\r\n\t}\r\n\r\n\t// set notification information\r\n\t_app_notify_setapp_id (hwnd, ptr_log->app_hash);\r\n\t_app_notify_setapp_icon (hwnd, NULL);\r\n\r\n\t// set window title\r\n\t_r_str_printf (window_title, RTL_NUMBER_OF (window_title), L\"%s - %s\", _r_locale_getstring (IDS_NOTIFY_TITLE), _r_app_getname ());\r\n\r\n\t_r_ctrl_setstring (hwnd, 0, window_title);\r\n\r\n\thdefer = BeginDeferWindowPos (2);\r\n\r\n\tempty = _r_locale_getstring_ex (IDS_STATUS_EMPTY);\r\n\r\n\tif (_r_obj_isstringempty (empty))\r\n\t\t_r_obj_movereference ((PVOID_PTR)&empty, _r_obj_createstring (L\"Empty...\"));\r\n\r\n\t// print name\r\n\t_r_obj_movereference ((PVOID_PTR)&localized_string, _r_obj_concatstrings (2, _r_locale_getstring (IDS_NAME), L\":\"));\r\n\t_r_obj_movereference ((PVOID_PTR)&string, _app_getappdisplayname (ptr_app, TRUE));\r\n\r\n\t_r_ctrl_settablestring (hwnd, &hdefer, IDC_FILE_ID, &localized_string->sr, IDC_FILE_TEXT, string ? &string->sr : &empty->sr);\r\n\r\n\tloading = _r_locale_getstring_ex (IDS_LOADING);\r\n\r\n\tif (_r_obj_isstringempty (loading))\r\n\t\t_r_obj_movereference ((PVOID_PTR)&loading, _r_obj_createstring (L\"Loading...\"));\r\n\r\n\t// print signature\r\n\t_r_obj_movereference ((PVOID_PTR)&localized_string, _r_obj_concatstrings (2, _r_locale_getstring (IDS_SIGNATURE), L\":\"));\r\n\t_r_ctrl_settablestring (hwnd, &hdefer, IDC_SIGNATURE_ID, &localized_string->sr, IDC_SIGNATURE_TEXT, &loading->sr);\r\n\r\n\t// print address\r\n\t_r_obj_movereference ((PVOID_PTR)&localized_string, _r_obj_concatstrings (2, _r_locale_getstring (IDS_ADDRESS), L\":\"));\r\n\t_r_ctrl_settablestring (hwnd, &hdefer, IDC_ADDRESS_ID, &localized_string->sr, IDC_ADDRESS_TEXT, &loading->sr);\r\n\r\n\t// print host\r\n\t_r_obj_movereference ((PVOID_PTR)&localized_string, _r_obj_concatstrings (2, _r_locale_getstring (IDS_HOST), L\":\"));\r\n\t_r_ctrl_settablestring (hwnd, &hdefer, IDC_HOST_ID, &localized_string->sr, IDC_HOST_TEXT, &loading->sr);\r\n\r\n\t// print port\r\n\t_r_obj_movereference ((PVOID_PTR)&localized_string, _r_obj_concatstrings (2, _r_locale_getstring (IDS_PORT), L\":\"));\r\n\t_r_obj_movereference ((PVOID_PTR)&string, _app_formatport (ptr_log->remote_port, ptr_log->protocol));\r\n\r\n\t_r_ctrl_settablestring (hwnd, &hdefer, IDC_PORT_ID, &localized_string->sr, IDC_PORT_TEXT, string ? &string->sr : &empty->sr);\r\n\r\n\t// print direction\r\n\t_r_obj_movereference ((PVOID_PTR)&localized_string, _r_obj_concatstrings (2, _r_locale_getstring (IDS_DIRECTION), L\":\"));\r\n\t_r_obj_movereference ((PVOID_PTR)&string, _app_db_getdirectionname (ptr_log->direction, ptr_log->is_loopback, TRUE));\r\n\r\n\t_r_ctrl_settablestring (hwnd, &hdefer, IDC_DIRECTION_ID, &localized_string->sr, IDC_DIRECTION_TEXT, string ? &string->sr : &empty->sr);\r\n\r\n\t// print filter name\r\n\t_r_obj_movereference ((PVOID_PTR)&localized_string, _r_obj_concatstrings (2, _r_locale_getstring (IDS_FILTER), L\":\"));\r\n\t_r_ctrl_settablestring (hwnd, &hdefer, IDC_FILTER_ID, &localized_string->sr, IDC_FILTER_TEXT, ptr_log->filter_name ? &ptr_log->filter_name->sr : &empty->sr);\r\n\r\n\t// print date\r\n\t_r_obj_movereference ((PVOID_PTR)&localized_string, _r_obj_concatstrings (2, _r_locale_getstring (IDS_DATE), L\":\"));\r\n\t_r_obj_movereference ((PVOID_PTR)&string, _r_format_unixtime (ptr_log->timestamp, FDTF_SHORTDATE | FDTF_LONGTIME));\r\n\r\n\t_r_ctrl_settablestring (hwnd, &hdefer, IDC_DATE_ID, &localized_string->sr, IDC_DATE_TEXT, string ? &string->sr : &empty->sr);\r\n\r\n\tif (hdefer)\r\n\t\tEndDeferWindowPos (hdefer);\r\n\r\n\t//_r_ctrl_setstring (hwnd, IDC_RULES_BTN, _r_locale_getstring (IDS_TRAY_RULES));\r\n\t_r_ctrl_setstring (hwnd, IDC_ALLOW_BTN, _r_locale_getstring (IDS_ACTION_ALLOW));\r\n\t_r_ctrl_setstring (hwnd, IDC_BLOCK_BTN, _r_locale_getstring (IDS_ACTION_BLOCK));\r\n\r\n\t// prevent fullscreen apps lose focus\r\n\tis_fullscreenmode = _r_wnd_isfullscreenmode ();\r\n\r\n\tif (!is_fullscreenmode)\r\n\t\t_r_wnd_top (hwnd, TRUE);\r\n\r\n\t// set safety timeout\r\n\t_app_notify_settimeout (hwnd);\r\n\r\n\t// set correct position\r\n\t_app_notify_setposition (hwnd, FALSE);\r\n\r\n\tShowWindow (hwnd, SW_SHOWNOACTIVATE);\r\n\r\n\tInvalidateRect (hwnd, NULL, TRUE);\r\n\r\n\t// query busy information\r\n\t_app_notify_queueinfo (hwnd, ptr_log);\r\n\r\n\tif (string)\r\n\t\t_r_obj_dereference (string);\r\n\r\n\t_r_obj_dereference (loading);\r\n\t_r_obj_dereference (empty);\r\n\r\n\t_r_obj_dereference (ptr_app);\r\n}\r\n\r\n// Play notification sound even if system have \"nosound\" mode\r\nVOID _app_notify_playsound ()\r\n{\r\n\tstatic volatile PR_STRING cached_path = NULL;\r\n\r\n\tPR_STRING current_path;\r\n\tPR_STRING path;\r\n\tHANDLE hkey;\r\n\tULONG flags = SND_ASYNC | SND_NODEFAULT | SND_NOWAIT | SND_SENTRY;\r\n\tNTSTATUS status;\r\n\r\n\tcurrent_path = _InterlockedCompareExchangePointer ((volatile PVOID_PTR)&cached_path, NULL, NULL);\r\n\r\n\tif (_r_obj_isstringempty (current_path) || !_r_fs_isexists (&current_path->sr))\r\n\t{\r\n\t\tstatus = _r_reg_openkey (HKEY_CURRENT_USER, L\"AppEvents\\\\Schemes\\\\Apps\\\\.Default\\\\\" NOTIFY_SOUND_NAME L\"\\\\.Default\", 0, KEY_READ, &hkey);\r\n\r\n\t\tif (NT_SUCCESS (status))\r\n\t\t{\r\n\t\t\tstatus = _r_reg_querystring (hkey, NULL, &path, NULL);\r\n\r\n\t\t\tif (NT_SUCCESS (status))\r\n\t\t\t{\r\n\t\t\t\tcurrent_path = _InterlockedCompareExchangePointer ((volatile PVOID_PTR)&cached_path, path, current_path);\r\n\r\n\t\t\t\tif (current_path)\r\n\t\t\t\t\t_r_obj_dereference (path);\r\n\t\t\t}\r\n\r\n\t\t\tNtClose (hkey);\r\n\t\t}\r\n\t}\r\n\r\n\tif (_r_obj_isstringempty (current_path) || !_r_fs_isexists (&current_path->sr) || !PlaySoundW (current_path->buffer, NULL, flags | SND_FILENAME))\r\n\t\tPlaySoundW (NOTIFY_SOUND_NAME, NULL, flags);\r\n}\r\n\r\nVOID _app_notify_queueinfo (\r\n\t_In_ HWND hwnd,\r\n\t_In_ PITEM_LOG ptr_log\r\n)\r\n{\r\n\tPITEM_CONTEXT context;\r\n\r\n\tcontext = _r_freelist_allocateitem (&context_free_list);\r\n\r\n\tcontext->hwnd = hwnd;\r\n\tcontext->base_address = _r_obj_reference (ptr_log);\r\n\r\n\t_r_workqueue_queueitem (&resolve_notify_queue, &_app_queue_notifyinformation, context);\r\n}\r\n\r\nVOID _app_notify_killprocess (\r\n\t_In_ HWND hwnd\r\n)\r\n{\r\n\tPSYSTEM_PROCESS_INFORMATION process;\r\n\tPSYSTEM_PROCESS_INFORMATION spi;\r\n\tPNOTIFY_CONTEXT context;\r\n\tHANDLE process_handle;\r\n\tPITEM_APP ptr_app;\r\n\tPR_STRING path;\r\n\tPR_STRING file_name;\r\n\tNTSTATUS status;\r\n\r\n\tcontext = _app_notify_getcontext (hwnd);\r\n\r\n\tif (!context)\r\n\t\treturn;\r\n\r\n\tptr_app = _app_getappitem (context->app_hash);\r\n\r\n\tif (!ptr_app)\r\n\t\treturn;\r\n\r\n\tstatus = _r_sys_enumprocesses (&spi);\r\n\r\n\tif (!NT_SUCCESS (status))\r\n\t{\r\n\t\t_r_show_errormessage (hwnd, L\"Cannot enumerate processes!\", status, NULL, ET_NATIVE);\r\n\r\n\t\t_r_log (LOG_LEVEL_ERROR, NULL, L\"_r_sys_enumprocesses\", status, NULL);\r\n\r\n\t\treturn;\r\n\t}\r\n\r\n\tfile_name = _r_path_getbasenamestring (&ptr_app->real_path->sr);\r\n\r\n\tprocess = PR_FIRST_PROCESS (spi);\r\n\r\n\tdo\r\n\t{\r\n\t\tif (!process->ImageName.Buffer)\r\n\t\t\tcontinue;\r\n\r\n\t\tif (_r_str_compare (process->ImageName.Buffer, file_name->buffer, TRUE) == 0)\r\n\t\t{\r\n\t\t\tstatus = _r_sys_getprocessimagepathbyid (HandleToULong (process->UniqueProcessId), TRUE, &path);\r\n\r\n\t\t\tif (NT_SUCCESS (status))\r\n\t\t\t{\r\n\t\t\t\tif (_r_str_isequal (&path->sr, &ptr_app->real_path->sr, TRUE))\r\n\t\t\t\t{\r\n\t\t\t\t\tstatus = _r_sys_openprocess (HandleToULong (process->UniqueProcessId), PROCESS_TERMINATE, &process_handle);\r\n\r\n\t\t\t\t\tif (NT_SUCCESS (status))\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tstatus = NtTerminateProcess (process_handle, STATUS_SUCCESS);\r\n\r\n\t\t\t\t\t\tif (!NT_SUCCESS (status))\r\n\t\t\t\t\t\t\t_r_show_errormessage (hwnd, L\"Cannot terminate process!\", status, file_name->buffer, ET_NATIVE);\r\n\r\n\t\t\t\t\t\tNtClose (process_handle);\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t_r_show_errormessage (hwnd, L\"Cannot open process!\", status, file_name->buffer, ET_NATIVE);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\t_r_obj_dereference (path);\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\t_r_show_errormessage (hwnd, L\"Cannot get process path!\", status, file_name->buffer, ET_NATIVE);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\twhile ((process = PR_NEXT_PROCESS (process)));\r\n\r\n\t_r_obj_dereference (file_name);\r\n\r\n\t_r_mem_free (spi);\r\n}\r\n\r\nVOID _app_notify_refresh (\r\n\t_In_ HWND hwnd\r\n)\r\n{\r\n\tPITEM_LOG ptr_log;\r\n\tULONG app_hash;\r\n\r\n\tif (!_r_wnd_isvisible (hwnd, TRUE))\r\n\t{\r\n\t\tDestroyWindow (hwnd);\r\n\r\n\t\treturn;\r\n\t}\r\n\r\n\tif (!_r_config_getboolean (L\"IsNotificationsEnabled\", TRUE, NULL))\r\n\t{\r\n\t\tDestroyWindow (hwnd);\r\n\r\n\t\treturn;\r\n\t}\r\n\r\n\tapp_hash = _app_notify_getapp_id (hwnd);\r\n\tptr_log = _app_notify_getobject (app_hash);\r\n\r\n\tif (!ptr_log)\r\n\t{\r\n\t\tDestroyWindow (hwnd);\r\n\r\n\t\treturn;\r\n\t}\r\n\r\n\t_app_notify_show (hwnd, ptr_log);\r\n\r\n\t_r_obj_dereference (ptr_log);\r\n}\r\n\r\nVOID _app_notify_setposition (\r\n\t_In_ HWND hwnd,\r\n\t_In_ BOOLEAN is_forced\r\n)\r\n{\r\n\tMONITORINFO monitor_info = {0};\r\n\tAPPBARDATA taskbar_rect = {0};\r\n\tR_RECTANGLE window_rect;\r\n\tHMONITOR hmonitor;\r\n\tPRECT rect;\r\n\tLONG dpi_value;\r\n\tLONG border_x;\r\n\tBOOLEAN is_intray;\r\n\r\n\t_r_wnd_getposition (hwnd, &window_rect);\r\n\r\n\tif (!is_forced && _r_wnd_isvisible (hwnd, FALSE))\r\n\t{\r\n\t\t_r_wnd_adjustrectangletoworkingarea (hwnd, &window_rect);\r\n\t\t_r_wnd_setposition (hwnd, &window_rect.position, NULL);\r\n\r\n\t\treturn;\r\n\t}\r\n\r\n\tis_intray = _r_config_getboolean (L\"IsNotificationsOnTray\", FALSE, NULL);\r\n\r\n\tif (is_intray)\r\n\t{\r\n\t\tmonitor_info.cbSize = sizeof (MONITORINFO);\r\n\r\n\t\thmonitor = MonitorFromWindow (hwnd, MONITOR_DEFAULTTONEAREST);\r\n\r\n\t\tif (GetMonitorInfoW (hmonitor, &monitor_info))\r\n\t\t{\r\n\t\t\ttaskbar_rect.cbSize = sizeof (APPBARDATA);\r\n\r\n\t\t\tif (SHAppBarMessage (ABM_GETTASKBARPOS, &taskbar_rect))\r\n\t\t\t{\r\n\t\t\t\tdpi_value = _r_dc_getwindowdpi (hwnd);\r\n\r\n\t\t\t\tborder_x = _r_dc_getsystemmetrics (SM_CXBORDER, dpi_value);\r\n\t\t\t\trect = &monitor_info.rcWork;\r\n\r\n\t\t\t\tif (taskbar_rect.uEdge == ABE_LEFT)\r\n\t\t\t\t{\r\n\t\t\t\t\twindow_rect.left = taskbar_rect.rc.right + border_x;\r\n\t\t\t\t\twindow_rect.top = (rect->bottom - window_rect.height) - border_x;\r\n\t\t\t\t}\r\n\t\t\t\telse if (taskbar_rect.uEdge == ABE_TOP)\r\n\t\t\t\t{\r\n\t\t\t\t\twindow_rect.left = (rect->right - window_rect.width) - border_x;\r\n\t\t\t\t\twindow_rect.top = taskbar_rect.rc.bottom + border_x;\r\n\t\t\t\t}\r\n\t\t\t\telse if (taskbar_rect.uEdge == ABE_RIGHT)\r\n\t\t\t\t{\r\n\t\t\t\t\twindow_rect.left = (rect->right - window_rect.width) - border_x;\r\n\t\t\t\t\twindow_rect.top = (rect->bottom - window_rect.height) - border_x;\r\n\t\t\t\t}\r\n\t\t\t\telse //if (taskbar_rect.uEdge == ABE_BOTTOM)\r\n\t\t\t\t{\r\n\t\t\t\t\twindow_rect.left = (rect->right - window_rect.width) - border_x;\r\n\t\t\t\t\twindow_rect.top = (rect->bottom - window_rect.height) - border_x;\r\n\t\t\t\t}\r\n\r\n\t\t\t\t_r_wnd_adjustrectangletoworkingarea (NULL, &window_rect);\r\n\t\t\t\t_r_wnd_setposition (hwnd, &window_rect.position, NULL);\r\n\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t// display window on center (depends on error, config etc...)\r\n\t_r_wnd_center (hwnd, NULL);\r\n\r\n\t_r_window_restoreposition (hwnd, L\"notification\");\r\n}\r\n\r\nVOID _app_notify_settimeout (\r\n\t_In_ HWND hwnd\r\n)\r\n{\r\n\t_r_ctrl_enable (hwnd, IDC_RULES_BTN, FALSE);\r\n\t_r_ctrl_enable (hwnd, IDC_KILLPROCESS_BTN, FALSE);\r\n\t_r_ctrl_enable (hwnd, IDC_ALLOW_BTN, FALSE);\r\n\t_r_ctrl_enable (hwnd, IDC_BLOCK_BTN, FALSE);\r\n\t_r_ctrl_enable (hwnd, IDC_NEXT_BTN, FALSE);\r\n\r\n\tSetTimer (hwnd, NOTIFY_TIMER_SAFETY_ID, NOTIFY_TIMER_SAFETY_TIMEOUT, NULL);\r\n}\r\n\r\nVOID _app_notify_initialize (\r\n\t_Inout_ PNOTIFY_CONTEXT context,\r\n\t_In_ LONG dpi_value\r\n)\r\n{\r\n\tNONCLIENTMETRICS ncm = {0};\r\n\tHBITMAP hbmp_allow;\r\n\tHBITMAP hbmp_block;\r\n\tHBITMAP hbmp_cross;\r\n\tHBITMAP hbmp_next;\r\n\tHBITMAP hbmp_rules;\r\n\tLONG icon_small;\r\n\tLONG icon_large;\r\n\r\n\t// destroy previous resources\r\n\tSAFE_DELETE_OBJECT (context->hfont_title);\r\n\tSAFE_DELETE_OBJECT (context->hfont_link);\r\n\tSAFE_DELETE_OBJECT (context->hfont_text);\r\n\r\n\tSAFE_DELETE_ICON (context->hico_allow);\r\n\tSAFE_DELETE_ICON (context->hico_block);\r\n\tSAFE_DELETE_ICON (context->hico_cross);\r\n\tSAFE_DELETE_ICON (context->hico_next);\r\n\tSAFE_DELETE_ICON (context->hico_rules);\r\n\r\n\ticon_small = _r_dc_getsystemmetrics (SM_CXSMICON, dpi_value);\r\n\ticon_large = _r_dc_getsystemmetrics (SM_CXICON, dpi_value);\r\n\r\n\t// set window icon\r\n\t_r_wnd_seticon (\r\n\t\tcontext->hwnd,\r\n\t\t_r_sys_loadsharedicon (NULL, MAKEINTRESOURCE (SIH_EXCLAMATION), icon_small),\r\n\t\t_r_sys_loadsharedicon (NULL, MAKEINTRESOURCE (SIH_EXCLAMATION), icon_large)\r\n\t);\r\n\r\n\t// set window font\r\n\tncm.cbSize = sizeof (ncm);\r\n\r\n\tif (_r_dc_getsystemparametersinfo (SPI_GETNONCLIENTMETRICS, ncm.cbSize, &ncm, dpi_value))\r\n\t{\r\n\t\tcontext->hfont_title = _app_createfont (&ncm.lfCaptionFont, 12, FALSE, dpi_value);\r\n\t\tcontext->hfont_link = _app_createfont (&ncm.lfMessageFont, 9, TRUE, dpi_value);\r\n\t\tcontext->hfont_text = _app_createfont (&ncm.lfMessageFont, 9, FALSE, dpi_value);\r\n\r\n\t\t_r_ctrl_setfont (context->hwnd, 0, context->hfont_text);\r\n\r\n\t\t_r_ctrl_setfont (context->hwnd, IDC_HEADER_ID, context->hfont_title);\r\n\t\t_r_ctrl_setfont (context->hwnd, IDC_FILE_TEXT, context->hfont_link);\r\n\r\n\t\tfor (INT i = IDC_SIGNATURE_TEXT; i <= IDC_DATE_TEXT; i++)\r\n\t\t\t_r_ctrl_settextmargin (context->hwnd, i, 0, 0);\r\n\r\n\t\tfor (INT i = IDC_SIGNATURE_TEXT; i <= IDC_NEXT_BTN; i++)\r\n\t\t\t_r_ctrl_setfont (context->hwnd, i, context->hfont_text);\r\n\t}\r\n\r\n\t// load images\r\n\t_r_res_loadimage (_r_sys_getimagebase (), L\"PNG\", MAKEINTRESOURCE (IDP_SETTINGS), &GUID_ContainerFormatPng, icon_small, icon_small, &hbmp_rules);\r\n\t_r_res_loadimage (_r_sys_getimagebase (), L\"PNG\", MAKEINTRESOURCE (IDP_ALLOW), &GUID_ContainerFormatPng, icon_small, icon_small, &hbmp_allow);\r\n\t_r_res_loadimage (_r_sys_getimagebase (), L\"PNG\", MAKEINTRESOURCE (IDP_BLOCK), &GUID_ContainerFormatPng, icon_small, icon_small, &hbmp_block);\r\n\t_r_res_loadimage (_r_sys_getimagebase (), L\"PNG\", MAKEINTRESOURCE (IDP_CROSS), &GUID_ContainerFormatPng, icon_small, icon_small, &hbmp_cross);\r\n\t_r_res_loadimage (_r_sys_getimagebase (), L\"PNG\", MAKEINTRESOURCE (IDP_NEXT), &GUID_ContainerFormatPng, icon_small, icon_small, &hbmp_next);\r\n\r\n\t// set button configuration\r\n\tif (hbmp_rules)\r\n\t{\r\n\t\tcontext->hico_rules = _r_dc_bitmaptoicon (hbmp_rules, icon_small, icon_small);\r\n\r\n\t\tDeleteObject (hbmp_rules);\r\n\t}\r\n\r\n\tif (hbmp_cross)\r\n\t{\r\n\t\tcontext->hico_cross = _r_dc_bitmaptoicon (hbmp_cross, icon_small, icon_small);\r\n\r\n\t\tDeleteObject (hbmp_cross);\r\n\t}\r\n\r\n\tif (hbmp_allow)\r\n\t{\r\n\t\tcontext->hico_allow = _r_dc_bitmaptoicon (hbmp_allow, icon_small, icon_small);\r\n\r\n\t\tDeleteObject (hbmp_allow);\r\n\t}\r\n\r\n\tif (hbmp_block)\r\n\t{\r\n\t\tcontext->hico_block = _r_dc_bitmaptoicon (hbmp_block, icon_small, icon_small);\r\n\r\n\t\tDeleteObject (hbmp_block);\r\n\t}\r\n\r\n\tif (hbmp_next)\r\n\t{\r\n\t\tcontext->hico_next = _r_dc_bitmaptoicon (hbmp_next, icon_small, icon_small);\r\n\r\n\t\tDeleteObject (hbmp_next);\r\n\t}\r\n\r\n\t_r_ctrl_seticon (context->hwnd, IDC_RULES_BTN, context->hico_rules);\r\n\t_r_ctrl_seticon (context->hwnd, IDC_KILLPROCESS_BTN, context->hico_cross);\r\n\t_r_ctrl_seticon (context->hwnd, IDC_ALLOW_BTN, context->hico_allow);\r\n\t_r_ctrl_seticon (context->hwnd, IDC_BLOCK_BTN, context->hico_block);\r\n\t_r_ctrl_seticon (context->hwnd, IDC_NEXT_BTN, context->hico_next);\r\n\r\n\t_r_ctrl_setbuttonmargins (context->hwnd, IDC_RULES_BTN, dpi_value);\r\n\t_r_ctrl_setbuttonmargins (context->hwnd, IDC_KILLPROCESS_BTN, dpi_value);\r\n\t_r_ctrl_setbuttonmargins (context->hwnd, IDC_ALLOW_BTN, dpi_value);\r\n\t_r_ctrl_setbuttonmargins (context->hwnd, IDC_BLOCK_BTN, dpi_value);\r\n\t_r_ctrl_setbuttonmargins (context->hwnd, IDC_NEXT_BTN, dpi_value);\r\n}\r\n\r\nVOID _app_notify_destroy (\r\n\t_In_ HWND hwnd\r\n)\r\n{\r\n\tPNOTIFY_CONTEXT context;\r\n\r\n\tcontext = _app_notify_getcontext (hwnd);\r\n\r\n\tif (!context)\r\n\t\treturn;\r\n\r\n\t_app_notify_setcontext (hwnd, NULL);\r\n\r\n\tSAFE_DELETE_ICON (context->hicon);\r\n\r\n\tSAFE_DELETE_OBJECT (context->hfont_title);\r\n\tSAFE_DELETE_OBJECT (context->hfont_link);\r\n\tSAFE_DELETE_OBJECT (context->hfont_text);\r\n\r\n\tSAFE_DELETE_ICON (context->hico_allow);\r\n\tSAFE_DELETE_ICON (context->hico_block);\r\n\tSAFE_DELETE_ICON (context->hico_cross);\r\n\tSAFE_DELETE_ICON (context->hico_rules);\r\n\r\n\t_r_mem_free (context);\r\n}\r\n\r\nVOID _app_notify_drawgradient (\r\n\t_In_ HDC hdc,\r\n\t_In_ LPCRECT rect\r\n)\r\n{\r\n\tCOLORREF gradient_arr[] = {\r\n\t\tRGB (0, 68, 112),\r\n\t\tRGB (7, 111, 95),\r\n\t};\r\n\tGRADIENT_RECT gradient_rect = {0};\r\n\tTRIVERTEX trivertx[2] = {0};\r\n\r\n\tC_ASSERT (RTL_NUMBER_OF (gradient_arr) == RTL_NUMBER_OF (trivertx));\r\n\r\n\tgradient_rect.LowerRight = 1;\r\n\t//gradient_rect.UpperLeft = 0;\r\n\r\n\tfor (ULONG_PTR i = 0; i < RTL_NUMBER_OF (trivertx); i++)\r\n\t{\r\n\t\ttrivertx[i].Red = GetRValue (gradient_arr[i]) << 8;\r\n\t\ttrivertx[i].Green = GetGValue (gradient_arr[i]) << 8;\r\n\t\ttrivertx[i].Blue = GetBValue (gradient_arr[i]) << 8;\r\n\r\n\t\tif (i == 0)\r\n\t\t{\r\n\t\t\ttrivertx[i].x = -1;\r\n\t\t\ttrivertx[i].y = -1;\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\ttrivertx[i].x = rect->right;\r\n\t\t\ttrivertx[i].y = rect->bottom;\r\n\t\t}\r\n\t}\r\n\r\n\tGradientFill (hdc, trivertx, RTL_NUMBER_OF (trivertx), &gradient_rect, 1, GRADIENT_FILL_RECT_H);\r\n}\r\n\r\nINT_PTR CALLBACK NotificationProc (\r\n\t_In_ HWND hwnd,\r\n\t_In_ UINT msg,\r\n\t_In_ WPARAM wparam,\r\n\t_In_ LPARAM lparam\r\n)\r\n{\r\n\tswitch (msg)\r\n\t{\r\n\t\tcase WM_INITDIALOG:\r\n\t\t{\r\n\t\t\tPNOTIFY_CONTEXT context;\r\n\t\t\tPITEM_LOG ptr_log;\r\n\t\t\tHWND current_hwnd;\r\n\t\t\tHWND htip;\r\n\t\t\tLONG dpi_value;\r\n\r\n\t\t\tcurrent_hwnd = _InterlockedCompareExchangePointer ((volatile PVOID_PTR)&config.hnotification, hwnd, config.hnotification);\r\n\r\n\t\t\tif (current_hwnd)\r\n\t\t\t\tDestroyWindow (current_hwnd);\r\n\r\n\t\t\t// initialize window context\r\n\t\t\tcontext = _r_mem_allocate (sizeof (NOTIFY_CONTEXT));\r\n\r\n\t\t\t_app_notify_setcontext (hwnd, context);\r\n\r\n\t\t\t// set correct position\r\n\t\t\t_app_notify_setposition (hwnd, FALSE);\r\n\r\n\t\t\tdpi_value = _r_dc_getwindowdpi (hwnd);\r\n\r\n\t\t\t_app_notify_initialize (context, dpi_value);\r\n\r\n\t\t\t// initialize tips\r\n\t\t\thtip = _r_ctrl_createtip (hwnd);\r\n\r\n\t\t\tif (htip)\r\n\t\t\t{\r\n\t\t\t\t_r_ctrl_settiptext (htip, hwnd, IDC_FILE_TEXT, LPSTR_TEXTCALLBACK);\r\n\t\t\t\t_r_ctrl_settiptext (htip, hwnd, IDC_RULES_BTN, LPSTR_TEXTCALLBACK);\r\n\t\t\t\t_r_ctrl_settiptext (htip, hwnd, IDC_KILLPROCESS_BTN, LPSTR_TEXTCALLBACK);\r\n\t\t\t\t_r_ctrl_settiptext (htip, hwnd, IDC_ALLOW_BTN, LPSTR_TEXTCALLBACK);\r\n\t\t\t\t_r_ctrl_settiptext (htip, hwnd, IDC_BLOCK_BTN, LPSTR_TEXTCALLBACK);\r\n\t\t\t\t_r_ctrl_settiptext (htip, hwnd, IDC_NEXT_BTN, L\"NEXT!\");\r\n\t\t\t}\r\n\r\n\t\t\t// display log information\r\n\t\t\tptr_log = (PITEM_LOG)lparam;\r\n\r\n\t\t\t_app_notify_show (hwnd, ptr_log);\r\n\r\n\t\t\tNtSetEvent (config.hnotify_evt, NULL);\r\n\r\n\t\t\t_r_obj_dereference (ptr_log);\r\n\r\n\t\t\t_r_theme_initialize (hwnd);\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase WM_CLOSE:\r\n\t\t{\r\n\t\t\tDestroyWindow (hwnd);\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase WM_DESTROY:\r\n\t\t{\r\n\t\t\t_r_window_saveposition (hwnd, L\"notification\");\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase WM_NCDESTROY:\r\n\t\t{\r\n\t\t\t_InterlockedCompareExchangePointer ((volatile PVOID_PTR)&config.hnotification, NULL, config.hnotification);\r\n\r\n\t\t\t_app_notify_destroy (hwnd);\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase WM_TIMER:\r\n\t\t{\r\n\t\t\tKillTimer (hwnd, wparam);\r\n\r\n\t\t\tif (wparam != NOTIFY_TIMER_SAFETY_ID)\r\n\t\t\t\tbreak;\r\n\r\n\t\t\t_r_ctrl_enable (hwnd, IDC_RULES_BTN, TRUE);\r\n\t\t\t_r_ctrl_enable (hwnd, IDC_KILLPROCESS_BTN, TRUE);\r\n\t\t\t_r_ctrl_enable (hwnd, IDC_ALLOW_BTN, TRUE);\r\n\t\t\t_r_ctrl_enable (hwnd, IDC_BLOCK_BTN, TRUE);\r\n\t\t\t_r_ctrl_enable (hwnd, IDC_NEXT_BTN, TRUE);\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase WM_DPICHANGED:\r\n\t\t{\r\n\t\t\tPNOTIFY_CONTEXT context;\r\n\r\n\t\t\tcontext = _app_notify_getcontext (hwnd);\r\n\r\n\t\t\t_r_wnd_message_dpichanged (hwnd, wparam, lparam);\r\n\r\n\t\t\tif (context)\r\n\t\t\t\t_app_notify_initialize (context, LOWORD (wparam));\r\n\r\n\t\t\t_app_notify_refresh (hwnd);\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase WM_SETTINGCHANGE:\r\n\t\t{\r\n\t\t\t_r_wnd_message_settingchange (hwnd, wparam, lparam);\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase WM_PAINT:\r\n\t\t{\r\n\t\t\tPAINTSTRUCT ps;\r\n\t\t\tHDC hdc;\r\n\r\n\t\t\thdc = BeginPaint (hwnd, &ps);\r\n\r\n\t\t\tif (!hdc)\r\n\t\t\t\tbreak;\r\n\r\n\t\t\t_r_dc_drawwindow (hdc, hwnd, TRUE);\r\n\r\n\t\t\tEndPaint (hwnd, &ps);\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase WM_CTLCOLORDLG:\r\n\t\tcase WM_CTLCOLORSTATIC:\r\n\t\t{\r\n\t\t\tHDC hdc;\r\n\t\t\tINT text_clr;\r\n\r\n\t\t\thdc = (HDC)wparam;\r\n\r\n\t\t\tif (msg == WM_CTLCOLORSTATIC && (GetDlgCtrlID ((HWND)lparam) == IDC_FILE_TEXT))\r\n\t\t\t{\r\n\t\t\t\ttext_clr = COLOR_HIGHLIGHT;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\ttext_clr = COLOR_WINDOWTEXT;\r\n\t\t\t}\r\n\r\n\t\t\tSetBkMode (hdc, TRANSPARENT); // HACK!!!\r\n\r\n\t\t\tSetTextColor (hdc, GetSysColor (text_clr));\r\n\t\t\tSetDCBrushColor (hdc, GetSysColor (COLOR_WINDOW));\r\n\r\n\t\t\treturn (INT_PTR)GetStockObject (DC_BRUSH);\r\n\t\t}\r\n\r\n\t\tcase WM_DRAWITEM:\r\n\t\t{\r\n\t\t\tLPDRAWITEMSTRUCT draw_info;\r\n\t\t\tRECT rect;\r\n\t\t\tLONG dpi_value;\r\n\t\t\tLONG icon_size_x;\r\n\t\t\tLONG wnd_spacing;\r\n\t\t\tPR_STRING string;\r\n\t\t\tHICON hicon;\r\n\r\n\t\t\tdraw_info = (LPDRAWITEMSTRUCT)lparam;\r\n\r\n\t\t\tif (draw_info->CtlID != IDC_HEADER_ID)\r\n\t\t\t\tbreak;\r\n\r\n\t\t\tdpi_value = _r_dc_getwindowdpi (hwnd);\r\n\r\n\t\t\ticon_size_x = _r_dc_getsystemmetrics (SM_CXICON, dpi_value);\r\n\t\t\twnd_spacing = _r_dc_getdpi (12, dpi_value);\r\n\r\n\t\t\tSetBkMode (draw_info->hDC, TRANSPARENT); // HACK!!!\r\n\r\n\t\t\t// draw title gradient\r\n\t\t\t_app_notify_drawgradient (draw_info->hDC, &draw_info->rcItem);\r\n\r\n\t\t\t// draw title text\r\n\t\t\tstring = _r_locale_getstring_ex (IDS_NOTIFY_HEADER);\r\n\r\n\t\t\tif (string)\r\n\t\t\t{\r\n\t\t\t\tSetTextColor (draw_info->hDC, RGB (255, 255, 255));\r\n\r\n\t\t\t\tSetRect (\r\n\t\t\t\t\t&rect,\r\n\t\t\t\t\twnd_spacing,\r\n\t\t\t\t\t0,\r\n\t\t\t\t\t_r_calc_rectwidth (&draw_info->rcItem) - (wnd_spacing * 3) - icon_size_x,\r\n\t\t\t\t\t_r_calc_rectheight (&draw_info->rcItem)\r\n\t\t\t\t);\r\n\r\n\t\t\t\t_r_dc_drawtext (NULL, draw_info->hDC, &string->sr, &rect, 0, 0, DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS | DT_NOCLIP | DT_NOPREFIX, 0);\r\n\r\n\t\t\t\t_r_obj_dereference (string);\r\n\t\t\t}\r\n\r\n\t\t\t// draw title icon\r\n\t\t\thicon = _app_notify_getapp_icon (hwnd);\r\n\r\n\t\t\tif (hicon)\r\n\t\t\t{\r\n\t\t\t\tSetRect (\r\n\t\t\t\t\t&rect,\r\n\t\t\t\t\t_r_calc_rectwidth (&draw_info->rcItem) - icon_size_x - wnd_spacing,\r\n\t\t\t\t\t(_r_calc_rectheight (&draw_info->rcItem) / 2) - (icon_size_x / 2),\r\n\t\t\t\t\ticon_size_x,\r\n\t\t\t\t\ticon_size_x\r\n\t\t\t\t);\r\n\r\n\t\t\t\tDrawIconEx (\r\n\t\t\t\t\tdraw_info->hDC,\r\n\t\t\t\t\trect.left,\r\n\t\t\t\t\trect.top,\r\n\t\t\t\t\thicon,\r\n\t\t\t\t\trect.right,\r\n\t\t\t\t\trect.bottom,\r\n\t\t\t\t\t0,\r\n\t\t\t\t\tNULL,\r\n\t\t\t\t\tDI_IMAGE | DI_MASK\r\n\t\t\t\t);\r\n\t\t\t}\r\n\r\n\t\t\tSetWindowLongPtrW (hwnd, DWLP_MSGRESULT, TRUE);\r\n\r\n\t\t\treturn TRUE;\r\n\t\t}\r\n\r\n\t\tcase WM_SETCURSOR:\r\n\t\t{\r\n\t\t\tINT ctrl_id;\r\n\r\n\t\t\tctrl_id = GetDlgCtrlID ((HWND)wparam);\r\n\r\n\t\t\tif (ctrl_id == IDC_FILE_TEXT)\r\n\t\t\t{\r\n\t\t\t\tSetCursor (LoadCursorW (NULL, IDC_HAND));\r\n\r\n\t\t\t\tSetWindowLongPtrW (hwnd, DWLP_MSGRESULT, TRUE);\r\n\r\n\t\t\t\treturn TRUE;\r\n\t\t\t}\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase WM_LBUTTONDOWN:\r\n\t\t{\r\n\t\t\t_r_wnd_sendmessage (hwnd, 0, WM_SYSCOMMAND, SC_MOVE | HTCAPTION, 0);\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase WM_ENTERSIZEMOVE:\r\n\t\tcase WM_EXITSIZEMOVE:\r\n\t\tcase WM_CAPTURECHANGED:\r\n\t\t{\r\n\t\t\tHCURSOR hcursor;\r\n\t\t\tLONG_PTR ex_style;\r\n\r\n\t\t\tex_style = _r_wnd_getstyle (hwnd, GWL_EXSTYLE);\r\n\r\n\t\t\tif (!(ex_style & WS_EX_LAYERED))\r\n\t\t\t\t_r_wnd_setstyle (hwnd, WS_EX_LAYERED, WS_EX_LAYERED, GWL_EXSTYLE);\r\n\r\n\t\t\thcursor = LoadCursorW (NULL, (msg == WM_ENTERSIZEMOVE) ? IDC_SIZEALL : IDC_ARROW);\r\n\r\n\t\t\tSetLayeredWindowAttributes (hwnd, 0, (msg == WM_ENTERSIZEMOVE) ? 150 : 255, LWA_ALPHA);\r\n\t\t\tSetCursor (hcursor);\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase WM_NOTIFY:\r\n\t\t{\r\n\t\t\tLPNMHDR nmlp;\r\n\r\n\t\t\tnmlp = (LPNMHDR)lparam;\r\n\r\n\t\t\tswitch (nmlp->code)\r\n\t\t\t{\r\n\t\t\t\tcase BCN_DROPDOWN:\r\n\t\t\t\t{\r\n\t\t\t\t\tPNOTIFY_CONTEXT context;\r\n\t\t\t\t\tPITEM_LOG ptr_log;\r\n\t\t\t\t\tR_RECTANGLE rectangle;\r\n\t\t\t\t\tRECT rect;\r\n\t\t\t\t\tHMENU hsubmenu;\r\n\t\t\t\t\tINT ctrl_id;\r\n\r\n\t\t\t\t\tctrl_id = (INT)(INT_PTR)nmlp->idFrom;\r\n\r\n\t\t\t\t\tif (!_r_ctrl_isenabled (hwnd, ctrl_id))\r\n\t\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t\tif (ctrl_id != IDC_ALLOW_BTN && ctrl_id != IDC_RULES_BTN)\r\n\t\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t\tcontext = _app_notify_getcontext (hwnd);\r\n\r\n\t\t\t\t\tif (!context)\r\n\t\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t\tptr_log = _app_notify_getobject (context->app_hash);\r\n\r\n\t\t\t\t\thsubmenu = CreatePopupMenu ();\r\n\r\n\t\t\t\t\tif (!hsubmenu)\r\n\t\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t\tif (ctrl_id == IDC_RULES_BTN)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t_app_generate_rulescontrol (hsubmenu, context->app_hash, ptr_log);\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse if (ctrl_id == IDC_ALLOW_BTN)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t_app_generate_timerscontrol (hsubmenu, context->app_hash);\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tif (GetClientRect (nmlp->hwndFrom, &rect))\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tClientToScreen (nmlp->hwndFrom, (PPOINT)&rect);\r\n\r\n\t\t\t\t\t\t_r_wnd_recttorectangle (&rectangle, &rect);\r\n\t\t\t\t\t\t_r_wnd_adjustrectangletoworkingarea (nmlp->hwndFrom, &rectangle);\r\n\t\t\t\t\t\t_r_wnd_rectangletorect (&rect, &rectangle);\r\n\r\n\t\t\t\t\t\t_r_menu_popup (hsubmenu, hwnd, (PPOINT)&rect, TRUE);\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tDestroyMenu (hsubmenu);\r\n\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tcase TTN_GETDISPINFO:\r\n\t\t\t\t{\r\n\t\t\t\t\tLPNMTTDISPINFOW lpnmdi;\r\n\t\t\t\t\tWCHAR buffer[1024] = {0};\r\n\t\t\t\t\tPR_STRING string;\r\n\t\t\t\t\tULONG app_hash;\r\n\t\t\t\t\tINT ctrl_id;\r\n\t\t\t\t\tINT listview_id = 0;\r\n\r\n\t\t\t\t\tlpnmdi = (LPNMTTDISPINFOW)lparam;\r\n\r\n\t\t\t\t\tif ((lpnmdi->uFlags & TTF_IDISHWND) == 0)\r\n\t\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t\tctrl_id = GetDlgCtrlID ((HWND)lpnmdi->hdr.idFrom);\r\n\r\n\t\t\t\t\tif (ctrl_id == IDC_FILE_TEXT)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tapp_hash = _app_notify_getapp_id (hwnd);\r\n\r\n\t\t\t\t\t\tif (_app_getappinfobyhash (app_hash, INFO_LISTVIEW_ID, &listview_id, sizeof (INT)))\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tstring = _app_gettooltipbylparam (_r_app_gethwnd (), listview_id, app_hash);\r\n\r\n\t\t\t\t\t\t\tif (string)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t_r_str_copy (buffer, RTL_NUMBER_OF (buffer), string->buffer);\r\n\r\n\t\t\t\t\t\t\t\t_r_obj_dereference (string);\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse if (ctrl_id == IDC_RULES_BTN)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t_r_str_copy (buffer, RTL_NUMBER_OF (buffer), _r_locale_getstring (IDS_NOTIFY_TOOLTIP));\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse if (ctrl_id == IDC_ALLOW_BTN)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t_r_str_copy (buffer, RTL_NUMBER_OF (buffer), _r_locale_getstring (IDS_ACTION_ALLOW_HINT));\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse if (ctrl_id == IDC_BLOCK_BTN)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t_r_str_copy (buffer, RTL_NUMBER_OF (buffer), _r_locale_getstring (IDS_ACTION_BLOCK_HINT));\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse if (ctrl_id == IDC_KILLPROCESS_BTN)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t_r_str_copy (buffer, RTL_NUMBER_OF (buffer), _r_locale_getstring (IDS_ACTION_TERMINATE_HINT));\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tstring = _r_ctrl_getstring (hwnd, ctrl_id);\r\n\r\n\t\t\t\t\t\tif (string)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t_r_str_copy (buffer, RTL_NUMBER_OF (buffer), string->buffer);\r\n\r\n\t\t\t\t\t\t\t_r_obj_dereference (string);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tif (!_r_str_isempty2 (buffer))\r\n\t\t\t\t\t\tlpnmdi->lpszText = buffer;\r\n\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase WM_COMMAND:\r\n\t\t{\r\n\t\t\tINT ctrl_id;\r\n\r\n\t\t\tctrl_id = LOWORD (wparam);\r\n\r\n\t\t\tif (ctrl_id >= IDX_RULES_SPECIAL && ctrl_id <= IDX_RULES_SPECIAL + (INT)(INT_PTR)_r_obj_getlistsize (rules_list) + 1)\r\n\t\t\t{\r\n\t\t\t\tHANDLE hengine;\r\n\t\t\t\tPR_LIST rules;\r\n\t\t\t\tPITEM_RULE ptr_rule;\r\n\t\t\t\tPITEM_APP ptr_app;\r\n\t\t\t\tPITEM_LOG ptr_log;\r\n\t\t\t\tPR_STRING rule;\r\n\t\t\t\tULONG_PTR rule_idx;\r\n\t\t\t\tULONG app_hash;\r\n\t\t\t\tBOOLEAN is_remove;\r\n\r\n\t\t\t\tapp_hash = _app_notify_getapp_id (hwnd);\r\n\t\t\t\tptr_app = _app_getappitem (app_hash);\r\n\r\n\t\t\t\tif (!ptr_app)\r\n\t\t\t\t\treturn FALSE;\r\n\r\n\t\t\t\trule_idx = (ULONG_PTR)ctrl_id - IDX_RULES_SPECIAL;\r\n\t\t\t\tptr_rule = _app_getrulebyid (rule_idx);\r\n\r\n\t\t\t\tif (!ptr_rule)\r\n\t\t\t\t{\r\n\t\t\t\t\tptr_log = _app_notify_getobject (app_hash);\r\n\r\n\t\t\t\t\tif (ptr_log)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\trule = _app_formataddress (ptr_log->af, 0, &ptr_log->remote_addr, ptr_log->remote_port, FMTADDR_AS_RULE);\r\n\r\n\t\t\t\t\t\tptr_rule = _app_addrule (NULL, NULL, NULL, FWP_DIRECTION_OUTBOUND, FWP_ACTION_PERMIT, ptr_log->protocol, ptr_log->af);\r\n\r\n\t\t\t\t\t\tptr_rule->name = _r_obj_createstring2 (&rule->sr);\r\n\t\t\t\t\t\tptr_rule->rule_remote = _r_obj_createstring2 (&rule->sr);\r\n\r\n\t\t\t\t\t\t_app_ruleenable (ptr_rule, TRUE, FALSE);\r\n\r\n\t\t\t\t\t\t_r_obj_addhashtableitem (ptr_rule->apps, app_hash, NULL);\r\n\r\n\t\t\t\t\t\t_r_obj_dereference (rule);\r\n\r\n\t\t\t\t\t\t_r_queuedlock_acquireexclusive (&lock_rules);\r\n\t\t\t\t\t\t_r_obj_addlistitem (rules_list, ptr_rule, &rule_idx);\r\n\t\t\t\t\t\t_r_queuedlock_releaseexclusive (&lock_rules);\r\n\r\n\t\t\t\t\t\tif (rule_idx != SIZE_MAX)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t_app_listview_addruleitem (_r_app_gethwnd (), ptr_rule, (ULONG)rule_idx, TRUE);\r\n\t\t\t\t\t\t\t_app_listview_updateby_id (_r_app_gethwnd (), DATA_LISTVIEW_CURRENT, PR_UPDATE_TYPE);\r\n\r\n\t\t\t\t\t\t\t_app_profile_save (hwnd);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\t_app_notify_freeobject (hwnd, ptr_app);\r\n\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\r\n\t\t\t\t_app_notify_freeobject (hwnd, ptr_app);\r\n\r\n\t\t\t\tif (!(ptr_rule->is_forservices && _app_issystemhash (app_hash)))\r\n\t\t\t\t{\r\n\t\t\t\t\tis_remove = ptr_rule->is_enabled && _r_obj_findhashtable (ptr_rule->apps, app_hash);\r\n\r\n\t\t\t\t\tif (is_remove)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t_r_obj_removehashtableitem (ptr_rule->apps, app_hash);\r\n\r\n\t\t\t\t\t\tif (_r_obj_isempty (ptr_rule->apps))\r\n\t\t\t\t\t\t\t_app_ruleenable (ptr_rule, FALSE, TRUE);\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t_r_obj_addhashtableitem (ptr_rule->apps, app_hash, NULL);\r\n\r\n\t\t\t\t\t\t_app_ruleenable (ptr_rule, TRUE, TRUE);\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\t_app_listview_updateitemby_param (_r_app_gethwnd (), app_hash, TRUE);\r\n\t\t\t\t\t_app_listview_updateitemby_param (_r_app_gethwnd (), rule_idx, FALSE);\r\n\r\n\t\t\t\t\tif (_wfp_isfiltersinstalled ())\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\thengine = _wfp_getenginehandle ();\r\n\r\n\t\t\t\t\t\trules = _r_obj_createlist (1, NULL);\r\n\r\n\t\t\t\t\t\t_r_obj_addlistitem (rules, ptr_rule, NULL);\r\n\r\n\t\t\t\t\t\t_wfp_create4filters (hengine, rules, DBG_ARG, FALSE);\r\n\r\n\t\t\t\t\t\t_r_obj_dereference (rules);\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\t_app_listview_updateby_id (_r_app_gethwnd (), DATA_LISTVIEW_CURRENT, PR_UPDATE_TYPE);\r\n\r\n\t\t\t\t\t_r_obj_dereference (ptr_rule);\r\n\t\t\t\t\t_r_obj_dereference (ptr_app);\r\n\r\n\t\t\t\t\t_app_profile_save (hwnd);\r\n\t\t\t\t}\r\n\r\n\t\t\t\treturn FALSE;\r\n\t\t\t}\r\n\t\t\telse if (ctrl_id >= IDX_TIMER && ctrl_id <= (IDX_TIMER + (RTL_NUMBER_OF (timer_array) - 1)))\r\n\t\t\t{\r\n\t\t\t\tULONG_PTR timer_idx;\r\n\t\t\t\tLONG64 seconds;\r\n\r\n\t\t\t\tif (!_r_ctrl_isenabled (hwnd, IDC_ALLOW_BTN))\r\n\t\t\t\t\treturn FALSE;\r\n\r\n\t\t\t\ttimer_idx = (ULONG_PTR)ctrl_id - IDX_TIMER;\r\n\t\t\t\tseconds = timer_array[timer_idx];\r\n\r\n\t\t\t\t_app_notify_command (hwnd, IDC_ALLOW_BTN, seconds);\r\n\r\n\t\t\t\treturn FALSE;\r\n\t\t\t}\r\n\r\n\t\t\tswitch (ctrl_id)\r\n\t\t\t{\r\n\t\t\t\tcase IDCANCEL: // process Esc key\r\n\t\t\t\t{\r\n\t\t\t\t\tDestroyWindow (hwnd);\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tcase IDC_FILE_TEXT:\r\n\t\t\t\t{\r\n\t\t\t\t\tULONG app_hash;\r\n\r\n\t\t\t\t\tapp_hash = _app_notify_getapp_id (hwnd);\r\n\r\n\t\t\t\t\tif (app_hash)\r\n\t\t\t\t\t\t_app_listview_showitemby_param (_r_app_gethwnd (), app_hash, TRUE);\r\n\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tcase IDC_RULES_BTN:\r\n\t\t\t\t{\r\n\t\t\t\t\tPEDITOR_CONTEXT context;\r\n\t\t\t\t\tPITEM_APP ptr_app;\r\n\t\t\t\t\tULONG app_hash;\r\n\r\n\t\t\t\t\tapp_hash = _app_notify_getapp_id (hwnd);\r\n\t\t\t\t\tptr_app = _app_getappitem (app_hash);\r\n\r\n\t\t\t\t\tif (!ptr_app)\r\n\t\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t\tcontext = _app_editor_createwindow (_r_app_gethwnd (), ptr_app, 1, FALSE);\r\n\r\n\t\t\t\t\tif (context)\r\n\t\t\t\t\t\t_app_editor_deletewindow (context);\r\n\r\n\t\t\t\t\t_app_notify_freeobject (hwnd, ptr_app);\r\n\r\n\t\t\t\t\t_r_obj_dereference (ptr_app);\r\n\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tcase IDC_ALLOW_BTN:\r\n\t\t\t\tcase IDC_BLOCK_BTN:\r\n\t\t\t\tcase IDC_NEXT_BTN:\r\n\t\t\t\t{\r\n\t\t\t\t\tif (_r_ctrl_isenabled (hwnd, ctrl_id))\r\n\t\t\t\t\t\t_app_notify_command (hwnd, ctrl_id, 0);\r\n\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tcase IDC_KILLPROCESS_BTN:\r\n\t\t\t\t{\r\n\t\t\t\t\t_app_notify_killprocess (hwnd);\r\n\r\n\t\t\t\t\t_r_ctrl_enable (hwnd, ctrl_id, FALSE);\r\n\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tcase IDM_OPENRULESEDITOR:\r\n\t\t\t\t{\r\n\t\t\t\t\tPEDITOR_CONTEXT context;\r\n\t\t\t\t\tPITEM_APP ptr_app;\r\n\t\t\t\t\tPITEM_RULE ptr_rule;\r\n\t\t\t\t\tPITEM_LOG ptr_log;\r\n\t\t\t\t\tPR_STRING app_name;\r\n\t\t\t\t\tPR_STRING rule_name;\r\n\t\t\t\t\tPR_STRING rule_string;\r\n\t\t\t\t\tULONG_PTR rule_idx;\r\n\t\t\t\t\tULONG app_hash;\r\n\r\n\t\t\t\t\tapp_hash = _app_notify_getapp_id (hwnd);\r\n\t\t\t\t\tptr_log = _app_notify_getobject (app_hash);\r\n\r\n\t\t\t\t\tif (!ptr_log)\r\n\t\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t\tapp_hash = ptr_log->app_hash;\r\n\t\t\t\t\tptr_app = _app_getappitem (app_hash);\r\n\r\n\t\t\t\t\tif (!ptr_app)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t_r_obj_dereference (ptr_log);\r\n\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tapp_name = _app_getappdisplayname (ptr_app, TRUE);\r\n\r\n\t\t\t\t\trule_string = _app_formataddress (ptr_log->af, 0, &ptr_log->remote_addr, ptr_log->remote_port, FMTADDR_AS_RULE);\r\n\r\n\t\t\t\t\trule_name = _r_format_string (L\"%s - %s\", _r_obj_getstring (app_name), _r_obj_getstring (rule_string));\r\n\r\n\t\t\t\t\tptr_rule = _app_addrule (rule_name, rule_string, NULL, ptr_log->direction, FWP_ACTION_PERMIT, ptr_log->protocol, ptr_log->af);\r\n\r\n\t\t\t\t\t_r_obj_addhashtableitem (ptr_rule->apps, app_hash, NULL);\r\n\r\n\t\t\t\t\t_app_ruleenable (ptr_rule, TRUE, TRUE);\r\n\r\n\t\t\t\t\tcontext = _app_editor_createwindow (_r_app_gethwnd (), ptr_rule, 0, TRUE);\r\n\r\n\t\t\t\t\tif (context)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t_r_queuedlock_acquireexclusive (&lock_rules);\r\n\t\t\t\t\t\t_r_obj_addlistitem (rules_list, _r_obj_reference (ptr_rule), &rule_idx);\r\n\t\t\t\t\t\t_r_queuedlock_releaseexclusive (&lock_rules);\r\n\r\n\t\t\t\t\t\t// set rule information\r\n\t\t\t\t\t\t_app_listview_addruleitem (_r_app_gethwnd (), ptr_rule, rule_idx, TRUE);\r\n\r\n\t\t\t\t\t\t// update app information\r\n\t\t\t\t\t\t_app_listview_updateitemby_param (_r_app_gethwnd (), app_hash, TRUE);\r\n\r\n\t\t\t\t\t\t_app_listview_updateby_id (_r_app_gethwnd (), DATA_LISTVIEW_CURRENT, PR_UPDATE_TYPE);\r\n\r\n\t\t\t\t\t\t_app_profile_save (hwnd);\r\n\r\n\t\t\t\t\t\t_app_editor_deletewindow (context);\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\t_app_notify_freeobject (hwnd, ptr_app);\r\n\r\n\t\t\t\t\tif (app_name)\r\n\t\t\t\t\t\t_r_obj_dereference (app_name);\r\n\r\n\t\t\t\t\tif (rule_string)\r\n\t\t\t\t\t\t_r_obj_dereference (rule_string);\r\n\r\n\t\t\t\t\t_r_obj_dereference (rule_name);\r\n\t\t\t\t\t_r_obj_dereference (ptr_rule);\r\n\t\t\t\t\t_r_obj_dereference (ptr_log);\r\n\t\t\t\t\t_r_obj_dereference (ptr_app);\r\n\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tcase IDM_COPY: // ctrl+c\r\n\t\t\t\tcase IDM_SELECT_ALL: // ctrl+a\r\n\t\t\t\t{\r\n\t\t\t\t\tstatic R_STRINGREF sr = PR_STRINGREF_INIT (WC_EDITW);\r\n\r\n\t\t\t\t\tPR_STRING class_name;\r\n\t\t\t\t\tHWND hedit;\r\n\r\n\t\t\t\t\thedit = GetFocus ();\r\n\r\n\t\t\t\t\tif (!hedit)\r\n\t\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t\tclass_name = _r_wnd_getclassname (hedit);\r\n\r\n\t\t\t\t\tif (!class_name)\r\n\t\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t\tif (_r_str_isequal (&class_name->sr, &sr, TRUE))\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif (ctrl_id == IDM_COPY)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t_r_wnd_sendmessage (hedit, 0, WM_COPY, 0, 0); // edit control hotkey for \"ctrl+c\" (issue #597)\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\telse if (ctrl_id == IDM_SELECT_ALL)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t_r_ctrl_setselection (hedit, 0, 0, -1); // edit control hotkey for \"ctrl+a\"\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\t_r_obj_dereference (class_name);\r\n\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\r\n\treturn FALSE;\r\n}\r\n"
  },
  {
    "path": "src/notifications.h",
    "content": "// simplewall\r\n// Copyright (c) 2016-2026 Henry++\r\n\r\n#pragma once\r\n\r\ntypedef struct _NOTIFY_CONTEXT\r\n{\r\n\tHWND hwnd;\r\n\r\n\tHICON hico_allow;\r\n\tHICON hico_block;\r\n\tHICON hico_cross;\r\n\tHICON hico_next;\r\n\tHICON hico_rules;\r\n\r\n\tHFONT hfont_title;\r\n\tHFONT hfont_link;\r\n\tHFONT hfont_text;\r\n\r\n\tHICON hicon;\r\n\r\n\tULONG app_hash;\r\n} NOTIFY_CONTEXT, *PNOTIFY_CONTEXT;\r\n\r\n_Ret_maybenull_\r\nHWND _app_notify_getwindow (\r\n\t_In_opt_ PITEM_LOG ptr_log\r\n);\r\n\r\n_Ret_maybenull_\r\nPNOTIFY_CONTEXT _app_notify_getcontext (\r\n\t_In_ HWND hwnd\r\n);\r\n\r\nVOID _app_notify_setcontext (\r\n\t_In_ HWND hwnd,\r\n\t_In_opt_ PNOTIFY_CONTEXT context\r\n);\r\n\r\nBOOLEAN _app_notify_command (\r\n\t_In_ HWND hwnd,\r\n\t_In_ INT button_id,\r\n\t_In_opt_ LONG64 seconds\r\n);\r\n\r\nBOOLEAN _app_notify_addobject (\r\n\t_In_ HWND hwnd,\r\n\t_In_ PITEM_LOG ptr_log,\r\n\t_Inout_ PITEM_APP ptr_app\r\n);\r\n\r\nVOID _app_notify_freeobject (\r\n\t_In_opt_ HWND hwnd,\r\n\t_Inout_ PITEM_APP ptr_app\r\n);\r\n\r\n_Ret_maybenull_\r\nHICON _app_notify_getapp_icon (\r\n\t_In_ HWND hwnd\r\n);\r\n\r\n_Ret_maybenull_\r\nPITEM_LOG _app_notify_getobject (\r\n\t_In_ ULONG app_hash\r\n);\r\n\r\nULONG _app_notify_getapp_id (\r\n\t_In_ HWND hwnd\r\n);\r\n\r\nULONG _app_notify_getnextapp_id (\r\n\t_In_ HWND hwnd\r\n);\r\n\r\nVOID _app_notify_setapp_icon (\r\n\t_In_ HWND hwnd,\r\n\t_In_opt_ HICON hicon\r\n);\r\n\r\nVOID _app_notify_setapp_id (\r\n\t_In_ HWND hwnd,\r\n\t_In_opt_ ULONG app_hash\r\n);\r\n\r\nVOID _app_notify_show (\r\n\t_In_ HWND hwnd,\r\n\t_In_ PITEM_LOG ptr_log\r\n);\r\n\r\nVOID _app_notify_playsound ();\r\n\r\nVOID _app_notify_queueinfo (\r\n\t_In_ HWND hwnd,\r\n\t_In_ PITEM_LOG ptr_log\r\n);\r\n\r\nVOID _app_notify_refresh (\r\n\t_In_ HWND hwnd\r\n);\r\n\r\nVOID _app_notify_setposition (\r\n\t_In_ HWND hwnd,\r\n\t_In_ BOOLEAN is_forced\r\n);\r\n\r\nVOID _app_notify_settimeout (\r\n\t_In_ HWND hwnd\r\n);\r\n\r\nVOID _app_notify_initialize (\r\n\t_Inout_ PNOTIFY_CONTEXT context,\r\n\t_In_ LONG dpi_value\r\n);\r\n\r\nVOID _app_notify_destroy (\r\n\t_In_ HWND hwnd\r\n);\r\n\r\nVOID _app_notify_drawgradient (\r\n\t_In_ HDC hdc,\r\n\t_In_ LPCRECT rect\r\n);\r\n\r\nINT_PTR CALLBACK NotificationProc (\r\n\t_In_ HWND hwnd,\r\n\t_In_ UINT msg,\r\n\t_In_ WPARAM wparam,\r\n\t_In_ LPARAM lparam\r\n);\r\n"
  },
  {
    "path": "src/packages.c",
    "content": "// simplewall\n// Copyright (c) 2016-2025 Henry++\n\n#include \"global.h\"\n\nBOOLEAN _app_package_isnotexists (\n\t_In_ PR_STRING package_sid\n)\n{\n\tULONG app_hash;\n\n\tapp_hash = _r_str_gethash (&package_sid->sr, TRUE);\n\n\tif (_app_isappfound (app_hash))\n\t\treturn TRUE;\n\n\t// there we try to found new packages (HACK!!!)\n\t_app_package_getpackageslist (_r_app_gethwnd ());\n\n\treturn _app_isappfound (app_hash);\n}\n\nVOID _app_package_parsepath (\n\t_Inout_ PR_STRING_PTR package_root_folder\n)\n{\n\tR_STRINGREF appx_names[] = {\n\t\tPR_STRINGREF_INIT (L\"AppxManifest.xml\"),\n\t\tPR_STRINGREF_INIT (L\"VSAppxManifest.xml\"),\n\t};\n\n\tR_STRINGREF separator_sr = PR_STRINGREF_INIT (L\"\\\\\");\n\tR_XML_LIBRARY xml_library = {0};\n\tPR_STRING manifest_path = NULL;\n\tPR_STRING result_path = NULL;\n\tPR_STRING path_string;\n\tR_STRINGREF executable_sr;\n\tHRESULT status;\n\tBOOLEAN is_success = FALSE;\n\n\tpath_string = *package_root_folder;\n\n\tfor (ULONG_PTR i = 0; i < RTL_NUMBER_OF (appx_names); i++)\n\t{\n\t\t_r_obj_movereference ((PVOID_PTR)&manifest_path, _r_obj_concatstringrefs (3, &path_string->sr, &separator_sr, &appx_names[i]));\n\n\t\tif (_r_fs_isexists (&manifest_path->sr))\n\t\t{\n\t\t\tis_success = TRUE;\n\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif (!is_success)\n\t\tgoto CleanupExit;\n\n\tstatus = _r_xml_initializelibrary (&xml_library, TRUE);\n\n\tif (FAILED (status))\n\t\tgoto CleanupExit;\n\n\tstatus = _r_xml_parsefile (&xml_library, manifest_path->buffer);\n\n\tif (FAILED (status))\n\t\tgoto CleanupExit;\n\n\tif (_r_xml_findchildbytagname (&xml_library, L\"Applications\"))\n\t{\n\t\twhile (_r_xml_enumchilditemsbytagname (&xml_library, L\"Application\"))\n\t\t{\n\t\t\tif (FAILED (_r_xml_getattribute (&xml_library, L\"Executable\", &executable_sr)))\n\t\t\t\tcontinue;\n\n\t\t\t_r_obj_movereference ((PVOID_PTR)&result_path, _r_obj_concatstringrefs (3, &path_string->sr, &separator_sr, &executable_sr));\n\n\t\t\tif (_r_fs_isexists (&result_path->sr))\n\t\t\t{\n\t\t\t\t_r_obj_swapreference ((PVOID_PTR)package_root_folder, result_path);\n\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\nCleanupExit:\n\n\tif (result_path)\n\t\t_r_obj_dereference (result_path);\n\n\tif (manifest_path)\n\t\t_r_obj_dereference (manifest_path);\n\n\t_r_xml_destroylibrary (&xml_library);\n}\n\nVOID _app_package_getpackagebyname (\n\t_In_ HANDLE hroot,\n\t_In_ LPCWSTR path,\n\t_In_ PR_STRING key_name\n)\n{\n\tWCHAR buffer[256];\n\tPR_STRING package_sid_string = NULL;\n\tPR_STRING display_name = NULL;\n\tPR_STRING real_path = NULL;\n\tPR_BYTE package_sid = NULL;\n\tPITEM_APP ptr_app;\n\tHANDLE hsubkey;\n\tLONG64 timestamp;\n\tULONG app_hash;\n\tNTSTATUS status;\n\n\t_r_str_printf (buffer, RTL_NUMBER_OF (buffer), L\"%s\\\\%s\", path, key_name->buffer);\n\n\tstatus = _r_reg_openkey (hroot, buffer, 0, KEY_READ, &hsubkey);\n\n\tif (!NT_SUCCESS (status))\n\t\tgoto CleanupExit;\n\n\tstatus = _r_reg_querybinary (hsubkey, L\"PackageSid\", &package_sid);\n\n\tif (!NT_SUCCESS (status))\n\t\tgoto CleanupExit;\n\n\tstatus = _r_str_fromsid (package_sid->buffer, &package_sid_string);\n\n\tif (!NT_SUCCESS (status))\n\t\tgoto CleanupExit;\n\n\t// already exists (skip)\n\tapp_hash = _r_str_gethash (&package_sid_string->sr, TRUE);\n\n\tif (_app_isappfound (app_hash))\n\t\tgoto CleanupExit;\n\n\t// parse package information\n\tif (!_app_uwp_getpackageinfo (key_name, &display_name, &real_path))\n\t\tgoto CleanupExit;\n\n\tif (real_path)\n\t\t_app_package_parsepath (&real_path);\n\n\t//_r_queuedlock_acquireexclusive (&lock_apps);\n\tapp_hash = _app_addapplication (NULL, DATA_APP_UWP, package_sid_string, display_name, real_path);\n\t//_r_queuedlock_releaseexclusive (&lock_apps);\n\n\tif (app_hash)\n\t{\n\t\tptr_app = _app_getappitem (app_hash);\n\n\t\tif (ptr_app)\n\t\t{\n\t\t\tstatus = _r_reg_queryinfo (hsubkey, NULL, &timestamp);\n\n\t\t\tif (NT_SUCCESS (status))\n\t\t\t\t_app_setappinfo (ptr_app, INFO_TIMESTAMP, &timestamp);\n\n\t\t\t_app_setappinfo (ptr_app, INFO_BYTES_DATA, _r_obj_reference (package_sid));\n\n\t\t\t_r_obj_dereference (ptr_app);\n\t\t}\n\t}\n\nCleanupExit:\n\n\tif (display_name)\n\t\t_r_obj_dereference (display_name);\n\n\tif (package_sid)\n\t\t_r_obj_dereference (package_sid);\n\n\tif (package_sid_string)\n\t\t_r_obj_dereference (package_sid_string);\n\n\tif (real_path)\n\t\t_r_obj_dereference (real_path);\n\n\tif (hsubkey)\n\t\tNtClose (hsubkey);\n}\n\nVOID _app_package_getpackagebysid (\n\t_In_ HANDLE hroot,\n\t_In_ LPCWSTR path,\n\t_In_ PR_STRING key_name\n)\n{\n\tWCHAR buffer[256];\n\tPR_STRING display_name = NULL;\n\tPR_STRING real_path = NULL;\n\tPR_BYTE package_sid = NULL;\n\tPR_STRING moniker = NULL;\n\tPITEM_APP ptr_app;\n\tHANDLE hsubkey;\n\tLONG64 timestamp = 0;\n\tULONG app_hash;\n\tNTSTATUS status;\n\n\t// already exists (skip)\n\tapp_hash = _r_str_gethash (&key_name->sr, TRUE);\n\n\tif (_app_isappfound (app_hash))\n\t\treturn;\n\n\t_r_str_printf (buffer, RTL_NUMBER_OF (buffer), L\"%s\\\\%s\", path, key_name->buffer);\n\n\tstatus = _r_reg_openkey (hroot, buffer, 0, KEY_READ, &hsubkey);\n\n\tif (!NT_SUCCESS (status))\n\t\tgoto CleanupExit;\n\n\tpackage_sid = _r_str_tosid (key_name);\n\n\tif (!package_sid)\n\t\tgoto CleanupExit;\n\n\t// query package moniker\n\tstatus = _r_reg_querystring (hsubkey, L\"Moniker\", &moniker, NULL);\n\n\tif (!NT_SUCCESS (status))\n\t\tgoto CleanupExit;\n\n\t// parse package information\n\tif (!_app_uwp_getpackageinfo (moniker, &display_name, &real_path))\n\t\tgoto CleanupExit;\n\n\tif (real_path)\n\t\t_app_package_parsepath (&real_path);\n\n\t//_r_queuedlock_acquireexclusive (&lock_apps);\n\tapp_hash = _app_addapplication (NULL, DATA_APP_UWP, key_name, display_name, NULL);\n\t//_r_queuedlock_releaseexclusive (&lock_apps);\n\n\tif (app_hash)\n\t{\n\t\tptr_app = _app_getappitem (app_hash);\n\n\t\tif (ptr_app)\n\t\t{\n\t\t\tstatus = _r_reg_queryinfo (hsubkey, NULL, &timestamp);\n\n\t\t\tif (NT_SUCCESS (status))\n\t\t\t\t_app_setappinfo (ptr_app, INFO_TIMESTAMP, &timestamp);\n\n\t\t\t_app_setappinfo (ptr_app, INFO_BYTES_DATA, _r_obj_reference (package_sid));\n\n\t\t\t_r_obj_dereference (ptr_app);\n\t\t}\n\t}\n\nCleanupExit:\n\n\tif (moniker)\n\t\t_r_obj_dereference (moniker);\n\n\tif (display_name)\n\t\t_r_obj_dereference (display_name);\n\n\tif (real_path)\n\t\t_r_obj_dereference (real_path);\n\n\tif (package_sid)\n\t\t_r_obj_dereference (package_sid);\n\n\tif (hsubkey)\n\t\tNtClose (hsubkey);\n}\n\nVOID NTAPI _app_package_threadproc (\n\t_In_ PVOID arglist\n)\n{\n\tIO_STATUS_BLOCK isb;\n\tHANDLE hservices_key = NULL;\n\tHANDLE hpackages_key = NULL;\n\tHANDLE event_handle1 = NULL;\n\tHANDLE event_handle2 = NULL;\n\tHANDLE hevents[2] = {0};\n\tPITEM_APP ptr_app = NULL;\n\tHWND hwnd;\n\tLONG64 current_time;\n\tULONG_PTR enum_key = 0;\n\tULONG flags = REG_NOTIFY_CHANGE_NAME;\n\tNTSTATUS status;\n\n\thwnd = arglist;\n\n\tstatus = NtCreateEvent (&event_handle1, EVENT_ALL_ACCESS, NULL, NotificationEvent, FALSE);\n\n\tif (!NT_SUCCESS (status))\n\t{\n\t\t_r_show_errormessage (hwnd, NULL, status, L\"NtCreateEvent\", ET_NATIVE);\n\n\t\treturn;\n\t}\n\n\tstatus = NtCreateEvent (&event_handle2, EVENT_ALL_ACCESS, NULL, NotificationEvent, FALSE);\n\n\tif (!NT_SUCCESS (status))\n\t{\n\t\t_r_show_errormessage (hwnd, NULL, status, L\"NtCreateEvent\", ET_NATIVE);\n\n\t\treturn;\n\t}\n\n\thevents[0] = event_handle1;\n\thevents[1] = event_handle2;\n\n\tstatus = _r_reg_openkey (HKEY_LOCAL_MACHINE, L\"System\\\\CurrentControlSet\\\\Services\", 0, KEY_NOTIFY, &hservices_key);\n\n\tif (_r_sys_isosversiongreaterorequal (WINDOWS_8))\n\t{\n\t\tflags |= REG_NOTIFY_THREAD_AGNOSTIC;\n\n\t\t_r_reg_openkey (HKEY_CURRENT_USER, L\"Software\\\\Classes\\\\Local Settings\\\\Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\AppModel\\\\Repository\\\\Packages\", 0, KEY_NOTIFY, &hpackages_key);\n\t}\n\n\tif (NT_SUCCESS (status))\n\t{\n\t\tNtNotifyChangeKey (hservices_key, event_handle1, NULL, NULL, &isb, flags, TRUE, NULL, 0, TRUE);\n\n\t\tif (hpackages_key)\n\t\t\tNtNotifyChangeKey (hpackages_key, event_handle2, NULL, NULL, &isb, flags, TRUE, NULL, 0, TRUE);\n\n\t\twhile (TRUE)\n\t\t{\n\t\t\tstatus = _r_sys_waitformultipleobjects (RTL_NUMBER_OF (hevents), hevents, INFINITE, FALSE);\n\n\t\t\tif (status == STATUS_WAIT_0)\n\t\t\t{\n\t\t\t\t_r_listview_deleteallitems (hwnd, IDC_APPS_SERVICE);\n\n\t\t\t\t_app_package_getserviceslist (hwnd);\n\n\t\t\t\t// add apps\n\t\t\t\tcurrent_time = _r_unixtime_now ();\n\n\t\t\t\tenum_key = 0;\n\n\t\t\t\t_r_queuedlock_acquireshared (&lock_apps);\n\n\t\t\t\twhile (_r_obj_enumhashtablepointer (apps_table, (PVOID_PTR)&ptr_app, NULL, &enum_key))\n\t\t\t\t{\n\t\t\t\t\tif (ptr_app->type == DATA_APP_SERVICE)\n\t\t\t\t\t{\n\t\t\t\t\t\t_app_listview_addappitem (hwnd, ptr_app);\n\n\t\t\t\t\t\t// install timer\n\t\t\t\t\t\tif (ptr_app->timer)\n\t\t\t\t\t\t\t_app_timer_set (hwnd, ptr_app, ptr_app->timer - current_time);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t_r_queuedlock_releaseshared (&lock_apps);\n\n\t\t\t\tNtNotifyChangeKey (hservices_key, event_handle1, NULL, NULL, &isb, flags, TRUE, NULL, 0, TRUE); // reset\n\t\t\t}\n\t\t\telse if (status == STATUS_WAIT_1)\n\t\t\t{\n\t\t\t\t_r_listview_deleteallitems (hwnd, IDC_APPS_UWP);\n\n\t\t\t\t_app_package_getpackageslist (hwnd);\n\n\t\t\t\t// add apps\n\t\t\t\tcurrent_time = _r_unixtime_now ();\n\n\t\t\t\tenum_key = 0;\n\n\t\t\t\t_r_queuedlock_acquireshared (&lock_apps);\n\n\t\t\t\twhile (_r_obj_enumhashtablepointer (apps_table, (PVOID_PTR)&ptr_app, NULL, &enum_key))\n\t\t\t\t{\n\t\t\t\t\tif (ptr_app->type == DATA_APP_UWP)\n\t\t\t\t\t{\n\t\t\t\t\t\t_app_listview_addappitem (hwnd, ptr_app);\n\n\t\t\t\t\t\t// install timer\n\t\t\t\t\t\tif (ptr_app->timer)\n\t\t\t\t\t\t\t_app_timer_set (hwnd, ptr_app, ptr_app->timer - current_time);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t_r_queuedlock_releaseshared (&lock_apps);\n\n\t\t\t\tif (hpackages_key)\n\t\t\t\t\tNtNotifyChangeKey (hpackages_key, event_handle2, NULL, NULL, &isb, flags, TRUE, NULL, 0, TRUE); // reset\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (hservices_key)\n\t\tNtClose (hservices_key);\n\n\tif (hpackages_key)\n\t\tNtClose (hpackages_key);\n\n\tNtClose (event_handle1);\n\tNtClose (event_handle2);\n}\n\nVOID _app_package_getpackageslist (\n\t_In_ HWND hwnd\n)\n{\n\tLPWSTR reg_byname = L\"Software\\\\Classes\\\\Local Settings\\\\Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\AppModel\\\\Repository\\\\Packages\";\n\tLPWSTR reg_bysid = L\"Software\\\\Classes\\\\Local Settings\\\\Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\AppContainer\\\\Mappings\";\n\tPR_STRING name;\n\tHANDLE hkey;\n\tULONG index = 0;\n\tNTSTATUS status;\n\n\t// query packages by name\n\tstatus = _r_reg_openkey (HKEY_CURRENT_USER, reg_byname, 0, KEY_READ, &hkey);\n\n\tif (!NT_SUCCESS (status))\n\t{\n\t\tif (status != STATUS_OBJECT_NAME_NOT_FOUND)\n\t\t\t_r_show_errormessage (hwnd, NULL, status, reg_byname, ET_NATIVE);\n\t}\n\telse\n\t{\n\t\twhile (TRUE)\n\t\t{\n\t\t\tstatus = _r_reg_enumkey (hkey, index, &name, NULL);\n\n\t\t\tif (!NT_SUCCESS (status))\n\t\t\t\tbreak;\n\n\t\t\t_app_package_getpackagebyname (HKEY_CURRENT_USER, reg_byname, name);\n\n\t\t\t_r_obj_dereference (name);\n\n\t\t\tindex += 1;\n\t\t}\n\n\t\tNtClose (hkey);\n\t}\n\n\t// query packages by sid\n\tstatus = _r_reg_openkey (HKEY_CURRENT_USER, reg_bysid, 0, KEY_READ, &hkey);\n\n\tif (!NT_SUCCESS (status))\n\t{\n\t\tif (status != STATUS_OBJECT_NAME_NOT_FOUND)\n\t\t\t_r_show_errormessage (hwnd, NULL, status, reg_bysid, ET_NATIVE);\n\t}\n\telse\n\t{\n\t\tindex = 0;\n\n\t\twhile (TRUE)\n\t\t{\n\t\t\tstatus = _r_reg_enumkey (hkey, index, &name, NULL);\n\n\t\t\tif (!NT_SUCCESS (status))\n\t\t\t\tbreak;\n\n\t\t\t_app_package_getpackagebysid (HKEY_CURRENT_USER, reg_bysid, name);\n\n\t\t\t_r_obj_dereference (name);\n\n\t\t\tindex += 1;\n\t\t}\n\n\t\tNtClose (hkey);\n\t}\n}\n\nVOID _app_package_getserviceslist (\n\t_In_ HWND hwnd\n)\n{\n\tWCHAR general_key[256];\n\tLPENUM_SERVICE_STATUS_PROCESS services;\n\tLPENUM_SERVICE_STATUS_PROCESS service;\n\tEXPLICIT_ACCESS ea;\n\tR_STRINGREF dummy_filename;\n\tPR_STRING converted_path;\n\tPR_STRING name_string;\n\tPR_STRING service_name;\n\tPR_STRING service_path;\n\tPR_BYTE service_sid;\n\tSC_HANDLE hsvcmgr;\n\tPITEM_APP ptr_app;\n\tPVOID service_sd;\n\tPVOID buffer;\n\tHANDLE hkey;\n\tLONG64 service_timestamp;\n\tULONG service_type = SERVICE_WIN32_OWN_PROCESS | SERVICE_WIN32_SHARE_PROCESS;\n\tULONG service_state = SERVICE_STATE_ALL;\n\tULONG services_returned;\n\tULONG return_length;\n\tULONG buffer_size;\n\tULONG sd_length;\n\tULONG app_hash;\n\tNTSTATUS status;\n\n\thsvcmgr = OpenSCManagerW (NULL, NULL, SC_MANAGER_CONNECT | SC_MANAGER_ENUMERATE_SERVICE);\n\n\tif (!hsvcmgr)\n\t{\n\t\t_r_show_errormessage (hwnd, NULL, NtLastError (), L\"OpenSCManagerW\", ET_WINDOWS);\n\n\t\treturn;\n\t}\n\n\t// win10+\n\tif (_r_sys_isosversiongreaterorequal (WINDOWS_10))\n\t\tservice_type |= SERVICE_INTERACTIVE_PROCESS | SERVICE_USER_SERVICE;\n\n\tbuffer_size = PR_SIZE_BUFFER;\n\tbuffer = _r_mem_allocate (buffer_size);\n\n\tif (!EnumServicesStatusExW (hsvcmgr, SC_ENUM_PROCESS_INFO, service_type, service_state, buffer, buffer_size, &return_length, &services_returned, NULL, NULL))\n\t{\n\t\tif (NtLastError () == ERROR_MORE_DATA)\n\t\t{\n\t\t\t// set the buffer\n\t\t\tbuffer_size += return_length;\n\t\t\tbuffer = _r_mem_reallocate (buffer, buffer_size);\n\n\t\t\t// now query again for services\n\t\t\tif (!EnumServicesStatusExW (hsvcmgr, SC_ENUM_PROCESS_INFO, service_type, service_state, buffer, buffer_size, &return_length, &services_returned, NULL, NULL))\n\t\t\t{\n\t\t\t\t_r_mem_free (buffer);\n\n\t\t\t\tbuffer = NULL;\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\t_r_mem_free (buffer);\n\n\t\t\tbuffer = NULL;\n\t\t}\n\t}\n\n\tif (!buffer)\n\t{\n\t\tCloseServiceHandle (hsvcmgr);\n\n\t\treturn;\n\t}\n\n\t// now traverse each service to get information\n\tservices = (LPENUM_SERVICE_STATUS_PROCESS)buffer;\n\n\tfor (ULONG i = 0; i < services_returned; i++)\n\t{\n\t\tservice = &services[i];\n\n\t\tapp_hash = _r_str_gethash2 (service->lpServiceName, TRUE);\n\n\t\tif (_app_isappfound (app_hash))\n\t\t\tcontinue;\n\n\t\t_r_str_printf (general_key, RTL_NUMBER_OF (general_key), L\"System\\\\CurrentControlSet\\\\Services\\\\%s\", service->lpServiceName);\n\n\t\tservice_name = _r_obj_createstring (service->lpServiceName);\n\n\t\tstatus = _r_reg_openkey (HKEY_LOCAL_MACHINE, general_key, 0, KEY_READ, &hkey);\n\n\t\tif (!NT_SUCCESS (status))\n\t\t{\n\t\t\t_r_obj_dereference (service_name);\n\n\t\t\tcontinue;\n\t\t}\n\n\t\t// skip userservice instances service types (win10+)\n\t\tif (_r_sys_isosversiongreaterorequal (WINDOWS_10))\n\t\t{\n\t\t\tstatus = _r_reg_queryulong (hkey, L\"Type\", &service_type);\n\n\t\t\tif (!NT_SUCCESS (status) || (service_type & SERVICE_USERSERVICE_INSTANCE) != 0)\n\t\t\t{\n\t\t\t\t_r_obj_dereference (service_name);\n\n\t\t\t\tNtClose (hkey);\n\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\n\t\t// query service path\n\t\tstatus = _r_reg_querystring (hkey, L\"ImagePath\", &service_path, NULL);\n\n\t\tif (NT_SUCCESS (status))\n\t\t{\n\t\t\t_r_path_parsecommandlinefuzzy (&service_path->sr, &dummy_filename, NULL, &converted_path);\n\n\t\t\tif (converted_path)\n\t\t\t{\n\t\t\t\t_r_obj_movereference ((PVOID_PTR)&service_path, converted_path);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tconverted_path = _r_path_dospathfromnt (&service_path->sr);\n\n\t\t\t\tif (converted_path)\n\t\t\t\t\t_r_obj_movereference ((PVOID_PTR)&service_path, converted_path);\n\t\t\t}\n\n\t\t\t// query service sid\n\t\t\tstatus = _r_sys_getservicesid (service->lpServiceName, &service_sid);\n\n\t\t\tif (NT_SUCCESS (status))\n\t\t\t{\n\t\t\t\t// When evaluating SECURITY_DESCRIPTOR conditions, the filter engine\n\t\t\t\t// checks for FWP_ACTRL_MATCH_FILTER access. If the DACL grants access,\n\t\t\t\t// it does not mean that the traffic is allowed; it just means that the\n\t\t\t\t// condition evaluates to true. Likewise if it denies access, the\n\t\t\t\t// condition evaluates to false.\n\n\t\t\t\t_app_setexplicitaccess (&ea, GRANT_ACCESS, FWP_ACTRL_MATCH_FILTER, NO_INHERITANCE, service_sid->buffer);\n\n\t\t\t\t// Security descriptors must be in self-relative form (i.e., contiguous).\n\t\t\t\t// The security descriptor returned by BuildSecurityDescriptorW is\n\t\t\t\t// already self-relative, but if you're using another mechanism to build\n\t\t\t\t// the descriptor, you may have to convert it. See MakeSelfRelativeSD for\n\t\t\t\t// details.\n\n\t\t\t\tstatus = BuildSecurityDescriptorW (NULL, NULL, 1, &ea, 0, NULL, NULL, &sd_length, &service_sd);\n\n\t\t\t\tif (status == ERROR_SUCCESS && service_sd)\n\t\t\t\t{\n\t\t\t\t\tname_string = _r_obj_createstring (service->lpDisplayName);\n\n\t\t\t\t\tapp_hash = _app_addapplication (NULL, DATA_APP_SERVICE, service_name, name_string, service_path);\n\n\t\t\t\t\tif (app_hash)\n\t\t\t\t\t{\n\t\t\t\t\t\tptr_app = _app_getappitem (app_hash);\n\n\t\t\t\t\t\tif (ptr_app)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t// query service timestamp\n\t\t\t\t\t\t\tstatus = _r_reg_queryinfo (hkey, NULL, &service_timestamp);\n\n\t\t\t\t\t\t\tif (NT_SUCCESS (status))\n\t\t\t\t\t\t\t\t_app_setappinfo (ptr_app, INFO_TIMESTAMP, &service_timestamp);\n\n\t\t\t\t\t\t\t_app_setappinfo (ptr_app, INFO_BYTES_DATA, _r_obj_createbyte_ex (service_sd, sd_length));\n\n\t\t\t\t\t\t\t_r_obj_dereference (ptr_app);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tLocalFree (service_sd);\n\n\t\t\t\t\t_r_obj_dereference (name_string);\n\t\t\t\t}\n\n\t\t\t\t_r_obj_dereference (service_sid);\n\t\t\t}\n\n\t\t\t_r_obj_dereference (service_path);\n\t\t}\n\n\t\t_r_obj_dereference (service_name);\n\n\t\tNtClose (hkey);\n\t}\n\n\t_r_mem_free (buffer);\n\n\tCloseServiceHandle (hsvcmgr);\n}\n"
  },
  {
    "path": "src/packages.h",
    "content": "// simplewall\n// Copyright (c) 2016-2025 Henry++\n\n#pragma once\n\nBOOLEAN _app_package_isnotexists (\n\t_In_ PR_STRING package_sid\n);\n\nVOID _app_package_parsepath (\n\t_Inout_ PR_STRING_PTR package_root_folder\n);\n\nVOID _app_package_getpackagebyname (\n\t_In_ HANDLE hroot,\n\t_In_ LPCWSTR path,\n\t_In_ PR_STRING key_name\n);\n\nVOID _app_package_getpackagebysid (\n\t_In_ HANDLE hroot,\n\t_In_ LPCWSTR path,\n\t_In_ PR_STRING key_name\n);\n\nVOID NTAPI _app_package_threadproc (\n\t_In_ PVOID arglist\n);\n\nVOID _app_package_getpackageslist (\n\t_In_ HWND hwnd\n);\n\nVOID _app_package_getserviceslist (\n\t_In_ HWND hwnd\n);\n"
  },
  {
    "path": "src/profile.c",
    "content": "// simplewall\r\n// Copyright (c) 2016-2026 Henry++\r\n\r\n#include \"global.h\"\r\n\r\n_Success_ (return)\r\nBOOLEAN _app_getappinfo (\r\n\t_In_ PITEM_APP ptr_app,\r\n\t_In_ ENUM_INFO_DATA info_data,\r\n\t_Out_writes_bytes_all_ (length) PVOID buffer,\r\n\t_In_ ULONG_PTR length\r\n)\r\n{\r\n\tRtlZeroMemory (buffer, length);\r\n\r\n\tswitch (info_data)\r\n\t{\r\n\t\tcase INFO_PATH:\r\n\t\t{\r\n\t\t\tPVOID ptr;\r\n\r\n\t\t\tif (length != sizeof (PVOID))\r\n\t\t\t\treturn FALSE;\r\n\r\n\t\t\tif (ptr_app->real_path)\r\n\t\t\t{\r\n\t\t\t\tptr = _r_obj_reference (ptr_app->real_path);\r\n\r\n\t\t\t\tRtlCopyMemory (buffer, &ptr, length);\r\n\r\n\t\t\t\treturn TRUE;\r\n\t\t\t}\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase INFO_DISPLAY_NAME:\r\n\t\t{\r\n\t\t\tPVOID ptr;\r\n\r\n\t\t\tif (length != sizeof (PVOID))\r\n\t\t\t\treturn FALSE;\r\n\r\n\t\t\tif (ptr_app->display_name)\r\n\t\t\t{\r\n\t\t\t\tptr = _r_obj_reference (ptr_app->display_name);\r\n\r\n\t\t\t\tRtlCopyMemory (buffer, &ptr, length);\r\n\r\n\t\t\t\treturn TRUE;\r\n\t\t\t}\r\n\t\t\telse if (ptr_app->original_path)\r\n\t\t\t{\r\n\t\t\t\tptr = _r_obj_reference (ptr_app->original_path);\r\n\r\n\t\t\t\tRtlCopyMemory (buffer, &ptr, length);\r\n\r\n\t\t\t\treturn TRUE;\r\n\t\t\t}\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase INFO_HASH:\r\n\t\t{\r\n\t\t\tPVOID ptr;\r\n\r\n\t\t\tif (length != sizeof (PVOID))\r\n\t\t\t\treturn FALSE;\r\n\r\n\t\t\tif (ptr_app->hash)\r\n\t\t\t{\r\n\t\t\t\tptr = _r_obj_reference (ptr_app->hash);\r\n\r\n\t\t\t\tRtlCopyMemory (buffer, &ptr, length);\r\n\r\n\t\t\t\treturn TRUE;\r\n\t\t\t}\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase INFO_TIMESTAMP:\r\n\t\t{\r\n\t\t\tif (length != sizeof (LONG64))\r\n\t\t\t\treturn FALSE;\r\n\r\n\t\t\tRtlCopyMemory (buffer, &ptr_app->timestamp, length);\r\n\r\n\t\t\treturn TRUE;\r\n\t\t}\r\n\r\n\t\tcase INFO_TIMER:\r\n\t\t{\r\n\t\t\tif (length != sizeof (LONG64))\r\n\t\t\t\treturn FALSE;\r\n\r\n\t\t\tRtlCopyMemory (buffer, &ptr_app->timer, length);\r\n\r\n\t\t\treturn TRUE;\r\n\t\t}\r\n\r\n\t\tcase INFO_LISTVIEW_ID:\r\n\t\t{\r\n\t\t\tINT listview_id;\r\n\r\n\t\t\tif (length != sizeof (INT))\r\n\t\t\t\treturn FALSE;\r\n\r\n\t\t\tlistview_id = _app_listview_getbytype (ptr_app->type);\r\n\r\n\t\t\tRtlCopyMemory (buffer, &listview_id, length);\r\n\r\n\t\t\treturn TRUE;\r\n\t\t}\r\n\r\n\t\tcase INFO_IS_ENABLED:\r\n\t\t{\r\n\t\t\tBOOLEAN is_enabled;\r\n\r\n\t\t\tif (length != sizeof (BOOLEAN))\r\n\t\t\t\treturn FALSE;\r\n\r\n\t\t\tis_enabled = (ptr_app->is_enabled != 0);\r\n\r\n\t\t\tRtlCopyMemory (buffer, &is_enabled, length);\r\n\r\n\t\t\treturn TRUE;\r\n\t\t}\r\n\r\n\t\tcase INFO_IS_SILENT:\r\n\t\t{\r\n\t\t\tBOOLEAN is_silent;\r\n\r\n\t\t\tif (length != sizeof (BOOLEAN))\r\n\t\t\t\treturn FALSE;\r\n\r\n\t\t\tis_silent = (ptr_app->is_silent != 0);\r\n\r\n\t\t\tRtlCopyMemory (buffer, &is_silent, length);\r\n\r\n\t\t\treturn TRUE;\r\n\t\t}\r\n\r\n\t\tcase INFO_IS_UNDELETABLE:\r\n\t\t{\r\n\t\t\tBOOLEAN is_undeletable;\r\n\r\n\t\t\tif (length != sizeof (BOOLEAN))\r\n\t\t\t\treturn FALSE;\r\n\r\n\t\t\tis_undeletable = (ptr_app->is_undeletable != 0);\r\n\r\n\t\t\tRtlCopyMemory (buffer, &is_undeletable, length);\r\n\r\n\t\t\treturn TRUE;\r\n\t\t}\r\n\r\n\t\tdefault:\r\n\t\t{\r\n\t\t\tFALLTHROUGH;\r\n\t\t}\r\n\t}\r\n\r\n\treturn FALSE;\r\n}\r\n\r\n_Success_ (return)\r\nBOOLEAN _app_getappinfobyhash (\r\n\t_In_ ULONG app_hash,\r\n\t_In_ ENUM_INFO_DATA info_data,\r\n\t_Out_writes_bytes_all_ (length) PVOID buffer,\r\n\t_In_ ULONG_PTR length\r\n)\r\n{\r\n\tPITEM_APP ptr_app;\r\n\tBOOLEAN is_success;\r\n\r\n\tRtlZeroMemory (buffer, length);\r\n\r\n\tptr_app = _app_getappitem (app_hash);\r\n\r\n\tif (!ptr_app)\r\n\t\treturn FALSE;\r\n\r\n\tis_success = _app_getappinfo (ptr_app, info_data, buffer, length);\r\n\r\n\t_r_obj_dereference (ptr_app);\r\n\r\n\treturn is_success;\r\n}\r\n\r\nVOID _app_setappinfo (\r\n\t_In_ PITEM_APP ptr_app,\r\n\t_In_ ENUM_INFO_DATA info_data,\r\n\t_In_opt_ PVOID value\r\n)\r\n{\r\n\tswitch (info_data)\r\n\t{\r\n\t\tcase INFO_BYTES_DATA:\r\n\t\t{\r\n\t\t\t_r_obj_movereference ((PVOID_PTR)&ptr_app->bytes, value);\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase INFO_COMMENT:\r\n\t\t{\r\n\t\t\t_r_obj_movereference ((PVOID_PTR)&ptr_app->comment, value);\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase INFO_HASH:\r\n\t\t{\r\n\t\t\t_r_obj_movereference ((PVOID_PTR)&ptr_app->hash, value);\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase INFO_TIMESTAMP:\r\n\t\t{\r\n\t\t\tif (!value)\r\n\t\t\t\tbreak;\r\n\r\n\t\t\tptr_app->timestamp = *((PLONG64)value);\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase INFO_TIMER:\r\n\t\t{\r\n\t\t\tHANDLE engine_handle;\r\n\t\t\tLONG64 timestamp;\r\n\r\n\t\t\tif (!value)\r\n\t\t\t\tbreak;\r\n\r\n\t\t\ttimestamp = *((PLONG64)value);\r\n\r\n\t\t\t// check timer expiration\r\n\t\t\tif (timestamp <= _r_unixtime_now ())\r\n\t\t\t{\r\n\t\t\t\tengine_handle = _wfp_getenginehandle ();\r\n\r\n\t\t\t\t_wfp_destroyfilters_array (engine_handle, ptr_app->guids, DBG_ARG);\r\n\r\n\t\t\t\t_r_obj_cleararray (ptr_app->guids);\r\n\r\n\t\t\t\tptr_app->timer = 0;\r\n\t\t\t\tptr_app->is_enabled = FALSE;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tptr_app->timer = timestamp;\r\n\t\t\t\tptr_app->is_enabled = TRUE;\r\n\t\t\t}\r\n\r\n\t\t\t_app_listview_updateitemby_param (_r_app_gethwnd (), ptr_app->app_hash, TRUE);\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase INFO_DISABLE:\r\n\t\t{\r\n\t\t\tHANDLE engine_handle;\r\n\r\n\t\t\tptr_app->is_enabled = FALSE;\r\n\r\n\t\t\tengine_handle = _wfp_getenginehandle ();\r\n\r\n\t\t\t_wfp_destroyfilters_array (engine_handle, ptr_app->guids, DBG_ARG);\r\n\r\n\t\t\t_r_obj_cleararray (ptr_app->guids);\r\n\r\n\t\t\t_app_listview_updateitemby_param (_r_app_gethwnd (), ptr_app->app_hash, TRUE);\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase INFO_IS_ENABLED:\r\n\t\t{\r\n\t\t\tptr_app->is_enabled = (PtrToLong (value) ? TRUE : FALSE);\r\n\r\n\t\t\t_app_listview_updateitemby_param (_r_app_gethwnd (), ptr_app->app_hash, TRUE);\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase INFO_IS_SILENT:\r\n\t\t{\r\n\t\t\tptr_app->is_silent = (PtrToLong (value) ? TRUE : FALSE);\r\n\r\n\t\t\tif (ptr_app->is_silent)\r\n\t\t\t\t_app_notify_freeobject (NULL, ptr_app);\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase INFO_IS_UNDELETABLE:\r\n\t\t{\r\n\t\t\tptr_app->is_undeletable = (PtrToLong (value) ? TRUE : FALSE);\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tdefault:\r\n\t\t{\r\n\t\t\tFALLTHROUGH;\r\n\t\t}\r\n\t}\r\n}\r\n\r\nVOID _app_setappinfobyhash (\r\n\t_In_ ULONG app_hash,\r\n\t_In_ ENUM_INFO_DATA info_data,\r\n\t_In_opt_ PVOID value\r\n)\r\n{\r\n\tPITEM_APP ptr_app;\r\n\r\n\tptr_app = _app_getappitem (app_hash);\r\n\r\n\tif (!ptr_app)\r\n\t\treturn;\r\n\r\n\t_app_setappinfo (ptr_app, info_data, value);\r\n\r\n\t_r_obj_dereference (ptr_app);\r\n}\r\n\r\n_Success_ (return)\r\nBOOLEAN _app_getruleinfo (\r\n\t_In_ PITEM_RULE ptr_rule,\r\n\t_In_ ENUM_INFO_DATA info_data,\r\n\t_Out_writes_bytes_all_ (length) PVOID buffer,\r\n\t_In_ ULONG_PTR length\r\n)\r\n{\r\n\tRtlZeroMemory (buffer, length);\r\n\r\n\tswitch (info_data)\r\n\t{\r\n\t\tcase INFO_LISTVIEW_ID:\r\n\t\t{\r\n\t\t\tINT listview_id;\r\n\r\n\t\t\tif (length != sizeof (INT))\r\n\t\t\t\treturn FALSE;\r\n\r\n\t\t\tlistview_id = _app_listview_getbytype (ptr_rule->type);\r\n\r\n\t\t\tRtlCopyMemory (buffer, &listview_id, length);\r\n\r\n\t\t\treturn TRUE;\r\n\t\t}\r\n\r\n\t\tcase INFO_IS_READONLY:\r\n\t\t{\r\n\t\t\tINT is_readonly;\r\n\r\n\t\t\tif (length != sizeof (INT))\r\n\t\t\t\treturn FALSE;\r\n\r\n\t\t\tis_readonly = !!ptr_rule->is_readonly;\r\n\r\n\t\t\tRtlCopyMemory (buffer, &is_readonly, length);\r\n\r\n\t\t\treturn TRUE;\r\n\t\t}\r\n\r\n\t\tdefault:\r\n\t\t{\r\n\t\t\tFALLTHROUGH;\r\n\t\t}\r\n\t}\r\n\r\n\treturn FALSE;\r\n}\r\n\r\n_Success_ (return)\r\nBOOLEAN _app_getruleinfobyid (\r\n\t_In_ ULONG_PTR index,\r\n\t_In_ ENUM_INFO_DATA info_data,\r\n\t_Out_writes_bytes_all_ (length) PVOID buffer,\r\n\t_In_ ULONG_PTR length\r\n)\r\n{\r\n\tPITEM_RULE ptr_rule;\r\n\tBOOLEAN is_success;\r\n\r\n\tptr_rule = _app_getrulebyid (index);\r\n\r\n\tif (!ptr_rule)\r\n\t\treturn FALSE;\r\n\r\n\tis_success = _app_getruleinfo (ptr_rule, info_data, buffer, length);\r\n\r\n\t_r_obj_dereference (ptr_rule);\r\n\r\n\treturn is_success;\r\n}\r\n\r\n_Success_ (return != 0)\r\nULONG _app_addapplication (\r\n\t_In_opt_ HWND hwnd,\r\n\t_In_ ENUM_TYPE_DATA type,\r\n\t_In_ PR_STRING path,\r\n\t_In_opt_ PR_STRING display_name,\r\n\t_In_opt_ PR_STRING real_path\r\n)\r\n{\r\n\tWCHAR path_full[0x400];\r\n\tR_STRINGREF path_sr;\r\n\tPITEM_APP ptr_app;\r\n\tULONG app_hash;\r\n\tBOOLEAN is_ntoskrnl;\r\n\r\n\tif (_r_obj_isstringempty2 (path))\r\n\t\treturn 0;\r\n\r\n\tif (_app_isappvalidpath (path) && _r_fs_isdirectory (&path->sr))\r\n\t\treturn 0;\r\n\r\n\t_r_obj_initializestringref2 (&path_sr, &path->sr);\r\n\r\n\t// prevent possible duplicate apps entries with short path (issue #640)\r\n\tif (_r_str_findchar (&path_sr, L'~', FALSE) != SIZE_MAX)\r\n\t{\r\n\t\tif (GetLongPathNameW (path_sr.buffer, path_full, RTL_NUMBER_OF (path_full)))\r\n\t\t\t_r_obj_initializestringref (&path_sr, path_full);\r\n\t}\r\n\r\n\tapp_hash = _r_str_gethash (&path_sr, TRUE);\r\n\r\n\tif (_app_isappfound (app_hash))\r\n\t\treturn app_hash; // already exists\r\n\r\n\tptr_app = _r_obj_allocate (sizeof (ITEM_APP), &_app_dereferenceapp);\r\n\tis_ntoskrnl = (app_hash == config.ntoskrnl_hash);\r\n\r\n\tptr_app->app_hash = app_hash;\r\n\r\n\tif (type == DATA_UNKNOWN)\r\n\t{\r\n\t\tif (_r_str_isstartswith2 (&path_sr, L\"S-1-\", TRUE)) // uwp (win8+)\r\n\t\t\ttype = DATA_APP_UWP;\r\n\t}\r\n\r\n\tif (type == DATA_APP_SERVICE || type == DATA_APP_UWP)\r\n\t{\r\n\t\tptr_app->type = type;\r\n\r\n\t\tif (display_name)\r\n\t\t\tptr_app->display_name = _r_obj_reference (display_name);\r\n\r\n\t\tif (real_path)\r\n\t\t\tptr_app->real_path = _r_obj_reference (real_path);\r\n\t}\r\n\telse if (_r_str_isstartswith2 (&path_sr, L\"\\\\device\\\\\", TRUE)) // device path\r\n\t{\r\n\t\tptr_app->type = DATA_APP_DEVICE;\r\n\t\tptr_app->real_path = _r_obj_createstring2 (&path_sr);\r\n\t}\r\n\telse\r\n\t{\r\n\t\tif (!is_ntoskrnl && _r_str_findchar (&path_sr, OBJ_NAME_PATH_SEPARATOR, FALSE) == SIZE_MAX)\r\n\t\t{\r\n\t\t\tptr_app->type = DATA_APP_PICO;\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tptr_app->type = PathIsNetworkPathW (path_sr.buffer) ? DATA_APP_NETWORK : DATA_APP_REGULAR;\r\n\t\t}\r\n\r\n\t\tif (is_ntoskrnl)\r\n\t\t{\r\n\t\t\tptr_app->real_path = _r_obj_createstring2 (&config.ntoskrnl_path->sr);\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tptr_app->real_path = _r_obj_createstring2 (&path_sr);\r\n\t\t}\r\n\t}\r\n\r\n\tptr_app->original_path = _r_obj_createstring2 (&path_sr);\r\n\r\n\t// fix \"System\" lowercase\r\n\tif (is_ntoskrnl)\r\n\t{\r\n\t\t_r_str_tolower (&ptr_app->original_path->sr);\r\n\r\n\t\tptr_app->original_path->buffer[0] = _r_str_upper (ptr_app->original_path->buffer[0]);\r\n\t}\r\n\r\n\t//if (ptr_app->type == DATA_APP_REGULAR || ptr_app->type == DATA_APP_DEVICE || ptr_app->type == DATA_APP_NETWORK)\r\n\t{\r\n\t\tptr_app->short_name = _r_path_getbasenamestring (&path_sr);\r\n\t}\r\n\r\n\tptr_app->guids = _r_obj_createarray (sizeof (GUID), 0x04, NULL); // initialize guids array\r\n\tptr_app->timestamp = _r_unixtime_now ();\r\n\r\n\t// insert object into the table\r\n\t//\r\n\t//_r_queuedlock_acquireexclusive (&lock_apps);\r\n\t_r_obj_addhashtablepointer (apps_table, app_hash, ptr_app);\r\n\t//_r_queuedlock_releaseexclusive (&lock_apps);\r\n\r\n\t// insert item\r\n\tif (hwnd)\r\n\t\t_app_listview_addappitem (hwnd, ptr_app);\r\n\r\n\t// queue file information\r\n\tif (!_r_obj_isstringempty (ptr_app->real_path))\r\n\t\t_app_getfileinformation (ptr_app->real_path, app_hash, ptr_app->type, _app_listview_getbytype (ptr_app->type));\r\n\r\n\treturn app_hash;\r\n}\r\n\r\nPITEM_RULE _app_addrule (\r\n\t_In_opt_ PR_STRING name,\r\n\t_In_opt_ PR_STRING rule_remote,\r\n\t_In_opt_ PR_STRING rule_local,\r\n\t_In_ FWP_DIRECTION direction,\r\n\t_In_ FWP_ACTION_TYPE action,\r\n\t_In_ UINT8 protocol,\r\n\t_In_ ADDRESS_FAMILY af\r\n)\r\n{\r\n\tPITEM_RULE ptr_rule;\r\n\r\n\tptr_rule = _r_obj_allocate (sizeof (ITEM_RULE), &_app_dereferencerule);\r\n\r\n\tptr_rule->apps = _r_obj_createhashtable (sizeof (SHORT), 4, NULL); // initialize hashtable\r\n\tptr_rule->guids = _r_obj_createarray (sizeof (GUID), 4, NULL); // initialize array\r\n\r\n\tptr_rule->type = DATA_RULE_USER;\r\n\r\n\t// set rule name\r\n\tif (name)\r\n\t{\r\n\t\tptr_rule->name = _r_obj_reference (name);\r\n\r\n\t\tif (_r_str_getlength2 (&ptr_rule->name->sr) > RULE_NAME_CCH_MAX)\r\n\t\t\t_r_str_setlength (&ptr_rule->name->sr, RULE_NAME_CCH_MAX * sizeof (WCHAR));\r\n\t}\r\n\r\n\t// set rule destination\r\n\tif (rule_remote)\r\n\t{\r\n\t\tptr_rule->rule_remote = _r_obj_reference (rule_remote);\r\n\r\n\t\tif (_r_str_getlength2 (&ptr_rule->rule_remote->sr) > RULE_RULE_CCH_MAX)\r\n\t\t\t_r_str_setlength (&ptr_rule->rule_remote->sr, RULE_RULE_CCH_MAX * sizeof (WCHAR));\r\n\t}\r\n\r\n\t// set rule source\r\n\tif (rule_local)\r\n\t{\r\n\t\tptr_rule->rule_local = _r_obj_reference (rule_local);\r\n\r\n\t\tif (_r_str_getlength2 (&ptr_rule->rule_local->sr) > RULE_RULE_CCH_MAX)\r\n\t\t\t_r_str_setlength (&ptr_rule->rule_local->sr, RULE_RULE_CCH_MAX * sizeof (WCHAR));\r\n\t}\r\n\r\n\t// set configuration\r\n\tptr_rule->direction = direction;\r\n\tptr_rule->action = action;\r\n\tptr_rule->protocol = protocol;\r\n\tptr_rule->af = af;\r\n\r\n\tptr_rule->protocol_str = _r_obj_createstring (_app_db_getprotoname (protocol, af));\r\n\r\n\treturn ptr_rule;\r\n}\r\n\r\n_Ret_maybenull_\r\nPITEM_RULE_CONFIG _app_addruleconfigtable (\r\n\t_In_ PR_HASHTABLE hashtable,\r\n\t_In_ ULONG rule_hash,\r\n\t_In_ PR_STRING rule_name,\r\n\t_In_ BOOLEAN is_enabled\r\n)\r\n{\r\n\tITEM_RULE_CONFIG entry = {0};\r\n\r\n\tentry.name = _r_obj_reference (rule_name);\r\n\tentry.is_enabled = is_enabled;\r\n\r\n\treturn _r_obj_addhashtableitem (hashtable, rule_hash, &entry);\r\n}\r\n\r\n_Ret_maybenull_\r\nPITEM_APP _app_getappitem (\r\n\t_In_ ULONG app_hash\r\n)\r\n{\r\n\tPITEM_APP ptr_app;\r\n\r\n\t_r_queuedlock_acquireshared (&lock_apps);\r\n\tptr_app = _r_obj_findhashtablepointer (apps_table, app_hash);\r\n\t_r_queuedlock_releaseshared (&lock_apps);\r\n\r\n\treturn ptr_app;\r\n}\r\n\r\n_Ret_maybenull_\r\nPITEM_RULE _app_getrulebyid (\r\n\t_In_ ULONG_PTR index\r\n)\r\n{\r\n\tPITEM_RULE ptr_rule;\r\n\r\n\t_r_queuedlock_acquireshared (&lock_rules);\r\n\r\n\tif (index < _r_obj_getlistsize (rules_list))\r\n\t{\r\n\t\tptr_rule = _r_obj_getlistitem (rules_list, index);\r\n\t}\r\n\telse\r\n\t{\r\n\t\tptr_rule = NULL;\r\n\t}\r\n\r\n\t_r_queuedlock_releaseshared (&lock_rules);\r\n\r\n\tif (ptr_rule)\r\n\t\treturn _r_obj_reference (ptr_rule);\r\n\r\n\treturn NULL;\r\n}\r\n\r\n_Ret_maybenull_\r\nPITEM_RULE _app_getrulebyhash (\r\n\t_In_ ULONG_PTR rule_hash\r\n)\r\n{\r\n\tPITEM_RULE ptr_rule;\r\n\r\n\tif (!rule_hash)\r\n\t\treturn NULL;\r\n\r\n\t_r_queuedlock_acquireshared (&lock_rules);\r\n\r\n\tfor (ULONG_PTR i = 0; i < _r_obj_getlistsize (rules_list); i++)\r\n\t{\r\n\t\tptr_rule = _r_obj_getlistitem (rules_list, i);\r\n\r\n\t\tif (ptr_rule)\r\n\t\t{\r\n\t\t\tif (ptr_rule->is_readonly)\r\n\t\t\t{\r\n\t\t\t\tif (_r_str_gethash (&ptr_rule->name->sr, TRUE) == rule_hash)\r\n\t\t\t\t{\r\n\t\t\t\t\t_r_queuedlock_releaseshared (&lock_rules);\r\n\r\n\t\t\t\t\treturn _r_obj_reference (ptr_rule);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t_r_queuedlock_releaseshared (&lock_rules);\r\n\r\n\treturn NULL;\r\n}\r\n\r\n_Ret_maybenull_\r\nPITEM_RULE_CONFIG _app_getruleconfigitem (\r\n\t_In_ ULONG rule_hash\r\n)\r\n{\r\n\tPITEM_RULE_CONFIG ptr_rule_config;\r\n\r\n\t_r_queuedlock_acquireshared (&lock_rules_config);\r\n\tptr_rule_config = _r_obj_findhashtable (rules_config, rule_hash);\r\n\t_r_queuedlock_releaseshared (&lock_rules_config);\r\n\r\n\treturn ptr_rule_config;\r\n}\r\n\r\n_Ret_maybenull_\r\nPITEM_LOG _app_getlogitem (\r\n\t_In_ ULONG log_hash\r\n)\r\n{\r\n\tPITEM_LOG ptr_log;\r\n\r\n\t_r_queuedlock_acquireshared (&lock_loglist);\r\n\tptr_log = _r_obj_findhashtablepointer (log_table, log_hash);\r\n\t_r_queuedlock_releaseshared (&lock_loglist);\r\n\r\n\treturn ptr_log;\r\n}\r\n\r\n_Success_ (return != 0)\r\nULONG _app_getlogapp (\r\n\t_In_ ULONG index\r\n)\r\n{\r\n\tPITEM_LOG ptr_log;\r\n\tULONG app_hash;\r\n\r\n\tptr_log = _app_getlogitem (index);\r\n\r\n\tif (ptr_log)\r\n\t{\r\n\t\tapp_hash = ptr_log->app_hash;\r\n\r\n\t\t_r_obj_dereference (ptr_log);\r\n\r\n\t\treturn app_hash;\r\n\t}\r\n\r\n\treturn 0;\r\n}\r\n\r\nCOLORREF _app_getappcolor (\r\n\t_In_ INT listview_id,\r\n\t_In_ ULONG app_hash,\r\n\t_In_ BOOLEAN is_systemapp,\r\n\t_In_ BOOLEAN is_validconnection\r\n)\r\n{\r\n\tPITEM_APP ptr_app;\r\n\tULONG color_hash = 0;\r\n\tBOOLEAN is_profilelist;\r\n\tBOOLEAN is_networklist;\r\n\r\n\tptr_app = _app_getappitem (app_hash);\r\n\r\n\tis_profilelist = (listview_id >= IDC_APPS_PROFILE && listview_id <= IDC_RULES_CUSTOM);\r\n\tis_networklist = (listview_id == IDC_NETWORK || listview_id == IDC_LOG);\r\n\r\n\tif (ptr_app && !is_networklist)\r\n\t{\r\n\t\tif (_r_config_getboolean (L\"IsHighlightInvalid\", TRUE, L\"colors\") && !_app_isappexists (ptr_app))\r\n\t\t{\r\n\t\t\tcolor_hash = config.color_invalid;\r\n\r\n\t\t\tgoto CleanupExit;\r\n\t\t}\r\n\t}\r\n\r\n\tif (_r_config_getboolean (L\"IsHighlightConnection\", TRUE, L\"colors\") && is_validconnection)\r\n\t{\r\n\t\tcolor_hash = config.color_network;\r\n\r\n\t\tgoto CleanupExit;\r\n\t}\r\n\r\n\tif (_r_config_getboolean (L\"IsHighlightSigned\", TRUE, L\"colors\") && _app_isappsigned (app_hash))\r\n\t{\r\n\t\tcolor_hash = config.color_signed;\r\n\r\n\t\tgoto CleanupExit;\r\n\t}\r\n\r\n\tif (ptr_app)\r\n\t{\r\n\t\tif (!is_profilelist && (_r_config_getboolean (L\"IsHighlightSpecial\", TRUE, L\"colors\") && _app_isapphaverule (app_hash, FALSE)))\r\n\t\t{\r\n\t\t\tcolor_hash = config.color_special;\r\n\r\n\t\t\tgoto CleanupExit;\r\n\t\t}\r\n\r\n\t\tif (_r_config_getboolean (L\"IsHighlightPico\", TRUE, L\"colors\") && ptr_app->type == DATA_APP_PICO)\r\n\t\t{\r\n\t\t\tcolor_hash = config.color_pico;\r\n\r\n\t\t\tgoto CleanupExit;\r\n\t\t}\r\n\r\n\t\tif (_r_config_getboolean (L\"IsHighlightUndelete\", TRUE, L\"colors\") && ptr_app->is_undeletable)\r\n\t\t{\r\n\t\t\tcolor_hash = config.color_nonremovable;\r\n\r\n\t\t\tgoto CleanupExit;\r\n\t\t}\r\n\t}\r\n\r\n\tif (_r_config_getboolean (L\"IsHighlightSystem\", TRUE, L\"colors\") && is_systemapp)\r\n\t{\r\n\t\tcolor_hash = config.color_system;\r\n\r\n\t\tgoto CleanupExit;\r\n\t}\r\n\r\nCleanupExit:\r\n\r\n\tif (ptr_app)\r\n\t\t_r_obj_dereference (ptr_app);\r\n\r\n\tif (color_hash)\r\n\t\treturn _app_getcolorvalue (color_hash);\r\n\r\n\treturn 0;\r\n}\r\n\r\nVOID _app_deleteappitem (\r\n\t_In_ HWND hwnd,\r\n\t_In_ ENUM_TYPE_DATA type,\r\n\t_In_ ULONG_PTR id_code\r\n)\r\n{\r\n\tINT listview_id;\r\n\tINT item_id;\r\n\r\n\tlistview_id = _app_listview_getbytype (type);\r\n\r\n\tif (!listview_id)\r\n\t\treturn;\r\n\r\n\titem_id = _app_listview_finditem (hwnd, listview_id, id_code);\r\n\r\n\tif (item_id != INT_ERROR)\r\n\t\t_r_listview_deleteitem (hwnd, listview_id, item_id);\r\n}\r\n\r\nVOID _app_freeapplication (\r\n\t_In_opt_ HWND hwnd,\r\n\t_In_ ULONG app_hash\r\n)\r\n{\r\n\tPITEM_RULE ptr_rule;\r\n\r\n\t_r_queuedlock_acquireshared (&lock_rules);\r\n\r\n\tfor (ULONG_PTR i = 0; i < _r_obj_getlistsize (rules_list); i++)\r\n\t{\r\n\t\tptr_rule = _r_obj_getlistitem (rules_list, i);\r\n\r\n\t\tif (!ptr_rule)\r\n\t\t\tcontinue;\r\n\r\n\t\tif (ptr_rule->type != DATA_RULE_USER)\r\n\t\t\tcontinue;\r\n\r\n\t\tif (hwnd)\r\n\t\t\t_app_ruleremoveapp (hwnd, i, ptr_rule, app_hash);\r\n\t}\r\n\r\n\t_r_queuedlock_releaseshared (&lock_rules);\r\n\r\n\t_r_obj_removehashtableitem (apps_table, app_hash);\r\n}\r\n\r\nVOID _app_getcount (\r\n\t_Out_ PITEM_STATUS status\r\n)\r\n{\r\n\tPITEM_APP ptr_app = NULL;\r\n\tPITEM_RULE ptr_rule;\r\n\tULONG_PTR enum_key = 0;\r\n\tBOOLEAN is_used;\r\n\r\n\tRtlZeroMemory (status, sizeof (ITEM_STATUS));\r\n\r\n\t_r_queuedlock_acquireshared (&lock_apps);\r\n\r\n\twhile (_r_obj_enumhashtablepointer (apps_table, (PVOID_PTR)&ptr_app, NULL, &enum_key))\r\n\t{\r\n\t\tis_used = _app_isappused (ptr_app);\r\n\r\n\t\tif (_app_istimerset (ptr_app))\r\n\t\t\tstatus->apps_timer_count += 1;\r\n\r\n\t\tif (!ptr_app->is_undeletable && (!_app_isappexists (ptr_app) || !is_used) && !(ptr_app->type == DATA_APP_SERVICE || ptr_app->type == DATA_APP_UWP))\r\n\t\t\tstatus->apps_unused_count += 1;\r\n\r\n\t\tif (is_used)\r\n\t\t\tstatus->apps_count += 1;\r\n\t}\r\n\r\n\t_r_queuedlock_releaseshared (&lock_apps);\r\n\r\n\t_r_queuedlock_acquireshared (&lock_rules);\r\n\r\n\tfor (ULONG_PTR i = 0; i < _r_obj_getlistsize (rules_list); i++)\r\n\t{\r\n\t\tptr_rule = _r_obj_getlistitem (rules_list, i);\r\n\r\n\t\tif (!ptr_rule)\r\n\t\t\tcontinue;\r\n\r\n\t\tif (ptr_rule->type == DATA_RULE_USER)\r\n\t\t{\r\n\t\t\tif (ptr_rule->is_enabled && !_r_obj_isempty (ptr_rule->apps))\r\n\t\t\t\tstatus->rules_global_count += 1;\r\n\r\n\t\t\tif (ptr_rule->is_readonly)\r\n\t\t\t{\r\n\t\t\t\tstatus->rules_predefined_count += 1;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tstatus->rules_user_count += 1;\r\n\t\t\t}\r\n\r\n\t\t\tstatus->rules_count += 1;\r\n\t\t}\r\n\t}\r\n\r\n\t_r_queuedlock_releaseshared (&lock_rules);\r\n}\r\n\r\nCOLORREF _app_getrulecolor (\r\n\t_In_ INT listview_id,\r\n\t_In_ ULONG_PTR rule_idx\r\n)\r\n{\r\n\tPITEM_RULE ptr_rule;\r\n\tULONG color_hash = 0;\r\n\r\n\tptr_rule = _app_getrulebyid (rule_idx);\r\n\r\n\tif (!ptr_rule)\r\n\t\treturn 0;\r\n\r\n\tif (_r_config_getboolean (L\"IsHighlightInvalid\", TRUE, L\"colors\") && ptr_rule->is_enabled && ptr_rule->is_haveerrors)\r\n\t{\r\n\t\tcolor_hash = config.color_invalid;\r\n\t}\r\n\telse if (_r_config_getboolean (L\"IsHighlightSpecial\", TRUE, L\"colors\") && (ptr_rule->is_forservices || !_r_obj_isempty (ptr_rule->apps)))\r\n\t{\r\n\t\tcolor_hash = config.color_special;\r\n\t}\r\n\r\n\t_r_obj_dereference (ptr_rule);\r\n\r\n\tif (color_hash)\r\n\t\treturn _app_getcolorvalue (color_hash);\r\n\r\n\treturn 0;\r\n}\r\n\r\nVOID _app_setappiteminfo (\r\n\t_In_ HWND hwnd,\r\n\t_In_ INT listview_id,\r\n\t_In_ INT item_id,\r\n\t_In_ PITEM_APP ptr_app\r\n)\r\n{\r\n\t_r_listview_setitem (hwnd, listview_id, item_id, 0, LPSTR_TEXTCALLBACK, I_IMAGECALLBACK, I_GROUPIDCALLBACK, I_DEFAULT);\r\n\r\n\t_r_listview_setitemcheck (hwnd, listview_id, item_id, !!ptr_app->is_enabled);\r\n}\r\n\r\nVOID _app_setruleiteminfo (\r\n\t_In_ HWND hwnd,\r\n\t_In_ INT listview_id,\r\n\t_In_ INT item_id,\r\n\t_In_ PITEM_RULE ptr_rule,\r\n\t_In_ BOOLEAN include_apps\r\n)\r\n{\r\n\tULONG_PTR enum_key = 0;\r\n\tULONG hash_code;\r\n\r\n\t_r_listview_setitem (hwnd, listview_id, item_id, 0, LPSTR_TEXTCALLBACK, I_IMAGECALLBACK, I_GROUPIDCALLBACK, I_DEFAULT);\r\n\r\n\t_r_listview_setitemcheck (hwnd, listview_id, item_id, !!ptr_rule->is_enabled);\r\n\r\n\tif (!include_apps)\r\n\t\treturn;\r\n\r\n\twhile (_r_obj_enumhashtable (ptr_rule->apps, NULL, &hash_code, &enum_key))\r\n\t{\r\n\t\t_app_listview_updateitemby_param (hwnd, hash_code, TRUE);\r\n\t}\r\n}\r\n\r\nVOID _app_ruleenable (\r\n\t_Inout_ PITEM_RULE ptr_rule,\r\n\t_In_ BOOLEAN is_enable,\r\n\t_In_ BOOLEAN is_createconfig\r\n)\r\n{\r\n\tPITEM_RULE_CONFIG ptr_config;\r\n\tULONG rule_hash;\r\n\r\n\tptr_rule->is_enabled = is_enable;\r\n\r\n\tif (!ptr_rule->is_readonly || !ptr_rule->name)\r\n\t\treturn;\r\n\r\n\trule_hash = _r_str_gethash (&ptr_rule->name->sr, TRUE);\r\n\r\n\tif (!rule_hash)\r\n\t\treturn;\r\n\r\n\tptr_config = _app_getruleconfigitem (rule_hash);\r\n\r\n\tif (ptr_config)\r\n\t{\r\n\t\tptr_config->is_enabled = is_enable;\r\n\t}\r\n\telse\r\n\t{\r\n\t\tif (is_createconfig)\r\n\t\t{\r\n\t\t\t_r_queuedlock_acquireexclusive (&lock_rules_config);\r\n\t\t\tptr_config = _app_addruleconfigtable (rules_config, rule_hash, ptr_rule->name, is_enable);\r\n\t\t\t_r_queuedlock_releaseexclusive (&lock_rules_config);\r\n\r\n\t\t\tif (ptr_config)\r\n\t\t\t\tptr_config->is_enabled = is_enable;\r\n\t\t}\r\n\t}\r\n}\r\n\r\nVOID _app_ruleremoveapp (\r\n\t_In_opt_ HWND hwnd,\r\n\t_In_ ULONG_PTR item_id,\r\n\t_In_ PITEM_RULE ptr_rule,\r\n\t_In_ ULONG app_hash\r\n)\r\n{\r\n\tif (!ptr_rule->apps)\r\n\t\treturn;\r\n\r\n\tif (!_r_obj_removehashtableitem (ptr_rule->apps, app_hash))\r\n\t\treturn;\r\n\r\n\tif (ptr_rule->is_enabled && _r_obj_isempty (ptr_rule->apps))\r\n\t{\r\n\t\tptr_rule->is_enabled = FALSE;\r\n\t\tptr_rule->is_haveerrors = FALSE;\r\n\r\n\t\tif (hwnd)\r\n\t\t{\r\n\t\t\tif (item_id != SIZE_MAX)\r\n\t\t\t\t_app_listview_updateitemby_param (hwnd, item_id, FALSE);\r\n\t\t}\r\n\t}\r\n}\r\n\r\nBOOLEAN _app_ruleblocklistsetchange (\r\n\t_Inout_ PITEM_RULE ptr_rule,\r\n\t_In_ LONG new_state\r\n)\r\n{\r\n\tBOOLEAN is_block;\r\n\r\n\tif (new_state == INT_ERROR)\r\n\t\treturn FALSE; // don't change\r\n\r\n\tif (new_state == 0 && !ptr_rule->is_enabled)\r\n\t\treturn FALSE; // not changed\r\n\r\n\tis_block = (ptr_rule->action == FWP_ACTION_BLOCK);\r\n\r\n\tif (new_state == 1 && ptr_rule->is_enabled && !is_block)\r\n\t\treturn FALSE; // not changed\r\n\r\n\tif (new_state == 2 && ptr_rule->is_enabled && is_block)\r\n\t\treturn FALSE; // not changed\r\n\r\n\tptr_rule->action = (new_state != 1) ? FWP_ACTION_BLOCK : FWP_ACTION_PERMIT;\r\n\r\n\tptr_rule->is_enabled_default = ptr_rule->is_enabled; // set default value for rule\r\n\tptr_rule->is_enabled = (new_state != 0);\r\n\r\n\treturn TRUE;\r\n}\r\n\r\nBOOLEAN _app_ruleblocklistsetstate (\r\n\t_Inout_ PITEM_RULE ptr_rule,\r\n\t_In_ LONG spy_state,\r\n\t_In_ LONG update_state,\r\n\t_In_ LONG extra_state\r\n)\r\n{\r\n\tif (ptr_rule->type != DATA_RULE_BLOCKLIST || _r_obj_isstringempty (ptr_rule->name))\r\n\t\treturn FALSE;\r\n\r\n\tif (_r_str_isstartswith2 (&ptr_rule->name->sr, L\"spy_\", TRUE))\r\n\t{\r\n\t\treturn _app_ruleblocklistsetchange (ptr_rule, spy_state);\r\n\t}\r\n\telse if (_r_str_isstartswith2 (&ptr_rule->name->sr, L\"update_\", TRUE))\r\n\t{\r\n\t\treturn _app_ruleblocklistsetchange (ptr_rule, update_state);\r\n\t}\r\n\telse if (_r_str_isstartswith2 (&ptr_rule->name->sr, L\"extra_\", TRUE))\r\n\t{\r\n\t\treturn _app_ruleblocklistsetchange (ptr_rule, extra_state);\r\n\t}\r\n\r\n\t// fallback: block rules with other names by default!\r\n\treturn _app_ruleblocklistsetchange (ptr_rule, 2);\r\n}\r\n\r\nVOID _app_ruleblocklistset (\r\n\t_In_opt_ HWND hwnd,\r\n\t_In_ LONG spy_state,\r\n\t_In_ LONG update_state,\r\n\t_In_ LONG extra_state,\r\n\t_In_ BOOLEAN is_instantapply\r\n)\r\n{\r\n\tPR_LIST rules;\r\n\tPITEM_RULE ptr_rule;\r\n\tHANDLE hengine;\r\n\tULONG_PTR changes_count = 0;\r\n\r\n\trules = _r_obj_createlist (6, &_r_obj_dereference);\r\n\r\n\t_r_queuedlock_acquireshared (&lock_rules);\r\n\r\n\tfor (ULONG_PTR i = 0; i < _r_obj_getlistsize (rules_list); i++)\r\n\t{\r\n\t\tptr_rule = _r_obj_getlistitem (rules_list, i);\r\n\r\n\t\tif (!ptr_rule)\r\n\t\t\tcontinue;\r\n\r\n\t\tif (ptr_rule->type != DATA_RULE_BLOCKLIST)\r\n\t\t\tcontinue;\r\n\r\n\t\tif (!_app_ruleblocklistsetstate (ptr_rule, spy_state, update_state, extra_state))\r\n\t\t\tcontinue;\r\n\r\n\t\t_app_ruleenable (ptr_rule, !!ptr_rule->is_enabled, FALSE);\r\n\r\n\t\tchanges_count += 1;\r\n\r\n\t\tif (hwnd)\r\n\t\t\t_app_listview_updateitemby_param (hwnd, i, FALSE);\r\n\r\n\t\tif (is_instantapply)\r\n\t\t\t_r_obj_addlistitem (rules, _r_obj_reference (ptr_rule), NULL); // dereference later!\r\n\t}\r\n\r\n\t_r_queuedlock_releaseshared (&lock_rules);\r\n\r\n\tif (changes_count)\r\n\t{\r\n\t\tif (hwnd)\r\n\t\t\t_app_listview_updateby_id (hwnd, DATA_RULE_BLOCKLIST, PR_UPDATE_TYPE | PR_UPDATE_NORESIZE);\r\n\r\n\t\tif (is_instantapply)\r\n\t\t{\r\n\t\t\tif (rules->count)\r\n\t\t\t{\r\n\t\t\t\tif (_wfp_isfiltersinstalled ())\r\n\t\t\t\t{\r\n\t\t\t\t\thengine = _wfp_getenginehandle ();\r\n\r\n\t\t\t\t\t_wfp_create4filters (hengine, rules, DBG_ARG, FALSE);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t_app_profile_save (hwnd); // required!\r\n\t}\r\n\r\n\t_r_obj_dereference (rules);\r\n}\r\n\r\n_Ret_maybenull_\r\nPR_STRING _app_appexpandrules (\r\n\t_In_ ULONG app_hash,\r\n\t_In_ LPWSTR delimeter\r\n)\r\n{\r\n\tR_STRINGBUILDER buffer;\r\n\tR_STRINGREF delimeter_sr;\r\n\tPR_STRING string;\r\n\tPITEM_RULE ptr_rule;\r\n\r\n\t_r_obj_initializestringbuilder (&buffer, 256);\r\n\r\n\t_r_obj_initializestringref (&delimeter_sr, delimeter);\r\n\r\n\t_r_queuedlock_acquireshared (&lock_rules);\r\n\r\n\tfor (ULONG_PTR i = 0; i < _r_obj_getlistsize (rules_list); i++)\r\n\t{\r\n\t\tptr_rule = _r_obj_getlistitem (rules_list, i);\r\n\r\n\t\tif (!ptr_rule)\r\n\t\t\tcontinue;\r\n\r\n\t\tif (ptr_rule->is_enabled && ptr_rule->type == DATA_RULE_USER && !_r_obj_isstringempty (ptr_rule->name) && _r_obj_findhashtable (ptr_rule->apps, app_hash))\r\n\t\t{\r\n\t\t\t_r_obj_appendstringbuilder2 (&buffer, &ptr_rule->name->sr);\r\n\r\n\t\t\tif (ptr_rule->is_readonly)\r\n\t\t\t\t_r_obj_appendstringbuilder (&buffer, SZ_RULE_INTERNAL_MENU);\r\n\r\n\t\t\t_r_obj_appendstringbuilder2 (&buffer, &delimeter_sr);\r\n\t\t}\r\n\t}\r\n\r\n\t_r_queuedlock_releaseshared (&lock_rules);\r\n\r\n\tstring = _r_obj_finalstringbuilder (&buffer);\r\n\r\n\t_r_str_trimstring (&string->sr, &delimeter_sr, 0);\r\n\r\n\tif (!_r_obj_isstringempty2 (string))\r\n\t\treturn string;\r\n\r\n\t_r_obj_deletestringbuilder (&buffer);\r\n\r\n\treturn NULL;\r\n\r\n}\r\n\r\n_Ret_maybenull_\r\nPR_STRING _app_rulesexpandapps (\r\n\t_In_ PITEM_RULE ptr_rule,\r\n\t_In_ BOOLEAN is_fordisplay,\r\n\t_In_ LPWSTR delimeter\r\n)\r\n{\r\n\tR_STRINGREF delimeter_sr;\r\n\tR_STRINGBUILDER sr;\r\n\tPITEM_APP ptr_app;\r\n\tPR_STRING string;\r\n\tULONG_PTR enum_key = 0;\r\n\tULONG hash_code;\r\n\r\n\t_r_obj_initializestringbuilder (&sr, 256);\r\n\r\n\t_r_obj_initializestringref (&delimeter_sr, delimeter);\r\n\r\n\tif (is_fordisplay && ptr_rule->is_forservices)\r\n\t{\r\n\t\tstring = _r_obj_concatstrings (\r\n\t\t\t4,\r\n\t\t\tPROC_SYSTEM_NAME,\r\n\t\t\tdelimeter,\r\n\t\t\t_r_obj_getstring (config.svchost_path),\r\n\t\t\tdelimeter\r\n\t\t);\r\n\r\n\t\t_r_obj_appendstringbuilder2 (&sr, &string->sr);\r\n\r\n\t\t_r_obj_dereference (string);\r\n\t}\r\n\r\n\twhile (_r_obj_enumhashtable (ptr_rule->apps, NULL, &hash_code, &enum_key))\r\n\t{\r\n\t\tptr_app = _app_getappitem (hash_code);\r\n\r\n\t\tif (!ptr_app)\r\n\t\t\tcontinue;\r\n\r\n\t\tstring = NULL;\r\n\r\n\t\tif (is_fordisplay)\r\n\t\t{\r\n\t\t\tif (ptr_app->type == DATA_APP_UWP)\r\n\t\t\t{\r\n\t\t\t\tif (ptr_app->display_name)\r\n\t\t\t\t\tstring = _r_path_compact (&ptr_app->display_name->sr, 64);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (!string)\r\n\t\t{\r\n\t\t\tif (is_fordisplay)\r\n\t\t\t{\r\n\t\t\t\tif (ptr_app->original_path)\r\n\t\t\t\t\tstring = _r_path_compact (&ptr_app->original_path->sr, 64);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (!string)\r\n\t\t\tstring = _r_obj_referencesafe (ptr_app->original_path);\r\n\r\n\t\tif (string)\r\n\t\t{\r\n\t\t\t_r_obj_appendstringbuilder2 (&sr, &string->sr);\r\n\t\t\t_r_obj_appendstringbuilder2 (&sr, &delimeter_sr);\r\n\r\n\t\t\t_r_obj_dereference (string);\r\n\t\t}\r\n\r\n\t\t_r_obj_dereference (ptr_app);\r\n\t}\r\n\r\n\tstring = _r_obj_finalstringbuilder (&sr);\r\n\r\n\t_r_str_trimstring (&string->sr, &delimeter_sr, PR_TRIM_END_ONLY);\r\n\r\n\tif (!_r_obj_isstringempty2 (string))\r\n\t\treturn string;\r\n\r\n\t_r_obj_deletestringbuilder (&sr);\r\n\r\n\treturn NULL;\r\n}\r\n\r\n_Ret_maybenull_\r\nPR_STRING _app_rulesexpandrules (\r\n\t_In_opt_ PR_STRING rule,\r\n\t_In_ LPWSTR delimeter\r\n)\r\n{\r\n\tR_STRINGBUILDER sb;\r\n\tR_STRINGREF delimeter_sr;\r\n\tR_STRINGREF remaining_part;\r\n\tR_STRINGREF first_part;\r\n\tPR_STRING string;\r\n\r\n\tif (_r_obj_isstringempty (rule))\r\n\t\treturn NULL;\r\n\r\n\t_r_obj_initializestringbuilder (&sb, 256);\r\n\r\n\t_r_obj_initializestringref (&delimeter_sr, delimeter);\r\n\r\n\t_r_obj_initializestringref2 (&remaining_part, &rule->sr);\r\n\r\n\twhile (remaining_part.length != 0)\r\n\t{\r\n\t\t_r_str_splitatchar (&remaining_part, DIVIDER_RULE[0], &first_part, &remaining_part);\r\n\r\n\t\t_r_obj_appendstringbuilder2 (&sb, &first_part);\r\n\t\t_r_obj_appendstringbuilder2 (&sb, &delimeter_sr);\r\n\t}\r\n\r\n\tstring = _r_obj_finalstringbuilder (&sb);\r\n\r\n\t_r_str_trimstring (&string->sr, &delimeter_sr, 0);\r\n\r\n\tif (!_r_obj_isstringempty2 (string))\r\n\t\treturn string;\r\n\r\n\t_r_obj_deletestringbuilder (&sb);\r\n\r\n\treturn NULL;\r\n}\r\n\r\nBOOLEAN _app_isappfromsystem (\r\n\t_In_opt_ PR_STRING path,\r\n\t_In_ ULONG app_hash\r\n)\r\n{\r\n\tif (_app_issystemhash (app_hash))\r\n\t\treturn TRUE;\r\n\r\n\tif (path)\r\n\t{\r\n\t\tif (_r_str_isstartswith (&path->sr, &config.windows_dir, TRUE))\r\n\t\t\treturn TRUE;\r\n\t}\r\n\r\n\treturn FALSE;\r\n}\r\n\r\nBOOLEAN _app_isapphavedrive (\r\n\t_In_ INT letter\r\n)\r\n{\r\n\tPITEM_APP ptr_app = NULL;\r\n\tULONG_PTR enum_key = 0;\r\n\tINT drive_id;\r\n\r\n\t_r_queuedlock_acquireshared (&lock_apps);\r\n\r\n\twhile (_r_obj_enumhashtablepointer (apps_table, (PVOID_PTR)&ptr_app, NULL, &enum_key))\r\n\t{\r\n\t\tif (_r_obj_isstringempty (ptr_app->original_path))\r\n\t\t\tcontinue;\r\n\r\n\t\tif (ptr_app->type == DATA_APP_REGULAR)\r\n\t\t{\r\n\t\t\tdrive_id = PathGetDriveNumberW (ptr_app->original_path->buffer);\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tdrive_id = INT_ERROR;\r\n\t\t}\r\n\r\n\t\tif (ptr_app->type == DATA_APP_DEVICE || (drive_id != INT_ERROR && drive_id == letter))\r\n\t\t{\r\n\t\t\tif (ptr_app->is_enabled || _app_isapphaverule (ptr_app->app_hash, FALSE))\r\n\t\t\t{\r\n\t\t\t\t_r_queuedlock_releaseshared (&lock_apps);\r\n\r\n\t\t\t\treturn TRUE;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t_r_queuedlock_releaseshared (&lock_apps);\r\n\r\n\treturn FALSE;\r\n}\r\n\r\nBOOLEAN _app_isapphaverule (\r\n\t_In_ ULONG app_hash,\r\n\t_In_ BOOLEAN is_countdisabled\r\n)\r\n{\r\n\tPITEM_RULE ptr_rule;\r\n\r\n\t_r_queuedlock_acquireshared (&lock_rules);\r\n\r\n\tfor (ULONG_PTR i = 0; i < _r_obj_getlistsize (rules_list); i++)\r\n\t{\r\n\t\tptr_rule = _r_obj_getlistitem (rules_list, i);\r\n\r\n\t\tif (ptr_rule)\r\n\t\t{\r\n\t\t\tif (ptr_rule->type == DATA_RULE_USER && (is_countdisabled || ptr_rule->is_enabled))\r\n\t\t\t{\r\n\t\t\t\tif (_r_obj_findhashtable (ptr_rule->apps, app_hash))\r\n\t\t\t\t{\r\n\t\t\t\t\t_r_queuedlock_releaseshared (&lock_rules);\r\n\r\n\t\t\t\t\treturn TRUE;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t_r_queuedlock_releaseshared (&lock_rules);\r\n\r\n\treturn FALSE;\r\n}\r\n\r\nBOOLEAN _app_isappexists (\r\n\t_In_ PITEM_APP ptr_app\r\n)\r\n{\r\n\tif (ptr_app->is_undeletable)\r\n\t\treturn TRUE;\r\n\r\n\tif (ptr_app->is_enabled && ptr_app->is_haveerrors)\r\n\t\treturn FALSE;\r\n\r\n\tswitch (ptr_app->type)\r\n\t{\r\n\t\tcase DATA_APP_REGULAR:\r\n\t\t{\r\n\t\t\tif (ptr_app->real_path && !_r_fs_isexists (&ptr_app->real_path->sr))\r\n\t\t\t\treturn FALSE;\r\n\r\n\t\t\treturn TRUE;\r\n\t\t}\r\n\r\n\t\tcase DATA_APP_DEVICE:\r\n\t\tcase DATA_APP_NETWORK:\r\n\t\tcase DATA_APP_SERVICE:\r\n\t\tcase DATA_APP_UWP:\r\n\t\tcase DATA_APP_PICO:\r\n\t\t{\r\n\t\t\treturn TRUE; // service and UWP is already undeletable\r\n\t\t}\r\n\r\n\t\tdefault:\r\n\t\t{\r\n\t\t\tFALLTHROUGH;\r\n\t\t}\r\n\t}\r\n\r\n\treturn FALSE;\r\n}\r\n\r\nBOOLEAN _app_isappfound (\r\n\t_In_ ULONG app_hash\r\n)\r\n{\r\n\tBOOLEAN is_found;\r\n\r\n\t_r_queuedlock_acquireshared (&lock_apps);\r\n\tis_found = (_r_obj_findhashtable (apps_table, app_hash) != NULL);\r\n\t_r_queuedlock_releaseshared (&lock_apps);\r\n\r\n\treturn is_found;\r\n}\r\n\r\nBOOLEAN _app_isappunused (\r\n\t_In_ PITEM_APP ptr_app\r\n)\r\n{\r\n\tif (ptr_app->is_undeletable)\r\n\t\treturn FALSE;\r\n\r\n\tif (!_app_isappexists (ptr_app))\r\n\t\treturn TRUE;\r\n\r\n\tif (!_app_isappused (ptr_app))\r\n\t\treturn TRUE;\r\n\r\n\treturn FALSE;\r\n}\r\n\r\nBOOLEAN _app_isappused (\r\n\t_In_ PITEM_APP ptr_app\r\n)\r\n{\r\n\tif (ptr_app->is_enabled || ptr_app->is_silent || ptr_app->is_undeletable)\r\n\t\treturn TRUE;\r\n\r\n\tif (_app_isapphaverule (ptr_app->app_hash, TRUE))\r\n\t\treturn TRUE;\r\n\r\n\treturn FALSE;\r\n}\r\n\r\nBOOLEAN _app_issystemhash (\r\n\t_In_ ULONG app_hash\r\n)\r\n{\r\n\treturn (app_hash == config.ntoskrnl_hash || app_hash == config.svchost_hash);\r\n}\r\n\r\nBOOLEAN _app_isrulesupportedbyos (\r\n\t_In_ PR_STRINGREF os_version\r\n)\r\n{\r\n\tstatic PR_STRING version_string = NULL;\r\n\r\n\tPR_STRING current_version;\r\n\tPR_STRING new_version;\r\n\r\n\tcurrent_version = _InterlockedCompareExchangePointer ((volatile PVOID_PTR)&version_string, NULL, NULL);\r\n\r\n\tif (!current_version)\r\n\t{\r\n\t\tnew_version = _r_format_string (L\"%d.%d\", NtCurrentPeb ()->OSMajorVersion, NtCurrentPeb ()->OSMinorVersion);\r\n\r\n\t\tcurrent_version = _InterlockedCompareExchangePointer ((volatile PVOID_PTR)&version_string, new_version, NULL);\r\n\r\n\t\tif (!current_version)\r\n\t\t{\r\n\t\t\tcurrent_version = new_version;\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\t_r_obj_dereference (new_version);\r\n\t\t}\r\n\t}\r\n\r\n\treturn (_r_str_versioncompare (&current_version->sr, os_version) != INT_ERROR);\r\n}\r\n\r\nVOID _app_profile_initialize ()\r\n{\r\n\tR_STRINGREF profile_internal_sr = PR_STRINGREF_INIT (XML_PROFILE_INTERNAL);\r\n\tR_STRINGREF profile_bak_sr = PR_STRINGREF_INIT (XML_PROFILE_FILE L\".bak\");\r\n\tR_STRINGREF profile_sr = PR_STRINGREF_INIT (XML_PROFILE_FILE);\r\n\tR_STRINGREF separator_sr = PR_STRINGREF_INIT (L\"\\\\\");\r\n\tPR_STRING path;\r\n\r\n\tpath = _r_app_getprofiledirectory (TRUE);\r\n\r\n\t_r_obj_movereference ((PVOID_PTR)&profile_info.profile_path, _r_obj_concatstringrefs (3, &path->sr, &separator_sr, &profile_sr));\r\n\t_r_obj_movereference ((PVOID_PTR)&profile_info.profile_path_backup, _r_obj_concatstringrefs (3, &path->sr, &separator_sr, &profile_bak_sr));\r\n\t_r_obj_movereference ((PVOID_PTR)&profile_info.profile_path_internal, _r_obj_concatstringrefs (3, &path->sr, &separator_sr, &profile_internal_sr));\r\n}\r\n\r\nNTSTATUS _app_profile_load_fromresource (\r\n\t_In_ LPCWSTR resource_name,\r\n\t_Out_ PDB_INFORMATION out_buffer\r\n)\r\n{\r\n\tPDB_INFORMATION db_info;\r\n\tR_STORAGE bytes;\r\n\tNTSTATUS status;\r\n\r\n\tdb_info = out_buffer;\r\n\r\n\tstatus = _app_db_initialize (db_info, TRUE);\r\n\r\n\tif (NT_SUCCESS (status))\r\n\t{\r\n\t\tstatus = _r_res_loadresource (_r_sys_getimagebase (), RT_RCDATA, resource_name, 0, &bytes);\r\n\r\n\t\tif (NT_SUCCESS (status))\r\n\t\t\tstatus = _app_db_openfrombuffer (db_info, &bytes, XML_VERSION_MAXIMUM, XML_TYPE_PROFILE_INTERNAL);\r\n\t}\r\n\r\n\treturn status;\r\n}\r\n\r\nVOID _app_profile_load_fallback ()\r\n{\r\n\tULONG app_hash;\r\n\r\n\tif (!_app_isappfound (config.my_hash))\r\n\t{\r\n\t\tapp_hash = _app_addapplication (NULL, DATA_UNKNOWN, config.my_path, NULL, NULL);\r\n\r\n\t\tif (app_hash)\r\n\t\t\t_app_setappinfobyhash (app_hash, INFO_IS_ENABLED, LongToPtr (TRUE));\r\n\t}\r\n\r\n\t_app_setappinfobyhash (config.my_hash, INFO_IS_UNDELETABLE, LongToPtr (TRUE));\r\n\r\n\t// disable deletion for this shit ;)\r\n\tif (!_r_config_getboolean (L\"IsInternalRulesDisabled\", FALSE, NULL))\r\n\t{\r\n\t\tif (!_app_isappfound (config.ntoskrnl_hash) && !_r_obj_isstringempty (config.system_path))\r\n\t\t\t_app_addapplication (NULL, DATA_UNKNOWN, config.system_path, NULL, NULL);\r\n\r\n\t\tif (!_app_isappfound (config.svchost_hash) && !_r_obj_isstringempty (config.svchost_path))\r\n\t\t\t_app_addapplication (NULL, DATA_UNKNOWN, config.svchost_path, NULL, NULL);\r\n\r\n\t\t_app_setappinfobyhash (config.ntoskrnl_hash, INFO_IS_UNDELETABLE, LongToPtr (TRUE));\r\n\t\t_app_setappinfobyhash (config.svchost_hash, INFO_IS_UNDELETABLE, LongToPtr (TRUE));\r\n\t}\r\n}\r\n\r\nVOID _app_profile_load_internal (\r\n\t_In_opt_ HWND hwnd,\r\n\t_In_ PR_STRING path,\r\n\t_In_ LPCWSTR resource_name,\r\n\t_Out_ PLONG64 out_timestamp\r\n)\r\n{\r\n\tDB_INFORMATION db_info_buffer;\r\n\tDB_INFORMATION db_info_file;\r\n\tPDB_INFORMATION db_info;\r\n\tBOOLEAN is_loadfromresource;\r\n\tLONG64 timestamp = 0;\r\n\tNTSTATUS status_file;\r\n\tNTSTATUS status_res;\r\n\tNTSTATUS status;\r\n\r\n\tstatus_file = _app_db_initialize (&db_info_file, TRUE);\r\n\r\n\tif (_r_fs_isexists (&path->sr))\r\n\t{\r\n\t\tif (NT_SUCCESS (status_file))\r\n\t\t\tstatus_file = _app_db_openfromfile (&db_info_file, path, XML_VERSION_MAXIMUM, XML_TYPE_PROFILE_INTERNAL);\r\n\t}\r\n\telse\r\n\t{\r\n\t\tstatus_file = STATUS_OBJECT_PATH_NOT_FOUND;\r\n\t}\r\n\r\n\tstatus_res = _app_profile_load_fromresource (resource_name, &db_info_buffer);\r\n\r\n\t// NOTE: prefer new profile version for 3.4+\r\n\tif (!NT_SUCCESS (status_file))\r\n\t{\r\n\t\tis_loadfromresource = TRUE;\r\n\t}\r\n\telse\r\n\t{\r\n\t\tis_loadfromresource = (db_info_file.version < db_info_buffer.version) || (db_info_file.timestamp < db_info_buffer.timestamp);\r\n\t}\r\n\r\n\tdb_info = is_loadfromresource ? &db_info_buffer : &db_info_file;\r\n\r\n\tstatus = is_loadfromresource ? status_res : status_file;\r\n\r\n\tif (NT_SUCCESS (status))\r\n\t{\r\n\t\tif (_app_db_parse (db_info, XML_TYPE_PROFILE_INTERNAL))\r\n\t\t\ttimestamp = db_info->timestamp;\r\n\t}\r\n\telse\r\n\t{\r\n\t\tif (status != STATUS_OBJECT_NAME_NOT_FOUND && status != STATUS_OBJECT_PATH_NOT_FOUND)\r\n\t\t{\r\n\t\t\tif (hwnd)\r\n\t\t\t\t_r_show_errormessage (hwnd, L\"Could not load internal profile!\", status, NULL, ET_NATIVE);\r\n\r\n\t\t\t_r_log (LOG_LEVEL_ERROR, NULL, L\"_app_profile_load_internal\", status, NULL);\r\n\t\t}\r\n\t}\r\n\r\n\t*out_timestamp = timestamp;\r\n\r\n\t_app_db_destroy (&db_info_buffer);\r\n\t_app_db_destroy (&db_info_file);\r\n}\r\n\r\nVOID _app_profile_refresh (\r\n\t_In_opt_ HWND hwnd\r\n)\r\n{\r\n\t// clear apps\r\n\t_r_queuedlock_acquireexclusive (&lock_apps);\r\n\t_r_obj_clearhashtable (apps_table);\r\n\t_r_queuedlock_releaseexclusive (&lock_apps);\r\n\r\n\t// clear rules\r\n\t_r_queuedlock_acquireexclusive (&lock_rules);\r\n\t_r_obj_clearlist (rules_list);\r\n\t_r_queuedlock_releaseexclusive (&lock_rules);\r\n\r\n\t// clear rules config\r\n\t_r_queuedlock_acquireexclusive (&lock_rules_config);\r\n\t_r_obj_clearhashtable (rules_config);\r\n\t_r_queuedlock_releaseexclusive (&lock_rules_config);\r\n\r\n\tif (!hwnd)\r\n\t\thwnd = _r_app_gethwnd ();\r\n\r\n\t// generate services list\r\n\t_app_package_getserviceslist (hwnd);\r\n\r\n\t// generate uwp packages list (win8+)\r\n\tif (_r_sys_isosversiongreaterorequal (WINDOWS_8))\r\n\t\t_app_package_getpackageslist (hwnd);\r\n}\r\n\r\nNTSTATUS _app_profile_load (\r\n\t_In_opt_ HWND hwnd,\r\n\t_In_opt_ PR_STRING path_custom\r\n)\r\n{\r\n\tDB_INFORMATION db_info;\r\n\tBOOLEAN is_update;\r\n\tNTSTATUS status;\r\n\r\n\tstatus = _app_db_initialize (&db_info, TRUE);\r\n\r\n\tif (!NT_SUCCESS (status))\r\n\t{\r\n\t\tif (hwnd)\r\n\t\t\t_r_show_errormessage (hwnd, L\"Could not intitialize profile!\", status, NULL, ET_WINDOWS);\r\n\r\n\t\t_r_log (LOG_LEVEL_ERROR, NULL, L\"_app_db_initialize\", status, NULL);\r\n\r\n\t\tgoto CleanupExit;\r\n\t}\r\n\r\n\tif (path_custom)\r\n\t{\r\n\t\tstatus = _app_db_openfromfile (&db_info, path_custom, XML_VERSION_MINIMAL, XML_TYPE_PROFILE);\r\n\t}\r\n\telse\r\n\t{\r\n\t\t_r_queuedlock_acquireshared (&lock_profile);\r\n\r\n\t\tstatus = _app_db_openfromfile (&db_info, profile_info.profile_path, XML_VERSION_MINIMAL, XML_TYPE_PROFILE);\r\n\r\n\t\tif (!NT_SUCCESS (status))\r\n\t\t\tstatus = _app_db_openfromfile (&db_info, profile_info.profile_path_backup, XML_VERSION_MINIMAL, XML_TYPE_PROFILE);\r\n\r\n\t\t_r_queuedlock_releaseshared (&lock_profile);\r\n\t}\r\n\r\nCleanupExit:\r\n\r\n\tis_update = (NT_SUCCESS (status) || !path_custom);\r\n\r\n\tif (is_update)\r\n\t{\r\n\t\tif (hwnd)\r\n\t\t\t_app_listview_clearitems (hwnd);\r\n\r\n\t\t_app_profile_refresh (hwnd);\r\n\t}\r\n\r\n\tif (NT_SUCCESS (status))\r\n\t{\r\n\t\t_app_db_parse (&db_info, XML_TYPE_PROFILE);\r\n\t}\r\n\telse\r\n\t{\r\n\t\tif (status != STATUS_OBJECT_NAME_NOT_FOUND && status != STATUS_OBJECT_PATH_NOT_FOUND)\r\n\t\t{\r\n\t\t\tif (hwnd)\r\n\t\t\t\t_r_show_errormessage (hwnd, L\"Could not load profile!\", status, NULL, ET_NATIVE);\r\n\r\n\t\t\t_r_log (LOG_LEVEL_ERROR, NULL, L\"_app_profile_load\", status, NULL);\r\n\t\t}\r\n\t}\r\n\r\n\tif (is_update)\r\n\t{\r\n\t\t// load internal rules (new!)\r\n\t\tif (!_r_config_getboolean (L\"IsInternalRulesDisabled\", FALSE, NULL))\r\n\t\t\t_app_profile_load_internal (hwnd, profile_info.profile_path_internal, MAKEINTRESOURCE (IDR_PROFILE_INTERNAL), &profile_info.profile_internal_timestamp);\r\n\r\n\t\t_app_profile_load_fallback ();\r\n\r\n\t\tif (hwnd)\r\n\t\t\t_app_listview_additems (hwnd);\r\n\t}\r\n\r\n\t_app_db_destroy (&db_info);\r\n\r\n\treturn status;\r\n}\r\n\r\nNTSTATUS _app_profile_save (\r\n\t_In_opt_ HWND hwnd\r\n)\r\n{\r\n\tDB_INFORMATION db_info;\r\n\tLONG64 timestamp;\r\n\tBOOLEAN is_backuprequired = FALSE;\r\n\tNTSTATUS status;\r\n\r\n\tstatus = _app_db_initialize (&db_info, FALSE);\r\n\r\n\tif (!NT_SUCCESS (status))\r\n\t{\r\n\t\tif (hwnd)\r\n\t\t\t_r_show_errormessage (hwnd, L\"Could not intitialize profile!\", status, NULL, ET_WINDOWS);\r\n\r\n\t\t_r_log (LOG_LEVEL_ERROR, NULL, L\"_app_db_initialize\", status, NULL);\r\n\r\n\t\treturn status;\r\n\t}\r\n\r\n\ttimestamp = _r_unixtime_now ();\r\n\r\n\tif (_r_config_getboolean (L\"IsBackupProfile\", TRUE, NULL))\r\n\t{\r\n\t\tif (!_r_fs_isexists (&profile_info.profile_path_backup->sr))\r\n\t\t\tis_backuprequired = TRUE;\r\n\r\n\t\tif (!is_backuprequired)\r\n\t\t{\r\n\t\t\tif (timestamp - _r_config_getlong64 (L\"BackupTimestamp\", 0, NULL) >= _r_config_getlong64 (L\"BackupPeriod\", BACKUP_HOURS_PERIOD, NULL))\r\n\t\t\t\tis_backuprequired = TRUE;\r\n\t\t}\r\n\t}\r\n\r\n\t_r_queuedlock_acquireexclusive (&lock_profile);\r\n\r\n\tstatus = _app_db_savetofile (&db_info, profile_info.profile_path, XML_VERSION_MAXIMUM, XML_TYPE_PROFILE, timestamp);\r\n\r\n\t_r_queuedlock_releaseexclusive (&lock_profile);\r\n\r\n\tif (!NT_SUCCESS (status))\r\n\t{\r\n\t\tif (hwnd)\r\n\t\t\t_r_show_errormessage (hwnd, L\"Could not save profile!\", status, NULL, ET_NATIVE);\r\n\r\n\t\t_r_log (LOG_LEVEL_ERROR, NULL, L\"_app_db_savetofile\", status, profile_info.profile_path->buffer);\r\n\t}\r\n\r\n\t_app_db_destroy (&db_info);\r\n\r\n\t// make backup\r\n\tif (is_backuprequired)\r\n\t{\r\n\t\t_r_fs_copyfile (&profile_info.profile_path->sr, &profile_info.profile_path_backup->sr, FALSE);\r\n\r\n\t\t_r_config_setlong64 (L\"BackupTimestamp\", timestamp, NULL);\r\n\t}\r\n\r\n\treturn status;\r\n}\r\n"
  },
  {
    "path": "src/profile.h",
    "content": "// simplewall\r\n// Copyright (c) 2016-2026 Henry++\r\n\r\n#pragma once\r\n\r\nFORCEINLINE BOOLEAN _app_isdisabledremoval (\r\n\t_In_ ULONG app_hash\r\n)\r\n{\r\n\tif (app_hash == config.my_hash || app_hash == config.ntoskrnl_hash || app_hash == config.svchost_hash || app_hash == config.wusvc_hash)\r\n\t\treturn TRUE;\r\n\r\n\treturn FALSE;\r\n}\r\n\r\n_Success_ (return)\r\nBOOLEAN _app_getappinfo (\r\n\t_In_ PITEM_APP ptr_app,\r\n\t_In_ ENUM_INFO_DATA info_data,\r\n\t_Out_writes_bytes_all_ (length) PVOID buffer,\r\n\t_In_ ULONG_PTR length\r\n);\r\n\r\n_Success_ (return)\r\nBOOLEAN _app_getappinfobyhash (\r\n\t_In_ ULONG app_hash,\r\n\t_In_ ENUM_INFO_DATA info_data,\r\n\t_Out_writes_bytes_all_ (length) PVOID buffer,\r\n\t_In_ ULONG_PTR length\r\n);\r\n\r\nVOID _app_setappinfo (\r\n\t_In_ PITEM_APP ptr_app,\r\n\t_In_ ENUM_INFO_DATA info_data,\r\n\t_In_opt_ PVOID value\r\n);\r\n\r\nVOID _app_setappinfobyhash (\r\n\t_In_ ULONG app_hash,\r\n\t_In_ ENUM_INFO_DATA info_data,\r\n\t_In_opt_ PVOID value\r\n);\r\n\r\n_Success_ (return)\r\nBOOLEAN _app_getruleinfo (\r\n\t_In_ PITEM_RULE ptr_rule,\r\n\t_In_ ENUM_INFO_DATA info_data,\r\n\t_Out_writes_bytes_all_ (length) PVOID buffer,\r\n\t_In_ ULONG_PTR length\r\n);\r\n\r\n_Success_ (return)\r\nBOOLEAN _app_getruleinfobyid (\r\n\t_In_ ULONG_PTR index,\r\n\t_In_ ENUM_INFO_DATA info_data,\r\n\t_Out_writes_bytes_all_ (length) PVOID buffer,\r\n\t_In_ ULONG_PTR length\r\n);\r\n\r\n_Success_ (return != 0)\r\nULONG _app_addapplication (\r\n\t_In_opt_ HWND hwnd,\r\n\t_In_ ENUM_TYPE_DATA type,\r\n\t_In_ PR_STRING path,\r\n\t_In_opt_ PR_STRING display_name,\r\n\t_In_opt_ PR_STRING real_path\r\n);\r\n\r\nPITEM_RULE _app_addrule (\r\n\t_In_opt_ PR_STRING name,\r\n\t_In_opt_ PR_STRING rule_remote,\r\n\t_In_opt_ PR_STRING rule_local,\r\n\t_In_ FWP_DIRECTION direction,\r\n\t_In_ FWP_ACTION_TYPE action,\r\n\t_In_ UINT8 protocol,\r\n\t_In_ ADDRESS_FAMILY af\r\n);\r\n\r\n_Ret_maybenull_\r\nPITEM_RULE_CONFIG _app_addruleconfigtable (\r\n\t_In_ PR_HASHTABLE hashtable,\r\n\t_In_ ULONG rule_hash,\r\n\t_In_ PR_STRING rule_name,\r\n\t_In_ BOOLEAN is_enabled\r\n);\r\n\r\n_Ret_maybenull_\r\nPITEM_APP _app_getappitem (\r\n\t_In_ ULONG app_hash\r\n);\r\n\r\n_Ret_maybenull_\r\nPITEM_RULE _app_getrulebyid (\r\n\t_In_ ULONG_PTR index\r\n);\r\n\r\n_Ret_maybenull_\r\nPITEM_RULE _app_getrulebyhash (\r\n\t_In_ ULONG_PTR rule_hash\r\n);\r\n\r\n_Ret_maybenull_\r\nPITEM_RULE_CONFIG _app_getruleconfigitem (\r\n\t_In_ ULONG rule_hash\r\n);\r\n\r\n_Ret_maybenull_\r\nPITEM_LOG _app_getlogitem (\r\n\t_In_ ULONG log_hash\r\n);\r\n\r\n_Success_ (return != 0)\r\nULONG _app_getlogapp (\r\n\t_In_ ULONG index\r\n);\r\n\r\nCOLORREF _app_getappcolor (\r\n\t_In_ INT listview_id,\r\n\t_In_ ULONG app_hash,\r\n\t_In_ BOOLEAN is_systemapp,\r\n\t_In_ BOOLEAN is_validconnection\r\n);\r\n\r\nVOID _app_deleteappitem (\r\n\t_In_ HWND hwnd,\r\n\t_In_ ENUM_TYPE_DATA type,\r\n\t_In_ ULONG_PTR id_code\r\n);\r\n\r\nVOID _app_freeapplication (\r\n\t_In_opt_ HWND hwnd,\r\n\t_In_ ULONG app_hash\r\n);\r\n\r\nBOOLEAN _app_isappfromsystem (\r\n\t_In_opt_ PR_STRING path,\r\n\t_In_ ULONG app_hash\r\n);\r\n\r\nBOOLEAN _app_isapphavedrive (\r\n\t_In_ INT letter\r\n);\r\n\r\nBOOLEAN _app_isapphaverule (\r\n\t_In_ ULONG app_hash,\r\n\t_In_ BOOLEAN is_countdisabled\r\n);\r\n\r\nBOOLEAN _app_isappexists (\r\n\t_In_ PITEM_APP ptr_app\r\n);\r\n\r\nBOOLEAN _app_isappfound (\r\n\t_In_ ULONG app_hash\r\n);\r\n\r\nBOOLEAN _app_isappunused (\r\n\t_In_ PITEM_APP ptr_app\r\n);\r\n\r\nBOOLEAN _app_isappused (\r\n\t_In_ PITEM_APP ptr_app\r\n);\r\n\r\nBOOLEAN _app_issystemhash (\r\n\t_In_ ULONG app_hash\r\n);\r\n\r\nVOID _app_getcount (\r\n\t_Out_ PITEM_STATUS status\r\n);\r\n\r\nCOLORREF _app_getrulecolor (\r\n\t_In_ INT listview_id,\r\n\t_In_ ULONG_PTR rule_idx\r\n);\r\n\r\nVOID _app_setappiteminfo (\r\n\t_In_ HWND hwnd,\r\n\t_In_ INT listview_id,\r\n\t_In_ INT item_id,\r\n\t_In_ PITEM_APP ptr_app\r\n);\r\n\r\nVOID _app_setruleiteminfo (\r\n\t_In_ HWND hwnd,\r\n\t_In_ INT listview_id,\r\n\t_In_ INT item_id,\r\n\t_In_ PITEM_RULE ptr_rule,\r\n\t_In_ BOOLEAN include_apps\r\n);\r\n\r\nVOID _app_ruleenable (\r\n\t_Inout_ PITEM_RULE ptr_rule,\r\n\t_In_ BOOLEAN is_enable,\r\n\t_In_ BOOLEAN is_createconfig\r\n);\r\n\r\n//VOID _app_rulecleanapp (\r\n//\t_In_opt_ HWND hwnd,\r\n//\t_In_ ULONG_PTR item_id,\r\n//\t_In_ PITEM_RULE ptr_rule,\r\n//\t_In_opt_ ULONG_PTR app_hash\r\n//);\r\n\r\nVOID _app_ruleremoveapp (\r\n\t_In_opt_ HWND hwnd,\r\n\t_In_ ULONG_PTR item_id,\r\n\t_In_ PITEM_RULE ptr_rule,\r\n\t_In_ ULONG app_hash\r\n);\r\n\r\nBOOLEAN _app_ruleblocklistsetchange (\r\n\t_Inout_ PITEM_RULE ptr_rule,\r\n\t_In_ LONG new_state\r\n);\r\n\r\nBOOLEAN _app_ruleblocklistsetstate (\r\n\t_Inout_ PITEM_RULE ptr_rule,\r\n\t_In_ LONG spy_state,\r\n\t_In_ LONG update_state,\r\n\t_In_ LONG extra_state\r\n);\r\n\r\nVOID _app_ruleblocklistset (\r\n\t_In_opt_ HWND hwnd,\r\n\t_In_ LONG spy_state,\r\n\t_In_ LONG update_state,\r\n\t_In_ LONG extra_state,\r\n\t_In_ BOOLEAN is_instantapply\r\n);\r\n\r\n_Ret_maybenull_\r\nPR_STRING _app_appexpandrules (\r\n\t_In_ ULONG app_hash,\r\n\t_In_ LPWSTR delimeter\r\n);\r\n\r\n_Ret_maybenull_\r\nPR_STRING _app_rulesexpandapps (\r\n\t_In_ PITEM_RULE ptr_rule,\r\n\t_In_ BOOLEAN is_fordisplay,\r\n\t_In_ LPWSTR delimeter\r\n);\r\n\r\n_Ret_maybenull_\r\nPR_STRING _app_rulesexpandrules (\r\n\t_In_opt_ PR_STRING rule,\r\n\t_In_ LPWSTR delimeter\r\n);\r\n\r\nBOOLEAN _app_isrulesupportedbyos (\r\n\t_In_ PR_STRINGREF os_version\r\n);\r\n\r\nVOID _app_profile_initialize ();\r\n\r\nNTSTATUS _app_profile_load_fromresource (\r\n\t_In_ LPCWSTR resource_name,\r\n\t_Out_ PDB_INFORMATION out_buffer\r\n);\r\n\r\nVOID _app_profile_load_fallback ();\r\n\r\nVOID _app_profile_load_internal (\r\n\t_In_opt_ HWND hwnd,\r\n\t_In_ PR_STRING path,\r\n\t_In_ LPCWSTR resource_name,\r\n\t_Out_ PLONG64 out_timestamp\r\n);\r\n\r\nNTSTATUS _app_profile_load (\r\n\t_In_opt_ HWND hwnd,\r\n\t_In_opt_ PR_STRING path_custom\r\n);\r\n\r\nNTSTATUS _app_profile_save (\r\n\t_In_opt_ HWND hwnd\r\n);\r\n"
  },
  {
    "path": "src/res/manifest.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\r\n<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">\r\n\t<dependency>\r\n\t\t<dependentAssembly>\r\n\t\t\t<assemblyIdentity type=\"win32\" name=\"Microsoft.Windows.Common-Controls\" version=\"6.0.0.0\" processorArchitecture=\"*\" language=\"*\" publicKeyToken=\"6595b64144ccf1df\" />\r\n\t\t</dependentAssembly>\r\n\t</dependency>\r\n\r\n\t<trustInfo xmlns=\"urn:schemas-microsoft-com:asm.v3\">\r\n\t\t<security>\r\n\t\t\t<requestedPrivileges>\r\n\t\t\t\t<requestedExecutionLevel level=\"asInvoker\" uiAccess=\"false\" />\r\n\t\t\t</requestedPrivileges>\r\n\t\t</security>\r\n\t</trustInfo>\r\n\r\n\t<compatibility xmlns=\"urn:schemas-microsoft-com:compatibility.v1\">\r\n\t\t<application>\r\n\t\t\t<maxversiontested Id=\"10.0.26200.0\" />\r\n\t\t\t<supportedOS Id=\"{35138B9A-5D96-4FBD-8E2D-A2440225F93A}\" /> <!-- win7 -->\r\n\t\t\t<supportedOS Id=\"{4A2F28E3-53B9-4441-BA9C-D69D4A4A6E38}\" /> <!-- win8 -->\r\n\t\t\t<supportedOS Id=\"{1F676C76-80E1-4239-95BB-83D0F6D0DA78}\" /> <!-- win8.1 -->\r\n\t\t\t<supportedOS Id=\"{8E0F7A12-BFB3-4FE8-B9A5-48FD50A15A9A}\" /> <!-- win10 -->\r\n\t\t</application>\r\n\t</compatibility>\r\n\r\n\t<application xmlns=\"urn:schemas-microsoft-com:asm.v3\">\r\n\t\t<windowsSettings>\r\n\t\t\t<dpiAware xmlns=\"http://schemas.microsoft.com/SMI/2005/WindowsSettings\">true</dpiAware>\r\n\t\t\t<dpiAwareness xmlns=\"http://schemas.microsoft.com/SMI/2016/WindowsSettings\">PerMonitorV2, PerMonitor</dpiAwareness>\r\n\t\t\t<disableWindowFiltering xmlns=\"http://schemas.microsoft.com/SMI/2011/WindowsSettings\">true</disableWindowFiltering>\r\n\t\t\t<printerDriverIsolation xmlns=\"http://schemas.microsoft.com/SMI/2011/WindowsSettings\">true</printerDriverIsolation>\r\n\t\t\t<longPathAware xmlns=\"http://schemas.microsoft.com/SMI/2016/WindowsSettings\">true</longPathAware>\r\n\t\t\t<activeCodePage xmlns=\"http://schemas.microsoft.com/SMI/2019/WindowsSettings\">UTF-8</activeCodePage>\r\n\t\t\t<heapType xmlns=\"http://schemas.microsoft.com/SMI/2020/WindowsSettings\">SegmentHeap</heapType>\r\n\t\t</windowsSettings>\r\n\t</application>\r\n</assembly>\r\n"
  },
  {
    "path": "src/resource.h",
    "content": "#ifndef __RESOURCE_H__\r\n#define __RESOURCE_H__\r\n\r\n#ifndef IDC_STATIC\r\n#define IDC_STATIC (-1)\r\n#endif\r\n\r\n// Acceleration\r\n#define IDA_MAIN 1\r\n\r\n// Menu Id\r\n#define IDM_MAIN 100\r\n#define IDM_TRAY 101\r\n\r\n// Dialogs\r\n#define IDD_MAIN 100\r\n#define IDD_NOTIFICATION 101\r\n#define IDD_EDITOR 102\r\n#define IDD_EDITOR_GENERAL 103\r\n#define IDD_EDITOR_RULE 104\r\n#define IDD_EDITOR_APPS 105\r\n#define IDD_EDITOR_ADDRULE 106\r\n#define IDD_EDITOR_APPINFO 107\r\n#define IDD_EDITOR_APPRULES 108\r\n#define IDD_SETTINGS_GENERAL 109\r\n#define IDD_SETTINGS_INTERFACE 110\r\n#define IDD_SETTINGS_HIGHLIGHTING 111\r\n#define IDD_SETTINGS_RULES 112\r\n#define IDD_SETTINGS_BLOCKLIST 113\r\n#define IDD_SETTINGS_NOTIFICATIONS 114\r\n#define IDD_SETTINGS_LOGGING 115\r\n#define IDD_SETTINGS_EXCLUDE 116\r\n\r\n// Main Dlg\r\n#define IDC_REBAR 102\r\n#define IDC_TOOLBAR 103\r\n#define IDC_SEARCH 104\r\n#define IDC_TAB 105\r\n#define IDC_APPS_PROFILE 106\r\n#define IDC_APPS_SERVICE 107\r\n#define IDC_APPS_UWP 108\r\n#define IDC_RULES_BLOCKLIST 109\r\n#define IDC_RULES_SYSTEM 110\r\n#define IDC_RULES_CUSTOM 111\r\n#define IDC_NETWORK 112\r\n#define IDC_LOG 113\r\n#define IDC_STATUSBAR 114\r\n\r\n// Settings Dlg\r\n#define IDC_NAV 115\r\n#define IDC_SAVE 116\r\n#define IDC_RESET 117\r\n#define IDC_CLOSE 118\r\n\r\n#define IDC_TITLE_GENERAL 119\r\n#define IDC_TITLE_LANGUAGE 120\r\n#define IDC_TITLE_CONNECTIONS 121\r\n#define IDC_TITLE_SECURITY 122\r\n#define IDC_TITLE_BLOCKLIST_SPY 123\r\n#define IDC_TITLE_BLOCKLIST_UPDATE 124\r\n#define IDC_TITLE_BLOCKLIST_EXTRA 125\r\n#define IDC_TITLE_CONFIRMATIONS 126\r\n#define IDC_TITLE_TRAY 127\r\n#define IDC_TITLE_HIGHLIGHTING 128\r\n#define IDC_TITLE_NOTIFICATIONS 129\r\n#define IDC_TITLE_LOGGING 130\r\n#define IDC_TITLE_LOGVIEWER 131\r\n#define IDC_TITLE_INTERFACE 132\r\n#define IDC_TITLE_ADVANCED 133\r\n\r\n#define IDC_ALWAYSONTOP_CHK 134\r\n#define IDC_LOADONSTARTUP_CHK 135\r\n#define IDC_STARTMINIMIZED_CHK 136\r\n#define IDC_SKIPUACWARNING_CHK 137\r\n#define IDC_CHECKUPDATES_CHK 138\r\n\r\n#define IDC_LANGUAGE_HINT 139\r\n#define IDC_LANGUAGE 140\r\n\r\n#define IDC_RULE_BLOCKOUTBOUND 141\r\n#define IDC_RULE_BLOCKINBOUND 142\r\n#define IDC_RULE_ALLOWLOOPBACK 143\r\n#define IDC_RULE_ALLOW6TO4 144\r\n\r\n#define IDC_USESTEALTHMODE_CHK 145\r\n#define IDC_INSTALLBOOTTIMEFILTERS_CHK 146\r\n\r\n#define IDC_USECERTIFICATES_CHK 147\r\n#define IDC_USEHASHES_CHK 148\r\n\r\n#define IDC_USENETWORKRESOLUTION_CHK 149\r\n\r\n#define IDC_BLOCKLIST_SPY_DISABLE 150\r\n#define IDC_BLOCKLIST_SPY_ALLOW 151\r\n#define IDC_BLOCKLIST_SPY_BLOCK 152\r\n\r\n#define IDC_BLOCKLIST_UPDATE_DISABLE 153\r\n#define IDC_BLOCKLIST_UPDATE_ALLOW 154\r\n#define IDC_BLOCKLIST_UPDATE_BLOCK 155\r\n\r\n#define IDC_BLOCKLIST_EXTRA_DISABLE 156\r\n#define IDC_BLOCKLIST_EXTRA_ALLOW 157\r\n#define IDC_BLOCKLIST_EXTRA_BLOCK 158\r\n\r\n#define IDC_BLOCKLIST_INFO 159\r\n\r\n#define IDC_CONFIRMEXIT_CHK 160\r\n#define IDC_CONFIRMEXITTIMER_CHK 161\r\n#define IDC_CONFIRMLOGCLEAR_CHK 162\r\n#define IDC_CONFIRMALLOW_CHK 163\r\n\r\n#define IDC_TRAYICONSINGLECLICK_CHK 164\r\n\r\n#define IDC_COLORS 165\r\n#define IDC_COLORS_HINT 166\r\n\r\n#define IDC_ENABLENOTIFICATIONS_CHK 167\r\n#define IDC_NOTIFICATIONSOUND_CHK 168\r\n#define IDC_NOTIFICATIONFULLSCREENSILENTMODE_CHK 169\r\n#define IDC_NOTIFICATIONONTRAY_CHK 170\r\n#define IDC_NOTIFICATIONTIMEOUT_HINT 171\r\n#define IDC_NOTIFICATIONTIMEOUT_CTRL 172\r\n#define IDC_NOTIFICATIONTIMEOUT 173\r\n#define IDC_EXCLUDESTEALTH_CHK 174\r\n#define IDC_EXCLUDECLASSIFYALLOW_CHK 175\r\n#define IDC_EXCLUDEBLOCKLIST_CHK 176\r\n#define IDC_EXCLUDECUSTOM_CHK 177\r\n\r\n#define IDC_ENABLELOG_CHK 178\r\n#define IDC_LOGPATH 179\r\n#define IDC_LOGPATH_BTN 180\r\n\r\n#define IDC_LOGVIEWER 181\r\n#define IDC_LOGVIEWER_BTN 182\r\n\r\n#define IDC_ENABLEUILOG_CHK 183\r\n\r\n#define IDC_LOGSIZELIMIT_HINT 184\r\n#define IDC_LOGSIZELIMIT_CTRL 185\r\n#define IDC_LOGSIZELIMIT 186\r\n\r\n// Notification Dlg\r\n#define IDC_HEADER_ID 187\r\n#define IDC_FILE_TEXT 188\r\n#define IDC_SIGNATURE_TEXT 189\r\n#define IDC_ADDRESS_TEXT 190\r\n#define IDC_HOST_TEXT 191\r\n#define IDC_PORT_TEXT 192\r\n#define IDC_DIRECTION_TEXT 193\r\n#define IDC_FILTER_TEXT 194\r\n#define IDC_DATE_TEXT 195\r\n#define IDC_FILE_ID 196\r\n#define IDC_SIGNATURE_ID 197\r\n#define IDC_ADDRESS_ID 198\r\n#define IDC_HOST_ID 199\r\n#define IDC_PORT_ID 200\r\n#define IDC_DIRECTION_ID 201\r\n#define IDC_FILTER_ID 202\r\n#define IDC_DATE_ID 203\r\n\r\n#define IDC_RULES_BTN 204\r\n#define IDC_KILLPROCESS_BTN 205\r\n#define IDC_ALLOW_BTN 206\r\n#define IDC_BLOCK_BTN 207\r\n#define IDC_NEXT_BTN 208\r\n\r\n// Editor Dlg\r\n#define IDC_RULE_NAME 209\r\n#define IDC_RULE_NAME_ID 210\r\n#define IDC_RULE_COMMENT 211\r\n#define IDC_RULE_COMMENT_ID 212\r\n#define IDC_RULE_PROTOCOL 213\r\n#define IDC_RULE_PROTOCOL_ID 214\r\n#define IDC_RULE_VERSION 215\r\n#define IDC_RULE_VERSION_ID 216\r\n#define IDC_RULE_DIRECTION 217\r\n#define IDC_RULE_DIRECTION_ID 218\r\n#define IDC_RULE_ACTION 219\r\n#define IDC_RULE_ACTION_ID 220\r\n#define IDC_RULE_REMOTE 221\r\n#define IDC_RULE_REMOTE_ID 222\r\n#define IDC_RULE_REMOTE_ADD 223\r\n#define IDC_RULE_REMOTE_EDIT 224\r\n#define IDC_RULE_REMOTE_DELETE 225\r\n#define IDC_RULE_LOCAL 226\r\n#define IDC_RULE_LOCAL_ID 227\r\n#define IDC_RULE_LOCAL_ADD 228\r\n#define IDC_RULE_LOCAL_EDIT 229\r\n#define IDC_RULE_LOCAL_DELETE 230\r\n#define IDC_RULE_APPS_ID 231\r\n#define IDC_RULE_APPS_HINT 232\r\n#define IDC_RULE 233\r\n#define IDC_RULE_ID 234\r\n#define IDC_RULE_HINT 235\r\n#define IDC_APP_NAME 236\r\n#define IDC_APP_ICON_ID 237\r\n#define IDC_APP_NAME_ID 238\r\n#define IDC_APP_SIGNATURE_ID 239\r\n#define IDC_APP_PATH 240\r\n#define IDC_APP_PATH_ID 241\r\n#define IDC_APP_EXPLORE_ID 242\r\n#define IDC_APP_COMMENT 243\r\n#define IDC_APP_COMMENT_ID 244\r\n#define IDC_APP_HASH 245\r\n#define IDC_APP_HASH_ID 246\r\n#define IDC_APP_HASH_RECHECK_ID 247\r\n#define IDC_APP_RULES_ID 248\r\n#define IDC_APP_HINT 249\r\n#define IDC_ENABLE_CHK 250\r\n\r\n// Main Menu\r\n#define IDM_SETTINGS 251\r\n#define IDM_ADD_FILE 252\r\n#define IDM_IMPORT 253\r\n#define IDM_EXPORT 254\r\n#define IDM_EXIT 255\r\n#define IDM_PURGE_UNUSED 256\r\n#define IDM_PURGE_TIMERS 257\r\n#define IDM_LOGCLEAR 258\r\n#define IDM_FIND 259\r\n#define IDM_REFRESH 260\r\n#define IDM_ALWAYSONTOP_CHK 261\r\n#define IDM_SHOWFILENAMESONLY_CHK 262\r\n#define IDM_SHOWSEARCHBAR_CHK 263\r\n#define IDM_AUTOSIZECOLUMNS_CHK 264\r\n#define IDM_VIEW_DETAILS 265\r\n#define IDM_VIEW_ICON 266\r\n#define IDM_VIEW_TILE 267\r\n#define IDM_SIZE_SMALL 268\r\n#define IDM_SIZE_LARGE 269\r\n#define IDM_SIZE_EXTRALARGE 270\r\n#define IDM_ICONSISHIDDEN 271\r\n#define IDM_USEDARKTHEME_CHK 272\r\n#define IDM_FONT 273\r\n#define IDM_LOADONSTARTUP_CHK 274\r\n#define IDM_STARTMINIMIZED_CHK 275\r\n#define IDM_SKIPUACWARNING_CHK 276\r\n#define IDM_CHECKUPDATES_CHK 277\r\n#define IDM_RULE_BLOCKOUTBOUND 278\r\n#define IDM_RULE_BLOCKINBOUND 279\r\n#define IDM_RULE_ALLOWLOOPBACK 280\r\n#define IDM_RULE_ALLOW6TO4 281\r\n#define IDM_RULE_ALLOWWINDOWSUPDATE 282\r\n#define IDM_PROFILETYPE_PLAIN 283\r\n#define IDM_PROFILETYPE_COMPRESSED 284\r\n#define IDM_PROFILETYPE_ENCRYPTED 285\r\n#define IDM_USENETWORKRESOLUTION_CHK 286\r\n#define IDM_USECERTIFICATES_CHK 287\r\n#define IDM_KEEPUNUSED_CHK 288\r\n#define IDM_USEHASHES_CHK 289\r\n#define IDM_USEAPPMONITOR_CHK 290\r\n#define IDM_BLOCKLIST_SPY_DISABLE 291\r\n#define IDM_BLOCKLIST_SPY_ALLOW 292\r\n#define IDM_BLOCKLIST_SPY_BLOCK 293\r\n#define IDM_BLOCKLIST_UPDATE_DISABLE 294\r\n#define IDM_BLOCKLIST_UPDATE_ALLOW 295\r\n#define IDM_BLOCKLIST_UPDATE_BLOCK 296\r\n#define IDM_BLOCKLIST_EXTRA_DISABLE 297\r\n#define IDM_BLOCKLIST_EXTRA_ALLOW 298\r\n#define IDM_BLOCKLIST_EXTRA_BLOCK 299\r\n#define IDM_WEBSITE 300\r\n#define IDM_CHECKUPDATES 301\r\n#define IDM_DONATE 302\r\n#define IDM_ABOUT 303\r\n\r\n// Tray Menu\r\n#define IDM_TRAY_SHOW 304\r\n#define IDM_TRAY_START 305\r\n#define IDM_TRAY_ENABLENOTIFICATIONS_CHK 306\r\n#define IDM_TRAY_ENABLENOTIFICATIONSSOUND_CHK 307\r\n#define IDM_TRAY_NOTIFICATIONFULLSCREENSILENTMODE_CHK 308\r\n#define IDM_TRAY_NOTIFICATIONONTRAY_CHK 309\r\n#define IDM_TRAY_ENABLELOG_CHK 310\r\n#define IDM_TRAY_ENABLEUILOG_CHK 311\r\n#define IDM_TRAY_LOGSHOW 312\r\n#define IDM_TRAY_LOGCLEAR 313\r\n#define IDM_TRAY_LOGSHOW_ERR 314\r\n#define IDM_TRAY_LOGCLEAR_ERR 315\r\n#define IDM_TRAY_SETTINGS 316\r\n#define IDM_TRAY_WEBSITE 317\r\n#define IDM_TRAY_ABOUT 318\r\n#define IDM_TRAY_EXIT 319\r\n\r\n// Listview Menu\r\n#define IDM_EXPLORE 320\r\n#define IDM_DISABLENOTIFICATIONS 321\r\n#define IDM_DISABLEREMOVAL 322\r\n#define IDM_OPENRULESEDITOR 323\r\n#define IDM_COPY 324\r\n#define IDM_COPY_VALUE 325\r\n#define IDM_CHECK 326\r\n#define IDM_UNCHECK 327\r\n#define IDM_DELETE 328\r\n#define IDM_DISABLETIMER 329\r\n#define IDM_PROPERTIES 330\r\n\r\n#define IDM_NOTIMER 331\r\n\r\n#define IDM_SELECT_ALL 332\r\n#define IDM_ZOOM 333\r\n#define IDM_TAB_NEXT 334\r\n#define IDM_TAB_PREV 335\r\n\r\n#define IDX_LANGUAGE 1000\r\n#define IDX_TIMER 1200\r\n#define IDX_NOTIFICATIONS 1300\r\n#define IDX_RULES_SPECIAL 1400\r\n#define IDX_COLUMN 1500\r\n\r\n// Strings\r\n#define IDS_TITLE_EXCLUDE 1\r\n#define IDS_FILE 2\r\n#define IDS_SETTINGS 3\r\n#define IDS_EXIT 4\r\n#define IDS_EDIT 5\r\n#define IDS_PURGE_ERRORS 6\r\n#define IDS_PURGE_UNUSED 7\r\n#define IDS_PURGE_TIMERS 8\r\n#define IDS_FIND 9\r\n#define IDS_FINDNEXT 10\r\n#define IDS_REFRESH 11\r\n#define IDS_VIEW 12\r\n#define IDS_ICONS 13\r\n#define IDS_ICONSSMALL 14\r\n#define IDS_ICONSLARGE 15\r\n#define IDS_ICONSISHIDDEN 16\r\n#define IDS_LANGUAGE 17\r\n#define IDS_FONT 18\r\n#define IDS_HELP 19\r\n#define IDS_WEBSITE 20\r\n#define IDS_CHECKUPDATES 21\r\n#define IDS_DONATE 22\r\n#define IDS_ABOUT 23\r\n#define IDS_TRAY_SHOW 24\r\n#define IDS_TRAY_START 25\r\n#define IDS_TRAY_STOP 26\r\n#define IDS_TRAY_MODE 27\r\n#define IDS_TRAY_RULES 28\r\n#define IDS_TRAY_BLOCKLIST_RULES 29\r\n#define IDS_TRAY_SYSTEM_RULES 30\r\n#define IDS_TRAY_USER_RULES 31\r\n#define IDS_TRAY_LOG 32\r\n#define IDS_TRAY_LOGERR 33\r\n#define IDS_ADD_FILE 34\r\n#define IDS_ADD_PROCESS 35\r\n#define IDS_ADD_PACKAGE 36\r\n#define IDS_ADD_SERVICE 37\r\n#define IDS_ANY 38\r\n#define IDS_DISABLENOTIFICATIONS 39\r\n#define IDS_OPENRULESEDITOR 40\r\n#define IDS_TIMER 41\r\n#define IDS_NOTIMER 42\r\n#define IDS_DISABLETIMER 43\r\n#define IDS_EXPLORE 44\r\n#define IDS_COPY 45\r\n#define IDS_SELECT_ALL 46\r\n#define IDS_CHECK 47\r\n#define IDS_UNCHECK 48\r\n#define IDS_ADD 49\r\n#define IDS_EDIT2 50\r\n#define IDS_DELETE 51\r\n#define IDS_EXPORT 52\r\n#define IDS_IMPORT 53\r\n#define IDS_MODE_WHITELIST 54\r\n#define IDS_MODE_BLACKLIST 55\r\n#define IDS_RULE_ALLOWINBOUND 56\r\n#define IDS_RULE_ALLOWLISTEN 57\r\n#define IDS_RULE_ALLOWLOOPBACK 58\r\n#define IDS_HIGHLIGHT_INVALID 59\r\n#define IDS_HIGHLIGHT_NETWORK 60\r\n#define IDS_HIGHLIGHT_PACKAGE 61\r\n#define IDS_HIGHLIGHT_PICO 62\r\n#define IDS_HIGHLIGHT_SERVICE 63\r\n#define IDS_HIGHLIGHT_SIGNED 64\r\n#define IDS_HIGHLIGHT_SILENT 65\r\n#define IDS_HIGHLIGHT_SPECIAL 66\r\n#define IDS_HIGHLIGHT_SYSTEM 67\r\n#define IDS_GROUP_TIMER 68\r\n#define IDS_EDITOR 69\r\n#define IDS_NAME 70\r\n#define IDS_RULE 71\r\n#define IDS_PORTVERSION 72\r\n#define IDS_PROTOCOL 73\r\n#define IDS_DIRECTION 74\r\n#define IDS_ACTION 75\r\n#define IDS_DATE 76\r\n#define IDS_FILEPATH 77\r\n#define IDS_SIGNATURE 78\r\n#define IDS_ADDRESS 79\r\n#define IDS_FILTER 80\r\n#define IDS_NOTES 81\r\n#define IDS_ADDED 82\r\n#define IDS_REGION 83\r\n#define IDS_TIMELEFT 84\r\n#define IDS_SIGN_SIGNED 85\r\n#define IDS_SIGN_UNSIGNED 86\r\n#define IDS_GROUP_ALLOWED 87\r\n#define IDS_GROUP_BLOCKED 88\r\n#define IDS_GROUP_ENABLED 89\r\n#define IDS_GROUP_SPECIAL 90\r\n#define IDS_GROUP_DISABLED 91\r\n#define IDS_DIRECTION_1 92\r\n#define IDS_DIRECTION_2 93\r\n#define IDS_DIRECTION_3 94\r\n#define IDS_ACTION_ALLOW 95\r\n#define IDS_ACTION_BLOCK 96\r\n#define IDS_ACTION_LATER 97\r\n#define IDS_RULE_APPLY 98\r\n#define IDS_DISABLE_CHK 99\r\n#define IDS_ENABLE_CHK 100\r\n#define IDS_ENABLEFORAPPS_CHK 101\r\n#define IDS_WIKI 102\r\n#define IDS_SAVE 103\r\n#define IDS_CLOSE 104\r\n#define IDS_SETTINGS_GENERAL 105\r\n#define IDS_TITLE_GENERAL 106\r\n#define IDS_TITLE_LANGUAGE 107\r\n#define IDS_TITLE_CONFIRMATIONS 108\r\n#define IDS_TITLE_INTERFACE 109\r\n#define IDS_TITLE_HIGHLIGHTING 110\r\n#define IDS_TITLE_EXPERTS 111\r\n#define IDS_TITLE_LOGGING 112\r\n#define IDS_TITLE_NOTIFICATIONS 113\r\n#define IDS_TITLE_ADVANCED 114\r\n#define IDS_ALWAYSONTOP_CHK 115\r\n#define IDS_LOADONSTARTUP_CHK 116\r\n#define IDS_STARTMINIMIZED_CHK 117\r\n#define IDS_SHOWFILENAMESONLY_CHK 118\r\n#define IDS_AUTOSIZECOLUMNS_CHK 119\r\n#define IDS_SKIPUACWARNING_CHK 120\r\n#define IDS_CHECKUPDATES_CHK 121\r\n#define IDS_LANGUAGE_HINT 122\r\n#define IDS_USEFULLBLOCKLIST_CHK 123\r\n#define IDS_USEFULLBLOCKLIST_HINT 124\r\n#define IDS_USESTEALTHMODE_CHK 125\r\n#define IDS_USESTEALTHMODE_HINT 126\r\n#define IDS_INSTALLBOOTTIMEFILTERS_CHK 127\r\n#define IDS_INSTALLBOOTTIMEFILTERS_HINT 128\r\n#define IDS_PROXYSUPPORT_CHK 129\r\n#define IDS_PROXYSUPPORT_HINT 130\r\n#define IDS_USEHOSTS_CHK 131\r\n#define IDS_USECERTIFICATES_CHK 132\r\n#define IDS_USENETWORKRESOLUTION_CHK 133\r\n#define IDS_DISABLEWINDOWSFIREWALL_CHK 134\r\n#define IDS_ENABLEWINDOWSFIREWALL_CHK 135\r\n#define IDS_CONFIRMEXIT_CHK 136\r\n#define IDS_CONFIRMEXITTIMER_CHK 137\r\n#define IDS_CONFIRMDELETE_CHK 138\r\n#define IDS_CONFIRMLOGCLEAR_CHK 139\r\n#define IDS_COLORS_HINT 140\r\n#define IDS_ENABLELOG_CHK 141\r\n#define IDS_LOGSHOW 142\r\n#define IDS_LOGCLEAR 143\r\n#define IDS_LOGSIZELIMIT_HINT 144\r\n#define IDS_ENABLENOTIFICATIONS_CHK 145\r\n#define IDS_NOTIFICATIONSOUND_CHK 146\r\n#define IDS_NOTIFICATIONNOBLOCKLIST_CHK 147\r\n#define IDS_NOTIFICATIONDISPLAYTIMEOUT_HINT 148\r\n#define IDS_NOTIFICATIONTIMEOUT_HINT 149\r\n#define IDS_RULES_BLOCKLIST_HINT 150\r\n#define IDS_RULES_SYSTEM_HINT 151\r\n#define IDS_RULES_USER_HINT 152\r\n#define IDS_NOTIFY_CREATERULE_ADDRESS 153\r\n#define IDS_NOTIFY_CREATERULE_PORT 154\r\n#define IDS_NOTIFY_DISABLENOTIFICATIONS 155\r\n#define IDS_NOTIFY_TOOLTIP 156\r\n#define IDS_QUESTION 157\r\n#define IDS_QUESTION_DELETE 158\r\n#define IDS_QUESTION_START 159\r\n#define IDS_QUESTION_STOP 160\r\n#define IDS_QUESTION_MODE 161\r\n#define IDS_QUESTION_EXIT 162\r\n#define IDS_QUESTION_LISTEN 163\r\n#define IDS_QUESTION_EXPERT 164\r\n#define IDS_QUESTION_TIMER 165\r\n#define IDS_QUESTION_TIMERS 166\r\n#define IDS_QUESTION_FLAG_CHK 167\r\n#define IDS_STATUS_TOTAL 168\r\n#define IDS_STATUS_SELECTED 169\r\n#define IDS_STATUS_EMPTY 170\r\n#define IDS_STATUS_ERROR 171\r\n#define IDS_STATUS_SYNTAX_ERROR 172\r\n#define IDS_ADDRESS_LOCAL 173\r\n#define IDS_ADDRESS_REMOTE 174\r\n#define IDS_UPDATE_ERROR 175\r\n#define IDS_CHECKUPDATESBETA_CHK 176\r\n#define IDS_CHECKUPDATES_LANGUAGE 177\r\n#define IDS_CHECKUPDATES_BLOCKLIST 178\r\n#define IDS_UPDATE_DOWNLOAD 179\r\n#define IDS_UPDATE_DONE 180\r\n#define IDS_GROUP_SPECIAL_APPS 181\r\n#define IDS_RULE_ALLOWINBOUND_HINT 182\r\n#define IDS_RULE_ALLOWLISTEN_HINT 183\r\n#define IDS_RULE_ALLOWLOOPBACK_HINT 184\r\n#define IDS_PROPERTIES 185\r\n#define IDS_RESET 186\r\n#define IDS_QUESTION_RESET 187\r\n#define IDS_TITLE_EXCLUSION 188\r\n#define IDS_EXCLUDESTEALTH_CHK 189\r\n#define IDS_EXCLUDEBLOCKLIST_CHK 190\r\n#define IDS_UPDATE_INIT 191\r\n#define IDS_UPDATE_INSTALL 192\r\n#define IDS_EXCLUDECUSTOM_CHK 193\r\n#define IDS_ENABLESPECIALGROUP_CHK 194\r\n#define IDS_EXCLUDECLASSIFYALLOW_CHK 195\r\n#define IDS_STATUS_TIMER_DONE 196\r\n#define IDS_ICONSEXTRALARGE 197\r\n#define IDS_STATUS_UNUSED_APPS 198\r\n#define IDS_STATUS_INVALID_APPS 199\r\n#define IDS_STATUS_TIMER_APPS 200\r\n#define IDS_SECUREFILTERS_CHK 201\r\n#define IDS_SECUREFILTERS_HINT 202\r\n#define IDS_USEREFRESHDEVICES_CHK 203\r\n#define IDS_RULE_ALLOW6TO4 204\r\n#define IDS_RECOMMENDED 205\r\n#define IDS_ICONSISTABLEVIEW 206\r\n#define IDS_ACTION_IGNORE 207\r\n#define IDS_ACTION_ALLOW_HINT 208\r\n#define IDS_ACTION_BLOCK_HINT 209\r\n#define IDS_ACTION_LATER_HINT 210\r\n#define IDS_RULE_APPLY_2 211\r\n#define IDS_EDITRULES 212\r\n#define IDS_TAB_APPS 213\r\n#define IDS_TAB_SERVICES 214\r\n#define IDS_TAB_PACKAGES 215\r\n#define IDS_TAB_NETWORK 216\r\n#define IDS_STATE 217\r\n#define IDS_STATUS_FILTERS_ACTIVE 218\r\n#define IDS_STATUS_FILTERS_INACTIVE 219\r\n#define IDS_STATUS_FILTERS_PROCESSING 220\r\n#define IDS_HIGHLIGHT_CONNECTION 221\r\n#define IDS_SHOWINLIST 222\r\n#define IDS_BLOCKLIST_SPY 223\r\n#define IDS_BLOCKLIST_UPDATE 224\r\n#define IDS_BLOCKLIST_EXTRA 225\r\n#define IDS_PORT 226\r\n#define IDS_NOTIFY_TITLE 227\r\n#define IDS_NOTIFY_HEADER 228\r\n#define IDS_DISABLE 229\r\n#define IDS_TITLE_SECURITY 230\r\n#define IDS_LOGVIEWER_HINT 231\r\n#define IDS_NOTIFICATIONONTRAY_CHK 232\r\n#define IDS_NETWORK_CLOSE 233\r\n#define IDS_RULE_BLOCKOUTBOUND 234\r\n#define IDS_RULE_BLOCKINBOUND 235\r\n#define IDS_VIEW_ICON 236\r\n#define IDS_VIEW_DETAILS 237\r\n#define IDS_VIEW_TILE 238\r\n#define IDS_RULE_HINT 239\r\n#define IDS_RULE_APPS_HINT 240\r\n#define IDS_STATUS_FILTERS_ACTIVE_TEMP 241\r\n#define IDS_INSTALL_PERMANENT 242\r\n#define IDS_INSTALL_TEMPORARY 243\r\n#define IDS_ENABLEUILOG_CHK 244\r\n#define IDS_NOTIFICATIONFULLSCREENSILENTMODE_CHK 245\r\n#define IDS_TITLE_TRAY 246\r\n#define IDS_TRAYICONSINGLECLICK_CHK 247\r\n#define IDS_ENABLE_APP_CHK 248\r\n#define IDS_APP_HINT 249\r\n#define IDS_HOST 250\r\n#define IDS_CONFIRMALLOW_CHK 251\r\n#define IDS_QUESTION_ALLOW 252\r\n#define IDS_SHOWSEARCHBAR_CHK 253\r\n#define IDS_LAYER 254\r\n#define IDS_RULE_ALLOWWINDOWSUPDATE 255\r\n#define IDS_ACTION_TERMINATE_HINT 256\r\n#define IDS_PROFILE_TYPE 257\r\n#define IDS_USEAPPMONITOR_CHK 258\r\n#define IDS_DISABLEREMOVAL 259\r\n#define IDS_USEHASHES_CHK 260\r\n#define IDS_COMMENT 261\r\n#define IDS_USEDARKTHEME 262\r\n#define IDS_KEEPUNUSED_CHK 263\r\n#define IDS_UPDATE_NO 264\r\n#define IDS_UPDATE_YES 265\r\n#define IDS_UPDATE_SPEED 266\r\n#define IDS_RULE_FOR_ALL 267\r\n#define IDS_RULE_FOR_APPS 268\r\n#define IDS_PROFILE_TYPE_PLAIN 269\r\n#define IDS_PROFILE_TYPE_COMPRESSED 270\r\n#define IDS_PROFILE_TYPE_ENCRYPTED 271\r\n#define IDS_SESSION_ONLY 272\r\n#define IDS_LIMIT_REACHED 273\r\n#define IDS_INTERNAL_RULE 274\r\n#define IDS_LOADING 275\r\n#define IDS_DIRECTION_REMOTE 276\r\n#define IDS_DIRECTION_LOCAL 277\r\n\r\n// RC data\r\n#define IDR_PROFILE_INTERNAL 1\r\n\r\n// PNG\r\n#define IDP_ADD 100\r\n#define IDP_ALLOW 101\r\n#define IDP_BLOCK 102\r\n#define IDP_CROSS 103\r\n#define IDP_NEXT 104\r\n#define IDP_SHIELD_ENABLE 105\r\n#define IDP_SHIELD_DISABLE 106\r\n#define IDP_REFRESH 107\r\n#define IDP_SETTINGS 108\r\n#define IDP_NOTIFICATIONS 109\r\n#define IDP_LOG 110\r\n#define IDP_LOGOPEN 111\r\n#define IDP_LOGCLEAR 112\r\n#define IDP_DONATE 113\r\n#define IDP_LOGUI 114\r\n#define IDP_SEARCH_LIGHT 115\r\n#define IDP_SEARCH_DARK 116\r\n\r\n// Icons\r\n#define IDI_MAIN 100\r\n#define IDI_ACTIVE IDI_MAIN\r\n#define IDI_INACTIVE 101\r\n\r\n#endif // __RESOURCE_H__\r\n"
  },
  {
    "path": "src/resource.rc",
    "content": "#include <windows.h>\r\n#include <commctrl.h>\r\n#include <richedit.h>\r\n\r\n#include \"resource.h\"\r\n#include \"rconfig.h\"\r\n#include \"app.h\"\r\n\r\nLANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT\r\n\r\n//\r\n// Accelerator resources\r\n//\r\nIDA_MAIN ACCELERATORS\r\nBEGIN\r\n\t\"A\", IDM_SELECT_ALL, CONTROL, VIRTKEY, NOINVERT\r\n\t\"C\", IDM_COPY, CONTROL, VIRTKEY, NOINVERT\r\n\t\"E\", IDM_EXPLORE, CONTROL, VIRTKEY, NOINVERT\r\n\t\"F\", IDM_FIND, CONTROL, VIRTKEY, NOINVERT\r\n\t\"S\", IDM_EXPORT, CONTROL, VIRTKEY, NOINVERT\r\n\t\"O\", IDM_IMPORT, CONTROL, VIRTKEY, NOINVERT\r\n\t\"I\", IDM_TRAY_LOGSHOW, CONTROL, VIRTKEY, NOINVERT\r\n\t\"T\", IDM_PURGE_TIMERS, CONTROL, SHIFT, VIRTKEY, NOINVERT\r\n\t\"X\", IDM_TRAY_LOGCLEAR, CONTROL, VIRTKEY, NOINVERT\r\n\t\"X\", IDM_PURGE_UNUSED, CONTROL, SHIFT, VIRTKEY, NOINVERT\r\n\tVK_RETURN, IDM_PROPERTIES, VIRTKEY, NOINVERT\r\n\tVK_DELETE, IDM_DELETE, VIRTKEY, NOINVERT\r\n\tVK_TAB, IDM_TAB_NEXT, VIRTKEY, CONTROL, NOINVERT\r\n\tVK_TAB, IDM_TAB_PREV, VIRTKEY, SHIFT, CONTROL, NOINVERT\r\n\tVK_F1, IDM_ABOUT, VIRTKEY, NOINVERT\r\n\tVK_F2, IDM_SETTINGS, VIRTKEY, NOINVERT\r\n\tVK_F4, IDM_TRAY_SHOW, ALT, VIRTKEY, NOINVERT\r\n\tVK_F5, IDM_REFRESH, VIRTKEY, NOINVERT\r\n\tVK_F11, IDM_ZOOM, VIRTKEY, NOINVERT\r\nEND\r\n\r\n//\r\n// Menu resources\r\n//\r\nIDM_MAIN MENU\r\nBEGIN\r\n\tPOPUP \" \"\r\n\tBEGIN\r\n\t\tMENUITEM \" \", IDM_SETTINGS\r\n\t\tMENUITEM SEPARATOR\r\n\t\tMENUITEM \" \", IDM_ADD_FILE\r\n\t\tMENUITEM SEPARATOR\r\n\t\tMENUITEM \" \", IDM_IMPORT\r\n\t\tMENUITEM \" \", IDM_EXPORT\r\n\t\tMENUITEM SEPARATOR\r\n\t\tMENUITEM \" \", IDM_EXIT\r\n\tEND\r\n\tPOPUP \" \"\r\n\tBEGIN\r\n\t\tMENUITEM \" \", IDM_PURGE_UNUSED\r\n\t\tMENUITEM \" \", IDM_PURGE_TIMERS\r\n\t\tMENUITEM SEPARATOR\r\n\t\tMENUITEM \" \", IDM_LOGCLEAR\r\n\t\tMENUITEM SEPARATOR\r\n\t\tMENUITEM \" \", IDM_REFRESH\r\n\tEND\r\n\tPOPUP \" \"\r\n\tBEGIN\r\n\t\tMENUITEM \" \", IDM_ALWAYSONTOP_CHK\r\n\t\tMENUITEM \" \", IDM_USEDARKTHEME_CHK\r\n\t\tMENUITEM \" \", IDM_AUTOSIZECOLUMNS_CHK\r\n\t\tMENUITEM \" \", IDM_SHOWFILENAMESONLY_CHK\r\n\t\tMENUITEM \" \", IDM_SHOWSEARCHBAR_CHK\r\n\t\tMENUITEM SEPARATOR\r\n\t\tPOPUP \" \"\r\n\t\tBEGIN\r\n\t\t\tMENUITEM \" \", IDM_VIEW_DETAILS\r\n\t\t\tMENUITEM \" \", IDM_VIEW_ICON\r\n\t\t\tMENUITEM \" \", IDM_VIEW_TILE\r\n\t\t\tMENUITEM SEPARATOR\r\n\t\t\tMENUITEM \" \", IDM_SIZE_SMALL\r\n\t\t\tMENUITEM \" \", IDM_SIZE_LARGE\r\n\t\t\tMENUITEM \" \", IDM_SIZE_EXTRALARGE\r\n\t\t\tMENUITEM SEPARATOR\r\n\t\t\tMENUITEM \" \", IDM_ICONSISHIDDEN\r\n\t\tEND\r\n\t\tPOPUP \" \"\r\n\t\tBEGIN\r\n\t\t\tMENUITEM \" \", IDX_LANGUAGE\r\n\t\tEND\r\n\t\tMENUITEM SEPARATOR\r\n\t\tMENUITEM \" \", IDM_FONT\r\n\tEND\r\n\tPOPUP \" \"\r\n\tBEGIN\r\n\t\tMENUITEM \" \", IDM_LOADONSTARTUP_CHK\r\n\t\tMENUITEM \" \", IDM_STARTMINIMIZED_CHK\r\n\t\tMENUITEM \" \", IDM_SKIPUACWARNING_CHK\r\n\t\tMENUITEM \" \", IDM_CHECKUPDATES_CHK\r\n\t\tMENUITEM SEPARATOR\r\n\t\tPOPUP \" \"\r\n\t\tBEGIN\r\n\t\t\tMENUITEM \" \", IDM_RULE_BLOCKOUTBOUND\r\n\t\t\tMENUITEM \" \", IDM_RULE_BLOCKINBOUND\r\n\t\t\tMENUITEM SEPARATOR\r\n\t\t\tMENUITEM \" \", IDM_RULE_ALLOWLOOPBACK\r\n\t\t\tMENUITEM \" \", IDM_RULE_ALLOW6TO4\r\n\t\t\tMENUITEM \" \", IDM_RULE_ALLOWWINDOWSUPDATE\r\n\t\tEND\r\n\t\tPOPUP \" \"\r\n\t\tBEGIN\r\n\t\t\tMENUITEM \" \", IDM_PROFILETYPE_PLAIN\r\n\t\t\tMENUITEM \" \", IDM_PROFILETYPE_COMPRESSED\r\n\t\t\tMENUITEM \" \", IDM_PROFILETYPE_ENCRYPTED\r\n\t\tEND\r\n\t\tMENUITEM SEPARATOR\r\n\t\tMENUITEM \" \", IDM_USENETWORKRESOLUTION_CHK\r\n\t\tMENUITEM \" \", IDM_USECERTIFICATES_CHK\r\n\t\tMENUITEM \" \", IDM_KEEPUNUSED_CHK\r\n\t\tMENUITEM \" \", IDM_USEHASHES_CHK\r\n\t\tMENUITEM \" \", IDM_USEAPPMONITOR_CHK\r\n\tEND\r\n\tPOPUP \" \"\r\n\tBEGIN\r\n\t\tPOPUP \" \"\r\n\t\tBEGIN\r\n\t\t\tMENUITEM \" \", IDM_BLOCKLIST_SPY_DISABLE\r\n\t\t\tMENUITEM \" \", IDM_BLOCKLIST_SPY_ALLOW\r\n\t\t\tMENUITEM \" \", IDM_BLOCKLIST_SPY_BLOCK\r\n\t\tEND\r\n\t\tPOPUP \" \"\r\n\t\tBEGIN\r\n\t\t\tMENUITEM \" \", IDM_BLOCKLIST_UPDATE_DISABLE\r\n\t\t\tMENUITEM \" \", IDM_BLOCKLIST_UPDATE_ALLOW\r\n\t\t\tMENUITEM \" \", IDM_BLOCKLIST_UPDATE_BLOCK\r\n\t\tEND\r\n\t\tPOPUP \" \"\r\n\t\tBEGIN\r\n\t\t\tMENUITEM \" \", IDM_BLOCKLIST_EXTRA_DISABLE\r\n\t\t\tMENUITEM \" \", IDM_BLOCKLIST_EXTRA_ALLOW\r\n\t\t\tMENUITEM \" \", IDM_BLOCKLIST_EXTRA_BLOCK\r\n\t\tEND\r\n\tEND\r\n\tPOPUP \" \"\r\n\tBEGIN\r\n\t\tMENUITEM \" \", IDM_WEBSITE\r\n\t\tMENUITEM \" \", IDM_CHECKUPDATES\r\n\t\tMENUITEM \" \", IDM_ABOUT\r\n\tEND\r\nEND\r\n\r\nIDM_TRAY MENU\r\nBEGIN\r\n\tPOPUP \"\"\r\n\tBEGIN\r\n\t\tMENUITEM \" \", IDM_TRAY_SHOW\r\n\t\tMENUITEM SEPARATOR\r\n\t\tMENUITEM \" \", IDM_TRAY_START\r\n\t\tMENUITEM SEPARATOR\r\n\t\tPOPUP \" \"\r\n\t\tBEGIN\r\n\t\t\tMENUITEM \" \", IDM_TRAY_ENABLENOTIFICATIONS_CHK\r\n\t\t\tMENUITEM SEPARATOR\r\n\t\t\tMENUITEM \" \", IDM_TRAY_ENABLENOTIFICATIONSSOUND_CHK\r\n\t\t\tMENUITEM \" \", IDM_TRAY_NOTIFICATIONFULLSCREENSILENTMODE_CHK\r\n\t\t\tMENUITEM \" \", IDM_TRAY_NOTIFICATIONONTRAY_CHK\r\n\t\tEND\r\n\t\tPOPUP \" \"\r\n\t\tBEGIN\r\n\t\t\tMENUITEM \" \", IDM_TRAY_ENABLELOG_CHK\r\n\t\t\tMENUITEM \" \", IDM_TRAY_ENABLEUILOG_CHK\r\n\t\t\tMENUITEM SEPARATOR\r\n\t\t\tMENUITEM \" \", IDM_TRAY_LOGSHOW\r\n\t\t\tMENUITEM \" \", IDM_TRAY_LOGCLEAR\r\n\t\tEND\r\n\t\tPOPUP \" \"\r\n\t\tBEGIN\r\n\t\t\tMENUITEM \" \", IDM_TRAY_LOGSHOW_ERR\r\n\t\t\tMENUITEM \" \", IDM_TRAY_LOGCLEAR_ERR\r\n\t\tEND\r\n\t\tMENUITEM SEPARATOR\r\n\t\tMENUITEM \" \", IDM_TRAY_SETTINGS\r\n\t\tMENUITEM SEPARATOR\r\n\t\tMENUITEM \" \", IDM_TRAY_WEBSITE\r\n\t\tMENUITEM \" \", IDM_TRAY_ABOUT\r\n\t\tMENUITEM SEPARATOR\r\n\t\tMENUITEM \" \", IDM_TRAY_EXIT\r\n\tEND\r\nEND\r\n\r\n//\r\n// Dialog resources\r\n//\r\nIDD_MAIN DIALOGEX 0, 0, 348, 196\r\nSTYLE WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | DS_SHELLFONT | DS_MODALFRAME | NOT WS_VISIBLE\r\nCAPTION APP_NAME\r\nMENU IDM_MAIN\r\nFONT 8, \"Ms Shell Dlg\"\r\nBEGIN\r\n\tCONTROL\t\t\t\"\", IDC_REBAR, REBARCLASSNAME, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CCS_NODIVIDER | CCS_TOP | RBS_VARHEIGHT | RBS_AUTOSIZE, 0, 0, 0, 0\r\n\r\n\tCONTROL\t\t\t\"\", IDC_TAB, WC_TABCONTROL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | TCS_HOTTRACK | TCS_TOOLTIPS | TCS_MULTILINE | TCS_FOCUSONBUTTONDOWN, 0, 0, 348, 158\r\n\r\n\tCONTROL\t\t\t\"\", IDC_APPS_PROFILE, WC_LISTVIEW, WS_CHILD | NOT WS_VISIBLE | WS_TABSTOP | LVS_SHOWSELALWAYS | LVS_REPORT | LVS_SHAREIMAGELISTS | LVS_AUTOARRANGE, 0, 14, 348, 170\r\n\tCONTROL\t\t\t\"\", IDC_APPS_SERVICE, WC_LISTVIEW, WS_CHILD | NOT WS_VISIBLE | WS_TABSTOP | LVS_SHOWSELALWAYS | LVS_REPORT | LVS_SHAREIMAGELISTS | LVS_AUTOARRANGE, 0, 14, 348, 170\r\n\tCONTROL\t\t\t\"\", IDC_APPS_UWP, WC_LISTVIEW, WS_CHILD | NOT WS_VISIBLE | WS_TABSTOP | LVS_SHOWSELALWAYS | LVS_REPORT | LVS_SHAREIMAGELISTS | LVS_AUTOARRANGE, 0, 14, 348, 170\r\n\tCONTROL\t\t\t\"\", IDC_RULES_BLOCKLIST, WC_LISTVIEW, WS_CHILD | NOT WS_VISIBLE | WS_TABSTOP | LVS_SHOWSELALWAYS | LVS_REPORT | LVS_SHAREIMAGELISTS | LVS_AUTOARRANGE, 0, 14, 348, 170\r\n\tCONTROL\t\t\t\"\", IDC_RULES_SYSTEM, WC_LISTVIEW, WS_CHILD | NOT WS_VISIBLE | WS_TABSTOP | LVS_SHOWSELALWAYS | LVS_REPORT | LVS_SHAREIMAGELISTS | LVS_AUTOARRANGE, 0, 14, 348, 170\r\n\tCONTROL\t\t\t\"\", IDC_RULES_CUSTOM, WC_LISTVIEW, WS_CHILD | NOT WS_VISIBLE | WS_TABSTOP | LVS_SHOWSELALWAYS | LVS_REPORT | LVS_SHAREIMAGELISTS | LVS_AUTOARRANGE, 0, 14, 348, 170\r\n\tCONTROL\t\t\t\"\", IDC_NETWORK, WC_LISTVIEW, WS_CHILD | NOT WS_VISIBLE | WS_TABSTOP | LVS_SHOWSELALWAYS | LVS_REPORT | LVS_SHAREIMAGELISTS | LVS_AUTOARRANGE, 0, 14, 348, 170\r\n\tCONTROL\t\t\t\"\", IDC_LOG, WC_LISTVIEW, WS_CHILD | NOT WS_VISIBLE | WS_TABSTOP | LVS_SHOWSELALWAYS | LVS_REPORT | LVS_SHAREIMAGELISTS | LVS_AUTOARRANGE, 0, 14, 348, 170\r\n\r\n\tCONTROL\t\t\t\"\", IDC_STATUSBAR, STATUSCLASSNAME, SBARS_TOOLTIPS, 0, 0, 0, 0\r\nEND\r\n\r\nIDD_NOTIFICATION DIALOGEX 0, 0, 320, 192\r\nSTYLE WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_POPUP | WS_BORDER | WS_SYSMENU | WS_CAPTION | DS_SHELLFONT | NOT WS_VISIBLE\r\nEXSTYLE WS_EX_APPWINDOW\r\nFONT 8, \"Ms Shell Dlg\"\r\nBEGIN\r\n\tCONTROL\t\t\t\"\", IDC_HEADER_ID, WC_STATIC, SS_OWNERDRAW, 0, 0, 320, 40\r\n\r\n\tLTEXT\t\t\t\"\", IDC_FILE_ID, 8, 46, 144, 12, WS_CHILD | WS_VISIBLE | SS_ENDELLIPSIS | SS_CENTERIMAGE\r\n\tLTEXT\t\t\t\"\", IDC_FILE_TEXT, 168, 46, 144, 12, WS_CHILD | WS_VISIBLE | SS_ENDELLIPSIS | SS_CENTERIMAGE | SS_NOTIFY | SS_RIGHT\r\n\r\n\tLTEXT\t\t\t\"\", IDC_SIGNATURE_ID, 8, 60, 144, 10, WS_CHILD | WS_VISIBLE | SS_ENDELLIPSIS | SS_CENTERIMAGE\r\n\tEDITTEXT\t\tIDC_SIGNATURE_TEXT, 168, 60, 144, 12, WS_CHILD | WS_VISIBLE | NOT WS_TABSTOP | NOT WS_BORDER | ES_READONLY | ES_AUTOHSCROLL | ES_RIGHT\r\n\r\n\tLTEXT\t\t\t\"\", IDC_ADDRESS_ID, 8, 74, 144, 10, WS_CHILD | WS_VISIBLE | SS_ENDELLIPSIS | SS_CENTERIMAGE\r\n\tEDITTEXT\t\tIDC_ADDRESS_TEXT, 168, 74, 144, 12, WS_CHILD | WS_VISIBLE | NOT WS_TABSTOP | NOT WS_BORDER | ES_READONLY | ES_AUTOHSCROLL | ES_RIGHT\r\n\r\n\tLTEXT\t\t\t\"\", IDC_HOST_ID, 8, 88, 144, 10, WS_CHILD | WS_VISIBLE | SS_ENDELLIPSIS | SS_CENTERIMAGE\r\n\tEDITTEXT\t\tIDC_HOST_TEXT, 168, 88, 144, 12, WS_CHILD | WS_VISIBLE | NOT WS_TABSTOP | NOT WS_BORDER | ES_READONLY | ES_AUTOHSCROLL | ES_RIGHT\r\n\r\n\tLTEXT\t\t\t\"\", IDC_PORT_ID, 8, 102, 144, 10, WS_CHILD | WS_VISIBLE | SS_ENDELLIPSIS | SS_CENTERIMAGE\r\n\tEDITTEXT\t\tIDC_PORT_TEXT, 168, 102, 144, 12, WS_CHILD | WS_VISIBLE | NOT WS_TABSTOP | NOT WS_BORDER | ES_READONLY | ES_AUTOHSCROLL | ES_RIGHT\r\n\r\n\tLTEXT\t\t\t\"\", IDC_DIRECTION_ID, 8, 116, 144, 10, WS_CHILD | WS_VISIBLE | SS_ENDELLIPSIS | SS_CENTERIMAGE\r\n\tEDITTEXT\t\tIDC_DIRECTION_TEXT, 168, 116, 144, 12, WS_CHILD | WS_VISIBLE | NOT WS_TABSTOP | NOT WS_BORDER | ES_READONLY | ES_AUTOHSCROLL | ES_RIGHT\r\n\r\n\tLTEXT\t\t\t\"\", IDC_FILTER_ID, 8, 130, 144, 10, WS_CHILD | WS_VISIBLE | SS_ENDELLIPSIS | SS_CENTERIMAGE\r\n\tEDITTEXT\t\tIDC_FILTER_TEXT, 168, 130, 144, 12, WS_CHILD | WS_VISIBLE | NOT WS_TABSTOP | NOT WS_BORDER | ES_READONLY | ES_AUTOHSCROLL | ES_RIGHT\r\n\r\n\tLTEXT\t\t\t\"\", IDC_DATE_ID, 8, 144, 144, 10, WS_CHILD | WS_VISIBLE | SS_ENDELLIPSIS | SS_CENTERIMAGE\r\n\tEDITTEXT\t\tIDC_DATE_TEXT, 168, 144, 144, 12, WS_CHILD | WS_VISIBLE | NOT WS_TABSTOP | NOT WS_BORDER | ES_READONLY | ES_AUTOHSCROLL | ES_RIGHT\r\n\r\n\tPUSHBUTTON\t\t\"\", IDC_RULES_BTN, 8, 170, 32, 15, WS_TABSTOP | WS_CHILD | WS_VISIBLE | BS_SPLITBUTTON | BS_ICON\r\n\tPUSHBUTTON\t\t\"\", IDC_KILLPROCESS_BTN, 44, 170, 26, 15, WS_TABSTOP | WS_CHILD | WS_VISIBLE | BS_ICON | BS_PUSHBUTTON\r\n\r\n\tPUSHBUTTON\t\t\"\", IDC_ALLOW_BTN, 114, 170, 82, 15, WS_TABSTOP | WS_CHILD | WS_VISIBLE | BS_SPLITBUTTON\r\n\tPUSHBUTTON\t\t\"\", IDC_BLOCK_BTN, 200, 170, 82, 15, WS_TABSTOP | WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON\r\n\tPUSHBUTTON\t\t\"\", IDC_NEXT_BTN, 286, 170, 26, 15, WS_TABSTOP | WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON | BS_ICON\r\nEND\r\n\r\nIDD_EDITOR DIALOGEX 0, 0, 292, 224\r\nSTYLE WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_POPUP | WS_BORDER | WS_SYSMENU | WS_CAPTION | DS_SHELLFONT | DS_MODALFRAME\r\nEXSTYLE WS_EX_APPWINDOW | WS_EX_CONTROLPARENT\r\nFONT 8, \"Ms Shell Dlg\"\r\nBEGIN\r\n\tCONTROL\t\t\t\"\", IDC_TAB, WC_TABCONTROL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | TCS_HOTTRACK | TCS_TOOLTIPS, 0, 0, 292, 196\r\n\r\n\tAUTOCHECKBOX\t\"\", IDC_ENABLE_CHK, 8, 202, 166, 14, BS_VCENTER\r\n\r\n\tDEFPUSHBUTTON\t\"\", IDC_SAVE, 180, 202, 50, 14, WS_TABSTOP\r\n\tPUSHBUTTON\t\t\"\", IDC_CLOSE, 234, 202, 50, 14, WS_TABSTOP\r\nEND\r\n\r\nIDD_EDITOR_GENERAL DIALOGEX 0, 0, 292, 210\r\nSTYLE WS_CHILD | WS_SYSMENU | WS_TABSTOP | WS_GROUP | DS_SHELLFONT | DS_CONTROL\r\nEXSTYLE WS_EX_CONTROLPARENT\r\nFONT 8, \"Ms Shell Dlg\"\r\nBEGIN\r\n\tGROUPBOX\t\t\"\", IDC_RULE_NAME, 6, 6, 274, 32, WS_GROUP\r\n\tEDITTEXT\t\tIDC_RULE_NAME_ID, 12, 18, 262, 12, WS_TABSTOP | ES_AUTOHSCROLL\r\n\r\n\tGROUPBOX\t\t\"\", IDC_RULE_COMMENT, 6, 40, 274, 32, WS_GROUP\r\n\tEDITTEXT\t\tIDC_RULE_COMMENT_ID, 12, 52, 262, 12, WS_TABSTOP | ES_AUTOHSCROLL\r\n\r\n\tGROUPBOX\t\t\"\", IDC_RULE_PROTOCOL, 6, 74, 134, 34, WS_GROUP\r\n\tCOMBOBOX\t\tIDC_RULE_PROTOCOL_ID, 12, 86, 122, 30, CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP\r\n\r\n\tGROUPBOX\t\t\"\", IDC_RULE_VERSION, 146, 74, 134, 34, WS_GROUP\r\n\tCOMBOBOX\t\tIDC_RULE_VERSION_ID, 152, 86, 122, 30, CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP\r\n\r\n\tGROUPBOX\t\t\"\", IDC_RULE_DIRECTION, 6, 108, 274, 34, WS_GROUP\r\n\tCOMBOBOX\t\tIDC_RULE_DIRECTION_ID, 12, 120, 262, 30, CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP\r\n\r\n\tGROUPBOX\t\t\"\", IDC_RULE_ACTION, 6, 142, 274, 34, WS_GROUP\r\n\tCOMBOBOX\t\tIDC_RULE_ACTION_ID, 12, 154, 262, 30, CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP\r\nEND\r\n\r\nIDD_EDITOR_RULE DIALOGEX 0, 0, 292, 210\r\nSTYLE WS_CHILD | WS_SYSMENU | WS_TABSTOP | WS_GROUP | DS_SHELLFONT | DS_CONTROL\r\nEXSTYLE WS_EX_CONTROLPARENT\r\nFONT 8, \"Ms Shell Dlg\"\r\nBEGIN\r\n\tGROUPBOX\t\t\"\", IDC_RULE_REMOTE, 6, 6, 274, 70, WS_GROUP\r\n\tCONTROL\t\t\t\"\", IDC_RULE_REMOTE_ID, WC_LISTVIEW, LVS_REPORT | LVS_NOCOLUMNHEADER | WS_BORDER | WS_TABSTOP | WS_VSCROLL | LVS_SHAREIMAGELISTS, 14, 18, 202, 50\r\n\r\n\tPUSHBUTTON\t\t\"\", IDC_RULE_REMOTE_ADD, 222, 18, 50, 14, WS_TABSTOP\r\n\tPUSHBUTTON\t\t\"\", IDC_RULE_REMOTE_EDIT, 222, 34, 50, 14, WS_TABSTOP\r\n\tPUSHBUTTON\t\t\"\", IDC_RULE_REMOTE_DELETE, 222, 50, 50, 14, WS_TABSTOP\r\n\r\n\tGROUPBOX\t\t\"\", IDC_RULE_LOCAL, 6, 78, 274, 70, WS_GROUP\r\n\tCONTROL\t\t\t\"\", IDC_RULE_LOCAL_ID, WC_LISTVIEW, LVS_REPORT | LVS_NOCOLUMNHEADER | WS_BORDER | WS_TABSTOP | WS_VSCROLL | LVS_SHAREIMAGELISTS, 14, 90, 202, 50\r\n\r\n\tPUSHBUTTON\t\t\"\", IDC_RULE_LOCAL_ADD, 222, 90, 50, 14, WS_TABSTOP\r\n\tPUSHBUTTON\t\t\"\", IDC_RULE_LOCAL_EDIT, 222, 106, 50, 14, WS_TABSTOP\r\n\tPUSHBUTTON\t\t\"\", IDC_RULE_LOCAL_DELETE, 222, 122, 50, 14, WS_TABSTOP\r\n\r\n\tLTEXT\t\t\t\"\", IDC_RULE_HINT, 6, 154, 256, 22\r\nEND\r\n\r\nIDD_EDITOR_APPS DIALOGEX 0, 0, 292, 210\r\nSTYLE WS_CHILD | WS_SYSMENU | WS_TABSTOP | WS_GROUP | DS_SHELLFONT | DS_CONTROL\r\nEXSTYLE WS_EX_CONTROLPARENT\r\nFONT 8, \"Ms Shell Dlg\"\r\nBEGIN\r\n\tEDITTEXT\t\tIDC_SEARCH, 0, 0, 290, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_BORDER | ES_AUTOHSCROLL\r\n\r\n\tCONTROL\t\t\t\"\", IDC_RULE_APPS_ID, WC_LISTVIEW, LVS_REPORT | WS_BORDER | WS_TABSTOP | WS_VSCROLL | LVS_SHAREIMAGELISTS, 0, 14, 290, 134\r\n\r\n\tLTEXT\t\t\t\"\", IDC_RULE_APPS_HINT, 6, 154, 256, 22\r\nEND\r\n\r\nIDD_EDITOR_APPINFO DIALOGEX 0, 0, 272, 240\r\nSTYLE WS_CHILD | WS_SYSMENU | WS_TABSTOP | WS_GROUP | DS_SHELLFONT | DS_CONTROL\r\nEXSTYLE WS_EX_CONTROLPARENT\r\nFONT 8, \"Ms Shell Dlg\"\r\nBEGIN\r\n\tGROUPBOX\t\t\"\", IDC_APP_NAME, 6, 6, 274, 42, WS_GROUP\r\n\r\n\tLTEXT\t\t\t\"\", IDC_APP_ICON_ID, 16, 18, 32, 32, SS_ICON\r\n\tEDITTEXT\t\tIDC_APP_NAME_ID, 48, 18, 224, 12, NOT WS_BORDER | WS_TABSTOP | ES_AUTOHSCROLL | ES_READONLY\r\n\tEDITTEXT\t\tIDC_APP_SIGNATURE_ID, 48, 30, 224, 12, NOT WS_BORDER | WS_TABSTOP | ES_AUTOHSCROLL | ES_READONLY\r\n\r\n\tGROUPBOX\t\t\"\", IDC_APP_PATH, 6, 50, 274, 34, WS_GROUP\r\n\tEDITTEXT\t\tIDC_APP_PATH_ID, 12, 62, 238, 12, WS_TABSTOP | ES_AUTOHSCROLL | ES_READONLY\r\n\tPUSHBUTTON\t\t\">\", IDC_APP_EXPLORE_ID, 254, 62, 20, 12, WS_TABSTOP\r\n\r\n\tGROUPBOX\t\t\"SHA-256:\", IDC_APP_HASH, 6, 86, 274, 34, WS_GROUP\r\n\tEDITTEXT\t\tIDC_APP_HASH_ID, 12, 98, 238, 12, WS_TABSTOP | ES_AUTOHSCROLL | ES_READONLY\r\n\tPUSHBUTTON\t\t\">\", IDC_APP_HASH_RECHECK_ID, 254, 98, 20, 12, WS_TABSTOP\r\n\r\n\tGROUPBOX\t\t\"\", IDC_APP_COMMENT, 6, 122, 274, 34, WS_GROUP\r\n\tEDITTEXT\t\tIDC_APP_COMMENT_ID, 12, 136, 262, 12, WS_TABSTOP | ES_AUTOHSCROLL\r\nEND\r\n\r\nIDD_EDITOR_APPRULES DIALOGEX 0, 0, 272, 240\r\nSTYLE WS_CHILD | WS_SYSMENU | WS_TABSTOP | WS_GROUP | DS_SHELLFONT | DS_CONTROL\r\nEXSTYLE WS_EX_CONTROLPARENT\r\nFONT 8, \"Ms Shell Dlg\"\r\nBEGIN\r\n\tEDITTEXT\t\tIDC_SEARCH, 0, 0, 290, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_BORDER | ES_AUTOHSCROLL\r\n\r\n\tCONTROL\t\t\t\"\", IDC_APP_RULES_ID, WC_LISTVIEW, LVS_REPORT | NOT WS_BORDER | WS_TABSTOP | WS_VSCROLL | LVS_SHAREIMAGELISTS, 0, 14, 290, 134\r\n\r\n\tLTEXT\t\t\t\"\", IDC_APP_HINT, 6, 154, 256, 22\r\nEND\r\n\r\nIDD_EDITOR_ADDRULE DIALOGEX 0, 0, 270, 148\r\nSTYLE WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_POPUP | WS_BORDER | WS_SYSMENU | WS_CAPTION | DS_SHELLFONT | DS_MODALFRAME\r\nFONT 8, \"Ms Shell Dlg\"\r\nBEGIN\r\n\tEDITTEXT\t\tIDC_RULE_ID, 8, 8, 254, 24, WS_TABSTOP | ES_AUTOHSCROLL | ES_MULTILINE\r\n\r\n\tEDITTEXT\t\tIDC_RULE_HINT, 8, 38, 254, 80, WS_VSCROLL | WS_BORDER | NOT WS_TABSTOP | ES_AUTOVSCROLL | ES_READONLY | ES_MULTILINE\r\n\r\n\tPUSHBUTTON\t\t\"\", IDC_SAVE, 158, 126, 50, 14, WS_TABSTOP\r\n\tPUSHBUTTON\t\t\"\", IDC_CLOSE, 212, 126, 50, 14, WS_TABSTOP\r\nEND\r\n\r\nIDD_SETTINGS_GENERAL DIALOGEX 0, 0, 262, 172\r\nSTYLE WS_CHILD | WS_SYSMENU | WS_TABSTOP | WS_GROUP | DS_SHELLFONT | DS_CONTROL\r\nEXSTYLE WS_EX_CONTROLPARENT\r\nFONT 8, \"Ms Shell Dlg\"\r\nBEGIN\r\n\tGROUPBOX\t\t\"\", IDC_TITLE_GENERAL, 0, 0, 262, 78, WS_GROUP\r\n\r\n\tAUTOCHECKBOX\t\"\", IDC_ALWAYSONTOP_CHK, 8, 12, 246, 12\r\n\tAUTOCHECKBOX\t\"\", IDC_LOADONSTARTUP_CHK, 8, 24, 246, 12\r\n\tAUTOCHECKBOX\t\"\", IDC_STARTMINIMIZED_CHK, 8, 36, 246, 12\r\n\tAUTOCHECKBOX\t\"\", IDC_SKIPUACWARNING_CHK, 8, 48, 246, 12\r\n\tAUTOCHECKBOX\t\"\", IDC_CHECKUPDATES_CHK, 8, 60, 246, 12\r\n\r\n\tGROUPBOX\t\t\"\", IDC_TITLE_LANGUAGE, 0, 80, 262, 36, WS_GROUP\r\n\r\n\tLTEXT\t\t\t\"\", IDC_LANGUAGE_HINT, 8, 94, 114, 12, SS_CENTERIMAGE\r\n\tCOMBOBOX\t\tIDC_LANGUAGE, 130, 94, 124, 30, CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP\r\nEND\r\n\r\nIDD_SETTINGS_INTERFACE DIALOGEX 0, 0, 262, 172\r\nSTYLE WS_CHILD | WS_SYSMENU | WS_TABSTOP | WS_GROUP | DS_SHELLFONT | DS_CONTROL\r\nEXSTYLE WS_EX_CONTROLPARENT\r\nFONT 8, \"Ms Shell Dlg\"\r\nBEGIN\r\n\tGROUPBOX\t\t\"\", IDC_TITLE_CONFIRMATIONS, 0, 0, 262, 64, WS_GROUP\r\n\r\n\tAUTOCHECKBOX\t\"\", IDC_CONFIRMEXIT_CHK, 8, 12, 246, 12\r\n\tAUTOCHECKBOX\t\"\", IDC_CONFIRMEXITTIMER_CHK, 8, 24, 246, 12\r\n\tAUTOCHECKBOX\t\"\", IDC_CONFIRMLOGCLEAR_CHK, 8, 36, 246, 12\r\n\tAUTOCHECKBOX\t\"\", IDC_CONFIRMALLOW_CHK, 8, 48, 246, 12\r\n\r\n\tGROUPBOX\t\t\"\", IDC_TITLE_TRAY, 0, 66, 262, 32, WS_GROUP\r\n\r\n\tAUTOCHECKBOX\t\"\", IDC_TRAYICONSINGLECLICK_CHK, 8, 78, 246, 12\r\nEND\r\n\r\nIDD_SETTINGS_HIGHLIGHTING DIALOGEX 0, 0, 262, 172\r\nSTYLE WS_CHILD | WS_SYSMENU | WS_TABSTOP | WS_GROUP | DS_SHELLFONT | DS_CONTROL\r\nEXSTYLE WS_EX_CONTROLPARENT\r\nFONT 8, \"Ms Shell Dlg\"\r\nBEGIN\r\n\tGROUPBOX\t\t\"\", IDC_TITLE_HIGHLIGHTING, 0, 0, 262, 172, WS_GROUP\r\n\r\n\tCONTROL\t\t\t\"\", IDC_COLORS, WC_LISTVIEW, LVS_REPORT | LVS_NOCOLUMNHEADER | LVS_SHAREIMAGELISTS | WS_BORDER | WS_TABSTOP | WS_VSCROLL, 8, 12, 246, 140\r\n\r\n\tLTEXT\t\t\t\"\", IDC_COLORS_HINT, 8, 156, 246, 12, SS_CENTERIMAGE\r\nEND\r\n\r\nIDD_SETTINGS_RULES DIALOGEX 0, 0, 262, 172\r\nSTYLE WS_CHILD | WS_SYSMENU | WS_TABSTOP | WS_GROUP | DS_SHELLFONT | DS_CONTROL\r\nEXSTYLE WS_EX_CONTROLPARENT\r\nFONT 8, \"Ms Shell Dlg\"\r\nBEGIN\r\n\tGROUPBOX\t\t\"\", IDC_TITLE_CONNECTIONS, 0, 0, 262, 64, WS_GROUP\r\n\r\n\tAUTOCHECKBOX\t\"\", IDC_RULE_BLOCKOUTBOUND, 8, 12, 246, 12\r\n\tAUTOCHECKBOX\t\"\", IDC_RULE_BLOCKINBOUND, 8, 24, 246, 12\r\n\tAUTOCHECKBOX\t\"\", IDC_RULE_ALLOWLOOPBACK, 8, 36, 246, 12\r\n\tAUTOCHECKBOX\t\"\", IDC_RULE_ALLOW6TO4, 8, 48, 246, 12\r\n\r\n\tGROUPBOX\t\t\"\", IDC_TITLE_SECURITY, 0, 66, 262, 40, WS_GROUP\r\n\r\n\tAUTOCHECKBOX\t\"\", IDC_USESTEALTHMODE_CHK, 8, 78, 246, 12\r\n\tAUTOCHECKBOX\t\"\", IDC_INSTALLBOOTTIMEFILTERS_CHK, 8, 90, 246, 12\r\n\r\n\tGROUPBOX\t\t\"\", IDC_TITLE_ADVANCED, 0, 108, 262, 52, WS_GROUP\r\n\r\n\tAUTOCHECKBOX\t\"\", IDC_USECERTIFICATES_CHK, 8, 120, 246, 12\r\n\tAUTOCHECKBOX\t\"\", IDC_USEHASHES_CHK, 8, 132, 246, 12\r\n\tAUTOCHECKBOX\t\"\", IDC_USENETWORKRESOLUTION_CHK, 8, 144, 246, 12\r\nEND\r\n\r\nIDD_SETTINGS_BLOCKLIST DIALOGEX 0, 0, 262, 172\r\nSTYLE WS_CHILD | WS_SYSMENU | WS_TABSTOP | WS_GROUP | DS_SHELLFONT | DS_CONTROL\r\nEXSTYLE WS_EX_CONTROLPARENT\r\nFONT 8, \"Ms Shell Dlg\"\r\nBEGIN\r\n\tGROUPBOX\t\t\"\", IDC_TITLE_BLOCKLIST_SPY, 0, 0, 262, 52, WS_GROUP\r\n\r\n\tAUTORADIOBUTTON\t\"\", IDC_BLOCKLIST_SPY_DISABLE, 8, 12, 246, 12\r\n\tAUTORADIOBUTTON\t\"\", IDC_BLOCKLIST_SPY_ALLOW, 8, 24, 246, 12\r\n\tAUTORADIOBUTTON\t\"\", IDC_BLOCKLIST_SPY_BLOCK, 8, 36, 246, 12\r\n\r\n\tGROUPBOX\t\t\"\", IDC_TITLE_BLOCKLIST_UPDATE, 0, 54, 262, 52, WS_GROUP\r\n\r\n\tAUTORADIOBUTTON\t\"\", IDC_BLOCKLIST_UPDATE_DISABLE, 8, 66, 246, 12\r\n\tAUTORADIOBUTTON\t\"\", IDC_BLOCKLIST_UPDATE_ALLOW, 8, 78, 246, 12\r\n\tAUTORADIOBUTTON\t\"\", IDC_BLOCKLIST_UPDATE_BLOCK, 8, 90, 246, 12\r\n\r\n\tGROUPBOX\t\t\"\", IDC_TITLE_BLOCKLIST_EXTRA, 0, 108, 262, 52, WS_GROUP\r\n\r\n\tAUTORADIOBUTTON\t\"\", IDC_BLOCKLIST_EXTRA_DISABLE, 8, 120, 246, 12\r\n\tAUTORADIOBUTTON\t\"\", IDC_BLOCKLIST_EXTRA_ALLOW, 8, 132, 246, 12\r\n\tAUTORADIOBUTTON\t\"\", IDC_BLOCKLIST_EXTRA_BLOCK, 8, 144, 246, 12\r\n\r\n\tCONTROL\t\t\t\"\", IDC_BLOCKLIST_INFO, WC_LINK, 0, 0, 164, 262, 18\r\nEND\r\n\r\nIDD_SETTINGS_NOTIFICATIONS DIALOGEX 0, 0, 262, 172\r\nSTYLE WS_CHILD | WS_SYSMENU | WS_TABSTOP | WS_GROUP | DS_SHELLFONT | DS_CONTROL\r\nEXSTYLE WS_EX_CONTROLPARENT\r\nFONT 8, \"Ms Shell Dlg\"\r\nBEGIN\r\n\tGROUPBOX\t\t\"\", IDC_TITLE_GENERAL, 0, 0, 262, 86, WS_GROUP\r\n\r\n\tAUTOCHECKBOX\t\"\", IDC_ENABLENOTIFICATIONS_CHK, 8, 12, 246, 12\r\n\tAUTOCHECKBOX\t\"\", IDC_NOTIFICATIONSOUND_CHK, 8, 24, 246, 12\r\n\tAUTOCHECKBOX\t\"\", IDC_NOTIFICATIONFULLSCREENSILENTMODE_CHK, 8, 36, 246, 12\r\n\tAUTOCHECKBOX\t\"\", IDC_NOTIFICATIONONTRAY_CHK, 8, 48, 246, 12\r\n\r\n\tLTEXT\t\t\t\"\", IDC_NOTIFICATIONTIMEOUT_HINT, 8, 64, 198, 12, SS_CENTERIMAGE\r\n\tEDITTEXT\t\tIDC_NOTIFICATIONTIMEOUT_CTRL, 210, 64, 44, 12, ES_AUTOHSCROLL | ES_NUMBER | ES_MULTILINE\r\n\tCONTROL\t\t\t\"\", IDC_NOTIFICATIONTIMEOUT, UPDOWN_CLASS, UDS_ALIGNRIGHT | UDS_ARROWKEYS | UDS_AUTOBUDDY | UDS_HOTTRACK | UDS_SETBUDDYINT | UDS_WRAP, 0, 0, 0, 0\r\nEND\r\n\r\nIDD_SETTINGS_LOGGING DIALOGEX 0, 0, 262, 172\r\nSTYLE WS_CHILD | WS_SYSMENU | WS_TABSTOP | WS_GROUP | DS_SHELLFONT | DS_CONTROL\r\nEXSTYLE WS_EX_CONTROLPARENT\r\nFONT 8, \"Ms Shell Dlg\"\r\nBEGIN\r\n\tGROUPBOX\t\t\"\", IDC_TITLE_GENERAL, 0, 0, 262, 66, WS_GROUP\r\n\r\n\tAUTOCHECKBOX\t\"\", IDC_ENABLELOG_CHK, 8, 12, 246, 12\r\n\r\n\tEDITTEXT\t\tIDC_LOGPATH, 8, 26, 218, 12, ES_AUTOHSCROLL | ES_MULTILINE\r\n\tPUSHBUTTON\t\t\"...\", IDC_LOGPATH_BTN, 230, 26, 24, 12, WS_TABSTOP\r\n\r\n\tLTEXT\t\t\t\"\", IDC_LOGSIZELIMIT_HINT, 8, 44, 198, 12, SS_CENTERIMAGE\r\n\tEDITTEXT\t\tIDC_LOGSIZELIMIT_CTRL, 210, 44, 44, 12, ES_AUTOHSCROLL | ES_NUMBER | ES_MULTILINE\r\n\tCONTROL\t\t\t\"\", IDC_LOGSIZELIMIT, UPDOWN_CLASS, UDS_ALIGNRIGHT | UDS_ARROWKEYS | UDS_AUTOBUDDY | UDS_HOTTRACK | UDS_SETBUDDYINT, 0, 0, 0, 0\r\n\r\n\tGROUPBOX\t\t\"\", IDC_TITLE_LOGVIEWER, 0, 68, 262, 34, WS_GROUP\r\n\r\n\tEDITTEXT\t\tIDC_LOGVIEWER, 8, 80, 218, 12, ES_AUTOHSCROLL | ES_MULTILINE\r\n\tPUSHBUTTON\t\t\"...\", IDC_LOGVIEWER_BTN, 230, 80, 24, 12, WS_TABSTOP\r\n\r\n\tGROUPBOX\t\t\"\", IDC_TITLE_INTERFACE, 0, 106, 262, 32, WS_GROUP\r\n\r\n\tAUTOCHECKBOX\t\"\", IDC_ENABLEUILOG_CHK, 8, 118, 246, 12\r\nEND\r\n\r\nIDD_SETTINGS_EXCLUDE DIALOGEX 0, 0, 262, 172\r\nSTYLE WS_CHILD | WS_SYSMENU | WS_TABSTOP | WS_GROUP | DS_SHELLFONT | DS_CONTROL\r\nEXSTYLE WS_EX_CONTROLPARENT\r\nFONT 8, \"Ms Shell Dlg\"\r\nBEGIN\r\n\tGROUPBOX\t\t\"\", IDC_TITLE_NOTIFICATIONS, 0, 0, 262, 42, WS_GROUP\r\n\r\n\tAUTOCHECKBOX\t\"\", IDC_EXCLUDEBLOCKLIST_CHK, 8, 12, 246, 12\r\n\tAUTOCHECKBOX\t\"\", IDC_EXCLUDECUSTOM_CHK, 8, 24, 246, 12\r\n\r\n\tGROUPBOX\t\t\"\", IDC_TITLE_LOGGING, 0, 46, 262, 42, WS_GROUP\r\n\r\n\tAUTOCHECKBOX\t\"\", IDC_EXCLUDESTEALTH_CHK, 8, 58, 246, 12\r\n\tAUTOCHECKBOX\t\"\", IDC_EXCLUDECLASSIFYALLOW_CHK, 8, 70, 246, 12\r\nEND\r\n\r\n//\r\n// String resources\r\n//\r\nSTRINGTABLE\r\nBEGIN\r\n\tIDS_UPDATE_NO \"No updates available.\"\r\n\tIDS_UPDATE_YES \"Update available. Download and install now?\"\r\n\tIDS_UPDATE_DOWNLOAD \"Downloading update...\"\r\n\tIDS_UPDATE_DONE \"Downloading update finished.\"\r\n\tIDS_UPDATE_ERROR \"Update server connection error.\"\r\n\tIDS_UPDATE_INIT \"Checking for new releases...\"\r\n\tIDS_UPDATE_INSTALL \"Update available. Do you want to install it now?\"\r\n\r\n\tIDS_FILE \"File\"\r\n\tIDS_SETTINGS \"Settings\"\r\n\tIDS_EXIT \"Exit\"\r\n\tIDS_EDIT \"Edit\"\r\n\tIDS_FIND \"Search\"\r\n\tIDS_FINDNEXT \"\"\r\n\tIDS_PURGE_UNUSED \"Purge unused apps\"\r\n\tIDS_PURGE_TIMERS \"Purge timers\"\r\n\tIDS_REFRESH \"Refresh\"\r\n\tIDS_VIEW \"View\"\r\n\tIDS_ICONS \"Icons\"\r\n\tIDS_ICONSSMALL \"Small\"\r\n\tIDS_ICONSLARGE \"Large\"\r\n\tIDS_ICONSISHIDDEN \"Do not load icons\"\r\n\tIDS_LANGUAGE \"Language\"\r\n\tIDS_FONT \"Font\"\r\n\tIDS_HELP \"Help\"\r\n\tIDS_WEBSITE \"Website\"\r\n\tIDS_CHECKUPDATES \"Check for updates\"\r\n\tIDS_DONATE \"Give thanks!\"\r\n\tIDS_ABOUT \"About\"\r\n\r\n\tIDS_TRAY_SHOW \"Show/Hide\"\r\n\tIDS_TRAY_START \"Enable filters\"\r\n\tIDS_TRAY_STOP \"Disable filters\"\r\n\tIDS_TRAY_RULES \"Rules\"\r\n\tIDS_TRAY_BLOCKLIST_RULES \"Blocklist\"\r\n\tIDS_TRAY_SYSTEM_RULES \"System rules\"\r\n\tIDS_TRAY_USER_RULES \"User rules\"\r\n\tIDS_TRAY_LOGERR \"Errors log\"\r\n\r\n\tIDS_ADD_FILE \"Add app\"\r\n\tIDS_ANY \"Any\"\r\n\tIDS_DISABLENOTIFICATIONS \"Disable notifications\"\r\n\tIDS_OPENRULESEDITOR \"Create rule\"\r\n\tIDS_TIMER \"Timer\"\r\n\tIDS_DISABLETIMER \"Disable timer\"\r\n\tIDS_EXPLORE \"Open containing folder\"\r\n\tIDS_COPY \"Copy\"\r\n\tIDS_SELECT_ALL \"Select all\"\r\n\tIDS_CHECK \"Enable selected\"\r\n\tIDS_UNCHECK \"Disable selected\"\r\n\r\n\tIDS_ADD \"Add\"\r\n\tIDS_EDIT2 \"Edit\"\r\n\tIDS_DELETE \"Delete\"\r\n\tIDS_EXPORT \"Export\"\r\n\tIDS_IMPORT \"Import\"\r\n\r\n\tIDS_RULE_ALLOWLOOPBACK \"Allow loopback connections for all\"\r\n\tIDS_RULE_ALLOWLOOPBACK_HINT \"This allows all loopback traffic.\"\r\n\r\n\tIDS_HIGHLIGHT_INVALID \"Invalid (file not found or filter problem)\"\r\n\tIDS_HIGHLIGHT_NETWORK \"Shared network app\"\r\n\tIDS_HIGHLIGHT_PICO \"Pico app\"\r\n\tIDS_HIGHLIGHT_SIGNED \"Signed app\"\r\n\tIDS_HIGHLIGHT_SILENT \"Disabled notifications\"\r\n\tIDS_HIGHLIGHT_SPECIAL \"User rules\"\r\n\tIDS_HIGHLIGHT_SYSTEM \"System app\"\r\n\tIDS_GROUP_TIMER \"Apps with timer\"\r\n\r\n\tIDS_EDITOR \"Rules editor\"\r\n\r\n\tIDS_NAME \"Name\"\r\n\tIDS_DIRECTION \"Direction\"\r\n\tIDS_PROTOCOL \"Protocol\"\r\n\tIDS_PORTVERSION \"Family (ports only)\"\r\n\tIDS_ACTION \"Action\"\r\n\tIDS_RULE \"Rule\"\r\n\tIDS_DATE \"Date\"\r\n\tIDS_FILEPATH \"Path\"\r\n\tIDS_SIGNATURE \"Signature\"\r\n\tIDS_ADDRESS \"Address\"\r\n\tIDS_FILTER \"Filter\"\r\n\tIDS_NOTES \"Notes\"\r\n\tIDS_ADDED \"Added\"\r\n\tIDS_TIMELEFT \"Time left\"\r\n\r\n\tIDS_SIGN_SIGNED \"Signed\"\r\n\tIDS_SIGN_UNSIGNED \"Not signed\"\r\n\r\n\tIDS_GROUP_ALLOWED \"Apps with internet access\"\r\n\tIDS_GROUP_SPECIAL_APPS \"Apps with user rules\"\r\n\tIDS_GROUP_BLOCKED \"Apps without internet access\"\r\n\r\n\tIDS_GROUP_ENABLED \"Enabled rules\"\r\n\tIDS_GROUP_DISABLED \"Disabled rules\"\r\n\r\n\tIDS_DIRECTION_1 \"Outbound\"\r\n\tIDS_DIRECTION_2 \"Inbound\"\r\n\tIDS_DIRECTION_3 \"Both\"\r\n\r\n\tIDS_ACTION_ALLOW \"Allow\"\r\n\tIDS_ACTION_BLOCK \"Block\"\r\n\r\n\tIDS_ENABLE_CHK \"Enable rule\"\r\n\r\n\tIDS_WIKI \"Help\"\r\n\tIDS_SAVE \"Save\"\r\n\tIDS_RESET \"Reset\"\r\n\tIDS_CLOSE \"Close\"\r\n\r\n\tIDS_SETTINGS_GENERAL \"General\"\r\n\r\n\tIDS_TITLE_GENERAL \"General configuration\"\r\n\tIDS_TITLE_LANGUAGE \"Language\"\r\n\tIDS_TITLE_CONFIRMATIONS \"Confirmations\"\r\n\tIDS_TITLE_INTERFACE \"Interface\"\r\n\tIDS_TITLE_HIGHLIGHTING \"Highlighting\"\r\n\tIDS_TITLE_LOGGING \"Packets log\"\r\n\tIDS_TITLE_NOTIFICATIONS \"Notifications\"\r\n\tIDS_TITLE_ADVANCED \"Advanced\"\r\n\tIDS_TITLE_EXCLUDE \"Exclude\"\r\n\r\n\tIDS_ALWAYSONTOP_CHK \"Always on top\"\r\n\tIDS_LOADONSTARTUP_CHK \"Load on system startup\"\r\n\tIDS_STARTMINIMIZED_CHK \"Start minimized\"\r\n\tIDS_SHOWFILENAMESONLY_CHK \"Show filenames only\"\r\n\tIDS_AUTOSIZECOLUMNS_CHK \"Autosize columns\"\r\n\tIDS_SKIPUACWARNING_CHK \"Skip \"\"User Account Control\"\" prompt warning\"\r\n\tIDS_CHECKUPDATES_CHK \"Periodically check for updates (recommended)\"\r\n\tIDS_CHECKUPDATESBETA_CHK \"\"\r\n\r\n\tIDS_LANGUAGE_HINT \"Select language:\"\r\n\r\n\tIDS_USESTEALTHMODE_CHK \"Prevent port scanning\"\r\n\tIDS_USESTEALTHMODE_HINT \"Prevent TCP port scanning by silently dropping inbound TCP RST and UDP port scanning by responding to outbound ICMP with \"\"Destination Unreachable\"\".\"\r\n\tIDS_INSTALLBOOTTIMEFILTERS_CHK \"Enable boot-time filters\"\r\n\tIDS_INSTALLBOOTTIMEFILTERS_HINT \"Prevent data leaks during system startup, even before the \"\"Base Filtering Engine\"\" (BFE) service starts.\"\r\n\r\n\tIDS_USECERTIFICATES_CHK \"Check apps for digital signatures\"\r\n\tIDS_USENETWORKRESOLUTION_CHK \"Resolve network addresses\"\r\n\r\n\tIDS_DISABLEWINDOWSFIREWALL_CHK \"Disable Windows Firewall\"\r\n\tIDS_ENABLEWINDOWSFIREWALL_CHK \"Enable Windows Firewall\"\r\n\r\n\tIDS_CONFIRMEXIT_CHK \"Show confirmation dialog on exit\"\r\n\tIDS_CONFIRMEXITTIMER_CHK \"Show confirmation dialog on exit when timers are active\"\r\n\tIDS_CONFIRMDELETE_CHK \"\"\r\n\tIDS_CONFIRMLOGCLEAR_CHK \"Confirm when clearing the log file\"\r\n\r\n\tIDS_COLORS_HINT \"Double-click an item to change it.\"\r\n\r\n\tIDS_ENABLELOG_CHK \"Enable packets logging to a file\"\r\n\tIDS_LOGSHOW \"Show log\"\r\n\tIDS_LOGCLEAR \"Clear log\"\r\n\r\n\tIDS_LOGSIZELIMIT_HINT \"Maximum log size: (kB)\"\r\n\r\n\tIDS_ENABLENOTIFICATIONS_CHK \"Enable packets notifications\"\r\n\tIDS_NOTIFICATIONSOUND_CHK \"Enable notifications sound\"\r\n\tIDS_NOTIFICATIONTIMEOUT_HINT \"Timeout between similar notifications (sec.):\"\r\n\tIDS_EXCLUDESTEALTH_CHK \"port scanner connections\"\r\n\tIDS_EXCLUDECLASSIFYALLOW_CHK \"allowed connections\"\r\n\tIDS_EXCLUDEBLOCKLIST_CHK \"blocklist\"\r\n\tIDS_EXCLUDECUSTOM_CHK \"user rules\"\r\n\r\n\tIDS_NOTIFY_TOOLTIP \"Set user rule to allow access to an address and/or port for this application.\"\r\n\r\n\tIDS_QUESTION \"Are you sure?\"\r\n\tIDS_QUESTION_DELETE \"Delete selected item(s)?\"\r\n\tIDS_QUESTION_START \"This will deny network access to apps as defined by the current configuration. Continue?\"\r\n\tIDS_QUESTION_STOP \"This will restore network access for all apps that are currently blocked. Continue?\"\r\n\tIDS_QUESTION_EXIT \"Installed filters will continue to work even if you exit. Continue?\"\r\n\tIDS_QUESTION_TIMER \"Timer(s) activated. Timers will only work when the application is running. Exit?\"\r\n\tIDS_QUESTION_TIMERS \"Delete all timers?\"\r\n\tIDS_QUESTION_RESET \"\"\r\n\tIDS_QUESTION_FLAG_CHK \"Do not ask again\"\r\n\r\n\tIDS_STATUS_TOTAL \"\"\r\n\r\n\tIDS_STATUS_UNUSED_APPS \"Unused apps\"\r\n\tIDS_STATUS_TIMER_APPS \"Apps with timer\"\r\n\r\n\tIDS_STATUS_EMPTY \"Empty.\"\r\n\tIDS_STATUS_ERROR \"\"\r\n\r\n\tIDS_STATUS_SYNTAX_ERROR \"Syntax error in rule!\"\r\n\tIDS_STATUS_TIMER_DONE \"Timer for application has been expired\"\r\n\r\n\tIDS_ADDRESS_LOCAL \"Source\"\r\n\tIDS_ADDRESS_REMOTE \"Destination\"\r\n\r\n\tIDS_ICONSEXTRALARGE \"Extra large\"\r\n\tIDS_SECUREFILTERS_CHK \"Enable protection of installed filters\" //removed\r\n\tIDS_SECUREFILTERS_HINT \"Prevent unauthorized applications from accessing the installed filters.\" //removed\r\n\tIDS_USEREFRESHDEVICES_CHK \"Refresh filters when (storage) devices are connected\"\r\n\r\n\tIDS_RULE_ALLOW6TO4 \"Allow IPv6 redirections (6to4) for all\"\r\n\tIDS_RECOMMENDED \"recommended\"\r\n\tIDS_ICONSISTABLEVIEW \"Show as table\"\r\n\r\n\tIDS_ACTION_ALLOW_HINT \"Allow network access forever\"\r\n\tIDS_ACTION_BLOCK_HINT \"Block network access forever ('til kingdom come)\"\r\n\tIDS_ACTION_LATER_HINT \"Ignore and ask me later\"\r\n\r\n\tIDS_RULE_APPLY_2 \"Apply \"\"%s\"\" for this app\"\r\n\r\n\tIDS_EDITRULES \"Edit rules\"\r\n\r\n\tIDS_TAB_APPS \"Apps\"\r\n\tIDS_TAB_SERVICES \"Services\"\r\n\tIDS_TAB_PACKAGES \"UWP apps\"\r\n\tIDS_TAB_NETWORK \"Connections\"\r\n\r\n\tIDS_STATE \"State\"\r\n\r\n\tIDS_STATUS_FILTERS_ACTIVE \"Filters are enabled.\"\r\n\tIDS_STATUS_FILTERS_INACTIVE \"Filters are disabled!\"\r\n\tIDS_STATUS_FILTERS_PROCESSING \"Applying filters\"\r\n\r\n\tIDS_HIGHLIGHT_CONNECTION \"Have network connections\"\r\n\tIDS_SHOWINLIST \"Show in list\"\r\n\r\n\tIDS_BLOCKLIST_SPY \"Microsoft spying and telemetry\"\r\n\tIDS_BLOCKLIST_UPDATE \"Microsoft update\"\r\n\tIDS_BLOCKLIST_EXTRA \"Microsoft applications\"\r\n\r\n\tIDS_PORT \"Port\"\r\n\r\n\tIDS_NOTIFY_TITLE \"Network alert\"\r\n\tIDS_NOTIFY_HEADER \"Network connection was blocked\"\r\n\r\n\tIDS_DISABLE \"Disable\"\r\n\tIDS_TITLE_SECURITY \"Security\"\r\n\tIDS_LOGVIEWER_HINT \"Log viewer app\"\r\n\tIDS_NOTIFICATIONONTRAY_CHK \"Show notification window on tray\"\r\n\r\n\tIDS_NETWORK_CLOSE \"Close connection\"\r\n\r\n\tIDS_RULE_BLOCKOUTBOUND \"Block outbound connections for all\"\r\n\tIDS_RULE_BLOCKINBOUND \"Block inbound connections for all\"\r\n\r\n\tIDS_VIEW_ICON \"Icons\"\r\n\tIDS_VIEW_DETAILS \"Details\"\r\n\tIDS_VIEW_TILE \"Tiles\"\r\n\r\n\tIDS_RULE_HINT \"If you leave fields blank, then rule will be applied for any address and port.\"\r\n\tIDS_RULE_APPS_HINT \"If there is no apps selected, then rule will be applied for all apps.\"\r\n\r\n\tIDS_STATUS_FILTERS_ACTIVE_TEMP \"Filters are enabled until reboot.\"\r\n\r\n\tIDS_INSTALL_PERMANENT \"Permanent rules. Rules are working until you disable it manually.\"\r\n\tIDS_INSTALL_TEMPORARY \"Temporary rules. Rules are reset after the next reboot.\"\r\n\r\n\tIDS_ENABLEUILOG_CHK \"Enable packets logging interface\"\r\n\r\n\tIDS_NOTIFICATIONFULLSCREENSILENTMODE_CHK \"Enable silent-mode when full screen app in foreground\"\r\n\r\n\tIDS_TITLE_TRAY \"Tray icon\"\r\n\tIDS_TRAYICONSINGLECLICK_CHK \"Single click on tray icon to open\"\r\n\r\n\tIDS_ENABLE_APP_CHK \"Enable network access\"\r\n\tIDS_APP_HINT \"There is no reason to set any permissive rule for app with already enabled internet access.\"\r\n\r\n\tIDS_HOST \"Host\"\r\n\r\n\tIDS_CONFIRMALLOW_CHK \"Confirm when allowing application\"\r\n\tIDS_QUESTION_ALLOW \"Are you sure you want to enable full internet access for this application?\"\r\n\r\n\tIDS_SHOWSEARCHBAR_CHK \"Show search bar\"\r\n\r\n\tIDS_LAYER \"Layer\"\r\n\r\n\tIDS_RULE_ALLOWWINDOWSUPDATE \"Allow Windows Update\"\r\n\r\n\tIDS_ACTION_TERMINATE_HINT \"Terminate process\"\r\n\r\n\tIDS_PROFILE_TYPE \"Profile type\"\r\n\r\n\tIDS_USEAPPMONITOR_CHK \"Monitor apps changing\"\r\n\r\n\tIDS_DISABLEREMOVAL \"Disable removal\"\r\n\r\n\tIDS_USEHASHES_CHK \"Check apps for sha-256 hash\"\r\n\r\n\tIDS_COMMENT \"Comments\"\r\n\r\n\tIDS_USEDARKTHEME \"Use dark theme\"\r\n\r\n\tIDS_KEEPUNUSED_CHK \"Keep unused apps\"\r\n\r\n\tIDS_UPDATE_SPEED \"Speed\"\r\n\r\n\tIDS_RULE_FOR_ALL \"for all\"\r\n\tIDS_RULE_FOR_APPS \"for apps\"\r\n\r\n\tIDS_PROFILE_TYPE_PLAIN \"Plain\"\r\n\tIDS_PROFILE_TYPE_COMPRESSED \"Compressed\"\r\n\tIDS_PROFILE_TYPE_ENCRYPTED \"Encrypted\"\r\n\r\n\tIDS_SESSION_ONLY \"session only\"\r\n\r\n\tIDS_LIMIT_REACHED \"Limit reached.\"\r\n\tIDS_INTERNAL_RULE \"Internal rule\"\r\n\r\n\tIDS_LOADING \"Loading...\"\r\n\r\n\tIDS_DIRECTION_REMOTE \"Remote\"\r\n\tIDS_DIRECTION_LOCAL \"Local\"\r\nEND\r\n\r\n//\r\n// RC data\r\n//\r\nIDR_PROFILE_INTERNAL RCDATA\t\t\"..\\\\bin\\\\profile_internal.bin\"\r\n\r\n//\r\n// PNG resources\r\n//\r\nIDP_ADD\t\t\t\tPNG\t\t\"res\\\\plus.png\"\r\nIDP_ALLOW\t\t\tPNG\t\t\"res\\\\accept_button.png\"\r\nIDP_BLOCK\t\t\tPNG\t\t\"res\\\\delete.png\"\r\nIDP_CROSS\t\t\tPNG\t\t\"res\\\\cross.png\"\r\nIDP_NEXT\t\t\tPNG\t\t\"res\\\\resultset_next.png\"\r\nIDP_SHIELD_ENABLE\tPNG\t\t\"res\\\\tick_shield.png\"\r\nIDP_SHIELD_DISABLE\tPNG\t\t\"res\\\\cross_shield.png\"\r\nIDP_REFRESH\t\t\tPNG\t\t\"res\\\\arrow_refresh.png\"\r\nIDP_SETTINGS\t\tPNG\t\t\"res\\\\cog_edit.png\"\r\nIDP_NOTIFICATIONS\tPNG\t\t\"res\\\\error.png\"\r\nIDP_LOG\t\t\t\tPNG\t\t\"res\\\\note.png\"\r\nIDP_LOGOPEN\t\t\tPNG\t\t\"res\\\\page_white_magnify.png\"\r\nIDP_LOGCLEAR\t\tPNG\t\t\"res\\\\page_white_delete.png\"\r\nIDP_DONATE\t\t\tPNG\t\t\"res\\\\paypal_fulllogo.png\"\r\nIDP_LOGUI\t\t\tPNG\t\t\"res\\\\eye.png\"\r\nIDP_SEARCH_LIGHT\tPNG\t\t\"res\\\\search_light.png\"\r\nIDP_SEARCH_DARK\t\tPNG\t\t\"res\\\\search_dark.png\"\r\n\r\n//\r\n// Icon resources\r\n//\r\nIDI_MAIN\t\t\tICON\t\t\"res\\\\100.ico\"\r\nIDI_INACTIVE\t\tICON\t\t\"res\\\\101.ico\"\r\n\r\n//\r\n// Manifest resource\r\n//\r\n1\t\t\tRT_MANIFEST\t\t\"res\\\\manifest.xml\"\r\n\r\n//\r\n// Version Information resources\r\n//\r\nVS_VERSION_INFO VERSIONINFO\r\nFILEVERSION\t\tAPP_VERSION_RES\r\nPRODUCTVERSION\tAPP_VERSION_RES\r\nFILEOS\t\t\tVOS__WINDOWS32\r\nFILETYPE\t\tVFT_APP\r\nFILESUBTYPE\t\tVFT2_UNKNOWN\r\nFILEFLAGSMASK\t0x00000000\r\nFILEFLAGS\t\tVS_FF_PATCHED | VS_FF_PRERELEASE\r\nBEGIN\r\n\tBLOCK \"StringFileInfo\"\r\n\tBEGIN\r\n\t\tBLOCK \"040904E4\"\r\n\t\tBEGIN\r\n\t\t\tVALUE \"Comments\", APP_COMMENT\r\n\t\t\tVALUE \"CompanyName\", APP_AUTHOR\r\n\t\t\tVALUE \"FileDescription\", APP_NAME\r\n\t\t\tVALUE \"FileVersion\", APP_VERSION\r\n\t\t\tVALUE \"InternalName\", APP_NAME_SHORT\r\n\t\t\tVALUE \"LegalCopyright\", APP_COPYRIGHT\r\n\t\t\tVALUE \"OriginalFilename\", APP_NAME_SHORT \".exe\"\r\n\t\t\tVALUE \"ProductName\", APP_NAME\r\n\t\t\tVALUE \"ProductVersion\", APP_VERSION\r\n\t\tEND\r\n\tEND\r\n\tBLOCK \"VarFileInfo\"\r\n\tBEGIN\r\n\t\tVALUE \"Translation\", 0x0409, 1252\r\n\tEND\r\nEND\r\n"
  },
  {
    "path": "src/search.c",
    "content": "// simplewall\r\n// Copyright (c) 2012-2021 dmex\r\n// Copyright (c) 2021-2025 Henry++\r\n\r\n#include \"global.h\"\r\n\r\nVOID _app_search_initialize (\r\n\t_Inout_ PSEARCH_CONTEXT context\r\n)\r\n{\r\n\tRECT rect;\r\n\tHTHEME htheme;\r\n\tLONG cx_border;\r\n\tHRESULT status;\r\n\r\n\tGetWindowRect (context->hwnd, &rect);\r\n\r\n\tcx_border = _r_dc_getsystemmetrics (SM_CXBORDER, context->dpi_value);\r\n\r\n\t// initialize borders\r\n\tcontext->cx_width = _r_dc_getdpi (20, context->dpi_value);\r\n\tcontext->cx_border = cx_border;\r\n\tcontext->dc_brush = GetStockObject (DC_BRUSH);\r\n\r\n\tif (IsThemeActive ())\r\n\t{\r\n\t\ththeme = _r_dc_openthemedata (context->hwnd, VSCLASS_EDIT, context->dpi_value);\r\n\r\n\t\tif (htheme)\r\n\t\t{\r\n\t\t\tstatus = GetThemeInt (htheme, 0, 0, TMT_BORDERSIZE, &context->cx_border);\r\n\r\n\t\t\tif (FAILED (status))\r\n\t\t\t\tcontext->cx_border = cx_border;\r\n\r\n\t\t\tCloseThemeData (htheme);\r\n\t\t}\r\n\t}\r\n}\r\n\r\nVOID _app_search_create (\r\n\t_In_ HWND hwnd\r\n)\r\n{\r\n\tPSEARCH_CONTEXT context;\r\n\tWCHAR buffer[128];\r\n\r\n\tcontext = _r_mem_allocate (sizeof (SEARCH_CONTEXT));\r\n\r\n\tcontext->hwnd = hwnd;\r\n\tcontext->dpi_value = _r_dc_getwindowdpi (hwnd);\r\n\r\n\t_app_search_initialize (context);\r\n\r\n\t_r_wnd_setcontext (context->hwnd, SHORT_MAX, context);\r\n\r\n\t// Subclass the Edit control window procedure.\r\n\tcontext->wnd_proc = (WNDPROC)GetWindowLongPtrW (context->hwnd, GWLP_WNDPROC);\r\n\tSetWindowLongPtrW (context->hwnd, GWLP_WNDPROC, (LONG_PTR)&_app_search_subclass_proc);\r\n\r\n\t_r_str_printf (buffer, RTL_NUMBER_OF (buffer), L\"%s...\", _r_locale_getstring (IDS_FIND));\r\n\r\n\t_r_edit_setcuebanner (context->hwnd, 0, buffer);\r\n\r\n\t// Initialize the theme parameters.\r\n\t_app_search_themechanged (hwnd, context);\r\n}\r\n\r\nVOID _app_search_initializeimages (\r\n\t_In_ PSEARCH_CONTEXT context,\r\n\t_In_ HWND hwnd\r\n)\r\n{\r\n\tHICON hicon_prev;\r\n\tHBITMAP hbitmap;\r\n\tNTSTATUS status;\r\n\r\n\t// initialize icons\r\n\tcontext->image_width = _r_dc_getsystemmetrics (SM_CXSMICON, context->dpi_value) + _r_dc_getdpi (4, context->dpi_value);\r\n\tcontext->image_height = _r_dc_getsystemmetrics (SM_CYSMICON, context->dpi_value) + _r_dc_getdpi (4, context->dpi_value);\r\n\r\n\tstatus = _r_res_loadimage (\r\n\t\t_r_sys_getimagebase (),\r\n\t\tL\"PNG\",\r\n\t\tMAKEINTRESOURCE (IDP_SEARCH_LIGHT),\r\n\t\t&GUID_ContainerFormatPng,\r\n\t\tcontext->image_width,\r\n\t\tcontext->image_height,\r\n\t\t&hbitmap\r\n\t);\r\n\r\n\tif (NT_SUCCESS (status))\r\n\t{\r\n\t\thicon_prev = context->hicon_light;\r\n\r\n\t\tcontext->hicon_light = _r_dc_bitmaptoicon (hbitmap, context->image_width, context->image_height);\r\n\r\n\t\tif (hicon_prev)\r\n\t\t\tDestroyIcon (hicon_prev);\r\n\r\n\t\tDeleteObject (hbitmap);\r\n\t}\r\n\r\n\tstatus = _r_res_loadimage (\r\n\t\t_r_sys_getimagebase (),\r\n\t\tL\"PNG\",\r\n\t\tMAKEINTRESOURCE (IDP_SEARCH_DARK),\r\n\t\t&GUID_ContainerFormatPng,\r\n\t\tcontext->image_width,\r\n\t\tcontext->image_height,\r\n\t\t&hbitmap\r\n\t);\r\n\r\n\tif (NT_SUCCESS (status))\r\n\t{\r\n\t\thicon_prev = context->hicon_dark;\r\n\r\n\t\tcontext->hicon_dark = _r_dc_bitmaptoicon (hbitmap, context->image_width, context->image_height);\r\n\r\n\t\tif (hicon_prev)\r\n\t\t\tDestroyIcon (hicon_prev);\r\n\r\n\t\tDeleteObject (hbitmap);\r\n\t}\r\n}\r\n\r\nVOID _app_search_themechanged (\r\n\t_In_ HWND hwnd,\r\n\t_Inout_ PSEARCH_CONTEXT context\r\n)\r\n{\r\n\t_app_search_initialize (context);\r\n\t_app_search_initializeimages (context, hwnd);\r\n\r\n\t// Reset the client area margins.\r\n\t_r_ctrl_settextmargin (hwnd, 0, 0, 0);\r\n\r\n\t// Refresh the non-client area.\r\n\tSetWindowPos (hwnd, NULL, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED);\r\n\r\n\t// Force the edit control to update its non-client area.\r\n\tRedrawWindow (hwnd, NULL, NULL, RDW_FRAME | RDW_INVALIDATE);\r\n}\r\n\r\nVOID _app_search_setvisible (\r\n\t_In_ HWND hwnd,\r\n\t_In_ HWND hsearch,\r\n\t_In_ LONG dpi_value\r\n)\r\n{\r\n\tBOOLEAN is_visible;\r\n\r\n\tis_visible = _r_config_getboolean (L\"IsShowSearchBar\", TRUE, NULL);\r\n\r\n\tif (is_visible)\r\n\t{\r\n\t\tif (!_r_rebar_isbandexists (hwnd, IDC_REBAR, REBAR_SEARCH_ID))\r\n\t\t\t_r_rebar_insertband (hwnd, IDC_REBAR, REBAR_SEARCH_ID, config.hsearchbar, RBBS_VARIABLEHEIGHT | RBBS_NOGRIPPER | RBBS_USECHEVRON, _r_dc_getdpi (180, dpi_value), 20);\r\n\r\n\t\tShowWindow (hsearch, SW_SHOWNA);\r\n\r\n\t\t_r_wnd_sendmessage (hsearch, 0, WM_SIZE, 0, 0);\r\n\r\n\t\tif (_r_wnd_isvisible (hwnd, FALSE))\r\n\t\t\tSetFocus (hsearch);\r\n\t}\r\n\telse\r\n\t{\r\n\t\tif (_r_rebar_isbandexists (hwnd, IDC_REBAR, REBAR_SEARCH_ID))\r\n\t\t\t_r_rebar_deleteband (hwnd, IDC_REBAR, REBAR_SEARCH_ID);\r\n\r\n\t\t_r_ctrl_setstring (hsearch, 0, L\"\");\r\n\r\n\t\tShowWindow (hsearch, SW_HIDE);\r\n\t}\r\n}\r\n\r\nVOID _app_search_drawwindow (\r\n\t_Inout_ PSEARCH_CONTEXT context,\r\n\t_In_ LPCRECT wnd_rect\r\n)\r\n{\r\n\tif (!_r_theme_isenabled ())\r\n\t\treturn;\r\n\r\n\tSetDCBrushColor (context->hdc, RGB (65, 65, 65));\r\n\r\n\tSelectObject (context->hdc, context->dc_brush);\r\n\r\n\tPatBlt (context->hdc, wnd_rect->left, wnd_rect->top, 1, wnd_rect->bottom - wnd_rect->top, PATCOPY);\r\n\tPatBlt (context->hdc, wnd_rect->right - 1, wnd_rect->top, 1, wnd_rect->bottom - wnd_rect->top, PATCOPY);\r\n\tPatBlt (context->hdc, wnd_rect->left, wnd_rect->top, wnd_rect->right - wnd_rect->left, 1, PATCOPY);\r\n\tPatBlt (context->hdc, wnd_rect->left, wnd_rect->bottom - 1, wnd_rect->right - wnd_rect->left, 1, PATCOPY);\r\n\r\n\tSetDCBrushColor (context->hdc, RGB (60, 60, 60));\r\n\r\n\tSelectObject (context->hdc, context->dc_brush);\r\n\r\n\tPatBlt (context->hdc, wnd_rect->left + 1, wnd_rect->top + 1, 1, wnd_rect->bottom - wnd_rect->top - 2, PATCOPY);\r\n\tPatBlt (context->hdc, wnd_rect->right - 2, wnd_rect->top + 1, 1, wnd_rect->bottom - wnd_rect->top - 2, PATCOPY);\r\n\tPatBlt (context->hdc, wnd_rect->left + 1, wnd_rect->top + 1, wnd_rect->right - wnd_rect->left - 2, 1, PATCOPY);\r\n\tPatBlt (context->hdc, wnd_rect->left + 1, wnd_rect->bottom - 2, wnd_rect->right - wnd_rect->left - 2, 1, PATCOPY);\r\n}\r\n\r\nVOID _app_search_drawbutton (\r\n\t_Inout_ PSEARCH_CONTEXT context,\r\n\t_In_ HWND hwnd,\r\n\t_In_ LPCRECT wnd_rect\r\n)\r\n{\r\n\tRECT btn_rect;\r\n\r\n\t_app_search_getbuttonrect (context, wnd_rect, &btn_rect);\r\n\r\n\tif (context->is_pushed)\r\n\t{\r\n\t\t_r_dc_fillrect (context->hdc, &btn_rect, _r_theme_isenabled () ? RGB (99, 99, 99) : RGB (153, 209, 255));\r\n\t}\r\n\telse if (context->is_hot)\r\n\t{\r\n\t\t_r_dc_fillrect (context->hdc, &btn_rect, _r_theme_isenabled () ? RGB (78, 78, 78) : RGB (205, 232, 255));\r\n\t}\r\n\telse\r\n\t{\r\n\t\t_r_dc_fillrect (context->hdc, &btn_rect, _r_theme_isenabled () ? RGB (60, 60, 60) : GetSysColor (COLOR_WINDOW));\r\n\t}\r\n\r\n\tDrawIconEx (\r\n\t\tcontext->hdc,\r\n\t\tbtn_rect.left + 1,\r\n\t\tbtn_rect.top,\r\n\t\t_r_theme_isenabled () ? context->hicon_light : context->hicon_dark,\r\n\t\tcontext->image_width,\r\n\t\tcontext->image_height,\r\n\t\t0,\r\n\t\tNULL,\r\n\t\tDI_NORMAL\r\n\t);\r\n}\r\n\r\nVOID _app_search_getbuttonrect (\r\n\t_In_ PSEARCH_CONTEXT context,\r\n\t_In_ LPCRECT wnd_rect,\r\n\t_Out_ PRECT btn_rect\r\n)\r\n{\r\n\t*btn_rect = *wnd_rect;\r\n\r\n\tbtn_rect->left = ((btn_rect->right - context->cx_width) - context->cx_border - 1);\r\n\tbtn_rect->top += context->cx_border;\r\n\tbtn_rect->right -= context->cx_border;\r\n\tbtn_rect->bottom -= context->cx_border;\r\n}\r\n\r\nBOOLEAN _app_search_isstringfound (\r\n\t_In_opt_ PR_STRINGREF string,\r\n\t_In_ PR_STRINGREF search_string,\r\n\t_Inout_ PITEM_LISTVIEW_CONTEXT context,\r\n\t_Inout_ PBOOLEAN is_changed\r\n)\r\n{\r\n\tif (!string)\r\n\t{\r\n\t\tif (context->is_hidden)\r\n\t\t{\r\n\t\t\tcontext->is_hidden = FALSE;\r\n\r\n\t\t\t*is_changed = TRUE;\r\n\t\t}\r\n\r\n\t\treturn FALSE;\r\n\t}\r\n\r\n\tif (_r_str_findstring (string, search_string, TRUE) != SIZE_MAX)\r\n\t{\r\n\t\tif (context->is_hidden)\r\n\t\t{\r\n\t\t\tcontext->is_hidden = FALSE;\r\n\r\n\t\t\t*is_changed = TRUE;\r\n\t\t}\r\n\r\n\t\treturn TRUE;\r\n\t}\r\n\telse\r\n\t{\r\n\t\tif (!context->is_hidden)\r\n\t\t{\r\n\t\t\tcontext->is_hidden = TRUE;\r\n\r\n\t\t\t*is_changed = TRUE;\r\n\t\t}\r\n\t}\r\n\r\n\treturn FALSE;\r\n}\r\n\r\nBOOLEAN _app_search_applyfiltercallback (\r\n\t_In_ HWND hwnd,\r\n\t_In_ INT listview_id,\r\n\t_In_opt_ PR_STRING search_string\r\n)\r\n{\r\n\tPITEM_LISTVIEW_CONTEXT context;\r\n\tINT item_count;\r\n\tBOOLEAN is_changed = FALSE;\r\n\r\n\titem_count = _r_listview_getitemcount (hwnd, listview_id);\r\n\r\n\tif (!item_count)\r\n\t\treturn FALSE;\r\n\r\n\tfor (INT i = 0; i < item_count; i++)\r\n\t{\r\n\t\tcontext = (PITEM_LISTVIEW_CONTEXT)_r_listview_getitemlparam (hwnd, listview_id, i);\r\n\r\n\t\tif (!context)\r\n\t\t\tcontinue;\r\n\r\n\t\tif (_app_search_applyfilteritem (hwnd, listview_id, i, context, search_string))\r\n\t\t\tis_changed = TRUE;\r\n\t}\r\n\r\n\tif (is_changed)\r\n\t\t_app_listview_updateby_id (hwnd, listview_id, PR_UPDATE_NOSETVIEW | PR_UPDATE_FORCE);\r\n\r\n\treturn is_changed;\r\n}\r\n\r\nBOOLEAN _app_search_applyfilteritem (\r\n\t_In_ HWND hwnd,\r\n\t_In_ INT listview_id,\r\n\t_In_ INT item_id,\r\n\t_Inout_ PITEM_LISTVIEW_CONTEXT context,\r\n\t_In_opt_ PR_STRING search_string\r\n)\r\n{\r\n\tPITEM_APP ptr_app = NULL;\r\n\tPITEM_RULE ptr_rule = NULL;\r\n\tPITEM_NETWORK ptr_network = NULL;\r\n\tPITEM_LOG ptr_log = NULL;\r\n\tPR_STRING string;\r\n\tBOOLEAN is_changed = FALSE;\r\n\r\n\t// reset hidden state\r\n\tif (context->is_hidden)\r\n\t{\r\n\t\tcontext->is_hidden = FALSE;\r\n\r\n\t\tis_changed = TRUE;\r\n\t}\r\n\r\n\tif (!search_string)\r\n\t\tgoto CleanupExit;\r\n\r\n\tswitch (listview_id)\r\n\t{\r\n\t\tcase IDC_APPS_PROFILE:\r\n\t\tcase IDC_APPS_SERVICE:\r\n\t\tcase IDC_APPS_UWP:\r\n\t\tcase IDC_RULE_APPS_ID:\r\n\t\t{\r\n\t\t\tptr_app = _app_getappitem ((ULONG)context->id_code);\r\n\r\n\t\t\tif (!ptr_app)\r\n\t\t\t\tgoto CleanupExit;\r\n\r\n\t\t\t// path\r\n\t\t\tif (ptr_app->real_path)\r\n\t\t\t{\r\n\t\t\t\tif (_app_search_isstringfound (&ptr_app->real_path->sr, &search_string->sr, context, &is_changed))\r\n\t\t\t\t\tgoto CleanupExit;\r\n\t\t\t}\r\n\r\n\t\t\t// comment\r\n\t\t\tif (!_r_obj_isstringempty (ptr_app->comment))\r\n\t\t\t{\r\n\t\t\t\tif (_app_search_isstringfound (&ptr_app->comment->sr, &search_string->sr, context, &is_changed))\r\n\t\t\t\t\tgoto CleanupExit;\r\n\t\t\t}\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase IDC_RULES_BLOCKLIST:\r\n\t\tcase IDC_RULES_SYSTEM:\r\n\t\tcase IDC_RULES_CUSTOM:\r\n\t\tcase IDC_APP_RULES_ID:\r\n\t\t{\r\n\t\t\tptr_rule = _app_getrulebyid (context->id_code);\r\n\r\n\t\t\tif (!ptr_rule)\r\n\t\t\t\tgoto CleanupExit;\r\n\r\n\t\t\tif (ptr_rule->name)\r\n\t\t\t{\r\n\t\t\t\tif (_app_search_isstringfound (&ptr_rule->name->sr, &search_string->sr, context, &is_changed))\r\n\t\t\t\t\tgoto CleanupExit;\r\n\t\t\t}\r\n\r\n\t\t\tif (ptr_rule->rule_remote)\r\n\t\t\t{\r\n\t\t\t\tif (_app_search_isstringfound (&ptr_rule->rule_remote->sr, &search_string->sr, context, &is_changed))\r\n\t\t\t\t\tgoto CleanupExit;\r\n\t\t\t}\r\n\r\n\t\t\tif (ptr_rule->rule_local)\r\n\t\t\t{\r\n\t\t\t\tif (_app_search_isstringfound (&ptr_rule->rule_local->sr, &search_string->sr, context, &is_changed))\r\n\t\t\t\t\tgoto CleanupExit;\r\n\t\t\t}\r\n\r\n\t\t\tif (ptr_rule->protocol_str)\r\n\t\t\t{\r\n\t\t\t\tif (_app_search_isstringfound (&ptr_rule->protocol_str->sr, &search_string->sr, context, &is_changed))\r\n\t\t\t\t\tgoto CleanupExit;\r\n\t\t\t}\r\n\r\n\t\t\t// comment\r\n\t\t\tif (!_r_obj_isstringempty (ptr_rule->comment))\r\n\t\t\t{\r\n\t\t\t\tif (_app_search_isstringfound (&ptr_rule->comment->sr, &search_string->sr, context, &is_changed))\r\n\t\t\t\t\tgoto CleanupExit;\r\n\t\t\t}\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase IDC_NETWORK:\r\n\t\t{\r\n\t\t\tptr_network = _app_network_getitem ((ULONG)context->id_code);\r\n\r\n\t\t\tif (!ptr_network)\r\n\t\t\t\tgoto CleanupExit;\r\n\r\n\t\t\t// path\r\n\t\t\tif (ptr_network->path)\r\n\t\t\t{\r\n\t\t\t\tif (_app_search_isstringfound (&ptr_network->path->sr, &search_string->sr, context, &is_changed))\r\n\t\t\t\t\tgoto CleanupExit;\r\n\t\t\t}\r\n\r\n\t\t\t// local address\r\n\t\t\tstring = _InterlockedCompareExchangePointer ((volatile PVOID_PTR)&ptr_network->local_addr_str, NULL, NULL);\r\n\r\n\t\t\tif (string)\r\n\t\t\t{\r\n\t\t\t\tif (_app_search_isstringfound (&string->sr, &search_string->sr, context, &is_changed))\r\n\t\t\t\t\tgoto CleanupExit;\r\n\t\t\t}\r\n\r\n\t\t\t// local host\r\n\t\t\tstring = _InterlockedCompareExchangePointer ((volatile PVOID_PTR)&ptr_network->local_host_str, NULL, NULL);\r\n\r\n\t\t\tif (string)\r\n\t\t\t{\r\n\t\t\t\tif (_app_search_isstringfound (&string->sr, &search_string->sr, context, &is_changed))\r\n\t\t\t\t\tgoto CleanupExit;\r\n\t\t\t}\r\n\r\n\t\t\t// remote address\r\n\t\t\tstring = _InterlockedCompareExchangePointer ((volatile PVOID_PTR)&ptr_network->remote_addr_str, NULL, NULL);\r\n\r\n\t\t\tif (string)\r\n\t\t\t{\r\n\t\t\t\tif (_app_search_isstringfound (&string->sr, &search_string->sr, context, &is_changed))\r\n\t\t\t\t\tgoto CleanupExit;\r\n\t\t\t}\r\n\r\n\t\t\t// remote host\r\n\t\t\tstring = _InterlockedCompareExchangePointer ((volatile PVOID_PTR)&ptr_network->remote_host_str, NULL, NULL);\r\n\r\n\t\t\tif (string)\r\n\t\t\t{\r\n\t\t\t\tif (_app_search_isstringfound (&string->sr, &search_string->sr, context, &is_changed))\r\n\t\t\t\t\tgoto CleanupExit;\r\n\t\t\t}\r\n\r\n\t\t\t// protocol\r\n\t\t\tif (ptr_network->protocol_str)\r\n\t\t\t{\r\n\t\t\t\tif (_app_search_isstringfound (&ptr_network->protocol_str->sr, &search_string->sr, context, &is_changed))\r\n\t\t\t\t\tgoto CleanupExit;\r\n\t\t\t}\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase IDC_LOG:\r\n\t\t{\r\n\t\t\tptr_log = _app_getlogitem ((ULONG)context->id_code);\r\n\r\n\t\t\tif (!ptr_log)\r\n\t\t\t\tgoto CleanupExit;\r\n\r\n\t\t\t// path\r\n\t\t\tif (ptr_log->path)\r\n\t\t\t{\r\n\t\t\t\tif (_app_search_isstringfound (&ptr_log->path->sr, &search_string->sr, context, &is_changed))\r\n\t\t\t\t\tgoto CleanupExit;\r\n\t\t\t}\r\n\r\n\t\t\t// filter name\r\n\t\t\tif (ptr_log->filter_name)\r\n\t\t\t{\r\n\t\t\t\tif (_app_search_isstringfound (&ptr_log->filter_name->sr, &search_string->sr, context, &is_changed))\r\n\t\t\t\t\tgoto CleanupExit;\r\n\t\t\t}\r\n\r\n\t\t\t// layer name\r\n\t\t\tif (ptr_log->layer_name)\r\n\t\t\t{\r\n\t\t\t\tif (_app_search_isstringfound (&ptr_log->layer_name->sr, &search_string->sr, context, &is_changed))\r\n\t\t\t\t\tgoto CleanupExit;\r\n\t\t\t}\r\n\r\n\t\t\t// user name\r\n\t\t\tif (ptr_log->username)\r\n\t\t\t{\r\n\t\t\t\tif (_app_search_isstringfound (&ptr_log->username->sr, &search_string->sr, context, &is_changed))\r\n\t\t\t\t\tgoto CleanupExit;\r\n\t\t\t}\r\n\r\n\t\t\t// local address\r\n\t\t\tstring = _InterlockedCompareExchangePointer ((volatile PVOID_PTR)&ptr_log->local_addr_str, NULL, NULL);\r\n\r\n\t\t\tif (string)\r\n\t\t\t{\r\n\t\t\t\tif (_app_search_isstringfound (&string->sr, &search_string->sr, context, &is_changed))\r\n\t\t\t\t\tgoto CleanupExit;\r\n\t\t\t}\r\n\r\n\t\t\t// local host\r\n\t\t\tstring = _InterlockedCompareExchangePointer ((volatile PVOID_PTR)&ptr_log->local_host_str, NULL, NULL);\r\n\r\n\t\t\tif (string)\r\n\t\t\t{\r\n\t\t\t\tif (_app_search_isstringfound (&string->sr, &search_string->sr, context, &is_changed))\r\n\t\t\t\t\tgoto CleanupExit;\r\n\t\t\t}\r\n\r\n\t\t\t// remote address\r\n\t\t\tstring = _InterlockedCompareExchangePointer ((volatile PVOID_PTR)&ptr_log->remote_addr_str, NULL, NULL);\r\n\r\n\t\t\tif (string)\r\n\t\t\t{\r\n\t\t\t\tif (_app_search_isstringfound (&string->sr, &search_string->sr, context, &is_changed))\r\n\t\t\t\t\tgoto CleanupExit;\r\n\t\t\t}\r\n\r\n\t\t\t// remote host\r\n\t\t\tstring = _InterlockedCompareExchangePointer ((volatile PVOID_PTR)&ptr_log->remote_host_str, NULL, NULL);\r\n\r\n\t\t\tif (string)\r\n\t\t\t{\r\n\t\t\t\tif (_app_search_isstringfound (&string->sr, &search_string->sr, context, &is_changed))\r\n\t\t\t\t\tgoto CleanupExit;\r\n\t\t\t}\r\n\r\n\t\t\t// protocol\r\n\t\t\tif (ptr_log->protocol_str)\r\n\t\t\t{\r\n\t\t\t\tif (_app_search_isstringfound (&ptr_log->protocol_str->sr, &search_string->sr, context, &is_changed))\r\n\t\t\t\t\tgoto CleanupExit;\r\n\t\t\t}\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\r\nCleanupExit:\r\n\r\n\tif (ptr_app)\r\n\t\t_r_obj_dereference (ptr_app);\r\n\r\n\tif (ptr_rule)\r\n\t\t_r_obj_dereference (ptr_rule);\r\n\r\n\tif (ptr_network)\r\n\t\t_r_obj_dereference (ptr_network);\r\n\r\n\tif (ptr_log)\r\n\t\t_r_obj_dereference (ptr_log);\r\n\r\n\tif (is_changed)\r\n\t\t_r_listview_setitem (hwnd, listview_id, item_id, 0, NULL, I_IMAGECALLBACK, I_GROUPIDCALLBACK, I_DEFAULT);\r\n\r\n\treturn is_changed;\r\n}\r\n\r\nVOID _app_search_applyfilter (\r\n\t_In_ HWND hwnd,\r\n\t_In_ INT listview_id,\r\n\t_In_opt_ PR_STRING search_string\r\n)\r\n{\r\n\tif (!((listview_id >= IDC_APPS_PROFILE && listview_id <= IDC_LOG) || listview_id == IDC_RULE_APPS_ID || listview_id == IDC_APP_RULES_ID))\r\n\t\treturn;\r\n\r\n\t_app_search_applyfiltercallback (hwnd, listview_id, search_string);\r\n}\r\n\r\nVOID _app_search_createbufferedcontext (\r\n\t_Inout_ PSEARCH_CONTEXT context,\r\n\t_In_ HDC hdc,\r\n\t_In_ LPCRECT buf_rect\r\n)\r\n{\r\n\tcontext->hdc = CreateCompatibleDC (hdc);\r\n\r\n\tif (!context->hdc)\r\n\t\treturn;\r\n\r\n\tCopyRect (&context->rect, buf_rect);\r\n\r\n\tcontext->hbitmap = CreateCompatibleBitmap (hdc, context->rect.right, context->rect.bottom);\r\n\r\n\tcontext->old_bitmap = SelectObject (context->hdc, context->hbitmap);\r\n}\r\n\r\nVOID _app_search_destroybufferedcontext (\r\n\t_Inout_ PSEARCH_CONTEXT context\r\n)\r\n{\r\n\tif (context->hdc && context->old_bitmap)\r\n\t\tSelectObject (context->hdc, context->old_bitmap);\r\n\r\n\tSAFE_DELETE_OBJECT (context->hbitmap);\r\n\r\n\tSAFE_DELETE_DC (context->hdc);\r\n}\r\n\r\nLRESULT CALLBACK _app_search_subclass_proc (\r\n\t_In_ HWND hwnd,\r\n\t_In_ UINT msg,\r\n\t_In_ WPARAM wparam,\r\n\t_In_ LPARAM lparam\r\n)\r\n{\r\n\tPSEARCH_CONTEXT context;\r\n\tWNDPROC wnd_proc;\r\n\r\n\tcontext = _r_wnd_getcontext (hwnd, SHORT_MAX);\r\n\r\n\tif (!context)\r\n\t\treturn 0;\r\n\r\n\twnd_proc = context->wnd_proc;\r\n\r\n\tswitch (msg)\r\n\t{\r\n\t\tcase WM_NCDESTROY:\r\n\t\t{\r\n\t\t\tSAFE_DELETE_ICON (context->hicon_light);\r\n\t\t\tSAFE_DELETE_ICON (context->hicon_dark);\r\n\r\n\t\t\t_r_wnd_removecontext (context->hwnd, SHORT_MAX);\r\n\r\n\t\t\tSetWindowLongPtrW (hwnd, GWLP_WNDPROC, (LONG_PTR)wnd_proc);\r\n\r\n\t\t\t_app_search_destroybufferedcontext (context);\r\n\r\n\t\t\t_r_mem_free (context);\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase WM_ERASEBKGND:\r\n\t\t{\r\n\t\t\treturn TRUE;\r\n\t\t}\r\n\r\n\t\tcase WM_NCCALCSIZE:\r\n\t\t{\r\n\t\t\tLPNCCALCSIZE_PARAMS calc_size;\r\n\r\n\t\t\tcalc_size = (LPNCCALCSIZE_PARAMS)lparam;\r\n\r\n\t\t\t// Let Windows handle the non-client defaults.\r\n\t\t\tCallWindowProcW (wnd_proc, hwnd, msg, wparam, lparam);\r\n\r\n\t\t\t// Deflate the client area to accommodate the custom button.\r\n\t\t\tcalc_size->rgrc[0].right -= context->cx_width;\r\n\r\n\t\t\treturn 0;\r\n\t\t}\r\n\r\n\t\tcase WM_NCPAINT:\r\n\t\t{\r\n\t\t\tRECT wnd_rect;\r\n\t\t\tRECT buf_rect;\r\n\t\t\tHRGN hrgn;\r\n\t\t\tHDC hdc;\r\n\t\t\tULONG flags = DCX_WINDOW | DCX_LOCKWINDOWUPDATE | DCX_USESTYLE;\r\n\r\n\t\t\thrgn = (HRGN)wparam;\r\n\r\n\t\t\tif (hrgn == HRGN_FULL)\r\n\t\t\t\thrgn = NULL;\r\n\r\n\t\t\tif (hrgn)\r\n\t\t\t\tflags |= DCX_INTERSECTRGN | DCX_NODELETERGN;\r\n\r\n\t\t\thdc = GetDCEx (hwnd, hrgn, flags);\r\n\r\n\t\t\tif (hdc)\r\n\t\t\t{\r\n\t\t\t\t// Get the screen coordinates of the window.\r\n\t\t\t\tGetWindowRect (hwnd, &wnd_rect);\r\n\r\n\t\t\t\t// Adjust the coordinates (start from 0,0).\r\n\t\t\t\tOffsetRect (&wnd_rect, -wnd_rect.left, -wnd_rect.top);\r\n\r\n\t\t\t\t// Exclude client area.\r\n\t\t\t\tExcludeClipRect (\r\n\t\t\t\t\thdc,\r\n\t\t\t\t\twnd_rect.left + context->cx_border + 1,\r\n\t\t\t\t\twnd_rect.top + context->cx_border + 1,\r\n\t\t\t\t\twnd_rect.right - context->cx_width - (context->cx_border + 1),\r\n\t\t\t\t\twnd_rect.bottom - (context->cx_border + 1)\r\n\t\t\t\t);\r\n\r\n\t\t\t\tSetRect (&buf_rect, 0, 0, _r_calc_rectwidth (&wnd_rect), _r_calc_rectheight (&wnd_rect));\r\n\r\n\t\t\t\tif (context->hdc && (context->rect.right < buf_rect.right || context->rect.bottom < buf_rect.bottom))\r\n\t\t\t\t\t_app_search_destroybufferedcontext (context);\r\n\r\n\t\t\t\tif (!context->hdc)\r\n\t\t\t\t\t_app_search_createbufferedcontext (context, hdc, &buf_rect);\r\n\r\n\t\t\t\tif (!context->hdc)\r\n\t\t\t\t{\r\n\t\t\t\t\tReleaseDC (hwnd, hdc);\r\n\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif ((context->is_mouseactive && context->is_hot) || GetFocus () == hwnd)\r\n\t\t\t\t{\r\n\t\t\t\t\t_r_dc_framerect (context->hdc, &wnd_rect, _r_theme_isenabled () ? WND_HOT_CLR : GetSysColor (COLOR_HOTLIGHT));\r\n\r\n\t\t\t\t\tInflateRect (&wnd_rect, -1, -1);\r\n\r\n\t\t\t\t\t_r_dc_framerect (context->hdc, &wnd_rect, GetSysColor (COLOR_WINDOW));\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\t_r_dc_framerect (context->hdc, &wnd_rect, GetSysColor (COLOR_WINDOWFRAME));\r\n\r\n\t\t\t\t\tInflateRect (&wnd_rect, -1, -1);\r\n\r\n\t\t\t\t\t_r_dc_framerect (context->hdc, &wnd_rect, GetSysColor (COLOR_WINDOW));\r\n\t\t\t\t}\r\n\r\n\t\t\t\t_app_search_drawwindow (context, &wnd_rect);\r\n\t\t\t\t_app_search_drawbutton (context, hwnd, &wnd_rect);\r\n\r\n\t\t\t\tBitBlt (hdc, buf_rect.left, buf_rect.top, buf_rect.right, buf_rect.bottom, context->hdc, 0, 0, SRCCOPY);\r\n\r\n\t\t\t\tReleaseDC (hwnd, hdc);\r\n\t\t\t}\r\n\r\n\t\t\treturn 0;\r\n\t\t}\r\n\r\n\t\tcase WM_NCHITTEST:\r\n\t\t{\r\n\t\t\tRECT wnd_rect;\r\n\t\t\tRECT btn_rect;\r\n\t\t\tPOINT point;\r\n\r\n\t\t\t// Get the screen coordinates of the mouse.\r\n\t\t\tif (!GetCursorPos (&point))\r\n\t\t\t\tbreak;\r\n\r\n\t\t\t// Get the screen coordinates of the window.\r\n\t\t\tif (!GetWindowRect (hwnd, &wnd_rect))\r\n\t\t\t\tbreak;\r\n\r\n\t\t\t// Get the position of the inserted button.\r\n\t\t\t_app_search_getbuttonrect (context, &wnd_rect, &btn_rect);\r\n\r\n\t\t\t// Check that the mouse is within the inserted button.\r\n\t\t\tif (PtInRect (&btn_rect, point))\r\n\t\t\t\treturn HTBORDER;\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase WM_NCLBUTTONDOWN:\r\n\t\t{\r\n\t\t\tRECT wnd_rect;\r\n\t\t\tRECT btn_rect;\r\n\t\t\tPOINT point;\r\n\r\n\t\t\t// Get the screen coordinates of the mouse.\r\n\t\t\tif (!GetCursorPos (&point))\r\n\t\t\t\tbreak;\r\n\r\n\t\t\t// Get the screen coordinates of the window.\r\n\t\t\tif (!GetWindowRect (hwnd, &wnd_rect))\r\n\t\t\t\tbreak;\r\n\r\n\t\t\t// Get the position of the inserted button.\r\n\t\t\t_app_search_getbuttonrect (context, &wnd_rect, &btn_rect);\r\n\r\n\t\t\tcontext->is_pushed = PtInRect (&btn_rect, point);\r\n\r\n\t\t\tSetCapture (hwnd);\r\n\r\n\t\t\tRedrawWindow (hwnd, NULL, NULL, RDW_FRAME | RDW_INVALIDATE);\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase WM_LBUTTONUP:\r\n\t\t{\r\n\t\t\tRECT wnd_rect;\r\n\t\t\tRECT btn_rect;\r\n\t\t\tPOINT point;\r\n\r\n\t\t\t// Get the screen coordinates of the mouse.\r\n\t\t\tif (!GetCursorPos (&point))\r\n\t\t\t\tbreak;\r\n\r\n\t\t\t// Get the screen coordinates of the window.\r\n\t\t\tif (!GetWindowRect (hwnd, &wnd_rect))\r\n\t\t\t\tbreak;\r\n\r\n\t\t\t// Get the position of the inserted button.\r\n\t\t\t_app_search_getbuttonrect (context, &wnd_rect, &btn_rect);\r\n\r\n\t\t\t// Check that the mouse is within the inserted button.\r\n\t\t\tif (PtInRect (&btn_rect, point))\r\n\t\t\t{\r\n\t\t\t\tSetFocus (hwnd);\r\n\r\n\t\t\t\t_r_ctrl_setstring (hwnd, 0, L\"\");\r\n\t\t\t}\r\n\r\n\t\t\tif (GetCapture () == hwnd)\r\n\t\t\t{\r\n\t\t\t\tcontext->is_pushed = FALSE;\r\n\r\n\t\t\t\tReleaseCapture ();\r\n\t\t\t}\r\n\r\n\t\t\tRedrawWindow (hwnd, NULL, NULL, RDW_FRAME | RDW_INVALIDATE);\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase WM_CUT:\r\n\t\tcase WM_CLEAR:\r\n\t\tcase WM_PASTE:\r\n\t\tcase WM_UNDO:\r\n\t\tcase WM_KEYUP:\r\n\t\tcase WM_SETTEXT:\r\n\t\tcase WM_KILLFOCUS:\r\n\t\t{\r\n\t\t\tRedrawWindow (hwnd, NULL, NULL, RDW_FRAME | RDW_INVALIDATE);\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase WM_SETTINGCHANGE:\r\n\t\tcase WM_SYSCOLORCHANGE:\r\n\t\tcase WM_THEMECHANGED:\r\n\t\tcase WM_DPICHANGED_AFTERPARENT:\r\n\t\t{\r\n\t\t\tif (msg == WM_DPICHANGED_AFTERPARENT)\r\n\t\t\t\tcontext->dpi_value = _r_dc_getwindowdpi (context->hwnd);\r\n\r\n\t\t\t_app_search_themechanged (hwnd, context);\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase WM_MOUSEMOVE:\r\n\t\tcase WM_NCMOUSEMOVE:\r\n\t\t{\r\n\t\t\tTRACKMOUSEEVENT tme = {0};\r\n\t\t\tRECT wnd_rect;\r\n\t\t\tRECT btn_rect;\r\n\t\t\tPOINT pt;\r\n\r\n\t\t\t// Get the screen coordinates of the mouse.\r\n\t\t\tif (!GetCursorPos (&pt))\r\n\t\t\t\tbreak;\r\n\r\n\t\t\t// Get the screen coordinates of the window.\r\n\t\t\tif (!GetWindowRect (hwnd, &wnd_rect))\r\n\t\t\t\tbreak;\r\n\r\n\t\t\tcontext->is_hot = PtInRect (&wnd_rect, pt);\r\n\r\n\t\t\t// Get the position of the inserted button.\r\n\t\t\t_app_search_getbuttonrect (context, &wnd_rect, &btn_rect);\r\n\r\n\t\t\t// Check that the mouse is within the inserted button.\r\n\t\t\tif (!context->is_mouseactive)\r\n\t\t\t{\r\n\t\t\t\ttme.cbSize = sizeof (TRACKMOUSEEVENT);\r\n\t\t\t\ttme.dwFlags = TME_LEAVE;\r\n\t\t\t\ttme.hwndTrack = hwnd;\r\n\t\t\t\ttme.dwHoverTime = 0;\r\n\r\n\t\t\t\tcontext->is_mouseactive = TRUE;\r\n\r\n\t\t\t\tTrackMouseEvent (&tme);\r\n\t\t\t}\r\n\r\n\t\t\tRedrawWindow (hwnd, NULL, NULL, RDW_FRAME | RDW_INVALIDATE);\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase WM_MOUSELEAVE:\r\n\t\tcase WM_NCMOUSELEAVE:\r\n\t\t{\r\n\t\t\tTRACKMOUSEEVENT tme = {0};\r\n\t\t\tRECT wnd_rect;\r\n\t\t\tRECT btn_rect;\r\n\t\t\tPOINT point;\r\n\r\n\t\t\tif (context->is_mouseactive)\r\n\t\t\t{\r\n\t\t\t\ttme.cbSize = sizeof (TRACKMOUSEEVENT);\r\n\t\t\t\ttme.dwFlags = TME_LEAVE | TME_CANCEL;\r\n\t\t\t\ttme.hwndTrack = hwnd;\r\n\t\t\t\ttme.dwHoverTime = 0;\r\n\r\n\t\t\t\tTrackMouseEvent (&tme);\r\n\r\n\t\t\t\tcontext->is_mouseactive = FALSE;\r\n\t\t\t}\r\n\r\n\t\t\t// Get the screen coordinates of the mouse.\r\n\t\t\tif (!GetCursorPos (&point))\r\n\t\t\t\tbreak;\r\n\r\n\t\t\t// Get the screen coordinates of the window.\r\n\t\t\tif (!GetWindowRect (hwnd, &wnd_rect))\r\n\t\t\t\tbreak;\r\n\r\n\t\t\t_app_search_getbuttonrect (context, &wnd_rect, &btn_rect);\r\n\r\n\t\t\tcontext->is_hot = PtInRect (&btn_rect, point);\r\n\r\n\t\t\tRedrawWindow (hwnd, NULL, NULL, RDW_FRAME | RDW_INVALIDATE);\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\r\n\treturn CallWindowProcW (wnd_proc, hwnd, msg, wparam, lparam);\r\n}\r\n"
  },
  {
    "path": "src/search.h",
    "content": "// simplewall\r\n// Copyright (c) 2012-2021 dmex\r\n// Copyright (c) 2021-2025 Henry++\r\n\r\n#pragma once\r\n\r\ntypedef struct _SEARCH_CONTEXT\r\n{\r\n\tRECT rect;\r\n\tHICON hicon_light;\r\n\tHICON hicon_dark;\r\n\tHBITMAP old_bitmap;\r\n\tHBITMAP hbitmap;\r\n\tHBRUSH dc_brush;\r\n\tHWND hwnd;\r\n\tHDC hdc;\r\n\r\n\tWNDPROC wnd_proc;\r\n\r\n\tunion\r\n\t{\r\n\t\tULONG flags;\r\n\r\n\t\tstruct\r\n\t\t{\r\n\t\t\tULONG is_hot : 1;\r\n\t\t\tULONG is_pushed : 1;\r\n\t\t\tULONG is_mouseactive : 1;\r\n\t\t\tULONG spare_bits : 29;\r\n\t\t};\r\n\t};\r\n\r\n\tLONG dpi_value;\r\n\r\n\tLONG image_width;\r\n\tLONG image_height;\r\n\r\n\tINT cx_width;\r\n\tINT cx_border;\r\n} SEARCH_CONTEXT, *PSEARCH_CONTEXT;\r\n\r\nVOID _app_search_initialize (\r\n\t_Inout_ PSEARCH_CONTEXT context\r\n);\r\n\r\nVOID _app_search_create (\r\n\t_In_ HWND hwnd\r\n);\r\n\r\nVOID _app_search_initializeimages (\r\n\t_In_ PSEARCH_CONTEXT context,\r\n\t_In_ HWND hwnd\r\n);\r\n\r\nVOID _app_search_themechanged (\r\n\t_In_ HWND hwnd,\r\n\t_Inout_ PSEARCH_CONTEXT context\r\n);\r\n\r\nVOID _app_search_setvisible (\r\n\t_In_ HWND hwnd,\r\n\t_In_ HWND hsearch,\r\n\t_In_ LONG dpi_value\r\n);\r\n\r\nVOID _app_search_drawwindow (\r\n\t_Inout_ PSEARCH_CONTEXT context,\r\n\t_In_ LPCRECT wnd_rect\r\n);\r\n\r\nVOID _app_search_drawbutton (\r\n\t_Inout_ PSEARCH_CONTEXT context,\r\n\t_In_ HWND hwnd,\r\n\t_In_ LPCRECT wnd_rect\r\n);\r\n\r\nVOID _app_search_getbuttonrect (\r\n\t_In_ PSEARCH_CONTEXT context,\r\n\t_In_ LPCRECT wnd_rect,\r\n\t_Out_ PRECT btn_rect\r\n);\r\n\r\nBOOLEAN _app_search_applyfiltercallback (\r\n\t_In_ HWND hwnd,\r\n\t_In_ INT listview_id,\r\n\t_In_opt_ PR_STRING search_string\r\n);\r\n\r\nBOOLEAN _app_search_applyfilteritem (\r\n\t_In_ HWND hwnd,\r\n\t_In_ INT listview_id,\r\n\t_In_ INT item_id,\r\n\t_Inout_ PITEM_LISTVIEW_CONTEXT context,\r\n\t_In_opt_ PR_STRING search_string\r\n);\r\n\r\nVOID _app_search_applyfilter (\r\n\t_In_ HWND hwnd,\r\n\t_In_ INT listview_id,\r\n\t_In_opt_ PR_STRING search_string\r\n);\r\n\r\nLRESULT CALLBACK _app_search_subclass_proc (\r\n\t_In_ HWND hwnd,\r\n\t_In_ UINT msg,\r\n\t_In_ WPARAM wparam,\r\n\t_In_ LPARAM lparam\r\n);\r\n"
  },
  {
    "path": "src/security.c",
    "content": "// simplewall\r\n// Copyright (c) 2020-2026 Henry++\r\n\r\n#include \"global.h\"\r\n\r\n_Ret_maybenull_\r\nPSID _app_quyerybuiltinsid (\r\n\t_In_ WELL_KNOWN_SID_TYPE sid_type\r\n)\r\n{\r\n\tPSID sid;\r\n\tULONG sid_length;\r\n\r\n\tsid_length = SECURITY_MAX_SID_SIZE;\r\n\tsid = _r_mem_allocate (sid_length);\r\n\r\n\tif (!CreateWellKnownSid (sid_type, NULL, sid, &sid_length))\r\n\t{\r\n\t\t_r_log_v (LOG_LEVEL_ERROR, NULL, L\"CreateWellKnownSid\", NtLastError (), L\"%d\", sid_type);\r\n\r\n\t\t_r_mem_free (sid);\r\n\r\n\t\treturn NULL;\r\n\r\n\t}\r\n\r\n\treturn sid;\r\n}\r\n\r\nVOID _app_generate_credentials ()\r\n{\r\n\t// For revoke current user (v3.0.5 Beta and lower)\r\n\tconfig.builtin_current_sid = _r_sys_getcurrenttoken ()->token_sid;\r\n\r\n\t// S-1-5-32-544 (BUILTIN\\Administrators)\r\n\tconfig.builtin_admins_sid = _app_quyerybuiltinsid (WinBuiltinAdministratorsSid);\r\n\r\n\t// S-1-5-32-556 (BUILTIN\\Network Configuration Operators)\r\n\tconfig.builtin_netops_sid = _app_quyerybuiltinsid (WinBuiltinNetworkConfigurationOperatorsSid);\r\n\r\n\t_r_sys_getservicesid (L\"mpssvc\", &config.service_mpssvc_sid);\r\n\t_r_sys_getservicesid (L\"NlaSvc\", &config.service_nlasvc_sid);\r\n\t_r_sys_getservicesid (L\"PolicyAgent\", &config.service_policyagent_sid);\r\n\t_r_sys_getservicesid (L\"RpcSs\", &config.service_rpcss_sid);\r\n\t_r_sys_getservicesid (L\"WdiServiceHost\", &config.service_wdiservicehost_sid);\r\n}\r\n\r\n_Ret_maybenull_\r\nPACL _app_createaccesscontrollist (\r\n\t_In_ PACL acl,\r\n\t_In_ BOOLEAN is_secure\r\n)\r\n{\r\n\tPACCESS_ALLOWED_ACE ace = NULL;\r\n\tEXPLICIT_ACCESS ea[3] = {0};\r\n\tPACL new_dacl = NULL;\r\n\tULONG count = 0;\r\n\tBOOLEAN is_currentuserhaverights = FALSE;\r\n\tBOOLEAN is_openforeveryone = FALSE;\r\n\tBOOLEAN is_secured = FALSE;\r\n\tNTSTATUS status;\r\n\r\n\tfor (WORD ace_index = 0; ace_index < acl->AceCount; ace_index++)\r\n\t{\r\n\t\tstatus = RtlGetAce (acl, ace_index, (PVOID_PTR)&ace);\r\n\r\n\t\tif (!NT_SUCCESS (status))\r\n\t\t{\r\n\t\t\t_r_log_v (LOG_LEVEL_ERROR, NULL, L\"RtlGetAce\", status, L\"%d\", ace_index);\r\n\r\n\t\t\tcontinue;\r\n\t\t}\r\n\r\n\t\tif (ace->Header.AceType == ACCESS_ALLOWED_ACE_TYPE)\r\n\t\t{\r\n\t\t\t// versions of SW before v3.0.5 added Carte blanche for current user\r\n\t\t\t//\r\n\t\t\t// src: https://github.com/henrypp/simplewall/blob/v.2.3.12/src/main.cpp#L8273\r\n\t\t\t// src: https://github.com/henrypp/simplewall/blob/v.2.3.13/src/main.cpp#L8354\r\n\t\t\t// src: https://github.com/henrypp/simplewall/blob/v.2.4.6/src/main.cpp#L8828\r\n\t\t\t// src: https://github.com/henrypp/simplewall/blob/v.3.0.5/src/wfp.cpp#L109\r\n\t\t\tif (RtlEqualSid (&ace->SidStart, config.builtin_current_sid))\r\n\t\t\t{\r\n\t\t\t\tif ((ace->Mask & (FWPM_GENERIC_EXECUTE | FWPM_GENERIC_WRITE | DELETE | WRITE_DAC | WRITE_OWNER)) != 0)\r\n\t\t\t\t\tis_currentuserhaverights = TRUE;\r\n\t\t\t}\r\n\r\n\t\t\t// versions of SW before v3.1.1 added Carte blanche for Everyone\r\n\t\t\t//\r\n\t\t\t// src: https://github.com/henrypp/simplewall/blob/v.2.4.6/src/main.cpp#L8833\r\n\t\t\t// src: https://github.com/henrypp/simplewall/blob/v.3.0.5/src/wfp.cpp#L114\r\n\t\t\t// src: https://github.com/henrypp/simplewall/blob/v.3.1.1/src/wfp.cpp#L150\r\n\t\t\telse if (RtlEqualSid (&ace->SidStart, &SeEveryoneSid))\r\n\t\t\t{\r\n\t\t\t\tif (((ace->Mask & ~(FWPM_ACTRL_CLASSIFY | FWPM_ACTRL_OPEN)) & (FWPM_GENERIC_EXECUTE | FWPM_GENERIC_READ)) != 0)\r\n\t\t\t\t\tis_openforeveryone = TRUE;\r\n\t\t\t}\r\n\t\t}\r\n\t\telse if (ace->Header.AceType == ACCESS_DENIED_ACE_TYPE)\r\n\t\t{\r\n\t\t\tif (RtlEqualSid (&ace->SidStart, &SeEveryoneSid))\r\n\t\t\t{\r\n\t\t\t\tif (ace->Mask == (FWPM_ACTRL_WRITE | DELETE | WRITE_DAC | WRITE_OWNER))\r\n\t\t\t\t\tis_secured = TRUE;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tif (is_openforeveryone || is_currentuserhaverights || is_secured != is_secure)\r\n\t{\r\n\t\t// revoke current user access rights\r\n\t\tif (is_currentuserhaverights)\r\n\t\t\t_app_setexplicitaccess (&ea[count++], REVOKE_ACCESS, 0, NO_INHERITANCE, config.builtin_current_sid);\r\n\r\n\t\t// revoke everyone access rights\r\n\t\tif (is_openforeveryone)\r\n\t\t\t_app_setexplicitaccess (&ea[count++], REVOKE_ACCESS, 0, NO_INHERITANCE, &SeEveryoneSid);\r\n\r\n\t\t// secure filter from deletion\r\n\t\t_app_setexplicitaccess (\r\n\t\t\t&ea[count++],\r\n\t\t\tis_secure ? DENY_ACCESS : GRANT_ACCESS,\r\n\t\t\tFWPM_ACTRL_WRITE | DELETE | WRITE_DAC | WRITE_OWNER,\r\n\t\t\tis_secure ? CONTAINER_INHERIT_ACE | OBJECT_INHERIT_ACE : NO_INHERITANCE,\r\n\t\t\t&SeEveryoneSid\r\n\t\t);\r\n\r\n\t\tstatus = SetEntriesInAclW (count, ea, acl, &new_dacl);\r\n\r\n\t\tif (status != ERROR_SUCCESS)\r\n\t\t\t_r_log (LOG_LEVEL_ERROR, NULL, L\"SetEntriesInAclW\", status, NULL);\r\n\r\n\t\treturn new_dacl;\r\n\t}\r\n\r\n\treturn NULL;\r\n}\r\n\r\nVOID _app_setexplicitaccess (\r\n\t_Out_ PEXPLICIT_ACCESS ea,\r\n\t_In_ ACCESS_MODE mode,\r\n\t_In_ ULONG rights,\r\n\t_In_ ULONG inheritance,\r\n\t_In_opt_ PSID sid\r\n)\r\n{\r\n\tRtlSecureZeroMemory (ea, sizeof (EXPLICIT_ACCESS));\r\n\r\n\tea->grfAccessMode = mode;\r\n\tea->grfAccessPermissions = rights;\r\n\tea->grfInheritance = inheritance;\r\n\r\n\tBuildTrusteeWithSidW (&(ea->Trustee), sid);\r\n}\r\n\r\nVOID _app_setenginesecurity (\r\n\t_In_ HANDLE hengine\r\n)\r\n{\r\n\tPSECURITY_DESCRIPTOR security_descriptor = NULL;\r\n\tPACCESS_ALLOWED_ACE ace = NULL;\r\n\tEXPLICIT_ACCESS ea[18] = {0};\r\n\tPSID sid_owner = NULL;\r\n\tPSID sid_group = NULL;\r\n\tPACL new_dacl = NULL;\r\n\tPACL dacl = NULL;\r\n\tPACL sacl = NULL;\r\n\tULONG count = 0;\r\n\tBOOLEAN is_currentuserhaverights = FALSE;\r\n\tBOOLEAN is_openforeveryone = FALSE;\r\n\tLONG status;\r\n\r\n\tstatus = FwpmEngineGetSecurityInfo0 (hengine, DACL_SECURITY_INFORMATION, &sid_owner, &sid_group, &dacl, &sacl, &security_descriptor);\r\n\r\n\tif (status != ERROR_SUCCESS)\r\n\t{\r\n\t\t_r_log (LOG_LEVEL_ERROR, NULL, L\"FwpmEngineGetSecurityInfo0\", status, NULL);\r\n\r\n\t\treturn;\r\n\t}\r\n\r\n\tif (dacl)\r\n\t{\r\n\t\tfor (WORD ace_index = 0; ace_index < dacl->AceCount; ace_index++)\r\n\t\t{\r\n\t\t\tstatus = RtlGetAce (dacl, ace_index, (PVOID_PTR)&ace);\r\n\r\n\t\t\tif (!NT_SUCCESS (status))\r\n\t\t\t{\r\n\t\t\t\t_r_log_v (LOG_LEVEL_ERROR, NULL, L\"RtlGetAce\", status, L\"%d\", ace_index);\r\n\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\r\n\t\t\tif (ace->Header.AceType != ACCESS_ALLOWED_ACE_TYPE)\r\n\t\t\t\tcontinue;\r\n\r\n\t\t\t// versions of SW before v3.0.5 added Carte blanche for current user\r\n\t\t\t//\r\n\t\t\t// src: https://github.com/henrypp/simplewall/blob/v.2.3.12/src/main.cpp#L8273\r\n\t\t\t// src: https://github.com/henrypp/simplewall/blob/v.2.3.13/src/main.cpp#L8354\r\n\t\t\t// src: https://github.com/henrypp/simplewall/blob/v.2.4.6/src/main.cpp#L8815\r\n\t\t\t// src: https://github.com/henrypp/simplewall/blob/v.3.0.5/src/wfp.cpp#L96\r\n\t\t\tif (RtlEqualSid (&ace->SidStart, config.builtin_current_sid))\r\n\t\t\t{\r\n\t\t\t\tif (ace->Mask == (FWPM_GENERIC_ALL | DELETE | WRITE_DAC | WRITE_OWNER))\r\n\t\t\t\t\tis_currentuserhaverights = TRUE;\r\n\t\t\t}\r\n\r\n\t\t\t// versions of SW before v3.1.1 added Carte blanche for Everyone\r\n\t\t\t//\r\n\t\t\t// src: https://github.com/henrypp/simplewall/blob/v.2.4.6/src/main.cpp#L8820\r\n\t\t\t// src: https://github.com/henrypp/simplewall/blob/v.3.0.5/src/wfp.cpp#L101\r\n\t\t\t// src: https://github.com/henrypp/simplewall/blob/v.3.1.1/src/wfp.cpp#L137\r\n\t\t\telse if (RtlEqualSid (&ace->SidStart, &SeEveryoneSid))\r\n\t\t\t{\r\n\t\t\t\tif (((ace->Mask & ~(FWPM_ACTRL_CLASSIFY | FWPM_ACTRL_OPEN)) & (FWPM_GENERIC_ALL)) != 0)\r\n\t\t\t\t\tis_openforeveryone = TRUE;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (is_currentuserhaverights || is_openforeveryone)\r\n\t\t{\r\n\t\t\tFwpmEngineSetSecurityInfo0 (hengine, OWNER_SECURITY_INFORMATION, &SeLocalServiceSid, NULL, NULL, NULL);\r\n\r\n\t\t\tFwpmNetEventsSetSecurityInfo0 (hengine, OWNER_SECURITY_INFORMATION, &SeLocalServiceSid, NULL, NULL, NULL);\r\n\r\n\t\t\t// revoke current user access rights\r\n\t\t\tif (is_currentuserhaverights)\r\n\t\t\t{\r\n\t\t\t\tif (config.builtin_current_sid)\r\n\t\t\t\t\t_app_setexplicitaccess (&ea[count++], REVOKE_ACCESS, 0, NO_INHERITANCE, config.builtin_current_sid);\r\n\t\t\t}\r\n\r\n\t\t\t// reset default engine rights\r\n\t\t\tif (is_openforeveryone)\r\n\t\t\t{\r\n\t\t\t\tif (config.builtin_admins_sid)\r\n\t\t\t\t{\r\n\t\t\t\t\t_app_setexplicitaccess (\r\n\t\t\t\t\t\t&ea[count++],\r\n\t\t\t\t\t\tGRANT_ACCESS,\r\n\t\t\t\t\t\tFWPM_GENERIC_ALL | DELETE | WRITE_DAC | WRITE_OWNER, NO_INHERITANCE,\r\n\t\t\t\t\t\tconfig.builtin_admins_sid\r\n\t\t\t\t\t);\r\n\r\n\t\t\t\t\t_app_setexplicitaccess (\r\n\t\t\t\t\t\t&ea[count++],\r\n\t\t\t\t\t\tGRANT_ACCESS,\r\n\t\t\t\t\t\t0x10000000,\r\n\t\t\t\t\t\tOBJECT_INHERIT_ACE | CONTAINER_INHERIT_ACE | INHERIT_ONLY_ACE,\r\n\t\t\t\t\t\tconfig.builtin_admins_sid\r\n\t\t\t\t\t);\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif (config.builtin_netops_sid)\r\n\t\t\t\t{\r\n\t\t\t\t\t_app_setexplicitaccess (\r\n\t\t\t\t\t\t&ea[count++],\r\n\t\t\t\t\t\tGRANT_ACCESS,\r\n\t\t\t\t\t\tFWPM_GENERIC_ALL | DELETE,\r\n\t\t\t\t\t\tNO_INHERITANCE,\r\n\t\t\t\t\t\tconfig.builtin_netops_sid\r\n\t\t\t\t\t);\r\n\r\n\t\t\t\t\t_app_setexplicitaccess (\r\n\t\t\t\t\t\t&ea[count++],\r\n\t\t\t\t\t\tGRANT_ACCESS,\r\n\t\t\t\t\t\t0xE0000000,\r\n\t\t\t\t\t\tOBJECT_INHERIT_ACE | CONTAINER_INHERIT_ACE | INHERIT_ONLY_ACE,\r\n\t\t\t\t\t\tconfig.builtin_netops_sid\r\n\t\t\t\t\t);\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif (config.service_mpssvc_sid)\r\n\t\t\t\t{\r\n\t\t\t\t\t_app_setexplicitaccess (\r\n\t\t\t\t\t\t&ea[count++],\r\n\t\t\t\t\t\tGRANT_ACCESS,\r\n\t\t\t\t\t\tFWPM_GENERIC_ALL | DELETE,\r\n\t\t\t\t\t\tNO_INHERITANCE,\r\n\t\t\t\t\t\tconfig.service_mpssvc_sid->buffer\r\n\t\t\t\t\t);\r\n\r\n\t\t\t\t\t_app_setexplicitaccess (\r\n\t\t\t\t\t\t&ea[count++],\r\n\t\t\t\t\t\tGRANT_ACCESS,\r\n\t\t\t\t\t\t0xE0000000,\r\n\t\t\t\t\t\tOBJECT_INHERIT_ACE | CONTAINER_INHERIT_ACE | INHERIT_ONLY_ACE,\r\n\t\t\t\t\t\tconfig.service_mpssvc_sid->buffer\r\n\t\t\t\t\t);\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif (config.service_nlasvc_sid)\r\n\t\t\t\t{\r\n\t\t\t\t\t_app_setexplicitaccess (\r\n\t\t\t\t\t\t&ea[count++],\r\n\t\t\t\t\t\tGRANT_ACCESS,\r\n\t\t\t\t\t\tFWPM_GENERIC_READ | FWPM_GENERIC_EXECUTE,\r\n\t\t\t\t\t\tNO_INHERITANCE,\r\n\t\t\t\t\t\tconfig.service_nlasvc_sid->buffer\r\n\t\t\t\t\t);\r\n\r\n\t\t\t\t\t_app_setexplicitaccess (\r\n\t\t\t\t\t\t&ea[count++],\r\n\t\t\t\t\t\tGRANT_ACCESS,\r\n\t\t\t\t\t\t0xA0000000,\r\n\t\t\t\t\t\tOBJECT_INHERIT_ACE | CONTAINER_INHERIT_ACE | INHERIT_ONLY_ACE,\r\n\t\t\t\t\t\tconfig.service_nlasvc_sid->buffer\r\n\t\t\t\t\t);\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif (config.service_policyagent_sid)\r\n\t\t\t\t{\r\n\t\t\t\t\t_app_setexplicitaccess (\r\n\t\t\t\t\t\t&ea[count++],\r\n\t\t\t\t\t\tGRANT_ACCESS,\r\n\t\t\t\t\t\tFWPM_GENERIC_ALL | DELETE,\r\n\t\t\t\t\t\tNO_INHERITANCE,\r\n\t\t\t\t\t\tconfig.service_policyagent_sid->buffer\r\n\t\t\t\t\t);\r\n\r\n\t\t\t\t\t_app_setexplicitaccess (\r\n\t\t\t\t\t\t&ea[count++],\r\n\t\t\t\t\t\tGRANT_ACCESS,\r\n\t\t\t\t\t\t0xE0000000,\r\n\t\t\t\t\t\tOBJECT_INHERIT_ACE | CONTAINER_INHERIT_ACE | INHERIT_ONLY_ACE,\r\n\t\t\t\t\t\tconfig.service_policyagent_sid->buffer\r\n\t\t\t\t\t);\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif (config.service_rpcss_sid)\r\n\t\t\t\t{\r\n\t\t\t\t\t_app_setexplicitaccess (\r\n\t\t\t\t\t\t&ea[count++],\r\n\t\t\t\t\t\tGRANT_ACCESS,\r\n\t\t\t\t\t\tFWPM_GENERIC_ALL | DELETE,\r\n\t\t\t\t\t\tNO_INHERITANCE,\r\n\t\t\t\t\t\tconfig.service_rpcss_sid->buffer\r\n\t\t\t\t\t);\r\n\r\n\t\t\t\t\t_app_setexplicitaccess (\r\n\t\t\t\t\t\t&ea[count++],\r\n\t\t\t\t\t\tGRANT_ACCESS,\r\n\t\t\t\t\t\t0xE0000000,\r\n\t\t\t\t\t\tOBJECT_INHERIT_ACE | CONTAINER_INHERIT_ACE | INHERIT_ONLY_ACE,\r\n\t\t\t\t\t\tconfig.service_rpcss_sid->buffer\r\n\t\t\t\t\t);\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif (config.service_wdiservicehost_sid)\r\n\t\t\t\t{\r\n\t\t\t\t\t_app_setexplicitaccess (\r\n\t\t\t\t\t\t&ea[count++],\r\n\t\t\t\t\t\tGRANT_ACCESS,\r\n\t\t\t\t\t\tFWPM_GENERIC_READ | FWPM_GENERIC_EXECUTE,\r\n\t\t\t\t\t\tNO_INHERITANCE,\r\n\t\t\t\t\t\tconfig.service_wdiservicehost_sid->buffer\r\n\t\t\t\t\t);\r\n\r\n\t\t\t\t\t_app_setexplicitaccess (\r\n\t\t\t\t\t\t&ea[count++],\r\n\t\t\t\t\t\tGRANT_ACCESS,\r\n\t\t\t\t\t\t0xA0000000,\r\n\t\t\t\t\t\tOBJECT_INHERIT_ACE | CONTAINER_INHERIT_ACE | INHERIT_ONLY_ACE,\r\n\t\t\t\t\t\tconfig.service_wdiservicehost_sid->buffer\r\n\t\t\t\t\t);\r\n\t\t\t\t}\r\n\r\n\t\t\t\t_app_setexplicitaccess (\r\n\t\t\t\t\t&ea[count++],\r\n\t\t\t\t\tSET_ACCESS,\r\n\t\t\t\t\tFWPM_ACTRL_CLASSIFY | FWPM_ACTRL_OPEN,\r\n\t\t\t\t\tOBJECT_INHERIT_ACE | CONTAINER_INHERIT_ACE,\r\n\t\t\t\t\t&SeEveryoneSid\r\n\t\t\t\t);\r\n\t\t\t}\r\n\r\n\t\t\tstatus = SetEntriesInAclW (count, ea, dacl, &new_dacl);\r\n\r\n\t\t\tif (status != ERROR_SUCCESS)\r\n\t\t\t{\r\n\t\t\t\t_r_log (LOG_LEVEL_ERROR, NULL, L\"SetEntriesInAclW\", status, NULL);\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tstatus = FwpmEngineSetSecurityInfo0 (hengine, DACL_SECURITY_INFORMATION, NULL, NULL, new_dacl, NULL);\r\n\r\n\t\t\t\tif (status != ERROR_SUCCESS)\r\n\t\t\t\t\t_r_log (LOG_LEVEL_ERROR, NULL, L\"FwpmEngineSetSecurityInfo0\", status, NULL);\r\n\r\n\t\t\t\tstatus = FwpmNetEventsSetSecurityInfo0 (hengine, DACL_SECURITY_INFORMATION, NULL, NULL, new_dacl, NULL);\r\n\r\n\t\t\t\tif (status != ERROR_SUCCESS)\r\n\t\t\t\t\t_r_log (LOG_LEVEL_ERROR, NULL, L\"FwpmNetEventsSetSecurityInfo0\", status, NULL);\r\n\r\n\t\t\t\tLocalFree (new_dacl);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tif (security_descriptor)\r\n\t\tFwpmFreeMemory0 ((PVOID_PTR)&security_descriptor);\r\n}\r\n\r\nVOID _app_setprovidersecurity (\r\n\t_In_ HANDLE hengine,\r\n\t_In_ LPCGUID provider_guid,\r\n\t_In_ BOOLEAN is_secure\r\n)\r\n{\r\n\tPSECURITY_DESCRIPTOR security_descriptor;\r\n\tPSID sid_owner;\r\n\tPSID sid_group;\r\n\tPACL dacl;\r\n\tPACL sacl;\r\n\tPACL new_dacl;\r\n\tULONG status;\r\n\r\n\tstatus = FwpmProviderGetSecurityInfoByKey0 (\r\n\t\thengine,\r\n\t\tprovider_guid,\r\n\t\tDACL_SECURITY_INFORMATION,\r\n\t\t&sid_owner,\r\n\t\t&sid_group,\r\n\t\t&dacl,\r\n\t\t&sacl,\r\n\t\t&security_descriptor\r\n\t);\r\n\r\n\tif (status != ERROR_SUCCESS)\r\n\t{\r\n\t\t_r_log (LOG_LEVEL_ERROR, NULL, L\"FwpmProviderGetSecurityInfoByKey0\", status, NULL);\r\n\r\n\t\treturn;\r\n\t}\r\n\r\n\tif (dacl)\r\n\t{\r\n\t\tnew_dacl = _app_createaccesscontrollist (dacl, is_secure);\r\n\r\n\t\tif (new_dacl)\r\n\t\t{\r\n\t\t\tstatus = FwpmProviderSetSecurityInfoByKey0 (\r\n\t\t\t\thengine,\r\n\t\t\t\tprovider_guid,\r\n\t\t\t\tOWNER_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION,\r\n\t\t\t\t(PCSID)config.builtin_admins_sid,\r\n\t\t\t\tNULL,\r\n\t\t\t\tnew_dacl,\r\n\t\t\t\tNULL\r\n\t\t\t);\r\n\r\n\t\t\tif (status != ERROR_SUCCESS)\r\n\t\t\t\t_r_log (LOG_LEVEL_ERROR, NULL, L\"FwpmProviderSetSecurityInfoByKey0\", status, NULL);\r\n\r\n\t\t\tLocalFree (new_dacl);\r\n\t\t}\r\n\t}\r\n\r\n\tif (security_descriptor)\r\n\t\tFwpmFreeMemory0 ((PVOID_PTR)&security_descriptor);\r\n}\r\n\r\nVOID _app_setsublayersecurity (\r\n\t_In_ HANDLE hengine,\r\n\t_In_ LPCGUID sublayer_guid,\r\n\t_In_ BOOLEAN is_secure\r\n)\r\n{\r\n\tPSECURITY_DESCRIPTOR security_descriptor;\r\n\tPSID sid_owner;\r\n\tPSID sid_group;\r\n\tPACL dacl;\r\n\tPACL sacl;\r\n\tPACL new_dacl;\r\n\tULONG status;\r\n\r\n\tstatus = FwpmSubLayerGetSecurityInfoByKey0 (\r\n\t\thengine,\r\n\t\tsublayer_guid,\r\n\t\tDACL_SECURITY_INFORMATION,\r\n\t\t&sid_owner,\r\n\t\t&sid_group,\r\n\t\t&dacl,\r\n\t\t&sacl,\r\n\t\t&security_descriptor\r\n\t);\r\n\r\n\tif (status != ERROR_SUCCESS)\r\n\t{\r\n\t\t_r_log (LOG_LEVEL_ERROR, NULL, L\"FwpmSubLayerGetSecurityInfoByKey0\", status, NULL);\r\n\r\n\t\treturn;\r\n\t}\r\n\r\n\tif (dacl)\r\n\t{\r\n\t\tnew_dacl = _app_createaccesscontrollist (dacl, is_secure);\r\n\r\n\t\tif (new_dacl)\r\n\t\t{\r\n\t\t\tstatus = FwpmSubLayerSetSecurityInfoByKey0 (\r\n\t\t\t\thengine,\r\n\t\t\t\tsublayer_guid,\r\n\t\t\t\tOWNER_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION,\r\n\t\t\t\t(PCSID)config.builtin_admins_sid,\r\n\t\t\t\tNULL,\r\n\t\t\t\tnew_dacl,\r\n\t\t\t\tNULL\r\n\t\t\t);\r\n\r\n\t\t\tif (status != ERROR_SUCCESS)\r\n\t\t\t\t_r_log (LOG_LEVEL_ERROR, NULL, L\"FwpmSubLayerSetSecurityInfoByKey0\", status, NULL);\r\n\r\n\t\t\tLocalFree (new_dacl);\r\n\t\t}\r\n\t}\r\n\r\n\tif (security_descriptor)\r\n\t\tFwpmFreeMemory0 ((PVOID_PTR)&security_descriptor);\r\n}\r\n\r\nVOID _app_setcalloutsecurity (\r\n\t_In_ HANDLE hengine,\r\n\t_In_ LPCGUID callout_guid,\r\n\t_In_ BOOLEAN is_secure\r\n)\r\n{\r\n\tPSECURITY_DESCRIPTOR security_descriptor;\r\n\tPSID sid_owner;\r\n\tPSID sid_group;\r\n\tPACL dacl;\r\n\tPACL sacl;\r\n\tPACL new_dacl;\r\n\tULONG status;\r\n\r\n\tstatus = FwpmCalloutGetSecurityInfoByKey0 (\r\n\t\thengine,\r\n\t\tcallout_guid,\r\n\t\tDACL_SECURITY_INFORMATION,\r\n\t\t&sid_owner,\r\n\t\t&sid_group,\r\n\t\t&dacl,\r\n\t\t&sacl,\r\n\t\t&security_descriptor\r\n\t);\r\n\r\n\tif (status != ERROR_SUCCESS)\r\n\t{\r\n\t\tif (status != FWP_E_CALLOUT_NOT_FOUND)\r\n\t\t\t_r_log (LOG_LEVEL_ERROR, NULL, L\"FwpmCalloutGetSecurityInfoByKey0\", status, NULL);\r\n\r\n\t\treturn;\r\n\t}\r\n\r\n\tif (dacl)\r\n\t{\r\n\t\tnew_dacl = _app_createaccesscontrollist (dacl, is_secure);\r\n\r\n\t\tif (new_dacl)\r\n\t\t{\r\n\t\t\tstatus = FwpmCalloutSetSecurityInfoByKey0 (\r\n\t\t\t\thengine,\r\n\t\t\t\tcallout_guid,\r\n\t\t\t\tOWNER_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION,\r\n\t\t\t\t(PCSID)config.builtin_admins_sid,\r\n\t\t\t\tNULL,\r\n\t\t\t\tnew_dacl,\r\n\t\t\t\tNULL\r\n\t\t\t);\r\n\r\n\t\t\tif (status != ERROR_SUCCESS)\r\n\t\t\t\t_r_log (LOG_LEVEL_ERROR, NULL, L\"FwpmCalloutSetSecurityInfoByKey0\", status, NULL);\r\n\r\n\t\t\tLocalFree (new_dacl);\r\n\t\t}\r\n\t}\r\n\r\n\tif (security_descriptor)\r\n\t\tFwpmFreeMemory0 ((PVOID_PTR)&security_descriptor);\r\n}\r\n\r\nVOID _app_setfiltersecurity (\r\n\t_In_ HANDLE hengine,\r\n\t_In_ LPCGUID filter_guid,\r\n\t_In_ BOOLEAN is_secure,\r\n\t_In_ LPCWSTR file_name,\r\n\t_In_ ULONG line\r\n)\r\n{\r\n\tPSECURITY_DESCRIPTOR security_descriptor;\r\n\tPSID sid_owner;\r\n\tPSID sid_group;\r\n\tPACL dacl;\r\n\tPACL sacl;\r\n\tPACL new_dacl;\r\n\tULONG status;\r\n\r\n\tstatus = FwpmFilterGetSecurityInfoByKey0 (hengine, filter_guid, DACL_SECURITY_INFORMATION, &sid_owner, &sid_group, &dacl, &sacl, &security_descriptor);\r\n\r\n\tif (status == ERROR_SUCCESS)\r\n\t{\r\n\t\tif (dacl)\r\n\t\t{\r\n\t\t\tnew_dacl = _app_createaccesscontrollist (dacl, is_secure);\r\n\r\n\t\t\tif (new_dacl)\r\n\t\t\t{\r\n\t\t\t\tstatus = FwpmFilterSetSecurityInfoByKey0 (hengine, filter_guid, OWNER_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION, (PCSID)config.builtin_admins_sid, NULL, new_dacl, NULL);\r\n\r\n\t\t\t\tif (status != ERROR_SUCCESS)\r\n\t\t\t\t\t_r_log_v (LOG_LEVEL_ERROR, NULL, L\"FwpmFilterSetSecurityInfoByKey0\", status, L\"#%d\", line);\r\n\r\n\t\t\t\tLocalFree (new_dacl);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\telse\r\n\t{\r\n\t\t//if (status != FWP_E_FILTER_NOT_FOUND)\r\n\t\t_r_log_v (LOG_LEVEL_ERROR, NULL, L\"FwpmFilterGetSecurityInfoByKey0\", status, L\"%s:%d\", DBG_ARG_VAR);\r\n\t}\r\n\r\n\tif (security_descriptor)\r\n\t\tFwpmFreeMemory0 ((PVOID_PTR)&security_descriptor);\r\n}\r\n"
  },
  {
    "path": "src/security.h",
    "content": "// simplewall\r\n// Copyright (c) 2020-2026 Henry++\r\n\r\n#pragma once\r\n\r\n_Ret_maybenull_\r\nPSID _app_quyerybuiltinsid (\r\n\t_In_ WELL_KNOWN_SID_TYPE sid_type\r\n);\r\n\r\nVOID _app_generate_credentials ();\r\n\r\n_Ret_maybenull_\r\nPACL _app_createaccesscontrollist (\r\n\t_In_ PACL acl,\r\n\t_In_ BOOLEAN is_secure\r\n);\r\n\r\nVOID _app_setexplicitaccess (\r\n\t_Out_ PEXPLICIT_ACCESS ea,\r\n\t_In_ ACCESS_MODE mode,\r\n\t_In_ ULONG rights,\r\n\t_In_ ULONG inheritance,\r\n\t_In_opt_ PSID sid\r\n);\r\n\r\nVOID _app_setenginesecurity (\r\n\t_In_ HANDLE hengine\r\n);\r\n\r\nVOID _app_setprovidersecurity (\r\n\t_In_ HANDLE hengine,\r\n\t_In_ LPCGUID provider_guid,\r\n\t_In_ BOOLEAN is_secure\r\n);\r\n\r\nVOID _app_setsublayersecurity (\r\n\t_In_ HANDLE hengine,\r\n\t_In_ LPCGUID sublayer_guid,\r\n\t_In_ BOOLEAN is_secure\r\n);\r\n\r\nVOID _app_setcalloutsecurity (\r\n\t_In_ HANDLE hengine,\r\n\t_In_ LPCGUID callout_guid,\r\n\t_In_ BOOLEAN is_secure\r\n);\r\n\r\nVOID _app_setfiltersecurity (\r\n\t_In_ HANDLE hengine,\r\n\t_In_ LPCGUID filter_guid,\r\n\t_In_ BOOLEAN is_secure,\r\n\t_In_ LPCWSTR file_name,\r\n\t_In_ ULONG line\r\n);\r\n"
  },
  {
    "path": "src/timer.c",
    "content": "// simplewall\r\n// Copyright (c) 2016-2024 Henry++\r\n\r\n#include \"global.h\"\r\n\r\nBOOLEAN _app_istimersactive ()\r\n{\r\n\tPITEM_APP ptr_app = NULL;\r\n\tULONG_PTR enum_key = 0;\r\n\r\n\t_r_queuedlock_acquireshared (&lock_apps);\r\n\r\n\twhile (_r_obj_enumhashtablepointer (apps_table, (PVOID_PTR)&ptr_app, NULL, &enum_key))\r\n\t{\r\n\t\tif (_app_istimerset (ptr_app))\r\n\t\t{\r\n\t\t\t_r_queuedlock_releaseshared (&lock_apps);\r\n\r\n\t\t\treturn TRUE;\r\n\t\t}\r\n\t}\r\n\r\n\t_r_queuedlock_releaseshared (&lock_apps);\r\n\r\n\treturn FALSE;\r\n}\r\n\r\nBOOLEAN _app_istimerset (\r\n\t_In_ PITEM_APP ptr_app\r\n)\r\n{\r\n\tif (!ptr_app->htimer)\r\n\t\treturn FALSE;\r\n\r\n\treturn !!IsThreadpoolTimerSet (ptr_app->htimer);\r\n}\r\n\r\nVOID _app_timer_set (\r\n\t_In_opt_ HWND hwnd,\r\n\t_Inout_ PITEM_APP ptr_app,\r\n\t_In_ LONG64 seconds\r\n)\r\n{\r\n\tPTP_TIMER htimer;\r\n\tFILETIME file_time;\r\n\tLARGE_INTEGER li;\r\n\tLONG64 current_time;\r\n\tBOOLEAN is_created = FALSE;\r\n\tNTSTATUS status;\r\n\r\n\tif (seconds <= 0)\r\n\t{\r\n\t\t_app_timer_reset (NULL, ptr_app);\r\n\t}\r\n\telse\r\n\t{\r\n\t\tcurrent_time = _r_unixtime_now ();\r\n\r\n\t\t_r_unixtime_to_filetime (current_time + seconds, &file_time);\r\n\r\n\t\t_r_calc_filetime2largeinteger (&file_time, &li);\r\n\r\n\t\tif (ptr_app->htimer)\r\n\t\t{\r\n\t\t\tTpSetTimer (ptr_app->htimer, &li, 0, 0);\r\n\r\n\t\t\tis_created = TRUE;\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tstatus = TpAllocTimer (&htimer, &_app_timer_callback, ULongToPtr (ptr_app->app_hash), NULL);\r\n\r\n\t\t\tif (NT_SUCCESS (status))\r\n\t\t\t{\r\n\t\t\t\tTpSetTimer (htimer, &li, 0, 0);\r\n\r\n\t\t\t\tptr_app->htimer = htimer;\r\n\r\n\t\t\t\tis_created = TRUE;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (is_created)\r\n\t\t{\r\n\t\t\tptr_app->is_enabled = TRUE;\r\n\t\t\tptr_app->timer = current_time + seconds;\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\t_app_timer_reset (NULL, ptr_app);\r\n\t\t}\r\n\t}\r\n\r\n\tif (hwnd)\r\n\t\t_app_listview_updateitemby_param (hwnd, ptr_app->app_hash, TRUE);\r\n}\r\n\r\nVOID _app_timer_reset (\r\n\t_In_opt_ HWND hwnd,\r\n\t_Inout_ PITEM_APP ptr_app\r\n)\r\n{\r\n\tptr_app->is_enabled = FALSE;\r\n\tptr_app->is_haveerrors = FALSE;\r\n\r\n\tptr_app->timer = 0;\r\n\r\n\tif (_app_istimerset (ptr_app))\r\n\t\t_app_timer_remove (ptr_app);\r\n\r\n\tif (hwnd)\r\n\t\t_app_listview_updateitemby_param (hwnd, ptr_app->app_hash, TRUE);\r\n}\r\n\r\nVOID _app_timer_remove (\r\n\t_Inout_ PITEM_APP ptr_app\r\n)\r\n{\r\n\tPTP_TIMER current_timer;\r\n\r\n\tcurrent_timer = ptr_app->htimer;\r\n\r\n\tptr_app->htimer = NULL;\r\n\r\n\tif (current_timer)\r\n\t\tTpReleaseTimer (current_timer);\r\n}\r\n\r\nVOID CALLBACK _app_timer_callback (\r\n\t_Inout_ PTP_CALLBACK_INSTANCE instance,\r\n\t_Inout_opt_ PVOID context,\r\n\t_Inout_ PTP_TIMER timer\r\n)\r\n{\r\n\tHANDLE hengine;\r\n\tHWND hwnd;\r\n\tPITEM_APP ptr_app;\r\n\tPR_LIST rules;\r\n\tPR_STRING string;\r\n\tWCHAR buffer[256];\r\n\tULONG icon_id;\r\n\tHRESULT status;\r\n\r\n\tptr_app = _app_getappitem (PtrToUlong (context));\r\n\r\n\tif (!ptr_app)\r\n\t\treturn;\r\n\r\n\tstatus = CoInitializeEx (NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);\r\n\r\n\thwnd = _r_app_gethwnd ();\r\n\r\n\t_app_timer_reset (hwnd, ptr_app);\r\n\r\n\thengine = _wfp_getenginehandle ();\r\n\r\n\trules = _r_obj_createlist (2, NULL);\r\n\r\n\t_r_obj_addlistitem (rules, ptr_app, NULL);\r\n\r\n\t_wfp_create3filters (hengine, rules, DBG_ARG, FALSE);\r\n\r\n\t_app_listview_updateby_id (hwnd, ptr_app->type, PR_UPDATE_TYPE | PR_UPDATE_FORCE);\r\n\r\n\t_r_obj_dereference (ptr_app);\r\n\t_r_obj_dereference (rules);\r\n\r\n\t_app_profile_save (hwnd);\r\n\r\n\tif (_r_config_getboolean (L\"IsNotificationsTimer\", TRUE, NULL))\r\n\t{\r\n\t\ticon_id = NIIF_INFO;\r\n\r\n\t\tif (!_r_config_getboolean (L\"IsNotificationsSound\", TRUE, NULL))\r\n\t\t\ticon_id |= NIIF_NOSOUND;\r\n\r\n\t\tstring = _app_getappdisplayname (ptr_app, TRUE);\r\n\r\n\t\t_r_str_printf (\r\n\t\t\tbuffer,\r\n\t\t\tRTL_NUMBER_OF (buffer),\r\n\t\t\tL\"%s - %s\",\r\n\t\t\t_r_app_getname (),\r\n\t\t\t_r_obj_getstringorempty (string)\r\n\t\t);\r\n\r\n\t\t_r_tray_popup (hwnd, &GUID_TrayIcon, icon_id, buffer, _r_locale_getstring (IDS_STATUS_TIMER_DONE));\r\n\r\n\t\tif (string)\r\n\t\t\t_r_obj_dereference (string);\r\n\t}\r\n\r\n\tif (status == S_OK || status == S_FALSE)\r\n\t\tCoUninitialize ();\r\n}\r\n"
  },
  {
    "path": "src/timer.h",
    "content": "// simplewall\r\n// Copyright (c) 2016-2024 Henry++\r\n\r\n#pragma once\r\n\r\nBOOLEAN _app_istimersactive ();\r\n\r\nBOOLEAN _app_istimerset (\r\n\t_In_ PITEM_APP ptr_app\r\n);\r\n\r\nVOID _app_timer_set (\r\n\t_In_opt_ HWND hwnd,\r\n\t_Inout_ PITEM_APP ptr_app,\r\n\t_In_ LONG64 seconds\r\n);\r\n\r\nVOID _app_timer_reset (\r\n\t_In_opt_ HWND hwnd,\r\n\t_Inout_ PITEM_APP ptr_app\r\n);\r\n\r\nVOID _app_timer_remove (\r\n\t_Inout_ PITEM_APP ptr_app\r\n);\r\n\r\nVOID CALLBACK _app_timer_callback (\r\n\t_Inout_ PTP_CALLBACK_INSTANCE instance,\r\n\t_Inout_opt_ PVOID context,\r\n\t_Inout_ PTP_TIMER timer\r\n);\r\n"
  },
  {
    "path": "src/uwp.cpp",
    "content": "// simplewall\n// Copyright (c) 2022-2024 Henry++\n\n#include \"routine.h\"\n\n#include <winrt/windows.foundation.h>\n#include <winrt/windows.foundation.collections.h>\n#include <winrt/windows.applicationmodel.h>\n#include <winrt/windows.management.deployment.h>\n#include <winrt/windows.storage.h>\n#include <winrt/windows.storage.streams.h>\n\n#include \"uwp.h\"\n\n_Success_ (return)\nBOOLEAN _app_uwp_loadpackageinfo (\n\t_In_ PR_STRING package_name,\n\t_Inout_ PR_STRING_PTR name_ptr,\n\t_Inout_ PR_STRING_PTR path_ptr\n)\n{\n\twinrt::Windows::ApplicationModel::Package package = NULL;\n\twinrt::Windows::ApplicationModel::PackageStatus status = 0;\n\twinrt::hstring display_name;\n\twinrt::hstring path;\n\n\tpackage = winrt::Windows::Management::Deployment::PackageManager{}.FindPackage (package_name->buffer);\n\n\tif (!package)\n\t\treturn FALSE;\n\n\tif (_r_sys_isosversiongreaterorequal (WINDOWS_10))\n\t{\n\t\tstatus = package.Status ();\n\n\t\tif (status.Disabled () || status.NotAvailable ())\n\t\t\treturn FALSE;\n\t}\n\n\tdisplay_name = package.DisplayName ();\n\tpath = package.InstalledLocation ().Path ();\n\n\tif (display_name.empty ())\n\t\tdisplay_name = package.Id ().Name ();\n\n\tif (display_name.empty ())\n\t{\n\t\t*name_ptr = _r_obj_createstring2 (&package_name->sr);\n\t}\n\telse\n\t{\n\t\tif (display_name == L\"1527c705-839a-4832-9118-54d4Bd6a0c89\")\n\t\t\tdisplay_name = L\"File Picker\"; // HACK!!!\n\n\t\t*name_ptr = _r_obj_createstring_ex (display_name.c_str (), display_name.size () * sizeof (WCHAR));\n\t}\n\n\tif (!path.empty ())\n\t\t*path_ptr = _r_obj_createstring_ex (path.c_str (), path.size () * sizeof (WCHAR));\n\n\treturn TRUE;\n}\n\n_Success_ (return)\nBOOLEAN _app_uwp_getpackageinfo (\n\t_In_ PR_STRING package_name,\n\t_Out_ PR_STRING_PTR name_ptr,\n\t_Out_ PR_STRING_PTR path_ptr\n)\n{\n\tBOOLEAN status = FALSE;\n\n\t*name_ptr = NULL;\n\t*path_ptr = NULL;\n\n\t__try\n\t{\n\t\tstatus = _app_uwp_loadpackageinfo (package_name, name_ptr, path_ptr);\n\t}\n\t__except (EXCEPTION_EXECUTE_HANDLER)\n\t{\n\t\t*name_ptr = _r_obj_createstring2 (&package_name->sr);\n\n\t\treturn TRUE;\n\t}\n\n\treturn status;\n}\n"
  },
  {
    "path": "src/uwp.h",
    "content": "// simplewall\n// Copyright (c) 2022-2024 Henry++\n\n#pragma once\n\n#ifdef __cplusplus\nextern \"C\"\n{\n#endif\n\n_Success_ (return)\nBOOLEAN _app_uwp_loadpackageinfo (\n\t_In_ PR_STRING package_name,\n\t_Inout_ PR_STRING_PTR name_ptr,\n\t_Inout_ PR_STRING_PTR path_ptr\n);\n\n_Success_ (return)\nBOOLEAN _app_uwp_getpackageinfo (\n\t_In_ PR_STRING package_name,\n\t_Out_ PR_STRING_PTR name_ptr,\n\t_Out_ PR_STRING_PTR path_ptr\n);\n\n#ifdef __cplusplus\n}\n#endif\n"
  },
  {
    "path": "src/wfp.c",
    "content": "// simplewall\r\n// Copyright (c) 2016-2026 Henry++\r\n\r\n#include \"global.h\"\r\n\r\nBOOLEAN _wfp_isfiltersapplying ()\r\n{\r\n\treturn _r_queuedlock_islocked (&lock_apply) || _r_queuedlock_islocked (&lock_transaction);\r\n}\r\n\r\nENUM_INSTALL_TYPE _wfp_isproviderinstalled (\r\n\t_In_ HANDLE engine_handle\r\n)\r\n{\r\n\tFWPM_PROVIDER0 *ptr_provider;\r\n\tENUM_INSTALL_TYPE install_type;\r\n\tULONG status;\r\n\r\n\tstatus = FwpmProviderGetByKey0 (engine_handle, &GUID_WfpProvider, &ptr_provider);\r\n\r\n\tif (status != ERROR_SUCCESS || !ptr_provider)\r\n\t\treturn INSTALL_DISABLED;\r\n\r\n\tif ((ptr_provider->flags & FWPM_PROVIDER_FLAG_DISABLED) == FWPM_PROVIDER_FLAG_DISABLED)\r\n\t{\r\n\t\tinstall_type = INSTALL_DISABLED;\r\n\t}\r\n\telse if ((ptr_provider->flags & FWPM_PROVIDER_FLAG_PERSISTENT) == FWPM_PROVIDER_FLAG_PERSISTENT)\r\n\t{\r\n\t\tinstall_type = INSTALL_ENABLED;\r\n\t}\r\n\telse\r\n\t{\r\n\t\tinstall_type = INSTALL_ENABLED_TEMPORARY;\r\n\t}\r\n\r\n\tFwpmFreeMemory0 ((PVOID_PTR)&ptr_provider);\r\n\r\n\treturn install_type;\r\n}\r\n\r\nENUM_INSTALL_TYPE _wfp_issublayerinstalled (\r\n\t_In_ HANDLE engine_handle\r\n)\r\n{\r\n\tFWPM_SUBLAYER0 *ptr_sublayer;\r\n\tENUM_INSTALL_TYPE install_type;\r\n\tULONG status;\r\n\r\n\tstatus = FwpmSubLayerGetByKey0 (engine_handle, &GUID_WfpSublayer, &ptr_sublayer);\r\n\r\n\tif (status != ERROR_SUCCESS || !ptr_sublayer)\r\n\t\treturn INSTALL_DISABLED;\r\n\r\n\tif ((ptr_sublayer->flags & FWPM_SUBLAYER_FLAG_PERSISTENT) == FWPM_SUBLAYER_FLAG_PERSISTENT)\r\n\t{\r\n\t\tinstall_type = INSTALL_ENABLED;\r\n\t}\r\n\telse\r\n\t{\r\n\t\tinstall_type = INSTALL_ENABLED_TEMPORARY;\r\n\t}\r\n\r\n\tFwpmFreeMemory0 ((PVOID_PTR)&ptr_sublayer);\r\n\r\n\treturn install_type;\r\n}\r\n\r\nBOOLEAN _wfp_isfiltersinstalled ()\r\n{\r\n\tENUM_INSTALL_TYPE install_type;\r\n\r\n\tinstall_type = _wfp_getinstalltype ();\r\n\r\n\treturn (install_type != INSTALL_DISABLED);\r\n}\r\n\r\nHANDLE _wfp_getenginehandle ()\r\n{\r\n\tstatic R_INITONCE init_once = PR_INITONCE_INIT;\r\n\tstatic HANDLE engine_handle = NULL;\r\n\r\n\tFWPM_SESSION0 session;\r\n\tULONG attempts = 6;\r\n\tULONG status;\r\n\r\n\tif (_r_initonce_begin (&init_once))\r\n\t{\r\n\t\t_r_math_generateguid (&config.session_key);\r\n\r\n\t\tdo\r\n\t\t{\r\n\t\t\tRtlZeroMemory (&session, sizeof (FWPM_SESSION0));\r\n\r\n\t\t\tsession.displayData.name = _r_app_getname ();\r\n\t\t\tsession.displayData.description = _r_app_getname ();\r\n\r\n\t\t\tsession.sessionKey = config.session_key;\r\n\r\n\t\t\tsession.txnWaitTimeoutInMSec = TRANSACTION_TIMEOUT;\r\n\r\n\t\t\tstatus = FwpmEngineOpen0 (NULL, RPC_C_AUTHN_WINNT, NULL, &session, &engine_handle);\r\n\r\n\t\t\tif (status == ERROR_SUCCESS)\r\n\t\t\t{\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tif (status == EPT_S_NOT_REGISTERED)\r\n\t\t\t\t{\r\n\t\t\t\t\t// The error say that BFE service is not in the running state, so we wait.\r\n\t\t\t\t\tif (attempts)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t_r_sys_sleep (500);\r\n\r\n\t\t\t\t\t\tattempts -= 1;\r\n\r\n\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\t_r_show_errormessage (_r_app_gethwnd (), L\"WFP engine initialization failed! Try again later.\", status, NULL, ET_WINDOWS);\r\n\r\n\t\t\t\t_r_log (LOG_LEVEL_CRITICAL, NULL, L\"FwpmEngineOpen0\", status, NULL);\r\n\r\n\t\t\t\tNtTerminateProcess (NtCurrentProcess (), status);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t\twhile (--attempts);\r\n\r\n\t\t_r_initonce_end (&init_once);\r\n\t}\r\n\r\n\treturn engine_handle;\r\n}\r\n\r\nENUM_INSTALL_TYPE _wfp_getinstalltype ()\r\n{\r\n\treturn _wfp_isproviderinstalled (_wfp_getenginehandle ());\r\n}\r\n\r\nPR_STRING _wfp_getlayername (\r\n\t_In_ LPGUID layer_guid\r\n)\r\n{\r\n\tLPCGUID layer_guids[] = {\r\n\t\t&FWPM_LAYER_ALE_AUTH_CONNECT_V4,\r\n\t\t&FWPM_LAYER_ALE_AUTH_CONNECT_V6,\r\n\t\t&FWPM_LAYER_ALE_CONNECT_REDIRECT_V4,\r\n\t\t&FWPM_LAYER_ALE_CONNECT_REDIRECT_V6,\r\n\t\t&FWPM_LAYER_ALE_AUTH_RECV_ACCEPT_V4,\r\n\t\t&FWPM_LAYER_ALE_AUTH_RECV_ACCEPT_V6,\r\n\t\t&FWPM_LAYER_ALE_AUTH_LISTEN_V4,\r\n\t\t&FWPM_LAYER_ALE_AUTH_LISTEN_V6,\r\n\t\t&FWPM_LAYER_ALE_RESOURCE_ASSIGNMENT_V4,\r\n\t\t&FWPM_LAYER_ALE_RESOURCE_ASSIGNMENT_V6,\r\n\t\t&FWPM_LAYER_OUTBOUND_TRANSPORT_V4,\r\n\t\t&FWPM_LAYER_OUTBOUND_TRANSPORT_V6,\r\n\t\t&FWPM_LAYER_INBOUND_TRANSPORT_V4,\r\n\t\t&FWPM_LAYER_INBOUND_TRANSPORT_V6,\r\n\t\t&FWPM_LAYER_IPFORWARD_V4,\r\n\t\t&FWPM_LAYER_IPFORWARD_V6,\r\n\t\t&FWPM_LAYER_INBOUND_ICMP_ERROR_V4,\r\n\t\t&FWPM_LAYER_INBOUND_ICMP_ERROR_V6,\r\n\t\t&FWPM_LAYER_OUTBOUND_ICMP_ERROR_V4,\r\n\t\t&FWPM_LAYER_OUTBOUND_ICMP_ERROR_V6,\r\n\t};\r\n\r\n\tR_STRINGREF layer_names[] = {\r\n\t\tPR_STRINGREF_INIT (L\"FWPM_LAYER_ALE_AUTH_CONNECT_V4\"),\r\n\t\tPR_STRINGREF_INIT (L\"FWPM_LAYER_ALE_AUTH_CONNECT_V6\"),\r\n\t\tPR_STRINGREF_INIT (L\"FWPM_LAYER_ALE_CONNECT_REDIRECT_V4\"),\r\n\t\tPR_STRINGREF_INIT (L\"FWPM_LAYER_ALE_CONNECT_REDIRECT_V6\"),\r\n\t\tPR_STRINGREF_INIT (L\"FWPM_LAYER_ALE_AUTH_RECV_ACCEPT_V4\"),\r\n\t\tPR_STRINGREF_INIT (L\"FWPM_LAYER_ALE_AUTH_RECV_ACCEPT_V6\"),\r\n\t\tPR_STRINGREF_INIT (L\"FWPM_LAYER_ALE_AUTH_LISTEN_V4\"),\r\n\t\tPR_STRINGREF_INIT (L\"FWPM_LAYER_ALE_AUTH_LISTEN_V6\"),\r\n\t\tPR_STRINGREF_INIT (L\"FWPM_LAYER_ALE_RESOURCE_ASSIGNMENT_V4\"),\r\n\t\tPR_STRINGREF_INIT (L\"FWPM_LAYER_ALE_RESOURCE_ASSIGNMENT_V6\"),\r\n\t\tPR_STRINGREF_INIT (L\"FWPM_LAYER_OUTBOUND_TRANSPORT_V4\"),\r\n\t\tPR_STRINGREF_INIT (L\"FWPM_LAYER_OUTBOUND_TRANSPORT_V6\"),\r\n\t\tPR_STRINGREF_INIT (L\"FWPM_LAYER_INBOUND_TRANSPORT_V4\"),\r\n\t\tPR_STRINGREF_INIT (L\"FWPM_LAYER_INBOUND_TRANSPORT_V6\"),\r\n\t\tPR_STRINGREF_INIT (L\"FWPM_LAYER_IPFORWARD_V4\"),\r\n\t\tPR_STRINGREF_INIT (L\"FWPM_LAYER_IPFORWARD_V6\"),\r\n\t\tPR_STRINGREF_INIT (L\"FWPM_LAYER_INBOUND_ICMP_ERROR_V4\"),\r\n\t\tPR_STRINGREF_INIT (L\"FWPM_LAYER_INBOUND_ICMP_ERROR_V6\"),\r\n\t\tPR_STRINGREF_INIT (L\"FWPM_LAYER_OUTBOUND_ICMP_ERROR_V4\"),\r\n\t\tPR_STRINGREF_INIT (L\"FWPM_LAYER_OUTBOUND_ICMP_ERROR_V6\"),\r\n\t};\r\n\r\n\tC_ASSERT (RTL_NUMBER_OF (layer_guids) == RTL_NUMBER_OF (layer_names));\r\n\r\n\tPR_STRING string;\r\n\r\n\tfor (ULONG_PTR i = 0; i < RTL_NUMBER_OF (layer_guids); i++)\r\n\t{\r\n\t\tif (IsEqualGUID (layer_guid, layer_guids[i]))\r\n\t\t\treturn _r_obj_createstring2 (&layer_names[i]);\r\n\t}\r\n\r\n\t_r_str_fromguid (layer_guid, TRUE, &string);\r\n\r\n\treturn string;\r\n}\r\n\r\nBOOLEAN _wfp_initialize (\r\n\t_In_opt_ HWND hwnd,\r\n\t_In_ HANDLE engine_handle\r\n)\r\n{\r\n\tFWPM_PROVIDER0 provider;\r\n\tFWPM_SUBLAYER0 sublayer;\r\n\tFWP_VALUE0* fwp_query = NULL;\r\n\tFWP_VALUE0 val;\r\n\tBOOLEAN is_success = TRUE; // already initialized\r\n\tBOOLEAN is_providerexist;\r\n\tBOOLEAN is_sublayerexist;\r\n\tBOOLEAN is_intransact;\r\n\tLONG status;\r\n\r\n\t_r_queuedlock_acquireshared (&lock_transaction);\r\n\r\n\t_app_setenginesecurity (engine_handle);\r\n\r\n\t// install engine provider and it's sublayer\r\n\tis_providerexist = (_wfp_isproviderinstalled (engine_handle) != INSTALL_DISABLED);\r\n\tis_sublayerexist = (_wfp_issublayerinstalled (engine_handle) != INSTALL_DISABLED);\r\n\r\n\tif (!is_providerexist || !is_sublayerexist)\r\n\t{\r\n\t\tis_intransact = _wfp_transact_start (engine_handle, DBG_ARG);\r\n\r\n\t\tif (!is_providerexist)\r\n\t\t{\r\n\t\t\t// create provider\r\n\t\t\tRtlZeroMemory (&provider, sizeof (FWPM_PROVIDER0));\r\n\r\n\t\t\tprovider.displayData.name = _r_app_getname ();\r\n\t\t\tprovider.displayData.description = _r_app_getname ();\r\n\r\n\t\t\tprovider.providerKey = GUID_WfpProvider;\r\n\r\n\t\t\tif (!config.is_filterstemporary)\r\n\t\t\t\tprovider.flags = FWPM_PROVIDER_FLAG_PERSISTENT;\r\n\r\n\t\t\tstatus = FwpmProviderAdd0 (engine_handle, &provider, NULL);\r\n\r\n\t\t\tif (status != ERROR_SUCCESS && status != FWP_E_ALREADY_EXISTS)\r\n\t\t\t{\r\n\t\t\t\tif (is_intransact)\r\n\t\t\t\t{\r\n\t\t\t\t\tFwpmTransactionAbort0 (engine_handle);\r\n\r\n\t\t\t\t\tis_intransact = FALSE;\r\n\t\t\t\t}\r\n\r\n\t\t\t\t_r_log (LOG_LEVEL_ERROR, &GUID_TrayIcon, L\"FwpmProviderAdd0\", status, NULL);\r\n\r\n\t\t\t\tis_success = FALSE;\r\n\r\n\t\t\t\tgoto CleanupExit;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tis_providerexist = TRUE;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (!is_sublayerexist)\r\n\t\t{\r\n\t\t\t// create sublayer\r\n\t\t\tRtlZeroMemory (&sublayer, sizeof (FWPM_SUBLAYER0));\r\n\r\n\t\t\tsublayer.displayData.name = _r_app_getname ();\r\n\t\t\tsublayer.displayData.description = _r_app_getname ();\r\n\r\n\t\t\tsublayer.providerKey = (LPGUID)&GUID_WfpProvider;\r\n\t\t\tsublayer.subLayerKey = GUID_WfpSublayer;\r\n\r\n\t\t\t// highest weight for UINT16\r\n\t\t\tsublayer.weight = (UINT16)_r_config_getlong (L\"SublayerWeight\", FW_SUBLAYER_WEIGHT, NULL);\r\n\r\n\t\t\tif (!config.is_filterstemporary)\r\n\t\t\t\tsublayer.flags = FWPM_SUBLAYER_FLAG_PERSISTENT;\r\n\r\n\t\t\tstatus = FwpmSubLayerAdd0 (engine_handle, &sublayer, NULL);\r\n\r\n\t\t\tif (status != ERROR_SUCCESS && status != FWP_E_ALREADY_EXISTS)\r\n\t\t\t{\r\n\t\t\t\tif (is_intransact)\r\n\t\t\t\t{\r\n\t\t\t\t\tFwpmTransactionAbort0 (engine_handle);\r\n\r\n\t\t\t\t\tis_intransact = FALSE;\r\n\t\t\t\t}\r\n\r\n\t\t\t\t_r_log (LOG_LEVEL_ERROR, &GUID_TrayIcon, L\"FwpmSubLayerAdd0\", status, NULL);\r\n\r\n\t\t\t\tis_success = FALSE;\r\n\r\n\t\t\t\tgoto CleanupExit;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tis_sublayerexist = TRUE;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (is_intransact)\r\n\t\t{\r\n\t\t\tif (!_wfp_transact_commit (engine_handle, DBG_ARG))\r\n\t\t\t\tis_success = FALSE;\r\n\t\t}\r\n\t}\r\n\r\n\t// set provider security information\r\n\t_app_setprovidersecurity (engine_handle, &GUID_WfpProvider, TRUE);\r\n\r\n\t// set sublayer security information\r\n\t_app_setsublayersecurity (engine_handle, &GUID_WfpSublayer, TRUE);\r\n\r\n\t// dropped packets logging (win7+)\r\n\tif (!config.is_neteventset)\r\n\t{\r\n\t\t// query net events state\r\n\t\tconfig.is_neteventenabled = FALSE;\r\n\r\n\t\tstatus = FwpmEngineGetOption0 (engine_handle, FWPM_ENGINE_COLLECT_NET_EVENTS, &fwp_query);\r\n\r\n\t\tif (status == ERROR_SUCCESS && fwp_query)\r\n\t\t{\r\n\t\t\tconfig.is_neteventenabled = (fwp_query->type == FWP_UINT32) && (!!fwp_query->uint32);\r\n\r\n\t\t\tFwpmFreeMemory0 ((PVOID_PTR)&fwp_query);\r\n\t\t}\r\n\r\n\t\t// enable net events (if it is disabled)\r\n\t\tif (config.is_neteventenabled)\r\n\t\t{\r\n\t\t\tconfig.is_neteventset = TRUE;\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tRtlZeroMemory (&val, sizeof (FWP_VALUE0));\r\n\r\n\t\t\tval.type = FWP_UINT32;\r\n\t\t\tval.uint32 = TRUE;\r\n\r\n\t\t\tstatus = FwpmEngineSetOption0 (engine_handle, FWPM_ENGINE_COLLECT_NET_EVENTS, &val);\r\n\r\n\t\t\tif (status != ERROR_SUCCESS)\r\n\t\t\t{\r\n\t\t\t\t_r_log (LOG_LEVEL_ERROR, NULL, L\"FwpmEngineSetOption0\", status, L\"FWPM_ENGINE_COLLECT_NET_EVENTS\");\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tconfig.is_neteventset = TRUE;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (config.is_neteventset)\r\n\t\t{\r\n\t\t\t_wfp_logsetoption (engine_handle);\r\n\r\n\t\t\t_wfp_logsubscribe (hwnd, engine_handle);\r\n\t\t}\r\n\t}\r\n\r\n\t// packet queuing (win8+)\r\n\tif (_r_sys_isosversiongreaterorequal (WINDOWS_8))\r\n\t{\r\n\t\tif (_r_config_getboolean (L\"IsPacketQueuingEnabled\", TRUE, NULL))\r\n\t\t{\r\n\t\t\t// Enables inbound or forward packet queuing independently.\r\n\t\t\t// when enabled, the system is able to evenly distribute cpu load\r\n\t\t\t// to multiple cpus for site-to-site ipsec tunnel scenarios.\r\n\r\n\t\t\tRtlZeroMemory (&val, sizeof (FWP_VALUE0));\r\n\r\n\t\t\tval.type = FWP_UINT32;\r\n\t\t\tval.uint32 = FWPM_ENGINE_OPTION_PACKET_QUEUE_INBOUND | FWPM_ENGINE_OPTION_PACKET_QUEUE_FORWARD;\r\n\r\n\t\t\tstatus = FwpmEngineSetOption0 (engine_handle, FWPM_ENGINE_PACKET_QUEUING, &val);\r\n\r\n\t\t\tif (status != ERROR_SUCCESS)\r\n\t\t\t\t_r_log (LOG_LEVEL_WARNING, NULL, L\"FwpmEngineSetOption0\", status, L\"FWPM_ENGINE_PACKET_QUEUING\");\r\n\t\t}\r\n\t}\r\n\r\nCleanupExit:\r\n\r\n\t_r_queuedlock_releaseshared (&lock_transaction);\r\n\r\n\treturn is_success;\r\n}\r\n\r\nVOID _wfp_uninitialize (\r\n\t_In_ HANDLE engine_handle,\r\n\t_In_ BOOLEAN is_full\r\n)\r\n{\r\n\tPR_ARRAY callouts;\r\n\tPR_STRING string;\r\n\tLPGUID guid;\r\n\tFWP_VALUE0 val;\r\n\tBOOLEAN is_intransact;\r\n\tULONG status;\r\n\r\n\t_r_queuedlock_acquireshared (&lock_transaction);\r\n\r\n\t// dropped packets logging (win7+)\r\n\tif (config.is_neteventset)\r\n\t\t_wfp_logunsubscribe (engine_handle);\r\n\r\n\tif (!config.is_neteventenabled && config.is_neteventset)\r\n\t{\r\n\t\tRtlZeroMemory (&val, sizeof (FWP_VALUE0));\r\n\r\n\t\tval.type = FWP_UINT32;\r\n\t\tval.uint32 = FALSE;\r\n\r\n\t\tstatus = FwpmEngineSetOption0 (engine_handle, FWPM_ENGINE_COLLECT_NET_EVENTS, &val);\r\n\r\n\t\tif (status == ERROR_SUCCESS)\r\n\t\t\tconfig.is_neteventset = FALSE;\r\n\t}\r\n\r\n\tif (is_full)\r\n\t{\r\n\t\t_app_setprovidersecurity (engine_handle, &GUID_WfpProvider, FALSE);\r\n\t\t_app_setsublayersecurity (engine_handle, &GUID_WfpSublayer, FALSE);\r\n\r\n\t\tstatus = _wfp_dumpcallouts (engine_handle, &GUID_WfpProvider, &callouts);\r\n\r\n\t\tif (status == ERROR_SUCCESS && callouts)\r\n\t\t{\r\n\t\t\tfor (ULONG_PTR i = 0; i < _r_obj_getarraysize (callouts); i++)\r\n\t\t\t{\r\n\t\t\t\tguid = (LPGUID)_r_obj_getarrayitem (callouts, i);\r\n\r\n\t\t\t\tif (guid)\r\n\t\t\t\t\t_app_setcalloutsecurity (engine_handle, guid, FALSE);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tis_intransact = _wfp_transact_start (engine_handle, DBG_ARG);\r\n\r\n\t\t// destroy callouts (deprecated)\r\n\t\tif (callouts)\r\n\t\t{\r\n\t\t\tfor (ULONG_PTR i = 0; i < _r_obj_getarraysize (callouts); i++)\r\n\t\t\t{\r\n\t\t\t\tguid = (LPGUID)_r_obj_getarrayitem (callouts, i);\r\n\r\n\t\t\t\tif (!guid)\r\n\t\t\t\t\tcontinue;\r\n\r\n\t\t\t\tstatus = FwpmCalloutDeleteByKey0 (engine_handle, guid);\r\n\r\n\t\t\t\tif (status != ERROR_SUCCESS)\r\n\t\t\t\t{\r\n\t\t\t\t\t_r_str_fromguid (guid, TRUE, &string);\r\n\r\n\t\t\t\t\t_r_log (LOG_LEVEL_ERROR, &GUID_TrayIcon, L\"FwpmCalloutDeleteByKey0\", status, _r_obj_getstring (string));\r\n\r\n\t\t\t\t\tif (string)\r\n\t\t\t\t\t\t_r_obj_dereference (string);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// destroy sublayer\r\n\t\tstatus = FwpmSubLayerDeleteByKey0 (engine_handle, &GUID_WfpSublayer);\r\n\r\n\t\tif (status != ERROR_SUCCESS && status != FWP_E_SUBLAYER_NOT_FOUND)\r\n\t\t\t_r_log (LOG_LEVEL_ERROR, &GUID_TrayIcon, L\"FwpmSubLayerDeleteByKey0\", status, NULL);\r\n\r\n\t\t// destroy provider\r\n\t\tstatus = FwpmProviderDeleteByKey0 (engine_handle, &GUID_WfpProvider);\r\n\r\n\t\tif (status != ERROR_SUCCESS && status != FWP_E_PROVIDER_NOT_FOUND)\r\n\t\t\t_r_log (LOG_LEVEL_ERROR, &GUID_TrayIcon, L\"FwpmProviderDeleteByKey0\", status, NULL);\r\n\r\n\t\tif (is_intransact)\r\n\t\t\t_wfp_transact_commit (engine_handle, DBG_ARG);\r\n\r\n\t\tif (callouts)\r\n\t\t\t_r_obj_dereference (callouts);\r\n\t}\r\n\r\n\t_r_queuedlock_releaseshared (&lock_transaction);\r\n}\r\n\r\nVOID _wfp_installfilters (\r\n\t_In_ HANDLE engine_handle\r\n)\r\n{\r\n\t// dump all filters into array\r\n\tPR_ARRAY guids;\r\n\tPR_LIST rules;\r\n\tLPGUID guid;\r\n\tPITEM_APP ptr_app = NULL;\r\n\tPITEM_RULE ptr_rule;\r\n\tULONG_PTR enum_key = 0;\r\n\tBOOLEAN is_intransact;\r\n\tULONG status;\r\n\r\n\t// set security information\r\n\t_app_setprovidersecurity (engine_handle, &GUID_WfpProvider, FALSE);\r\n\t_app_setsublayersecurity (engine_handle, &GUID_WfpSublayer, FALSE);\r\n\r\n\t_wfp_clearfilter_ids ();\r\n\r\n\t_r_queuedlock_acquireshared (&lock_transaction);\r\n\r\n\tstatus = _wfp_dumpfilters (engine_handle, &GUID_WfpProvider, &guids);\r\n\r\n\t// restore filters security\r\n\tif (status == ERROR_SUCCESS)\r\n\t{\r\n\t\tfor (ULONG_PTR i = 0; i < _r_obj_getarraysize (guids); i++)\r\n\t\t{\r\n\t\t\tguid = (LPGUID)_r_obj_getarrayitem (guids, i);\r\n\r\n\t\t\tif (guid)\r\n\t\t\t\t_app_setfiltersecurity (engine_handle, guid, FALSE, DBG_ARG);\r\n\t\t}\r\n\t}\r\n\r\n\tis_intransact = _wfp_transact_start (engine_handle, DBG_ARG);\r\n\r\n\t// destroy all filters\r\n\tif (status == ERROR_SUCCESS)\r\n\t{\r\n\t\tfor (ULONG_PTR i = 0; i < _r_obj_getarraysize (guids); i++)\r\n\t\t{\r\n\t\t\tguid = (LPGUID)_r_obj_getarrayitem (guids, i);\r\n\r\n\t\t\tif (guid)\r\n\t\t\t\t_wfp_deletefilter (engine_handle, guid);\r\n\t\t}\r\n\r\n\t\t_r_obj_dereference (guids);\r\n\t}\r\n\r\n\trules = _r_obj_createlist (10, &_r_obj_dereference);\r\n\r\n\t// apply apps rules\r\n\t_r_queuedlock_acquireshared (&lock_apps);\r\n\r\n\twhile (_r_obj_enumhashtablepointer (apps_table, (PVOID_PTR)&ptr_app, NULL, &enum_key))\r\n\t{\r\n\t\tif (ptr_app->is_enabled)\r\n\t\t\t_r_obj_addlistitem (rules, _r_obj_reference (ptr_app), NULL);\r\n\t}\r\n\r\n\t_r_queuedlock_releaseshared (&lock_apps);\r\n\r\n\tif (!_r_obj_isempty2 (rules))\r\n\t{\r\n\t\t_wfp_create3filters (engine_handle, rules, DBG_ARG, is_intransact);\r\n\r\n\t\t_r_obj_clearlist (rules);\r\n\t}\r\n\r\n\t// apply blocklist/system/user rules\r\n\t_r_queuedlock_acquireshared (&lock_rules);\r\n\r\n\tfor (ULONG_PTR i = 0; i < _r_obj_getlistsize (rules_list); i++)\r\n\t{\r\n\t\tptr_rule = _r_obj_getlistitem (rules_list, i);\r\n\r\n\t\tif (ptr_rule)\r\n\t\t{\r\n\t\t\tif (ptr_rule->is_enabled)\r\n\t\t\t\t_r_obj_addlistitem (rules, _r_obj_reference (ptr_rule), NULL);\r\n\t\t}\r\n\t}\r\n\r\n\t_r_queuedlock_releaseshared (&lock_rules);\r\n\r\n\tif (!_r_obj_isempty2 (rules))\r\n\t{\r\n\t\t_wfp_create4filters (engine_handle, rules, DBG_ARG, is_intransact);\r\n\r\n\t\t_r_obj_clearlist (rules);\r\n\t}\r\n\r\n\t// apply internal rules\r\n\t_wfp_create2filters (engine_handle, DBG_ARG, is_intransact);\r\n\r\n\tif (is_intransact)\r\n\t\t_wfp_transact_commit (engine_handle, DBG_ARG);\r\n\r\n\t// secure filters\r\n\tstatus = _wfp_dumpfilters (engine_handle, &GUID_WfpProvider, &guids);\r\n\r\n\tif (status == ERROR_SUCCESS)\r\n\t{\r\n\t\tfor (ULONG_PTR i = 0; i < _r_obj_getarraysize (guids); i++)\r\n\t\t{\r\n\t\t\tguid = (LPGUID)_r_obj_getarrayitem (guids, i);\r\n\r\n\t\t\tif (guid)\r\n\t\t\t\t_app_setfiltersecurity (engine_handle, guid, TRUE, DBG_ARG);\r\n\t\t}\r\n\r\n\t\t_r_obj_dereference (guids);\r\n\t}\r\n\r\n\t_app_setprovidersecurity (engine_handle, &GUID_WfpProvider, TRUE);\r\n\t_app_setsublayersecurity (engine_handle, &GUID_WfpSublayer, TRUE);\r\n\r\n\t_r_queuedlock_releaseshared (&lock_transaction);\r\n\r\n\t_r_obj_dereference (rules);\r\n}\r\n\r\nBOOLEAN _wfp_transact_start (\r\n\t_In_ HANDLE engine_handle,\r\n\t_In_ LPCWSTR file_name,\r\n\t_In_ ULONG line\r\n)\r\n{\r\n\tULONG status;\r\n\r\n\tstatus = FwpmTransactionBegin0 (engine_handle, 0);\r\n\r\n\tif (status == FWP_E_TXN_IN_PROGRESS)\r\n\t\treturn FALSE;\r\n\r\n\tif (status != ERROR_SUCCESS)\r\n\t{\r\n\t\t_r_log_v (LOG_LEVEL_ERROR, &GUID_TrayIcon, L\"FwpmTransactionBegin0\", status, L\"%s:%d\", DBG_ARG_VAR);\r\n\r\n\t\treturn FALSE;\r\n\t}\r\n\r\n\treturn TRUE;\r\n}\r\n\r\nBOOLEAN _wfp_transact_commit (\r\n\t_In_ HANDLE engine_handle,\r\n\t_In_ LPCWSTR file_name,\r\n\t_In_ ULONG line\r\n)\r\n{\r\n\tULONG status;\r\n\r\n\tstatus = FwpmTransactionCommit0 (engine_handle);\r\n\r\n\tif (status != ERROR_SUCCESS)\r\n\t{\r\n\t\t_r_log_v (LOG_LEVEL_ERROR, &GUID_TrayIcon, L\"FwpmTransactionCommit0\", status, L\"%s:%d\", DBG_ARG_VAR);\r\n\r\n\t\tFwpmTransactionAbort0 (engine_handle);\r\n\r\n\t\treturn FALSE;\r\n\t}\r\n\r\n\treturn TRUE;\r\n}\r\n\r\nBOOLEAN _wfp_deletefilter (\r\n\t_In_ HANDLE engine_handle,\r\n\t_In_ LPGUID filter_id\r\n)\r\n{\r\n\tPR_STRING string;\r\n\tULONG status;\r\n\r\n\tstatus = FwpmFilterDeleteByKey0 (engine_handle, filter_id);\r\n\r\n\tif (status != ERROR_SUCCESS && status != FWP_E_FILTER_NOT_FOUND)\r\n\t{\r\n\t\t_r_str_fromguid (filter_id, TRUE, &string);\r\n\r\n\t\t_r_log (LOG_LEVEL_ERROR, &GUID_TrayIcon, L\"FwpmFilterDeleteByKey0\", status, _r_obj_getstringordefault (string, L\"<no data>\"));\r\n\r\n\t\tif (string)\r\n\t\t\t_r_obj_dereference (string);\r\n\r\n\t\treturn FALSE;\r\n\t}\r\n\r\n\treturn TRUE;\r\n}\r\n\r\nFORCEINLINE LPCWSTR _wfp_filtertypetostring (\r\n\t_In_ ENUM_TYPE_DATA filter_type\r\n)\r\n{\r\n\tswitch (filter_type)\r\n\t{\r\n\t\tcase DATA_APP_REGULAR:\r\n\t\tcase DATA_APP_DEVICE:\r\n\t\tcase DATA_APP_NETWORK:\r\n\t\tcase DATA_APP_PICO:\r\n\t\tcase DATA_APP_SERVICE:\r\n\t\tcase DATA_APP_UWP:\r\n\t\t{\r\n\t\t\treturn L\"App\";\r\n\t\t}\r\n\r\n\t\tcase DATA_RULE_BLOCKLIST:\r\n\t\t{\r\n\t\t\treturn L\"Blocklist\";\r\n\t\t}\r\n\r\n\t\tcase DATA_RULE_SYSTEM:\r\n\t\t{\r\n\t\t\treturn L\"System rule\";\r\n\t\t}\r\n\r\n\t\tcase DATA_RULE_SYSTEM_USER:\r\n\t\tcase DATA_RULE_USER:\r\n\t\t{\r\n\t\t\treturn L\"User rule\";\r\n\t\t}\r\n\r\n\t\tcase DATA_FILTER_GENERAL:\r\n\t\t{\r\n\t\t\treturn L\"Internal\";\r\n\t\t}\r\n\r\n\t\tdefault:\r\n\t\t{\r\n\t\t\tFALLTHROUGH;\r\n\t\t}\r\n\t}\r\n\r\n\treturn NULL;\r\n}\r\n\r\nULONG _wfp_createcallout (\r\n\t_In_ HANDLE engine_handle,\r\n\t_In_ LPCGUID layer_key,\r\n\t_In_ LPCGUID callout_key\r\n)\r\n{\r\n\tFWPM_CALLOUT0 callout = {0};\r\n\tULONG status;\r\n\r\n\tcallout.displayData.name = _r_app_getname ();\r\n\tcallout.displayData.description = _r_app_getname ();\r\n\r\n\tif (!config.is_filterstemporary)\r\n\t\tcallout.flags = FWPM_CALLOUT_FLAG_PERSISTENT;\r\n\r\n\tcallout.providerKey = (LPGUID)&GUID_WfpProvider;\r\n\r\n\tRtlCopyMemory (&callout.calloutKey, callout_key, sizeof (GUID));\r\n\tRtlCopyMemory (&callout.applicableLayer, layer_key, sizeof (GUID));\r\n\r\n\tstatus = FwpmCalloutAdd0 (engine_handle, &callout, NULL, NULL);\r\n\r\n\tif (status != ERROR_SUCCESS && status != FWP_E_ALREADY_EXISTS)\r\n\t\t_r_log (LOG_LEVEL_ERROR, &GUID_TrayIcon, L\"FwpmCalloutAdd0\", status, NULL);\r\n\r\n\treturn status;\r\n}\r\n\r\nULONG _wfp_createfilter (\r\n\t_In_ HANDLE engine_handle,\r\n\t_In_ ENUM_TYPE_DATA type,\r\n\t_In_opt_ LPCWSTR filter_name,\r\n\t_In_reads_ (count) FWPM_FILTER_CONDITION0 *lpcond,\r\n\t_In_ UINT32 count,\r\n\t_In_ LPCGUID layer_id,\r\n\t_In_opt_ LPCGUID callout_id,\r\n\t_In_ UINT8 weight,\r\n\t_In_ FWP_ACTION_TYPE action,\r\n\t_In_ UINT32 flags,\r\n\t_Inout_opt_ PR_ARRAY guids\r\n)\r\n{\r\n\tFWPM_FILTER0 filter = {0};\r\n\tWCHAR filter_description[128];\r\n\tPR_STRING layer_name;\r\n\tLPCWSTR filter_type;\r\n\tUINT64 filter_id;\r\n\tULONG status;\r\n\r\n\t// create filter guid\r\n\t_r_math_generateguid (&filter.filterKey);\r\n\r\n\tfilter_type = _wfp_filtertypetostring (type);\r\n\r\n\tif (filter_type && filter_name)\r\n\t{\r\n\t\t_r_str_printf (filter_description, RTL_NUMBER_OF (filter_description), L\"%s\\\\%s\", filter_type, filter_name);\r\n\t}\r\n\telse if (filter_name)\r\n\t{\r\n\t\t_r_str_copy (filter_description, RTL_NUMBER_OF (filter_description), filter_name);\r\n\t}\r\n\telse\r\n\t{\r\n\t\t_r_str_copy (filter_description, RTL_NUMBER_OF (filter_description), _r_locale_getstring (IDS_STATUS_EMPTY));\r\n\t}\r\n\r\n\t// reset action rights\r\n\tif (weight == FW_WEIGHT_HIGHEST_IMPORTANT || action == FWP_ACTION_BLOCK || action == FWP_ACTION_CALLOUT_TERMINATING)\r\n\t\tfilter.flags = FWPM_FILTER_FLAG_CLEAR_ACTION_RIGHT;\r\n\r\n\t// set filter flags\r\n\tif ((flags & FWPM_FILTER_FLAG_BOOTTIME) == 0)\r\n\t{\r\n\t\tif (!config.is_filterstemporary)\r\n\t\t\tfilter.flags |= FWPM_FILTER_FLAG_PERSISTENT;\r\n\r\n\t\t// filter is indexed to help enable faster lookup during classification (win8+)\r\n\t\tif (_r_sys_isosversiongreaterorequal (WINDOWS_8))\r\n\t\t\tfilter.flags |= FWPM_FILTER_FLAG_INDEXED;\r\n\t}\r\n\r\n\tif (flags)\r\n\t\tfilter.flags |= flags;\r\n\r\n\tfilter.displayData.name = _r_app_getname ();\r\n\tfilter.displayData.description = filter_description;\r\n\r\n\tRtlCopyMemory (&filter.subLayerKey, &GUID_WfpSublayer, sizeof (GUID));\r\n\tRtlCopyMemory (&filter.layerKey, layer_id, sizeof (GUID));\r\n\r\n\tif (callout_id)\r\n\t\tRtlCopyMemory (&filter.action.calloutKey, callout_id, sizeof (GUID));\r\n\r\n\tfilter.providerKey = (LPGUID)&GUID_WfpProvider;\r\n\tfilter.weight.type = FWP_UINT8;\r\n\tfilter.weight.uint8 = weight;\r\n\tfilter.action.type = action;\r\n\r\n\tif (count)\r\n\t{\r\n\t\tfilter.numFilterConditions = count;\r\n\t\tfilter.filterCondition = lpcond;\r\n\t}\r\n\r\n\tstatus = FwpmFilterAdd0 (engine_handle, &filter, NULL, &filter_id);\r\n\r\n\tif (status == ERROR_SUCCESS)\r\n\t{\r\n\t\tif (guids)\r\n\t\t\t_r_obj_addarrayitem (guids, &filter.filterKey, NULL);\r\n\t}\r\n\telse\r\n\t{\r\n\t\tlayer_name = _wfp_getlayername ((LPGUID)layer_id);\r\n\r\n\t\t_r_log_v (LOG_LEVEL_ERROR, &GUID_TrayIcon, L\"FwpmFilterAdd0\", status, L\"%s\\\\%s\", _r_obj_getstring (layer_name), filter.displayData.description);\r\n\r\n\t\tif (layer_name)\r\n\t\t\t_r_obj_dereference (layer_name);\r\n\t}\r\n\r\n\treturn status;\r\n}\r\n\r\nVOID _wfp_clearfilter_ids ()\r\n{\r\n\tPITEM_APP ptr_app = NULL;\r\n\tPITEM_RULE ptr_rule;\r\n\tULONG_PTR enum_key = 0;\r\n\r\n\t// clear common filters\r\n\t_r_obj_cleararray (filter_ids);\r\n\r\n\t// clear apps filters\r\n\t_r_queuedlock_acquireshared (&lock_apps);\r\n\r\n\twhile (_r_obj_enumhashtablepointer (apps_table, (PVOID_PTR)&ptr_app, NULL, &enum_key))\r\n\t{\r\n\t\tptr_app->is_haveerrors = FALSE;\r\n\r\n\t\tif (ptr_app->guids)\r\n\t\t\t_r_obj_cleararray (ptr_app->guids);\r\n\t}\r\n\r\n\t_r_queuedlock_releaseshared (&lock_apps);\r\n\r\n\t// clear rules filters\r\n\t_r_queuedlock_acquireshared (&lock_rules);\r\n\r\n\tfor (ULONG_PTR i = 0; i < _r_obj_getlistsize (rules_list); i++)\r\n\t{\r\n\t\tptr_rule = _r_obj_getlistitem (rules_list, i);\r\n\r\n\t\tif (!ptr_rule)\r\n\t\t\tcontinue;\r\n\r\n\t\tptr_rule->is_haveerrors = FALSE;\r\n\r\n\t\t_r_obj_cleararray (ptr_rule->guids);\r\n\t}\r\n\r\n\t_r_queuedlock_releaseshared (&lock_rules);\r\n}\r\n\r\nVOID _wfp_destroyfilters (\r\n\t_In_ HANDLE engine_handle\r\n)\r\n{\r\n\tPR_ARRAY guids;\r\n\tULONG status;\r\n\r\n\t_wfp_clearfilter_ids ();\r\n\r\n\t// destroy all filters\r\n\t_r_queuedlock_acquireshared (&lock_transaction);\r\n\r\n\tstatus = _wfp_dumpfilters (engine_handle, &GUID_WfpProvider, &guids);\r\n\r\n\t_r_queuedlock_releaseshared (&lock_transaction);\r\n\r\n\tif (status != ERROR_SUCCESS)\r\n\t\treturn;\r\n\r\n\t_wfp_destroyfilters_array (engine_handle, guids, DBG_ARG);\r\n\r\n\t_r_obj_dereference (guids);\r\n}\r\n\r\nVOID _wfp_destroyfilters_array (\r\n\t_In_ HANDLE engine_handle,\r\n\t_In_ PR_ARRAY guids,\r\n\t_In_ LPCWSTR file_name,\r\n\t_In_ ULONG line\r\n)\r\n{\r\n\tLPGUID guid;\r\n\tBOOLEAN is_enabled;\r\n\tBOOLEAN is_intransact;\r\n\r\n\tis_enabled = _app_initinterfacestate (_r_app_gethwnd (), FALSE);\r\n\r\n\t_r_queuedlock_acquireshared (&lock_transaction);\r\n\r\n\tfor (ULONG_PTR i = 0; i < _r_obj_getarraysize (guids); i++)\r\n\t{\r\n\t\tguid = (LPGUID)_r_obj_getarrayitem (guids, i);\r\n\r\n\t\tif (guid)\r\n\t\t\t_app_setfiltersecurity (engine_handle, guid, FALSE, DBG_ARG_VAR);\r\n\t}\r\n\r\n\tis_intransact = _wfp_transact_start (engine_handle, DBG_ARG_VAR);\r\n\r\n\tfor (ULONG_PTR i = 0; i < _r_obj_getarraysize (guids); i++)\r\n\t{\r\n\t\tguid = (LPGUID)_r_obj_getarrayitem (guids, i);\r\n\r\n\t\tif (guid)\r\n\t\t\t_wfp_deletefilter (engine_handle, guid);\r\n\t}\r\n\r\n\tif (is_intransact)\r\n\t\t_wfp_transact_commit (engine_handle, DBG_ARG_VAR);\r\n\r\n\t_r_queuedlock_releaseshared (&lock_transaction);\r\n\r\n\t_app_restoreinterfacestate (_r_app_gethwnd (), is_enabled);\r\n}\r\n\r\nBOOLEAN _wfp_createrulefilter (\r\n\t_In_ HANDLE engine_handle,\r\n\t_In_ ENUM_TYPE_DATA filter_type,\r\n\t_In_opt_ LPCWSTR filter_name,\r\n\t_In_opt_ ULONG app_hash,\r\n\t_In_opt_ PITEM_FILTER_CONFIG filter_config,\r\n\t_In_opt_ PR_STRINGREF rule_remote,\r\n\t_In_opt_ PR_STRINGREF rule_local,\r\n\t_In_ UINT8 weight,\r\n\t_In_ FWP_ACTION_TYPE action,\r\n\t_In_ UINT32 flags,\r\n\t_Inout_opt_ PR_ARRAY guids\r\n)\r\n{\r\n\tFWPM_FILTER_CONDITION0 fwfc[8] = {0};\r\n\tUINT32 count = 0;\r\n\tITEM_ADDRESS address;\r\n\tFWP_V4_ADDR_AND_MASK fwp_addr4_and_mask1;\r\n\tFWP_V4_ADDR_AND_MASK fwp_addr4_and_mask2;\r\n\tFWP_V6_ADDR_AND_MASK fwp_addr6_and_mask1;\r\n\tFWP_V6_ADDR_AND_MASK fwp_addr6_and_mask2;\r\n\tFWP_RANGE0 fwp_range1;\r\n\tFWP_RANGE0 fwp_range2;\r\n\tFWP_BYTE_BLOB *byte_blob = NULL;\r\n\tPITEM_APP ptr_app = NULL;\r\n\tFWP_DIRECTION direction;\r\n\tUINT8 protocol;\r\n\tADDRESS_FAMILY af;\r\n\tPR_STRINGREF rules[] = {\r\n\t\trule_remote,\r\n\t\trule_local\r\n\t};\r\n\t//BOOLEAN is_remoteaddr_set = FALSE;\r\n\t//BOOLEAN is_remoteport_set = FALSE;\r\n\tBOOLEAN is_success = FALSE;\r\n\tNTSTATUS status;\r\n\r\n\tif (filter_config)\r\n\t{\r\n\t\tdirection = filter_config->direction;\r\n\t\tprotocol = filter_config->protocol;\r\n\t\taf = filter_config->af;\r\n\t}\r\n\telse\r\n\t{\r\n\t\tdirection = FWP_DIRECTION_MAX;\r\n\t\tprotocol = 0;\r\n\t\taf = AF_UNSPEC;\r\n\t}\r\n\r\n\t// set path condition\r\n\tif (app_hash)\r\n\t{\r\n\t\tptr_app = _app_getappitem (app_hash);\r\n\r\n\t\tif (!ptr_app)\r\n\t\t{\r\n\t\t\t_r_log_v (LOG_LEVEL_WARNING, NULL, TEXT (__FUNCTION__), 0, L\"App \\\"%\" TEXT (PR_ULONG) L\"\\\" was not found!\", app_hash);\r\n\r\n\t\t\tgoto CleanupExit;\r\n\t\t}\r\n\r\n\t\tif (ptr_app->type == DATA_APP_SERVICE) // windows service\r\n\t\t{\r\n\t\t\tif (ptr_app->bytes)\r\n\t\t\t{\r\n\t\t\t\tByteBlobAlloc (ptr_app->bytes->buffer, RtlLengthSecurityDescriptor (ptr_app->bytes->buffer), (PVOID_PTR)&byte_blob);\r\n\r\n\t\t\t\tfwfc[count].fieldKey = FWPM_CONDITION_ALE_USER_ID;\r\n\t\t\t\tfwfc[count].matchType = FWP_MATCH_EQUAL;\r\n\t\t\t\tfwfc[count].conditionValue.type = FWP_SECURITY_DESCRIPTOR_TYPE;\r\n\t\t\t\tfwfc[count].conditionValue.sd = byte_blob;\r\n\r\n\t\t\t\tcount += 1;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\t_r_log (LOG_LEVEL_ERROR, NULL, TEXT (__FUNCTION__), 0, _r_obj_getstring (ptr_app->original_path));\r\n\r\n\t\t\t\tgoto CleanupExit;\r\n\t\t\t}\r\n\t\t}\r\n\t\telse if (ptr_app->type == DATA_APP_UWP) // uwp app (win8+)\r\n\t\t{\r\n\t\t\tif (ptr_app->bytes)\r\n\t\t\t{\r\n\t\t\t\tfwfc[count].fieldKey = FWPM_CONDITION_ALE_PACKAGE_ID;\r\n\t\t\t\tfwfc[count].matchType = FWP_MATCH_EQUAL;\r\n\t\t\t\tfwfc[count].conditionValue.type = FWP_SID;\r\n\t\t\t\tfwfc[count].conditionValue.sid = (PSID)ptr_app->bytes->buffer;\r\n\r\n\t\t\t\tcount += 1;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\t_r_log (LOG_LEVEL_ERROR, NULL, TEXT (__FUNCTION__), 0, _r_obj_getstring (ptr_app->original_path));\r\n\r\n\t\t\t\tgoto CleanupExit;\r\n\t\t\t}\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tstatus = _FwpmGetAppIdFromFileName1 (ptr_app->original_path, ptr_app->type, (PVOID_PTR)&byte_blob);\r\n\r\n\t\t\tif (NT_SUCCESS (status))\r\n\t\t\t{\r\n\t\t\t\tfwfc[count].fieldKey = FWPM_CONDITION_ALE_APP_ID;\r\n\t\t\t\tfwfc[count].matchType = FWP_MATCH_EQUAL;\r\n\t\t\t\tfwfc[count].conditionValue.type = FWP_BYTE_BLOB_TYPE;\r\n\t\t\t\tfwfc[count].conditionValue.byteBlob = byte_blob;\r\n\r\n\t\t\t\tcount += 1;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\t// do not log file not found to error log\r\n\t\t\t\tif (status != STATUS_OBJECT_NAME_NOT_FOUND && status != STATUS_OBJECT_PATH_NOT_FOUND)\r\n\t\t\t\t\t_r_log (LOG_LEVEL_ERROR, NULL, L\"FwpmGetAppIdFromFileName\", status, _r_obj_getstring (ptr_app->original_path));\r\n\r\n\t\t\t\tgoto CleanupExit;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t// set ip/port condition\r\n\tfor (ULONG_PTR i = 0; i < RTL_NUMBER_OF (rules); i++)\r\n\t{\r\n\t\tif (_r_obj_isstringempty (rules[i]))\r\n\t\t\tcontinue;\r\n\r\n\t\tif (!_app_parserulestring (rules[i], &address))\r\n\t\t\tgoto CleanupExit;\r\n\r\n\t\tif (i == 0)\r\n\t\t{\r\n\t\t\tif (address.type == DATA_TYPE_PORT)\r\n\t\t\t{\r\n\t\t\t\t//is_remoteport_set = TRUE;\r\n\t\t\t}\r\n\t\t\telse if (address.type == DATA_TYPE_IP)\r\n\t\t\t{\r\n\t\t\t\t//is_remoteaddr_set = TRUE;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (address.is_range)\r\n\t\t{\r\n\t\t\tif (address.type == DATA_TYPE_IP)\r\n\t\t\t{\r\n\t\t\t\tif (address.format == NET_ADDRESS_IPV4)\r\n\t\t\t\t{\r\n\t\t\t\t\taf = AF_INET;\r\n\t\t\t\t}\r\n\t\t\t\telse if (address.format == NET_ADDRESS_IPV6)\r\n\t\t\t\t{\r\n\t\t\t\t\taf = AF_INET6;\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\tgoto CleanupExit;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tif (address.type == DATA_TYPE_PORT)\r\n\t\t\t{\r\n\t\t\t\tif (i == 0)\r\n\t\t\t\t{\r\n\t\t\t\t\tfwfc[count].fieldKey = FWPM_CONDITION_IP_REMOTE_PORT;\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\tfwfc[count].fieldKey = FWPM_CONDITION_IP_LOCAL_PORT;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tif (i == 0)\r\n\t\t\t\t{\r\n\t\t\t\t\tfwfc[count].fieldKey = FWPM_CONDITION_IP_REMOTE_ADDRESS;\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\tfwfc[count].fieldKey = FWPM_CONDITION_IP_LOCAL_ADDRESS;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tfwfc[count].matchType = FWP_MATCH_RANGE;\r\n\t\t\tfwfc[count].conditionValue.type = FWP_RANGE_TYPE;\r\n\r\n\t\t\tif (i == 0)\r\n\t\t\t{\r\n\t\t\t\tfwp_range1 = address.range;\r\n\t\t\t\tfwfc[count].conditionValue.rangeValue = &fwp_range1;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tfwp_range2 = address.range;\r\n\t\t\t\tfwfc[count].conditionValue.rangeValue = &fwp_range2;\r\n\t\t\t}\r\n\r\n\t\t\tcount += 1;\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tif (address.type == DATA_TYPE_PORT)\r\n\t\t\t{\r\n\t\t\t\tif (i == 0)\r\n\t\t\t\t{\r\n\t\t\t\t\tfwfc[count].fieldKey = FWPM_CONDITION_IP_REMOTE_PORT;\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\tfwfc[count].fieldKey = FWPM_CONDITION_IP_LOCAL_PORT;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tfwfc[count].matchType = FWP_MATCH_EQUAL;\r\n\t\t\t\tfwfc[count].conditionValue.type = FWP_UINT16;\r\n\t\t\t\tfwfc[count].conditionValue.uint16 = address.port;\r\n\r\n\t\t\t\tcount += 1;\r\n\t\t\t}\r\n\t\t\telse if (address.type == DATA_TYPE_IP)\r\n\t\t\t{\r\n\t\t\t\tif (i == 0)\r\n\t\t\t\t{\r\n\t\t\t\t\tfwfc[count].fieldKey = FWPM_CONDITION_IP_REMOTE_ADDRESS;\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\tfwfc[count].fieldKey = FWPM_CONDITION_IP_LOCAL_ADDRESS;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tfwfc[count].matchType = FWP_MATCH_EQUAL;\r\n\r\n\t\t\t\tif (address.format == NET_ADDRESS_IPV4)\r\n\t\t\t\t{\r\n\t\t\t\t\taf = AF_INET;\r\n\r\n\t\t\t\t\tfwfc[count].conditionValue.type = FWP_V4_ADDR_MASK;\r\n\t\t\t\t\t//fwfc[count].conditionValue.v4AddrMask = &address.addr4;\r\n\r\n\t\t\t\t\tif (i == 0)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tfwp_addr4_and_mask1 = address.addr4;\r\n\t\t\t\t\t\tfwfc[count].conditionValue.v4AddrMask = &fwp_addr4_and_mask1;\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tfwp_addr4_and_mask2 = address.addr4;\r\n\t\t\t\t\t\tfwfc[count].conditionValue.v4AddrMask = &fwp_addr4_and_mask2;\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tcount += 1;\r\n\t\t\t\t}\r\n\t\t\t\telse if (address.format == NET_ADDRESS_IPV6)\r\n\t\t\t\t{\r\n\t\t\t\t\taf = AF_INET6;\r\n\r\n\t\t\t\t\tfwfc[count].conditionValue.type = FWP_V6_ADDR_MASK;\r\n\t\t\t\t\t//fwfc[count].conditionValue.v6AddrMask = &address.addr6;\r\n\r\n\t\t\t\t\tif (i == 0)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tfwp_addr6_and_mask1 = address.addr6;\r\n\t\t\t\t\t\tfwfc[count].conditionValue.v6AddrMask = &fwp_addr6_and_mask1;\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tfwp_addr6_and_mask2 = address.addr6;\r\n\t\t\t\t\t\tfwfc[count].conditionValue.v6AddrMask = &fwp_addr6_and_mask2;\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tcount += 1;\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\tgoto CleanupExit;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tgoto CleanupExit;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// set port if available\r\n\t\tif (address.type == DATA_TYPE_IP)\r\n\t\t{\r\n\t\t\tif (address.port)\r\n\t\t\t{\r\n\t\t\t\tif (i == 0)\r\n\t\t\t\t{\r\n\t\t\t\t\tfwfc[count].fieldKey = FWPM_CONDITION_IP_REMOTE_PORT;\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\tfwfc[count].fieldKey = FWPM_CONDITION_IP_LOCAL_PORT;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tfwfc[count].matchType = FWP_MATCH_EQUAL;\r\n\t\t\t\tfwfc[count].conditionValue.type = FWP_UINT16;\r\n\t\t\t\tfwfc[count].conditionValue.uint16 = address.port;\r\n\r\n\t\t\t\tcount += 1;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t// set protocol condition\r\n\tif (protocol)\r\n\t{\r\n\t\tfwfc[count].fieldKey = FWPM_CONDITION_IP_PROTOCOL;\r\n\t\tfwfc[count].matchType = FWP_MATCH_EQUAL;\r\n\t\tfwfc[count].conditionValue.type = FWP_UINT8;\r\n\t\tfwfc[count].conditionValue.uint8 = protocol;\r\n\r\n\t\tcount += 1;\r\n\t}\r\n\r\n\t// create outbound layer filter\r\n\tif (direction == FWP_DIRECTION_OUTBOUND || direction == FWP_DIRECTION_MAX)\r\n\t{\r\n\t\tif (af == AF_INET || af == AF_UNSPEC)\r\n\t\t{\r\n\t\t\t_wfp_createfilter (\r\n\t\t\t\tengine_handle,\r\n\t\t\t\tfilter_type,\r\n\t\t\t\tfilter_name,\r\n\t\t\t\tfwfc,\r\n\t\t\t\tcount,\r\n\t\t\t\t&FWPM_LAYER_ALE_AUTH_CONNECT_V4,\r\n\t\t\t\tNULL,\r\n\t\t\t\tweight,\r\n\t\t\t\taction,\r\n\t\t\t\tflags,\r\n\t\t\t\tguids\r\n\t\t\t);\r\n\t\t}\r\n\r\n\t\tif (af == AF_INET6 || af == AF_UNSPEC)\r\n\t\t{\r\n\t\t\t_wfp_createfilter (\r\n\t\t\t\tengine_handle,\r\n\t\t\t\tfilter_type,\r\n\t\t\t\tfilter_name,\r\n\t\t\t\tfwfc,\r\n\t\t\t\tcount,\r\n\t\t\t\t&FWPM_LAYER_ALE_AUTH_CONNECT_V6,\r\n\t\t\t\tNULL,\r\n\t\t\t\tweight,\r\n\t\t\t\taction,\r\n\t\t\t\tflags,\r\n\t\t\t\tguids\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n\r\n\t// create inbound layer filter\r\n\tif (direction == FWP_DIRECTION_INBOUND || direction == FWP_DIRECTION_MAX)\r\n\t{\r\n\t\tif (af == AF_INET || af == AF_UNSPEC)\r\n\t\t{\r\n\t\t\t_wfp_createfilter (\r\n\t\t\t\tengine_handle,\r\n\t\t\t\tfilter_type,\r\n\t\t\t\tfilter_name,\r\n\t\t\t\tfwfc,\r\n\t\t\t\tcount,\r\n\t\t\t\t&FWPM_LAYER_ALE_AUTH_RECV_ACCEPT_V4,\r\n\t\t\t\tNULL,\r\n\t\t\t\tweight,\r\n\t\t\t\taction,\r\n\t\t\t\tflags,\r\n\t\t\t\tguids\r\n\t\t\t);\r\n\t\t}\r\n\r\n\t\tif (af == AF_INET6 || af == AF_UNSPEC)\r\n\t\t{\r\n\t\t\t_wfp_createfilter (\r\n\t\t\t\tengine_handle,\r\n\t\t\t\tfilter_type,\r\n\t\t\t\tfilter_name,\r\n\t\t\t\tfwfc,\r\n\t\t\t\tcount,\r\n\t\t\t\t&FWPM_LAYER_ALE_AUTH_RECV_ACCEPT_V6,\r\n\t\t\t\tNULL,\r\n\t\t\t\tweight,\r\n\t\t\t\taction,\r\n\t\t\t\tflags,\r\n\t\t\t\tguids\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n\r\n\tis_success = TRUE;\r\n\r\nCleanupExit:\r\n\r\n\tif (ptr_app)\r\n\t\t_r_obj_dereference (ptr_app);\r\n\r\n\tif (byte_blob)\r\n\t\tByteBlobFree ((PVOID_PTR)&byte_blob);\r\n\r\n\treturn is_success;\r\n}\r\n\r\nBOOLEAN _wfp_create4filters (\r\n\t_In_ HANDLE engine_handle,\r\n\t_In_ PR_LIST rules,\r\n\t_In_ LPCWSTR file_name,\r\n\t_In_ ULONG line,\r\n\t_In_ BOOLEAN is_intransact\r\n)\r\n{\r\n\tR_STRINGREF remote_remaining_part;\r\n\tR_STRINGREF local_remaining_part;\r\n\tR_STRINGREF rule_remote_part;\r\n\tR_STRINGREF rule_local_part;\r\n\tLPCWSTR rule_name;\r\n\tPR_ARRAY guids;\r\n\tLPGUID guid;\r\n\tPITEM_RULE ptr_rule;\r\n\tULONG_PTR enum_key;\r\n\tULONG hash_code;\r\n\tBOOLEAN is_enabled;\r\n\r\n\tif (_r_obj_isempty (rules))\r\n\t\treturn FALSE;\r\n\r\n\tis_enabled = _app_initinterfacestate (_r_app_gethwnd (), FALSE);\r\n\r\n\tif (!is_intransact && _wfp_isfiltersapplying ())\r\n\t\tis_intransact = TRUE;\r\n\r\n\tguids = _r_obj_createarray (sizeof (GUID), 10, NULL);\r\n\r\n\tif (!is_intransact)\r\n\t{\r\n\t\tfor (ULONG_PTR i = 0; i < _r_obj_getlistsize (rules); i++)\r\n\t\t{\r\n\t\t\tptr_rule = _r_obj_getlistitem (rules, i);\r\n\r\n\t\t\tif (!ptr_rule)\r\n\t\t\t\tcontinue;\r\n\r\n\t\t\tif (!_r_obj_isempty (ptr_rule->guids))\r\n\t\t\t{\r\n\t\t\t\t_r_obj_addarrayitems (guids, ptr_rule->guids->items, ptr_rule->guids->count);\r\n\r\n\t\t\t\t_r_obj_cleararray (ptr_rule->guids);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tfor (ULONG_PTR i = 0; i < _r_obj_getarraysize (guids); i++)\r\n\t\t{\r\n\t\t\tguid = (LPGUID)_r_obj_getarrayitem (guids, i);\r\n\r\n\t\t\tif (guid)\r\n\t\t\t\t_app_setfiltersecurity (engine_handle, guid, FALSE, DBG_ARG_VAR);\r\n\t\t}\r\n\r\n\t\t_r_queuedlock_acquireshared (&lock_transaction);\r\n\r\n\t\tis_intransact = !_wfp_transact_start (engine_handle, DBG_ARG_VAR);\r\n\t}\r\n\r\n\tfor (ULONG_PTR i = 0; i < _r_obj_getarraysize (guids); i++)\r\n\t{\r\n\t\tguid = (LPGUID)_r_obj_getarrayitem (guids, i);\r\n\r\n\t\tif (guid)\r\n\t\t\t_wfp_deletefilter (engine_handle, guid);\r\n\t}\r\n\r\n\tfor (ULONG_PTR i = 0; i < _r_obj_getlistsize (rules); i++)\r\n\t{\r\n\t\tptr_rule = _r_obj_getlistitem (rules, i);\r\n\r\n\t\tif (!ptr_rule)\r\n\t\t\tcontinue;\r\n\r\n\t\tptr_rule->is_haveerrors = FALSE;\r\n\r\n\t\t_r_obj_cleararray (ptr_rule->guids);\r\n\r\n\t\tif (!ptr_rule->is_enabled)\r\n\t\t\tcontinue;\r\n\r\n\t\trule_name = _r_obj_getstring (ptr_rule->name);\r\n\r\n\t\tif (!_r_obj_isstringempty (ptr_rule->rule_remote))\r\n\t\t{\r\n\t\t\t_r_str_splitatchar (&ptr_rule->rule_remote->sr, DIVIDER_RULE[0], &rule_remote_part, &remote_remaining_part);\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\t_r_obj_initializestringrefempty (&rule_remote_part);\r\n\t\t\t_r_obj_initializestringrefempty (&remote_remaining_part);\r\n\t\t}\r\n\r\n\t\tif (!_r_obj_isstringempty (ptr_rule->rule_local))\r\n\t\t{\r\n\t\t\t_r_str_splitatchar (&ptr_rule->rule_local->sr, DIVIDER_RULE[0], &rule_local_part, &local_remaining_part);\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\t_r_obj_initializestringrefempty (&rule_local_part);\r\n\t\t\t_r_obj_initializestringrefempty (&local_remaining_part);\r\n\t\t}\r\n\r\n\t\twhile (TRUE)\r\n\t\t{\r\n\t\t\t// apply rules for services hosts\r\n\t\t\tif (ptr_rule->is_forservices)\r\n\t\t\t{\r\n\t\t\t\tif (!_wfp_createrulefilter (\r\n\t\t\t\t\tengine_handle,\r\n\t\t\t\t\tptr_rule->type,\r\n\t\t\t\t\trule_name,\r\n\t\t\t\t\tconfig.ntoskrnl_hash,\r\n\t\t\t\t\t&ptr_rule->config,\r\n\t\t\t\t\t&rule_remote_part,\r\n\t\t\t\t\t&rule_local_part,\r\n\t\t\t\t\tptr_rule->weight,\r\n\t\t\t\t\tptr_rule->action,\r\n\t\t\t\t\t0,\r\n\t\t\t\t\tptr_rule->guids))\r\n\t\t\t\t{\r\n\t\t\t\t\tptr_rule->is_haveerrors = TRUE;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif (!_wfp_createrulefilter (\r\n\t\t\t\t\tengine_handle,\r\n\t\t\t\t\tptr_rule->type,\r\n\t\t\t\t\trule_name,\r\n\t\t\t\t\tconfig.svchost_hash,\r\n\t\t\t\t\t&ptr_rule->config,\r\n\t\t\t\t\t&rule_remote_part,\r\n\t\t\t\t\t&rule_local_part,\r\n\t\t\t\t\tptr_rule->weight,\r\n\t\t\t\t\tptr_rule->action,\r\n\t\t\t\t\t0,\r\n\t\t\t\t\tptr_rule->guids))\r\n\t\t\t\t{\r\n\t\t\t\t\tptr_rule->is_haveerrors = TRUE;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tif (!_r_obj_isempty (ptr_rule->apps))\r\n\t\t\t{\r\n\t\t\t\tenum_key = 0;\r\n\r\n\t\t\t\twhile (_r_obj_enumhashtable (ptr_rule->apps, NULL, &hash_code, &enum_key))\r\n\t\t\t\t{\r\n\t\t\t\t\tif (ptr_rule->is_forservices && _app_issystemhash (hash_code))\r\n\t\t\t\t\t\tcontinue;\r\n\r\n\t\t\t\t\tif (!_wfp_createrulefilter (\r\n\t\t\t\t\t\tengine_handle,\r\n\t\t\t\t\t\tptr_rule->type,\r\n\t\t\t\t\t\trule_name,\r\n\t\t\t\t\t\thash_code,\r\n\t\t\t\t\t\t&ptr_rule->config,\r\n\t\t\t\t\t\t&rule_remote_part,\r\n\t\t\t\t\t\t&rule_local_part,\r\n\t\t\t\t\t\tptr_rule->weight,\r\n\t\t\t\t\t\tptr_rule->action,\r\n\t\t\t\t\t\t0,\r\n\t\t\t\t\t\tptr_rule->guids))\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tptr_rule->is_haveerrors = TRUE;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tif (!_wfp_createrulefilter (\r\n\t\t\t\t\tengine_handle,\r\n\t\t\t\t\tptr_rule->type,\r\n\t\t\t\t\trule_name,\r\n\t\t\t\t\t0,\r\n\t\t\t\t\t&ptr_rule->config,\r\n\t\t\t\t\t&rule_remote_part,\r\n\t\t\t\t\t&rule_local_part,\r\n\t\t\t\t\tptr_rule->weight,\r\n\t\t\t\t\tptr_rule->action,\r\n\t\t\t\t\t0,\r\n\t\t\t\t\tptr_rule->guids))\r\n\t\t\t\t{\r\n\t\t\t\t\tptr_rule->is_haveerrors = TRUE;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tif (remote_remaining_part.length == 0 && local_remaining_part.length == 0)\r\n\t\t\t\tbreak;\r\n\r\n\t\t\tif (remote_remaining_part.length != 0)\r\n\t\t\t\t_r_str_splitatchar (&remote_remaining_part, DIVIDER_RULE[0], &rule_remote_part, &remote_remaining_part);\r\n\r\n\t\t\tif (local_remaining_part.length != 0)\r\n\t\t\t\t_r_str_splitatchar (&local_remaining_part, DIVIDER_RULE[0], &rule_local_part, &local_remaining_part);\r\n\t\t}\r\n\t}\r\n\r\n\tif (!is_intransact)\r\n\t{\r\n\t\t_wfp_transact_commit (engine_handle, DBG_ARG_VAR);\r\n\r\n\t\tfor (ULONG_PTR i = 0; i < _r_obj_getlistsize (rules); i++)\r\n\t\t{\r\n\t\t\tptr_rule = _r_obj_getlistitem (rules, i);\r\n\r\n\t\t\tif (ptr_rule && ptr_rule->is_enabled)\r\n\t\t\t{\r\n\t\t\t\tfor (ULONG_PTR j = 0; j < _r_obj_getarraysize (ptr_rule->guids); j++)\r\n\t\t\t\t{\r\n\t\t\t\t\tguid = (LPGUID)_r_obj_getarrayitem (ptr_rule->guids, j);\r\n\r\n\t\t\t\t\tif (guid)\r\n\t\t\t\t\t\t_app_setfiltersecurity (engine_handle, guid, TRUE, DBG_ARG_VAR);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t_r_queuedlock_releaseshared (&lock_transaction);\r\n\t}\r\n\r\n\t_app_restoreinterfacestate (_r_app_gethwnd (), is_enabled);\r\n\r\n\t_r_obj_dereference (guids);\r\n\r\n\treturn TRUE;\r\n}\r\n\r\nBOOLEAN _wfp_create3filters (\r\n\t_In_ HANDLE engine_handle,\r\n\t_In_ PR_LIST rules,\r\n\t_In_ LPCWSTR file_name,\r\n\t_In_ ULONG line,\r\n\t_In_ BOOLEAN is_intransact\r\n)\r\n{\r\n\r\n\tPR_ARRAY guids;\r\n\tLPGUID guid;\r\n\tPITEM_APP ptr_app;\r\n\tPR_STRING string;\r\n\tBOOLEAN is_enabled;\r\n\r\n\tif (_r_obj_isempty (rules))\r\n\t\treturn FALSE;\r\n\r\n\tif (!is_intransact && _wfp_isfiltersapplying ())\r\n\t\tis_intransact = TRUE;\r\n\r\n\tguids = _r_obj_createarray (sizeof (GUID), 10, NULL);\r\n\r\n\tis_enabled = _app_initinterfacestate (_r_app_gethwnd (), FALSE);\r\n\r\n\tif (!is_intransact)\r\n\t{\r\n\t\tfor (ULONG_PTR i = 0; i < _r_obj_getlistsize (rules); i++)\r\n\t\t{\r\n\t\t\tptr_app = _r_obj_getlistitem (rules, i);\r\n\r\n\t\t\tif (ptr_app && !_r_obj_isempty (ptr_app->guids))\r\n\t\t\t{\r\n\t\t\t\t_r_obj_addarrayitems (guids, ptr_app->guids->items, ptr_app->guids->count);\r\n\r\n\t\t\t\t_r_obj_cleararray (ptr_app->guids);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tfor (ULONG_PTR i = 0; i < _r_obj_getarraysize (guids); i++)\r\n\t\t{\r\n\t\t\tguid = (LPGUID)_r_obj_getarrayitem (guids, i);\r\n\r\n\t\t\tif (guid)\r\n\t\t\t\t_app_setfiltersecurity (engine_handle, guid, FALSE, DBG_ARG_VAR);\r\n\t\t}\r\n\r\n\t\t_r_queuedlock_acquireshared (&lock_transaction);\r\n\r\n\t\tis_intransact = !_wfp_transact_start (engine_handle, DBG_ARG_VAR);\r\n\t}\r\n\r\n\tfor (ULONG_PTR i = 0; i < _r_obj_getarraysize (guids); i++)\r\n\t{\r\n\t\tguid = (LPGUID)_r_obj_getarrayitem (guids, i);\r\n\r\n\t\tif (guid)\r\n\t\t\t_wfp_deletefilter (engine_handle, guid);\r\n\t}\r\n\r\n\tfor (ULONG_PTR i = 0; i < _r_obj_getlistsize (rules); i++)\r\n\t{\r\n\t\tptr_app = _r_obj_getlistitem (rules, i);\r\n\r\n\t\tif (ptr_app && ptr_app->is_enabled)\r\n\t\t{\r\n\t\t\tstring = _app_getappdisplayname (ptr_app, TRUE);\r\n\r\n\t\t\tif (!_wfp_createrulefilter (\r\n\t\t\t\tengine_handle,\r\n\t\t\t\tptr_app->type,\r\n\t\t\t\t_r_obj_getstring (string),\r\n\t\t\t\tptr_app->app_hash,\r\n\t\t\t\tNULL,\r\n\t\t\t\tNULL,\r\n\t\t\t\tNULL,\r\n\t\t\t\tFW_WEIGHT_APP,\r\n\t\t\t\tFWP_ACTION_PERMIT,\r\n\t\t\t\t0,\r\n\t\t\t\tptr_app->guids))\r\n\t\t\t{\r\n\t\t\t\tptr_app->is_haveerrors = TRUE;\r\n\t\t\t}\r\n\r\n\t\t\tif (string)\r\n\t\t\t\t_r_obj_dereference (string);\r\n\t\t}\r\n\t}\r\n\r\n\tif (!is_intransact)\r\n\t{\r\n\t\t_wfp_transact_commit (engine_handle, DBG_ARG_VAR);\r\n\r\n\t\tfor (ULONG_PTR i = 0; i < _r_obj_getlistsize (rules); i++)\r\n\t\t{\r\n\t\t\tptr_app = _r_obj_getlistitem (rules, i);\r\n\r\n\t\t\tif (ptr_app)\r\n\t\t\t{\r\n\t\t\t\tfor (ULONG_PTR j = 0; j < _r_obj_getarraysize (ptr_app->guids); j++)\r\n\t\t\t\t{\r\n\t\t\t\t\tguid = (LPGUID)_r_obj_getarrayitem (ptr_app->guids, j);\r\n\r\n\t\t\t\t\tif (guid)\r\n\t\t\t\t\t\t_app_setfiltersecurity (engine_handle, guid, TRUE, DBG_ARG_VAR);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t_r_queuedlock_releaseshared (&lock_transaction);\r\n\t}\r\n\r\n\t_app_restoreinterfacestate (_r_app_gethwnd (), is_enabled);\r\n\r\n\t_r_obj_dereference (guids);\r\n\r\n\treturn TRUE;\r\n}\r\n\r\nBOOLEAN _wfp_create2filters (\r\n\t_In_ HANDLE engine_handle,\r\n\t_In_ LPCWSTR file_name,\r\n\t_In_ ULONG line,\r\n\t_In_ BOOLEAN is_intransact\r\n)\r\n{\r\n\t// ipv4/ipv6 loopback\r\n\tR_STRINGREF loopback_list[] = {\r\n\t\tPR_STRINGREF_INIT (L\"0.0.0.0/8\"),\r\n\t\tPR_STRINGREF_INIT (L\"10.0.0.0/8\"),\r\n\t\tPR_STRINGREF_INIT (L\"100.64.0.0/10\"),\r\n\t\tPR_STRINGREF_INIT (L\"127.0.0.0/8\"),\r\n\t\tPR_STRINGREF_INIT (L\"169.254.0.0/16\"),\r\n\t\tPR_STRINGREF_INIT (L\"172.16.0.0/12\"),\r\n\t\tPR_STRINGREF_INIT (L\"192.0.0.0/24\"),\r\n\t\tPR_STRINGREF_INIT (L\"192.0.2.0/24\"),\r\n\t\tPR_STRINGREF_INIT (L\"192.88.99.0/24\"),\r\n\t\tPR_STRINGREF_INIT (L\"192.168.0.0/16\"),\r\n\t\tPR_STRINGREF_INIT (L\"198.18.0.0/15\"),\r\n\t\tPR_STRINGREF_INIT (L\"198.51.100.0/24\"),\r\n\t\tPR_STRINGREF_INIT (L\"203.0.113.0/24\"),\r\n\t\tPR_STRINGREF_INIT (L\"224.0.0.0/4\"),\r\n\t\tPR_STRINGREF_INIT (L\"240.0.0.0/4\"),\r\n\t\tPR_STRINGREF_INIT (L\"255.255.255.255/32\"),\r\n\t\tPR_STRINGREF_INIT (L\"[::]/0\"),\r\n\t\tPR_STRINGREF_INIT (L\"[::]/128\"),\r\n\t\tPR_STRINGREF_INIT (L\"[::1]/128\"),\r\n\t\tPR_STRINGREF_INIT (L\"[::ffff:0:0]/96\"),\r\n\t\tPR_STRINGREF_INIT (L\"[::ffff:0:0:0]/96\"),\r\n\t\tPR_STRINGREF_INIT (L\"[64:ff9b::]/96\"),\r\n\t\tPR_STRINGREF_INIT (L\"[100::]/64\"),\r\n\t\tPR_STRINGREF_INIT (L\"[2001::]/32\"),\r\n\t\tPR_STRINGREF_INIT (L\"[2001:20::]/28\"),\r\n\t\tPR_STRINGREF_INIT (L\"[2001:db8::]/32\"),\r\n\t\tPR_STRINGREF_INIT (L\"[2002::]/16\"),\r\n\t\tPR_STRINGREF_INIT (L\"[fc00::]/7\"),\r\n\t\tPR_STRINGREF_INIT (L\"[fe80::]/10\"),\r\n\t\tPR_STRINGREF_INIT (L\"[ff00::]/8\")\r\n\t};\r\n\r\n\tFWPM_FILTER_CONDITION0 fwfc[3] = {0};\r\n\tITEM_ADDRESS address;\r\n\tLPGUID guid;\r\n\tFWP_ACTION_TYPE action;\r\n\tBOOLEAN is_enabled;\r\n\r\n\tis_enabled = _app_initinterfacestate (_r_app_gethwnd (), FALSE);\r\n\r\n\tif (!is_intransact && _wfp_isfiltersapplying ())\r\n\t\tis_intransact = TRUE;\r\n\r\n\tif (!is_intransact)\r\n\t{\r\n\t\tif (!_r_obj_isempty (filter_ids))\r\n\t\t{\r\n\t\t\tfor (ULONG_PTR i = 0; i < _r_obj_getarraysize (filter_ids); i++)\r\n\t\t\t{\r\n\t\t\t\tguid = (LPGUID)_r_obj_getarrayitem (filter_ids, i);\r\n\r\n\t\t\t\tif (guid)\r\n\t\t\t\t\t_app_setfiltersecurity (engine_handle, guid, FALSE, DBG_ARG_VAR);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t_r_queuedlock_acquireshared (&lock_transaction);\r\n\r\n\t\tis_intransact = !_wfp_transact_start (engine_handle, DBG_ARG_VAR);\r\n\t}\r\n\r\n\tif (!_r_obj_isempty (filter_ids))\r\n\t{\r\n\t\tfor (ULONG_PTR i = 0; i < _r_obj_getarraysize (filter_ids); i++)\r\n\t\t{\r\n\t\t\tguid = (LPGUID)_r_obj_getarrayitem (filter_ids, i);\r\n\r\n\t\t\tif (guid)\r\n\t\t\t\t_wfp_deletefilter (engine_handle, guid);\r\n\t\t}\r\n\r\n\t\t_r_obj_cleararray (filter_ids);\r\n\t}\r\n\r\n\t// add loopback connections permission\r\n\tif (_r_config_getboolean (L\"AllowLoopbackConnections\", TRUE, NULL))\r\n\t{\r\n\t\t// match all loopback (localhost) data\r\n\t\t// tests if the network traffic is (non-)app container loopback traffic (win8+)\r\n\r\n\t\tfwfc[0].fieldKey = FWPM_CONDITION_FLAGS;\r\n\t\tfwfc[0].matchType = FWP_MATCH_FLAGS_ALL_SET;\r\n\t\tfwfc[0].conditionValue.type = FWP_UINT32;\r\n\t\tfwfc[0].conditionValue.uint32 = FWP_CONDITION_FLAG_IS_LOOPBACK;\r\n\r\n\t\t// tests if the network traffic is (non-)app container loopback traffic (win8+)\r\n\t\tif (_r_sys_isosversiongreaterorequal (WINDOWS_8))\r\n\t\t{\r\n\t\t\tfwfc[0].matchType = FWP_MATCH_FLAGS_ANY_SET;\r\n\t\t\tfwfc[0].conditionValue.uint32 |= FWP_CONDITION_FLAG_IS_APPCONTAINER_LOOPBACK;\r\n\t\t}\r\n\r\n\t\t_wfp_createfilter (\r\n\t\t\tengine_handle,\r\n\t\t\tDATA_FILTER_GENERAL,\r\n\t\t\tFW_NAME_LOOPBACK,\r\n\t\t\tfwfc,\r\n\t\t\t1,\r\n\t\t\t&FWPM_LAYER_ALE_AUTH_CONNECT_V4,\r\n\t\t\tNULL,\r\n\t\t\tFW_WEIGHT_HIGHEST_IMPORTANT,\r\n\t\t\tFWP_ACTION_PERMIT,\r\n\t\t\t0,\r\n\t\t\tfilter_ids\r\n\t\t);\r\n\r\n\t\t_wfp_createfilter (\r\n\t\t\tengine_handle,\r\n\t\t\tDATA_FILTER_GENERAL,\r\n\t\t\tFW_NAME_LOOPBACK,\r\n\t\t\tfwfc,\r\n\t\t\t1,\r\n\t\t\t&FWPM_LAYER_ALE_AUTH_CONNECT_V6,\r\n\t\t\tNULL,\r\n\t\t\tFW_WEIGHT_HIGHEST_IMPORTANT,\r\n\t\t\tFWP_ACTION_PERMIT,\r\n\t\t\t0,\r\n\t\t\tfilter_ids\r\n\t\t);\r\n\r\n\t\t_wfp_createfilter (\r\n\t\t\tengine_handle,\r\n\t\t\tDATA_FILTER_GENERAL,\r\n\t\t\tFW_NAME_LOOPBACK,\r\n\t\t\tfwfc,\r\n\t\t\t1,\r\n\t\t\t&FWPM_LAYER_ALE_AUTH_RECV_ACCEPT_V4,\r\n\t\t\tNULL,\r\n\t\t\tFW_WEIGHT_HIGHEST_IMPORTANT,\r\n\t\t\tFWP_ACTION_PERMIT,\r\n\t\t\t0,\r\n\t\t\tfilter_ids\r\n\t\t);\r\n\r\n\t\t_wfp_createfilter (\r\n\t\t\tengine_handle,\r\n\t\t\tDATA_FILTER_GENERAL,\r\n\t\t\tFW_NAME_LOOPBACK,\r\n\t\t\tfwfc,\r\n\t\t\t1,\r\n\t\t\t&FWPM_LAYER_ALE_AUTH_RECV_ACCEPT_V6,\r\n\t\t\tNULL,\r\n\t\t\tFW_WEIGHT_HIGHEST_IMPORTANT,\r\n\t\t\tFWP_ACTION_PERMIT,\r\n\t\t\t0,\r\n\t\t\tfilter_ids\r\n\t\t);\r\n\r\n\t\tfor (ULONG_PTR i = 0; i < RTL_NUMBER_OF (loopback_list); i++)\r\n\t\t{\r\n\t\t\tif (!_app_parserulestring (&loopback_list[i], &address))\r\n\t\t\t\tcontinue;\r\n\r\n\t\t\tfwfc[1].matchType = FWP_MATCH_EQUAL;\r\n\r\n\t\t\tif (address.format == NET_ADDRESS_IPV4)\r\n\t\t\t{\r\n\t\t\t\tfwfc[1].conditionValue.type = FWP_V4_ADDR_MASK;\r\n\t\t\t\tfwfc[1].conditionValue.v4AddrMask = &address.addr4;\r\n\r\n\t\t\t\tfwfc[1].fieldKey = FWPM_CONDITION_IP_REMOTE_ADDRESS;\r\n\r\n\t\t\t\t_wfp_createfilter (\r\n\t\t\t\t\tengine_handle,\r\n\t\t\t\t\tDATA_FILTER_GENERAL,\r\n\t\t\t\t\tFW_NAME_LOOPBACK,\r\n\t\t\t\t\tfwfc,\r\n\t\t\t\t\t2,\r\n\t\t\t\t\t&FWPM_LAYER_ALE_AUTH_CONNECT_V4,\r\n\t\t\t\t\tNULL,\r\n\t\t\t\t\tFW_WEIGHT_HIGHEST_IMPORTANT,\r\n\t\t\t\t\tFWP_ACTION_PERMIT,\r\n\t\t\t\t\t0,\r\n\t\t\t\t\tfilter_ids\r\n\t\t\t\t);\r\n\r\n\t\t\t\tfwfc[1].fieldKey = FWPM_CONDITION_IP_LOCAL_ADDRESS;\r\n\r\n\t\t\t\t_wfp_createfilter (\r\n\t\t\t\t\tengine_handle,\r\n\t\t\t\t\tDATA_FILTER_GENERAL,\r\n\t\t\t\t\tFW_NAME_LOOPBACK,\r\n\t\t\t\t\tfwfc,\r\n\t\t\t\t\t2,\r\n\t\t\t\t\t&FWPM_LAYER_ALE_AUTH_RECV_ACCEPT_V4,\r\n\t\t\t\t\tNULL,\r\n\t\t\t\t\tFW_WEIGHT_HIGHEST_IMPORTANT,\r\n\t\t\t\t\tFWP_ACTION_PERMIT,\r\n\t\t\t\t\t0,\r\n\t\t\t\t\tfilter_ids\r\n\t\t\t\t);\r\n\t\t\t}\r\n\t\t\telse if (address.format == NET_ADDRESS_IPV6)\r\n\t\t\t{\r\n\t\t\t\tfwfc[1].conditionValue.type = FWP_V6_ADDR_MASK;\r\n\t\t\t\tfwfc[1].conditionValue.v6AddrMask = &address.addr6;\r\n\r\n\t\t\t\tfwfc[1].fieldKey = FWPM_CONDITION_IP_REMOTE_ADDRESS;\r\n\r\n\t\t\t\t_wfp_createfilter (\r\n\t\t\t\t\tengine_handle,\r\n\t\t\t\t\tDATA_FILTER_GENERAL,\r\n\t\t\t\t\tFW_NAME_LOOPBACK,\r\n\t\t\t\t\tfwfc,\r\n\t\t\t\t\t2,\r\n\t\t\t\t\t&FWPM_LAYER_ALE_AUTH_CONNECT_V6,\r\n\t\t\t\t\tNULL,\r\n\t\t\t\t\tFW_WEIGHT_HIGHEST_IMPORTANT,\r\n\t\t\t\t\tFWP_ACTION_PERMIT,\r\n\t\t\t\t\t0,\r\n\t\t\t\t\tfilter_ids\r\n\t\t\t\t);\r\n\r\n\t\t\t\tfwfc[1].fieldKey = FWPM_CONDITION_IP_LOCAL_ADDRESS;\r\n\r\n\t\t\t\t_wfp_createfilter (\r\n\t\t\t\t\tengine_handle,\r\n\t\t\t\t\tDATA_FILTER_GENERAL,\r\n\t\t\t\t\tFW_NAME_LOOPBACK,\r\n\t\t\t\t\tfwfc,\r\n\t\t\t\t\t2,\r\n\t\t\t\t\t&FWPM_LAYER_ALE_AUTH_RECV_ACCEPT_V6,\r\n\t\t\t\t\tNULL,\r\n\t\t\t\t\tFW_WEIGHT_HIGHEST_IMPORTANT,\r\n\t\t\t\t\tFWP_ACTION_PERMIT,\r\n\t\t\t\t\t0,\r\n\t\t\t\t\tfilter_ids\r\n\t\t\t\t);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t// firewall service rules\r\n\t// https://msdn.microsoft.com/en-us/library/gg462153.aspx\r\n\tif (_r_config_getboolean (L\"AllowIPv6\", TRUE, NULL))\r\n\t{\r\n\t\t// allows 6to4 tunneling, which enables ipv6 to run over an ipv4 network\r\n\t\tfwfc[0].fieldKey = FWPM_CONDITION_IP_PROTOCOL;\r\n\t\tfwfc[0].matchType = FWP_MATCH_EQUAL;\r\n\t\tfwfc[0].conditionValue.type = FWP_UINT8;\r\n\t\tfwfc[0].conditionValue.uint8 = IPPROTO_IPV6; // ipv6 header\r\n\r\n\t\t_wfp_createfilter (\r\n\t\t\tengine_handle,\r\n\t\t\tDATA_FILTER_GENERAL,\r\n\t\t\tL\"Allow6to4\",\r\n\t\t\tfwfc,\r\n\t\t\t1,\r\n\t\t\t&FWPM_LAYER_ALE_AUTH_RECV_ACCEPT_V4,\r\n\t\t\tNULL,\r\n\t\t\tFW_WEIGHT_HIGHEST_IMPORTANT,\r\n\t\t\tFWP_ACTION_PERMIT,\r\n\t\t\t0,\r\n\t\t\tfilter_ids\r\n\t\t);\r\n\r\n\t\t// allows icmpv6 router solicitation messages, which are\r\n\t\t// required for the ipv6 stack to work properly\r\n\t\tfwfc[0].fieldKey = FWPM_CONDITION_ICMP_TYPE;\r\n\t\tfwfc[0].matchType = FWP_MATCH_EQUAL;\r\n\t\tfwfc[0].conditionValue.type = FWP_UINT16;\r\n\r\n\t\tfwfc[0].conditionValue.uint16 = 0x85;\r\n\r\n\t\t_wfp_createfilter (\r\n\t\t\tengine_handle,\r\n\t\t\tDATA_FILTER_GENERAL,\r\n\t\t\tL\"AllowIcmpV6Type133\",\r\n\t\t\tfwfc,\r\n\t\t\t1,\r\n\t\t\t&FWPM_LAYER_ALE_AUTH_RECV_ACCEPT_V6,\r\n\t\t\tNULL,\r\n\t\t\tFW_WEIGHT_HIGHEST_IMPORTANT,\r\n\t\t\tFWP_ACTION_PERMIT,\r\n\t\t\t0,\r\n\t\t\tfilter_ids\r\n\t\t);\r\n\r\n\t\t// allows icmpv6 router advertise messages, which are required\r\n\t\t// for the ipv6 stack to work properly\r\n\t\tfwfc[0].conditionValue.uint16 = 0x86;\r\n\r\n\t\t_wfp_createfilter (\r\n\t\t\tengine_handle,\r\n\t\t\tDATA_FILTER_GENERAL,\r\n\t\t\tL\"AllowIcmpV6Type134\",\r\n\t\t\tfwfc,\r\n\t\t\t1,\r\n\t\t\t&FWPM_LAYER_ALE_AUTH_RECV_ACCEPT_V6,\r\n\t\t\tNULL,\r\n\t\t\tFW_WEIGHT_HIGHEST_IMPORTANT,\r\n\t\t\tFWP_ACTION_PERMIT,\r\n\t\t\t0,\r\n\t\t\tfilter_ids\r\n\t\t);\r\n\r\n\t\t// allows icmpv6 neighbor solicitation messages, which\r\n\t\t// are required for the ipv6 stack to work properly\r\n\t\tfwfc[0].conditionValue.uint16 = 0x87;\r\n\r\n\t\t_wfp_createfilter (\r\n\t\t\tengine_handle,\r\n\t\t\tDATA_FILTER_GENERAL,\r\n\t\t\tL\"AllowIcmpV6Type135\",\r\n\t\t\tfwfc,\r\n\t\t\t1,\r\n\t\t\t&FWPM_LAYER_ALE_AUTH_RECV_ACCEPT_V6,\r\n\t\t\tNULL,\r\n\t\t\tFW_WEIGHT_HIGHEST_IMPORTANT,\r\n\t\t\tFWP_ACTION_PERMIT,\r\n\t\t\t0,\r\n\t\t\tfilter_ids\r\n\t\t);\r\n\r\n\t\t// allows icmpv6 neighbor advertise messages, which are\r\n\t\t// required for the ipv6 stack to work properly\r\n\t\tfwfc[0].conditionValue.uint16 = 0x88;\r\n\r\n\t\t_wfp_createfilter (\r\n\t\t\tengine_handle,\r\n\t\t\tDATA_FILTER_GENERAL,\r\n\t\t\tL\"AllowIcmpV6Type136\",\r\n\t\t\tfwfc,\r\n\t\t\t1,\r\n\t\t\t&FWPM_LAYER_ALE_AUTH_RECV_ACCEPT_V6,\r\n\t\t\tNULL,\r\n\t\t\tFW_WEIGHT_HIGHEST_IMPORTANT,\r\n\t\t\tFWP_ACTION_PERMIT,\r\n\t\t\t0,\r\n\t\t\tfilter_ids\r\n\t\t);\r\n\t}\r\n\r\n\t// prevent port scanning using stealth discards and silent drops\r\n\t// https://docs.microsoft.com/ru-ru/windows/desktop/FWP/preventing-port-scanning\r\n\tif (_r_config_getboolean (L\"UseStealthMode\", TRUE, NULL))\r\n\t{\r\n\t\t// blocks udp port scanners\r\n\t\tfwfc[0].fieldKey = FWPM_CONDITION_FLAGS;\r\n\t\tfwfc[0].matchType = FWP_MATCH_FLAGS_NONE_SET;\r\n\t\tfwfc[0].conditionValue.type = FWP_UINT32;\r\n\t\tfwfc[0].conditionValue.uint32 = FWP_CONDITION_FLAG_IS_LOOPBACK;\r\n\r\n\t\t// tests if the network traffic is (non-)app container loopback traffic (win8+)\r\n\t\tif (_r_sys_isosversiongreaterorequal (WINDOWS_8))\r\n\t\t\tfwfc[0].conditionValue.uint32 |= FWP_CONDITION_FLAG_IS_APPCONTAINER_LOOPBACK;\r\n\r\n\t\tfwfc[1].fieldKey = FWPM_CONDITION_ICMP_TYPE;\r\n\t\tfwfc[1].matchType = FWP_MATCH_EQUAL;\r\n\t\tfwfc[1].conditionValue.type = FWP_UINT16;\r\n\t\tfwfc[1].conditionValue.uint16 = 0x03; // destination unreachable\r\n\r\n\t\t_wfp_createfilter (\r\n\t\t\tengine_handle,\r\n\t\t\tDATA_FILTER_GENERAL,\r\n\t\t\tFW_NAME_ICMP_ERROR,\r\n\t\t\tfwfc,\r\n\t\t\t2,\r\n\t\t\t&FWPM_LAYER_OUTBOUND_ICMP_ERROR_V4,\r\n\t\t\tNULL,\r\n\t\t\tFW_WEIGHT_HIGHEST,\r\n\t\t\tFWP_ACTION_BLOCK,\r\n\t\t\t0,\r\n\t\t\tfilter_ids\r\n\t\t);\r\n\r\n\t\t_wfp_createfilter (\r\n\t\t\tengine_handle,\r\n\t\t\tDATA_FILTER_GENERAL,\r\n\t\t\tFW_NAME_ICMP_ERROR,\r\n\t\t\tfwfc,\r\n\t\t\t2,\r\n\t\t\t&FWPM_LAYER_OUTBOUND_ICMP_ERROR_V6,\r\n\t\t\tNULL,\r\n\t\t\tFW_WEIGHT_HIGHEST,\r\n\t\t\tFWP_ACTION_BLOCK,\r\n\t\t\t0,\r\n\t\t\tfilter_ids\r\n\t\t);\r\n\r\n\t\t// blocks tcp port scanners (exclude loopback)\r\n\t\tfwfc[0].conditionValue.uint32 |= FWP_CONDITION_FLAG_IS_IPSEC_SECURED;\r\n\r\n\t\t_wfp_createfilter (\r\n\t\t\tengine_handle,\r\n\t\t\tDATA_FILTER_GENERAL,\r\n\t\t\tFW_NAME_TCP_RST_ONCLOSE,\r\n\t\t\tfwfc,\r\n\t\t\t1,\r\n\t\t\t&FWPM_LAYER_INBOUND_TRANSPORT_V4_DISCARD,\r\n\t\t\t&FWPM_CALLOUT_WFP_TRANSPORT_LAYER_V4_SILENT_DROP,\r\n\t\t\tFW_WEIGHT_HIGHEST,\r\n\t\t\tFWP_ACTION_CALLOUT_TERMINATING,\r\n\t\t\t0,\r\n\t\t\tfilter_ids\r\n\t\t);\r\n\r\n\t\t_wfp_createfilter (\r\n\t\t\tengine_handle,\r\n\t\t\tDATA_FILTER_GENERAL,\r\n\t\t\tFW_NAME_TCP_RST_ONCLOSE,\r\n\t\t\tfwfc,\r\n\t\t\t1,\r\n\t\t\t&FWPM_LAYER_INBOUND_TRANSPORT_V6_DISCARD,\r\n\t\t\t&FWPM_CALLOUT_WFP_TRANSPORT_LAYER_V6_SILENT_DROP,\r\n\t\t\tFW_WEIGHT_HIGHEST,\r\n\t\t\tFWP_ACTION_CALLOUT_TERMINATING,\r\n\t\t\t0,\r\n\t\t\tfilter_ids\r\n\t\t);\r\n\t}\r\n\r\n\t// install boot-time filters (enforced at boot-time,\r\n\t// even before \"base filtering engine\" service starts)\r\n\tif (_r_config_getboolean (L\"InstallBoottimeFilters\", TRUE, NULL) && !config.is_filterstemporary)\r\n\t{\r\n\t\tfwfc[0].fieldKey = FWPM_CONDITION_FLAGS;\r\n\t\tfwfc[0].matchType = FWP_MATCH_FLAGS_ALL_SET;\r\n\t\tfwfc[0].conditionValue.type = FWP_UINT32;\r\n\t\tfwfc[0].conditionValue.uint32 = FWP_CONDITION_FLAG_IS_LOOPBACK;\r\n\r\n\t\t// tests if the network traffic is (non-)app container loopback traffic (win8+)\r\n\t\tif (_r_sys_isosversiongreaterorequal (WINDOWS_8))\r\n\t\t{\r\n\t\t\tfwfc[0].matchType = FWP_MATCH_FLAGS_ANY_SET;\r\n\t\t\tfwfc[0].conditionValue.uint32 |= FWP_CONDITION_FLAG_IS_APPCONTAINER_LOOPBACK;\r\n\t\t}\r\n\r\n\t\t_wfp_createfilter (\r\n\t\t\tengine_handle,\r\n\t\t\tDATA_FILTER_GENERAL,\r\n\t\t\tFW_NAME_BOOTTIME,\r\n\t\t\tfwfc,\r\n\t\t\t1,\r\n\t\t\t&FWPM_LAYER_IPFORWARD_V4,\r\n\t\t\tNULL,\r\n\t\t\tFW_WEIGHT_HIGHEST_IMPORTANT,\r\n\t\t\tFWP_ACTION_PERMIT,\r\n\t\t\tFWPM_FILTER_FLAG_BOOTTIME,\r\n\t\t\tfilter_ids\r\n\t\t);\r\n\r\n\t\t_wfp_createfilter (\r\n\t\t\tengine_handle,\r\n\t\t\tDATA_FILTER_GENERAL,\r\n\t\t\tFW_NAME_BOOTTIME,\r\n\t\t\tfwfc,\r\n\t\t\t1,\r\n\t\t\t&FWPM_LAYER_IPFORWARD_V6,\r\n\t\t\tNULL,\r\n\t\t\tFW_WEIGHT_HIGHEST_IMPORTANT,\r\n\t\t\tFWP_ACTION_PERMIT,\r\n\t\t\tFWPM_FILTER_FLAG_BOOTTIME,\r\n\t\t\tfilter_ids\r\n\t\t);\r\n\r\n\t\t_wfp_createfilter (\r\n\t\t\tengine_handle,\r\n\t\t\tDATA_FILTER_GENERAL,\r\n\t\t\tFW_NAME_BOOTTIME,\r\n\t\t\tfwfc,\r\n\t\t\t1,\r\n\t\t\t&FWPM_LAYER_ALE_AUTH_RECV_ACCEPT_V4,\r\n\t\t\tNULL,\r\n\t\t\tFW_WEIGHT_HIGHEST_IMPORTANT,\r\n\t\t\tFWP_ACTION_PERMIT,\r\n\t\t\tFWPM_FILTER_FLAG_BOOTTIME,\r\n\t\t\tfilter_ids\r\n\t\t);\r\n\r\n\t\t_wfp_createfilter (\r\n\t\t\tengine_handle,\r\n\t\t\tDATA_FILTER_GENERAL,\r\n\t\t\tFW_NAME_BOOTTIME,\r\n\t\t\tfwfc,\r\n\t\t\t1,\r\n\t\t\t&FWPM_LAYER_ALE_AUTH_RECV_ACCEPT_V6,\r\n\t\t\tNULL,\r\n\t\t\tFW_WEIGHT_HIGHEST_IMPORTANT,\r\n\t\t\tFWP_ACTION_PERMIT,\r\n\t\t\tFWPM_FILTER_FLAG_BOOTTIME,\r\n\t\t\tfilter_ids\r\n\t\t);\r\n\r\n\t\t_wfp_createfilter (\r\n\t\t\tengine_handle,\r\n\t\t\tDATA_FILTER_GENERAL,\r\n\t\t\tFW_NAME_BOOTTIME,\r\n\t\t\tfwfc,\r\n\t\t\t1,\r\n\t\t\t&FWPM_LAYER_INBOUND_ICMP_ERROR_V4,\r\n\t\t\tNULL,\r\n\t\t\tFW_WEIGHT_HIGHEST_IMPORTANT,\r\n\t\t\tFWP_ACTION_PERMIT,\r\n\t\t\tFWPM_FILTER_FLAG_BOOTTIME,\r\n\t\t\tfilter_ids\r\n\t\t);\r\n\r\n\t\t_wfp_createfilter (\r\n\t\t\tengine_handle,\r\n\t\t\tDATA_FILTER_GENERAL,\r\n\t\t\tFW_NAME_BOOTTIME,\r\n\t\t\tfwfc,\r\n\t\t\t1,\r\n\t\t\t&FWPM_LAYER_INBOUND_ICMP_ERROR_V6,\r\n\t\t\tNULL,\r\n\t\t\tFW_WEIGHT_HIGHEST_IMPORTANT,\r\n\t\t\tFWP_ACTION_PERMIT,\r\n\t\t\tFWPM_FILTER_FLAG_BOOTTIME,\r\n\t\t\tfilter_ids\r\n\t\t);\r\n\r\n\t\t_wfp_createfilter (\r\n\t\t\tengine_handle,\r\n\t\t\tDATA_FILTER_GENERAL,\r\n\t\t\tFW_NAME_BOOTTIME,\r\n\t\t\tfwfc,\r\n\t\t\t1,\r\n\t\t\t&FWPM_LAYER_OUTBOUND_ICMP_ERROR_V4,\r\n\t\t\tNULL,\r\n\t\t\tFW_WEIGHT_HIGHEST_IMPORTANT,\r\n\t\t\tFWP_ACTION_PERMIT,\r\n\t\t\tFWPM_FILTER_FLAG_BOOTTIME,\r\n\t\t\tfilter_ids\r\n\t\t);\r\n\r\n\t\t_wfp_createfilter (\r\n\t\t\tengine_handle,\r\n\t\t\tDATA_FILTER_GENERAL,\r\n\t\t\tFW_NAME_BOOTTIME,\r\n\t\t\tfwfc,\r\n\t\t\t1,\r\n\t\t\t&FWPM_LAYER_OUTBOUND_ICMP_ERROR_V6,\r\n\t\t\tNULL,\r\n\t\t\tFW_WEIGHT_HIGHEST_IMPORTANT,\r\n\t\t\tFWP_ACTION_PERMIT,\r\n\t\t\tFWPM_FILTER_FLAG_BOOTTIME,\r\n\t\t\tfilter_ids\r\n\t\t);\r\n\r\n\t\t_wfp_createfilter (\r\n\t\t\tengine_handle,\r\n\t\t\tDATA_FILTER_GENERAL,\r\n\t\t\tFW_NAME_BOOTTIME,\r\n\t\t\tNULL,\r\n\t\t\t0,\r\n\t\t\t&FWPM_LAYER_ALE_AUTH_RECV_ACCEPT_V4,\r\n\t\t\tNULL,\r\n\t\t\tFW_WEIGHT_LOWEST,\r\n\t\t\tFWP_ACTION_BLOCK,\r\n\t\t\tFWPM_FILTER_FLAG_BOOTTIME,\r\n\t\t\tfilter_ids\r\n\t\t);\r\n\r\n\t\t_wfp_createfilter (\r\n\t\t\tengine_handle,\r\n\t\t\tDATA_FILTER_GENERAL,\r\n\t\t\tFW_NAME_BOOTTIME,\r\n\t\t\tNULL,\r\n\t\t\t0,\r\n\t\t\t&FWPM_LAYER_ALE_AUTH_RECV_ACCEPT_V6,\r\n\t\t\tNULL,\r\n\t\t\tFW_WEIGHT_LOWEST,\r\n\t\t\tFWP_ACTION_BLOCK,\r\n\t\t\tFWPM_FILTER_FLAG_BOOTTIME,\r\n\t\t\tfilter_ids\r\n\t\t);\r\n\r\n\t\t_wfp_createfilter (\r\n\t\t\tengine_handle,\r\n\t\t\tDATA_FILTER_GENERAL,\r\n\t\t\tFW_NAME_BOOTTIME,\r\n\t\t\tNULL,\r\n\t\t\t0,\r\n\t\t\t&FWPM_LAYER_INBOUND_ICMP_ERROR_V4,\r\n\t\t\tNULL,\r\n\t\t\tFW_WEIGHT_LOWEST,\r\n\t\t\tFWP_ACTION_BLOCK,\r\n\t\t\tFWPM_FILTER_FLAG_BOOTTIME,\r\n\t\t\tfilter_ids\r\n\t\t);\r\n\r\n\t\t_wfp_createfilter (\r\n\t\t\tengine_handle,\r\n\t\t\tDATA_FILTER_GENERAL,\r\n\t\t\tFW_NAME_BOOTTIME,\r\n\t\t\tNULL,\r\n\t\t\t0,\r\n\t\t\t&FWPM_LAYER_INBOUND_ICMP_ERROR_V6,\r\n\t\t\tNULL,\r\n\t\t\tFW_WEIGHT_LOWEST,\r\n\t\t\tFWP_ACTION_BLOCK,\r\n\t\t\tFWPM_FILTER_FLAG_BOOTTIME,\r\n\t\t\tfilter_ids\r\n\t\t);\r\n\r\n\t\t_wfp_createfilter (\r\n\t\t\tengine_handle,\r\n\t\t\tDATA_FILTER_GENERAL,\r\n\t\t\tFW_NAME_BOOTTIME,\r\n\t\t\tNULL,\r\n\t\t\t0,\r\n\t\t\t&FWPM_LAYER_OUTBOUND_ICMP_ERROR_V4,\r\n\t\t\tNULL,\r\n\t\t\tFW_WEIGHT_LOWEST,\r\n\t\t\tFWP_ACTION_BLOCK,\r\n\t\t\tFWPM_FILTER_FLAG_BOOTTIME,\r\n\t\t\tfilter_ids\r\n\t\t);\r\n\r\n\t\t_wfp_createfilter (\r\n\t\t\tengine_handle,\r\n\t\t\tDATA_FILTER_GENERAL,\r\n\t\t\tFW_NAME_BOOTTIME,\r\n\t\t\tNULL,\r\n\t\t\t0,\r\n\t\t\t&FWPM_LAYER_OUTBOUND_ICMP_ERROR_V6,\r\n\t\t\tNULL,\r\n\t\t\tFW_WEIGHT_LOWEST,\r\n\t\t\tFWP_ACTION_BLOCK,\r\n\t\t\tFWPM_FILTER_FLAG_BOOTTIME,\r\n\t\t\tfilter_ids\r\n\t\t);\r\n\r\n\t\t// win7+ boot-time features\r\n\t\tfwfc[0].fieldKey = FWPM_CONDITION_FLAGS;\r\n\t\tfwfc[0].matchType = FWP_MATCH_FLAGS_NONE_SET;\r\n\t\tfwfc[0].conditionValue.type = FWP_UINT32;\r\n\t\tfwfc[0].conditionValue.uint32 = FWP_CONDITION_FLAG_IS_OUTBOUND_PASS_THRU | FWP_CONDITION_FLAG_IS_INBOUND_PASS_THRU;\r\n\r\n\t\t_wfp_createfilter (\r\n\t\t\tengine_handle,\r\n\t\t\tDATA_FILTER_GENERAL,\r\n\t\t\tFW_NAME_BOOTTIME,\r\n\t\t\tfwfc,\r\n\t\t\t1,\r\n\t\t\t&FWPM_LAYER_IPFORWARD_V4,\r\n\t\t\tNULL,\r\n\t\t\tFW_WEIGHT_APP,\r\n\t\t\tFWP_ACTION_BLOCK,\r\n\t\t\tFWPM_FILTER_FLAG_BOOTTIME,\r\n\t\t\tfilter_ids\r\n\t\t);\r\n\r\n\t\t_wfp_createfilter (\r\n\t\t\tengine_handle,\r\n\t\t\tDATA_FILTER_GENERAL,\r\n\t\t\tFW_NAME_BOOTTIME,\r\n\t\t\tfwfc,\r\n\t\t\t1,\r\n\t\t\t&FWPM_LAYER_IPFORWARD_V6,\r\n\t\t\tNULL,\r\n\t\t\tFW_WEIGHT_APP,\r\n\t\t\tFWP_ACTION_BLOCK,\r\n\t\t\tFWPM_FILTER_FLAG_BOOTTIME,\r\n\t\t\tfilter_ids\r\n\t\t);\r\n\t}\r\n\r\n\taction = _r_config_getboolean (L\"BlockOutboundConnections\", TRUE, NULL) ? FWP_ACTION_BLOCK : FWP_ACTION_PERMIT;\r\n\r\n\t// block outbound connection\r\n\tif (action == FWP_ACTION_BLOCK)\r\n\t{\r\n\t\t// workaround #689\r\n\t\tif (_r_sys_isosversiongreaterorequal (WINDOWS_8))\r\n\t\t{\r\n\t\t\t_wfp_createfilter (\r\n\t\t\t\tengine_handle,\r\n\t\t\t\tDATA_FILTER_GENERAL,\r\n\t\t\t\tFW_NAME_BLOCK_CONNECTION,\r\n\t\t\t\tNULL,\r\n\t\t\t\t0,\r\n\t\t\t\t&FWPM_LAYER_ALE_AUTH_CONNECT_V4,\r\n\t\t\t\t&FWPM_CALLOUT_TCP_TEMPLATES_CONNECT_LAYER_V4,\r\n\t\t\t\tFW_WEIGHT_LOWEST,\r\n\t\t\t\tFWP_ACTION_CALLOUT_TERMINATING,\r\n\t\t\t\t0,\r\n\t\t\t\tfilter_ids\r\n\t\t\t);\r\n\r\n\t\t\t_wfp_createfilter (\r\n\t\t\t\tengine_handle,\r\n\t\t\t\tDATA_FILTER_GENERAL,\r\n\t\t\t\tFW_NAME_BLOCK_CONNECTION,\r\n\t\t\t\tNULL,\r\n\t\t\t\t0,\r\n\t\t\t\t&FWPM_LAYER_ALE_AUTH_CONNECT_V6,\r\n\t\t\t\t&FWPM_CALLOUT_TCP_TEMPLATES_CONNECT_LAYER_V6,\r\n\t\t\t\tFW_WEIGHT_LOWEST,\r\n\t\t\t\tFWP_ACTION_CALLOUT_TERMINATING,\r\n\t\t\t\t0,\r\n\t\t\t\tfilter_ids\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n\r\n\t// fallback\r\n\t_wfp_createfilter (\r\n\t\tengine_handle,\r\n\t\tDATA_FILTER_GENERAL,\r\n\t\tFW_NAME_BLOCK_CONNECTION,\r\n\t\tNULL,\r\n\t\t0,\r\n\t\t&FWPM_LAYER_ALE_AUTH_CONNECT_V4,\r\n\t\tNULL,\r\n\t\tFW_WEIGHT_LOWEST,\r\n\t\taction,\r\n\t\t0,\r\n\t\tfilter_ids\r\n\t);\r\n\r\n\t_wfp_createfilter (\r\n\t\tengine_handle,\r\n\t\tDATA_FILTER_GENERAL,\r\n\t\tFW_NAME_BLOCK_CONNECTION,\r\n\t\tNULL,\r\n\t\t0,\r\n\t\t&FWPM_LAYER_ALE_AUTH_CONNECT_V6,\r\n\t\tNULL,\r\n\t\tFW_WEIGHT_LOWEST,\r\n\t\taction,\r\n\t\t0,\r\n\t\tfilter_ids\r\n\t);\r\n\r\n\t// block inbound connections\r\n\tif (_r_config_getboolean (L\"UseStealthMode\", TRUE, NULL) || _r_config_getboolean (L\"BlockInboundConnections\", TRUE, NULL))\r\n\t{\r\n\t\taction = FWP_ACTION_BLOCK;\r\n\t}\r\n\telse\r\n\t{\r\n\t\taction = FWP_ACTION_PERMIT;\r\n\t}\r\n\r\n\t_wfp_createfilter (\r\n\t\tengine_handle,\r\n\t\tDATA_FILTER_GENERAL,\r\n\t\tFW_NAME_BLOCK_RECVACCEPT,\r\n\t\tNULL,\r\n\t\t0,\r\n\t\t&FWPM_LAYER_ALE_AUTH_RECV_ACCEPT_V4,\r\n\t\tNULL,\r\n\t\tFW_WEIGHT_LOWEST,\r\n\t\taction,\r\n\t\t0,\r\n\t\tfilter_ids\r\n\t);\r\n\r\n\t_wfp_createfilter (\r\n\t\tengine_handle,\r\n\t\tDATA_FILTER_GENERAL,\r\n\t\tFW_NAME_BLOCK_RECVACCEPT,\r\n\t\tNULL,\r\n\t\t0,\r\n\t\t&FWPM_LAYER_ALE_AUTH_RECV_ACCEPT_V6,\r\n\t\tNULL,\r\n\t\tFW_WEIGHT_LOWEST,\r\n\t\taction,\r\n\t\t0,\r\n\t\tfilter_ids\r\n\t);\r\n\r\n\tif (!is_intransact)\r\n\t{\r\n\t\t_wfp_transact_commit (engine_handle, DBG_ARG_VAR);\r\n\r\n\t\tfor (ULONG_PTR i = 0; i < _r_obj_getarraysize (filter_ids); i++)\r\n\t\t{\r\n\t\t\tguid = (LPGUID)_r_obj_getarrayitem (filter_ids, i);\r\n\r\n\t\t\tif (guid)\r\n\t\t\t\t_app_setfiltersecurity (engine_handle, guid, TRUE, DBG_ARG_VAR);\r\n\t\t}\r\n\r\n\t\t_r_queuedlock_releaseshared (&lock_transaction);\r\n\t}\r\n\r\n\t_app_restoreinterfacestate (_r_app_gethwnd (), is_enabled);\r\n\r\n\treturn TRUE;\r\n}\r\n\r\n_Success_ (return == ERROR_SUCCESS)\r\nULONG _wfp_dumpcallouts (\r\n\t_In_ HANDLE engine_handle,\r\n\t_In_ LPCGUID provider_id,\r\n\t_Outptr_ PR_ARRAY_PTR out_buffer\r\n)\r\n{\r\n\tFWPM_CALLOUT0 **callouts_enum = NULL;\r\n\tFWPM_CALLOUT0 *callout;\r\n\tPR_ARRAY guids = NULL;\r\n\tHANDLE enum_handle = NULL;\r\n\tUINT32 return_count;\r\n\tULONG status;\r\n\r\n\t*out_buffer = NULL;\r\n\r\n\tstatus = FwpmCalloutCreateEnumHandle0 (engine_handle, NULL, &enum_handle);\r\n\r\n\tif (status != ERROR_SUCCESS)\r\n\t\treturn status;\r\n\r\n\tstatus = FwpmCalloutEnum0 (engine_handle, enum_handle, UINT32_MAX, &callouts_enum, &return_count);\r\n\r\n\tif (status != ERROR_SUCCESS)\r\n\t\tgoto CleanupExit;\r\n\r\n\tif (!callouts_enum)\r\n\t{\r\n\t\tstatus = ERROR_NOT_FOUND;\r\n\r\n\t\tgoto CleanupExit;\r\n\t}\r\n\r\n\tguids = _r_obj_createarray (sizeof (GUID), return_count, NULL);\r\n\r\n\tfor (UINT32 i = 0; i < return_count; i++)\r\n\t{\r\n\t\tcallout = callouts_enum[i];\r\n\r\n\t\tif (!callout || !callout->providerKey)\r\n\t\t\tcontinue;\r\n\r\n\t\tif (IsEqualGUID (callout->providerKey, provider_id))\r\n\t\t\t_r_obj_addarrayitem (guids, &callout->calloutKey, NULL);\r\n\t}\r\n\r\n\tif (_r_obj_isempty2 (guids))\r\n\t\tstatus = ERROR_NOT_FOUND;\r\n\r\nCleanupExit:\r\n\r\n\tif (status == ERROR_SUCCESS)\r\n\t{\r\n\t\t*out_buffer = guids;\r\n\t}\r\n\telse\r\n\t{\r\n\t\tif (guids)\r\n\t\t\t_r_obj_dereference (guids);\r\n\t}\r\n\r\n\tif (enum_handle)\r\n\t\tFwpmCalloutDestroyEnumHandle0 (engine_handle, enum_handle);\r\n\r\n\tif (callouts_enum)\r\n\t\tFwpmFreeMemory0 ((PVOID_PTR)&callouts_enum);\r\n\r\n\treturn status;\r\n}\r\n\r\n_Success_ (return == ERROR_SUCCESS)\r\nULONG _wfp_dumpfilters (\r\n\t_In_ HANDLE engine_handle,\r\n\t_In_ LPCGUID provider_id,\r\n\t_Outptr_ PR_ARRAY_PTR out_buffer\r\n)\r\n{\r\n\tFWPM_FILTER0 **filters_enum = NULL;\r\n\tFWPM_FILTER0 *filter;\r\n\tPR_ARRAY guids = NULL;\r\n\tHANDLE enum_handle = NULL;\r\n\tUINT32 return_count;\r\n\tULONG status;\r\n\r\n\t*out_buffer = NULL;\r\n\r\n\tstatus = FwpmFilterCreateEnumHandle0 (engine_handle, NULL, &enum_handle);\r\n\r\n\tif (status != ERROR_SUCCESS)\r\n\t\treturn status;\r\n\r\n\tstatus = FwpmFilterEnum0 (engine_handle, enum_handle, UINT32_MAX, &filters_enum, &return_count);\r\n\r\n\tif (status != ERROR_SUCCESS)\r\n\t\tgoto CleanupExit;\r\n\r\n\tif (!filters_enum)\r\n\t{\r\n\t\tstatus = ERROR_NOT_FOUND;\r\n\r\n\t\tgoto CleanupExit;\r\n\t}\r\n\r\n\tguids = _r_obj_createarray (sizeof (GUID), return_count, NULL);\r\n\r\n\tfor (UINT32 i = 0; i < return_count; i++)\r\n\t{\r\n\t\tfilter = filters_enum[i];\r\n\r\n\t\tif (!filter || !filter->providerKey)\r\n\t\t\tcontinue;\r\n\r\n\t\tif (IsEqualGUID (filter->providerKey, provider_id))\r\n\t\t\t_r_obj_addarrayitem (guids, &filter->filterKey, NULL);\r\n\t}\r\n\r\n\tif (_r_obj_isempty2 (guids))\r\n\t{\r\n\t\tstatus = ERROR_NOT_FOUND;\r\n\r\n\t\t_r_obj_dereference (guids);\r\n\t}\r\n\r\nCleanupExit:\r\n\r\n\tif (status == ERROR_SUCCESS)\r\n\t\t*out_buffer = guids;\r\n\r\n\tif (enum_handle)\r\n\t\tFwpmFilterDestroyEnumHandle0 (engine_handle, enum_handle);\r\n\r\n\tif (filters_enum)\r\n\t\tFwpmFreeMemory0 ((PVOID_PTR)&filters_enum);\r\n\r\n\treturn status;\r\n}\r\n\r\nVOID NTAPI _wfp_applythread (\r\n\t_In_ PVOID arglist\r\n)\r\n{\r\n\tPITEM_CONTEXT context;\r\n\tHANDLE engine_handle;\r\n\tLONG dpi_value;\r\n\r\n\t_r_queuedlock_acquireshared (&lock_apply);\r\n\r\n\tcontext = (PITEM_CONTEXT)arglist;\r\n\tengine_handle = _wfp_getenginehandle ();\r\n\r\n\t// dropped packets logging (win7+)\r\n\tif (config.is_neteventset)\r\n\t\t_wfp_logunsubscribe (engine_handle);\r\n\r\n\tif (context->is_install)\r\n\t{\r\n\t\tif (_wfp_initialize (context->hwnd, engine_handle))\r\n\t\t\t_wfp_installfilters (engine_handle);\r\n\t}\r\n\telse\r\n\t{\r\n\t\tif (_r_sys_isosversiongreaterorequal (WINDOWS_10))\r\n\t\t\t_app_wufixenable (context->hwnd, FALSE);\r\n\r\n\t\t_wfp_destroyfilters (engine_handle);\r\n\t\t_wfp_uninitialize (engine_handle, TRUE);\r\n\t}\r\n\r\n\t// dropped packets logging (win7+)\r\n\tif (config.is_neteventset)\r\n\t\t_wfp_logsubscribe (context->hwnd, engine_handle);\r\n\r\n\tif (_r_sys_isosversiongreaterorequal (WINDOWS_10))\r\n\t\t_app_wufixenable (context->hwnd, _r_config_getboolean (L\"IsWUFixEnabled\", FALSE, NULL));\r\n\r\n\tdpi_value = _r_dc_getwindowdpi (context->hwnd);\r\n\r\n\t_app_restoreinterfacestate (context->hwnd, TRUE);\r\n\t_app_setinterfacestate (context->hwnd, dpi_value);\r\n\r\n\t_r_freelist_deleteitem (&context_free_list, context);\r\n\r\n\t_app_profile_save (context->hwnd);\r\n\r\n\t_r_queuedlock_releaseshared (&lock_apply);\r\n}\r\n\r\nVOID _wfp_firewallenable (\r\n\t_In_ BOOLEAN is_enable\r\n)\r\n{\r\n\tNET_FW_PROFILE_TYPE2 profile_types[] = {\r\n\t\tNET_FW_PROFILE2_DOMAIN,\r\n\t\tNET_FW_PROFILE2_PRIVATE,\r\n\t\tNET_FW_PROFILE2_PUBLIC\r\n\t};\r\n\r\n\tINetFwPolicy2 *INetFwPolicy = NULL;\r\n\tHRESULT status;\r\n\r\n\tstatus = CoCreateInstance (&CLSID_NetFwPolicy2, NULL, CLSCTX_INPROC_SERVER, &IID_INetFwPolicy2, (PVOID_PTR)&INetFwPolicy);\r\n\r\n\tif (FAILED (status))\r\n\t\treturn;\r\n\r\n\tfor (ULONG_PTR i = 0; i < RTL_NUMBER_OF (profile_types); i++)\r\n\t{\r\n\t\tstatus = INetFwPolicy2_put_FirewallEnabled (INetFwPolicy, profile_types[i], is_enable ? VARIANT_TRUE : VARIANT_FALSE);\r\n\r\n\t\tif (FAILED (status))\r\n\t\t\t_r_log_v (LOG_LEVEL_INFO, NULL, L\"INetFwPolicy2_put_FirewallEnabled\", status, L\"%d\", profile_types[i]);\r\n\t}\r\n\r\n\tINetFwPolicy2_Release (INetFwPolicy);\r\n}\r\n\r\nBOOLEAN _wfp_firewallisenabled ()\r\n{\r\n\tNET_FW_PROFILE_TYPE2 profile_types[] = {\r\n\t\tNET_FW_PROFILE2_DOMAIN,\r\n\t\tNET_FW_PROFILE2_PRIVATE,\r\n\t\tNET_FW_PROFILE2_PUBLIC\r\n\t};\r\n\r\n\tINetFwPolicy2 *INetFwPolicy = NULL;\r\n\tVARIANT_BOOL result = VARIANT_FALSE;\r\n\tHRESULT status;\r\n\r\n\tstatus = CoCreateInstance (&CLSID_NetFwPolicy2, NULL, CLSCTX_INPROC_SERVER, &IID_INetFwPolicy2, (PVOID_PTR)&INetFwPolicy);\r\n\r\n\tif (SUCCEEDED (status))\r\n\t{\r\n\t\tfor (ULONG_PTR i = 0; i < RTL_NUMBER_OF (profile_types); i++)\r\n\t\t{\r\n\t\t\tstatus = INetFwPolicy2_get_FirewallEnabled (INetFwPolicy, profile_types[i], &result);\r\n\r\n\t\t\tif (SUCCEEDED (status))\r\n\t\t\t{\r\n\t\t\t\tif (result == VARIANT_TRUE)\r\n\t\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tINetFwPolicy2_Release (INetFwPolicy);\r\n\t}\r\n\r\n\tif (result == VARIANT_TRUE)\r\n\t\treturn TRUE;\r\n\r\n\treturn FALSE;\r\n}\r\n\r\n_Success_ (NT_SUCCESS (return))\r\nNTSTATUS _FwpmGetAppIdFromFileName1 (\r\n\t_In_ PR_STRING path,\r\n\t_In_ ENUM_TYPE_DATA type,\r\n\t_Out_ PVOID_PTR byte_blob\r\n)\r\n{\r\n\tR_STRINGREF path_skip_root;\r\n\tPR_STRING original_path;\r\n\tPR_STRING path_root;\r\n\tNTSTATUS status;\r\n\r\n\t*byte_blob = NULL;\r\n\r\n\tif (type == DATA_APP_REGULAR || type == DATA_APP_NETWORK || type == DATA_APP_SERVICE)\r\n\t{\r\n\t\tif (_r_str_gethash (&path->sr, TRUE) == config.ntoskrnl_hash)\r\n\t\t{\r\n\t\t\tByteBlobAlloc (path->buffer, path->length + sizeof (UNICODE_NULL), byte_blob);\r\n\r\n\t\t\treturn STATUS_SUCCESS;\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tstatus = _r_path_ntpathfromdos (&path->sr, TRUE, &original_path);\r\n\r\n\t\t\tif (!NT_SUCCESS (status))\r\n\t\t\t{\r\n\t\t\t\t// file is inaccessible or not found, maybe low-level\r\n\t\t\t\t// driver preventing file access? try another way!\r\n\t\t\t\tif (status == STATUS_OBJECT_NAME_NOT_FOUND || status == STATUS_FILE_IS_A_DIRECTORY || status == STATUS_ACCESS_DENIED)\r\n\t\t\t\t{\r\n\t\t\t\t\tif (!_app_isappvalidpath (path))\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\treturn status;\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t// file path (without root)\r\n\t\t\t\t\t\tpath_root = _r_obj_createstring2 (&path->sr);\r\n\r\n\t\t\t\t\t\tPathStripToRootW (path_root->buffer);\r\n\r\n\t\t\t\t\t\t_r_str_trimtonullterminator (&path_root->sr);\r\n\r\n\t\t\t\t\t\tstatus = _r_path_ntpathfromdos (&path_root->sr, FALSE, &original_path);\r\n\r\n\t\t\t\t\t\tif (!NT_SUCCESS (status))\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t_r_obj_dereference (path_root);\r\n\r\n\t\t\t\t\t\t\treturn status;\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t// file path (without root)\r\n\t\t\t\t\t\t_r_obj_initializestringref (&path_skip_root, PathSkipRootW (path->buffer));\r\n\r\n\t\t\t\t\t\t_r_obj_movereference ((PVOID_PTR)&original_path, _r_obj_concatstringrefs (2, &original_path->sr, &path_skip_root));\r\n\r\n\t\t\t\t\t\t_r_str_tolower (&original_path->sr); // lower is important!\r\n\r\n\t\t\t\t\t\t_r_obj_dereference (path_root);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\treturn status;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tByteBlobAlloc (original_path->buffer, original_path->length + sizeof (UNICODE_NULL), byte_blob);\r\n\r\n\t\t\t_r_obj_dereference (original_path);\r\n\r\n\t\t\treturn STATUS_SUCCESS;\r\n\t\t}\r\n\t}\r\n\telse if (type == DATA_APP_PICO || type == DATA_APP_DEVICE)\r\n\t{\r\n\t\toriginal_path = _r_obj_createstring2 (&path->sr);\r\n\r\n\t\tif (type == DATA_APP_DEVICE)\r\n\t\t\t_r_str_tolower (&original_path->sr); // lower is important!\r\n\r\n\t\tByteBlobAlloc (original_path->buffer, original_path->length + sizeof (UNICODE_NULL), byte_blob);\r\n\r\n\t\t_r_obj_dereference (original_path);\r\n\r\n\t\treturn STATUS_SUCCESS;\r\n\t}\r\n\r\n\treturn STATUS_FILE_NOT_AVAILABLE;\r\n}\r\n\r\nVOID ByteBlobAlloc (\r\n\t_In_ LPCVOID data,\r\n\t_In_ ULONG_PTR bytes_count,\r\n\t_Out_ PVOID_PTR byte_blob\r\n)\r\n{\r\n\tFWP_BYTE_BLOB *blob;\r\n\r\n\tblob = _r_mem_allocate (sizeof (FWP_BYTE_BLOB) + bytes_count);\r\n\r\n\tblob->size = (UINT)(UINT_PTR)bytes_count;\r\n\tblob->data = PTR_ADD_OFFSET (blob, sizeof (FWP_BYTE_BLOB));\r\n\r\n\tRtlCopyMemory (blob->data, data, bytes_count);\r\n\r\n\t*byte_blob = blob;\r\n}\r\n\r\nVOID ByteBlobFree (\r\n\t_Inout_ PVOID_PTR byte_blob\r\n)\r\n{\r\n\tFWP_BYTE_BLOB *original_blob;\r\n\r\n\toriginal_blob = *byte_blob;\r\n\t*byte_blob = NULL;\r\n\r\n\tif (original_blob)\r\n\t\t_r_mem_free (original_blob);\r\n}\r\n"
  },
  {
    "path": "src/wfp.h",
    "content": "// simplewall\r\n// Copyright (c) 2016-2026 Henry++\r\n\r\n#pragma once\r\n\r\n// guids\r\nDEFINE_GUID (GUID_WfpProvider, 0xB0D553E2, 0xC6A0, 0x4A9A, 0xAE, 0xB8, 0xC7, 0x52, 0x48, 0x3E, 0xD6, 0x2F);\r\nDEFINE_GUID (GUID_WfpSublayer, 0x9FEE6F59, 0xB951, 0x4F9A, 0xB5, 0x2F, 0x13, 0x3D, 0xCF, 0x7A, 0x42, 0x79);\r\n\r\n// filter names\r\n#define FW_NAME_BLOCK_CONNECTION L\"BlockConnection\"\r\n#define FW_NAME_BLOCK_RECVACCEPT L\"BlockRecvAccept\"\r\n#define FW_NAME_ICMP_ERROR L\"BlockIcmpError\"\r\n#define FW_NAME_TCP_RST_ONCLOSE L\"BlockTcpRstOnClose\"\r\n#define FW_NAME_BOOTTIME L\"BlockBoottime\"\r\n#define FW_NAME_LOOPBACK L\"AllowLoopback\"\r\n\r\n// sublayer weight\r\n#define FW_SUBLAYER_WEIGHT 0xFFFF\r\n\r\n// filter weights\r\n#define FW_WEIGHT_HIGHEST_IMPORTANT 0x0F\r\n#define FW_WEIGHT_HIGHEST 0x0E\r\n#define FW_WEIGHT_RULE_BLOCKLIST 0x0D\r\n#define FW_WEIGHT_RULE_USER_BLOCK 0x0C\r\n#define FW_WEIGHT_RULE_USER 0x0B\r\n#define FW_WEIGHT_RULE_SYSTEM 0x0A\r\n#define FW_WEIGHT_APP 0x09\r\n#define FW_WEIGHT_LOWEST 0x08\r\n\r\nENUM_INSTALL_TYPE _wfp_isproviderinstalled (\r\n\t_In_ HANDLE engine_handle\r\n);\r\n\r\nENUM_INSTALL_TYPE _wfp_issublayerinstalled (\r\n\t_In_ HANDLE engine_handle\r\n);\r\n\r\nBOOLEAN _wfp_isfiltersapplying ();\r\n\r\nBOOLEAN _wfp_isfiltersinstalled ();\r\n\r\nHANDLE _wfp_getenginehandle ();\r\n\r\nENUM_INSTALL_TYPE _wfp_getinstalltype ();\r\n\r\nPR_STRING _wfp_getlayername (\r\n\t_In_ LPGUID layer_guid\r\n);\r\n\r\nBOOLEAN _wfp_initialize (\r\n\t_In_opt_ HWND hwnd,\r\n\t_In_ HANDLE engine_handle\r\n);\r\n\r\nVOID _wfp_uninitialize (\r\n\t_In_ HANDLE engine_handle,\r\n\t_In_ BOOLEAN is_full\r\n);\r\n\r\nVOID _wfp_installfilters (\r\n\t_In_ HANDLE engine_handle\r\n);\r\n\r\nBOOLEAN _wfp_transact_start (\r\n\t_In_ HANDLE engine_handle,\r\n\t_In_ LPCWSTR file_name,\r\n\t_In_ ULONG line\r\n);\r\n\r\nBOOLEAN _wfp_transact_commit (\r\n\t_In_ HANDLE engine_handle,\r\n\t_In_ LPCWSTR file_name,\r\n\t_In_ ULONG line\r\n);\r\n\r\nULONG _wfp_createcallout (\r\n\t_In_ HANDLE engine_handle,\r\n\t_In_ LPCGUID layer_key,\r\n\t_In_ LPCGUID callout_key\r\n);\r\n\r\nBOOLEAN _wfp_deletefilter (\r\n\t_In_ HANDLE engine_handle,\r\n\t_In_ LPGUID filter_id\r\n);\r\n\r\nULONG _wfp_createfilter (\r\n\t_In_ HANDLE engine_handle,\r\n\t_In_ ENUM_TYPE_DATA type,\r\n\t_In_opt_ LPCWSTR filter_name,\r\n\t_In_reads_ (count) FWPM_FILTER_CONDITION0 *lpcond,\r\n\t_In_ UINT32 count,\r\n\t_In_ LPCGUID layer_id,\r\n\t_In_opt_ LPCGUID callout_id,\r\n\t_In_ UINT8 weight,\r\n\t_In_ FWP_ACTION_TYPE action,\r\n\t_In_ UINT32 flags,\r\n\t_Inout_opt_ PR_ARRAY guids\r\n);\r\n\r\nVOID _wfp_clearfilter_ids ();\r\n\r\nVOID _wfp_destroyfilters (\r\n\t_In_ HANDLE engine_handle\r\n);\r\n\r\nVOID _wfp_destroyfilters_array (\r\n\t_In_ HANDLE engine_handle,\r\n\t_In_ PR_ARRAY guids,\r\n\t_In_ LPCWSTR file_name,\r\n\t_In_ ULONG line\r\n);\r\n\r\nBOOLEAN _wfp_createrulefilter (\r\n\t_In_ HANDLE engine_handle,\r\n\t_In_ ENUM_TYPE_DATA filter_type,\r\n\t_In_opt_ LPCWSTR filter_name,\r\n\t_In_opt_ ULONG app_hash,\r\n\t_In_opt_ PITEM_FILTER_CONFIG filter_config,\r\n\t_In_opt_ PR_STRINGREF rule_remote,\r\n\t_In_opt_ PR_STRINGREF rule_local,\r\n\t_In_ UINT8 weight,\r\n\t_In_ FWP_ACTION_TYPE action,\r\n\t_In_ UINT32 flags,\r\n\t_Inout_opt_ PR_ARRAY guids\r\n);\r\n\r\nBOOLEAN _wfp_create4filters (\r\n\t_In_ HANDLE engine_handle,\r\n\t_In_ PR_LIST rules,\r\n\t_In_ LPCWSTR file_name,\r\n\t_In_ ULONG line,\r\n\t_In_ BOOLEAN is_intransact\r\n);\r\n\r\nBOOLEAN _wfp_create3filters (\r\n\t_In_ HANDLE engine_handle,\r\n\t_In_ PR_LIST rules,\r\n\t_In_ LPCWSTR file_name,\r\n\t_In_ ULONG line,\r\n\t_In_ BOOLEAN is_intransact\r\n);\r\n\r\nBOOLEAN _wfp_create2filters (\r\n\t_In_ HANDLE engine_handle,\r\n\t_In_ LPCWSTR file_name,\r\n\t_In_ ULONG line,\r\n\t_In_ BOOLEAN is_intransact\r\n);\r\n\r\n_Success_ (return == ERROR_SUCCESS)\r\nULONG _wfp_dumpcallouts (\r\n\t_In_ HANDLE engine_handle,\r\n\t_In_ LPCGUID provider_id,\r\n\t_Outptr_ PR_ARRAY_PTR out_buffer\r\n);\r\n\r\n_Success_ (return == ERROR_SUCCESS)\r\nULONG _wfp_dumpfilters (\r\n\t_In_ HANDLE engine_handle,\r\n\t_In_ LPCGUID provider_id,\r\n\t_Outptr_ PR_ARRAY_PTR out_buffer\r\n);\r\n\r\nVOID NTAPI _wfp_applythread (\r\n\t_In_ PVOID arglist\r\n);\r\n\r\nVOID _wfp_firewallenable (\r\n\t_In_ BOOLEAN is_enable\r\n);\r\n\r\nBOOLEAN _wfp_firewallisenabled ();\r\n\r\n_Success_ (NT_SUCCESS (return))\r\nNTSTATUS _FwpmGetAppIdFromFileName1 (\r\n\t_In_ PR_STRING path,\r\n\t_In_ ENUM_TYPE_DATA type,\r\n\t_Out_ PVOID_PTR byte_blob\r\n);\r\n\r\nVOID ByteBlobAlloc (\r\n\t_In_ LPCVOID data,\r\n\t_In_ ULONG_PTR bytes_count,\r\n\t_Out_ PVOID_PTR byte_blob\r\n);\r\n\r\nVOID ByteBlobFree (\r\n\t_Inout_ PVOID_PTR byte_blob\r\n);\r\n"
  }
]