#include "hook.hpp" #include #include #include #include #include #include #include #include #include #include "Zydis.h" std::unordered_map g_features = { // Available with Plex Pass { "c9d9b7ee-fdd9-474e-b143-5039c04e9b9b", "guided-upgrade" }, { "9e93f8a8-7ccd-4d15-99fa-76a158027660", "increase-password-complexity" }, { "547514ab-3284-46e5-af77-bbaff247e3fc", "upgrade-3ds2" }, { "3ae06d3a-a76b-435e-8cef-2d2008610ba2", "ad-countdown-timer" }, { "abd37b14-706c-461f-8255-fa9563882af3", "adaptive_bitrate" }, { "d1477307-4dac-4e57-9258-252e5b908693", "amazon-loop-debug" }, { "b227c158-e062-4ff1-95d8-8ed11cecafb1", "Android - Dolby Vision" }, { "86da2200-58db-4d78-ba46-f146ba25906b", "Android - PiP" }, { "2797e341-b062-46ed-862f-0acbba5dd522", "artist-tv" }, { "c987122a-a796-432f-af00-953821c127bb", "avod-ad-analysis" }, { "e703655b-ee05-4e24-97e3-a138da62c425", "avod-new-media" }, { "bec2ba97-4b25-472b-9cfc-674f5c68c2ae", "blacklist_get_signin" }, { "b3b87f19-5ccd-4b14-bb62-b9d7b982392e", "blacklist-subnets" }, { "6aaaf4fc-c55f-4042-92c8-b35f7886d249", "bypass-web-navbar-upsell-modal" }, { "fb34e64d-cd89-47b8-8bae-a6d20c542bae", "camera_upload" }, { "567033ef-ffee-44fb-8f90-f678077445f9", "CU Sunset" }, { "58829fc9-26b8-41f4-a6c0-90ea7a11ae24", "chromecast-music-mp" }, { "6ab6677b-ad9b-444f-9ca1-b8027d05b3e1", "client-non-destructive-comskip" }, { "5b6190a9-77a4-477e-9fbc-c8118e35a4c1", "client-radio-stations" }, { "65152b75-13a9-408a-bd30-dbd23a259183", "cloudsync" }, { "b25b878c-4f60-4337-9f6b-2d97ef41d036", "cloudflare-turnstile-required" }, { "c4704b28-4e26-460a-bf2e-2576d0c2cb77", "community-new-user-onboarding" }, { "7bb1ed71-a0a3-4362-aa08-7c3fa7241578", "community-friendships-management" }, { "fc3e8322-5e6e-4f4a-9d71-728c6d5656bd", "community-phase0" }, { "a852775a-2b74-4624-aaa3-3d624471a537", "community-phase0-web" }, { "6272ad55-9fc0-43c6-8e1a-3f0df7a3630e", "community-p1" }, { "31fcbe1f-0459-42cb-a15f-5084f62374d9", "community-p2-r1" }, { "06798ab7-4fa5-4416-9db3-f313c4292f01", "community-p2-r2" }, { "626004b8-a8b8-4fb1-9adc-8a6277f98597", "community-p2-r3" }, { "8f47a689-aa84-408f-bf6b-00015e9413e1", "community-p2-r4" }, { "7f46bf17-fabf-4f96-99a2-cf374f6eed71", "comments_and_replies_push_notifications" }, { "c36a6985-eee3-4400-a394-c5787fad15b5", "friend_request_push_notifications" }, { "3f6baa76-7488-479a-9e4f-49ff2c0d3711", "community_access_plex_tv" }, { "24b4cf36-b296-4002-86b7-f1adb657e76a", "companions_sonos" }, { "32cc8bf5-b425-4582-a52d-71b4f1cf436b", "content_filter" }, { "f6a0e423-1a83-418c-8448-a1c7105fd71a", "create_anonymous_users" }, { "926bc176-58ca-47da-b8e3-080ed14ea6ba", "credits-markers" }, { "849433b0-ef60-4a71-9dd9-939bc01f5362", "custom-home-removal" }, { "7ee1495c-2798-4288-94e2-9cd98e67d441", "grandfather-sync" }, { "d29f0ee0-3d3a-46c3-b582-4bc69bc17c29", "disable_home_user_friendships" }, { "ce8f644e-87ce-4ba5-b165-fadd69778019", "disable_sharing_friendships" }, { "6225c337-cd26-4ff0-b864-6c6dd84c9e0d", "disco-reported-issues" }, { "d865f64a-ca06-472d-ae01-7a444aba6251", "disco-director-cast-crew-updates" }, { "e9cc7ec1-be5a-4727-af7b-0f107af1a07c", "disco-epg-airings-on-detail-pages" }, { "2131d3dc-56c8-45d0-acec-c4683fd9a027", "discover-genre-browsing" }, { "cb0e4c75-b1cb-43e9-97ea-6b9bc66c717b", "discover-managed-related-vod" }, { "807d9881-a846-40c3-8d54-84fc490b7ba9", "discover-managed-user-test" }, { "ba7c4a4f-a13b-4ec0-8eb2-cd0ba2fe77f8", "discover-services-hub" }, { "67c80530-eae3-4500-a9fa-9b6947d0f6d1", "Sync v3" }, { "3bfd3ccf-8c63-4dbb-8f87-9b21b402c82b", "downloads-gating" }, { "34e182bd-2f62-4678-a9e9-d13b3e25019d", "drm_support" }, { "e8230c74-0940-4b91-9e20-6571eb068086", "dvr" }, { "c92d4903-bc06-4715-8ce4-4a22674abac8", "dvr-block-unsupported-countries" }, { "af291e9e-813f-4467-8779-5d215abc3b5f", "le_isrg_root_x1" }, { "9c982beb-c676-4d6f-a777-ff5d37ec3081", "epg-recent-channels" }, { "5d819d02-5d04-4116-8eec-f49def4e2d6f", "federated-auth" }, { "4742780c-af9d-4b44-bf5b-7b27e3369aa8", "global-continue-watching" }, { "84a754b0-d1ca-4433-af2d-c949bf4b4936", "hwtranscode" }, { "bc8d1fca-deb0-4d0a-a6f4-12cfd681002d", "hardware_transcoding" }, { "b2403ac6-4885-4971-8b96-59353fd87c72", "home" }, { "f1ac7a53-c524-4311-9a27-713562fc24fa", "HRK_enable_EUR" }, { "c6ce2260-a19d-4fea-9f74-a52231f03924", "hybrid-guide" }, { "55b9f6ed-5d26-4d2d-a436-68882a9901b5", "imagga-v2" }, { "b83c8dc9-5a01-4b7a-a7c9-5870c8a6e21b", "intro-markers" }, { "39dbdd84-8339-4736-96a1-0eb105cc2e08", "ios14-privacy-banner" }, { "b58d7f28-7b4a-49bb-97a7-152645505f28", "item_clusters" }, { "81c8d5fa-8d90-4833-aa10-a31a51310e2f", "iterable-notification-tokens" }, { "e4a9fd6f-4105-476b-bc57-adccd009323b", "keep-payment-method" }, { "c7ae6f8f-05e6-48bb-9024-c05c1dc3c43e", "kevin-bacon" }, { "cb151c05-1943-408a-b37c-06f7d409d6bb", "korea-consent" }, { "8536058d-e1dd-4ae7-b30f-e8b059b7cc17", "lets_encrypt" }, { "6b85840c-d79d-40c2-8d8f-dfc0b7d26776", "lightning-dvr-pivot" }, { "65685ff8-4375-4e4c-a806-ec1f0b4a8b7f", "livetv" }, { "de789b83-9c5e-4472-bccf-791c69e67500", "livetv-platform-specific" }, { "d8810b38-ec9b-494c-8555-3df6e365dfbd", "allow_dvr" }, { "9eaa5152-320b-48e6-9d47-9492ba5e5b54", "live-tv-channels-grid" }, { "d1b1e233-a891-45e5-935c-6114e905dbe8", "live-tv-grid-pagination" }, { "dab501df-5d99-48ef-afc2-3e839e4ddc9a", "live-tv-support-incomplete-segments" }, { "4b522f91-ae89-4f62-af9c-76f44d8ef61c", "tuner-sharing" }, { "0b8bf267-1acf-4f89-99eb-4afbb9d250e5", "live-tv-on-plex-subtitles" }, { "002c9f1a-2fc0-4812-b85b-0e6140f21a0f", "lyrics" }, { "7ab197ee-1bd6-4335-8f55-db827f0110ba", "media-access-split-2" }, { "4a933f24-464d-4a6b-b372-9e4497abd361", "discover" }, { "dbab9396-78ff-48f5-a5ce-c76539ed1b6e", "cloud-livetv" }, { "22b27e12-472e-4383-92ea-2ec3976d8e72", "metadata_search" }, { "f8ea4f37-c554-476a-8852-1cbd2912f3f6", "metadata" }, { "8e8dd5c8-14a4-4208-97d4-623e09191774", "music_preview" }, { "e7cea823-02e5-48c4-a501-d37b82bf132f", "music" }, { "1841971c-6be5-40e6-a211-7e189d767a78", "podcasts" }, { "68747f3a-ce13-46ce-9274-1e0544c9f500", "vod_cloudflare" }, { "ed374ad1-1d36-4396-8794-f710011e4fed", "vod_subtitles" }, { "50a1cfe9-dac1-4722-aee8-cc22e9758dd6", "tunefind-vod" }, { "cc9bea3b-11ab-4402-a222-4958bb129cab", "vod" }, { "55e1398c-930f-41c1-bead-f5c2e471bb25", "webshows" }, { "1844737f-1a87-45c3-ab20-01435959e63c", "music_videos" }, { "de65add8-2782-4bb8-b156-e0b57a844479", "new_plex_pass_prices" }, { "b77e6744-c18d-415a-8e7c-7aac5d7a7750", "news-provider-sunset-modal" }, { "0de6151c-e0dd-47c8-a81e-1acb977c7f0f", "nominatim" }, { "3dd35df0-3e4a-4e74-9ba8-2baeda83a733", "nonAnonymousAccount" }, { "5dc82bc9-6038-4c21-b752-bc3454773eda", "onboarding-community" }, { "73d0bba4-a6ba-4114-bac3-3039c12e08fb", "parental-controls" }, { "82999dd3-a2be-482e-9f44-357879b4f603", "pass" }, { "f4fe27db-7292-4e13-98b6-f3ff9b5ed5fe", "people-pages" }, { "652968f4-d474-4e04-a1cf-2dd1eaeb488a", "people-pages-pms" }, { "96cac76e-c5bc-4596-87eb-4fdfef9aaa11", "photos-favorites" }, { "2ea0e464-ea4f-4be2-97c1-ce6ed4b377dd", "photos-metadata-edition" }, { "850f3d1e-3f38-44c1-9c0c-e3c9127b8b5a", "photosV6-edit" }, { "3a2b0cb6-1519-4431-98e2-823c248c70eb", "photosV6-tv-albums" }, { "068f4adf-43e5-4cc6-b5a1-1243e1be4c53", "playback-speed" }, { "02da2909-ddfd-46be-9e42-65008a79fc05", "played_badges" }, { "9aea4ca5-2095-4619-9339-88c1e662fde6", "pms_health" }, { "222020fb-1504-492d-af33-a0b80a49558a", "premium-dashboard" }, { "d413fb56-de7b-40e4-acd0-f3dbb7c9e104", "premium_music_metadata" }, { "a0a78867-6b26-446f-9c3f-df4edf831259", "promoted-grid-channel-filters" }, { "3eb2789b-200c-4a15-91d2-dedfe560953c", "rate-limit-client-token" }, { "64adaa4e-aa7e-457d-b385-51438216d7fe", "shared_server_notification" }, { "6c4d66d9-729d-49dc-b70d-ab2652abf15a", "shared_source_notification" }, { "0cce52a7-0778-4781-9a07-712370fb6b8a", "require-plex-nonce" }, { "644c4466-05fa-45e0-a478-c594cf81778f", "save-to-library" }, { "ccef9d3a-537a-43d9-8161-4c7113c6e2bb", "scrobbling-service" }, { "7b392594-6949-4736-9894-e57a9dfe4037", "scrobbling-service-plex-tv" }, { "1df3cd16-faf2-4d37-8349-1fcf3713bf1d", "album-types" }, { "1417df52-986e-4e4b-8dcd-3997fbc5c976", "collections" }, { "8fd37970-6e4e-4f00-a64a-e70b52f18e94", "music-analysis" }, { "300231e0-69aa-4dce-97f4-52d8c00e3e8c", "radio" }, { "05690239-443e-43fb-bc1a-95b5d916ca63", "session_bandwidth_restrictions" }, { "4ca03b04-54c1-4f9f-aea2-f813ae48f317", "session_kick" }, { "6d7be725-9a96-42c7-8af4-01e735138822", "exclude restrictions" }, { "1b3a63e4-c2f4-4011-a181-2343d3a97ef7", "signin_notification" }, { "b5874ecb-6610-47b2-8906-1b5a897acb02", "signin_with_apple" }, { "62b1e357-5450-41d8-9b60-c7705f750849", "singleitemsharing" }, { "c5adf9dc-af13-4a85-a24b-98de6fa2f595", "sleep-timer" }, { "8a9471c4-13bd-435a-b5b8-4ca6e423f355", "sonos-client-feature" }, { "579156cf-0664-45b4-8b7b-dda400ac3e26", "spotlight-style-hub" }, { "fec722a0-a6d4-4fbd-96dc-4ffb02b072c5", "spring_serve_ad_provider" }, { "bb50c92f-b412-44fe-8d8a-b1684f212a44", "Subtitles on Demand" }, { "9dc1df45-fb45-4be1-9ab2-eb23eb57f082", "sync" }, { "6380e085-02fe-43b5-8bff-380fa4f2423c", "trailers" }, { "a3d2d5c4-46a0-436e-a2d6-80d26f32b369", "transcoder_cache" }, { "c2409baa-d044-45c7-b1f4-e9e7ccd2d128", "boost-voices" }, { "85ebfb7b-77fb-4afd-bb1a-2fe2fefdddbe", "TREBLE-show-features" }, { "a6e0a154-4735-4cbb-a6ec-7a0a146c8216", "silence-removal" }, { "95149521-f64b-46ea-825c-9114e56afd2c", "sweet-fades" }, { "1dd846ed-7cde-4dc5-8ef6-53d3ce8c4e9d", "visualizers" }, { "bbf73498-4912-4d80-9560-47c4fe212cec", "volume-leveling" }, { "07f804e6-28e6-4beb-b5c3-f2aefc88b938", "tunefind-clients" }, { "9b5a4bea-3bbe-45d2-b226-00a6ef4d8e65", "tvod" }, { "5d80b92d-4ecf-4b0b-935f-5efc907bb2c1", "tvod_playback" }, { "362c5ba7-41e8-400d-8354-18d53868e2d3", "tvod-rentals" }, { "e25d0e25-109e-4d6d-9a54-db0931af31c3", "tvod-wtw" }, { "06d14b9e-2af8-4c2b-a4a1-ea9d5c515824", "two-factor-authentication" }, { "20824f5c-6dd9-4655-9970-e7701a73c02a", "two-factor-authentication-clients" }, { "d14556be-ae6d-4407-89d0-b83953f4789a", "type-first" }, { "cec2152f-321a-4c24-8c6d-c2b35a624389", "ultrablur" }, { "8b46de05-1f96-4278-87b3-010ba5b1e386", "universal-search" }, { "cce9af5d-7b44-4119-a6b1-108fd0db725c", "universal-search-live-tv" }, { "b6b68f84-5127-4dc9-8a7e-3a04419b5cd4", "universal-search-new-quick-search" }, { "d9528436-ee7c-42e3-ab7b-814f85ef74b4", "universal-watchlist" }, { "b46d16ae-cbd6-4226-8ee9-ab2b27e5dd42", "unsupportedtuners" }, { "096ab4b8-04d2-41f4-9602-f1d5b9e8c7cc", "users-and-sharing" }, { "1b870b8e-f1a7-497c-80b2-857d45f3123f", "vod-schema" }, { "65faa2d0-f57e-4c63-a6b6-f1baa48951b1", "watch-together-20200520" }, { "f83450e2-759a-4de4-8b31-e4a163896d43", "watch-together-invite" }, { "236de47b-a757-4ed7-9003-507b296057b5", "watched-badges-v3" }, { "f0c452ce-11e7-465f-be04-5fb0bf4bec48", "watchlist" }, { "edd6039a-137c-4ace-b5d5-4e111ce9690b", "watchlist-source" }, { "f0f40559-a43a-4b8f-85ef-bdb1de1a912a", "watchlist-rss" }, { "b737075d-a6c5-4e8a-8ee9-7dc72d984062", "web-desktop-live-tv-chromecast-remote-player" }, { "f8484f94-92a8-4ca4-9f43-e83ab3f586c7", "web-desktop-v4-dvr-setup" }, { "29bca3b8-e40b-4c69-b71c-f88047240f9b", "web-desktop-v4-home" }, { "591895c1-8c60-4eab-8096-3594bb190257", "web-desktop-v4-pre-plays" }, { "740a75d2-6dba-4317-ba68-ed3d619d4c7a", "web-log-viewer" }, { "5e2a89ec-fb26-4234-b66e-14d37f35dff2", "web_server_dashboard" }, { "73c73f05-7131-41cd-86d7-b91301684bfe", "web-share-v2" }, { "6f82ca43-6117-4e55-ae0e-5ea3b3e99a96", "webhooks" }, { "e4f02866-841f-4ceb-a30c-0a0e68fb874d", "where-to-watch-clients" }, // Dev/Ninja features { "044a1fac-6b55-47d0-9933-25a035709432", "transcode-offline" }, { "0e2acda2-d70d-4df6-96e0-f63cf264d217", "transcode-hevc" }, { "fd6683b9-1426-4b00-840f-cd5fb0904a6a", "transcode-tonemapping" }, { "fef9b829-af7e-430c-a757-d80de818f211", "music-analysis" }, { "ea442c16-044a-4fa7-8461-62643f313c62", "thetvdb_v4_plugin" }, { "0eee866d-782b-4dfd-b42b-3bbe8eb0af16", "server-manager" }, { "0a348865-4f87-46dc-8bb2-f37637975724", "photos-v5" }, { "59127bcf-acc8-4e97-ad88-8ba6380880b9", "pro_install" }, { "c55d5900-b546-416d-a8c5-45b24a13e9bc", "download_certificates" }, { "3d572099-e243-49bb-9f94-17de7703f9f9", "advanced-playback-settings" }, { "99d17487-7106-4d42-a3b1-c92f68b73165", "news" }, { "e4532fb1-b2e8-4269-9225-b804657cb3ba", "roku-dogfood" }, { "a19d495a-1cef-4f7c-ab77-5186e63e17f7", "loudness" }, { "4866e9e9-ad14-4c2b-bd92-49576f320fd7", "ump-matching-pref" }, { "d20f9af2-fdb1-4927-99eb-a2eb8fbff799", "shared-radio" }, { "c43d8d0f-7aa3-4fef-b9ad-4902580c90ce", "incremental-epg" }, { "075954ad-56ef-4f5e-9519-9cfb0ed05827", "categories" }, { "88aba3a3-bd62-42a5-91bb-0558a4c1db57", "collections-custom-sorting" }, { "e954ef21-08b4-411e-a1f0-7551f1e57b11", "push-notification" }, { "cd0ef747-af8a-414b-9d3a-dd02b6454db9", "voice-activity-generation" }, { "ba8459cd-81fe-4799-93e2-84358717bfb4", "augmentation-provider-environment" }, { "16abced2-1e64-4f01-b64f-f8ef41b1ea6c", "plex-online-environment" }, { "a6f3f9b3-c10c-4b94-ad59-755e30ac6c90", "detect-commercials" }, }; std::bitset<704>* g_feature_flags; auto _is_feature_available = reinterpret_cast(0); auto _map_find = reinterpret_cast(0); auto _bitset_init = reinterpret_cast(0); auto _is_user_feature_set = reinterpret_cast(0); std::optional> get_dottext_info() { std::ifstream file("/proc/self/maps"); std::string line; while(std::getline(file, line)) { // I don't understand Linux :| // Only .text should have `r-xp`. This works I guess.. if(line.find("Plex Media Server") != std::string::npos && line.find("r-xp") != std::string::npos) { const uintptr_t start = std::stoull(line.substr(0, line.find('-')), nullptr, 16); const uintptr_t end = std::stoull(line.substr(line.find('-') + 1), nullptr, 16); return std::make_tuple(start, end); } } return std::nullopt; } std::optional create_hook(uintptr_t from, uintptr_t to) { ZydisDecoder decoder; ZydisDecodedInstruction instruction; ZydisDecoderInit(&decoder, ZYDIS_MACHINE_MODE_LONG_64, ZYDIS_STACK_WIDTH_64); auto trampoline_mem = reinterpret_cast(mmap(NULL, getpagesize(), PROT_READ|PROT_WRITE|PROT_EXEC, MAP_ANONYMOUS|MAP_SHARED, -1, 0)); size_t offset = 0; while(offset < 14) { if(ZYAN_SUCCESS(ZydisDecoderDecodeInstruction(&decoder, nullptr, reinterpret_cast(from + offset), ZYDIS_MAX_INSTRUCTION_LENGTH, &instruction))) { std::memcpy(trampoline_mem + offset, reinterpret_cast(from + offset), instruction.length); offset += instruction.length; } else { delete[] trampoline_mem; return std::nullopt; } } uint8_t shellcode[] = { 0xFF, 0x25, 0x00, 0x00, 0x00, 0x00, // jmp [rip+0x06] 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // ? }; // Jump to original code in trampoline and make trampoline executable *reinterpret_cast(&shellcode[6]) = from + offset; std::memcpy(trampoline_mem + offset, shellcode, sizeof(shellcode)); mprotect(reinterpret_cast(trampoline_mem), 64, PROT_READ|PROT_EXEC); // Jump to target code *reinterpret_cast(&shellcode[6]) = to; mprotect(reinterpret_cast(from), sizeof(shellcode), PROT_READ|PROT_WRITE|PROT_EXEC); memcpy(reinterpret_cast(from), shellcode, sizeof(shellcode)); mprotect(reinterpret_cast(from), sizeof(shellcode), PROT_READ|PROT_EXEC); return reinterpret_cast(trampoline_mem); } std::optional sig_scan(const uintptr_t start, const uintptr_t end, std::string_view pattern) { constexpr const uint16_t WILDCARD = 0xFFFF; std::vector pattern_vec; for(uintptr_t i = 0; i < pattern.length(); i++) { if(pattern[i] == ' ') { continue; } if(pattern[i] == '?') { if(pattern[i + 1] == '?') { i++; } pattern_vec.push_back(WILDCARD); continue; } pattern_vec.push_back(static_cast(std::strtol(&pattern[i], nullptr, 16))); i++; } const auto vec_length = pattern_vec.size(); for(uintptr_t i = start; i <= end - vec_length; i++) { bool mismatch = false; for(uintptr_t x = 0; x < vec_length; x++) { const auto mem = *reinterpret_cast(i + x); if(pattern_vec[x] != WILDCARD && mem != pattern_vec[x]) { mismatch = true; break; } } if(!mismatch) { return i; } } return std::nullopt; } uintptr_t follow_call_rel32(const uintptr_t address) { return address + 5 + *reinterpret_cast(address + 1); } bool process_feature(const char* guid) { if(g_features.contains(guid)) { return true; } return false; } uint64_t hook_is_feature_available(uintptr_t user, const char** feature) { if(process_feature(*feature)) { return true; } return _is_feature_available(user, feature); } uint64_t* hook_map_find(uintptr_t* rcx, const char** str) { if(str != nullptr && process_feature(*str)) { static uint64_t FAKE_PTR = 0; return &FAKE_PTR; } return _map_find(rcx, str); } uint64_t hook_bitset_init(uintptr_t rcx) { auto ret = _bitset_init(rcx); g_feature_flags->set(); return ret; } bool hook_is_user_feature_set([[maybe_unused]] uintptr_t rcx, [[maybe_unused]] int expected, [[maybe_unused]] int feature) { return static_cast(expected); } void hook() { auto info = get_dottext_info(); if(!info) { return; } const auto start = std::get<0>(info.value()); const auto end = std::get<1>(info.value()); if(const auto is_user_feature_set = sig_scan(start, end, "55 48 89 E5 48 8B 07 48 85 C0 74 6A"); is_user_feature_set) { if(auto trampoline = create_hook(is_user_feature_set.value(), reinterpret_cast(hook_is_user_feature_set)); trampoline) { _is_user_feature_set = reinterpret_cast(trampoline.value()); } } // Features are now enabled in boost::atomic as of 2024/08/13 PMS BETA if(const auto bitset = sig_scan(start, end, "48 8D 0D ? ? ? ? 48 8B 94 05 90 FE FF FF"); bitset) { const uintptr_t addr = bitset.value() + 7 + *reinterpret_cast(bitset.value() + 3); g_feature_flags = reinterpret_cast*>(addr); if(const auto bitset_init = sig_scan(start, end, "55 48 89 E5 41 57 41 56 41 55 41 54 53 48 81 EC ? ? 00 00 49 89 FE 48 8D 9D ? ? ? ? 48 89 DF E8 ? ? ? ? 48 8B 1B 48 85 DB"); bitset_init) { if(auto trampoline = create_hook(bitset_init.value(), reinterpret_cast(hook_bitset_init)); trampoline) { _bitset_init = reinterpret_cast(trampoline.value()); // No reason to hook the rest return; } } } if(const auto is_feature_available_ref = sig_scan(start, end, "E8 ? ? ? ? 86 43"); is_feature_available_ref) { const auto is_feature_available = follow_call_rel32(is_feature_available_ref.value()); if(auto trampoline = create_hook(is_feature_available, reinterpret_cast(hook_is_feature_available)); trampoline) { _is_feature_available = reinterpret_cast(trampoline.value()); } } if(const auto map_find = sig_scan(start, end, "55 48 89 E5 41 57 41 56 53 48 83 EC ? 49 89 F7 4C 8D 77"); map_find) { if(auto trampoline = create_hook(map_find.value(), reinterpret_cast(hook_map_find)); trampoline) { _map_find = reinterpret_cast(trampoline.value()); } } }