int XGetWindowProperty(Display* display, Window w, Atom property, long long_offset, long long_length, Bool delete, Atom req_type, Atom* actual_type_return, int* actual_format_return, unsigned long* nitems_return, unsigned long* bytes_after_return, unsigned char** prop_return) https://tronche.com/gui/x/xlib/window-information/XGetWindowProperty.html long_offset Specifies the offset in the specif
| 961 | // BadValue Some numeric value falls outside the range of values accepted by the request.Unless a specific range is specified for an argument, the full range defined by the argument's type is accepted. Any argument defined as a set of alternatives can generate this error. |
| 962 | // BadWindow A value for a Window argument does not name a defined Window. |
| 963 | static void x11_GetWindowProperty(CPU* cpu) { |
| 964 | KThread* thread = cpu->thread; |
| 965 | XServer* server = XServer::getServer(); |
| 966 | KMemory* memory = cpu->memory; |
| 967 | XWindowPtr window = server->getWindow(ARG2); |
| 968 | U32 propertyAtom = ARG3; |
| 969 | U32 long_offset = ARG4 * 4; |
| 970 | U32 long_length = ARG5 * 4; |
| 971 | U32 deleteProperty = ARG6; |
| 972 | U32 req_type = ARG7; |
| 973 | U32 actual_type_return = ARG8; |
| 974 | U32 actual_format_return = ARG9; |
| 975 | U32 nitems_return = ARG10; |
| 976 | U32 bytes_after_return = ARG11; |
| 977 | U32 prop_return = ARG12; |
| 978 | |
| 979 | memory->writed(actual_type_return, 0); |
| 980 | memory->writed(actual_format_return, 0); |
| 981 | memory->writed(nitems_return, 0); |
| 982 | memory->writed(bytes_after_return, 0); |
| 983 | memory->writed(prop_return, 0); |
| 984 | |
| 985 | if (!window) { |
| 986 | EAX = BadWindow; |
| 987 | return; |
| 988 | } |
| 989 | |
| 990 | BString propertyName; |
| 991 | if (!server->getAtom(propertyAtom, propertyName)) { |
| 992 | EAX = BadAtom; |
| 993 | return; |
| 994 | } |
| 995 | BString propertyType; |
| 996 | if (!server->getAtom(req_type, propertyType)) { |
| 997 | EAX = BadAtom; |
| 998 | return; |
| 999 | } |
| 1000 | EAX = Success; |
| 1001 | |
| 1002 | XPropertyPtr property = window->getProperty(propertyAtom); |
| 1003 | if (!property) { |
| 1004 | return; |
| 1005 | } |
| 1006 | if (long_offset > property->length) { |
| 1007 | EAX = BadValue; |
| 1008 | return; |
| 1009 | } |
| 1010 | |
| 1011 | memory->writed(actual_type_return, property->type); |
| 1012 | memory->writed(actual_format_return, property->format); |
| 1013 | |
| 1014 | U32 toCopy = std::min(long_length, property->length - long_offset); |
| 1015 | if (toCopy == 0) { |
| 1016 | // XGetWindowProperty() always allocates one extra byte in prop_return (even if the property is zero length) and sets it to zero so that simple properties consisting of characters do not have to be copied into yet another string before use. |
| 1017 | U32 valueAddress = thread->process->alloc(thread, 1); // alloc guarantees zero'd out memory |
| 1018 | memory->writed(prop_return, valueAddress); |
| 1019 | return; |
| 1020 | } |
nothing calls this directly
no test coverage detected