You should not change scmdatabase_find_service_by_displayname, it does what its name implies. You should fix the callers where necessary.
The scmdatabase_find_service_by_displayname is currently wrong. It dereferences a NULL pointer if the registry database contains a service without a display name. The callers can't do anything about that. Both callers expects that if the display name is not explicitly set, the key name should be used as the display name - it looks like a general rule (I've just found that QueryServiceConfig also needs such a feature). Alternatively, code could be added to load_service_config and CreateService to set lpDisplayName to service->name if the display name is not present in the registery. However, this would create a side-effect not present on Windows - this display name would be written to the registery after e.g. a ChangeServiceConfig.
Mikolaj Zalewski