Bug Hunting Session
Bug 122034 - Replace deprecated WinAPI functions with their recommended substitutions
Summary: Replace deprecated WinAPI functions with their recommended substitutions
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: easyHack, skillCpp, skillWindows, topicCleanup
Depends on:
Blocks:
 
Reported: 2018-12-12 08:01 UTC by Mike Kaganski
Modified: 2018-12-13 03:48 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Kaganski 2018-12-12 08:01:41 UTC
Throughout the Win-specific part of the codebase, we have some deprecated WinAPI functions used. For example, CreateDIBPatternBrush [1] is used in GDI code. This might have different degree of consequences, from performance (deprecated functions are most probably internally implemented as wrappers over up-to-date API, with inevitable overhead; some obsolete API requires more processing, like using GlobalAlloc to obtain memory handle for CreateDIBPatternBrush), to possible loss of compatibility/functionality (some of obsolete functions may not support some newer OS functions).

This easy hack is about looking through the WinAPI functions used in the code, and checking if they are obsoleted by some newer/recommended API, and ultimately replacing those deprecated functions (with required modifications around that).

This requires first obtaining the list of such functions. This might be done e.g. using tools like Dependencies, [2] which can list imports of a module:

> C:\Dependencies_x64_Release\Dependencies.exe -imports c:\lo\core\instdir\program\gdipluscanvaslo.dll

and analyzing the output related to system libraries (KERNEL32.DLL, GDI32.DLL, etc).

Then, reading of the identified functions' documentation is required. [3] For each deprecated function found, the place where it's used should be found in the codebase. Some of the usages might come from external libraries; this easy hack is only about internal usages.

Not every usage of a deprecated function might require replacement; I cannot come with an example when it might be undesirable, but it is possible. So when reading the documentation, one must pay close attention to details about differences in behavior of the obsolete and recommended APIs.

[1] https://docs.microsoft.com/en-us/windows/desktop/api/wingdi/nf-wingdi-createdibpatternbrush
[2] https://github.com/lucasg/Dependencies
[3] https://docs.microsoft.com/en-us/windows/desktop/api/index