# Working with Enabled and Non-Enabled Modules

The pointer checker is not supported on macOS systems.

An enabled module is a module compiled with the pointer checker option enabled, while a non-enabled module is a module compiled with this compiler option disabled.

If you write a pointer to memory or return a pointer from a non-enabled module, the pointer may get incorrect bounds information. If you use this pointer with the incorrect bounds information in an enabled module, the pointer checker will report an incorrect out-of-bounds error because the bounds do not correspond to the pointer.

To minimize this issue, the pointer checker stores a copy of the pointer along with the bounds information. When the pointer is loaded into memory, the value of the pointer is compared with the value of the pointer copy. If these two values match, the bounds information is assumed to be correct and is then used. However, if the two values do not match, the bounds are set to allow access to any memory.

The pointer checker can still report an out-of-bounds error if a pointer from a non-enabled module matches the pointer copy stored with the bounds information.

For example, consider the case where you create the following pointer by using a run-time library function from a non-enabled module:

Example: Pointer Created with RTL Function
    p = my_realloc(p, old_size + 100);

If the memory allocator can simply extend the memory allocated to `p`, and then returns the same pointer, an enabled module could use this pointer with the old bounds information. The pointer checker then reports an out-of-bounds error because this feature does not know about the extension created by the realloc() function.

To prevent incorrect out-of-bounds errors when you have both enabled and non-enabled modules, do one of the following:

- Remove the bounds information from the pointer by using the __chkp_kill_bounds() intrinsic function

- Set the correct bounds information by using the __chkp_make_bounds() intrinsic function in an enabled module.

## Removing the Bounds Information

When you remove the bounds information, you disable pointer checking on this pointer. You can remove the bounds information by using the __chkp_kill_bounds() intrinsic function.

Example: Removing Bounds Information with __chkp_kill_bounds()
    void * unknown_pointer_returning_function() {
       ...
       // Use the intrinsic function in the return pointer
       return __chkp_kill_bounds(the_ptr);
    }

## Setting the correct bounds information

You can use the __chkp_make_bounds() intrinsic function to set the correct bounds information for a pointer.

For example, you use the Windows* HeapAlloc() function to create a pointer. Since this operating system function is from a non-enabled module, the pointer from this function will not have the correct bounds information.

To get a pointer with the correct bounds information, use the __chkp_make_bounds() intrinsic function in the return value:

Example: Obtaining a Pointer with __chkp_make_bounds()
    void * myalloc(size_t size){ return __chkp_make_bounds(HeapAlloc(MyHeap, flags, size), size); }

Parent topic: Using the Pointer Checker