IRQL rules for RtlXxxString functions

On 09-Dec-2013 17:12, Maxim S. Shatskih wrote:

> Actually, I have always thought locale works on per-system basis, rather than per process one.

The “Language for Unicode programs” settings, which governs MBCS<->Unicode conversions, is system-wide.

http://www.microsoft.com/en-us/download/details.aspx?id=13209

  • pa

Locale is per thread:
http://msdn.microsoft.com/en-us/library/windows/desktop/dd374051(v=vs.85).aspx

– pa

On 09-Dec-2013 14:49, xxxxx@hotmail.com wrote:

> I meant that if different user processes did the conversion then it could result in different
> Unicode representations.

…but my question still stands - I have always thought locale concept works on SYSTEM-WIDE basis, so that you cannot have locale A for the user X and locale Y for the user B. Things like user preferences, home directory, etc are user-specific, but locale is not (otherwise Logon screen may be displayed in language that a given user does not understand) Is this suggestion correct?

Anton Bassov

I also have some questions about safe strings. Could someone clarify if these functions can be called at DISPATCH?

I saw a few threads (AFAIR with replies from Doron) saying that if format string doesn’t contain any string specifiers (like %s and so on) the functions can be called at DISPATCH. On the other hand I saw a thread describing BSoD even with no string specifiers. Probably the code path is PAGED.

What a bigger problem I am trying to solve?

Debug prints are not enough sometimes. I would like to have some logging with ETW mechanism to know what happened before OS has died. So, it should be something like KdPrint but not only to debug port but also to ETW. RtlStringCchVPrintf looks very useful to format the string, but some functions may be called at DISPATCH, so it should be DISPATCH safe.

I could re-implement the wheel with my own DISPATCH safe formatter function. But it would be better to use existing one.

Thanks.

I believe it is per-thread, with each thread starting off with the locale
of the process, which is based on the per-session locale, which defaults
to the system locale (the API SetThreadLocale is kind of a giveaway on
this…)
joe

> Because the conversion would be done in the context of the usermode
> process locale though,
> two processes could have the same ascii that results in different
> Unicode, I think.

Actually, I have always thought locale works on per-system basis, rather
than per process one.
Am I wrong?

Anton Bassov


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

Per-thread. See SetThreadLocale. Also look at WideCharToMultiByte and
MultiByteToWideChar, which can supply a locale, indicate the current
thread locale, current session locale, or current system locale be used.
joe

On 09-Dec-2013 17:12, Maxim S. Shatskih wrote:
>> Actually, I have always thought locale works on per-system basis,
>> rather than per process one.
>
> The “Language for Unicode programs” settings, which governs
> MBCS<->Unicode conversions, is system-wide.

http://www.microsoft.com/en-us/download/details.aspx?id=13209

  • pa

NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

I think that the change of “Language for non-Unicode programs” in Control Panel actually installs another NLS files to the OS.

So, I expect that the only locales which will work with W2A and A2W functions are US English and the one installed in the Control Panel. Well, also UTF-8 which is considered to be a fake locale, just to reuse W2A and A2W to do Unicode <-> UTF-8 conversions.

IE supports displaying lots of different national languages in the web pages, but I don’t think it ever supports A encoding for these languages, I think it only works with W and UTF-8.

So, if you need to work with some national language using some app, and the app is built using A encoding, then you must set the aforementioned Control Panel setting.

Am I wrong?


Maxim S. Shatskih
Microsoft MVP on File System And Storage
xxxxx@storagecraft.com
http://www.storagecraft.com

wrote in message news:xxxxx@ntdev…
> Per-thread. See SetThreadLocale. Also look at WideCharToMultiByte and
> MultiByteToWideChar, which can supply a locale, indicate the current
> thread locale, current session locale, or current system locale be used.
> joe
>
>> On 09-Dec-2013 17:12, Maxim S. Shatskih wrote:
>>>> Actually, I have always thought locale works on per-system basis,
>>>> rather than per process one.
>>>
>>> The “Language for Unicode programs” settings, which governs
>>> MBCS<->Unicode conversions, is system-wide.
>>
>> http://www.microsoft.com/en-us/download/details.aspx?id=13209
>>
>> - pa
>>
>>
>> —
>> NTDEV is sponsored by OSR
>>
>> Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev
>>
>> OSR is HIRING!! See http://www.osr.com/careers
>>
>> For our schedule of WDF, WDM, debugging and other seminars visit:
>> http://www.osr.com/seminars
>>
>> To unsubscribe, visit the List Server section of OSR Online at
>> http://www.osronline.com/page.cfm?name=ListServer
>>
>
>
>

> I think that the change of “Language for non-Unicode programs” in

Control Panel actually installs another NLS files to the OS.

So, I expect that the only locales which will work with W2A and A2W
functions are US English and the one installed in the Control Panel.
Well, also UTF-8 which is considered to be a fake locale, just to
reuse W2A and A2W to do Unicode <-> UTF-8 conversions.

I believe A2W and W2A use the current user’s locale, not the system
locale, so they default to the per-session. But I haven’t looked at the
expansion of those macros in many years.

IE supports displaying lots of different national languages in the web
pages, but I don’t think it ever supports A encoding for these
languages, I think it only works with W and UTF-8.

So, if you need to work with some national language using some app,
and the app is built using A encoding, then you must set the
aforementioned Control Panel setting.

Yep. This is why 8-bit apps should be treated as another dangerous and
dead technology.

Or, as I would tell my students, “The correct response, when your boss
comes in and says ‘We have a massive order for our software from Korea,
but they want it localized. How long will that take?’ the correct answer
is not ‘Well, let me see if I can get it to compile in Unicode, and then
see how many things break, and I’ll get back to you, give me a month or
so’ but ‘How long will it take to get the Korean translator to get here?’”

While Unicode is still a pretty small piece of the localization effort, if
it a critical piece, and without it, there is not much point to worrying
about currency formats, date formats, time formats, numeric formats in
general, etc.
joe

Am I wrong?


Maxim S. Shatskih
Microsoft MVP on File System And Storage
xxxxx@storagecraft.com
http://www.storagecraft.com

wrote in message news:xxxxx@ntdev…
>> Per-thread. See SetThreadLocale. Also look at WideCharToMultiByte and
>> MultiByteToWideChar, which can supply a locale, indicate the current
>> thread locale, current session locale, or current system locale be used.
>> joe
>>
>>> On 09-Dec-2013 17:12, Maxim S. Shatskih wrote:
>>>>> Actually, I have always thought locale works on per-system basis,
>>>>> rather than per process one.
>>>>
>>>> The “Language for Unicode programs” settings, which governs
>>>> MBCS<->Unicode conversions, is system-wide.
>>>
>>> http://www.microsoft.com/en-us/download/details.aspx?id=13209
>>>
>>> - pa
>>>
>>>
>>> —
>>> NTDEV is sponsored by OSR
>>>
>>> Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev
>>>
>>> OSR is HIRING!! See http://www.osr.com/careers
>>>
>>> For our schedule of WDF, WDM, debugging and other seminars visit:
>>> http://www.osr.com/seminars
>>>
>>> To unsubscribe, visit the List Server section of OSR Online at
>>> http://www.osronline.com/page.cfm?name=ListServer
>>>
>>
>>
>>
>
> —
> NTDEV is sponsored by OSR
>
> Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev
>
> OSR is HIRING!! See http://www.osr.com/careers
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>

> I believe A2W and W2A use the current user’s locale, not the system

locale, so they default to the per-session. But I haven’t looked at the
expansion of those macros in many years.

I just nicknamed the MultiByteXxx functions this way, to avoid excessive typing :slight_smile:

but they want it localized. How long will that take?’ the correct answer
is not ‘Well, let me see if I can get it to compile in Unicode, and then
see how many things break, and I’ll get back to you, give me a month or
so’ but ‘How long will it take to get the Korean translator to get here?’"

Modern days, compiling apps to ANSI is a nonsense.


Maxim S. Shatskih
Microsoft MVP on File System And Storage
xxxxx@storagecraft.com
http://www.storagecraft.com

>> I believe A2W and W2A use the current user’s locale, not the system

> locale, so they default to the per-session. But I haven’t looked at the
> expansion of those macros in many years.

I just nicknamed the MultiByteXxx functions this way, to avoid excessive
typing :slight_smile:

> but they want it localized. How long will that take?’ the correct
> answer
> is not ‘Well, let me see if I can get it to compile in Unicode, and then
> see how many things break, and I’ll get back to you, give me a month or
> so’ but ‘How long will it take to get the Korean translator to get
> here?’"

Modern days, compiling apps to ANSI is a nonsense.

I started writing “Unicode-aware” apps about 1996, and one day I just
“flipped the Unicode switch” and my app continued to function perfectly,
with no issues at all. Most of my apps were trivially convertible to
Unicode (I had trouble selling the idea to clients, who had weird ideas
about how “inefficient” two-byte characters had to be, so I had to compile
them as ANSI to meet client spec; but the first time a client needed a
Unicode app, it was truly a matter of minutes to rebuild as a Unicode app,
and yes, I was asked that very question, and they liked my answer. In
only one case did I have to do a little more work, but the translation
went so slowly on their side that I made the fix in a couple days and they
never noticed…)

Full localization can be a bit messier, particularly for some locales,
where “non-standard” behavior is dictated by law. For example, in
Scandanavia the “civilian” clock is the classic 12-hour clock, but by law
all public transportation applications must use 24-hour time; one friend
who worked for a while in Japan told me that while the conventional
Gregorian calendar is the “civilian” calendar in Japan, the dates are not
valid for legal documents, where the date must be in the form of “The
day of the month of the year of the reign of our emperor
.” And Windows supports this!
joe

>
> –
> Maxim S. Shatskih
> Microsoft MVP on File System And Storage
> xxxxx@storagecraft.com
> http://www.storagecraft.com
>
>
> —
> NTDEV is sponsored by OSR
>
> Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev
>
> OSR is HIRING!! See http://www.osr.com/careers
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>

> Scandanavia the “civilian” clock is the classic 12-hour clock,

It’s classic only for Anglophones :slight_smile: together with the Farenheigt temperature and inches+feet+miles.

Metric countries (nearly whole Europe+exUSSR+China+IIRC Asian/Pacific) use 24 hour clock.

Nevertheless, in Russia, in everyday speech, we say “8 of evening” and not “20”. But, in any official context, 24hour scale is used.

Also, in Russia, Gregorian calendar was only accepted by the communists in around 1918, before this, Julian calendar was used.

The reason is that the Russian Orthodox Church dislikes anything going from Roman Popes, including the calendar in this case.

The Russian Church is still using Julian calendar internally. That’s why Christmas in Russia is early Jan and not late Dec.

valid for legal documents, where the date must be in the form of “The
day of the month of the year of the reign of our emperor
> .” And Windows supports this!

Oh really? This is one of the most amazing facts on Windows I’ve known.


Maxim S. Shatskih
Microsoft MVP on File System And Storage
xxxxx@storagecraft.com
http://www.storagecraft.com

Actually, that goes for the entire Eastern Orthodox Church, of which the Russian Orthodox Church is but one branch.

Now… as to when Christmas is celebrated… that’s actually a more complicated question.

LOL… yes, that’s PART of it. Anything that smacks of the Papacy is anathema to the Eastern Orthodox Church, for sure. The other part is that the Eastern Orthodox Church is about things being unchanging. The Julian Calendar was in use at the start of the Common Era, and … well … that was good enough then, it should be good enough now.

People tend to think that the Gregorian calendar has been used forever, but that’s far from the truth. It’s use is only relatively recent in most countries. Great Britain adopted it in 1752. And the Gregorian Calendar was only adopted in Russia after the October Revolution, which took place on October 1917 of the JULIAN calendar (or, at least, so says Wikipedia… and we all know that Wikipedia is always right).

Peter
OSR

>Calendar was only adopted in Russia after the October Revolution, which took place on October

1917 of the JULIAN calendar

Exactly, that’s why the anniversary of the October revolution (one of the 2-3 USSR’s major holidays) is November 7.

IIRC Gregorian calendar was adopted in Russia in Feb 1918, with a leap of Feb 1 - then Feb 14.


Maxim S. Shatskih

Microsoft MVP on File System And Storage

xxxxx@storagecraft.com

http://www.storagecraft.com

> > valid for legal documents, where the date must be in the form of "The

> day of the month of the year of the reign of our
> > emperor ." And Windows supports this!
>
> Oh really? This is one of the most amazing facts on Windows I’ve known.
>

I am in awe of the fact that the death of a person would require a reasonably urgent hotfix to an operating system (assuming that law would demand that the crowning of a new emperor would require his name be used in all dates from that point on).

James

Why would that require a hotfix? The construct is evocative of a format specifier, no?

Phil

Not speaking for LogRhythm
Phil Barila | Senior Software Engineer
720.881.5364 (w)
LogRhythm, Inc.
A LEADER in the 2013 SIEM Magic Quadrant
Perfect 5-Star Rating in SC Magazine for 5 Consecutive Years

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of James Harper
Sent: Monday, December 16, 2013 1:40 PM
To: Windows System Software Devs Interest List
Subject: RE: Re:[ntdev] Re:Re:Re:IRQL rules for RtlXxxString functions

> > valid for legal documents, where the date must be in the form of
> > “The day of the month of the year of the reign of
> > our emperor .” And Windows supports this!
>
> Oh really? This is one of the most amazing facts on Windows I’ve known.
>

I am in awe of the fact that the death of a person would require a reasonably urgent hotfix to an operating system (assuming that law would demand that the crowning of a new emperor would require his name be used in all dates from that point on).

James


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

James Harper wrote:

>> valid for legal documents, where the date must be in the form of “The
>> day of the month of the year of the reign of our
>>> emperor .” And Windows supports this!
>> Oh really? This is one of the most amazing facts on Windows I’ve known.
> I am in awe of the fact that the death of a person would require a reasonably urgent hotfix to an operating system (assuming that law would demand that the crowning of a new emperor would require his name be used in all dates from that point on).

I used to work with a rather strange fellow who insisted on using that
style of date in his comments. So, where I would have written “10 June
1988”, he wrote “10 June, Showa 63”. When I asked him about it, he
tried to make a self-righteous claim that he objected to basing his
entire timekeeping system on “the birth date of some poor schmuck”. I
wanted to point out that the Japanese emperor was “some poor schmuck”,
but I decided it was better just to drop it and back away slowly.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Peter,

This will probably be the only time I ever correct you. The Eastern Orthodox church is more fragmented than one might imagine, as not all churches are in communion. The largest schism is due to a disagreement over the fourth Ecumenical council. More recently, there is the schism in Ukraine as one portion recognizes the Moscow Patriarch, and the other portion recognizes the Kyiv Patriarch.

The Greek Orthodox church is also split. The Old Calendarists adhere to the Julian calendar while the New Calendarists (the vast majority, including myself) adhere to the Gregorian calendar for Christmas and the Julian for Easter. This occurred if I am not mistaken, in the 1920’s. Just don’t ask me why on that one.

Hold on - are not religious discussions of any description strictly prohibited on OSR lists???

If we proceed at such a pace, I guess we will be discussing politics, salaries and consultancy rates, make hate speeches in a style that even Mr.Kyler himself would not dare to dream of, etc,etc,etc, on OSR lists, pretty shortly…

Anton Bassov

Thank you, Mr. CK. I humbly stand corrected, and appreciate the definitive clarification.

Just one of the wonderful details of the Soviet calendar.

Didn’t the Soviet Union decide to change the length of the week at one point… from 7 days to 5 days, because a 7 day week was a religious thing? Or, did I simply read that in a pamphlet of hooey distributed by the John Birch Society to demonstrate the vast extent of the evil’s of the USSR?

Yes, indeed. But not CALENDAR discussions that reference religion parenthetically.

In any case, we’re seriously off topic. Yet another interesting digression. But an off-topic one, for sure.

Peter
OSR

> Didn’t the Soviet Union decide to change the length of the week at one point… from 7 days to 5 days,

because a 7 day week was a religious thing? Or, did I simply read that in a pamphlet of hooey
distributed by the John Birch Society to demonstrate the vast extent of the evil’s of the USSR?

Well, I guess you heard it from Mr.Kyler…

Anton Bassov

>I am in awe of the fact that the death of a person would require a reasonably urgent hotfix

Death of the emperor is a serious event, as serious as the daylight savings law changes in some countries, which also require a hotfix.


Maxim S. Shatskih
Microsoft MVP on File System And Storage
xxxxx@storagecraft.com
http://www.storagecraft.com