In a custom module, get return of hook for making it available in other hook
Yes, if you implement a hook provided by a contrib module, it is invoked by that module function.
You can declare those two variables in global scope so that they can be accessible each other in the functions.

&lt;?php
// mymodule.module
global $foo1;
global $foo2;

function mymodule_contribmodulehook1 ($parameter1, $parameter2) {
  global $foo2;
  //$foo2 here 
  $foo1 = 1;
}

function mymodule_contribmodulehook2 ($parameter1, $parameter2) {
  global $foo1;
  //$foo1 here
  $foo2 = 1;
}


If you don't want to use global scope for your variables, you can save and retrieve them alternatively in your Drupal database using variable_set() and variable_get().

function mymodule_contribmodulehook1 ($parameter1, $parameter2) {
  $foo2 = variable_get('foo2');
  $foo1 = 1; 
  variable_set('foo1', $foo1);
}

function mymodule_contribmodulehook2 ($parameter1, $parameter2) {
  $foo1 = variable_get('foo1'); 
  $foo2 = 1;
  variable_set('foo2', $foo2);
}


Note that, for both approaches, you don't need to return each of them as long as you don't have any other purpose.