Compare commits
66 commits
Author | SHA1 | Date | |
---|---|---|---|
|
417d212ea9 | ||
|
0e72b97770 | ||
|
2524968059 | ||
|
b6d6f18e6a | ||
|
6c0fb778f4 | ||
|
5c37ceaa97 | ||
|
1786276e52 | ||
|
3be31123e9 | ||
|
7b60923460 | ||
|
2f00e5264b | ||
|
6e4d3a3906 | ||
|
b115ecadb2 | ||
|
781da57c4e | ||
|
27f82da96a | ||
|
42658d7acb | ||
|
ce2d05edd4 | ||
|
5ce7782fab | ||
|
1467953323 | ||
|
6e20afa898 | ||
|
d506aa091c | ||
|
fb2e609b6e | ||
|
638f85281c | ||
|
730afcd0a4 | ||
|
952fb4ec83 | ||
|
cd9d69da30 | ||
|
83b771a186 | ||
|
1fc3004d41 | ||
|
076f041175 | ||
|
b324d94931 | ||
|
65f1d80cda | ||
|
74fa514608 | ||
|
ad20c28501 | ||
|
9c17f65208 | ||
|
56f3e05586 | ||
|
9600f0d081 | ||
|
739bbd3fc9 | ||
|
cfa0dc0eb4 | ||
|
3e41738d4b | ||
|
82434a0b96 | ||
|
b34f976b22 | ||
|
5e53cb8898 | ||
|
55ed268530 | ||
|
374c55e12f | ||
|
763ddd3473 | ||
|
7b9b222148 | ||
|
2516e8192d | ||
|
c45f13e083 | ||
|
20b22c90f0 | ||
|
8ef97f20db | ||
|
01b75daa26 | ||
|
a6a6b12e18 | ||
|
b2caad916c | ||
|
6df86b0bcc | ||
|
1ac3f6e76c | ||
|
d42fef5e50 | ||
|
4d90ab7f58 | ||
|
aef1947874 | ||
|
707c74f320 | ||
|
79a937965f | ||
|
10cfa46328 | ||
|
cee95c9712 | ||
|
83a325f1e8 | ||
|
d884acc4cb | ||
|
7436b556f3 | ||
|
d0858cca2b | ||
|
a35d8f8fa5 |
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
.vs
|
||||||
|
Output
|
3
.gitmodules
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
[submodule "TegraRcmGUI/tools/src/biskeydump"]
|
||||||
|
path = TegraRcmGUI/tools/src/biskeydump
|
||||||
|
url = https://github.com/eliboa/biskeydump
|
339
LICENSE
Normal file
|
@ -0,0 +1,339 @@
|
||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 2, June 1991
|
||||||
|
|
||||||
|
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||||
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The licenses for most software are designed to take away your
|
||||||
|
freedom to share and change it. By contrast, the GNU General Public
|
||||||
|
License is intended to guarantee your freedom to share and change free
|
||||||
|
software--to make sure the software is free for all its users. This
|
||||||
|
General Public License applies to most of the Free Software
|
||||||
|
Foundation's software and to any other program whose authors commit to
|
||||||
|
using it. (Some other Free Software Foundation software is covered by
|
||||||
|
the GNU Lesser General Public License instead.) You can apply it to
|
||||||
|
your programs, too.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
this service if you wish), that you receive source code or can get it
|
||||||
|
if you want it, that you can change the software or use pieces of it
|
||||||
|
in new free programs; and that you know you can do these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to make restrictions that forbid
|
||||||
|
anyone to deny you these rights or to ask you to surrender the rights.
|
||||||
|
These restrictions translate to certain responsibilities for you if you
|
||||||
|
distribute copies of the software, or if you modify it.
|
||||||
|
|
||||||
|
For example, if you distribute copies of such a program, whether
|
||||||
|
gratis or for a fee, you must give the recipients all the rights that
|
||||||
|
you have. You must make sure that they, too, receive or can get the
|
||||||
|
source code. And you must show them these terms so they know their
|
||||||
|
rights.
|
||||||
|
|
||||||
|
We protect your rights with two steps: (1) copyright the software, and
|
||||||
|
(2) offer you this license which gives you legal permission to copy,
|
||||||
|
distribute and/or modify the software.
|
||||||
|
|
||||||
|
Also, for each author's protection and ours, we want to make certain
|
||||||
|
that everyone understands that there is no warranty for this free
|
||||||
|
software. If the software is modified by someone else and passed on, we
|
||||||
|
want its recipients to know that what they have is not the original, so
|
||||||
|
that any problems introduced by others will not reflect on the original
|
||||||
|
authors' reputations.
|
||||||
|
|
||||||
|
Finally, any free program is threatened constantly by software
|
||||||
|
patents. We wish to avoid the danger that redistributors of a free
|
||||||
|
program will individually obtain patent licenses, in effect making the
|
||||||
|
program proprietary. To prevent this, we have made it clear that any
|
||||||
|
patent must be licensed for everyone's free use or not licensed at all.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||||
|
|
||||||
|
0. This License applies to any program or other work which contains
|
||||||
|
a notice placed by the copyright holder saying it may be distributed
|
||||||
|
under the terms of this General Public License. The "Program", below,
|
||||||
|
refers to any such program or work, and a "work based on the Program"
|
||||||
|
means either the Program or any derivative work under copyright law:
|
||||||
|
that is to say, a work containing the Program or a portion of it,
|
||||||
|
either verbatim or with modifications and/or translated into another
|
||||||
|
language. (Hereinafter, translation is included without limitation in
|
||||||
|
the term "modification".) Each licensee is addressed as "you".
|
||||||
|
|
||||||
|
Activities other than copying, distribution and modification are not
|
||||||
|
covered by this License; they are outside its scope. The act of
|
||||||
|
running the Program is not restricted, and the output from the Program
|
||||||
|
is covered only if its contents constitute a work based on the
|
||||||
|
Program (independent of having been made by running the Program).
|
||||||
|
Whether that is true depends on what the Program does.
|
||||||
|
|
||||||
|
1. You may copy and distribute verbatim copies of the Program's
|
||||||
|
source code as you receive it, in any medium, provided that you
|
||||||
|
conspicuously and appropriately publish on each copy an appropriate
|
||||||
|
copyright notice and disclaimer of warranty; keep intact all the
|
||||||
|
notices that refer to this License and to the absence of any warranty;
|
||||||
|
and give any other recipients of the Program a copy of this License
|
||||||
|
along with the Program.
|
||||||
|
|
||||||
|
You may charge a fee for the physical act of transferring a copy, and
|
||||||
|
you may at your option offer warranty protection in exchange for a fee.
|
||||||
|
|
||||||
|
2. You may modify your copy or copies of the Program or any portion
|
||||||
|
of it, thus forming a work based on the Program, and copy and
|
||||||
|
distribute such modifications or work under the terms of Section 1
|
||||||
|
above, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) You must cause the modified files to carry prominent notices
|
||||||
|
stating that you changed the files and the date of any change.
|
||||||
|
|
||||||
|
b) You must cause any work that you distribute or publish, that in
|
||||||
|
whole or in part contains or is derived from the Program or any
|
||||||
|
part thereof, to be licensed as a whole at no charge to all third
|
||||||
|
parties under the terms of this License.
|
||||||
|
|
||||||
|
c) If the modified program normally reads commands interactively
|
||||||
|
when run, you must cause it, when started running for such
|
||||||
|
interactive use in the most ordinary way, to print or display an
|
||||||
|
announcement including an appropriate copyright notice and a
|
||||||
|
notice that there is no warranty (or else, saying that you provide
|
||||||
|
a warranty) and that users may redistribute the program under
|
||||||
|
these conditions, and telling the user how to view a copy of this
|
||||||
|
License. (Exception: if the Program itself is interactive but
|
||||||
|
does not normally print such an announcement, your work based on
|
||||||
|
the Program is not required to print an announcement.)
|
||||||
|
|
||||||
|
These requirements apply to the modified work as a whole. If
|
||||||
|
identifiable sections of that work are not derived from the Program,
|
||||||
|
and can be reasonably considered independent and separate works in
|
||||||
|
themselves, then this License, and its terms, do not apply to those
|
||||||
|
sections when you distribute them as separate works. But when you
|
||||||
|
distribute the same sections as part of a whole which is a work based
|
||||||
|
on the Program, the distribution of the whole must be on the terms of
|
||||||
|
this License, whose permissions for other licensees extend to the
|
||||||
|
entire whole, and thus to each and every part regardless of who wrote it.
|
||||||
|
|
||||||
|
Thus, it is not the intent of this section to claim rights or contest
|
||||||
|
your rights to work written entirely by you; rather, the intent is to
|
||||||
|
exercise the right to control the distribution of derivative or
|
||||||
|
collective works based on the Program.
|
||||||
|
|
||||||
|
In addition, mere aggregation of another work not based on the Program
|
||||||
|
with the Program (or with a work based on the Program) on a volume of
|
||||||
|
a storage or distribution medium does not bring the other work under
|
||||||
|
the scope of this License.
|
||||||
|
|
||||||
|
3. You may copy and distribute the Program (or a work based on it,
|
||||||
|
under Section 2) in object code or executable form under the terms of
|
||||||
|
Sections 1 and 2 above provided that you also do one of the following:
|
||||||
|
|
||||||
|
a) Accompany it with the complete corresponding machine-readable
|
||||||
|
source code, which must be distributed under the terms of Sections
|
||||||
|
1 and 2 above on a medium customarily used for software interchange; or,
|
||||||
|
|
||||||
|
b) Accompany it with a written offer, valid for at least three
|
||||||
|
years, to give any third party, for a charge no more than your
|
||||||
|
cost of physically performing source distribution, a complete
|
||||||
|
machine-readable copy of the corresponding source code, to be
|
||||||
|
distributed under the terms of Sections 1 and 2 above on a medium
|
||||||
|
customarily used for software interchange; or,
|
||||||
|
|
||||||
|
c) Accompany it with the information you received as to the offer
|
||||||
|
to distribute corresponding source code. (This alternative is
|
||||||
|
allowed only for noncommercial distribution and only if you
|
||||||
|
received the program in object code or executable form with such
|
||||||
|
an offer, in accord with Subsection b above.)
|
||||||
|
|
||||||
|
The source code for a work means the preferred form of the work for
|
||||||
|
making modifications to it. For an executable work, complete source
|
||||||
|
code means all the source code for all modules it contains, plus any
|
||||||
|
associated interface definition files, plus the scripts used to
|
||||||
|
control compilation and installation of the executable. However, as a
|
||||||
|
special exception, the source code distributed need not include
|
||||||
|
anything that is normally distributed (in either source or binary
|
||||||
|
form) with the major components (compiler, kernel, and so on) of the
|
||||||
|
operating system on which the executable runs, unless that component
|
||||||
|
itself accompanies the executable.
|
||||||
|
|
||||||
|
If distribution of executable or object code is made by offering
|
||||||
|
access to copy from a designated place, then offering equivalent
|
||||||
|
access to copy the source code from the same place counts as
|
||||||
|
distribution of the source code, even though third parties are not
|
||||||
|
compelled to copy the source along with the object code.
|
||||||
|
|
||||||
|
4. You may not copy, modify, sublicense, or distribute the Program
|
||||||
|
except as expressly provided under this License. Any attempt
|
||||||
|
otherwise to copy, modify, sublicense or distribute the Program is
|
||||||
|
void, and will automatically terminate your rights under this License.
|
||||||
|
However, parties who have received copies, or rights, from you under
|
||||||
|
this License will not have their licenses terminated so long as such
|
||||||
|
parties remain in full compliance.
|
||||||
|
|
||||||
|
5. You are not required to accept this License, since you have not
|
||||||
|
signed it. However, nothing else grants you permission to modify or
|
||||||
|
distribute the Program or its derivative works. These actions are
|
||||||
|
prohibited by law if you do not accept this License. Therefore, by
|
||||||
|
modifying or distributing the Program (or any work based on the
|
||||||
|
Program), you indicate your acceptance of this License to do so, and
|
||||||
|
all its terms and conditions for copying, distributing or modifying
|
||||||
|
the Program or works based on it.
|
||||||
|
|
||||||
|
6. Each time you redistribute the Program (or any work based on the
|
||||||
|
Program), the recipient automatically receives a license from the
|
||||||
|
original licensor to copy, distribute or modify the Program subject to
|
||||||
|
these terms and conditions. You may not impose any further
|
||||||
|
restrictions on the recipients' exercise of the rights granted herein.
|
||||||
|
You are not responsible for enforcing compliance by third parties to
|
||||||
|
this License.
|
||||||
|
|
||||||
|
7. If, as a consequence of a court judgment or allegation of patent
|
||||||
|
infringement or for any other reason (not limited to patent issues),
|
||||||
|
conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot
|
||||||
|
distribute so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you
|
||||||
|
may not distribute the Program at all. For example, if a patent
|
||||||
|
license would not permit royalty-free redistribution of the Program by
|
||||||
|
all those who receive copies directly or indirectly through you, then
|
||||||
|
the only way you could satisfy both it and this License would be to
|
||||||
|
refrain entirely from distribution of the Program.
|
||||||
|
|
||||||
|
If any portion of this section is held invalid or unenforceable under
|
||||||
|
any particular circumstance, the balance of the section is intended to
|
||||||
|
apply and the section as a whole is intended to apply in other
|
||||||
|
circumstances.
|
||||||
|
|
||||||
|
It is not the purpose of this section to induce you to infringe any
|
||||||
|
patents or other property right claims or to contest validity of any
|
||||||
|
such claims; this section has the sole purpose of protecting the
|
||||||
|
integrity of the free software distribution system, which is
|
||||||
|
implemented by public license practices. Many people have made
|
||||||
|
generous contributions to the wide range of software distributed
|
||||||
|
through that system in reliance on consistent application of that
|
||||||
|
system; it is up to the author/donor to decide if he or she is willing
|
||||||
|
to distribute software through any other system and a licensee cannot
|
||||||
|
impose that choice.
|
||||||
|
|
||||||
|
This section is intended to make thoroughly clear what is believed to
|
||||||
|
be a consequence of the rest of this License.
|
||||||
|
|
||||||
|
8. If the distribution and/or use of the Program is restricted in
|
||||||
|
certain countries either by patents or by copyrighted interfaces, the
|
||||||
|
original copyright holder who places the Program under this License
|
||||||
|
may add an explicit geographical distribution limitation excluding
|
||||||
|
those countries, so that distribution is permitted only in or among
|
||||||
|
countries not thus excluded. In such case, this License incorporates
|
||||||
|
the limitation as if written in the body of this License.
|
||||||
|
|
||||||
|
9. The Free Software Foundation may publish revised and/or new versions
|
||||||
|
of the General Public License from time to time. Such new versions will
|
||||||
|
be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the Program
|
||||||
|
specifies a version number of this License which applies to it and "any
|
||||||
|
later version", you have the option of following the terms and conditions
|
||||||
|
either of that version or of any later version published by the Free
|
||||||
|
Software Foundation. If the Program does not specify a version number of
|
||||||
|
this License, you may choose any version ever published by the Free Software
|
||||||
|
Foundation.
|
||||||
|
|
||||||
|
10. If you wish to incorporate parts of the Program into other free
|
||||||
|
programs whose distribution conditions are different, write to the author
|
||||||
|
to ask for permission. For software which is copyrighted by the Free
|
||||||
|
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||||
|
make exceptions for this. Our decision will be guided by the two goals
|
||||||
|
of preserving the free status of all derivatives of our free software and
|
||||||
|
of promoting the sharing and reuse of software generally.
|
||||||
|
|
||||||
|
NO WARRANTY
|
||||||
|
|
||||||
|
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||||
|
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||||
|
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||||
|
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||||
|
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||||
|
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||||
|
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||||
|
REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||||
|
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||||
|
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||||
|
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||||
|
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||||
|
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||||
|
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||||
|
POSSIBILITY OF SUCH DAMAGES.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest
|
||||||
|
to attach them to the start of each source file to most effectively
|
||||||
|
convey the exclusion of warranty; and each file should have at least
|
||||||
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License along
|
||||||
|
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If the program is interactive, make it output a short notice like this
|
||||||
|
when it starts in an interactive mode:
|
||||||
|
|
||||||
|
Gnomovision version 69, Copyright (C) year name of author
|
||||||
|
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
|
This is free software, and you are welcome to redistribute it
|
||||||
|
under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
|
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||||
|
parts of the General Public License. Of course, the commands you use may
|
||||||
|
be called something other than `show w' and `show c'; they could even be
|
||||||
|
mouse-clicks or menu items--whatever suits your program.
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or your
|
||||||
|
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||||
|
necessary. Here is a sample; alter the names:
|
||||||
|
|
||||||
|
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||||
|
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||||
|
|
||||||
|
<signature of Ty Coon>, 1 April 1989
|
||||||
|
Ty Coon, President of Vice
|
||||||
|
|
||||||
|
This General Public License does not permit incorporating your program into
|
||||||
|
proprietary programs. If your program is a subroutine library, you may
|
||||||
|
consider it more useful to permit linking proprietary applications with the
|
||||||
|
library. If this is what you want to do, use the GNU Lesser General
|
||||||
|
Public License instead of this License.
|
63
README.md
|
@ -1,22 +1,59 @@
|
||||||
# TegraRcmGUI
|

|
||||||
A simple C++ GUI for [TegraRcmSmash](https://github.com/rajkosto/TegraRcmSmash) by [rajkosto](https://github.com/rajkosto).
|

|
||||||
|

|
||||||
|

|
||||||
|

|
||||||
|

|
||||||
|
|
||||||
## Important notice
|
# TegraRcmGUI
|
||||||
I did not code the original application, only GUI related parts (all credits goes to @rajkosto & @ktemkin).
|
C++ GUI for [TegraRcmSmash](https://github.com/rajkosto/TegraRcmSmash) by [rajkosto](https://github.com/rajkosto) (Fusée Gelée exploit for Nintendo Switch)
|
||||||
I used TegraRcmSmash_v1.1 in this project. Since then, rajkosto released new binaries, check out his [website](https://switchtools.sshnuke.net/) !
|
|
||||||
|
The RCM exploit only works on "unpatched" units, i.e manufactured before July 2018. To check if your Switch is patched, use https://ismyswitchpatched.com/
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
- Inject payloads, such as CFW loader
|
- Inject payloads
|
||||||
- Run Linux on your switch
|
- Manage favorites
|
||||||
- Auto inject option : automatically inject payload after selection or/and when the Switch is plugged in RCM mode (does not apply at startup)
|
- Run Linux on your switch (ShofEL2)
|
||||||
|
- Mount device as USB mass storage (read/write from/to SD card & NAND partitions, hold power button down for 5sec to exit)
|
||||||
|
- Dump BIS keys for eMMC content decryption (biskeydump by rajkosto)
|
||||||
|
- Option - "Auto inject" : automatically inject payload after selection or/and when the Switch is plugged in RCM mode
|
||||||
|
- Option - Minimize app to tray & tray icon's context menu
|
||||||
|
- Option - Run app at Windows startup
|
||||||
- Install APX device driver (if needed)
|
- Install APX device driver (if needed)
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## Download
|
## Download
|
||||||
[Latest release](https://github.com/eliboa/TegraRcmGUI/releases) (Windows)
|
[Latest release](https://github.com/eliboa/TegraRcmGUI/releases/latest) (Windows)
|
||||||
|
|
||||||
|
## Important notice
|
||||||
|
This UI is **Windows-only**.
|
||||||
|
For other platforms, you can use :
|
||||||
|
- [Fusée Launcher](https://github.com/Cease-and-DeSwitch/fusee-launcher) (GNU/Linux)
|
||||||
|
- [NXBoot](https://mologie.github.io/nxboot/) (OS X, iOS)
|
||||||
|
- [JTegraNX](https://github.com/dylwedma11748/JTegraNX) (Windows, OS X, GNU/Linux)
|
||||||
|
- [NXLoader](https://github.com/DavidBuchanan314/NXLoader) (Android)
|
||||||
|
- [Web Fusée Launcher](https://fusee-gelee.firebaseapp.com/) (Cross-platform, only works with Chrome)
|
||||||
|
|
||||||
|
## Issue / Suggestion
|
||||||
|
Please open new [issue](https://github.com/eliboa/TegraRcmGUI/issues) to report a bug or submit a suggestion.
|
||||||
|
|
||||||
|
## Development
|
||||||
|
|
||||||
|
Install the [libusbk dev kit](https://sourceforge.net/projects/libusbk/) using the setup program, then create an environment variable `LIBUSBK_DIR` with the installation path as the value.
|
||||||
|
|
||||||
|
## How to backup/restore your Nintendo Switch's NAND ?
|
||||||
|
|
||||||
|
1) Use [memloader](https://github.com/rajkosto/memloader) v3 to mount eMMC on your computer
|
||||||
|
2) Download and open [NxNandManager](https://github.com/eliboa/NxNandManager). Select "File" then "Open drive".
|
||||||
|
3) Select the mounted drive. You can now perform backup/restore operations.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
## Credits
|
## Credits
|
||||||
- [Kate Temkin](https://github.com/ktemkin) / Fusée Launcher
|
- [Rajkosto](https://github.com/rajkosto) / [TegraRcmSmash](https://github.com/rajkosto/TegraRcmSmash) (Fusée Launcher reimplementation for Windows), [memloader](https://github.com/rajkosto/memloader), SD tool, [biskeydump](https://github.com/rajkosto/biskeydump)
|
||||||
- [Rajkosto](https://github.com/rajkosto) / TegraRcmSmash (Fusée Launcher reimplementation for Windows)
|
- [Kate Temkin](https://github.com/ktemkin) / [Fusée Launcher](https://github.com/Cease-and-DeSwitch/fusee-launcher)
|
||||||
- [fail0verflow](https://github.com/fail0verflow) / ShofEL2 (Boot stack for no-modification, universal code execution and Linux on the Nintendo Switch)
|
- [fail0verflow](https://github.com/fail0verflow) / [ShofEL2](https://github.com/fail0verflow/shofel2) (Boot stack for no-modification, universal code execution and Linux on the Nintendo Switch)
|
||||||
|
- [SciresM](https://github.com/SciresM) / [Atmosphere](https://github.com/Atmosphere-NX/Atmosphere)
|
||||||
|
- [CTCaer](https://github.com/CTCaer/hekate) / [Hekate](https://github.com/CTCaer/hekate)
|
||||||
|
- [Reisyukaku](https://github.com/Reisyukaku/) / [ReiNX](https://github.com/Reisyukaku/ReiNX)
|
||||||
|
|
BIN
TegraRcmGUI.rc
|
@ -1,9 +1,9 @@
|
||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio 14
|
# Visual Studio 15
|
||||||
VisualStudioVersion = 14.0.24720.0
|
VisualStudioVersion = 15.0.26228.9
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TegraRcmGUI", "TegraRcmGUI.vcxproj", "{2C091C5B-378F-44D0-91F2-53489BA7B83C}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TegraRcmGUI", "TegraRcmGUI\TegraRcmGUI.vcxproj", "{2C091C5B-378F-44D0-91F2-53489BA7B83C}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<PropertyGroup />
|
|
||||||
</Project>
|
|
371
TegraRcmGUI/DialogTab01.cpp
Normal file
|
@ -0,0 +1,371 @@
|
||||||
|
/*
|
||||||
|
DialogTab01.cpp
|
||||||
|
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright(c) 2018 eliboa
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files(the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions :
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "stdafx.h"
|
||||||
|
#include "TegraRcmGUI.h"
|
||||||
|
#include "DialogTab01.h"
|
||||||
|
#include "afxdialogex.h"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
|
||||||
|
// DialogTab01 dialog
|
||||||
|
|
||||||
|
IMPLEMENT_DYNAMIC(DialogTab01, CDialog)
|
||||||
|
|
||||||
|
DialogTab01::DialogTab01(TegraRcm *pTegraRcm, CWnd* Parent /*=NULL*/)
|
||||||
|
: CDialog(ID_DIALOGTAB_01, Parent)
|
||||||
|
{
|
||||||
|
m_TegraRcm = pTegraRcm;
|
||||||
|
}
|
||||||
|
|
||||||
|
DialogTab01::~DialogTab01()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BOOL DialogTab01::OnInitDialog()
|
||||||
|
{
|
||||||
|
CDialog::OnInitDialog();
|
||||||
|
CRect rc;
|
||||||
|
|
||||||
|
string pfile = m_TegraRcm->GetPreset("PAYLOAD_FILE");
|
||||||
|
CString file(pfile.c_str());
|
||||||
|
this->GetDlgItem(PAYLOAD_PATH)->SetWindowTextW(file);
|
||||||
|
|
||||||
|
CButton* pBtn = (CButton*)GetDlgItem(IDC_BROWSE);
|
||||||
|
pBtn->GetWindowRect(rc);
|
||||||
|
int height = rc.Height() * 0.8;
|
||||||
|
pBtn->ModifyStyle(0, BS_ICON);
|
||||||
|
HICON hIcn = (HICON)LoadImage(
|
||||||
|
AfxGetApp()->m_hInstance,
|
||||||
|
MAKEINTRESOURCE(ID_BROWSE_ICON),
|
||||||
|
IMAGE_ICON,
|
||||||
|
height, height, // use actual size
|
||||||
|
LR_DEFAULTCOLOR
|
||||||
|
);
|
||||||
|
|
||||||
|
pBtn->SetIcon(hIcn);
|
||||||
|
|
||||||
|
pBtn = (CButton*)GetDlgItem(ID_ADD_FAV);
|
||||||
|
|
||||||
|
|
||||||
|
pBtn->GetWindowRect(rc);
|
||||||
|
height = rc.Height() * 0.8;
|
||||||
|
|
||||||
|
pBtn->ModifyStyle(0, BS_ICON);
|
||||||
|
hIcn = (HICON)LoadImage(
|
||||||
|
AfxGetApp()->m_hInstance,
|
||||||
|
MAKEINTRESOURCE(ID_ADD_ICON),
|
||||||
|
IMAGE_ICON,
|
||||||
|
height, height, // use actual size
|
||||||
|
LR_DEFAULTCOLOR
|
||||||
|
);
|
||||||
|
pBtn->SetIcon(hIcn);
|
||||||
|
|
||||||
|
pBtn = (CButton*)GetDlgItem(ID_DEL_FAV);
|
||||||
|
pBtn->ModifyStyle(0, BS_ICON);
|
||||||
|
hIcn = (HICON)LoadImage(
|
||||||
|
AfxGetApp()->m_hInstance,
|
||||||
|
MAKEINTRESOURCE(ID_DELETE_ICON),
|
||||||
|
IMAGE_ICON,
|
||||||
|
height, height, // use actual size
|
||||||
|
LR_DEFAULTCOLOR
|
||||||
|
);
|
||||||
|
pBtn->SetIcon(hIcn);
|
||||||
|
|
||||||
|
PREVENT_AUTOINJECT = FALSE;
|
||||||
|
|
||||||
|
m_TegraRcm->AppendLog("Add favorites to listbox");
|
||||||
|
|
||||||
|
for (int i = 0; i < m_TegraRcm->Favorites.GetCount(); i++)
|
||||||
|
{
|
||||||
|
CListBox*pListBox = (CListBox*)GetDlgItem(IDC_LIST1);
|
||||||
|
CString fav = m_TegraRcm->Favorites[i];
|
||||||
|
int nIndex = fav.ReverseFind(_T('\\'));
|
||||||
|
CString csFilename, csPath, Item;
|
||||||
|
if (nIndex > 0)
|
||||||
|
{
|
||||||
|
csFilename = fav.Right(fav.GetLength() - nIndex - 1);
|
||||||
|
csPath = fav.Left(nIndex);
|
||||||
|
Item = csFilename + _T(" (") + csPath + _T(")");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Item = fav;
|
||||||
|
}
|
||||||
|
pListBox->AddString(_tcsdup(Item));
|
||||||
|
|
||||||
|
wstring wcsPath(csPath);
|
||||||
|
string scsPath(wcsPath.begin(), wcsPath.end());
|
||||||
|
m_TegraRcm->AppendLog("Add favorites to listbox");
|
||||||
|
m_TegraRcm->AppendLog(scsPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
CFont* pFont = GetFont();
|
||||||
|
LOGFONT lf;
|
||||||
|
pFont->GetLogFont(&lf);
|
||||||
|
lf.lfWeight = FW_BOLD;
|
||||||
|
m_BoldFont.CreateFontIndirect(&lf);
|
||||||
|
|
||||||
|
GetDlgItem(IDC_INJECT)->SendMessage(WM_SETFONT, WPARAM(HFONT(m_BoldFont)), 0);
|
||||||
|
|
||||||
|
return TRUE; // return TRUE unless you set the focus to a control
|
||||||
|
// EXCEPTION: OCX Property Pages should return FALSE
|
||||||
|
}
|
||||||
|
|
||||||
|
BEGIN_MESSAGE_MAP(DialogTab01, CDialog)
|
||||||
|
ON_BN_CLICKED(IDC_BROWSE, &DialogTab01::OnBnClickedBrowse)
|
||||||
|
ON_BN_CLICKED(IDC_INJECT, &DialogTab01::InjectPayload)
|
||||||
|
ON_BN_CLICKED(ID_ADD_FAV, &DialogTab01::OnBnClickedAddFav)
|
||||||
|
ON_BN_CLICKED(ID_DEL_FAV, &DialogTab01::OnBnClickedDelFav)
|
||||||
|
ON_LBN_DBLCLK(IDC_LIST1, &DialogTab01::OnDblclkList1)
|
||||||
|
ON_LBN_SELCHANGE(IDC_LIST1, &DialogTab01::OnLbnSelchangeList1)
|
||||||
|
ON_MESSAGE(DM_GETDEFID, OnGetDefID)
|
||||||
|
ON_WM_CTLCOLOR()
|
||||||
|
END_MESSAGE_MAP()
|
||||||
|
|
||||||
|
//
|
||||||
|
// Auto-inject on change path
|
||||||
|
//
|
||||||
|
void DialogTab01::OnEnChangePath()
|
||||||
|
{
|
||||||
|
CString file;
|
||||||
|
GetDlgItem(PAYLOAD_PATH)->GetWindowTextW(file);
|
||||||
|
PAYLOAD_FILE = _tcsdup(file);
|
||||||
|
|
||||||
|
if (!PREVENT_AUTOINJECT)
|
||||||
|
{
|
||||||
|
// Save payload path
|
||||||
|
CT2CA pszConvertedAnsiString(file);
|
||||||
|
std::string file_c(pszConvertedAnsiString);
|
||||||
|
m_TegraRcm->SetPreset("PAYLOAD_FILE", file_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
string value = m_TegraRcm->GetPreset("AUTO_INJECT");
|
||||||
|
TegraRcmSmash device;
|
||||||
|
int RCM_STATUS = device.RcmStatus();
|
||||||
|
// If Auto inject option enabled
|
||||||
|
if (value == "TRUE" && !PREVENT_AUTOINJECT)
|
||||||
|
{
|
||||||
|
// Delay auto inject if RCM not detected
|
||||||
|
if (RCM_STATUS != 0)
|
||||||
|
{
|
||||||
|
DELAY_AUTOINJECT = TRUE;
|
||||||
|
m_TegraRcm->SendUserMessage("Injection scheduled. Waiting for device", VALID);
|
||||||
|
}
|
||||||
|
// Inject payload if RCM detected
|
||||||
|
else {
|
||||||
|
InjectPayload();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
PREVENT_AUTOINJECT = FALSE;
|
||||||
|
}
|
||||||
|
void DialogTab01::OnBnClickedBrowse()
|
||||||
|
{
|
||||||
|
CString szFilter;
|
||||||
|
szFilter = "Bin files (*.bin)|*.bin|All files (*.*)|*.*||";
|
||||||
|
|
||||||
|
CFileDialog FileOpenDialog(
|
||||||
|
TRUE,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST,
|
||||||
|
szFilter, // filter
|
||||||
|
AfxGetMainWnd()); // the parent window
|
||||||
|
|
||||||
|
CString file;
|
||||||
|
this->GetDlgItem(PAYLOAD_PATH)->GetWindowTextW(file);
|
||||||
|
FileOpenDialog.m_ofn.lpstrInitialDir = file;
|
||||||
|
|
||||||
|
if (FileOpenDialog.DoModal() == IDOK)
|
||||||
|
{
|
||||||
|
CFile File;
|
||||||
|
VERIFY(File.Open(FileOpenDialog.GetPathName(), CFile::modeRead));
|
||||||
|
CString Filename;
|
||||||
|
Filename = File.GetFilePath();
|
||||||
|
this->GetDlgItem(PAYLOAD_PATH)->SetWindowTextW(Filename);
|
||||||
|
OnEnChangePath();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void DialogTab01::InjectPayload()
|
||||||
|
{
|
||||||
|
CString file;
|
||||||
|
this->GetDlgItem(PAYLOAD_PATH)->GetWindowTextW(file);
|
||||||
|
PAYLOAD_FILE = _tcsdup(file);
|
||||||
|
|
||||||
|
if (PAYLOAD_FILE == nullptr) {
|
||||||
|
m_TegraRcm->BitmapDisplay(LOAD_ERROR);
|
||||||
|
m_TegraRcm->SendUserMessage("No file selected", INVALID);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::ifstream infile(file);
|
||||||
|
if (!infile.good())
|
||||||
|
{
|
||||||
|
m_TegraRcm->SendUserMessage("File doesn't exist", INVALID);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_TegraRcm->BitmapDisplay(LOADING);
|
||||||
|
GetParent()->UpdateWindow();
|
||||||
|
|
||||||
|
TCHAR cmd[MAX_PATH] = TEXT("\"");
|
||||||
|
lstrcat(cmd, PAYLOAD_FILE);
|
||||||
|
lstrcat(cmd, TEXT("\""));
|
||||||
|
|
||||||
|
m_TegraRcm->SendUserMessage("Injecting payload...");
|
||||||
|
int rc = m_TegraRcm->Smasher(cmd);
|
||||||
|
if (rc >= 0)
|
||||||
|
{
|
||||||
|
m_TegraRcm->BitmapDisplay(LOADED);
|
||||||
|
m_TegraRcm->SendUserMessage("Payload injected !", VALID);
|
||||||
|
m_TegraRcm->AppendLogBox(TEXT("Payload successfully injected\r\n"));
|
||||||
|
m_TegraRcm->WAITING_RECONNECT = TRUE;
|
||||||
|
if (!m_TegraRcm->CmdShow) m_TegraRcm->ShowTrayIconBalloon(TEXT("Payload injected"), TEXT(" "), 1000, NIIF_INFO);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_TegraRcm->BitmapDisplay(LOAD_ERROR);
|
||||||
|
string s = "Error while injecting payload (RC=" + std::to_string(rc) + ")";
|
||||||
|
if (!m_TegraRcm->CmdShow) m_TegraRcm->ShowTrayIconBalloon(TEXT("Error"), TEXT("Error while injecting payload"), 1000, NIIF_ERROR);
|
||||||
|
m_TegraRcm->SendUserMessage(s.c_str(), INVALID);
|
||||||
|
CString rc_str;
|
||||||
|
rc_str.Format(L"%d", rc);
|
||||||
|
m_TegraRcm->AppendLogBox(TEXT("Error while injecting payload (RC=") + rc_str + TEXT(")\r\n"));
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DialogTab01::OnBnClickedAddFav()
|
||||||
|
{
|
||||||
|
|
||||||
|
CString csPath;
|
||||||
|
GetDlgItem(PAYLOAD_PATH)->GetWindowTextW(csPath);
|
||||||
|
std::ifstream infile(csPath);
|
||||||
|
if (!infile.good())
|
||||||
|
{
|
||||||
|
m_TegraRcm->SendUserMessage("File doesn't exist", INVALID);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
CListBox*pListBox = (CListBox*) GetDlgItem(IDC_LIST1);
|
||||||
|
CString csPathf(csPath), csFilename, Item;
|
||||||
|
int nIndex = csPathf.ReverseFind(_T('\\'));
|
||||||
|
if (nIndex > 0) csFilename = csPathf.Right(csPathf.GetLength() - nIndex - 1);
|
||||||
|
else return;
|
||||||
|
|
||||||
|
for (int i = 0; i < m_TegraRcm->Favorites.GetCount(); i++)
|
||||||
|
{
|
||||||
|
if (m_TegraRcm->Favorites[i] == csPathf)
|
||||||
|
{
|
||||||
|
m_TegraRcm->SendUserMessage("Favorite already exists", INVALID);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
csPath = csPathf.Left(nIndex);
|
||||||
|
Item = csFilename + _T(" (") + csPath + _T(")");
|
||||||
|
pListBox->AddString(_tcsdup(Item));
|
||||||
|
m_ListBox.Add(csPathf);
|
||||||
|
m_TegraRcm->Favorites.Add(csPathf);
|
||||||
|
m_TegraRcm->SaveFavorites();
|
||||||
|
|
||||||
|
m_TegraRcm->SendUserMessage("Favorite added", VALID);
|
||||||
|
m_TegraRcm->AppendLogBox(TEXT("New favorite added\r\n"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DialogTab01::OnBnClickedDelFav()
|
||||||
|
{
|
||||||
|
|
||||||
|
CListBox*pListBox = (CListBox*)GetDlgItem(IDC_LIST1);
|
||||||
|
int i = pListBox->GetCurSel();
|
||||||
|
if (i >= 0)
|
||||||
|
{
|
||||||
|
pListBox->DeleteString(i);
|
||||||
|
m_TegraRcm->Favorites.RemoveAt(i);
|
||||||
|
m_TegraRcm->SaveFavorites();
|
||||||
|
m_TegraRcm->SendUserMessage("Favorite removed", VALID);
|
||||||
|
m_TegraRcm->AppendLogBox(TEXT("Favorite removed\r\n"));
|
||||||
|
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DialogTab01::OnDblclkList1()
|
||||||
|
{
|
||||||
|
if (m_SelectedItem >= 0)
|
||||||
|
{
|
||||||
|
CString fav = m_TegraRcm->Favorites.GetAt(m_SelectedItem);
|
||||||
|
GetDlgItem(PAYLOAD_PATH)->SetWindowTextW(fav);
|
||||||
|
GetDlgItem(PAYLOAD_PATH)->GetFocus();
|
||||||
|
if (m_TegraRcm->GetPreset("AUTO_INJECT") != "TRUE" && m_TegraRcm->GetRcmStatus() == 0)
|
||||||
|
{
|
||||||
|
InjectPayload();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
OnEnChangePath();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DialogTab01::OnLbnSelchangeList1()
|
||||||
|
{
|
||||||
|
CListBox*pListBox = (CListBox*)GetDlgItem(IDC_LIST1);
|
||||||
|
int i = pListBox->GetCurSel();
|
||||||
|
if (i >= 0)
|
||||||
|
{
|
||||||
|
m_SelectedItem = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
HBRUSH DialogTab01::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
|
||||||
|
{
|
||||||
|
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
|
||||||
|
|
||||||
|
switch (pWnd->GetDlgCtrlID())
|
||||||
|
{
|
||||||
|
case ID_SELECT_PAYLOAD:
|
||||||
|
case ID_FAVORITES_TITLE:
|
||||||
|
pDC->SelectObject(&m_BoldFont);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return hbr;
|
||||||
|
}
|
||||||
|
LRESULT DialogTab01::OnGetDefID(WPARAM wp, LPARAM lp)
|
||||||
|
{
|
||||||
|
return MAKELONG(0, DC_HASDEFID);
|
||||||
|
}
|
44
TegraRcmGUI/DialogTab01.h
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
#pragma once
|
||||||
|
#include <string>
|
||||||
|
#include "TegraRcmGUIDlg.h"
|
||||||
|
#include "TegraRcm.h"
|
||||||
|
#include "afxole.h"
|
||||||
|
|
||||||
|
// DialogTab01 dialog
|
||||||
|
|
||||||
|
class DialogTab01 :
|
||||||
|
public CDialog
|
||||||
|
{
|
||||||
|
DECLARE_DYNAMIC(DialogTab01)
|
||||||
|
public:
|
||||||
|
DialogTab01(TegraRcm *pTegraRcm, CWnd* Parent = NULL); // standard constructor
|
||||||
|
virtual ~DialogTab01();
|
||||||
|
|
||||||
|
// Dialog Data
|
||||||
|
#ifdef AFX_DESIGN_TIME
|
||||||
|
enum { IDD = ID_DIALOGTAB_01 };
|
||||||
|
#endif
|
||||||
|
TCHAR* PAYLOAD_FILE;
|
||||||
|
BOOL PREVENT_AUTOINJECT = TRUE;
|
||||||
|
BOOL DELAY_AUTOINJECT = TRUE;
|
||||||
|
CArray <CString, CString> m_ListBox;
|
||||||
|
int m_SelectedItem = -1;
|
||||||
|
CFont m_BoldFont;
|
||||||
|
virtual BOOL OnInitDialog();
|
||||||
|
DECLARE_MESSAGE_MAP()
|
||||||
|
|
||||||
|
afx_msg void OnEnChangePath();
|
||||||
|
|
||||||
|
private:
|
||||||
|
TegraRcm *m_TegraRcm;
|
||||||
|
public:
|
||||||
|
afx_msg void InjectPayload();
|
||||||
|
afx_msg void OnBnClickedBrowse();
|
||||||
|
afx_msg void OnBnClickedAddFav();
|
||||||
|
afx_msg void OnBnClickedDelFav();
|
||||||
|
afx_msg void OnDblclkList1();
|
||||||
|
afx_msg void OnLbnSelchangeList1();
|
||||||
|
afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
|
||||||
|
COleDropTarget FileDropTarget;
|
||||||
|
afx_msg LRESULT OnGetDefID(WPARAM wp, LPARAM lp);
|
||||||
|
};
|
385
TegraRcmGUI/DialogTab02.cpp
Normal file
|
@ -0,0 +1,385 @@
|
||||||
|
/*
|
||||||
|
DialogTab02.cpp
|
||||||
|
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright(c) 2018 eliboa
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files(the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions :
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
|
||||||
|
*/
|
||||||
|
//
|
||||||
|
#include "stdafx.h"
|
||||||
|
#include "TegraRcmGUI.h"
|
||||||
|
#include "afxdialogex.h"
|
||||||
|
#include "DialogTab02.h"
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <codecvt>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
// DialogTab02 dialog
|
||||||
|
|
||||||
|
IMPLEMENT_DYNAMIC(DialogTab02, CDialogEx)
|
||||||
|
|
||||||
|
DialogTab02::DialogTab02(TegraRcm *pTegraRcm, CWnd* Parent /*=NULL*/)
|
||||||
|
: CDialogEx(ID_DIALOGTAB_02, Parent)
|
||||||
|
{
|
||||||
|
m_TegraRcm = pTegraRcm;
|
||||||
|
}
|
||||||
|
|
||||||
|
DialogTab02::~DialogTab02()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialogTab02::DoDataExchange(CDataExchange* pDX)
|
||||||
|
{
|
||||||
|
CDialogEx::DoDataExchange(pDX);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BEGIN_MESSAGE_MAP(DialogTab02, CDialogEx)
|
||||||
|
ON_BN_CLICKED(IDC_MOUNT_SD, &DialogTab02::OnBnClickedMountSd)
|
||||||
|
ON_BN_CLICKED(IDC_SHOFEL2, &DialogTab02::OnBnClickedShofel2)
|
||||||
|
// ON_WM_CTLCOLOR()
|
||||||
|
ON_WM_CTLCOLOR()
|
||||||
|
ON_BN_CLICKED(IDC_DUMP_BISKEY, &DialogTab02::OnBnClickedDumpBiskey)
|
||||||
|
END_MESSAGE_MAP()
|
||||||
|
|
||||||
|
|
||||||
|
// DialogTab02 message handlers
|
||||||
|
|
||||||
|
BOOL DialogTab02::OnInitDialog()
|
||||||
|
{
|
||||||
|
CDialogEx::OnInitDialog();
|
||||||
|
CRect rc;
|
||||||
|
|
||||||
|
CButton* pBtn = (CButton*)GetDlgItem(IDC_MOUNT_SD);
|
||||||
|
pBtn->GetWindowRect(rc);
|
||||||
|
int height = rc.Height() * 0.8;
|
||||||
|
pBtn->ModifyStyle(0, BS_ICON);
|
||||||
|
HICON hIcn = (HICON)LoadImage(
|
||||||
|
AfxGetApp()->m_hInstance,
|
||||||
|
MAKEINTRESOURCE(ID_UMSTOOL_ICON),
|
||||||
|
IMAGE_ICON,
|
||||||
|
height, height, // use actual size
|
||||||
|
LR_DEFAULTCOLOR
|
||||||
|
);
|
||||||
|
pBtn->SetIcon(hIcn);
|
||||||
|
|
||||||
|
pBtn = (CButton*)GetDlgItem(IDC_SHOFEL2);
|
||||||
|
pBtn->ModifyStyle(0, BS_ICON);
|
||||||
|
hIcn = (HICON)LoadImage(
|
||||||
|
AfxGetApp()->m_hInstance,
|
||||||
|
MAKEINTRESOURCE(ID_LINUX_ICON),
|
||||||
|
IMAGE_ICON,
|
||||||
|
height, height, // use actual size
|
||||||
|
LR_DEFAULTCOLOR
|
||||||
|
);
|
||||||
|
pBtn->SetIcon(hIcn);
|
||||||
|
|
||||||
|
pBtn = (CButton*)GetDlgItem(IDC_DUMP_BISKEY);
|
||||||
|
pBtn->ModifyStyle(0, BS_ICON);
|
||||||
|
hIcn = (HICON)LoadImage(
|
||||||
|
AfxGetApp()->m_hInstance,
|
||||||
|
MAKEINTRESOURCE(ID_KEYS_ICON),
|
||||||
|
IMAGE_ICON,
|
||||||
|
height, height, // use actual size
|
||||||
|
LR_DEFAULTCOLOR
|
||||||
|
);
|
||||||
|
pBtn->SetIcon(hIcn);
|
||||||
|
|
||||||
|
CFont* pFont = GetFont();
|
||||||
|
LOGFONT lf;
|
||||||
|
pFont->GetLogFont(&lf);
|
||||||
|
lf.lfWeight = FW_BOLD;
|
||||||
|
m_BoldFont.CreateFontIndirect(&lf);
|
||||||
|
|
||||||
|
CComboBox* pmyComboBox = (CComboBox*)GetDlgItem(ID_UMS_COMBO);
|
||||||
|
pmyComboBox->AddString(TEXT("eMMC BOOT0 (DANGEROUS)"));
|
||||||
|
pmyComboBox->AddString(TEXT("eMMC BOOT1 (DANGEROUS)"));
|
||||||
|
pmyComboBox->AddString(TEXT("eMMC rawNAND (DANGEROUS)"));
|
||||||
|
pmyComboBox->AddString(TEXT("MMC - SD Card"));
|
||||||
|
pmyComboBox->SetCurSel(3);
|
||||||
|
|
||||||
|
|
||||||
|
return TRUE; // return TRUE unless you set the focus to a control
|
||||||
|
// EXCEPTION: OCX Property Pages should return FALSE
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialogTab02::OnBnClickedMountSd()
|
||||||
|
{
|
||||||
|
CComboBox* pmyComboBox = (CComboBox*)GetDlgItem(ID_UMS_COMBO);
|
||||||
|
if (pmyComboBox->GetCurSel() < 3) {
|
||||||
|
CString message = _T("-----> WARNING <-----\nYou are about to mount internal storage of your Nintendo Switch\nBE VERY CAREFUL ! Do not format or write to your NAND partitions if you don't know what you're doing.\nTHIS COULD BRICK YOUR CONSOLE !!!\n\nAre you really sure you want to continue ?");
|
||||||
|
const int result = MessageBox(message, _T("BEWARE & WARNING"), MB_YESNO | MB_ICONWARNING);
|
||||||
|
if (result != IDYES) {
|
||||||
|
m_TegraRcm->AppendLogBox(TEXT("Mount NAND partition ABORTED\r\n"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_TegraRcm->BitmapDisplay(LOADING);
|
||||||
|
GetParent()->UpdateWindow();
|
||||||
|
string s;
|
||||||
|
|
||||||
|
|
||||||
|
TCHAR args[256];
|
||||||
|
switch (pmyComboBox->GetCurSel())
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
_tcscpy_s(args, 255, TEXT(".\\tools\\memloader\\memloader_usb.bin -r --dataini=.\\tools\\memloader\\ums_boot0.ini"));
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
_tcscpy_s(args, 255, TEXT(".\\tools\\memloader\\memloader_usb.bin -r --dataini=.\\tools\\memloader\\ums_boot1.ini"));
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
_tcscpy_s(args, 255, TEXT(".\\tools\\memloader\\memloader_usb.bin -r --dataini=.\\tools\\memloader\\ums_emmc.ini"));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
_tcscpy_s(args, 255, TEXT(".\\tools\\memloader\\memloader_usb.bin -r --dataini=.\\tools\\memloader\\ums_sd.ini"));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
int rc = m_TegraRcm->Smasher(args, FALSE);
|
||||||
|
if (rc < -10)
|
||||||
|
{
|
||||||
|
m_TegraRcm->BitmapDisplay(LOAD_ERROR);
|
||||||
|
s = "Error while injecting UMS Tool (RC=" + std::to_string(rc) + ")";
|
||||||
|
if (!m_TegraRcm->CmdShow) m_TegraRcm->ShowTrayIconBalloon(TEXT("Error"), TEXT("Error while injecting payload"), 1000, NIIF_ERROR);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_TegraRcm->BitmapDisplay(LOADED);
|
||||||
|
s = "UMS Tool injected";
|
||||||
|
if (!m_TegraRcm->CmdShow) m_TegraRcm->ShowTrayIconBalloon(TEXT("UMS Tool injected"), TEXT(" "), 1000, NIIF_INFO);
|
||||||
|
}
|
||||||
|
//CA2T wt(s.c_str());
|
||||||
|
//GetParent()->SetDlgItemText(INFO_LABEL, wt);
|
||||||
|
CString ss(s.c_str());
|
||||||
|
m_TegraRcm->AppendLogBox(ss + TEXT("\r\n"));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DialogTab02::OnBnClickedShofel2()
|
||||||
|
{
|
||||||
|
TCHAR *exe_dir = m_TegraRcm->GetAbsolutePath(TEXT(""), CSIDL_APPDATA);
|
||||||
|
|
||||||
|
string s;
|
||||||
|
TCHAR *COREBOOT_FILE = m_TegraRcm->GetAbsolutePath(TEXT("tools\\shofel2\\coreboot\\coreboot.rom"), CSIDL_APPDATA);
|
||||||
|
TCHAR *PAYLOAD = m_TegraRcm->GetAbsolutePath(TEXT("tools\\shofel2\\coreboot\\cbfs.bin"), CSIDL_APPDATA);
|
||||||
|
CString COREBOOT_FILE2 = COREBOOT_FILE;
|
||||||
|
CString COREBOOT = _T("CBFS+") + COREBOOT_FILE2;
|
||||||
|
|
||||||
|
std::ifstream infile(COREBOOT_FILE);
|
||||||
|
BOOL coreboot_exists = infile.good();
|
||||||
|
std::ifstream infile2(PAYLOAD);
|
||||||
|
BOOL payload_exists = infile2.good();
|
||||||
|
|
||||||
|
if (!coreboot_exists || !payload_exists) {
|
||||||
|
//GetParent()->SetDlgItemText(INFO_LABEL, TEXT("Linux coreboot not found in \\shofel2 dir"));
|
||||||
|
m_TegraRcm->AppendLogBox(TEXT("Linux coreboot not found in \\shofel2 di\r\n"));
|
||||||
|
|
||||||
|
CString message = _T("Kernel not found in shofel2 directory. Do you want to automatically download arch linux kernel from SoulCipher repo ?");
|
||||||
|
const int result = MessageBox(message, _T("Kernel not found"), MB_YESNOCANCEL | MB_ICONQUESTION);
|
||||||
|
if (result == IDYES)
|
||||||
|
{
|
||||||
|
PROCESS_INFORMATION pif;
|
||||||
|
STARTUPINFO si;
|
||||||
|
ZeroMemory(&si, sizeof(si));
|
||||||
|
si.cb = sizeof(si);
|
||||||
|
TCHAR *download_script = m_TegraRcm->GetAbsolutePath(TEXT("tools\\shofel2\\download.bat"), CSIDL_APPDATA);
|
||||||
|
BOOL bRet = CreateProcess(download_script, NULL, NULL, NULL, FALSE, 0, NULL, exe_dir, &si, &pif);
|
||||||
|
}
|
||||||
|
return; // TO-DO : Remove return for coreboot injection after download
|
||||||
|
}
|
||||||
|
m_TegraRcm->BitmapDisplay(LOADING);
|
||||||
|
GetParent()->UpdateWindow();
|
||||||
|
//GetParent()->SetDlgItemText(INFO_LABEL, TEXT("Loading coreboot. Please wait."));
|
||||||
|
m_TegraRcm->AppendLogBox(TEXT("Linux coreboot not found in \\shofel2 di\r\n"));
|
||||||
|
|
||||||
|
|
||||||
|
//int rc = device.SmashMain(5, args);
|
||||||
|
TCHAR cmd[4096] = TEXT("--relocator= \"");
|
||||||
|
lstrcat(cmd, _tcsdup(PAYLOAD));
|
||||||
|
lstrcat(cmd, TEXT("\" \"CBFS:"));
|
||||||
|
lstrcat(cmd, _tcsdup(COREBOOT_FILE));
|
||||||
|
lstrcat(cmd, TEXT("\""));
|
||||||
|
int rc = m_TegraRcm->Smasher(cmd, FALSE);
|
||||||
|
int test = 1;
|
||||||
|
if (rc >= 0 || rc < -7)
|
||||||
|
{
|
||||||
|
//GetParent()->SetDlgItemText(INFO_LABEL, TEXT("Coreboot injected. Waiting 5s for device..."));
|
||||||
|
m_TegraRcm->AppendLogBox(TEXT("Coreboot injected. Waiting 5s for device...\r\n"));
|
||||||
|
Sleep(5000);
|
||||||
|
|
||||||
|
PROCESS_INFORMATION pif;
|
||||||
|
STARTUPINFO si;
|
||||||
|
ZeroMemory(&si, sizeof(si));
|
||||||
|
si.cb = sizeof(si);
|
||||||
|
TCHAR *imx_script = m_TegraRcm->GetAbsolutePath(TEXT("tools\\shofel2\\imx_usb.bat"), CSIDL_APPDATA);
|
||||||
|
//GetParent()->SetDlgItemText(INFO_LABEL, TEXT("Loading coreboot... Please wait."));
|
||||||
|
m_TegraRcm->AppendLogBox(TEXT("Loading coreboot... Please wait\r\n"));
|
||||||
|
|
||||||
|
BOOL ret = CreateProcess(imx_script, NULL, NULL, NULL, FALSE, CREATE_NO_WINDOW, NULL, exe_dir, &si, &pif);
|
||||||
|
int rc = -50;
|
||||||
|
if (NULL != ret)
|
||||||
|
{
|
||||||
|
WaitForSingleObject(pif.hProcess, INFINITE);
|
||||||
|
DWORD exit_code;
|
||||||
|
if (FALSE != GetExitCodeProcess(pif.hProcess, &exit_code))
|
||||||
|
{
|
||||||
|
if (STILL_ACTIVE != exit_code) rc = exit_code;
|
||||||
|
}
|
||||||
|
else rc = -51;
|
||||||
|
CloseHandle(pif.hProcess);
|
||||||
|
CloseHandle(pif.hThread);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rc == 0)
|
||||||
|
{
|
||||||
|
m_TegraRcm->BitmapDisplay(LOADED);
|
||||||
|
s = "\nCoreboot loaded !";
|
||||||
|
if (!m_TegraRcm->CmdShow) m_TegraRcm->ShowTrayIconBalloon(TEXT("Coreboot loaded "), TEXT(" "), 1000, NIIF_INFO);
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_TegraRcm->BitmapDisplay(LOAD_ERROR);
|
||||||
|
s = "Error while loading imx_usb.exe";
|
||||||
|
if (!m_TegraRcm->CmdShow) m_TegraRcm->ShowTrayIconBalloon(TEXT("Error"), TEXT("Error while loading imx_usb.exe"), 1000, NIIF_ERROR);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
s = "Error while injecting payload. (RC=" + std::to_string(rc) + ")";
|
||||||
|
if (!m_TegraRcm->CmdShow) m_TegraRcm->ShowTrayIconBalloon(TEXT("Error"), TEXT("Error while injecting payload"), 1000, NIIF_ERROR);
|
||||||
|
|
||||||
|
}
|
||||||
|
//CA2T wt2(s.c_str());
|
||||||
|
//GetParent()->SetDlgItemText(INFO_LABEL, wt2);
|
||||||
|
CString ss(s.c_str());
|
||||||
|
m_TegraRcm->AppendLogBox(ss + TEXT("\r\n"));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
HBRUSH DialogTab02::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
|
||||||
|
{
|
||||||
|
HBRUSH hbr = CDialogEx::OnCtlColor(pDC, pWnd, nCtlColor);
|
||||||
|
|
||||||
|
switch (pWnd->GetDlgCtrlID())
|
||||||
|
{
|
||||||
|
case ID_UMSTOOL_TITLE:
|
||||||
|
case ID_LINUX_TITLE:
|
||||||
|
case ID_BISKEY_TITLE:
|
||||||
|
pDC->SelectObject(&m_BoldFont);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return hbr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DialogTab02::OnBnClickedDumpBiskey()
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
m_TegraRcm->BitmapDisplay(LOADING);
|
||||||
|
GetParent()->UpdateWindow();
|
||||||
|
TCHAR args[] = TEXT("-w tools\\biskeydump_usb.bin BOOT:0x0");
|
||||||
|
int rc = m_TegraRcm->Smasher(args);
|
||||||
|
|
||||||
|
BOOL keyFound = FALSE;
|
||||||
|
TCHAR *rfile = m_TegraRcm->GetAbsolutePath(TEXT("out.log"), CSIDL_APPDATA);
|
||||||
|
CString Cline;
|
||||||
|
std::wifstream fin(rfile, std::ios::binary);
|
||||||
|
fin.imbue(std::locale(fin.getloc(), new std::codecvt_utf8_utf16<wchar_t>));
|
||||||
|
CString Filename;
|
||||||
|
for (wchar_t c; fin.get(c); ) {
|
||||||
|
CString Cchar(c);
|
||||||
|
if (Cchar == TEXT("\n")) {
|
||||||
|
|
||||||
|
if (Cline.Find(TEXT("HWI")) != -1 ||
|
||||||
|
Cline.Find(TEXT("SBK")) != -1 ||
|
||||||
|
Cline.Find(TEXT("TSEC KEY")) != -1 ||
|
||||||
|
Cline.Find(TEXT("BIS KEY")) != -1) {
|
||||||
|
|
||||||
|
if (!keyFound)
|
||||||
|
{
|
||||||
|
keyFound = TRUE;
|
||||||
|
|
||||||
|
CString szFilter;
|
||||||
|
szFilter = "TXT files (*.txt)|*.txt|All files (*.*)|*.*||";
|
||||||
|
|
||||||
|
CFileDialog FileOpenDialog(
|
||||||
|
FALSE,
|
||||||
|
NULL,
|
||||||
|
TEXT("BIS_keys.txt"),
|
||||||
|
OFN_HIDEREADONLY,
|
||||||
|
szFilter,
|
||||||
|
AfxGetMainWnd());
|
||||||
|
|
||||||
|
if (FileOpenDialog.DoModal() == IDOK)
|
||||||
|
{
|
||||||
|
CFile File;
|
||||||
|
Filename = FileOpenDialog.GetPathName();
|
||||||
|
remove(CT2A(Filename));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
CT2CA pszConvertedAnsiString(Cline + _T('\n'));
|
||||||
|
std::string outLine = pszConvertedAnsiString;
|
||||||
|
fstream outFile;
|
||||||
|
outFile.open(Filename, fstream::in | fstream::out | fstream::app);
|
||||||
|
outFile << outLine;
|
||||||
|
outFile.close();
|
||||||
|
|
||||||
|
}
|
||||||
|
Cline.Empty();
|
||||||
|
}
|
||||||
|
else if (Cchar != TEXT("\r") && Cchar != TEXT("")) {
|
||||||
|
Cline.Append(Cchar);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fin.close();
|
||||||
|
|
||||||
|
|
||||||
|
CString s;
|
||||||
|
if (!keyFound)
|
||||||
|
{
|
||||||
|
m_TegraRcm->BitmapDisplay(LOAD_ERROR);
|
||||||
|
s.Append(TEXT("Error while retrieving BIS keys"));
|
||||||
|
if (!m_TegraRcm->CmdShow) m_TegraRcm->ShowTrayIconBalloon(TEXT("Error"), s, 1000, NIIF_ERROR);
|
||||||
|
s.Append(TEXT("\r\n"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_TegraRcm->BitmapDisplay(LOADED);
|
||||||
|
CString loc(Filename);
|
||||||
|
s.Append(TEXT("BIS keys saved to : "));
|
||||||
|
s.Append(loc);
|
||||||
|
if (!m_TegraRcm->CmdShow) m_TegraRcm->ShowTrayIconBalloon(s, TEXT(" "), 1000, NIIF_INFO);
|
||||||
|
s.Append(TEXT("\r\n"));
|
||||||
|
|
||||||
|
}
|
||||||
|
m_TegraRcm->AppendLogBox(s);
|
||||||
|
}
|
39
TegraRcmGUI/DialogTab02.h
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
#pragma once
|
||||||
|
#include <string>
|
||||||
|
#include "TegraRcmGUIDlg.h"
|
||||||
|
#include "TegraRcm.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// DialogTab02 dialog
|
||||||
|
|
||||||
|
class DialogTab02 :
|
||||||
|
public CDialogEx
|
||||||
|
{
|
||||||
|
DECLARE_DYNAMIC(DialogTab02)
|
||||||
|
public:
|
||||||
|
DialogTab02(TegraRcm *pTegraRcm, CWnd* pParent = NULL); // standard constructor
|
||||||
|
virtual ~DialogTab02();
|
||||||
|
|
||||||
|
// Dialog Data
|
||||||
|
#ifdef AFX_DESIGN_TIME
|
||||||
|
enum { IDD = ID_DIALOGTAB_02 };
|
||||||
|
#endif
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||||
|
CFont m_BoldFont;
|
||||||
|
DECLARE_MESSAGE_MAP()
|
||||||
|
public:
|
||||||
|
afx_msg void OnBnClickedMountSd();
|
||||||
|
afx_msg void OnBnClickedShofel2();
|
||||||
|
private:
|
||||||
|
TegraRcm *m_TegraRcm;
|
||||||
|
public:
|
||||||
|
virtual BOOL OnInitDialog();
|
||||||
|
// HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
|
||||||
|
|
||||||
|
afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
|
||||||
|
afx_msg void OnBnClickedDumpBiskey();
|
||||||
|
};
|
254
TegraRcmGUI/DialogTab03.cpp
Normal file
|
@ -0,0 +1,254 @@
|
||||||
|
#include "stdafx.h"
|
||||||
|
#include "TegraRcmGUI.h"
|
||||||
|
#include "DialogTab03.h"
|
||||||
|
#include "afxdialogex.h"
|
||||||
|
|
||||||
|
|
||||||
|
// DialogTab03 dialog
|
||||||
|
|
||||||
|
IMPLEMENT_DYNAMIC(DialogTab03, CDialogEx)
|
||||||
|
|
||||||
|
DialogTab03::DialogTab03(TegraRcm *pTegraRcm, CWnd* Parent /*=NULL*/)
|
||||||
|
: CDialogEx(ID_DIALOGTAB_03, Parent)
|
||||||
|
{
|
||||||
|
m_TegraRcm = pTegraRcm;
|
||||||
|
}
|
||||||
|
|
||||||
|
DialogTab03::~DialogTab03()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialogTab03::DoDataExchange(CDataExchange* pDX)
|
||||||
|
{
|
||||||
|
CDialogEx::DoDataExchange(pDX);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BOOL DialogTab03::OnInitDialog()
|
||||||
|
{
|
||||||
|
CDialog::OnInitDialog();
|
||||||
|
CleanRegestry();
|
||||||
|
|
||||||
|
string value = m_TegraRcm->GetPreset("AUTO_INJECT");
|
||||||
|
if (value == "TRUE")
|
||||||
|
{
|
||||||
|
m_TegraRcm->AUTOINJECT_CURR = TRUE;
|
||||||
|
CMFCButton*checkbox = (CMFCButton*)GetDlgItem(AUTO_INJECT);
|
||||||
|
checkbox->SetCheck(BST_CHECKED);
|
||||||
|
}
|
||||||
|
|
||||||
|
value = m_TegraRcm->GetPreset("MIN_TO_TRAY");
|
||||||
|
if (value == "TRUE")
|
||||||
|
{
|
||||||
|
m_TegraRcm->MIN_TO_TRAY_CURR = TRUE;
|
||||||
|
CMFCButton*checkbox = (CMFCButton*)GetDlgItem(MIN_TO_TRAY);
|
||||||
|
checkbox->SetCheck(BST_CHECKED);
|
||||||
|
}
|
||||||
|
|
||||||
|
value = m_TegraRcm->GetPreset("LOGGING");
|
||||||
|
if (value == "TRUE")
|
||||||
|
{
|
||||||
|
m_TegraRcm->LOGGING_CURR = TRUE;
|
||||||
|
CMFCButton* checkbox = (CMFCButton*)GetDlgItem(LOGGING);
|
||||||
|
checkbox->SetCheck(BST_CHECKED);
|
||||||
|
}
|
||||||
|
|
||||||
|
TCHAR szPath[MAX_PATH];
|
||||||
|
if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, szPath)))
|
||||||
|
{
|
||||||
|
PathAppend(szPath, _T("\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\TegraRcmGUI.lnk"));
|
||||||
|
std::ifstream infile(szPath);
|
||||||
|
if (infile.good()) {
|
||||||
|
infile.close();
|
||||||
|
CMFCButton*checkbox = (CMFCButton*)GetDlgItem(RUN_WINSTART);
|
||||||
|
checkbox->SetCheck(BST_CHECKED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE; // return TRUE unless you set the focus to a control
|
||||||
|
// EXCEPTION: OCX Property Pages should return FALSE
|
||||||
|
}
|
||||||
|
|
||||||
|
BEGIN_MESSAGE_MAP(DialogTab03, CDialogEx)
|
||||||
|
ON_BN_CLICKED(AUTO_INJECT, &DialogTab03::OnClickedAutoInject)
|
||||||
|
ON_BN_CLICKED(MIN_TO_TRAY, &DialogTab03::OnClickedMinToTray)
|
||||||
|
ON_BN_CLICKED(ID_INSTALL_DRIVER, &DialogTab03::OnBnClickedInstallDriver)
|
||||||
|
ON_BN_CLICKED(RUN_WINSTART, &DialogTab03::OnBnClickedWinstart)
|
||||||
|
ON_BN_CLICKED(LOGGING, &DialogTab03::OnClickedLogging)
|
||||||
|
//ON_BN_CLICKED(IDC_BUTTON2, &DialogTab03::OnBnClickedButton2)
|
||||||
|
END_MESSAGE_MAP()
|
||||||
|
|
||||||
|
|
||||||
|
// DialogTab03 message handlers
|
||||||
|
|
||||||
|
|
||||||
|
void DialogTab03::OnClickedAutoInject()
|
||||||
|
{
|
||||||
|
// Get Auto inject checkbox value (checked, unchecked)
|
||||||
|
CButton *m_ctlCheck = (CButton*)GetDlgItem(AUTO_INJECT);
|
||||||
|
BOOL IsCheckChecked = (m_ctlCheck->GetCheck() == 1) ? true : false;
|
||||||
|
|
||||||
|
if (m_TegraRcm->AUTOINJECT_CURR != IsCheckChecked)
|
||||||
|
{
|
||||||
|
// Auto inject option enabled
|
||||||
|
if (IsCheckChecked)
|
||||||
|
{
|
||||||
|
m_TegraRcm->SetPreset("AUTO_INJECT", "TRUE");
|
||||||
|
m_TegraRcm->DELAY_AUTOINJECT = TRUE;
|
||||||
|
}
|
||||||
|
// Auto inject option disabled
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_TegraRcm->SetPreset("AUTO_INJECT", "FALSE");
|
||||||
|
m_TegraRcm->DELAY_AUTOINJECT = FALSE;
|
||||||
|
}
|
||||||
|
// Save current checkbox value
|
||||||
|
m_TegraRcm->AUTOINJECT_CURR = IsCheckChecked;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DialogTab03::OnClickedMinToTray()
|
||||||
|
{
|
||||||
|
// Get Minimize to tray checkbox value (checked, unchecked)
|
||||||
|
CButton *m_ctlCheck = (CButton*)GetDlgItem(MIN_TO_TRAY);
|
||||||
|
BOOL IsCheckChecked = (m_ctlCheck->GetCheck() == 1) ? true : false;
|
||||||
|
if (m_TegraRcm->MIN_TO_TRAY_CURR != IsCheckChecked)
|
||||||
|
{
|
||||||
|
if (IsCheckChecked) m_TegraRcm->SetPreset("MIN_TO_TRAY", "TRUE");
|
||||||
|
else m_TegraRcm->SetPreset("MIN_TO_TRAY", "FALSE");
|
||||||
|
m_TegraRcm->MIN_TO_TRAY_CURR = IsCheckChecked;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DialogTab03::OnClickedLogging()
|
||||||
|
{
|
||||||
|
// Get Minimize to tray checkbox value (checked, unchecked)
|
||||||
|
CButton* m_ctlCheck = (CButton*)GetDlgItem(LOGGING);
|
||||||
|
BOOL IsCheckChecked = (m_ctlCheck->GetCheck() == 1) ? true : false;
|
||||||
|
if (m_TegraRcm->LOGGING_CURR != IsCheckChecked)
|
||||||
|
{
|
||||||
|
if (IsCheckChecked) m_TegraRcm->SetPreset("LOGGING", "TRUE");
|
||||||
|
else m_TegraRcm->SetPreset("LOGGING", "FALSE");
|
||||||
|
m_TegraRcm->LOGGING_CURR = IsCheckChecked;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DialogTab03::OnBnClickedInstallDriver()
|
||||||
|
{
|
||||||
|
m_TegraRcm->InstallDriver();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void DialogTab03::OnBnClickedWinstart()
|
||||||
|
{
|
||||||
|
// Init
|
||||||
|
HKEY hKey;
|
||||||
|
const std::string key = "TegraRcmGUI";
|
||||||
|
std::vector<char> buffer;
|
||||||
|
|
||||||
|
// Get checkbox value (checked, unchecked)
|
||||||
|
CButton *m_ctlCheck = (CButton*)GetDlgItem(RUN_WINSTART);
|
||||||
|
BOOL IsCheckChecked = (m_ctlCheck->GetCheck() == 1) ? true : false;
|
||||||
|
|
||||||
|
// Get application absolute path
|
||||||
|
TCHAR szPath[_MAX_PATH];
|
||||||
|
if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, szPath)))
|
||||||
|
{
|
||||||
|
// Remove shortcut
|
||||||
|
PathAppend(szPath, _T("\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\TegraRcmGUI.lnk"));
|
||||||
|
if(remove(CW2A(szPath)) == 0) m_TegraRcm->AppendLogBox(TEXT("Winstart shortcut REMOVED\r\n"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create new shortcut
|
||||||
|
if (IsCheckChecked) {
|
||||||
|
CreateLink();
|
||||||
|
m_TegraRcm->AppendLogBox(TEXT("Winstart shortcut ADDED\r\n"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DialogTab03::CreateLink()
|
||||||
|
{
|
||||||
|
TCHAR szAppPath[_MAX_PATH];
|
||||||
|
VERIFY(::GetModuleFileName(AfxGetApp()->m_hInstance, szAppPath, _MAX_PATH));
|
||||||
|
|
||||||
|
TCHAR szPath[_MAX_PATH];
|
||||||
|
if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, szPath)))
|
||||||
|
{
|
||||||
|
PathAppend(szPath, _T("\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\TegraRcmGUI.lnk"));
|
||||||
|
}
|
||||||
|
CoInitializeEx(NULL, 0);
|
||||||
|
HRESULT hres = 0;
|
||||||
|
IShellLink* psl;
|
||||||
|
if (SUCCEEDED(hres)) {
|
||||||
|
hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_ALL, IID_IShellLink, (LPVOID*)&psl);
|
||||||
|
if (SUCCEEDED(hres)) {
|
||||||
|
IPersistFile* ppf;
|
||||||
|
|
||||||
|
// Set the path to the shortcut target and add the description.
|
||||||
|
//PathAppend(szPath, _T("\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\TegraRcmGUI.lnk"));
|
||||||
|
|
||||||
|
psl->SetPath(szAppPath);
|
||||||
|
psl->SetArguments(_T("/autostart"));
|
||||||
|
psl->SetDescription(L"TegraRcmGUI");
|
||||||
|
psl->SetIconLocation(szAppPath, 0);
|
||||||
|
|
||||||
|
CString csPath, csPathf(szAppPath);
|
||||||
|
int nIndex = csPathf.ReverseFind(_T('\\'));
|
||||||
|
if (nIndex > 0) csPath = csPathf.Left(nIndex);
|
||||||
|
else csPath.Empty();
|
||||||
|
psl->SetWorkingDirectory(csPath);
|
||||||
|
|
||||||
|
hres = psl->QueryInterface(IID_IPersistFile, (LPVOID*)&ppf);
|
||||||
|
if (SUCCEEDED(hres)) {
|
||||||
|
hres = ppf->Save(szPath, TRUE);
|
||||||
|
ppf->Release();
|
||||||
|
}
|
||||||
|
psl->Release();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
CoUninitialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialogTab03::CleanRegestry() {
|
||||||
|
HKEY hKey;
|
||||||
|
const std::string key = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run";
|
||||||
|
const std::string subkey = "TegraRcmGUI";
|
||||||
|
|
||||||
|
// Open Run Registry location
|
||||||
|
LONG lnRes = RegOpenKeyExA(HKEY_CURRENT_USER,
|
||||||
|
key.c_str(), 0, KEY_READ, &hKey);
|
||||||
|
|
||||||
|
if (ERROR_SUCCESS == lnRes)
|
||||||
|
{
|
||||||
|
lnRes = RegQueryValueExA(hKey, subkey.c_str(), NULL, NULL, NULL, NULL);
|
||||||
|
if (lnRes != ERROR_FILE_NOT_FOUND)
|
||||||
|
{
|
||||||
|
//Remove regestry value
|
||||||
|
lnRes = RegOpenKeyEx(HKEY_CURRENT_USER,
|
||||||
|
_T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run"),
|
||||||
|
0L, KEY_WRITE,
|
||||||
|
&hKey);
|
||||||
|
|
||||||
|
if (lnRes != ERROR_FILE_NOT_FOUND)
|
||||||
|
{
|
||||||
|
//Remove regestry value
|
||||||
|
lnRes = RegDeleteValueA(hKey, subkey.c_str());
|
||||||
|
|
||||||
|
// Create new shortcut
|
||||||
|
CreateLink();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
void DialogTab03::OnBnClickedButton2()
|
||||||
|
{
|
||||||
|
m_TegraRcm->SetLocale();
|
||||||
|
}
|
||||||
|
*/
|
51
TegraRcmGUI/DialogTab03.h
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
#pragma once
|
||||||
|
#include <string>
|
||||||
|
#include "TegraRcmGUIDlg.h"
|
||||||
|
#include "TegraRcm.h"
|
||||||
|
|
||||||
|
#include "stdafx.h"
|
||||||
|
#include <Windows.h>
|
||||||
|
#include <shlobj.h>
|
||||||
|
#include <winnls.h>
|
||||||
|
#include <shobjidl.h>
|
||||||
|
#include <objbase.h>
|
||||||
|
#include <objidl.h>
|
||||||
|
#include <shlguid.h>
|
||||||
|
#include <atlbase.h>
|
||||||
|
#include <atlconv.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// DialogTab03 dialog
|
||||||
|
|
||||||
|
class DialogTab03 : public CDialogEx
|
||||||
|
{
|
||||||
|
DECLARE_DYNAMIC(DialogTab03)
|
||||||
|
|
||||||
|
public:
|
||||||
|
DialogTab03(TegraRcm *pTegraRcm, CWnd* Parent = NULL); // standard constructor
|
||||||
|
virtual ~DialogTab03();
|
||||||
|
|
||||||
|
// Dialog Data
|
||||||
|
#ifdef AFX_DESIGN_TIME
|
||||||
|
enum { IDD = ID_DIALOGTAB_03 };
|
||||||
|
#endif
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||||
|
|
||||||
|
virtual BOOL OnInitDialog();
|
||||||
|
DECLARE_MESSAGE_MAP()
|
||||||
|
|
||||||
|
private:
|
||||||
|
TegraRcm *m_TegraRcm;
|
||||||
|
public:
|
||||||
|
afx_msg void OnClickedAutoInject();
|
||||||
|
afx_msg void OnClickedMinToTray();
|
||||||
|
afx_msg void OnBnClickedInstallDriver();
|
||||||
|
afx_msg void OnBnClickedWinstart();
|
||||||
|
afx_msg void OnClickedLogging();
|
||||||
|
void CreateLink();
|
||||||
|
afx_msg void CleanRegestry();
|
||||||
|
|
||||||
|
};
|
72
TegraRcmGUI/MyTabCtrl.cpp
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
#include "stdafx.h"
|
||||||
|
#include "MyTabCtrl.h"
|
||||||
|
#include "DialogTab01.h"
|
||||||
|
#include "DialogTab02.h"
|
||||||
|
#include "DialogTab03.h"
|
||||||
|
#include "resource.h"
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
|
||||||
|
MyTabCtrl::MyTabCtrl()
|
||||||
|
{
|
||||||
|
|
||||||
|
m_DialogID[0] = ID_DIALOGTAB_01;
|
||||||
|
m_DialogID[1] = ID_DIALOGTAB_02;
|
||||||
|
m_DialogID[2] = ID_DIALOGTAB_03;
|
||||||
|
|
||||||
|
m_nPageCount = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
MyTabCtrl::~MyTabCtrl()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
BEGIN_MESSAGE_MAP(MyTabCtrl, CTabCtrl)
|
||||||
|
ON_NOTIFY_REFLECT(TCN_SELCHANGE, &MyTabCtrl::OnTcnSelchange)
|
||||||
|
END_MESSAGE_MAP()
|
||||||
|
|
||||||
|
//This function creates the Dialog boxes once
|
||||||
|
void MyTabCtrl::InitDialogs(TegraRcm *parent)
|
||||||
|
{
|
||||||
|
m_TegraRcm = parent;
|
||||||
|
m_Dialog[0] = new DialogTab01(m_TegraRcm);
|
||||||
|
m_Dialog[1] = new DialogTab02(m_TegraRcm);
|
||||||
|
m_Dialog[2] = new DialogTab03(m_TegraRcm);
|
||||||
|
m_Dialog[0]->Create(m_DialogID[0], GetParent());
|
||||||
|
m_Dialog[1]->Create(m_DialogID[1], GetParent());
|
||||||
|
m_Dialog[2]->Create(m_DialogID[2], GetParent());
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyTabCtrl::OnTcnSelchange(NMHDR *pNMHDR, LRESULT *pResult)
|
||||||
|
{
|
||||||
|
// TODO: Add your control notification handler code here
|
||||||
|
ActivateTabDialogs();
|
||||||
|
*pResult = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyTabCtrl::ActivateTabDialogs()
|
||||||
|
{
|
||||||
|
//ASSERT(MyParentDlg);
|
||||||
|
//.OnPaint();
|
||||||
|
|
||||||
|
int nSel = GetCurSel();
|
||||||
|
if (m_Dialog[nSel]->m_hWnd)
|
||||||
|
m_Dialog[nSel]->ShowWindow(SW_HIDE);
|
||||||
|
|
||||||
|
CRect l_rectClient;
|
||||||
|
CRect l_rectWnd;
|
||||||
|
|
||||||
|
GetClientRect(l_rectClient);
|
||||||
|
AdjustRect(FALSE, l_rectClient);
|
||||||
|
GetWindowRect(l_rectWnd);
|
||||||
|
GetParent()->ScreenToClient(l_rectWnd);
|
||||||
|
l_rectClient.OffsetRect(l_rectWnd.left, l_rectWnd.top);
|
||||||
|
for (int nCount = 0; nCount < m_nPageCount; nCount++) {
|
||||||
|
m_Dialog[nCount]->SetWindowPos(&wndTop, l_rectClient.left, l_rectClient.top, l_rectClient.Width(), l_rectClient.Height(), SWP_HIDEWINDOW);
|
||||||
|
}
|
||||||
|
m_Dialog[nSel]->SetWindowPos(&wndTop, l_rectClient.left, l_rectClient.top, l_rectClient.Width(), l_rectClient.Height(), SWP_SHOWWINDOW);
|
||||||
|
|
||||||
|
m_Dialog[nSel]->ShowWindow(SW_SHOW);
|
||||||
|
|
||||||
|
}
|
25
TegraRcmGUI/MyTabCtrl.h
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
#pragma once
|
||||||
|
#include "afxcmn.h"
|
||||||
|
#include "TegraRcm.h"
|
||||||
|
|
||||||
|
class MyTabCtrl :
|
||||||
|
public CTabCtrl
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MyTabCtrl();
|
||||||
|
~MyTabCtrl();
|
||||||
|
|
||||||
|
//Array to hold the list of dialog boxes/tab pages for CTabCtrl
|
||||||
|
int m_DialogID[3];
|
||||||
|
//CDialog Array Variable to hold the dialogs
|
||||||
|
CDialog *m_Dialog[3];
|
||||||
|
int m_nPageCount;
|
||||||
|
//Function to Create the dialog boxes during startup
|
||||||
|
void InitDialogs(TegraRcm *parent);
|
||||||
|
|
||||||
|
//Function to activate the tab dialog boxes
|
||||||
|
void ActivateTabDialogs();
|
||||||
|
DECLARE_MESSAGE_MAP()
|
||||||
|
afx_msg void OnTcnSelchange(NMHDR *pNMHDR, LRESULT *pResult);
|
||||||
|
TegraRcm *m_TegraRcm;
|
||||||
|
};
|
1196
TegraRcmGUI/TegraRcm.cpp
Normal file
129
TegraRcmGUI/TegraRcm.h
Normal file
|
@ -0,0 +1,129 @@
|
||||||
|
#pragma once
|
||||||
|
#include <string>
|
||||||
|
#include <windows.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <iostream>
|
||||||
|
#include <sstream>
|
||||||
|
#pragma once
|
||||||
|
#include <fstream>
|
||||||
|
#include <iostream>
|
||||||
|
#include <cstdio>
|
||||||
|
#include <memory>
|
||||||
|
#include <stdexcept>
|
||||||
|
#include "resource.h"
|
||||||
|
#include "TegraRcmSmash.h"
|
||||||
|
#include <setupapi.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <Strsafe.h>
|
||||||
|
#include "afxcmn.h"
|
||||||
|
#include <tlhelp32.h>
|
||||||
|
|
||||||
|
#pragma comment (lib, "setupapi.lib")
|
||||||
|
|
||||||
|
class TegraRcm
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TegraRcm(CDialog* pParent = NULL);
|
||||||
|
~TegraRcm();
|
||||||
|
|
||||||
|
public:
|
||||||
|
void InitCtrltbDlgs(CDialog* pCtrltb1, CDialog* pCtrltb2, CDialog* pCtrltb3);
|
||||||
|
int GetRcmStatus();
|
||||||
|
ULONGLONG GetDllVersion(LPCTSTR lpszDllName);
|
||||||
|
TCHAR* GetAbsolutePath(TCHAR* relative_path, DWORD dwFlags);
|
||||||
|
void SetLocale();
|
||||||
|
void AppendLogBox(CString line);
|
||||||
|
void UpdateLogBox();
|
||||||
|
string GetPreset(string param);
|
||||||
|
void InstallDriver();
|
||||||
|
BOOL LookForAPXDevice();
|
||||||
|
void AppendLog(string message);
|
||||||
|
void SendUserMessage(string message, int type = NEUTRAL);
|
||||||
|
void SetPreset(string param, string value);
|
||||||
|
void GetFavorites();
|
||||||
|
void AddFavorite(CString value);
|
||||||
|
void SaveFavorites();
|
||||||
|
void BitmapDisplay(int IMG);
|
||||||
|
void LookUp();
|
||||||
|
int Smasher(TCHAR args[], BOOL bInheritHandles = TRUE);
|
||||||
|
char* GetRelativeFilename(char *currentDirectory, char *absoluteFilename);
|
||||||
|
|
||||||
|
|
||||||
|
void KillRunningProcess(CString process);
|
||||||
|
HWND find_main_window(unsigned long process_id);
|
||||||
|
|
||||||
|
BOOL CmdShow = TRUE;
|
||||||
|
// Notify Icon
|
||||||
|
NOTIFYICONDATA m_NID;
|
||||||
|
CPoint m_ptMouseHoverEvent;
|
||||||
|
|
||||||
|
BOOL CreateTrayIcon();
|
||||||
|
BOOL SetTrayIconTipText(LPCTSTR pszText);
|
||||||
|
BOOL ShowTrayIconBalloon(LPCTSTR pszTitle, LPCTSTR pszText, UINT unTimeout, DWORD dwInfoFlags);
|
||||||
|
BOOL SetTrayIcon(HICON hIcon);
|
||||||
|
BOOL SetTrayIcon(WORD wIconID);
|
||||||
|
void ShowContextMenu(HWND hWnd);
|
||||||
|
BOOL DestroyTrayIcon();
|
||||||
|
LRESULT OnTrayIconEvent(WPARAM wParam, LPARAM lParam);
|
||||||
|
|
||||||
|
BOOL PAUSE_LKP_DEVICE = FALSE;
|
||||||
|
BOOL AUTOINJECT_CURR = FALSE;
|
||||||
|
BOOL DELAY_AUTOINJECT = TRUE;
|
||||||
|
BOOL WAITING_RECONNECT = FALSE;
|
||||||
|
BOOL ASK_FOR_DRIVER = FALSE;
|
||||||
|
BOOL MIN_TO_TRAY_CURR = FALSE;
|
||||||
|
BOOL LOGGING_CURR = FALSE;
|
||||||
|
|
||||||
|
CString csPath;
|
||||||
|
COLORREF LabelColor = RGB(0, 0, 0);
|
||||||
|
COLORREF WhiteRGB = RGB(255, 255, 255);
|
||||||
|
COLORREF BlackRGB = RGB(0, 0, 0);
|
||||||
|
COLORREF RedRGB = RGB(255, 0, 0);
|
||||||
|
COLORREF GreenRGB = RGB(0, 100, 0);
|
||||||
|
|
||||||
|
TCHAR* PAYLOAD_FILE;
|
||||||
|
CArray <CString, CString> Favorites;
|
||||||
|
CDialog* m_Parent;
|
||||||
|
CDialog* m_Ctrltb1;
|
||||||
|
CDialog* m_Ctrltb2;
|
||||||
|
CDialog* m_Ctrltb3;
|
||||||
|
|
||||||
|
struct Label {
|
||||||
|
int uid;
|
||||||
|
string name;
|
||||||
|
};
|
||||||
|
|
||||||
|
Label labels[23] = {
|
||||||
|
{ 0, "TegraRcmGUI"},
|
||||||
|
{ 1, "No file selected" },
|
||||||
|
{ 2, "File doesn't exist" },
|
||||||
|
{ 3, "Injecting payload..." },
|
||||||
|
{ 4, "Payload injected !" },
|
||||||
|
{ 5, "Error while injecting payload" },
|
||||||
|
{ 6, "Favorite already exists" },
|
||||||
|
{ 7, "Favorite added" },
|
||||||
|
{ 8, "Favorite removed" },
|
||||||
|
{ 9, "UMS Tool injected" },
|
||||||
|
{ 10, "Linux coreboot not found in \\shofel2 dir" },
|
||||||
|
{ 11, "Kernel not found in shofel2 directory. Do you want to automatically download arch linux kernel from SoulCipher repo ?" },
|
||||||
|
{ 12, "Kernel not found" },
|
||||||
|
{ 13, "Loading coreboot. Please wait." },
|
||||||
|
{ 14, "Coreboot injected. Waiting 5s for device..." },
|
||||||
|
{ 15, "Coreboot loaded " },
|
||||||
|
{ 16, "Error" },
|
||||||
|
{ 17, "Error while loading imx_usb.exe" },
|
||||||
|
{ 18, "APX device driver is missing. Do you want to install it now ?" },
|
||||||
|
{ 19, "APX driver not found !" },
|
||||||
|
{ 20, "Waiting for user action" },
|
||||||
|
{ 21, "Waiting for device in RCM mode" },
|
||||||
|
{ 22, "Payload already injected. Are you sure you want to overwrite the stack again ?" }
|
||||||
|
};
|
||||||
|
|
||||||
|
private:
|
||||||
|
HWND m_hWnd;
|
||||||
|
TegraRcmSmash m_Device;
|
||||||
|
int m_RC = -99;;
|
||||||
|
BOOL FIRST_LOOKUP = TRUE;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
|
@ -1,15 +1,38 @@
|
||||||
|
/*
|
||||||
|
TegraRcmGUI.cpp
|
||||||
|
|
||||||
// TegraRcmGUI.cpp : Defines the class behaviors for the application.
|
MIT License
|
||||||
//
|
|
||||||
|
Copyright(c) 2018 eliboa
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files(the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions :
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "TegraRcmGUI.h"
|
#include "TegraRcmGUI.h"
|
||||||
|
#include "MyTabCtrl.h"
|
||||||
#include "TegraRcmGUIDlg.h"
|
#include "TegraRcmGUIDlg.h"
|
||||||
#include "TegraRcmSmash.h"
|
#include "TegraRcmSmash.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
|
||||||
|
@ -56,6 +79,9 @@ BOOL CTegraRcmGUIApp::InitInstance()
|
||||||
|
|
||||||
CWinApp::InitInstance();
|
CWinApp::InitInstance();
|
||||||
|
|
||||||
|
// Get command line args
|
||||||
|
CCustomCommandLineInfo oInfo;
|
||||||
|
ParseCommandLine(oInfo);
|
||||||
|
|
||||||
AfxEnableControlContainer();
|
AfxEnableControlContainer();
|
||||||
|
|
||||||
|
@ -70,12 +96,14 @@ BOOL CTegraRcmGUIApp::InitInstance()
|
||||||
SetRegistryKey(_T("Local AppWizard-Generated Applications"));
|
SetRegistryKey(_T("Local AppWizard-Generated Applications"));
|
||||||
|
|
||||||
CTegraRcmGUIDlg dlg;
|
CTegraRcmGUIDlg dlg;
|
||||||
|
if (oInfo.IsAutostart()) {
|
||||||
|
dlg.AUTOSTART = TRUE;
|
||||||
|
}
|
||||||
m_pMainWnd = &dlg;
|
m_pMainWnd = &dlg;
|
||||||
INT_PTR nResponse = dlg.DoModal();
|
INT_PTR nResponse = dlg.DoModal();
|
||||||
if (nResponse == IDOK)
|
if (nResponse == IDOK)
|
||||||
{
|
{
|
||||||
// TODO: Place code here to handle when the dialog is
|
// TODO
|
||||||
// dismissed with OK
|
|
||||||
}
|
}
|
||||||
else if (nResponse == IDCANCEL)
|
else if (nResponse == IDCANCEL)
|
||||||
{
|
{
|
||||||
|
@ -99,4 +127,3 @@ int CTegraRcmGUIApp::Run()
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,4 +30,24 @@ public:
|
||||||
DECLARE_MESSAGE_MAP()
|
DECLARE_MESSAGE_MAP()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class CCustomCommandLineInfo : public CCommandLineInfo
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CCustomCommandLineInfo()
|
||||||
|
{
|
||||||
|
m_bAutostart = FALSE;
|
||||||
|
}
|
||||||
|
BOOL m_bAutostart;
|
||||||
|
public:
|
||||||
|
BOOL IsAutostart() { return m_bAutostart; };
|
||||||
|
|
||||||
|
virtual void ParseParam(LPCTSTR pszParam, BOOL bFlag, BOOL bLast)
|
||||||
|
{
|
||||||
|
if (0 == wcscmp(pszParam, L"autostart"))
|
||||||
|
{
|
||||||
|
m_bAutostart = TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
extern CTegraRcmGUIApp theApp;
|
extern CTegraRcmGUIApp theApp;
|
BIN
TegraRcmGUI/TegraRcmGUI.rc
Normal file
40
TegraRcmGUI/TegraRcmGUI.sln
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio 14
|
||||||
|
VisualStudioVersion = 14.0.24720.0
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TegraRcmGUI", "TegraRcmGUI.vcxproj", "{2C091C5B-378F-44D0-91F2-53489BA7B83C}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|x64 = Debug|x64
|
||||||
|
Debug|x86 = Debug|x86
|
||||||
|
Release|x64 = Release|x64
|
||||||
|
Release|x86 = Release|x86
|
||||||
|
Static Debug|x64 = Static Debug|x64
|
||||||
|
Static Debug|x86 = Static Debug|x86
|
||||||
|
Static Release|x64 = Static Release|x64
|
||||||
|
Static Release|x86 = Static Release|x86
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{2C091C5B-378F-44D0-91F2-53489BA7B83C}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{2C091C5B-378F-44D0-91F2-53489BA7B83C}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{2C091C5B-378F-44D0-91F2-53489BA7B83C}.Debug|x86.ActiveCfg = Debug|Win32
|
||||||
|
{2C091C5B-378F-44D0-91F2-53489BA7B83C}.Debug|x86.Build.0 = Debug|Win32
|
||||||
|
{2C091C5B-378F-44D0-91F2-53489BA7B83C}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{2C091C5B-378F-44D0-91F2-53489BA7B83C}.Release|x64.Build.0 = Release|x64
|
||||||
|
{2C091C5B-378F-44D0-91F2-53489BA7B83C}.Release|x86.ActiveCfg = Release|Win32
|
||||||
|
{2C091C5B-378F-44D0-91F2-53489BA7B83C}.Release|x86.Build.0 = Release|Win32
|
||||||
|
{2C091C5B-378F-44D0-91F2-53489BA7B83C}.Static Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{2C091C5B-378F-44D0-91F2-53489BA7B83C}.Static Debug|x64.Build.0 = Debug|x64
|
||||||
|
{2C091C5B-378F-44D0-91F2-53489BA7B83C}.Static Debug|x86.ActiveCfg = Debug|Win32
|
||||||
|
{2C091C5B-378F-44D0-91F2-53489BA7B83C}.Static Debug|x86.Build.0 = Debug|Win32
|
||||||
|
{2C091C5B-378F-44D0-91F2-53489BA7B83C}.Static Release|x64.ActiveCfg = Release|x64
|
||||||
|
{2C091C5B-378F-44D0-91F2-53489BA7B83C}.Static Release|x64.Build.0 = Release|x64
|
||||||
|
{2C091C5B-378F-44D0-91F2-53489BA7B83C}.Static Release|x86.ActiveCfg = Release|Win32
|
||||||
|
{2C091C5B-378F-44D0-91F2-53489BA7B83C}.Static Release|x86.Build.0 = Release|Win32
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
|
@ -22,13 +22,13 @@
|
||||||
<ProjectGuid>{2C091C5B-378F-44D0-91F2-53489BA7B83C}</ProjectGuid>
|
<ProjectGuid>{2C091C5B-378F-44D0-91F2-53489BA7B83C}</ProjectGuid>
|
||||||
<RootNamespace>TegraRcmGUI</RootNamespace>
|
<RootNamespace>TegraRcmGUI</RootNamespace>
|
||||||
<Keyword>MFCProj</Keyword>
|
<Keyword>MFCProj</Keyword>
|
||||||
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
|
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
<PlatformToolset>v140</PlatformToolset>
|
<PlatformToolset>v142</PlatformToolset>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
<UseOfMfc>Dynamic</UseOfMfc>
|
<UseOfMfc>Dynamic</UseOfMfc>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
@ -38,12 +38,12 @@
|
||||||
<WholeProgramOptimization>false</WholeProgramOptimization>
|
<WholeProgramOptimization>false</WholeProgramOptimization>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
<UseOfMfc>Dynamic</UseOfMfc>
|
<UseOfMfc>Dynamic</UseOfMfc>
|
||||||
<PlatformToolset>v140</PlatformToolset>
|
<PlatformToolset>v142</PlatformToolset>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
<PlatformToolset>v140</PlatformToolset>
|
<PlatformToolset>v142</PlatformToolset>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
<UseOfMfc>Dynamic</UseOfMfc>
|
<UseOfMfc>Dynamic</UseOfMfc>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
@ -53,7 +53,7 @@
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
<UseOfMfc>Dynamic</UseOfMfc>
|
<UseOfMfc>Dynamic</UseOfMfc>
|
||||||
<PlatformToolset>v140</PlatformToolset>
|
<PlatformToolset>v142</PlatformToolset>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
<ImportGroup Label="ExtensionSettings">
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
@ -78,26 +78,29 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
<LinkIncremental>true</LinkIncremental>
|
<LinkIncremental>true</LinkIncremental>
|
||||||
|
<OutDir>$(SolutionDir)\Output\$(Platform)\$(Configuration)\</OutDir>
|
||||||
|
<IntDir>Output\$(Platform)\$(Configuration)\</IntDir>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
<LinkIncremental>false</LinkIncremental>
|
<LinkIncremental>false</LinkIncremental>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
<LinkIncremental>false</LinkIncremental>
|
<OutDir>$(SolutionDir)\Output\$(Platform)\$(Configuration)\</OutDir>
|
||||||
|
<IntDir>Output\$(Platform)\$(Configuration)\</IntDir>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;_WINDOWS;_CRT_SECURE_NO_WARNINGS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<AdditionalIncludeDirectories>$(LIBUSBK_DIR)\includes\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(LIBUSBK_DIR)\includes\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<AdditionalDependencies>Version.lib;libusbK.lib</AdditionalDependencies>
|
<AdditionalDependencies>Version.lib;libusbK.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
<AdditionalLibraryDirectories>$(LIBUSBK_DIR)\bin\lib\$(PlatformShortName.Replace('x64','amd64'))\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
<AdditionalLibraryDirectories>$(LIBUSBK_DIR)\bin\lib\$(PlatformShortName.Replace('x64','amd64'))\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
|
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
|
||||||
</Link>
|
</Link>
|
||||||
|
@ -117,15 +120,15 @@
|
||||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<PreprocessorDefinitions>_WINDOWS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>_WINDOWS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<AdditionalIncludeDirectories>$(LIBUSBK_DIR)\includes\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(LIBUSBK_DIR)\includes\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
|
|
||||||
<AdditionalLibraryDirectories>$(LIBUSBK_DIR)\bin\lib\$(PlatformShortName.Replace('x64','amd64'))\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
<AdditionalLibraryDirectories>$(LIBUSBK_DIR)\bin\lib\$(PlatformShortName.Replace('x64','amd64'))\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
|
<AdditionalDependencies>Version.lib;libusbK.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
<Midl>
|
<Midl>
|
||||||
<MkTypLibCompatible>false</MkTypLibCompatible>
|
<MkTypLibCompatible>false</MkTypLibCompatible>
|
||||||
|
@ -145,7 +148,7 @@
|
||||||
<Optimization>MaxSpeed</Optimization>
|
<Optimization>MaxSpeed</Optimization>
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;_WINDOWS;_CRT_SECURE_NO_WARNINGS;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<AdditionalIncludeDirectories>$(LIBUSBK_DIR)\includes\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(LIBUSBK_DIR)\includes\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
@ -156,6 +159,9 @@
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<AdditionalLibraryDirectories>$(LIBUSBK_DIR)\bin\lib\$(PlatformShortName.Replace('x64','amd64'))\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
<AdditionalLibraryDirectories>$(LIBUSBK_DIR)\bin\lib\$(PlatformShortName.Replace('x64','amd64'))\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
<AdditionalDependencies>Version.lib;libusbK.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>Version.lib;libusbK.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
<UACExecutionLevel>AsInvoker</UACExecutionLevel>
|
||||||
|
<EnableUAC>true</EnableUAC>
|
||||||
|
<UACUIAccess>false</UACUIAccess>
|
||||||
</Link>
|
</Link>
|
||||||
<Midl>
|
<Midl>
|
||||||
<MkTypLibCompatible>false</MkTypLibCompatible>
|
<MkTypLibCompatible>false</MkTypLibCompatible>
|
||||||
|
@ -202,12 +208,17 @@
|
||||||
<Text Include="ReadMe.txt" />
|
<Text Include="ReadMe.txt" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ClInclude Include="DialogTab01.h" />
|
||||||
|
<ClInclude Include="DialogTab02.h" />
|
||||||
|
<ClInclude Include="DialogTab03.h" />
|
||||||
<ClInclude Include="libusbk_int.h" />
|
<ClInclude Include="libusbk_int.h" />
|
||||||
|
<ClInclude Include="MyTabCtrl.h" />
|
||||||
<ClInclude Include="Resource.h" />
|
<ClInclude Include="Resource.h" />
|
||||||
<ClInclude Include="res\BitmapPicture.h" />
|
<ClInclude Include="res\BitmapPicture.h" />
|
||||||
<ClInclude Include="ScopeGuard.h" />
|
<ClInclude Include="ScopeGuard.h" />
|
||||||
<ClInclude Include="stdafx.h" />
|
<ClInclude Include="stdafx.h" />
|
||||||
<ClInclude Include="targetver.h" />
|
<ClInclude Include="targetver.h" />
|
||||||
|
<ClInclude Include="TegraRcm.h" />
|
||||||
<ClInclude Include="TegraRcmGUI.h" />
|
<ClInclude Include="TegraRcmGUI.h" />
|
||||||
<ClInclude Include="TegraRcmGUIDlg.h" />
|
<ClInclude Include="TegraRcmGUIDlg.h" />
|
||||||
<ClInclude Include="TegraRcmSmash.h" />
|
<ClInclude Include="TegraRcmSmash.h" />
|
||||||
|
@ -216,6 +227,10 @@
|
||||||
<ClInclude Include="WinHandle.h" />
|
<ClInclude Include="WinHandle.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ClCompile Include="DialogTab01.cpp" />
|
||||||
|
<ClCompile Include="DialogTab02.cpp" />
|
||||||
|
<ClCompile Include="DialogTab03.cpp" />
|
||||||
|
<ClCompile Include="MyTabCtrl.cpp" />
|
||||||
<ClCompile Include="res\BitmapPicture.cpp" />
|
<ClCompile Include="res\BitmapPicture.cpp" />
|
||||||
<ClCompile Include="stdafx.cpp">
|
<ClCompile Include="stdafx.cpp">
|
||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
||||||
|
@ -223,6 +238,7 @@
|
||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="TegraRcm.cpp" />
|
||||||
<ClCompile Include="TegraRcmGUI.cpp" />
|
<ClCompile Include="TegraRcmGUI.cpp" />
|
||||||
<ClCompile Include="TegraRcmGUIDlg.cpp" />
|
<ClCompile Include="TegraRcmGUIDlg.cpp" />
|
||||||
<ClCompile Include="TegraRcmSmash.cpp" />
|
<ClCompile Include="TegraRcmSmash.cpp" />
|
||||||
|
@ -237,16 +253,33 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Image Include="..\..\..\..\..\..\Visual Studio 2015\Projects\TegraRcmGUI\TegraRcmGUI\res\TegraRcmGUI.ico" />
|
<Image Include="..\..\..\..\..\..\Visual Studio 2015\Projects\TegraRcmGUI\TegraRcmGUI\res\TegraRcmGUI.ico" />
|
||||||
|
<Image Include="res\add.ico" />
|
||||||
<Image Include="res\bitmap2.bmp" />
|
<Image Include="res\bitmap2.bmp" />
|
||||||
|
<Image Include="res\browse.ico" />
|
||||||
|
<Image Include="res\bunch-of-keys.ico" />
|
||||||
|
<Image Include="res\delete.ico" />
|
||||||
<Image Include="res\driver_ko.bmp" />
|
<Image Include="res\driver_ko.bmp" />
|
||||||
|
<Image Include="res\driver_ko_2.bmp" />
|
||||||
<Image Include="res\error.bmp" />
|
<Image Include="res\error.bmp" />
|
||||||
|
<Image Include="res\error_2.bmp" />
|
||||||
|
<Image Include="res\icon1.ico" />
|
||||||
<Image Include="res\init_log.bmp" />
|
<Image Include="res\init_log.bmp" />
|
||||||
<Image Include="res\init_logo.bmp" />
|
<Image Include="res\init_logo.bmp" />
|
||||||
|
<Image Include="res\init_logo_2.bmp" />
|
||||||
|
<Image Include="res\linux_icon.ico" />
|
||||||
<Image Include="res\loaded.bmp" />
|
<Image Include="res\loaded.bmp" />
|
||||||
|
<Image Include="res\loaded_2.bmp" />
|
||||||
<Image Include="res\loading.bmp" />
|
<Image Include="res\loading.bmp" />
|
||||||
|
<Image Include="res\loading_2.bmp" />
|
||||||
<Image Include="res\rcm_detected.bmp" />
|
<Image Include="res\rcm_detected.bmp" />
|
||||||
|
<Image Include="res\rcm_detected_2.bmp" />
|
||||||
<Image Include="res\rcm_undetected.bmp" />
|
<Image Include="res\rcm_undetected.bmp" />
|
||||||
|
<Image Include="res\rcm_undetected_2.bmp" />
|
||||||
|
<Image Include="res\status.ico" />
|
||||||
<Image Include="res\TegraRcmGUI.ico" />
|
<Image Include="res\TegraRcmGUI.ico" />
|
||||||
|
<Image Include="res\tray_ico_connected.ico" />
|
||||||
|
<Image Include="res\tray_ico_not_connected.ico" />
|
||||||
|
<Image Include="res\usb_icon.ico" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
<ImportGroup Label="ExtensionTargets">
|
|
@ -54,6 +54,21 @@
|
||||||
<ClInclude Include="res\BitmapPicture.h">
|
<ClInclude Include="res\BitmapPicture.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="MyTabCtrl.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DialogTab01.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DialogTab02.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DialogTab03.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="TegraRcm.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="TegraRcmGUI.cpp">
|
<ClCompile Include="TegraRcmGUI.cpp">
|
||||||
|
@ -71,6 +86,21 @@
|
||||||
<ClCompile Include="res\BitmapPicture.cpp">
|
<ClCompile Include="res\BitmapPicture.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="MyTabCtrl.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DialogTab01.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DialogTab02.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="DialogTab03.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="TegraRcm.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ResourceCompile Include="TegraRcmGUI.rc">
|
<ResourceCompile Include="TegraRcmGUI.rc">
|
||||||
|
@ -116,5 +146,56 @@
|
||||||
<Image Include="res\loading.bmp">
|
<Image Include="res\loading.bmp">
|
||||||
<Filter>Resource Files</Filter>
|
<Filter>Resource Files</Filter>
|
||||||
</Image>
|
</Image>
|
||||||
|
<Image Include="res\icon1.ico">
|
||||||
|
<Filter>Resource Files</Filter>
|
||||||
|
</Image>
|
||||||
|
<Image Include="res\tray_ico_connected.ico">
|
||||||
|
<Filter>Resource Files</Filter>
|
||||||
|
</Image>
|
||||||
|
<Image Include="res\tray_ico_not_connected.ico">
|
||||||
|
<Filter>Resource Files</Filter>
|
||||||
|
</Image>
|
||||||
|
<Image Include="res\browse.ico">
|
||||||
|
<Filter>Resource Files</Filter>
|
||||||
|
</Image>
|
||||||
|
<Image Include="res\status.ico">
|
||||||
|
<Filter>Resource Files</Filter>
|
||||||
|
</Image>
|
||||||
|
<Image Include="res\linux_icon.ico">
|
||||||
|
<Filter>Resource Files</Filter>
|
||||||
|
</Image>
|
||||||
|
<Image Include="res\usb_icon.ico">
|
||||||
|
<Filter>Resource Files</Filter>
|
||||||
|
</Image>
|
||||||
|
<Image Include="res\add.ico">
|
||||||
|
<Filter>Resource Files</Filter>
|
||||||
|
</Image>
|
||||||
|
<Image Include="res\delete.ico">
|
||||||
|
<Filter>Resource Files</Filter>
|
||||||
|
</Image>
|
||||||
|
<Image Include="res\rcm_undetected_2.bmp">
|
||||||
|
<Filter>Resource Files</Filter>
|
||||||
|
</Image>
|
||||||
|
<Image Include="res\driver_ko_2.bmp">
|
||||||
|
<Filter>Resource Files</Filter>
|
||||||
|
</Image>
|
||||||
|
<Image Include="res\rcm_detected_2.bmp">
|
||||||
|
<Filter>Resource Files</Filter>
|
||||||
|
</Image>
|
||||||
|
<Image Include="res\loaded_2.bmp">
|
||||||
|
<Filter>Resource Files</Filter>
|
||||||
|
</Image>
|
||||||
|
<Image Include="res\loading_2.bmp">
|
||||||
|
<Filter>Resource Files</Filter>
|
||||||
|
</Image>
|
||||||
|
<Image Include="res\error_2.bmp">
|
||||||
|
<Filter>Resource Files</Filter>
|
||||||
|
</Image>
|
||||||
|
<Image Include="res\init_logo_2.bmp">
|
||||||
|
<Filter>Resource Files</Filter>
|
||||||
|
</Image>
|
||||||
|
<Image Include="res\bunch-of-keys.ico">
|
||||||
|
<Filter>Resource Files</Filter>
|
||||||
|
</Image>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
471
TegraRcmGUI/TegraRcmGUIDlg.cpp
Normal file
|
@ -0,0 +1,471 @@
|
||||||
|
/*
|
||||||
|
TegraRcmGUIDlg.cpp
|
||||||
|
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright(c) 2018 eliboa
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files(the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions :
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "stdafx.h"
|
||||||
|
#include "afxdialogex.h"
|
||||||
|
#include "TegraRcmGUI.h"
|
||||||
|
#include "TegraRcmGUIDlg.h"
|
||||||
|
#include <windows.h>
|
||||||
|
#include <shellapi.h>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
#ifdef _DEBUG
|
||||||
|
#define new DEBUG_NEW
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define ARRAY_SIZE 1024
|
||||||
|
|
||||||
|
CString csPath;
|
||||||
|
CString csPath2;
|
||||||
|
ULONGLONG GetDllVersion(LPCTSTR lpszDllName);
|
||||||
|
|
||||||
|
//
|
||||||
|
// dialog
|
||||||
|
//
|
||||||
|
CTegraRcmGUIDlg::CTegraRcmGUIDlg(CWnd* pParent /*=NULL*/)
|
||||||
|
: CDialog(IDD_TEGRARCMGUI_DIALOG, pParent)
|
||||||
|
, STATUS(0)
|
||||||
|
{
|
||||||
|
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
|
||||||
|
}
|
||||||
|
void CTegraRcmGUIDlg::DoDataExchange(CDataExchange* pDX)
|
||||||
|
{
|
||||||
|
CDialog::DoDataExchange(pDX);
|
||||||
|
DDX_Control(pDX, RCM_PIC_1, RCM_BITMAP1);
|
||||||
|
DDX_Control(pDX, RCM_PIC_2, RCM_BITMAP2);
|
||||||
|
DDX_Control(pDX, RCM_PIC_3, RCM_BITMAP3);
|
||||||
|
DDX_Control(pDX, RCM_PIC_4, RCM_BITMAP0);
|
||||||
|
DDX_Control(pDX, RCM_PIC_5, RCM_BITMAP4);
|
||||||
|
DDX_Control(pDX, RCM_PIC_6, RCM_BITMAP5);
|
||||||
|
DDX_Control(pDX, RCM_PIC_7, RCM_BITMAP6);
|
||||||
|
DDX_Control(pDX, IDC_TAB_CONTROL, m_tbCtrl);
|
||||||
|
}
|
||||||
|
BEGIN_MESSAGE_MAP(CTegraRcmGUIDlg, CDialog)
|
||||||
|
ON_WM_CTLCOLOR()
|
||||||
|
ON_WM_TIMER()
|
||||||
|
ON_WM_SIZE()
|
||||||
|
ON_WM_SYSCOMMAND()
|
||||||
|
ON_WM_PAINT()
|
||||||
|
ON_WM_QUERYDRAGICON()
|
||||||
|
ON_WM_SHOWWINDOW()
|
||||||
|
ON_WM_CLOSE()
|
||||||
|
ON_MESSAGE(WM_SYSICON, OnTrayIconEvent)
|
||||||
|
ON_COMMAND(SWM_EXIT, OnClose)
|
||||||
|
ON_COMMAND(SWM_SHOW, ShowWindowCommand)
|
||||||
|
ON_COMMAND(SWM_HIDE, HideWindowCommand)
|
||||||
|
ON_COMMAND(SWM_INJECT, InjectCommand)
|
||||||
|
ON_COMMAND(SWM_BROWSE, BrowseCommand)
|
||||||
|
ON_COMMAND(SWM_LINUX, LinuxCommand)
|
||||||
|
ON_COMMAND(SWM_MOUNT, MountCommand)
|
||||||
|
ON_COMMAND(SWM_FAV01, InjectFav01Command)
|
||||||
|
ON_COMMAND(SWM_FAV02, InjectFav02Command)
|
||||||
|
ON_COMMAND(SWM_FAV03, InjectFav03Command)
|
||||||
|
ON_COMMAND(SWM_FAV04, InjectFav04Command)
|
||||||
|
ON_COMMAND(SWM_FAV05, InjectFav05Command)
|
||||||
|
ON_COMMAND(SWM_FAV06, InjectFav06Command)
|
||||||
|
ON_COMMAND(SWM_FAV07, InjectFav07Command)
|
||||||
|
ON_COMMAND(SWM_FAV08, InjectFav08Command)
|
||||||
|
ON_COMMAND(SWM_FAV09, InjectFav09Command)
|
||||||
|
ON_COMMAND(SWM_FAV10, InjectFav10Command)
|
||||||
|
ON_COMMAND(SWM_AUTOINJECT, AutoInjectCommand)
|
||||||
|
ON_MESSAGE(WM_QUERYENDSESSION, OnQueryEndSession)
|
||||||
|
END_MESSAGE_MAP()
|
||||||
|
|
||||||
|
//
|
||||||
|
// message handlers
|
||||||
|
//
|
||||||
|
BOOL CTegraRcmGUIDlg::OnInitDialog()
|
||||||
|
{
|
||||||
|
|
||||||
|
m_TegraRcm = new TegraRcm(this);
|
||||||
|
m_TegraRcm->AppendLog("new TegraRcm()");
|
||||||
|
|
||||||
|
CDialog::OnInitDialog();
|
||||||
|
|
||||||
|
// Accessibility
|
||||||
|
EnableActiveAccessibility();
|
||||||
|
|
||||||
|
// Get current directory
|
||||||
|
TCHAR szPath[_MAX_PATH];
|
||||||
|
VERIFY(::GetModuleFileName(AfxGetApp()->m_hInstance, szPath, _MAX_PATH));
|
||||||
|
CString csPathf(szPath);
|
||||||
|
CT2CA pszConvertedAnsiString(csPathf);
|
||||||
|
std::string strStd(pszConvertedAnsiString);
|
||||||
|
m_TegraRcm->AppendLog("Module filename is : ");
|
||||||
|
m_TegraRcm->AppendLog(strStd);
|
||||||
|
|
||||||
|
int nIndex = csPathf.ReverseFind(_T('\\'));
|
||||||
|
if (nIndex > 0) csPath = csPathf.Left(nIndex);
|
||||||
|
else csPath.Empty();
|
||||||
|
|
||||||
|
// Initialize bitmap
|
||||||
|
CRect rc;
|
||||||
|
AfxGetMainWnd()->GetWindowRect(rc);
|
||||||
|
int width = rc.Width();
|
||||||
|
int fontSize = width * 0.031;
|
||||||
|
if (width < 400)
|
||||||
|
{
|
||||||
|
RCM_BITMAP0.SetBitmap(INIT_LOGO_2);
|
||||||
|
RCM_BITMAP1.SetBitmap(RCM_NOT_DETECTED_2);
|
||||||
|
RCM_BITMAP2.SetBitmap(DRIVER_KO_2);
|
||||||
|
RCM_BITMAP3.SetBitmap(RCM_DETECTED_2);
|
||||||
|
RCM_BITMAP4.SetBitmap(LOADING_2);
|
||||||
|
RCM_BITMAP5.SetBitmap(LOADED_2);
|
||||||
|
RCM_BITMAP6.SetBitmap(LOAD_ERROR_2);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
RCM_BITMAP0.SetBitmap(INIT_LOGO);
|
||||||
|
RCM_BITMAP1.SetBitmap(RCM_NOT_DETECTED);
|
||||||
|
RCM_BITMAP2.SetBitmap(DRIVER_KO);
|
||||||
|
RCM_BITMAP3.SetBitmap(RCM_DETECTED);
|
||||||
|
RCM_BITMAP4.SetBitmap(LOADING);
|
||||||
|
RCM_BITMAP5.SetBitmap(LOADED);
|
||||||
|
RCM_BITMAP6.SetBitmap(LOAD_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Log Box
|
||||||
|
LOGFONT lf;
|
||||||
|
/*
|
||||||
|
CEdit* pBox = (CEdit*)AfxGetMainWnd()->GetDlgItem(IDC_LOG_BOX);
|
||||||
|
CFont* old = pBox->GetFont();
|
||||||
|
old->GetLogFont(&lf);
|
||||||
|
CFont newfont;
|
||||||
|
newfont.CreateFont(lf.lfHeight + 30, 0, lf.lfEscapement, lf.lfOrientation, lf.lfWeight, lf.lfItalic, lf.lfUnderline, lf.lfStrikeOut, lf.lfCharSet, lf.lfOutPrecision, lf.lfClipPrecision, lf.lfQuality, lf.lfPitchAndFamily, lf.lfFaceName);
|
||||||
|
pBox->SetFont(&newfont);
|
||||||
|
*/
|
||||||
|
|
||||||
|
CEdit* pBox = (CEdit*)AfxGetMainWnd()->GetDlgItem(IDC_LOG_BOX);
|
||||||
|
|
||||||
|
CFont *myFont = new CFont();
|
||||||
|
myFont->CreateFont(fontSize, 0, 0, 0, FW_NORMAL, false, false,
|
||||||
|
0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
|
||||||
|
FIXED_PITCH | FF_MODERN, _T("Verdana"));
|
||||||
|
|
||||||
|
pBox->SetFont(myFont);
|
||||||
|
|
||||||
|
|
||||||
|
// Menu
|
||||||
|
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
|
||||||
|
ASSERT(IDM_ABOUTBOX < 0xF000);
|
||||||
|
CMenu* pSysMenu = GetSystemMenu(FALSE);
|
||||||
|
if (pSysMenu != NULL)
|
||||||
|
{
|
||||||
|
BOOL bNameValid;
|
||||||
|
CString strAboutMenu;
|
||||||
|
bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX);
|
||||||
|
ASSERT(bNameValid);
|
||||||
|
if (!strAboutMenu.IsEmpty())
|
||||||
|
{
|
||||||
|
pSysMenu->AppendMenu(MF_SEPARATOR);
|
||||||
|
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set icons
|
||||||
|
SetIcon(m_hIcon, TRUE); // Set big icon
|
||||||
|
SetIcon(m_hIcon, FALSE); // Set small icon
|
||||||
|
|
||||||
|
// Kill other running process of app
|
||||||
|
m_TegraRcm->KillRunningProcess(TEXT("TegraRcmGUI.exe"));
|
||||||
|
|
||||||
|
m_tbCtrl.InitDialogs(m_TegraRcm);
|
||||||
|
|
||||||
|
TCITEM tcItem1;
|
||||||
|
tcItem1.mask = TCIF_TEXT;
|
||||||
|
tcItem1.pszText = _T("Payload");
|
||||||
|
m_tbCtrl.InsertItem(0, &tcItem1);
|
||||||
|
|
||||||
|
TCITEM tcItem2;
|
||||||
|
tcItem2.mask = TCIF_TEXT;
|
||||||
|
tcItem2.pszText = _T("Tools");
|
||||||
|
m_tbCtrl.InsertItem(1, &tcItem2);
|
||||||
|
|
||||||
|
TCITEM tcItem3;
|
||||||
|
tcItem3.mask = TCIF_TEXT;
|
||||||
|
tcItem3.pszText = _T("Settings");
|
||||||
|
|
||||||
|
m_tbCtrl.InsertItem(2, &tcItem3);
|
||||||
|
m_tbCtrl.ActivateTabDialogs();
|
||||||
|
|
||||||
|
m_TegraRcm->InitCtrltbDlgs(m_tbCtrl.m_Dialog[0], m_tbCtrl.m_Dialog[1], m_tbCtrl.m_Dialog[2]);
|
||||||
|
|
||||||
|
m_TegraRcm->BitmapDisplay(INIT_LOGO);
|
||||||
|
|
||||||
|
// Tray icon
|
||||||
|
m_TegraRcm->CreateTrayIcon();
|
||||||
|
m_TegraRcm->SetTrayIconTipText(TEXT("TegraRcmGUI"));
|
||||||
|
|
||||||
|
// Start timer to check RCM status every second
|
||||||
|
CTegraRcmGUIDlg::StartTimer();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
void CTegraRcmGUIDlg::OnSysCommand(UINT nID, LPARAM lParam)
|
||||||
|
{
|
||||||
|
CDialog::OnSysCommand(nID, lParam);
|
||||||
|
}
|
||||||
|
void CTegraRcmGUIDlg::OnShowWindow(BOOL bShow, UINT nStatus)
|
||||||
|
{
|
||||||
|
//CmdShow = bShow;
|
||||||
|
//CDialog::OnShowWindow(bShow, nStatus);
|
||||||
|
}
|
||||||
|
HBRUSH CTegraRcmGUIDlg::OnCtlColor(CDC* pDC, CWnd *pWnd, UINT nCtlColor)
|
||||||
|
{
|
||||||
|
switch (nCtlColor)
|
||||||
|
{
|
||||||
|
case CTLCOLOR_STATIC:
|
||||||
|
/*
|
||||||
|
if (GetDlgItem(IDC_RAJKOSTO)->GetSafeHwnd() == pWnd->GetSafeHwnd() || GetDlgItem(SEPARATOR)->GetSafeHwnd() == pWnd->GetSafeHwnd())
|
||||||
|
{
|
||||||
|
pDC->SetTextColor(RGB(192, 192, 192));
|
||||||
|
pDC->SetBkMode(TRANSPARENT);
|
||||||
|
return (HBRUSH)GetStockObject(NULL_BRUSH);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
if (GetDlgItem(INFO_LABEL)->GetSafeHwnd() == pWnd->GetSafeHwnd())
|
||||||
|
{
|
||||||
|
pDC->SetBkMode(TRANSPARENT);
|
||||||
|
pDC->SetTextColor(m_TegraRcm->LabelColor);
|
||||||
|
return (HBRUSH) CreateSolidBrush( WhiteRGB );
|
||||||
|
}
|
||||||
|
if (GetDlgItem(IDC_LOG_BOX)->GetSafeHwnd() == pWnd->GetSafeHwnd())
|
||||||
|
{
|
||||||
|
pDC->SetBkMode(TRANSPARENT);
|
||||||
|
return (HBRUSH)CreateSolidBrush(WhiteRGB);
|
||||||
|
}
|
||||||
|
if (GetDlgItem(IDC_STATUS_BG)->GetSafeHwnd() == pWnd->GetSafeHwnd())
|
||||||
|
{
|
||||||
|
return (HBRUSH)CreateSolidBrush(WhiteRGB);
|
||||||
|
}
|
||||||
|
if (GetDlgItem(RCM_BITMAP)->GetSafeHwnd() == pWnd->GetSafeHwnd())
|
||||||
|
{
|
||||||
|
return (HBRUSH)CreateSolidBrush(WhiteRGB);
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void CTegraRcmGUIDlg::OnPaint()
|
||||||
|
{
|
||||||
|
|
||||||
|
if (IsIconic())
|
||||||
|
{
|
||||||
|
CPaintDC dc(this); // device context for painting
|
||||||
|
|
||||||
|
SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
|
||||||
|
|
||||||
|
// Center icon in client rectangle
|
||||||
|
int cxIcon = GetSystemMetrics(SM_CXICON);
|
||||||
|
int cyIcon = GetSystemMetrics(SM_CYICON);
|
||||||
|
CRect rect;
|
||||||
|
GetClientRect(&rect);
|
||||||
|
int x = (rect.Width() - cxIcon + 1) / 2;
|
||||||
|
int y = (rect.Height() - cyIcon + 1) / 2;
|
||||||
|
|
||||||
|
// Draw the icon
|
||||||
|
dc.DrawIcon(x, y, m_hIcon);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CDialog::OnPaint();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
HCURSOR CTegraRcmGUIDlg::OnQueryDragIcon()
|
||||||
|
{
|
||||||
|
return static_cast<HCURSOR>(m_hIcon);
|
||||||
|
}
|
||||||
|
void CTegraRcmGUIDlg::OnSize(UINT nType, int cx, int cy)
|
||||||
|
{
|
||||||
|
if (nType == SIZE_MINIMIZED)
|
||||||
|
{
|
||||||
|
if (m_TegraRcm->MIN_TO_TRAY_CURR)
|
||||||
|
{
|
||||||
|
ShowWindow(SW_HIDE);
|
||||||
|
}
|
||||||
|
if (m_TegraRcm != NULL)
|
||||||
|
{
|
||||||
|
m_TegraRcm->CmdShow = FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (m_TegraRcm != NULL) m_TegraRcm->CmdShow = TRUE;
|
||||||
|
//ShowWindow(SW_RESTORE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void CTegraRcmGUIDlg::OnClose()
|
||||||
|
{
|
||||||
|
m_TegraRcm->DestroyTrayIcon();
|
||||||
|
PostQuitMessage(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
LRESULT CTegraRcmGUIDlg::OnTrayIconEvent(WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
return m_TegraRcm->OnTrayIconEvent(wParam, lParam);
|
||||||
|
}
|
||||||
|
void CTegraRcmGUIDlg::ShowWindowCommand()
|
||||||
|
{
|
||||||
|
ShowWindow(SW_RESTORE);
|
||||||
|
SetForegroundWindow();
|
||||||
|
SetFocus();
|
||||||
|
SetActiveWindow();
|
||||||
|
if (m_TegraRcm != NULL)
|
||||||
|
{
|
||||||
|
m_TegraRcm->CmdShow = TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void CTegraRcmGUIDlg::HideWindowCommand()
|
||||||
|
{
|
||||||
|
ShowWindow(SW_HIDE);
|
||||||
|
if (m_TegraRcm != NULL)
|
||||||
|
{
|
||||||
|
m_TegraRcm->CmdShow = FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void CTegraRcmGUIDlg::InjectCommand()
|
||||||
|
{
|
||||||
|
if (m_TegraRcm != NULL)
|
||||||
|
{
|
||||||
|
DialogTab01 *pt = (DialogTab01*) m_TegraRcm->m_Ctrltb1;
|
||||||
|
pt->InjectPayload();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void CTegraRcmGUIDlg::BrowseCommand()
|
||||||
|
{
|
||||||
|
if (m_TegraRcm != NULL)
|
||||||
|
{
|
||||||
|
DialogTab01 *pt = (DialogTab01*)m_TegraRcm->m_Ctrltb1;
|
||||||
|
pt->OnBnClickedBrowse();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void CTegraRcmGUIDlg::LinuxCommand()
|
||||||
|
{
|
||||||
|
if (m_TegraRcm != NULL)
|
||||||
|
{
|
||||||
|
DialogTab02 *pt = (DialogTab02*)m_TegraRcm->m_Ctrltb2;
|
||||||
|
pt->OnBnClickedShofel2();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void CTegraRcmGUIDlg::MountCommand()
|
||||||
|
{
|
||||||
|
if (m_TegraRcm != NULL)
|
||||||
|
{
|
||||||
|
DialogTab02 *pt = (DialogTab02*)m_TegraRcm->m_Ctrltb2;
|
||||||
|
CComboBox* pmyComboBox = (CComboBox*)pt->GetDlgItem(ID_UMS_COMBO);
|
||||||
|
pmyComboBox->SetCurSel(3);
|
||||||
|
pt->OnBnClickedMountSd();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void CTegraRcmGUIDlg::InjectFav01Command() { InjectFavCommand(0); }
|
||||||
|
void CTegraRcmGUIDlg::InjectFav02Command() { InjectFavCommand(1); }
|
||||||
|
void CTegraRcmGUIDlg::InjectFav03Command() { InjectFavCommand(2); }
|
||||||
|
void CTegraRcmGUIDlg::InjectFav04Command() { InjectFavCommand(3); }
|
||||||
|
void CTegraRcmGUIDlg::InjectFav05Command() { InjectFavCommand(4); }
|
||||||
|
void CTegraRcmGUIDlg::InjectFav06Command() { InjectFavCommand(5); }
|
||||||
|
void CTegraRcmGUIDlg::InjectFav07Command() { InjectFavCommand(6); }
|
||||||
|
void CTegraRcmGUIDlg::InjectFav08Command() { InjectFavCommand(7); }
|
||||||
|
void CTegraRcmGUIDlg::InjectFav09Command() { InjectFavCommand(8); }
|
||||||
|
void CTegraRcmGUIDlg::InjectFav10Command() { InjectFavCommand(9); }
|
||||||
|
void CTegraRcmGUIDlg::InjectFavCommand(int i)
|
||||||
|
{
|
||||||
|
if (m_TegraRcm != NULL)
|
||||||
|
{
|
||||||
|
DialogTab01 *pt = (DialogTab01*)m_TegraRcm->m_Ctrltb1;
|
||||||
|
CString fav = m_TegraRcm->Favorites.GetAt(i);
|
||||||
|
pt->GetDlgItem(PAYLOAD_PATH)->SetWindowTextW(fav);
|
||||||
|
pt->GetDlgItem(PAYLOAD_PATH)->GetFocus();
|
||||||
|
pt->InjectPayload();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CTegraRcmGUIDlg::AutoInjectCommand()
|
||||||
|
{
|
||||||
|
if (m_TegraRcm != NULL)
|
||||||
|
{
|
||||||
|
DialogTab03 *pt = (DialogTab03*)m_TegraRcm->m_Ctrltb3;
|
||||||
|
if (m_TegraRcm->AUTOINJECT_CURR)
|
||||||
|
{
|
||||||
|
m_TegraRcm->AUTOINJECT_CURR = FALSE;
|
||||||
|
m_TegraRcm->SetPreset("AUTO_INJECT", "FALSE");
|
||||||
|
m_TegraRcm->DELAY_AUTOINJECT = FALSE;
|
||||||
|
CButton *m_ctlCheck = (CButton*)pt->GetDlgItem(AUTO_INJECT);
|
||||||
|
m_ctlCheck->SetCheck(BST_UNCHECKED);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_TegraRcm->AUTOINJECT_CURR = TRUE;
|
||||||
|
m_TegraRcm->SetPreset("AUTO_INJECT", "TRUE");
|
||||||
|
m_TegraRcm->DELAY_AUTOINJECT = TRUE;
|
||||||
|
CButton *m_ctlCheck = (CButton*)pt->GetDlgItem(AUTO_INJECT);
|
||||||
|
m_ctlCheck->SetCheck(BST_CHECKED);
|
||||||
|
}
|
||||||
|
AfxGetMainWnd()->UpdateWindow();
|
||||||
|
pt->OnClickedAutoInject();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CTegraRcmGUIDlg::StartTimer()
|
||||||
|
{
|
||||||
|
// Set timer for Minutes.
|
||||||
|
//SetTimer(ID_TIMER_MINUTE, 60 * 1000, 0);
|
||||||
|
// Set timer for Seconds.
|
||||||
|
SetTimer(ID_TIMER_SECONDS, 1000, 0);
|
||||||
|
}
|
||||||
|
void CTegraRcmGUIDlg::StopTimer()
|
||||||
|
{
|
||||||
|
// Stop both timers.
|
||||||
|
KillTimer(ID_TIMER_MINUTE);
|
||||||
|
KillTimer(ID_TIMER_SECONDS);
|
||||||
|
}
|
||||||
|
void CTegraRcmGUIDlg::OnTimer(UINT_PTR nIDEvent)
|
||||||
|
{
|
||||||
|
// Each second
|
||||||
|
if (nIDEvent == ID_TIMER_SECONDS)
|
||||||
|
{
|
||||||
|
m_TegraRcm->LookUp();
|
||||||
|
}
|
||||||
|
|
||||||
|
// After first initDialog, hide window if min2tray option is enabled
|
||||||
|
if (AUTOSTART)
|
||||||
|
{
|
||||||
|
if (m_TegraRcm->MIN_TO_TRAY_CURR) HideWindowCommand();
|
||||||
|
AUTOSTART = FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LRESULT CTegraRcmGUIDlg::OnQueryEndSession(WPARAM wParm, LPARAM lParm)
|
||||||
|
{
|
||||||
|
// This is not useful, exit is not needed in that case
|
||||||
|
m_TegraRcm->AppendLog("OnEndSession");
|
||||||
|
PostMessage(WM_QUIT);
|
||||||
|
return TRUE;
|
||||||
|
}
|
130
TegraRcmGUI/TegraRcmGUIDlg.h
Normal file
|
@ -0,0 +1,130 @@
|
||||||
|
// TegraRcmGUIDlg.h : header file
|
||||||
|
//
|
||||||
|
#pragma once
|
||||||
|
#include "res/BitmapPicture.h"
|
||||||
|
#include "resource.h"
|
||||||
|
#include <string>
|
||||||
|
#include "TegraRcmSmash.h"
|
||||||
|
#include "res/BitmapPicture.h"
|
||||||
|
#include <windows.h>
|
||||||
|
#include <string>
|
||||||
|
#include <time.h>
|
||||||
|
#include <thread>
|
||||||
|
#include <iostream>
|
||||||
|
#include <sstream>
|
||||||
|
#include <fstream>
|
||||||
|
#include <iostream>
|
||||||
|
#include <cstdio>
|
||||||
|
#include <memory>
|
||||||
|
#include <stdexcept>
|
||||||
|
#include <array>
|
||||||
|
#include <setupapi.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <Strsafe.h>
|
||||||
|
#include "afxcmn.h"
|
||||||
|
#include "MyTabCtrl.h"
|
||||||
|
#include "TegraRcm.h"
|
||||||
|
#include "DialogTab01.h"
|
||||||
|
#include "DialogTab02.h"
|
||||||
|
#include "DialogTab03.h"
|
||||||
|
|
||||||
|
|
||||||
|
#pragma comment (lib, "setupapi.lib")
|
||||||
|
|
||||||
|
// CTegraRcmGUIDlg dialog
|
||||||
|
class CTegraRcmGUIDlg :
|
||||||
|
public CDialog
|
||||||
|
{
|
||||||
|
// Construction
|
||||||
|
public:
|
||||||
|
CTegraRcmGUIDlg(CWnd* pParent = NULL); // standard constructor
|
||||||
|
|
||||||
|
CBitmapPicture RCM_BITMAP0;
|
||||||
|
CBitmapPicture RCM_BITMAP1;
|
||||||
|
CBitmapPicture RCM_BITMAP2;
|
||||||
|
CBitmapPicture RCM_BITMAP3;
|
||||||
|
CBitmapPicture RCM_BITMAP4;
|
||||||
|
CBitmapPicture RCM_BITMAP5;
|
||||||
|
CBitmapPicture RCM_BITMAP6;
|
||||||
|
HICON StatusIcon;
|
||||||
|
CMFCEditBrowseCtrl m_EditBrowse;
|
||||||
|
|
||||||
|
BOOL AUTOINJECT_CURR = FALSE;
|
||||||
|
TCHAR* PAYLOAD_FILE;
|
||||||
|
int RCM_STATUS = -10;
|
||||||
|
BOOL WAITING_RECONNECT = FALSE;
|
||||||
|
BOOL PREVENT_AUTOINJECT = TRUE;
|
||||||
|
BOOL DELAY_AUTOINJECT = TRUE;
|
||||||
|
BOOL ASK_FOR_DRIVER = FALSE;
|
||||||
|
BOOL PAUSE_LKP_DEVICE = FALSE;
|
||||||
|
BOOL AUTOSTART = FALSE;
|
||||||
|
BOOL CmdShow;
|
||||||
|
COLORREF LabelColor = RGB(0, 0, 0);
|
||||||
|
COLORREF WhiteRGB = RGB(255, 255, 255);
|
||||||
|
COLORREF BlackRGB = RGB(0, 0, 0);
|
||||||
|
COLORREF RedRGB = RGB(255, 0, 0);
|
||||||
|
COLORREF GreenRGB = RGB(0, 100, 0);
|
||||||
|
|
||||||
|
const UINT ID_TIMER_MINUTE = 0x1001;
|
||||||
|
const UINT ID_TIMER_SECONDS = 0x1000;
|
||||||
|
|
||||||
|
// Dialog Data
|
||||||
|
#ifdef AFX_DESIGN_TIME
|
||||||
|
enum { IDD = IDD_TEGRARCMGUI_DIALOG };
|
||||||
|
#endif
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||||
|
|
||||||
|
// Implementation
|
||||||
|
|
||||||
|
HICON m_hIcon;
|
||||||
|
|
||||||
|
// Generated message map functions
|
||||||
|
virtual BOOL OnInitDialog();
|
||||||
|
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
|
||||||
|
afx_msg void OnIdle();
|
||||||
|
afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
|
||||||
|
afx_msg void OnPaint();
|
||||||
|
afx_msg void OnClose();
|
||||||
|
afx_msg void OnSize(UINT nType, int cx, int cy);
|
||||||
|
afx_msg HCURSOR OnQueryDragIcon();
|
||||||
|
afx_msg void OnDestroy();
|
||||||
|
afx_msg LRESULT OnTrayIconEvent(WPARAM wParam, LPARAM lParam);
|
||||||
|
DECLARE_MESSAGE_MAP()
|
||||||
|
afx_msg LRESULT OnQueryEndSession(WPARAM wParm, LPARAM lParm);
|
||||||
|
|
||||||
|
public:
|
||||||
|
void StartTimer();
|
||||||
|
void StopTimer();
|
||||||
|
void OnTimer(UINT_PTR nIDEvent);
|
||||||
|
int STATUS;
|
||||||
|
afx_msg void BitmapDisplay(int IMG);
|
||||||
|
|
||||||
|
afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd *pWnd, UINT nCtlColor);
|
||||||
|
void ShowWindowCommand();
|
||||||
|
void HideWindowCommand();
|
||||||
|
void InjectCommand();
|
||||||
|
void BrowseCommand();
|
||||||
|
void LinuxCommand();
|
||||||
|
void MountCommand();
|
||||||
|
void InjectFavCommand(int i);
|
||||||
|
void InjectFav01Command();
|
||||||
|
void InjectFav02Command();
|
||||||
|
void InjectFav03Command();
|
||||||
|
void InjectFav04Command();
|
||||||
|
void InjectFav05Command();
|
||||||
|
void InjectFav06Command();
|
||||||
|
void InjectFav07Command();
|
||||||
|
void InjectFav08Command();
|
||||||
|
void InjectFav09Command();
|
||||||
|
void InjectFav10Command();
|
||||||
|
void AutoInjectCommand();
|
||||||
|
|
||||||
|
CTegraRcmGUIDlg *m_pMainWnd = this;
|
||||||
|
private:
|
||||||
|
MyTabCtrl m_tbCtrl;
|
||||||
|
TegraRcm *m_TegraRcm;
|
||||||
|
public:
|
||||||
|
afx_msg void OnEnChangeLogBox();
|
||||||
|
};
|
|
@ -225,6 +225,98 @@ TegraRcmSmash::~TegraRcmSmash()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int TegraRcmSmash::Test()
|
||||||
|
{
|
||||||
|
KLST_DEVINFO_HANDLE deviceInfo = nullptr;
|
||||||
|
|
||||||
|
KLST_HANDLE deviceList = nullptr;
|
||||||
|
if (!LstK_Init(&deviceList, KLST_FLAG_NONE))
|
||||||
|
{
|
||||||
|
const auto errorCode = GetLastError();
|
||||||
|
// Win32 error trying to list USB devices
|
||||||
|
return -6;
|
||||||
|
}
|
||||||
|
auto lstKgrd = MakeScopeGuard([&deviceList]()
|
||||||
|
{
|
||||||
|
if (deviceList != nullptr)
|
||||||
|
{
|
||||||
|
LstK_Free(deviceList);
|
||||||
|
deviceList = nullptr;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Get the number of devices contained in the device list.
|
||||||
|
UINT deviceCount = 0;
|
||||||
|
LstK_Count(deviceList, &deviceCount);
|
||||||
|
|
||||||
|
if (deviceCount == 0 || LstK_FindByVidPid(deviceList, deviceVid, devicePid, &deviceInfo) == FALSE)
|
||||||
|
{
|
||||||
|
// No device found in RCM Mode
|
||||||
|
return -5;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (deviceInfo != nullptr)
|
||||||
|
{
|
||||||
|
if (deviceInfo->DriverID != KUSB_DRVID_LIBUSBK)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Wrong driver => need to install libusbK driver
|
||||||
|
*/
|
||||||
|
return -4;
|
||||||
|
}
|
||||||
|
|
||||||
|
KUSB_DRIVER_API Usb;
|
||||||
|
LibK_LoadDriverAPI(&Usb, deviceInfo->DriverID);
|
||||||
|
|
||||||
|
// Initialize the device
|
||||||
|
KUSB_HANDLE handle = nullptr;
|
||||||
|
if (!Usb.Init(&handle, deviceInfo))
|
||||||
|
{
|
||||||
|
const auto errorCode = GetLastError();
|
||||||
|
// Failed to handle device
|
||||||
|
return -3;
|
||||||
|
}
|
||||||
|
|
||||||
|
RCMDeviceHacker rcmDev(Usb, handle); handle = nullptr;
|
||||||
|
|
||||||
|
libusbk::version_t usbkVersion;
|
||||||
|
memset(&usbkVersion, 0, sizeof(usbkVersion));
|
||||||
|
const auto versRetVal = rcmDev.getDriverVersion(usbkVersion);
|
||||||
|
if (versRetVal <= 0)
|
||||||
|
{
|
||||||
|
// Failed to get USB driver version
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
else if (usbkVersion.major != 3 || usbkVersion.minor != 0 || usbkVersion.micro != 7)
|
||||||
|
{
|
||||||
|
|
||||||
|
// Wrong USB driver version
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ByteVector readBuffer(32768, 0);
|
||||||
|
for (int i = 0; i <= 100; i++)
|
||||||
|
{
|
||||||
|
int bytesRead = 0;
|
||||||
|
if ((bytesRead = rcmDev.read(&readBuffer[0], readBuffer.size())) > 0)
|
||||||
|
{
|
||||||
|
static const char READY_INDICATOR[] = "READY.\n";
|
||||||
|
if (bytesRead == array_countof(READY_INDICATOR) - 1 && memcmp(&readBuffer[0], READY_INDICATOR, array_countof(READY_INDICATOR) - 1) == 0)
|
||||||
|
{
|
||||||
|
int bytesSent = rcmDev.write((const u8*)"RECV", strlen("RECV"));
|
||||||
|
if (bytesSent == strlen("RECV"))
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int TegraRcmSmash::RcmStatus()
|
int TegraRcmSmash::RcmStatus()
|
||||||
{
|
{
|
||||||
|
@ -295,7 +387,6 @@ int TegraRcmSmash::RcmStatus()
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
|
@ -18,5 +18,7 @@ public:
|
||||||
TegraRcmSmash();
|
TegraRcmSmash();
|
||||||
~TegraRcmSmash();
|
~TegraRcmSmash();
|
||||||
static int RcmStatus();
|
static int RcmStatus();
|
||||||
|
static int Test();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
BIN
TegraRcmGUI/res/TegraRcmGUI.ico
Normal file
After Width: | Height: | Size: 23 KiB |
Before Width: | Height: | Size: 179 KiB After Width: | Height: | Size: 179 KiB |
BIN
TegraRcmGUI/res/add.ico
Normal file
After Width: | Height: | Size: 2.4 KiB |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
BIN
TegraRcmGUI/res/browse.ico
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
TegraRcmGUI/res/bunch-of-keys.ico
Normal file
After Width: | Height: | Size: 17 KiB |
BIN
TegraRcmGUI/res/delete.ico
Normal file
After Width: | Height: | Size: 2.4 KiB |
Before Width: | Height: | Size: 84 KiB After Width: | Height: | Size: 82 KiB |
BIN
TegraRcmGUI/res/driver_ko_2.bmp
Normal file
After Width: | Height: | Size: 30 KiB |
Before Width: | Height: | Size: 84 KiB After Width: | Height: | Size: 82 KiB |
BIN
TegraRcmGUI/res/error_2.bmp
Normal file
After Width: | Height: | Size: 30 KiB |
BIN
TegraRcmGUI/res/icon1.ico
Normal file
After Width: | Height: | Size: 44 KiB |
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 28 KiB |
BIN
TegraRcmGUI/res/init_logo_2.bmp
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
TegraRcmGUI/res/linux_icon.ico
Normal file
After Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 84 KiB After Width: | Height: | Size: 82 KiB |
BIN
TegraRcmGUI/res/loaded_2.bmp
Normal file
After Width: | Height: | Size: 30 KiB |
Before Width: | Height: | Size: 84 KiB After Width: | Height: | Size: 82 KiB |
BIN
TegraRcmGUI/res/loading_2.bmp
Normal file
After Width: | Height: | Size: 30 KiB |
Before Width: | Height: | Size: 84 KiB After Width: | Height: | Size: 82 KiB |
BIN
TegraRcmGUI/res/rcm_detected_2.bmp
Normal file
After Width: | Height: | Size: 30 KiB |
Before Width: | Height: | Size: 84 KiB After Width: | Height: | Size: 82 KiB |
BIN
TegraRcmGUI/res/rcm_undetected_2.bmp
Normal file
After Width: | Height: | Size: 30 KiB |
BIN
TegraRcmGUI/res/status.ico
Normal file
After Width: | Height: | Size: 4.2 KiB |
BIN
TegraRcmGUI/res/tray_ico_connected.ico
Normal file
After Width: | Height: | Size: 25 KiB |
BIN
TegraRcmGUI/res/tray_ico_not_connected.ico
Normal file
After Width: | Height: | Size: 24 KiB |
BIN
TegraRcmGUI/res/usb_icon.ico
Normal file
After Width: | Height: | Size: 21 KiB |
BIN
TegraRcmGUI/resource.h
Normal file
3
TegraRcmGUI/shofel2/imx_usb.bat
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
cd shofel2
|
||||||
|
imx_usb.exe -c conf/
|
||||||
|
ping 127.0.0.1 -n 6 > nul
|
BIN
TegraRcmGUI/tools/biskeydump_usb.bin
Normal file
BIN
TegraRcmGUI/tools/memloader/memloader_usb.bin
Normal file
BIN
TegraRcmGUI/tools/memloader/u-boot.elf
Normal file
14
TegraRcmGUI/tools/memloader/ums_boot0.ini
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
[load:PH_0]
|
||||||
|
if=/u-boot.elf
|
||||||
|
skip=0x00010000
|
||||||
|
count=0x0006e13f
|
||||||
|
dst=0x80110000
|
||||||
|
|
||||||
|
[load:script]
|
||||||
|
if=ums_emmc_boot0.scr.img
|
||||||
|
dst=0x80100000
|
||||||
|
|
||||||
|
[boot:ENTRY]
|
||||||
|
pc=0x80110000
|
||||||
|
maxMemoryFreq=200
|
||||||
|
pwroffHoldTime=4
|
14
TegraRcmGUI/tools/memloader/ums_boot1.ini
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
[load:PH_0]
|
||||||
|
if=/u-boot.elf
|
||||||
|
skip=0x00010000
|
||||||
|
count=0x0006e13f
|
||||||
|
dst=0x80110000
|
||||||
|
|
||||||
|
[load:script]
|
||||||
|
if=ums_emmc_boot1.scr.img
|
||||||
|
dst=0x80100000
|
||||||
|
|
||||||
|
[boot:ENTRY]
|
||||||
|
pc=0x80110000
|
||||||
|
maxMemoryFreq=-1600
|
||||||
|
pwroffHoldTime=4
|
13
TegraRcmGUI/tools/memloader/ums_emmc.ini
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
[load:PH_0]
|
||||||
|
if=/u-boot.elf
|
||||||
|
skip=0x00010000
|
||||||
|
count=0x0006e13f
|
||||||
|
dst=0x80110000
|
||||||
|
|
||||||
|
[load:script]
|
||||||
|
if=ums_emmc.scr.img
|
||||||
|
dst=0x80100000
|
||||||
|
|
||||||
|
[boot:ENTRY]
|
||||||
|
pc=0x80110000
|
||||||
|
pwroffHoldTime=4
|
1
TegraRcmGUI/tools/memloader/ums_emmc.scr
Normal file
|
@ -0,0 +1 @@
|
||||||
|
ums 1 mmc 0.0
|
BIN
TegraRcmGUI/tools/memloader/ums_emmc.scr.img
Normal file
1
TegraRcmGUI/tools/memloader/ums_emmc_boot0.scr
Normal file
|
@ -0,0 +1 @@
|
||||||
|
ums 1 mmc 0.1
|
BIN
TegraRcmGUI/tools/memloader/ums_emmc_boot0.scr.img
Normal file
1
TegraRcmGUI/tools/memloader/ums_emmc_boot1.scr
Normal file
|
@ -0,0 +1 @@
|
||||||
|
ums 1 mmc 0.2
|
BIN
TegraRcmGUI/tools/memloader/ums_emmc_boot1.scr.img
Normal file
13
TegraRcmGUI/tools/memloader/ums_sd.ini
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
[load:PH_0]
|
||||||
|
if=/u-boot.elf
|
||||||
|
skip=0x00010000
|
||||||
|
count=0x0007c1bf
|
||||||
|
dst=0x80110000
|
||||||
|
|
||||||
|
[load:script]
|
||||||
|
if=ums_sd.scr.img
|
||||||
|
dst=0x80100000
|
||||||
|
|
||||||
|
[boot:ENTRY]
|
||||||
|
pc=0x80110000
|
||||||
|
pwroffHoldTime=4
|
2
TegraRcmGUI/tools/memloader/ums_sd.scr
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
ums 1 mmc 1
|
||||||
|
|
BIN
TegraRcmGUI/tools/memloader/ums_sd.scr.img
Normal file
1
TegraRcmGUI/tools/src/biskeydump
Submodule
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit ed57dd5032840ab7084bcd76e8b9408dd7245958
|
|
@ -1,703 +0,0 @@
|
||||||
|
|
||||||
// TegraRcmGUIDlg.cpp : implementation file
|
|
||||||
//
|
|
||||||
|
|
||||||
#include "stdafx.h"
|
|
||||||
#include "afxdialogex.h"
|
|
||||||
#include "TegraRcmGUI.h"
|
|
||||||
#include "TegraRcmGUIDlg.h"
|
|
||||||
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
#ifdef _DEBUG
|
|
||||||
#define new DEBUG_NEW
|
|
||||||
#endif
|
|
||||||
|
|
||||||
TCHAR* PAYLOAD_FILE;
|
|
||||||
int RCM_STATUS = -10;
|
|
||||||
BOOL WAITING_RECONNECT = FALSE;
|
|
||||||
BOOL AUTOINJECT_CURR = FALSE;
|
|
||||||
BOOL PREVENT_AUTOINJECT = TRUE;
|
|
||||||
BOOL DELAY_AUTOINJECT = FALSE;
|
|
||||||
BOOL ASK_FOR_DRIVER = FALSE;
|
|
||||||
BOOL PAUSE_LKP_DEVICE = FALSE;
|
|
||||||
|
|
||||||
CString csPath;
|
|
||||||
|
|
||||||
// CTegraRcmGUIDlg dialog
|
|
||||||
|
|
||||||
CTegraRcmGUIDlg::CTegraRcmGUIDlg(CWnd* pParent /*=NULL*/)
|
|
||||||
: CDialog(IDD_TEGRARCMGUI_DIALOG, pParent)
|
|
||||||
, STATUS(0)
|
|
||||||
{
|
|
||||||
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CTegraRcmGUIDlg::DoDataExchange(CDataExchange* pDX)
|
|
||||||
{
|
|
||||||
CDialog::DoDataExchange(pDX);
|
|
||||||
DDX_Control(pDX, RCM_PIC_1, RCM_BITMAP1);
|
|
||||||
DDX_Control(pDX, RCM_PIC_2, RCM_BITMAP2);
|
|
||||||
DDX_Control(pDX, RCM_PIC_3, RCM_BITMAP3);
|
|
||||||
DDX_Control(pDX, RCM_PIC_4, RCM_BITMAP0);
|
|
||||||
DDX_Control(pDX, RCM_PIC_5, RCM_BITMAP4);
|
|
||||||
DDX_Control(pDX, RCM_PIC_6, RCM_BITMAP5);
|
|
||||||
DDX_Control(pDX, RCM_PIC_7, RCM_BITMAP6);
|
|
||||||
DDX_Control(pDX, PAYLOAD_PATH, m_EditBrowse);
|
|
||||||
}
|
|
||||||
|
|
||||||
BEGIN_MESSAGE_MAP(CTegraRcmGUIDlg, CDialog)
|
|
||||||
ON_WM_CTLCOLOR()
|
|
||||||
ON_WM_TIMER()
|
|
||||||
ON_WM_SYSCOMMAND()
|
|
||||||
ON_WM_PAINT()
|
|
||||||
ON_WM_QUERYDRAGICON()
|
|
||||||
ON_EN_CHANGE(PAYLOAD_PATH, &CTegraRcmGUIDlg::OnEnChangePath)
|
|
||||||
ON_BN_CLICKED(IDC_INJECT, &CTegraRcmGUIDlg::InjectPayload)
|
|
||||||
ON_BN_CLICKED(IDC_SHOFEL2, &CTegraRcmGUIDlg::OnBnClickedShofel2)
|
|
||||||
ON_BN_CLICKED(IDC_MOUNT_SD, &CTegraRcmGUIDlg::OnBnClickedMountSd)
|
|
||||||
END_MESSAGE_MAP()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
HBRUSH CTegraRcmGUIDlg::OnCtlColor(CDC* pDC, CWnd *pWnd, UINT nCtlColor)
|
|
||||||
{
|
|
||||||
switch (nCtlColor)
|
|
||||||
{
|
|
||||||
case CTLCOLOR_STATIC:
|
|
||||||
if (GetDlgItem(IDC_RAJKOSTO)->GetSafeHwnd() == pWnd->GetSafeHwnd() || GetDlgItem(SEPARATOR)->GetSafeHwnd() == pWnd->GetSafeHwnd())
|
|
||||||
{
|
|
||||||
pDC->SetTextColor(RGB(192, 192, 192));
|
|
||||||
pDC->SetBkMode(TRANSPARENT);
|
|
||||||
return (HBRUSH)GetStockObject(NULL_BRUSH);
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
return CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// CTegraRcmGUIDlg message handlers
|
|
||||||
|
|
||||||
BOOL CTegraRcmGUIDlg::OnInitDialog()
|
|
||||||
{
|
|
||||||
CDialog::OnInitDialog();
|
|
||||||
|
|
||||||
// Accessibility
|
|
||||||
EnableActiveAccessibility();
|
|
||||||
|
|
||||||
// Get current directory
|
|
||||||
TCHAR szPath[_MAX_PATH];
|
|
||||||
VERIFY(::GetModuleFileName(AfxGetApp()->m_hInstance, szPath, _MAX_PATH));
|
|
||||||
CString csPathf(szPath);
|
|
||||||
int nIndex = csPathf.ReverseFind(_T('\\'));
|
|
||||||
if (nIndex > 0) csPath = csPathf.Left(nIndex);
|
|
||||||
else csPath.Empty();
|
|
||||||
|
|
||||||
// Initialize bitmap
|
|
||||||
RCM_BITMAP0.SetBitmap(INIT_LOGO);
|
|
||||||
RCM_BITMAP1.SetBitmap(RCM_NOT_DETECTED);
|
|
||||||
RCM_BITMAP2.SetBitmap(DRIVER_KO);
|
|
||||||
RCM_BITMAP3.SetBitmap(RCM_DETECTED);
|
|
||||||
RCM_BITMAP4.SetBitmap(LOADING);
|
|
||||||
RCM_BITMAP5.SetBitmap(LOADED);
|
|
||||||
RCM_BITMAP6.SetBitmap(LOAD_ERROR);
|
|
||||||
|
|
||||||
BitmapDisplay(INIT_LOGO);
|
|
||||||
|
|
||||||
// Check for APX driver at startup
|
|
||||||
//BOOL isDriverInstalled = LookForDriver();
|
|
||||||
//if (!isDriverInstalled) InstallDriver();
|
|
||||||
|
|
||||||
// Read & apply presets
|
|
||||||
string value = GetPreset("AUTO_INJECT");
|
|
||||||
if (value == "TRUE")
|
|
||||||
{
|
|
||||||
AUTOINJECT_CURR = TRUE;
|
|
||||||
CMFCButton*checkbox = (CMFCButton*)GetDlgItem(AUTO_INJECT);
|
|
||||||
checkbox->SetCheck(BST_CHECKED);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
string pfile = GetPreset("PAYLOAD_FILE");
|
|
||||||
CString file(pfile.c_str());
|
|
||||||
this->GetDlgItem(PAYLOAD_PATH)->SetWindowTextW(file);
|
|
||||||
//PREVENT_AUTOINJECT = TRUE;
|
|
||||||
|
|
||||||
// Menu
|
|
||||||
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
|
|
||||||
ASSERT(IDM_ABOUTBOX < 0xF000);
|
|
||||||
CMenu* pSysMenu = GetSystemMenu(FALSE);
|
|
||||||
if (pSysMenu != NULL)
|
|
||||||
{
|
|
||||||
BOOL bNameValid;
|
|
||||||
CString strAboutMenu;
|
|
||||||
bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX);
|
|
||||||
ASSERT(bNameValid);
|
|
||||||
if (!strAboutMenu.IsEmpty())
|
|
||||||
{
|
|
||||||
pSysMenu->AppendMenu(MF_SEPARATOR);
|
|
||||||
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set icons
|
|
||||||
SetIcon(m_hIcon, TRUE); // Set big icon
|
|
||||||
SetIcon(m_hIcon, FALSE); // Set small icon
|
|
||||||
|
|
||||||
// Start timer to check RCM status every second
|
|
||||||
CTegraRcmGUIDlg::StartTimer();
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CTegraRcmGUIDlg::OnSysCommand(UINT nID, LPARAM lParam)
|
|
||||||
{
|
|
||||||
CDialog::OnSysCommand(nID, lParam);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void CTegraRcmGUIDlg::OnPaint()
|
|
||||||
{
|
|
||||||
|
|
||||||
if (IsIconic())
|
|
||||||
{
|
|
||||||
CPaintDC dc(this); // device context for painting
|
|
||||||
|
|
||||||
SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
|
|
||||||
|
|
||||||
// Center icon in client rectangle
|
|
||||||
int cxIcon = GetSystemMetrics(SM_CXICON);
|
|
||||||
int cyIcon = GetSystemMetrics(SM_CYICON);
|
|
||||||
CRect rect;
|
|
||||||
GetClientRect(&rect);
|
|
||||||
int x = (rect.Width() - cxIcon + 1) / 2;
|
|
||||||
int y = (rect.Height() - cyIcon + 1) / 2;
|
|
||||||
|
|
||||||
// Draw the icon
|
|
||||||
dc.DrawIcon(x, y, m_hIcon);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
CDialog::OnPaint();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// The system calls this function to obtain the cursor to display while the user drags
|
|
||||||
// the minimized window.
|
|
||||||
HCURSOR CTegraRcmGUIDlg::OnQueryDragIcon()
|
|
||||||
{
|
|
||||||
return static_cast<HCURSOR>(m_hIcon);
|
|
||||||
}
|
|
||||||
const UINT ID_TIMER_MINUTE = 0x1001;
|
|
||||||
const UINT ID_TIMER_SECONDS = 0x1000;
|
|
||||||
// Start the timers.
|
|
||||||
void CTegraRcmGUIDlg::StartTimer()
|
|
||||||
{
|
|
||||||
// Set timer for Minutes.
|
|
||||||
//SetTimer(ID_TIMER_MINUTE, 60 * 1000, 0);
|
|
||||||
// Set timer for Seconds.
|
|
||||||
SetTimer(ID_TIMER_SECONDS, 1000, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Stop the timers.
|
|
||||||
void CTegraRcmGUIDlg::StopTimer()
|
|
||||||
{
|
|
||||||
// Stop both timers.
|
|
||||||
KillTimer(ID_TIMER_MINUTE);
|
|
||||||
KillTimer(ID_TIMER_SECONDS);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CTegraRcmGUIDlg::BitmapDisplay(int IMG)
|
|
||||||
{
|
|
||||||
// Init & bitmap pointers
|
|
||||||
CStatic*pRcm_not_detected = (CStatic*)GetDlgItem(RCM_PIC_1);
|
|
||||||
CStatic*pDriverKO = (CStatic*)GetDlgItem(RCM_PIC_2);
|
|
||||||
CStatic*pRcm_detected = (CStatic*)GetDlgItem(RCM_PIC_3);
|
|
||||||
CStatic*pInitLogo = (CStatic*)GetDlgItem(RCM_PIC_4);
|
|
||||||
CStatic*pLoading = (CStatic*)GetDlgItem(RCM_PIC_5);
|
|
||||||
CStatic*pLoaded = (CStatic*)GetDlgItem(RCM_PIC_6);
|
|
||||||
CStatic*pError = (CStatic*)GetDlgItem(RCM_PIC_7);
|
|
||||||
|
|
||||||
pRcm_not_detected->ShowWindow(SW_HIDE);
|
|
||||||
pDriverKO->ShowWindow(SW_HIDE);
|
|
||||||
pRcm_detected->ShowWindow(SW_HIDE);
|
|
||||||
pInitLogo->ShowWindow(SW_HIDE);
|
|
||||||
pLoading->ShowWindow(SW_HIDE);
|
|
||||||
pLoaded->ShowWindow(SW_HIDE);
|
|
||||||
pError->ShowWindow(SW_HIDE);
|
|
||||||
|
|
||||||
switch (IMG)
|
|
||||||
{
|
|
||||||
case INIT_LOGO:
|
|
||||||
pInitLogo->ShowWindow(SW_SHOW);
|
|
||||||
break;
|
|
||||||
case RCM_NOT_DETECTED:
|
|
||||||
pRcm_not_detected->ShowWindow(SW_SHOW);
|
|
||||||
break;
|
|
||||||
case DRIVER_KO:
|
|
||||||
pDriverKO->ShowWindow(SW_SHOW);
|
|
||||||
break;
|
|
||||||
case RCM_DETECTED:
|
|
||||||
pRcm_detected->ShowWindow(SW_SHOW);
|
|
||||||
break;
|
|
||||||
case LOADING:
|
|
||||||
pLoading->ShowWindow(SW_SHOW);
|
|
||||||
UpdateWindow();
|
|
||||||
break;
|
|
||||||
case LOADED:
|
|
||||||
pLoaded->ShowWindow(SW_SHOW);
|
|
||||||
break;
|
|
||||||
case LOAD_ERROR:
|
|
||||||
pError->ShowWindow(SW_SHOW);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Timer Handler.
|
|
||||||
void CTegraRcmGUIDlg::OnTimer(UINT nIDEvent)
|
|
||||||
{
|
|
||||||
// Each second
|
|
||||||
if (nIDEvent == ID_TIMER_SECONDS)
|
|
||||||
{
|
|
||||||
// Exit when PAUSE_LKP_DEVICE flag is TRUE
|
|
||||||
if (PAUSE_LKP_DEVICE) return;
|
|
||||||
|
|
||||||
// Get Auto inject checkbox value (checked, unchecked)
|
|
||||||
CButton *m_ctlCheck = (CButton*)GetDlgItem(AUTO_INJECT);
|
|
||||||
BOOL IsCheckChecked = (m_ctlCheck->GetCheck() == 1) ? true : false;
|
|
||||||
|
|
||||||
if (AUTOINJECT_CURR != IsCheckChecked)
|
|
||||||
{
|
|
||||||
// Auto inject option enabled
|
|
||||||
if (IsCheckChecked)
|
|
||||||
{
|
|
||||||
SetPreset("AUTO_INJECT", "TRUE");
|
|
||||||
DELAY_AUTOINJECT = TRUE;
|
|
||||||
}
|
|
||||||
// Auto inject option disabled
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SetPreset("AUTO_INJECT", "FALSE");
|
|
||||||
DELAY_AUTOINJECT = FALSE;
|
|
||||||
}
|
|
||||||
// Save current checkbox value
|
|
||||||
AUTOINJECT_CURR = IsCheckChecked;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get RCM device Status
|
|
||||||
// This feature has been developped by Rajkosto (copied from TegraRcmSmash)
|
|
||||||
TegraRcmSmash device;
|
|
||||||
int rc = device.RcmStatus();
|
|
||||||
|
|
||||||
std::string s = "";
|
|
||||||
|
|
||||||
// RCM Status = "RCM detected"
|
|
||||||
if (rc >= 0)
|
|
||||||
{
|
|
||||||
this->GetDlgItem(IDC_INJECT)->EnableWindow(TRUE);
|
|
||||||
this->GetDlgItem(IDC_SHOFEL2)->EnableWindow(TRUE);
|
|
||||||
this->GetDlgItem(IDC_MOUNT_SD)->EnableWindow(TRUE);
|
|
||||||
|
|
||||||
}
|
|
||||||
// RCM Status = "USB Driver KO"
|
|
||||||
else if (rc > -5)
|
|
||||||
{
|
|
||||||
this->GetDlgItem(IDC_INJECT)->EnableWindow(FALSE);
|
|
||||||
this->GetDlgItem(IDC_SHOFEL2)->EnableWindow(FALSE);
|
|
||||||
this->GetDlgItem(IDC_MOUNT_SD)->EnableWindow(FALSE);
|
|
||||||
s = "lbusbK driver is needed !";
|
|
||||||
}
|
|
||||||
// RCM Status = "RCM not detected"
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this->GetDlgItem(IDC_INJECT)->EnableWindow(FALSE);
|
|
||||||
this->GetDlgItem(IDC_SHOFEL2)->EnableWindow(FALSE);
|
|
||||||
this->GetDlgItem(IDC_MOUNT_SD)->EnableWindow(FALSE);
|
|
||||||
s = "Waiting for Switch in RCM mode.";
|
|
||||||
|
|
||||||
// Delay Auto inject if needed
|
|
||||||
if (AUTOINJECT_CURR) DELAY_AUTOINJECT = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// On change RCM status
|
|
||||||
if (rc != RCM_STATUS)
|
|
||||||
{
|
|
||||||
RCM_STATUS = rc;
|
|
||||||
CStatic*pCtrl0 = (CStatic*)GetDlgItem(RCM_PIC_4);
|
|
||||||
pCtrl0->ShowWindow(SW_HIDE);
|
|
||||||
|
|
||||||
// Status changed to "RCM Detected"
|
|
||||||
if (rc == 0)
|
|
||||||
{
|
|
||||||
BitmapDisplay(RCM_DETECTED);
|
|
||||||
|
|
||||||
CString file;
|
|
||||||
this->GetDlgItem(PAYLOAD_PATH)->GetWindowTextW(file);
|
|
||||||
|
|
||||||
// Trigger auto inject if payload injection scheduled
|
|
||||||
if (DELAY_AUTOINJECT && file.GetLength() > 0)
|
|
||||||
{
|
|
||||||
InjectPayload();
|
|
||||||
DELAY_AUTOINJECT = FALSE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SetDlgItemText(INFO_LABEL, TEXT("\nSelect a payload :"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Status changed to "RCM not detected" or "USB driver KO"
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Ask for driver install
|
|
||||||
if (rc > -5)
|
|
||||||
{
|
|
||||||
BitmapDisplay(DRIVER_KO);
|
|
||||||
InstallDriver();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
BitmapDisplay(RCM_NOT_DETECTED);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Status changed to "RCM not detected" -> Disable WAITING_RECONNECT flag
|
|
||||||
if (rc <= -5) WAITING_RECONNECT = FALSE;
|
|
||||||
}
|
|
||||||
RCM_STATUS = rc;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// On change payload path
|
|
||||||
void CTegraRcmGUIDlg::OnEnChangePath()
|
|
||||||
{
|
|
||||||
CString file;
|
|
||||||
this->GetDlgItem(PAYLOAD_PATH)->GetWindowTextW(file);
|
|
||||||
PAYLOAD_FILE = _tcsdup(file);
|
|
||||||
|
|
||||||
if (!PREVENT_AUTOINJECT)
|
|
||||||
{
|
|
||||||
// Save payload path
|
|
||||||
CT2CA pszConvertedAnsiString(file);
|
|
||||||
std::string file_c(pszConvertedAnsiString);
|
|
||||||
SetPreset("PAYLOAD_FILE", file_c);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string s = "\nSelect a payload :";
|
|
||||||
|
|
||||||
CButton *m_ctlCheck = (CButton*)GetDlgItem(AUTO_INJECT);
|
|
||||||
BOOL IsCheckChecked = (m_ctlCheck->GetCheck() == 1) ? true : false;
|
|
||||||
// If Auto inject option enabled
|
|
||||||
if (IsCheckChecked && !PREVENT_AUTOINJECT)
|
|
||||||
{
|
|
||||||
// Delay auto inject if RCM not detected
|
|
||||||
if (RCM_STATUS != 0)
|
|
||||||
{
|
|
||||||
DELAY_AUTOINJECT = TRUE;
|
|
||||||
s = "Payload injection scheduled.\nWaiting for RCM mode.";
|
|
||||||
}
|
|
||||||
// Inject payload if RCM detected
|
|
||||||
else InjectPayload();
|
|
||||||
}
|
|
||||||
PREVENT_AUTOINJECT = FALSE;
|
|
||||||
CA2T wt(s.c_str());
|
|
||||||
SetDlgItemText(INFO_LABEL, wt);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// User payload injection
|
|
||||||
void CTegraRcmGUIDlg::InjectPayload()
|
|
||||||
{
|
|
||||||
string s;
|
|
||||||
if (PAYLOAD_FILE == nullptr) {
|
|
||||||
BitmapDisplay(LOAD_ERROR);
|
|
||||||
SetDlgItemText(INFO_LABEL, TEXT("\nNo file selected !"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
BitmapDisplay(LOADING);
|
|
||||||
int rc = Smasher(PAYLOAD_FILE);
|
|
||||||
if (rc >= 0)
|
|
||||||
{
|
|
||||||
BitmapDisplay(LOADED);
|
|
||||||
s = "\nPayload injected !";
|
|
||||||
WAITING_RECONNECT = TRUE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
BitmapDisplay(LOAD_ERROR);
|
|
||||||
s = "Error while injecting payload (RC=" + std::to_string(rc) + ")";
|
|
||||||
}
|
|
||||||
CA2T wt(s.c_str());
|
|
||||||
CTegraRcmGUIDlg::SetDlgItemText(INFO_LABEL, wt);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CTegraRcmGUIDlg::OnBnClickedShofel2()
|
|
||||||
{
|
|
||||||
TCHAR *exe_dir = GetAbsolutePath(TEXT(""), CSIDL_APPDATA);
|
|
||||||
|
|
||||||
string s;
|
|
||||||
TCHAR *COREBOOT_FILE = GetAbsolutePath(TEXT("shofel2\\coreboot\\coreboot.rom"), CSIDL_APPDATA);
|
|
||||||
TCHAR *PAYLOAD = GetAbsolutePath(TEXT("shofel2\\coreboot\\cbfs.bin"), CSIDL_APPDATA);
|
|
||||||
CString COREBOOT_FILE2 = COREBOOT_FILE;
|
|
||||||
CString COREBOOT = _T("CBFS+") + COREBOOT_FILE2;
|
|
||||||
|
|
||||||
std::ifstream infile(COREBOOT_FILE);
|
|
||||||
BOOL coreboot_exists = infile.good();
|
|
||||||
std::ifstream infile2(PAYLOAD);
|
|
||||||
BOOL payload_exists = infile2.good();
|
|
||||||
|
|
||||||
if (!coreboot_exists || !payload_exists) {
|
|
||||||
SetDlgItemText(INFO_LABEL, TEXT("Linux coreboot not found in \\shofel2 dir"));
|
|
||||||
CString message = _T("Kernel not found in shofel2 directory. Do you want to automatically download arch linux kernel from SoulCipher repo ?");
|
|
||||||
const int result = MessageBox(message, _T("Kernel not found"), MB_YESNOCANCEL | MB_ICONQUESTION);
|
|
||||||
if (result == IDYES)
|
|
||||||
{
|
|
||||||
PROCESS_INFORMATION pif;
|
|
||||||
STARTUPINFO si;
|
|
||||||
ZeroMemory(&si, sizeof(si));
|
|
||||||
si.cb = sizeof(si);
|
|
||||||
TCHAR *download_script = GetAbsolutePath(TEXT("shofel2\\download.bat"), CSIDL_APPDATA);
|
|
||||||
BOOL bRet = CreateProcess(download_script, NULL, NULL, NULL, FALSE, 0, NULL, exe_dir, &si, &pif);
|
|
||||||
}
|
|
||||||
return; // TO-DO : Remove return for coreboot injection after download
|
|
||||||
}
|
|
||||||
BitmapDisplay(LOADING);
|
|
||||||
SetDlgItemText(INFO_LABEL, TEXT("Loading coreboot. Please wait."));
|
|
||||||
|
|
||||||
//int rc = device.SmashMain(5, args);
|
|
||||||
TCHAR cmd[MAX_PATH] = TEXT("--relocator= \"");
|
|
||||||
lstrcat(cmd, _tcsdup(PAYLOAD));
|
|
||||||
lstrcat(cmd, TEXT("\" \"CBFS:"));
|
|
||||||
lstrcat(cmd, _tcsdup(COREBOOT_FILE));
|
|
||||||
lstrcat(cmd, TEXT("\""));
|
|
||||||
int rc = Smasher(cmd);
|
|
||||||
|
|
||||||
if (rc >= 0 || rc < -7)
|
|
||||||
{
|
|
||||||
SetDlgItemText(INFO_LABEL, TEXT("Coreboot injected. Waiting 5s for device..."));
|
|
||||||
Sleep(5000);
|
|
||||||
|
|
||||||
PROCESS_INFORMATION pif;
|
|
||||||
STARTUPINFO si;
|
|
||||||
ZeroMemory(&si, sizeof(si));
|
|
||||||
si.cb = sizeof(si);
|
|
||||||
TCHAR *imx_script = GetAbsolutePath(TEXT("shofel2\\imx_usb.bat"), CSIDL_APPDATA);
|
|
||||||
SetDlgItemText(INFO_LABEL, TEXT("Loading coreboot... Please wait."));
|
|
||||||
BOOL ret = CreateProcess(imx_script, NULL, NULL, NULL, FALSE, CREATE_NO_WINDOW, NULL, exe_dir, &si, &pif);
|
|
||||||
int rc = -50;
|
|
||||||
if (NULL != ret)
|
|
||||||
{
|
|
||||||
WaitForSingleObject(pif.hProcess, INFINITE);
|
|
||||||
DWORD exit_code;
|
|
||||||
if (FALSE != GetExitCodeProcess(pif.hProcess, &exit_code))
|
|
||||||
{
|
|
||||||
if (STILL_ACTIVE != exit_code) rc = exit_code;
|
|
||||||
}
|
|
||||||
else rc = -51;
|
|
||||||
CloseHandle(pif.hProcess);
|
|
||||||
CloseHandle(pif.hThread);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rc == 0)
|
|
||||||
{
|
|
||||||
BitmapDisplay(LOADED);
|
|
||||||
s = "\nCoreboot loaded !";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
BitmapDisplay(LOAD_ERROR);
|
|
||||||
s = "Error while loading imx_usb.exe";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
s = "Error while injecting payload. (RC=" + std::to_string(rc) + ")";
|
|
||||||
}
|
|
||||||
CA2T wt2(s.c_str());
|
|
||||||
SetDlgItemText(INFO_LABEL, wt2);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
string CTegraRcmGUIDlg::GetPreset(string param)
|
|
||||||
{
|
|
||||||
TCHAR *rfile = GetAbsolutePath(TEXT("presets.conf"), CSIDL_APPDATA);
|
|
||||||
CT2A rfile_c(rfile, CP_UTF8);
|
|
||||||
TRACE(_T("UTF8: %S\n"), rfile_c.m_psz);
|
|
||||||
|
|
||||||
ifstream readFile(rfile_c);
|
|
||||||
string readout;
|
|
||||||
string search = param + "=";
|
|
||||||
std::string value = "";
|
|
||||||
if (readFile.is_open())
|
|
||||||
{
|
|
||||||
while (getline(readFile, readout)) {
|
|
||||||
if (readout.find(search) != std::string::npos) {
|
|
||||||
std::string delimiter = "=";
|
|
||||||
value = readout.substr(readout.find(delimiter) + 1, readout.length() + 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
readFile.close();
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CTegraRcmGUIDlg::SetPreset(string param, string value)
|
|
||||||
{
|
|
||||||
TCHAR *rfile = GetAbsolutePath(TEXT("presets.conf"), CSIDL_APPDATA);
|
|
||||||
TCHAR *wfile = GetAbsolutePath(TEXT("presets.conf.tmp"), CSIDL_APPDATA);
|
|
||||||
CT2A rfile_c(rfile, CP_UTF8);
|
|
||||||
TRACE(_T("UTF8: %S\n"), rfile_c.m_psz);
|
|
||||||
CT2A wfile_c(wfile, CP_UTF8);
|
|
||||||
TRACE(_T("UTF8: %S\n"), wfile_c.m_psz);
|
|
||||||
|
|
||||||
// Replace or create preset in file
|
|
||||||
ofstream outFile(wfile_c);
|
|
||||||
ifstream readFile(rfile_c);
|
|
||||||
string readout;
|
|
||||||
string search = param + "=";
|
|
||||||
string replace = "\n" + search + value + "\n";
|
|
||||||
BOOL found = FALSE;
|
|
||||||
while (getline(readFile, readout)) {
|
|
||||||
if (readout.find(search) != std::string::npos) {
|
|
||||||
outFile << replace;
|
|
||||||
found = TRUE;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
outFile << readout;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!found) {
|
|
||||||
outFile << replace;
|
|
||||||
}
|
|
||||||
outFile.close();
|
|
||||||
readFile.close();
|
|
||||||
remove(rfile_c);
|
|
||||||
rename(wfile_c, rfile_c);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void CTegraRcmGUIDlg::InstallDriver()
|
|
||||||
{
|
|
||||||
CString message = _T("APX device driver is missing. Do you want to install it now ?");
|
|
||||||
const int result = MessageBox(message, _T("APX driver not found !"), MB_YESNOCANCEL | MB_ICONQUESTION);
|
|
||||||
if (result == IDYES)
|
|
||||||
{
|
|
||||||
SHELLEXECUTEINFO shExInfo = { 0 };
|
|
||||||
shExInfo.cbSize = sizeof(shExInfo);
|
|
||||||
shExInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
|
|
||||||
shExInfo.hwnd = 0;
|
|
||||||
shExInfo.lpVerb = _T("runas");
|
|
||||||
CString exe_file = csPath + _T("\\apx_driver\\InstallDriver.exe");
|
|
||||||
shExInfo.lpFile = exe_file;
|
|
||||||
shExInfo.lpDirectory = 0;
|
|
||||||
shExInfo.nShow = SW_SHOW;
|
|
||||||
shExInfo.hInstApp = 0;
|
|
||||||
|
|
||||||
if (ShellExecuteEx(&shExInfo))
|
|
||||||
{
|
|
||||||
CloseHandle(shExInfo.hProcess);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ASK_FOR_DRIVER = TRUE;
|
|
||||||
}
|
|
||||||
typedef int(__cdecl *MYPROC)(LPWSTR);
|
|
||||||
|
|
||||||
|
|
||||||
BOOL CTegraRcmGUIDlg::LookForDriver()
|
|
||||||
{
|
|
||||||
TCHAR *system_dir = GetAbsolutePath(TEXT("libusbK.dll"), CSIDL_SYSTEM);
|
|
||||||
std::ifstream infile(system_dir);
|
|
||||||
BOOL file_exists = infile.good();
|
|
||||||
return file_exists;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void CTegraRcmGUIDlg::OnBnClickedMountSd()
|
|
||||||
{
|
|
||||||
BitmapDisplay(LOADING);
|
|
||||||
string s;
|
|
||||||
TCHAR args[] = TEXT("memloader\\memloader_usb.bin -r --dataini=memloader\\ums_sd.ini");
|
|
||||||
int rc = Smasher(args);
|
|
||||||
if (rc < 0)
|
|
||||||
{
|
|
||||||
|
|
||||||
BitmapDisplay(LOAD_ERROR);
|
|
||||||
s = "Error while loading payload (RC=" + std::to_string(rc) + ")";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
BitmapDisplay(LOADING);
|
|
||||||
s = "SD tool (by rajkosto) injected";
|
|
||||||
}
|
|
||||||
CA2T wt(s.c_str());
|
|
||||||
CTegraRcmGUIDlg::SetDlgItemText(INFO_LABEL, wt);
|
|
||||||
}
|
|
||||||
|
|
||||||
int CTegraRcmGUIDlg::Smasher(TCHAR args[])
|
|
||||||
{
|
|
||||||
if (WAITING_RECONNECT)
|
|
||||||
{
|
|
||||||
CString message = _T("Payload already injected. Are you sure you want to overwrite the stack again ?");
|
|
||||||
const int result = MessageBox(message, _T("WARNING !"), MB_YESNOCANCEL | MB_ICONQUESTION);
|
|
||||||
if (result != IDYES)
|
|
||||||
{
|
|
||||||
DELAY_AUTOINJECT = FALSE;
|
|
||||||
RCM_STATUS = -99;
|
|
||||||
return -99;
|
|
||||||
}
|
|
||||||
WAITING_RECONNECT = FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
SECURITY_ATTRIBUTES sa;
|
|
||||||
sa.nLength = sizeof(sa);
|
|
||||||
sa.lpSecurityDescriptor = NULL;
|
|
||||||
sa.bInheritHandle = TRUE;
|
|
||||||
PROCESS_INFORMATION pi;
|
|
||||||
STARTUPINFO si;
|
|
||||||
BOOL ret = FALSE;
|
|
||||||
DWORD flags = CREATE_NO_WINDOW;
|
|
||||||
ZeroMemory(&pi, sizeof(PROCESS_INFORMATION));
|
|
||||||
ZeroMemory(&si, sizeof(STARTUPINFO));
|
|
||||||
si.cb = sizeof(STARTUPINFO);
|
|
||||||
si.dwFlags |= STARTF_USESTDHANDLES;
|
|
||||||
si.hStdInput = NULL;
|
|
||||||
TCHAR cmd[MAX_PATH] = TEXT(".\\TegraRcmSmash.exe ");
|
|
||||||
lstrcat(cmd, args);
|
|
||||||
ret = CreateProcess(NULL, cmd, NULL, NULL, TRUE, flags, NULL, NULL, &si, &pi);
|
|
||||||
int rc = -50;
|
|
||||||
if (NULL != ret)
|
|
||||||
{
|
|
||||||
WaitForSingleObject(pi.hProcess, INFINITE);
|
|
||||||
DWORD exit_code;
|
|
||||||
if (FALSE != GetExitCodeProcess(pi.hProcess, &exit_code))
|
|
||||||
{
|
|
||||||
if (STILL_ACTIVE != exit_code)
|
|
||||||
{
|
|
||||||
rc = exit_code;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
rc = -51;
|
|
||||||
}
|
|
||||||
CloseHandle(pi.hProcess);
|
|
||||||
CloseHandle(pi.hThread);
|
|
||||||
}
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
TCHAR* CTegraRcmGUIDlg::GetAbsolutePath(TCHAR* relative_path, DWORD dwFlags)
|
|
||||||
{
|
|
||||||
TCHAR szPath[MAX_PATH];
|
|
||||||
if (SUCCEEDED(SHGetFolderPath(NULL, dwFlags, NULL, SHGFP_TYPE_CURRENT, szPath)))
|
|
||||||
{
|
|
||||||
if (dwFlags == CSIDL_APPDATA) PathAppend(szPath, _T("\\TegraRcmGUI"));
|
|
||||||
PathAppend(szPath, relative_path);
|
|
||||||
return _tcsdup(szPath);
|
|
||||||
}
|
|
||||||
return _T("");
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,73 +0,0 @@
|
||||||
|
|
||||||
// TegraRcmGUIDlg.h : header file
|
|
||||||
//
|
|
||||||
#pragma once
|
|
||||||
#include "res/BitmapPicture.h"
|
|
||||||
#include <string>
|
|
||||||
#include "TegraRcmSmash.h"
|
|
||||||
#include "res/BitmapPicture.h"
|
|
||||||
#include <windows.h>
|
|
||||||
#include <string>
|
|
||||||
#include <thread>
|
|
||||||
#include <iostream>
|
|
||||||
#include <sstream>
|
|
||||||
#include <fstream>
|
|
||||||
#include <iostream>
|
|
||||||
#include <cstdio>
|
|
||||||
#include <memory>
|
|
||||||
#include <stdexcept>
|
|
||||||
#include <array>
|
|
||||||
|
|
||||||
|
|
||||||
// CTegraRcmGUIDlg dialog
|
|
||||||
class CTegraRcmGUIDlg : public CDialog
|
|
||||||
{
|
|
||||||
// Construction
|
|
||||||
public:
|
|
||||||
CTegraRcmGUIDlg(CWnd* pParent = NULL); // standard constructor
|
|
||||||
CBitmapPicture RCM_BITMAP0;
|
|
||||||
CBitmapPicture RCM_BITMAP1;
|
|
||||||
CBitmapPicture RCM_BITMAP2;
|
|
||||||
CBitmapPicture RCM_BITMAP3;
|
|
||||||
CBitmapPicture RCM_BITMAP4;
|
|
||||||
CBitmapPicture RCM_BITMAP5;
|
|
||||||
CBitmapPicture RCM_BITMAP6;
|
|
||||||
CMFCEditBrowseCtrl m_EditBrowse;
|
|
||||||
// Dialog Data
|
|
||||||
#ifdef AFX_DESIGN_TIME
|
|
||||||
enum { IDD = IDD_TEGRARCMGUI_DIALOG };
|
|
||||||
#endif
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
|
||||||
|
|
||||||
|
|
||||||
// Implementation
|
|
||||||
protected:
|
|
||||||
HICON m_hIcon;
|
|
||||||
// Generated message map functions
|
|
||||||
virtual BOOL OnInitDialog();
|
|
||||||
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
|
|
||||||
afx_msg void OnIdle();
|
|
||||||
afx_msg void OnShowWindow();
|
|
||||||
afx_msg void OnPaint();
|
|
||||||
afx_msg HCURSOR OnQueryDragIcon();
|
|
||||||
DECLARE_MESSAGE_MAP()
|
|
||||||
public:
|
|
||||||
void StartTimer();
|
|
||||||
void StopTimer();
|
|
||||||
void OnTimer(UINT nIDEvent);
|
|
||||||
int STATUS;
|
|
||||||
afx_msg void BitmapDisplay(int IMG);
|
|
||||||
afx_msg void OnEnChangePath();
|
|
||||||
afx_msg void InjectPayload();
|
|
||||||
afx_msg void OnBnClickedShofel2();
|
|
||||||
afx_msg string GetPreset(string param);
|
|
||||||
afx_msg void SetPreset(string param, string value);
|
|
||||||
afx_msg void InstallDriver();
|
|
||||||
afx_msg BOOL LookForDriver();
|
|
||||||
afx_msg void OnBnClickedMountSd();
|
|
||||||
afx_msg int Smasher(TCHAR args[]);
|
|
||||||
afx_msg TCHAR* GetAbsolutePath(TCHAR *relative_path, DWORD dwFlags);
|
|
||||||
afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd *pWnd, UINT nCtlColor);
|
|
||||||
};
|
|
Before Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 8.1 KiB |
Before Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 21 KiB |