XNU Image Fuzzer 1.8.2
Documentation for XNU Image Fuzzer
Loading...
Searching...
No Matches
ViewController Class Reference

Core and external libraries necessary for the fuzzer functionality. More...

#include <ViewController.h>

+ Inheritance diagram for ViewController:
+ Collaboration diagram for ViewController:

Instance Methods

(void) - viewDidLoad [implementation]
 Called after the controller's view is loaded into memory.
 
(void) - loadFuzzedImagesFromDocumentsDirectory [implementation]
 Loads fuzzed images from the documents directory into the collection view.
 
(NSInteger) - collectionView:numberOfItemsInSection: [implementation]
 Asks the data source for the number of items in the specified section.
 
(UICollectionViewCell *) - collectionView:cellForItemAtIndexPath: [implementation]
 Asks the data source for the cell that corresponds to the specified item in the collection view.
 
(CGSize) - collectionView:layout:sizeForItemAtIndexPath: [implementation]
 Asks the delegate for the size of the specified item’s cell.
 

Properties

UICollectionView * collectionView [implementation]
 
NSMutableArray< UIImage * > * fuzzedImages [implementation]
 
NSMutableArray< NSString * > * imagePaths [implementation]
 

Detailed Description

Core and external libraries necessary for the fuzzer functionality.

This section includes the necessary headers for the Foundation framework, UIKit, Core Graphics, standard input/output, standard library, memory management, mathematical functions, Boolean type, floating-point limits, and string functions. These libraries support image processing, UI interaction, and basic C operations essential for the application.

Definition at line 36 of file ViewController.h.

Method Documentation

◆ collectionView:cellForItemAtIndexPath:

- (UICollectionViewCell *) collectionView: (UICollectionView *) collectionView
cellForItemAtIndexPath: (NSIndexPath *) indexPath 
implementation

Asks the data source for the cell that corresponds to the specified item in the collection view.

Parameters
collectionViewThe collection view requesting this cell.
indexPathThe index path that specifies the location of the item.
Returns
A configured cell object.

Definition at line 46 of file ViewController.m.

138 :(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
139 UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"ImageCell" forIndexPath:indexPath];
140
141 // Configure cell
142 cell.backgroundColor = [UIColor lightGrayColor]; // For visibility
143
144 UIImageView *imageView = [[UIImageView alloc] initWithFrame:cell.contentView.bounds];
145 imageView.contentMode = UIViewContentModeScaleAspectFit;
146 imageView.image = self.fuzzedImages[indexPath.row];
147 [cell.contentView addSubview:imageView]; // Add imageView to cell's contentView
148
149 NSLog(@"Configuring cell for item at %@ with image name: %@", indexPath, self.imagePaths[indexPath.row]);
150
151 return cell;
152}
NSMutableArray< NSString * > * imagePaths
UICollectionView * collectionView

References fuzzedImages, and loadFuzzedImagesFromDocumentsDirectory.

+ Here is the call graph for this function:

◆ collectionView:layout:sizeForItemAtIndexPath:

- (CGSize) collectionView: (UICollectionView *) collectionView
layout: (UICollectionViewLayout *) collectionViewLayout
sizeForItemAtIndexPath: (NSIndexPath *) indexPath 
implementation

Asks the delegate for the size of the specified item’s cell.

Parameters
collectionViewThe collection view object displaying the flow layout.
collectionViewLayoutThe layout object requesting the information.
indexPathThe index path of the item.
Returns
The width and height of the specified item. Adjust as needed.

Definition at line 46 of file ViewController.m.

163 :(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
164 return CGSizeMake(100, 100); // Adjust size as needed
165}

◆ collectionView:numberOfItemsInSection:

- (NSInteger) collectionView: (UICollectionView *) collectionView
numberOfItemsInSection: (NSInteger) section 
implementation

Asks the data source for the number of items in the specified section.

Returns the number of fuzzed images.

Parameters
collectionViewThe collection view requesting this information.
sectionThe index number of the section.
Returns
The number of rows in section.

Definition at line 46 of file ViewController.m.

128 :(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
129 return self.fuzzedImages.count;
130}
NSMutableArray< UIImage * > * fuzzedImages

◆ loadFuzzedImagesFromDocumentsDirectory

- (void) loadFuzzedImagesFromDocumentsDirectory
implementation

Loads fuzzed images from the documents directory into the collection view.

Definition at line 46 of file ViewController.m.

87 {
88 NSFileManager *fileManager = [NSFileManager defaultManager];
89 NSString *documentsDirectoryPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject];
90 NSError *error = nil;
91 NSArray *directoryContents = [fileManager contentsOfDirectoryAtPath:documentsDirectoryPath error:&error];
92
93 if (!error) {
94 NSLog(@"Found %lu items in the documents directory.", (unsigned long)directoryContents.count);
95 for (NSString *fileName in directoryContents) {
96 if ([fileName.pathExtension isEqualToString:@"png"] || [fileName.pathExtension isEqualToString:@"jpg"] || [fileName.pathExtension isEqualToString:@"jpeg"]) {
97 NSString *filePath = [documentsDirectoryPath stringByAppendingPathComponent:fileName];
98 UIImage *image = [UIImage imageWithContentsOfFile:filePath];
99 if (image) {
100 [self.fuzzedImages addObject:image];
101 [self.imagePaths addObject:fileName];
102 NSLog(@"Successfully loaded image: %@", fileName);
103 } else {
104 NSLog(@"Failed to load image: %@", fileName);
105 }
106 }
107 }
108 } else {
109 NSLog(@"Error reading the documents directory: %@", error.localizedDescription);
110 }
111
112 NSLog(@"Total loaded fuzzed images: %lu", (unsigned long)self.fuzzedImages.count);
113
114 // Reload the collection view on the main thread
115 dispatch_async(dispatch_get_main_queue(), ^{
116 [self.collectionView reloadData];
117 });
118}

Referenced by collectionView:cellForItemAtIndexPath:.

+ Here is the caller graph for this function:

◆ viewDidLoad

- (void) viewDidLoad
implementation

Called after the controller's view is loaded into memory.

Initializes the view controller's properties, collection view, and loads fuzzed images.

Definition at line 46 of file ViewController.m.

55 {
56 [super viewDidLoad];
57
58 // Initialize arrays
59 self.fuzzedImages = [NSMutableArray new];
60 self.imagePaths = [NSMutableArray new];
61
62 // Setup the collectionView layout
63 UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
64 layout.itemSize = CGSizeMake(100, 100);
65 layout.minimumLineSpacing = 10;
66 layout.minimumInteritemSpacing = 10;
67
68 // Initialize the collectionView
69 self.collectionView = [[UICollectionView alloc] initWithFrame:self.view.bounds collectionViewLayout:layout];
70 self.collectionView.backgroundColor = [UIColor whiteColor];
71 self.collectionView.dataSource = self;
72 self.collectionView.delegate = self;
73
74 // Register UICollectionViewCell class
75 [self.collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"ImageCell"];
76
77 // Add collectionView to the view hierarchy
78 [self.view addSubview:self.collectionView];
79
80 // Load fuzzed images
81 [self loadFuzzedImagesFromDocumentsDirectory];
82}

Property Documentation

◆ collectionView

- (UICollectionView*) collectionView
readwritenonatomicstrongimplementation

Provided by category ViewController().

◆ fuzzedImages

- (NSMutableArray<UIImage *>*) fuzzedImages
readwritenonatomicstrongimplementation

Provided by category ViewController().

Referenced by collectionView:cellForItemAtIndexPath:.

◆ imagePaths

- (NSMutableArray<NSString *>*) imagePaths
readwritenonatomicstrongimplementation

Provided by category ViewController().


The documentation for this class was generated from the following files: