7 Copyright (C) 2008-2009, Nicolas VIVIEN
8 Copyright (C) 2005-2010, 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>
36 using namespace Barry
;
41 const char *Version
= Barry::Version(major
, minor
);
44 << "bjvmdebug - Command line USB Blackberry Java Debugger\n"
45 << " Copyright 2008-2009, Nicolas VIVIEN.\n"
46 << " Copyright 2005-2010, Net Direct Inc. (http://www.netdirect.ca/)\n"
47 << " Using: " << Version
<< "\n"
50 << " -p pin PIN of device to talk with\n"
51 << " If only one device is plugged in, this flag is optional\n"
52 << " -P pass Simplistic method to specify device password\n"
53 << " -v Dump protocol data during operation\n"
58 int main(int argc
, char *argv
[])
65 bool data_dump
= false;
67 vector
<string
> params
;
70 // process command line options
72 int cmd
= getopt(argc
, argv
, "hp:P:v");
78 case 'p': // Blackberry PIN
79 pin
= strtoul(optarg
, NULL
, 16);
82 case 'P': // Device password
86 case 'v': // data dump on
97 // Initialize the barry library. Must be called before
99 Barry::Init(data_dump
);
101 // Probe the USB bus for Blackberry devices and display.
102 // If user has specified a PIN, search for it in the
103 // available device list here as well
105 int activeDevice
= probe
.FindActive(pin
);
106 if( activeDevice
== -1 ) {
107 cerr
<< "No device selected, or PIN not found" << endl
;
111 // Create our controller object
112 Barry::Controller
con(probe
.Get(activeDevice
));
113 Barry::Mode::JVMDebug
jvmdebug(con
);
116 // execute each mode that was turned on
118 jvmdebug
.Open(password
.c_str());
122 jvmdebug
.Unknown01();
123 jvmdebug
.Unknown02();
124 jvmdebug
.Unknown03();
125 jvmdebug
.Unknown04();
126 jvmdebug
.Unknown05();
129 cout
<< "Java Modules List :" << endl
;
131 jvmdebug
.GetModulesList(list
);
136 cout
<< "Java Threads currently running :" << endl
;
138 jvmdebug
.GetThreadsList(list
);
142 jvmdebug
.Unknown06();
143 jvmdebug
.Unknown07();
144 jvmdebug
.Unknown08();
145 jvmdebug
.Unknown09();
146 jvmdebug
.Unknown10();
150 for (int i
=0; i
<20; i
++) {
153 ret
= jvmdebug
.GetConsoleMessage(msg
);
157 jvmdebug
.GetStatus(status
);
160 cout
<< "JVM message : " << msg
<< endl
;
167 catch( Usb::Error
&ue
) {
168 std::cout
<< endl
; // flush any normal output first
169 std::cerr
<< "Usb::Error caught: " << ue
.what() << endl
;
172 catch( Barry::Error
&se
) {
174 std::cerr
<< "Barry::Error caught: " << se
.what() << endl
;
177 catch( std::exception
&e
) {
179 std::cerr
<< "std::exception caught: " << e
.what() << endl
;