Fix Open/CloseProxmark issues in PR#607#615
Conversation
|
Hi @micolous, can we please split this up into fixes and "library API" changes? Agreed to commit these:
(although I wouldn't call it "global state" - the state is not visible outside of comms.c except via calling However, I would like to discuss these first:
This would add a function to the comms API which requires a serial_port as parameter - an OS and device dependent structure which I think should remain hidden inside comms.c. Isn't there a way to start the thread via
If you don't want to replace it, then let's try to modify it with some
Maybe adding |
Double-free issues are now in #617. I'll rebase on that once that's merged.
But My issue is that AndProx's signature for I mean, we could have I think PM3-internal tests should be their own special binary, and then have a uart implementation that allows some I presently use the same PM3 binary for simulated and real devices, and use a Java mocking library to provide a different interface, because there's not much point in implementing I'll probably eventually switch to using Java interfaces to fix some other issue with rooted devices, so even my JNI code will have an opaque
We could do something like #506, and have a define like But I liked just splitting up the function instead, between "bit that is important for PM3 CLI tools" and "bit that is important for using PM3-client as a protocol". I already replaced |
- StartProxmark split from OpenProxmark, to make it easier to start up the USB communication thread and set the serial port, without also have PM3 try to open the serial port for us. This is useful when PM3 doesn't have a path to a real device, such as with tests with a simulated device, and on Android). - OpenProxmark now doesn't mutate global state until it has finished. - CloseProxmark now puts PM3 in offline mode, and clears global state. - CloseProxmark now checks for a non-null serial_port before calling uart_close, to avoid unintentional double-free'ing serial_port. - main now calls CloseProxmark once.
36b8d8c to
abd2e77
Compare
|
Rebased on current master (with #617), please take a look. |
Please replace If you find a way to move the weird |
|
btw: |
|
I wrote There's another alternative (for me)... with #607, the But it means stashing the parameters for What I want is a way to inject a value into |
|
You would simply call e.g. |
|
Replaced by #625. |
Since #463 has been closed with #607 billed as it's replacement, and it doesn't fully address my concerns, this is a new PR to fix issues that impact making Android support work from Proxmark master:
StartProxmark split from OpenProxmark, to make it easier to start up the USB communication thread and set the serial port, without also having PM3 try to open the serial port for us. This is useful when PM3 doesn't have a path to a real device, such as with tests with a simulated device, and on Android).
OpenProxmark now doesn't mutate global state until it has successfully finished.
CloseProxmark now puts PM3 in offline mode, and clears global state.
CloseProxmark now checks for a non-null serial_port before calling uart_close, to avoid unintentional double-free'ing serial_port. This fixes a crash-on-exit on OSX.
Things that are not required or used for Android support, but that are related and included in this PR:
main now calls CloseProxmark once. This fixes a crash-on-exit on OSX.
OpenProxmark now takes a
char*argument again, becauseCloseProxmarktreatsserial_port_nameas achar*.As I've mentioned before, I'm not looking to replace
comms.con Android, and this was never my intent when first submitting the file. Several pieces of important global state (such assp,offline, anduart_communication) are stored in this file.At present,
CloseProxmarkstill blindly callsunlinkon Android, because#ifdef _LINUX_still triggers on Android, and this is the only way to shut down the USB communication thread.