flat assembler
Message board for the users of flat assembler.

Index > Projects and Ideas > Sparky8 - The system response improver

Goto page Previous  1, 2, 3  Next
Author
Thread Post new topic Reply to topic
f0dder



Joined: 19 Feb 2004
Posts: 3175
Location: Denmark
f0dder 14 Mar 2007, 00:07
There's one very important thing to do on windows, and that's "do it the safe way". It's not like you're running this code in an innerloop, and it's not going to add even a kilobyte doing it "the right way".

It would make sense that all APIs with a returncode does clear lasterror on success, but knowing Microsoft... well Smile
Post 14 Mar 2007, 00:07
View user's profile Send private message Visit poster's website Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 14 Mar 2007, 00:22
Yes, I know f0dder and if it must be done no problem but here we have that the current documentation breaks the previous one but there was programs coded in the time were the old docs were written and those old docs told to the programmers that LastError is always set by CreateMutex.

I edited my post with nice colours to see the LastError sets more clear Razz
Post 14 Mar 2007, 00:22
View user's profile Send private message Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3175
Location: Denmark
f0dder 14 Mar 2007, 00:32
Well, weren't the old docs ported from the win16 docs? Things have been added since that, etc.

Oh well. Safe coder <3
Post 14 Mar 2007, 00:32
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 14 Mar 2007, 00:32
Quote:
but here we have that the current documentation breaks the previous one [...] and those old docs told to the programmers that LastError is always set by CreateMutex.

no they didn't:

Quote:
Return Values
If the function succeeds, the return value is a handle to the mutex object. If the named mutex object existed before the function call, the GetLastError function returns ERROR_ALREADY_EXISTS. Otherwise, GetLastError returns zero.
If the function fails, the return value is NULL. To get extended error information, call GetLastError.

Problem is that you state that "otherwise" applies to first "if", not to second "if". If "otherwise" applies to first if you are right, if to second you are not.

Gramatically, this is usage of ambigous context, so we can say MSDN doesn specify it clearly.

Anyway, it is common to use last suitable item as context, and in such case you are wrong.

Razz Cool
Post 14 Mar 2007, 00:32
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 14 Mar 2007, 00:33
Quote:
It would make sense that all APIs with a returncode does clear lasterror on success, but knowing Microsoft... well
And some even don't set lasterror on error... beatufil Smile
Post 14 Mar 2007, 00:33
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 14 Mar 2007, 01:02
No vid, I apply it to second "if" but even with that for me it still means that it's always set because the second "if" requieres a "If the function succeeds, ..." to be true.

My english skills are lower than the average of the members of this forum so forgive me if I make a lot of noise with wrong deduction from my part.Razz

Note that if the second "if" doesn't requieres the first one to be true then the docs leaves undefined which return value you have under an ERROR_ALREADY_EXISTS (unless I'm doing wrong gramatical interpretation again).
Post 14 Mar 2007, 01:02
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 14 Mar 2007, 10:20
Quote:
No vid, I apply it to second "if" but even with that for me it still means that it's always set because the second "if" requieres a "If the function succeeds, ..." to be true.
thinking again about it... No. Second "if" cannot be nested under first "if". Because when ERROR_ALREADY_EXISTS is returned, then function haven't succeeded.

Now I understand why they changed this description Very Happy

Anyway, my interpretation is how they MEANT it, you can find out by reading corrected description in newer MSDN.

And still, you shouldn't just ignore another errors, every error you wasn't awaiting should be displayed and program terminated. This is extremely helpful for debugging, and required in serious programming
Post 14 Mar 2007, 10:20
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 14 Mar 2007, 14:01
Code:
include 'win32axp.inc'

.code
_mutex_name db "Mutex Test", 0

start:
invoke  CreateMutex,NULL,FALSE,_mutex_name
mov     esi, eax
invoke  GetLastError
mov     edi, eax

invoke CreateMutex,NULL,FALSE,_mutex_name
mov    ebx, eax
invoke GetLastError
int3
.end start    

Code:
ESI = $10
EDI = 0

EBX = $20
EAX = $B7    


The ERROR_ALREADY_EXISTS is a succesful error like ERROR_SUCCESS. The function can fail if you try to create a named mutex which already exists but you don't have privilegies to do that but in that case the function really fails and sets ERROR_ACCESS_DENIED and returns NULL.

Also note that the qoute lost the original format but actually the "If the function succeeds, ..." and "If the function fails, ..." belongs to different paragraphs. The first paragraph for me guaranties that LastError will be set always you try to create a NAMED mutex and the second paragraph guaranties at any fail situation that LastError will be set. The real scenario where LastError is undefined by the old docs is when you create an UNNAMED mutex.

BTW, did you see http://msdn2.microsoft.com/en-us/library/ms682396.aspx ? There there is a very similar copy of my quote but in the context of CreateEvent. I see that current software tends to use this instead of CreateMutex but dissasembling MSN Messenger I see that they check the return value before calling GetLastError Sad (but MSN Messenger silently dies like in the ERROR_ALREADY_EXISTS case).

Well, I think that I must do it like you said but I think that the docs are wrong then.
Post 14 Mar 2007, 14:01
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 14 Mar 2007, 15:11
Quote:
Well, I think that I must do it like you said but I think that the docs are wrong then.
yes, at least they seem to be fixing some unclear / unexact formulations (not yet in CreateEvent)
Post 14 Mar 2007, 15:11
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Plue



Joined: 15 Dec 2005
Posts: 151
Plue 15 Mar 2007, 12:00
This works a bit on my computer, but most of the lagging here comes when a program accesses the disk, not because it uses all CPU. Is it possible to reduce the maximum allowed disk access time per time slice or something?
Post 15 Mar 2007, 12:00
View user's profile Send private message Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3175
Location: Denmark
f0dder 15 Mar 2007, 12:26
Plue wrote:
This works a bit on my computer, but most of the lagging here comes when a program accesses the disk, not because it uses all CPU. Is it possible to reduce the maximum allowed disk access time per time slice or something?

For that, you need the super duper new and improved WINDOWS VISDUUUUUH!

_________________
Image - carpe noctem
Post 15 Mar 2007, 12:26
View user's profile Send private message Visit poster's website Reply with quote
white_wight



Joined: 03 Feb 2006
Posts: 24
white_wight 28 Mar 2007, 09:09
http://s0m.narod.ru/
another one system response improver Wink


Description: to make the long story short :-)
Download
Filename: speedballs.zip
Filesize: 39.18 KB
Downloaded: 708 Time(s)



Last edited by white_wight on 12 Apr 2007, 01:03; edited 1 time in total
Post 28 Mar 2007, 09:09
View user's profile Send private message Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3175
Location: Denmark
f0dder 28 Mar 2007, 11:22
white_wight: that site doesn't support direct links - you have to go to s0m.narod.ru before you can download the zip...

And gah, why do people comment their sourcecode in anything but English? >_<
Post 28 Mar 2007, 11:22
View user's profile Send private message Visit poster's website Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2341
Location: Usono (aka, USA)
rugxulo 31 Mar 2007, 04:29
f0dder wrote:
white_wight:
And gah, why do people comment their sourcecode in anything but English? >_<


Because Morse code is too bloated? Wink

Seriously, I think only about 20% (or less??) of the world's population speaks English. Besides, English is a bit complex to learn, and takes a long time. It'd be better if people used something sensible (IMO, Esperanto), but popular opinion (for now) disagrees.

P.S. It would've been funnier if you'd said that in Danish. (Go ahead and edit your post to add it. Pretty please?) Razz
Post 31 Mar 2007, 04:29
View user's profile Send private message Visit poster's website Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3175
Location: Denmark
f0dder 31 Mar 2007, 06:07
rux: I'm definitely it would be so grreat if everybody commented in English. Espically the Russians, they do some GODDAMN great stuff!

Jeg ville ønske at alle folk var internationale!
Post 31 Mar 2007, 06:07
View user's profile Send private message Visit poster's website Reply with quote
white_wight



Joined: 03 Feb 2006
Posts: 24
white_wight 12 Apr 2007, 01:10
Quote:
rux: I'm definitely it would be so grreat if everybody commented in English. Espically the Russians, they do some GODDAMN great stuff!

Maybe because some don't know English that much. (check particularly the exit message box of those Speedballs Wink)

Quote:
Jeg ville ønske at alle folk var internationale!

Eh? Smile
Post 12 Apr 2007, 01:10
View user's profile Send private message Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3175
Location: Denmark
f0dder 12 Apr 2007, 12:05
See, that sentence made as much sense to you as russian (and a bunch of other languages) make to most people Smile

"I wish that everybody were international" - and now it makes sense.
Post 12 Apr 2007, 12:05
View user's profile Send private message Visit poster's website Reply with quote
white_wight



Joined: 03 Feb 2006
Posts: 24
white_wight 12 Apr 2007, 14:05
rugxulo wrote:
Seriously, I think only about 20% (or less??) of the world's population speaks English. Besides, English is a bit complex to learn, and takes a long time. It'd be better if people used something sensible (IMO, Esperanto), but popular opinion (for now) disagrees.

Well, if you are español, Français, italiano or Englishman, then of course it will take a couple of month for you to master Esperanto.
And what about Arab or Japanese or Chinese?
I don't think that for those folks it is that easier to learn Esperanto. Wink
Moreover, there are more resourses to study English than any other language in the world. At least for now. Smile
Post 12 Apr 2007, 14:05
View user's profile Send private message Reply with quote
r22



Joined: 27 Dec 2004
Posts: 805
r22 13 Apr 2007, 02:37
I don't see the reason for the sleep and loop approach for sparky.

I'm pretty sure SetWindowsHookEx using WH_SHELL will return the handle of a just activated window which would remove the polling and make it event driven.

The Win XP64 kernel is pretty well optimized, but I did find one bad function that I patched to improve the overall speed. I think there's a thread about it, but just cranking the priority is a lot easier and service pack proof than patching system dlls.

Vista64 probably has a few Rtl functions that are sub-optimal. Microsoft doesn't really take advantage of the almost global compatibility with SIMD when compiling 64 bit code (IE no current x86 64 processor is without SSE2 extensions). Function that drivers seem to call a lot are the best candidates for patching, when I get Vista64 I'll do a little decompiling and see what turns up.

Wonder if its possible to recreate a system dll with customized/optimized functions then make a slip streamed copy of your install cd/dvd with the new dll. Not sure of the kernel integrity checks would bug out or not.
Post 13 Apr 2007, 02:37
View user's profile Send private message AIM Address Yahoo Messenger Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3175
Location: Denmark
f0dder 13 Apr 2007, 12:23
r22 wrote:

Wonder if its possible to recreate a system dll with customized/optimized functions then make a slip streamed copy of your install cd/dvd with the new dll. Not sure of the kernel integrity checks would bug out or not.

I don't think this is a good idea... it's too much bother doing this, it will be nuked by windows update, and the system will probably also bitch about it because it detects the DLLs as modified (drivers are even worse, requiring signing and all that).

So, in-memory patching is probably the best route to take. Can probably even be made pseudo-generic, if replacement code size <= original code size... but of course doing the patching is a bit tricky.
Post 13 Apr 2007, 12:23
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2, 3  Next

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.