2 /// \file bjavadebug.cc
7 Copyright (C) 2008-2009, Nicolas VIVIEN
8 Copyright (C) 2005-2009, Net Direct Inc. (http://www.netdirect.ca/)
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19 See the GNU General Public License in the COPYING file at the
20 root directory of this project for more details.
24 #include <barry/barry.h>
35 using namespace Barry
;
40 const char *Version
= Barry::Version(major
, minor
);
43 << "bjavadebug - Command line USB Blackberry Java Debugger\n"
44 << " Copyright 2008-2009, Nicolas VIVIEN.\n"
45 << " Copyright 2005-2009, Net Direct Inc. (http://www.netdirect.ca/)\n"
46 << " Using: " << Version
<< "\n"
49 << " -p pin PIN of device to talk with\n"
50 << " If only one device is plugged in, this flag is optional\n"
51 << " -P pass Simplistic method to specify device password\n"
52 << " -v Dump protocol data during operation\n"
57 int main(int argc
, char *argv
[])
62 bool data_dump
= false;
64 vector
<string
> params
;
67 // process command line options
69 int cmd
= getopt(argc
, argv
, "hp:P:v");
75 case 'p': // Blackberry PIN
76 pin
= strtoul(optarg
, NULL
, 16);
79 case 'P': // Device password
83 case 'v': // data dump on
94 // Initialize the barry library. Must be called before
96 Barry::Init(data_dump
);
98 // Probe the USB bus for Blackberry devices and display.
99 // If user has specified a PIN, search for it in the
100 // available device list here as well
102 int activeDevice
= probe
.FindActive(pin
);
103 if( activeDevice
== -1 ) {
104 cerr
<< "No device selected, or PIN not found" << endl
;
108 // Create our controller object
109 Barry::Controller
con(probe
.Get(activeDevice
));
110 Barry::Mode::JavaDebug
javadebug(con
);
113 // execute each mode that was turned on
115 javadebug
.Open(password
.c_str());
119 javadebug
.Unknown01();
120 javadebug
.Unknown02();
121 javadebug
.Unknown03();
122 javadebug
.Unknown04();
123 javadebug
.Unknown05();
126 cout
<< "Java Modules List :" << endl
;
128 javadebug
.GetModulesList(list
);
133 cout
<< "Java Threads currently running :" << endl
;
135 javadebug
.GetThreadsList(list
);
139 javadebug
.Unknown06();
140 javadebug
.Unknown07();
141 javadebug
.Unknown08();
142 javadebug
.Unknown09();
143 javadebug
.Unknown10();
147 for (int i
=0; i
<20; i
++) {
150 ret
= javadebug
.GetConsoleMessage(msg
);
154 javadebug
.GetStatus(status
);
157 cout
<< "JVM message : " << msg
<< endl
;
164 catch( Usb::Error
&ue
) {
165 std::cout
<< endl
; // flush any normal output first
166 std::cerr
<< "Usb::Error caught: " << ue
.what() << endl
;
169 catch( Barry::Error
&se
) {
171 std::cerr
<< "Barry::Error caught: " << se
.what() << endl
;
174 catch( std::exception
&e
) {
176 std::cerr
<< "std::exception caught: " << e
.what() << endl
;