The value.lval inside the zval * container contains the key to your resource and thus can be used to fetch the resource with the following macro:
Now that the user got his resource, at some point he is passing it back to one of your functions. The value.lval inside the zval * container contains the key to your resource and thus can be used to fetch the resource with the following macro: ZEND_FETCH_RESOURCE: