yashsingh1/xdaforums huggingface dataset:
[Android Software/Hacking General [Developers Only]] k1ll3r8e:
Heyho :)

Np, if the little snippet dun works let me know then i'll have a look at it.

About the DeviceConnectionMonitor have a look at this post.

About the AndroidCtrlUI.dll, yes it needs also the AndroidCtrl.dll the UI dll is only a MVVM overlay for my base dll.

The attachment is an simple example for the use of my AndroidCtrlUI.dll (It includes currently my updated dlls, so dun use the old one's in this example project).

Regards,

Sebastian
[Android Software/Hacking General [Developers Only]] squabbi:
I got the connection monitor working! Thanks! :) Now with your advice for the identifier token, I get this:

System.Collections.Generic.List`1[System.String]

I remember once we had this issue and we fixed it somehow. :)

Thanks for the UI example too! I haven't looked at it yet but I will soon! Thanks friend! :)
[Android Software/Hacking General [Developers Only]] k1ll3r8e:
Heyho :)

Sry for the little mistake, i fixed it, for me and my token it works now. :P

List<string> _token = new List<string>();
foreach (string line in Fastboot.Instance().OEM.GetIdentifierToken())
{
GroupCollection groups = Regex.Match(line, @"^\(bootloader\)\s{1,}(?<PART>.*?)$").Groups;
string part = groups["PART"].Value;
if (String.IsNullOrEmpty(part) == false && Regex.IsMatch(part, @"^<{1,}.*?>{1,}$") == false)
{
_token.Add(part);
}
}
//the final string which u can write to an file
string token = String.Join("\n", _token.ToArray());

About the "monitor" np. :)

Regards,

Sebastian
[Android Software/Hacking General [Developers Only]] squabbi:
It still doesn't work for me. It shows the same string as before! :( Thanks for helping!
[Android Software/Hacking General [Developers Only]] k1ll3r8e:
Heyho :)

That's sad to hear... I think ur token output is different from mine... That's why the regex dun works...

I've send u an example from my token-dialog (window) so u can check the output with ur's.

Regards,

Sebastian
[Android Software/Hacking General [Developers Only]] squabbi:
Hey buddy

Could you help explain how to implement the AndroidCtrl.Logger; to display the logs to a textbox or a text block?

Thanks!
[Android Software/Hacking General [Developers Only]] k1ll3r8e:
Heyho :)

Have a look at this article.

...

Logger.Instance.CallbackWarning += CallbackLogger;

// This is the callback for all events
public void CallbackLogger(object sender, LoggerArgs e)
{
App.Current.Dispatcher.Invoke((Action)delegate
{
// Here u have to add the worker which will add e.Log data to the textbox/-block
// U can also call "e.Log.ToString()" to get an formatted multi-line string
});
}

...

Hope this helps :)

Regards,

Sebastian
[Android Software/Hacking General [Developers Only]] squabbi:
Thanks bro! It worked!! I should have read it again! ;)

Now, is it possible to have something like this:

private async void fastbootFlash(string file, string partition)
{
Fastboot.Instance().Flash(IDDevicePartition.[I want to use the string partition here], file);
}

So I can just call it:

Button1_click
{
fastbootFlash("recovery1", "recovery");
}

Thank you for ur time! :))
[Android Software/Hacking General [Developers Only]] k1ll3r8e:
Heyho :)

no u can't use an string as an enum. But, u can act like the following example:

Fastboot.Instance().Execute(String.Join(" ", "flash", "MyPartition", Tools.General.Quote("MyImgPath")), 0);

EDIT (another, maybe better solution):

...
using System.Windows.Collections.Generic;
...
// Set an ComboBox as partition selector
// ComboBox _partition = new ComboBox();

// Add all partitions from the IDDevicePartition enum to it
foreach (IDDevicePartition enu in Enum.GetValues(typeof(IDDevicePartition)))
{
// Here i use an KeyValuePair (u can also use an own class), so u can bind to the "Key" property of the KeyValuePair
// to display the user the partition name
_partition.Add(new KeyValuePair<string, IDDevicePartition>(enu.ToString(), enu));
}
...

private async void fastbootFlash(string file)
{
if (_partition != null)
{
if (_partition.SelectedItem != null)
{
// Use the selected partition to flash the img
Fastboot.Instance().Flash(((KeyValuePair<string, IDDevicePartition>)_partition.SelectedItem).Value, file);
}
}
}

(Code is untested)

Hope this helps :)

Regards,

Sebastian
[Android Software/Hacking General [Developers Only]] squabbi:
Hey man! Could you add this new adb command? Its for the HTC one M9.

ADB.Instance().Reboot(IDBoot.DOWNLOAD)

to do:

adb reboot download

Thanks! :D
[Android Software/Hacking General [Developers Only]] k1ll3r8e:
Heyho :)

sure! - I just add it to the dll upload starts in 5 min ;)

EDIT:

UPDATE is online!

Regards,

Sebastian
[Android Software/Hacking General [Developers Only]] squabbi:
Hey dude! Long time! Umm I think you already said something about this. But if I wanted to get the adb and fastboot files to extract to another folder? Eg. "./Data/adb"
[Android Software/Hacking General [Developers Only]] k1ll3r8e:
Heyho :)

no problem, i'll write later today also an little "How-To" article about that stuff. Currently u can't change the extraction directory. But u can deploy the files to the default directory and then move them to ur location. Then u can change the paths inside the dll like the following examples.

(string) PATH_AAPT = (PATH_DIRECTORY_AAPT\aapt.exe) Hold the final aapt path (can't be changed)
(string) PATH_DIRECTORY_AAPT = (DLL_PATH\adb\) Here u can change the directory (but only the directory)

(string) PATH_ADB
(string) PATH_DIRECTORY_ADB

(string) PATH_FASTBOOT
(string) PATH_DIRECTORY_FASTBOOT

(string) PATH_SIGNER
(string) PATH_DIRECTORY_SIGNER

Hope this helps for the moment.

PS: I'll add an extraction method which will extract the files where u want. ;)

Regards,

Sebastian
[Android Software/Hacking General [Developers Only]] squabbi:
Thanks bro! I look forward to it
[Android Software/Hacking General [Developers Only]] k1ll3r8e:
Hey bro ;)

-

Just an update, i decided to write an "Config" class which will hold all "init", "default", "fallback" values. This class can be configured before u start working with the dll it's self. So u have the ability to implement the dll a bit deeper in ur program.

Also, all values will have the current defaults.

I hope that i get it today done.

--- EDIT ---

[MENTION=4752144]squabbi[/MENTION], update is online! ;) - Have a look at this article.

Regards,

Sebastian
[Android Software/Hacking General [Developers Only]] squabbi:
Thanks! I'll check it out soon! :D
[Android Software/Hacking General [Developers Only]] squabbi:
Hello! :D

Is it possible to exclude the connection monitor's logger output? :) and also can I wait for device to go into recovery or a certain state?

Thanks!
[Android Software/Hacking General [Developers Only]] k1ll3r8e:
Heyho :)

I'm just downloading MSVS 2015 Enterprise... This will take a while... 21 GB^^

After this, i'll have a look at the "Logger".

But so far i can say, i implement an option to exclude some logging points.

- EDIT -

About the "wait-for-device", currently u have the following method which will do this for u.

This will wait for an ADB device, so u can use it to wait for "DEVICE" or "RECOVERY". Remember, this call will block the current thread until a device is connected.

- EDIT1 -

[MENTION=4752144]squabbi[/MENTION] the logger changes are a bit more complex as i thought... So i need a bit more time to do all the changes.

Regards,

Sebastian
[Android Software/Hacking General [Developers Only]] squabbi:
Heyoo! :)

I hope you are well. I have a question with the device state checker. It doesn't seem to work well or properly with my Nexus 6P. When I press the button it shows me the messagebox 'not detected' even though the deviceselector detects the 6P in fastboot.

IDDeviceState state = General.CheckDeviceState(ADB.Instance().DeviceID);
if (state == IDDeviceState.DEVICE)
{
ADB.Instance().Reboot(IDBoot.BOOTLOADER);
processBusyInd.BusyContent = "Flashing TWRP...";
loop_state_check:
if (state == IDDeviceState.FASTBOOT)
{
Fastboot.Instance().Flash(IDDevicePartition.RECOVERY, dialog.FileName);
processBusyInd.BusyContent = "Rebooting...";
FastbootRebootSelectionsDialog();
processBusyInd.IsBusy = false;
}
else
{
goto loop_state_check;
}
}
else if (state == IDDeviceState.FASTBOOT)
{
processBusyInd.BusyContent = "Flashing TWRP...";
Fastboot.Instance().Flash(IDDevicePartition.RECOVERY, dialog.FileName);
processBusyInd.BusyContent = "Rebooting...";
FastbootRebootSelectionsDialog();
processBusyInd.IsBusy = false;
}

Thanks! :)
[Android Software/Hacking General [Developers Only]] k1ll3r8e:
Heyho :)

-

here so far everything is fine - hope on ur end also?

-

About the problem, can u have a look at ur adb output if it looks similar to this?

*adb devices -l*

List of devices attached
xxxxxxxx device product:kltexx model:SM_G900F device:klte

If it don't, pls send me ur output, that i can realign the regex function.

Regards,

Sebastian
[Android Software/Hacking General [Developers Only]] squabbi:
I'm good thank you. :)

This is my output. It looks the same to yours.

I:\Android\Android Tools>adb devices -l
List of devices attached
XXXXXXXXXXXXXXXX device product:angler model:Nexus_6P device:angler

Is there any way of checking the device state with the "status" from the device selector (combobox)?

Thanks.
[Android Software/Hacking General [Developers Only]] k1ll3r8e:
Heyho ;)

-

that good to hear ;)

-

About the output, maybe u passed an empty (string)deviceID?

IDDeviceState state = General.CheckDeviceState(ADB.Instance().DeviceID);

/* Are u sure that u selected a device before u use? */
ADB.Instance().DeviceID

About the selector, u can use the following variables to get the required data:

/* FileSystemViewModel myModel = new FileSystemViewModel(); */

(DataModelDevicesItem) myModel.DeviceSelector.SelectedItem
(ListCollectionView) myModel.DeviceSelector.ComboElements

Hope this helps u ;)

Regards,

Sebastian
[Android Software/Hacking General [Developers Only]] squabbi:
Hello! It's me again! :)

Could you add these partitions?

vendor

userdata

bootloader

Thank you!

EDIT:

Is there any way in getting a live output (async) while the command is running using the method you gave almost a year ago (it still works! :) )

Output is displayed via a richtextbox:

<RichTextBox x:Name="console" IsReadOnly="True" HorizontalAlignment="Left" Height="110" Margin="10,362,0,0" VerticalAlignment="Top" Width="497">
<RichTextBox.Resources>
<Style TargetType="{x:Type Paragraph}">
<Setter Property="Margin" Value="0,0,0,0"/>
</Style>
</RichTextBox.Resources>
<FlowDocument/>
</RichTextBox>

This is the method:

public void Add(List<string> msg)
{
foreach (string tmp in msg)
{
console.Document.Blocks.Add(new Paragraph());
}
console.ScrollToEnd();
}

This is how I call it:

Add(Fastboot.Instance().Execute("flash vendor " + comma.Content + appPath + "Data/Downloads/Vendor/" + vendorListBox.SelectedItem.ToString() + comma.Content, -1));

For some fastboot commands, especially when I'm flashing a large zip I want to be able to see the sending, flashing and done messages as they come up. I've tried experimenting by making it async and await but with no luck.

EDIT 2! ahha I keep on finding new things!

Can you update the fastboot binary and commands to reflect new commands such as: fastboot flashing unlock etc. It should have been updated with the 23.0.1 rev of the SDK tools. Thanks,

EDIT 3! I'm on a roll! haha

Is there any way to fix this error? When I compile and run the program the tree view is fine.

https://gyazo.com/992225e548ddd2a8877b856960e50a74

Regards,

Squabbi
[Android Software/Hacking General [Developers Only]] k1ll3r8e:
Heyho XD,

about the partitions, i just added them to the (enum)IDDevicePartition ;)

about the "real time" output, u can use the "ProcessModels.RealTimeBG{}" class like:

using using AndroidCtrl.ProcessModels;
...

RealTimeBG procRT = new RealTimeBG(Fastboot.PATH_EXE, "flash vendor " + comma.Content + appPath + "Data/Downloads/Vendor/" + vendorListBox.SelectedItem.ToString() + comma.Content);
procRT.Callback += Response;
procRT.Start();

/*procRT.Dispose();*/

private void Response(object sender, ProcessResponseArgs e)
{
if (string.IsNullOrEmpty(e.Response) == false)
{

}
}

about the fastboot commands, i just download the latest SDK and update adb.exe and fastboot.exe. I'll also have a look at the new commands ;)

(THX for that hint btw. :P)

about the error, i have no idea where it comes from... but i'll have a look at this part and do also a code analysis :P

---

The new build goes later online - i'll update this post and send u a pm ;)

---

NOTE:

To all who use this dll, i have changed a view variables and deleted the "Logger" namespace. The "Logger" will be replaced in the next time. Also, i added an "Tools.Update" class, this is the new way to get the latest version of the dll (U can use it but u don't must).

---

Regards,

Sebastian
[Android Software/Hacking General [Developers Only]] squabbi:
Thanks for adding in those partitions! :) and np about the new sdk update. btw the tools.update looks promising too.

I had a look at the RealTimeBG and I tried to incorporate it into something like this:

flashVendor.IsEnabled = false;
vendorProgressBar.IsIndeterminate = true;
RealTimeBG procRT = new RealTimeBG(Fastboot.PATH_FASTBOOT, "flash vendor " + comma.Content + appPath + "Data/Downloads/Vendor/" + vendorListBox.SelectedItem.ToString() + comma.Content);
procRT.Callback += Response;
procRT.Start();
vendorProgressBar.IsIndeterminate = false;
flashVendor.IsEnabled = true;

Where I click a button and it will disable it and start a progress bar. But I'm guessing it runs on a different background thread. It didn't turn out what I wanted to see. When I flashed the vendor image it took 7 seconds to flash, the output (which I've done like this:)

private void Response(object sender, ProcessResponseArgs e)
{
if (string.IsNullOrEmpty(e.Response) == false)
{
App.Current.Dispatcher.Invoke((Action)delegate
{
console.Document.Blocks.Add(new Paragraph(new Run(e.Response.ToString())));
});
}
}

It will only display the output when the image has been completely flashed. I would prefer it to be able to be used with a progress indicator of some sort.

I hope you get what I mean. ;)

Regards,

Squabbi
[Android Software/Hacking General [Developers Only]] k1ll3r8e:
Heyho,

- new build is out -

np for adding the partitions :cyclops:

about the output, i added "ProcessModels.RealTimeBG.IsAlive" so u can now check if the process is still running. Also, i added to some methods the "CallbackProcessResponse responseCallback" parameter, so u can now get nearly all outputs in "real time".

- If the callback will be triggered only at the end of the process, the process didn't return something while its flashing the image. -

Maybe u can add a "dummy" ProgessBar which animates "from left to right and right to left" than set an text field on top of it which indicates the state like:

State: Erasing/Formatting/Flashing/Rebooting
+--------------------------------------------------------+
| <-> | (Progressbar)
+--------------------------------------------------------+

or like this:

Overall progress: Erasing/Formatting/Flashing/Rebooting
+--------------------------------------------------------+
| 1 | 2 | 3 | 4 | 5 | (Progressbar)
+--------------------------------------------------------+

+--------------------------------------------------------+
| Erasing/Formatting/Flashing/Rebooting | (Progressbar)
+--------------------------------------------------------+

about the MSVS editor error, i checked a view files but i can't reproduce this error... Which MSVS version did u use?

Hope this helps ;)

Regards,

Sebastian
[Android Software/Hacking General [Developers Only]] squabbi:
Thanks for updating so quickly! I've chosen to use the traditional 'Add' method for showing output. Btw, I'm using VS 2015 community. I can PM you the xaml code. :) :good: Also one more thing, the device connection monitor with the combobox won't show my device anymore. It used to before but I don't know what happened.

It's so close to being finished. :)

Thanks,
[Android Software/Hacking General [Developers Only]] k1ll3r8e:
Heyho ;)

np for the update - i use the same MSVS version so, send me ur xaml code then ill have a look at it ;)

about the connection monitor,

1. download/install/run this tool

2. get the output from "adb devices -l"

3. paste it into the "sample text" box

4. add this

^(?<SERIAL>.*?)\s{1,}(?<STATE>.*?)(\s{1,}product:\s{0,}(?<PRODUCT>.*?))?(\s{1,}model:\s{0,}(?<MODEL>.*?))?(\s{1,}device:\s{0,}(?<DEVICE>.*?))?$

to the "Regular Expression" box

5. press "Run Match" or "Validate"

if the "Search Results" box stay empty my regular expression have a bug^^

(Pls report if the expression can detect the output line.)

Hope this helps ;)

Regards,

Sebastian
[Android Software/Hacking General [Developers Only]] squabbi:
Looks like it's validated so there should be no problems. I'll send you (PM) the whole thing so you can take a look at the connection monitor too.

Thanks,

Squabbi
[Android Software/Hacking General [Developers Only]] KP@2016:
Hello Sir, Really A Great Job done by you, but since i am new to this, can you please help me.. Actually i want to use some prop values from ADB so basically i need to launch adb shell getprop ***** but how to do it using your dll can you please help
[Android Software/Hacking General [Developers Only]] k1ll3r8e:
Heyho ;)

thx for the warm words!

-

To get the buildprops u can use:

(string) ADB.Instance().Device.BuildProperties.Get(string property, bool dictionary = true)
(Dictionary<string, string>) ADB.Instance().Device.BuildProperties.GetProperties
(bool) ADB.Instance().Device.BuildProperties.Set(string key, string val)

Btw. during heavy refactoring of the both dll's i added the new "pre-builds" as attachment that u can build ur app on top of the new dll's. Because i changed a lot of returns and types, for example: Nearly all List<string> have been replaced by IEnumerable<string> so u have a better control about the collections and during System.Linq the data is much faster available. Also a lot of List<string> have been replaced by bool and the functions act now on the process exit code.

I also work currently on the Win IoT and Win UWP versions of the dlls.

Regards,

Sebastian
[Android Software/Hacking General [Developers Only]] KP@2016:
Thank you sir..

---------- Post added at 06:37 PM ---------- Previous post was at 06:13 PM ----------

Sorry to disturb you again... Sir

But how this actually works.. Means since i am new to this.. Can u bit give am example on it.. For eg i wanna set a prop value in a label4.text which is ro.product.model so how could i do it..

For eg label4.Text = Adb.Instance....???

Also i want to run some shell cmd commands like gzip and all.. So how can we do that...

Thank you in Advance
[Android Software/Hacking General [Developers Only]] k1ll3r8e:
Heyho,

i don't know how fit u are on using an external dll. But i'll try my best to provide u a really basic sample. To set up the 1st use of the dll u have to act like:

...
using System.Linq
using AndroidCtrl;
using AndroidCtrl.ADB;
...
namespace ....
...
private ADB myDevice = null;
...
public void InitDLL()
{
// check if we have adb rdy
if (ADB.IntegrityCheck() == false)
{
// if not
if (ADB.IsStarted)
{
ADB.Stop();
}
Deploy.ADB();
}

// check if adb is already running
if (ADB.IsStarted == false)
{
ADB.Start();
}

// check if we have a device connected
IEnumerable<DataModelDevicesItem> res = ADB.Devices();
if (res != null && res.Any())
{
// Set up the device
myDevice = ADB.Instance(res.ElementAt(0).Serial);

// to select the device dll wide u can act like
ADB.SelectDevice(res.ElementAt(0));
}
else
{
throw new Exception("No device found!");
}
}

public void DoSomething()
{
if (myDevice != null)
{
// get the data - here we don't need to care about NULL
// because BuildProperties.Get() will return
// an string.Empty if there is nothing to get
MyTextBox.Text = myDevice.Device.BuildProperties.Get("ro.product.model");

// if u have the device selected u can now act like
MyTextBox.Text = ADB.Instance().Device.BuildProperties.Get("ro.product.model");
// so u don't need the myDevice field and u can easily switch between devices
// via ADB.SelectDevice()
}
}
}

Hope this helps u to understand how u have to act ;)

EDIT:

There was a little error in the sample, i fixed it ;)

res.ElementAt(0).Device must be res.ElementAt(0).Serial

Regards,

Sebastian
[Android Software/Hacking General [Developers Only]] KP@2016:
Thank you sir.. You are great... Your work is really a good contribute to devs really.. Why don't you spread it along other forums also make youtube videos on it.. Or a docs would be great.... Really a great.. Work.. World must know your great contribution :svetius:
[Android Software/Hacking General [Developers Only]] k1ll3r8e:
Heyho,

THX mate! - About the documentation, here is a little how-to, when i'm done with the refactoring i'll extent the how-to. ;)

Regards,

Sebastian
[Android Software/Hacking General [Developers Only]] KP@2016:
Hey Bros Can you do a little help,,, I want to check with dll that If Adb has connection it should pass back some values elseif fastboot has connection it should passback some values Can you do this little help ;)
[Android Software/Hacking General [Developers Only]] k1ll3r8e:
Heyho,

have a look at this article ;)

Regards,

Sebastian
[Android Software/Hacking General [Developers Only]] Darkness1:
I like the class, I will write my personal android toolkit with this ;)

Just a question, have you tried to port it to work on mono too?
[Android Software/Hacking General [Developers Only]] k1ll3r8e:
Heyho,

currently there is no mono build, because i use some p/invokes, for example, the icon extraction and the unzip functionality. If i have time, i'll have a look for equivalents in mono. Maybe i can get it work without major changes, but the AndroidCtrlUI.dll might never work on mono because so far i have read (never read deep into it), mono doesn't support WPF and the AndroidCtrlUI.dll is based on WPF and the MVVM pattern. So in this case i have to create a complete new dll only for Win Forms that mono can render the UI items.

Hope i could help u ;)

Regards,

Sebastian
[Android Software/Hacking General [Developers Only]] amoamare:
The attribute [MethodImpl(MethodImplOptions.Synchronized)] is similar to calling lock(this) which can cause deadlocks and has a known bug for x64 static classes sense it locks as lock(typeof(class)) as noted here https://connect.microsoft.com/Visua...ckexception-when-used-on-static-method-on-x64

As well as https://stackoverflow.com/questions/2223656/what-does-methodimploptions-synchronized-do

Best practice is to lock on a private read only object.

Overall nice project and work.

internal class Foo
{
private readonly object SyncRoot = new object();

public void Bar()
{
lock(SyncRoot)
{
}
}
}
[Android Software/Hacking General [Developers Only]] k1ll3r8e:
Heyho,

thx for the "hint" but u should also read a bit deeper. Because as i mentioned here the lock() examples are not safe... Because, with Monitor.Exit(Foo); ur lock statement is useless^^ - Also i don't got any error or deadlocks as mentioned, so i'll not change it to insecure lock(). If i get some proofs that there is a crash which will appear ever and ever again i would do that but i got no reports in that direction.

Edit:

Just had another look at this case and found that: MSDN... This proofs my concept :P - Because "lock()" is likely "Monitor.something".

Regards,

Sebastian