7 Copyright (C) 2008-2009, Nicolas VIVIEN
8 Copyright (C) 2005-2013, 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>
34 #include "barrygetopt.h"
37 using namespace Barry
;
41 int logical
, major
, minor
;
42 const char *Version
= Barry::Version(logical
, major
, minor
);
44 cerr
<< string_vprintf(
45 _("bjvmdebug - Command line USB Blackberry Java Debugger\n"
46 " Copyright 2008-2009, Nicolas VIVIEN.\n"
47 " Copyright 2005-2013, Net Direct Inc. (http://www.netdirect.ca/)\n"
51 " -p pin PIN of device to talk with\n"
52 " If only one device is plugged in, this flag is optional\n"
53 " -P pass Simplistic method to specify device password\n"
54 " -v Dump protocol data during operation\n"), Version
)
59 int main(int argc
, char *argv
[])
66 bool data_dump
= false;
68 vector
<string
> params
;
71 // process command line options
73 int cmd
= getopt(argc
, argv
, "hp:P:v");
79 case 'p': // Blackberry PIN
80 pin
= strtoul(optarg
, NULL
, 16);
83 case 'P': // Device password
87 case 'v': // data dump on
98 // Initialize the barry library. Must be called before
100 Barry::Init(data_dump
);
102 // Probe the USB bus for Blackberry devices and display.
103 // If user has specified a PIN, search for it in the
104 // available device list here as well
106 int activeDevice
= probe
.FindActive(pin
);
107 if( activeDevice
== -1 ) {
108 cerr
<< _("No device selected, or PIN not found")
113 // Create our controller object
114 Barry::Controller
con(probe
.Get(activeDevice
));
115 Barry::Mode::JVMDebug
jvmdebug(con
);
118 // execute each mode that was turned on
120 jvmdebug
.Open(password
.c_str());
124 jvmdebug
.Unknown01();
125 jvmdebug
.Unknown02();
126 jvmdebug
.Unknown03();
127 jvmdebug
.Unknown04();
128 jvmdebug
.Unknown05();
131 cout
<< _("Java Modules List :") << endl
;
133 jvmdebug
.GetModulesList(list
);
138 cout
<< _("Java Threads currently running :") << endl
;
140 jvmdebug
.GetThreadsList(list
);
144 jvmdebug
.Unknown06();
145 jvmdebug
.Unknown07();
146 jvmdebug
.Unknown08();
147 jvmdebug
.Unknown09();
148 jvmdebug
.Unknown10();
152 for (int i
=0; i
<20; i
++) {
155 ret
= jvmdebug
.GetConsoleMessage(msg
);
159 jvmdebug
.GetStatus(status
);
162 cout
<< _("JVM message : ") << msg
<< endl
;
169 catch( Usb::Error
&ue
) {
170 std::cout
<< endl
; // flush any normal output first
171 std::cerr
<< _("Usb::Error caught: ") << ue
.what() << endl
;
174 catch( Barry::Error
&se
) {
176 std::cerr
<< _("Barry::Error caught: ") << se
.what() << endl
;
179 catch( std::exception
&e
) {
181 std::cerr
<< _("std::exception caught: ") << e
.what() << endl
;