Skip to content

Commit

Permalink
Fixed possible crash while enabling developer mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
master131 committed Apr 1, 2019
1 parent d559e75 commit 340ca57
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
5 changes: 3 additions & 2 deletions iFakeLocation/DeviceInformation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ private enum DiskImageUploadMode {
UploadImage
}

private static readonly MobileImageMounterUploadCallBack MounterUploadCallback = MounterReadCallback;

private static int MounterReadCallback(IntPtr buffer, uint size, IntPtr userData) {
var imageStream = (FileStream) GCHandle.FromIntPtr(userData).Target;
var buf = new byte[size];
Expand Down Expand Up @@ -265,9 +267,8 @@ public void EnableDeveloperMode(string deviceImagePath, string deviceImageSignat
case DiskImageUploadMode.UploadImage:
// Create stream for device image and wrap as a pointer for callback
var handle = GCHandle.Alloc(imageStream);

// Upload the image and then free unmanaged wrapper
mounter.mobile_image_mounter_upload_image(mounterHandle, imageType, (uint)imageStream.Length, sig, (ushort) sig.Length, MounterReadCallback, GCHandle.ToIntPtr(handle));
mounter.mobile_image_mounter_upload_image(mounterHandle, imageType, (uint)imageStream.Length, sig, (ushort) sig.Length, MounterUploadCallback, GCHandle.ToIntPtr(handle));
handle.Free();
break;
case DiskImageUploadMode.AFC:
Expand Down
2 changes: 1 addition & 1 deletion iFakeLocation/MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions iFakeLocation/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ public MainForm()
{
InitializeComponent();

var ver = Assembly.GetExecutingAssembly().GetName().Version;
Text += " v" + ver.Major + "." + ver.Minor;

try
{
// Load the native modules
Expand Down
4 changes: 2 additions & 2 deletions iFakeLocation/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.1.0.0")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyVersion("0.2.0.0")]
[assembly: AssemblyFileVersion("0.2.0.0")]

0 comments on commit 340ca57

Please sign in to comment.