I've built a C++ native Android app with NDK toolcahain.
I've first tested the app using the adb tool and got the following output:
Code:
generic:/ $ run-as cardservice.hr.cardservice
generic:/data/data/cardservice.hr.cardservice $ cd card/
generic:/data/data/cardservice.hr.cardservice/card/ $ ./cardService
2016-11-30 20:36:06,245 INFO [default] Starting CardService
App continues to run
But problem starts when I try to do the same thing from a Android application.
The following code:
Code:
private void exec_command() throws IOException, InterruptedException {
String command = "./data/data/cardservice.hr.cardservice/card/cardService"
Process check_card_service = Runtime.getRuntime().exec(command);
BufferedReader in = new BufferedReader(new InputStreamReader(check_card_service.getInputStream()));
String line;
String content = "";
while ((line = in.readLine()) != null) {
System.out.println(line);
content = content + line;
}
check_card_service.waitFor();
};
It starts the application but the application fails, and stops working.
Code:
2016-11-30 19:25:11,417 INFO [default] Starting CardService
2016-11-30 19:25:11,447 INFO [default] Underlying Transport Error, Code: websocketpp.transport.asio:3
So my question is what is different in my approaches, what changes if i run it from my app or from the adb shell?
The application does not need root access.
Do you need any extra information?
Related
Hi all,
Does anyone know how to retrive (identify) the system name of the Storage Card using .Net C.F. and Visual Basic language?
This is because often changig the WM version or the localization of the device, can also change the name of the Storage Card (with related "Path not found" error in the program).
Thanks for help
using C#.net
Code:
private static string GetStorageCardPath()
{
DirectoryInfo di = new DirectoryInfo(@"\");
FileSystemInfo[] fsi = di.GetFileSystemInfos();
foreach (FileSystemInfo fileSystemInfo in fsi)
{
if ((fileSystemInfo.Attributes & FileAttributes.Temporary) == FileAttributes.Temporary)
{
return fileSystemInfo.FullName;
}
}
return null;
}
and with convert csharp to vb in VB.net
Code:
Private Shared Function GetStorageCardPath() As String
Dim di As New DirectoryInfo("\")
Dim fsi As FileSystemInfo() = di.GetFileSystemInfos()
For Each fileSystemInfo As FileSystemInfo In fsi
If (fileSystemInfo.Attributes And FileAttributes.Temporary) = FileAttributes.Temporary Then
Return fileSystemInfo.FullName
End If
Next
Return Nothing
End Function
Thanks HeliosDev!
Hello friends.
I am a lazy person with a lack of time. So, when I wanted to Phone Commander to add support for exporting registry keys to a file, I found an older, freely usable code (first I tried RegSaveKey coredll function, but I coud not elevate calling Process privilegies). PCMD will be the first "ondevice" WP7 application that allows you to export this (thanks Ultrashot we can also do it from a PC by Remote Tools). Unfortunately, the obtained code was using an MFC classes (CFile etc). Probably would not be a problem to rewrite it for another entry in the file, but I do not want change 3rd code. And MFC can be useful in the future too.
There were basically two options:
1. Use dynamic linking, because statically linking MFC to ATL is not allowed (conflicts of application instances). But then I had to get the correct library and try if they will run on WP7. In the future, I'll try.
2. Take all the MFC source code (included in WM DTK) and rewrite them to work statically in WP7, with prepared out CWinApp etc. It was a nasty job, but for some classes (especially CFile) is complete and functional to use. Next week there will publish libraries, source code and tutorial to use MFC classes in ATL native WP7 projects. EDIT: See 2nd post, this is probably better way then first one.
Meanwhile small code sample to export registers (ExportRegKey is 3rd function using CFile parameter):
Code:
BOOL ExportRegKey(HKEY hroot, const CString &root, const CString &key, CFile &out);
STDMETHODIMP CRegistryX::RegExportKeySimple(DWORD dwKey, LPCWSTR szSubKey, LPCWSTR szFileName)
{
TRACE(L"RegExportKeySimple(DWORD dwKey = %X, LPCWSTR szSubKey = %s, LPCWSTR szFileName = %s)", dwKey, szSubKey, szFileName);
try
{
HKEY hKey = (HKEY) dwKey;
LONG lRes = ERROR_SUCCESS;
CString root = L"";
switch (dwKey)
{
case HKEY_LOCAL_MACHINE:
{
root = _T("HKEY_LOCAL_MACHINE");
} break;
case HKEY_CURRENT_USER:
{
root = _T("HKEY_CURRENT_USER");
} break;
case HKEY_CLASSES_ROOT:
{
root = _T("HKEY_CLASSES_ROOT");
} break;
case HKEY_USERS:
{
root = _T("HKEY_USERS");
} break;
/*
case HKEY_CURRENT_CONFIG:
{
root = _T("HKEY_CURRENT_CONFIG");
} break;
*/
default:
{
root = _T("HKEY_UNKNOWN");
} break;
root = _T("");
}
CString key = szSubKey;
CFile out;
out.Open(szFileName, CFile::modeWrite | CFile::modeCreate );
lRes = ExportRegKey(hKey, root, key, out);
out.Close();
TRACE(L"RegExportKeySimple ExportRegKey lRes = %d)", lRes);
if (lRes == ERROR_SUCCESS)
{
return S_OK;
}
else
{
return ReturnError(L"RegSetDwordSimple RegSetValueEx", 0x80070000 | lRes);
}
}
catch (...)
{
return ReturnError(L"RegGetDwordSimple", GetLastError());
}
}
This is also Native TRACE example to see native messages in VP2010 managed Output window.
Full MFC using
I tried FULL MFC from VS2008 CE SDK using and this is possible.
1. Exe files - success with statical or dynamical MFC linking. Drawable components may have problems only.
2. Static linking to dll: If we can want use native dll with statically linked MFC to managed VS2010 dll or application, there are two ways:
- To change our usual COM interface to MFC standard. It may be possible, but I did not try it.
- To make ATL interstitial ATL dll with COM interface, which can call exported functions from MFC dll.
3. Dynamical MFC linking to ATL (COM) dll. I mean thi is the best way now.
For dynamical linking MFC dlls must be copied to device - to appplication directory or ideally to \Windows directory. Mostly:
\\Program Files (x86)\Microsoft Visual Studio 9.0\VC\ce\dll\ARMV4I\msvcr90.dll
\\Program Files (x86)\Microsoft Visual Studio 9.0\VC\ce\dll\ARMV4I\atl90.dll
\\Program Files (x86)\Microsoft Visual Studio 9.0\VC\ce\dll\ARMV4I\msvcr90d.dll
\\Program Files (x86)\Microsoft Visual Studio 9.0\VC\ce\dll\ARMV4I\MFC90UD.dll
Hello.
I'm working on a project where I need to store some information from the Windows Phone store in my Parse database, but since I'm new to both Parse and JavaScript (only supported language for Cloud Code) I need some help.
There seem to be something wrong with a property, but more than that I can't get, not which row or anything.
My code at the moment is this:
Code:
Parse.Cloud.job("getWP8Apps", function(request, response) {
Parse.Cloud.useMasterKey();
var query = new Parse.Query("developer");
query.each(function(results) {
Parse.Cloud.httpRequest({
url: 'http://zunderstorehost.azurewebsites.net/api/WP8StoreAppList/Publisher/' + results.get("publisherName"),
success: function(httpResponse) {
var apps = httpResponse.data;
for(var app in apps) {
var application = Parse.Object.extend("application");
var newApp = new application();
newApp.save({
categories: app.categories,
guid: app.guid,
haslivetile: app.haslivetile,
icon: app.icon,
mame: app.name,
offers: app.offers,
publisher: app.publisher,
publisherid: app.publisherid,
rating: app.rating,
ratingCount: app.ratingcount,
releaseDate: app.releasedate,
version: app.version
}, {
success: function(newApp){ console.log(app.name + " saved!"); },
error: function(newApp, error) {console.error("Something failed: " + error.description); }});
}
},
error: function(error) {
console.error("Something failed: " + error.description);
}
});
});
});
The developer object that I'm fetching from the storage is a small collection of items containing some general information about the different developers included in this, amongst that information, their Windows Phone Store Publisher Name which is to be used to fetch a list of their published applications.
The application object is a json converted class through the Parse Class Import function (that function converts the Json to a valid table structure for data storage of the result).
So, anyone with some ideas on what could be the issue here?
Any help is highly appreciated!
NOTE: This code is to run in the cloud, not in the app. Thats why I posted this in the web section. If it fits better somewhere else, feel free to move it.
I'm trying to read the list of active Xposed modules at "/data/data/de.robv.android.xposed.installer/conf/modules.list"
Currently, I'm using
Code:
String line;
process = new ProcessBuilder("su", "-c", "cat", MODULES_LIST_FILE).start();
BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream()));
while ((line = in.readLine()) != null) {
modules.add(line);
}
in.close();
- which does work, I'd just prefer to not require root access.
Where could I possibly hook to give me access to this file?
Thanks!
arilotter said:
I'm trying to read the list of active Xposed modules at "/data/data/de.robv.android.xposed.installer/conf/modules.list"
Currently, I'm using
Code:
String line;
process = new ProcessBuilder("su", "-c", "cat", MODULES_LIST_FILE).start();
BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream()));
while ((line = in.readLine()) != null) {
modules.add(line);
}
in.close();
- which does work, I'd just prefer to not require root access.
Where could I possibly hook to give me access to this file?
Thanks!
Click to expand...
Click to collapse
I believe that the "android" package has access to all data. So you could hook handleLoadPackage, wait for the "android" package to load, then try reading your file. Not sure if it'd work or not, though. You wouldn't have to hook any specific method.
Hey community,
I have another question.
I am trying to get adb to drop a root shell on my OP5T.
What I did so far was edit default.prop:
ro.secure=0
ro.debuggable=1
ro.adb.secure=0
service.adb.root=1
After repacking and booting the modified ramdisk, I try this command from my computer:
adb root
It tells me adbd is restarting as root, but when I do 'adb shell' after, it doesn't give me a root shell.
Now I am sure the props are changed because when I do getpro ro.secure it gives me 0, so I know the default.props got loaded correctly.
Any reason why adb is not dropping me a root shell?
This is the code that does the checks in the adbd daemon:
Code:
static bool should_drop_privileges() {
#if defined(ALLOW_ADBD_ROOT)
// The properties that affect `adb root` and `adb unroot` are ro.secure and
// ro.debuggable. In this context the names don't make the expected behavior
// particularly obvious.
//
// ro.debuggable:
// Allowed to become root, but not necessarily the default. Set to 1 on
// eng and userdebug builds.
//
// ro.secure:
// Drop privileges by default. Set to 1 on userdebug and user builds.
bool ro_secure = android::base::GetBoolProperty("ro.secure", true);
bool ro_debuggable = __android_log_is_debuggable();
// Drop privileges if ro.secure is set...
bool drop = ro_secure;
// ... except "adb root" lets you keep privileges in a debuggable build.
std::string prop = android::base::GetProperty("service.adb.root", "");
bool adb_root = (prop == "1");
bool adb_unroot = (prop == "0");
if (ro_debuggable && adb_root) {
drop = false;
}
// ... and "adb unroot" lets you explicitly drop privileges.
if (adb_unroot) {
drop = true;
}
return drop;
#else
return true; // "adb root" not allowed, always drop privileges.
#endif // ALLOW_ADBD_ROOT
}
Greetings,
Down...