View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0038020 | FPC | RTL | public | 2020-11-01 16:55 | 2020-11-04 12:08 |
Reporter | Sergey Larin | Assigned To | Sven Barth | ||
Priority | normal | Severity | minor | Reproducibility | have not tried |
Status | closed | Resolution | fixed | ||
Fixed in Version | 3.3.1 | ||||
Summary | 0038020: Using GetModuleHandle instead of LoadLibrary when getting the GetTickCount64 address | ||||
Description | When getting the address of the GetTickCount64 function, GetModuleHandle('kernel32.dll') is used, not LoadLibrary('kernel32.dll'). It is generally wrong to use LoadLibrary('kernel32.dll') without FreeLibrary('kernel32.dll'). You can use GetModuleHandle('kernel32.dll') because at the time of calling GetTickCount64 from SysUtils, the kernel32.dll library is guaranteed to be loaded. | ||||
Tags | patch, rtl | ||||
Fixed in Revision | 47274 | ||||
FPCOldBugId | |||||
FPCTarget | - | ||||
Attached Files |
|
|
gettickcount64-win-loadlibrary-fix.patch (852 bytes)
diff --git a/rtl/win/sysutils.pp b/rtl/win/sysutils.pp index 3c1f8eb791..cd617af960 100644 --- a/rtl/win/sysutils.pp +++ b/rtl/win/sysutils.pp @@ -847,19 +847,13 @@ var {$ENDIF} function GetTickCount64: QWord; -{$IFNDEF WINCE} -var - lib: THandle; -{$ENDIF} begin {$IFNDEF WINCE} + if Assigned(WinGetTickCount64) then + Exit(WinGetTickCount64()); { on Vista and newer there is a GetTickCount64 implementation } if Win32MajorVersion >= 6 then begin - if not Assigned(WinGetTickCount64) then begin - lib := LoadLibrary('kernel32.dll'); - WinGetTickCount64 := TGetTickCount64( - GetProcAddress(lib, 'GetTickCount64')); - end; + WinGetTickCount64 := TGetTickCount64(GetProcAddress(GetModuleHandle('kernel32.dll'), 'GetTickCount64')); Result := WinGetTickCount64(); end else {$ENDIF} |
|
Thank you for the patch. Please test and close if okay. |
Date Modified | Username | Field | Change |
---|---|---|---|
2020-11-01 16:55 | Sergey Larin | New Issue | |
2020-11-01 16:55 | Sergey Larin | File Added: gettickcount64-win-loadlibrary-fix.patch | |
2020-11-01 16:55 | Sergey Larin | Tag Attached: rtl | |
2020-11-01 16:55 | Sergey Larin | Tag Attached: patch | |
2020-11-01 20:41 | Sven Barth | Assigned To | => Sven Barth |
2020-11-01 20:41 | Sven Barth | Status | new => resolved |
2020-11-01 20:41 | Sven Barth | Resolution | open => fixed |
2020-11-01 20:41 | Sven Barth | Fixed in Version | => 3.3.1 |
2020-11-01 20:41 | Sven Barth | Fixed in Revision | => 47274 |
2020-11-01 20:41 | Sven Barth | FPCTarget | => - |
2020-11-01 20:41 | Sven Barth | Note Added: 0126688 | |
2020-11-04 12:08 | Sergey Larin | Status | resolved => closed |