Provide a variable as source for digitalRead();

Is it possible to make something that a digitalRead() command is reading a variable? Not a pin?

My problem is, i want too add an ability to a library and can't alter the library because of lack of knowing and future updates.

The library itself uses "digitalRead(thePin)" to get its value.

Any way to provide a boolean variable to that? Or create something like virtual pins and define a value for them?

As long as the variable contains a valid pin number, a variable should work fine. What makes you think it wouldn't?

KeithRB:
As long as the variable contains a valid pin number, a variable should work fine. What makes you think it wouldn't?

It should not contain a pin number, it should "simulate" an input

I would like to use for example

somevar = HIGH
digitalRead(somevar) should then return high or low

No. You can't do that. The digitalRead() function takes a pin number and reads the physical hardware. You can't "emulate" the digitalRead() function without the library being aware of the emulation.

Then I would put a wrapper around digital read:

int myDitigalRead(int var)
{
    
    if (var == -1) return LOW;
    if (var == -2) return HIGH;

    return DigitalRead(var);

}

You have to be careful because HIGH and LOW are valid pin numbers.

Then I would put a wrapper around digital read:

That would require a modification to the existing library, which OP seems unwilling, or unable, to modify.

The library itself uses "digitalRead(thePin)" to get its value.

Does the library return the value it reads or does it do something with the value read ?

More details of what you are trying to do would help considerably.