tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

MozillaRuntimeMainAndroid.cpp (1178B)


      1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
      2 * vim: sw=2 ts=4 et :
      3 * This Source Code Form is subject to the terms of the Mozilla Public
      4 * License, v. 2.0. If a copy of the MPL was not distributed with this
      5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #include <dlfcn.h>
      8 #include <android/log.h>
      9 
     10 int main(int argc, char* argv[]) {
     11  // Check for the absolute minimum number of args we need to move
     12  // forward here. We expect the last arg to be the child process type.
     13  if (argc < 2) return 1;
     14 
     15  void* mozloader_handle = dlopen("libmozglue.so", RTLD_LAZY);
     16  if (!mozloader_handle) {
     17    __android_log_print(ANDROID_LOG_ERROR, "GeckoChildLoad",
     18                        "Couldn't load mozloader because %s", dlerror());
     19    return 1;
     20  }
     21 
     22  typedef int (*ChildProcessInit_t)(int, char**);
     23  ChildProcessInit_t fChildProcessInit =
     24      (ChildProcessInit_t)dlsym(mozloader_handle, "ChildProcessInit");
     25  if (!fChildProcessInit) {
     26    __android_log_print(ANDROID_LOG_ERROR, "GeckoChildLoad",
     27                        "Couldn't load cpi_t because %s", dlerror());
     28    return 1;
     29  }
     30 
     31  return fChildProcessInit(argc, argv);
     32 }