Skip to content
This repository was archived by the owner on Aug 17, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [

<!-- #endregion -->

{
"type": "chrome",
"request": "launch",
"name": "Open settings.json",
"file": "c:\\Users\\issam.DESKTOP-9DRRJHF\\AppData\\Roaming\\Code - Insiders\\User\\settings.json"
}
]
}
19 changes: 15 additions & 4 deletions WDBRemoveThreeAppLimit/grant_full_disk_access.m
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,18 @@ static uint64_t patchfind_pointer_to_string(void* executable_map, size_t executa
if (!str_offset) {
return 0;
}
uint64_t str_file_offset = str_offset - executable_map;
for (int i = 0; i < executable_length; i += 8) {
uint64_t val = *(uint64_t*)(executable_map + i);
uint64_t str_file_offset = (uint64_t)((uintptr_t)str_offset - (uintptr_t)executable_map);

/*
* Use size_t for the loop variable to prevent potential integer overflow
* when scanning very large executables ( >2 GB ). Using a signed 32-bit
* integer could cause the loop to terminate early or exhibit undefined
* behaviour on such inputs.
*/
for (size_t i = 0; i < executable_length; i += 8) {
uint64_t val = *(uint64_t*)((char*)executable_map + i);
if ((val & 0xfffffffful) == str_file_offset) {
return i;
return (uint64_t)i;
}
}
return 0;
Expand Down Expand Up @@ -590,12 +597,15 @@ bool patch_installd() {
NSData* sourceData = make_patch_installd(targetMap, targetLength);
if (!sourceData) {
NSLog(@"can't patchfind");
munmap(targetMap, targetLength);
close(fd);
return false;
}

if (!overwrite_file(fd, sourceData)) {
overwrite_file(fd, originalData);
munmap(targetMap, targetLength);
close(fd);
NSLog(@"can't overwrite");
return false;
}
Expand All @@ -606,5 +616,6 @@ bool patch_installd() {
// TODO(zhuowei): for now we revert it once installd starts
// so the change will only last until when this installd exits
overwrite_file(fd, originalData);
close(fd);
return true;
}
5 changes: 4 additions & 1 deletion WDBRemoveThreeAppLimit/helpers.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@
char* buf = malloc(PAGE_SIZE*10);
memset(buf, 'A', PAGE_SIZE*10);
fwrite(buf, PAGE_SIZE*10, 1, f);
//fclose(f);
// Clean up resources before returning the file path
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(This isn't actually used - this is taken from Ian Beer's sample code and isn't actually called)

fflush(f);
fclose(f);
free(buf);
return path;
}

Expand Down