Exetools  

Go Back   Exetools > General > General Discussion

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 07-23-2024, 23:47
WhoCares's Avatar
WhoCares WhoCares is offline
who cares
 
Join Date: Jan 2002
Location: Here
Posts: 468
Rept. Given: 11
Rept. Rcvd 32 Times in 25 Posts
Thanks Given: 69
Thanks Rcvd at 247 Times in 94 Posts
WhoCares Reputation: 32
maybe a bug of Windows API PathMatchSpecW() ?

Consider the following code. PathMatchSpecW() is expected to do case-insensitive match(It seems that MS never documents this but it's true), so variable "matched" should be TRUE.

static const WCHAR pattern[] = L"的f";
const auto matched = PathMatchSpecW(L"的F", pattern);

But actually it is FALSE. Why?

I stepped into its asm code, it uses IsDBCSLeadByte(0x84) to check the first Chinese UTF-16 WCHAR '的'(0x7684), and IsDBCSLeadByte(0x84) returns TRUE for Chinese code page. Then it does case-sensitive comparison of 'f' and 'F', and finally returns FALSE.

I think it's WRONG to use IsDBCSLeadByte() for any byte of a UTF-16 string.
Perhaps MS guys add this logic to provide some compatibility with old weird strings?
__________________
AKA Solomon/blowfish.
Reply With Quote
  #2  
Old 07-23-2024, 23:53
sendersu sendersu is offline
VIP
 
Join Date: Oct 2010
Posts: 1,305
Rept. Given: 337
Rept. Rcvd 237 Times in 127 Posts
Thanks Given: 340
Thanks Rcvd at 652 Times in 357 Posts
sendersu Reputation: 200-299 sendersu Reputation: 200-299 sendersu Reputation: 200-299
how about dig under the WinAPI hood?
using your lovely debugger!
Reply With Quote
  #3  
Old 07-24-2024, 00:00
WhoCares's Avatar
WhoCares WhoCares is offline
who cares
 
Join Date: Jan 2002
Location: Here
Posts: 468
Rept. Given: 11
Rept. Rcvd 32 Times in 25 Posts
Thanks Given: 69
Thanks Rcvd at 247 Times in 94 Posts
WhoCares Reputation: 32
I already debugged it

It's unexpected to use IsDBCSLeadByte() for a UTF-16 string.


Quote:
Originally Posted by sendersu View Post
how about dig under the WinAPI hood?
using your lovely debugger!
__________________
AKA Solomon/blowfish.
Reply With Quote
The Following User Says Thank You to WhoCares For This Useful Post:
sendersu (07-24-2024)
  #4  
Old 07-25-2024, 12:33
WhoCares's Avatar
WhoCares WhoCares is offline
who cares
 
Join Date: Jan 2002
Location: Here
Posts: 468
Rept. Given: 11
Rept. Rcvd 32 Times in 25 Posts
Thanks Given: 69
Thanks Rcvd at 247 Times in 94 Posts
WhoCares Reputation: 32
IsDBCSLeadByte() should be used for GBK/GB2312/GB18030 encoding etc.(CJK encodings)

Here is a good replacement for PatchMatchSpecW():
https://github.com/kirkjkrauss/MatchingWildcards

This article is also interesting:
https://www.codeproject.com/Articles/5163931/Fast-String-Matching-with-Wildcards-Globs-and-Giti
__________________
AKA Solomon/blowfish.

Last edited by WhoCares; 07-25-2024 at 12:39.
Reply With Quote
The Following User Says Thank You to WhoCares For This Useful Post:
niculaita (07-26-2024)
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
C# (Classic .exe, Windows 10, Windows Phone etc.) Protection delidolunet General Discussion 7 10-11-2016 01:10
(Q) .NET App Source Code Protection (Silverlight, Windows Phone, Windows 8) delidolunet General Discussion 7 08-02-2013 10:33
Windows 2000 and Windows nt 4 sources, question shady General Discussion 2 04-15-2004 04:17


All times are GMT +8. The time now is 05:34.


Always Your Best Friend: Aaron, JMI, ahmadmansoor, ZeNiX, chessgod101
( Since 1998 )