News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Equates of Windows.inc sorted by value and name

Started by jj2007, December 01, 2023, 12:52:25 PM

Previous topic - Next topic

jj2007

include \masm32\MasmBasic\MasmBasic.inc
  Init
  Cls 5
  Dim o$()
  Recall "\Masm32\include\Windows.inc", i$()
  xor ecx, ecx
  For_ each esi in i$()
.if Rinstr(esi, "equ", 1+4) ; from the right, case-insensitive, full word
add eax, 4 ; go just behind the "equ"
void Val(eax) ; convert e.g. "equ 123h"
.if edx!=-127 ; flag not a number
xchg eax, edi ; eax is a bit too volatile ;-)
Let o$(ecx)=Str$("%0000000000u\t", edi)+esi
inc ecx
.endif
.endif
  Next
  QSort o$()
  Store "SortedWindowsIncEquates.txt", o$()
  lea edi, [o$(?)-10] ; upper bound-10
  For_ ecx=0 To eax-1
.if ecx<10 || ecx>=edi
.if Zero?
PrintLine "..."
.endif
PrintLine Mid$(o$(ecx), Instr_(o$(ecx), Tb$)+1)
.endif
  Next
  Print Str$("%i entries found", o$(?))
EndOfCode

Output:
_MM_HINT_NTA                    equ 0
ABE_LEFT                            equ 0
ABM_NEW                              equ 0h
ABN_STATECHANGE                      equ 0h
AC_LINE_OFFLINE                      equ 0h
AC_SRC_OVER                      equ 00h
ACCESS_ALLOWED_ACE_TYPE              equ 0h
ACCESS_MIN_MS_ACE_TYPE equ (0h)
ACCESS_OBJECT_GUID equ 0
AddrMode1616                        equ 0
...
SP_ERROR                            equ -1
SSRVOPT_RESET                      equ -1
START_PAGE_GENERAL              equ 0FFFFFFFFh
SV2GV_CURRENTVIEW      equ 0ffffffffh
TIME_ZONE_ID_INVALID            equ 0FFFFFFFFh
UCSCHAR_INVALID_CHARACTER        equ 0ffffffffh
WAIT_FAILED              equ -1
WAVE_MAPPER                          equ -1
WH_MIN                              equ -1
WH_MSGFILTER                        equ -1

Might be useful if you see a WM_xx message but don't know the name :cool:

NoCforMe

Heh; I have a sorted windows.inc file that I created long ago. Didn't have to go to any programming trouble: just fired up my favorite editor of all time, MultiEdit, selected all the text and told it to sort it. Milliseconds later I had my sorted file (which as you point out is very useful for finding the values of various things).

Unfortunately, MultiEdit no longer runs on Windows (as of Windows 7; it still ran under XP). More's the pity ...
Assembly language programming should be fun. That's why I do it.

jj2007

Quote from: NoCforMe on December 01, 2023, 01:24:50 PMjust fired up my favorite editor of all time, MultiEdit, selected all the text and told it to sort it

I am sure MultiEdit did it correctly, exactly like the snippet above :thumbsup:

JOB_ACCESS_READ                  equ 00000020h
JOB_OBJECT_LIMIT_PRIORITY_CLASS  equ 00000020h
JOB_OBJECT_UILIMIT_GLOBALATOMS   equ 00000020h
JOB_STATUS_OFFLINE                   equ 20h
JOY_BUTTON6                          equ 20h
JOY_RETURNV                          equ 20h
JOYCAPS_POV4DIR                  equ 0020h
KEY_CREATE_LINK                      equ 20h
LANG_URDU equ 20h
LBS_OWNERDRAWVARIABLE                equ 20h
LC_STYLED                            equ 32
LF_FACESIZE                          equ 32
LLKHF_ALTDOWN           equ 20h
LMEM_NODISCARD                       equ 20h
LOAD_LIBRARY_AS_IMAGE_RESOURCE   equ 00000020h
LOCALE_SLONGDATE                     equ 20h

TimoVJL

May the source be with you

jj2007

Timo,

I am sure Notepad++ can "sort lines", but I doubt that you'll get this correctly:
HTTP_QUERY_FROM                 equ 31
IMAGE_REL_IA64_ADDEND            equ 001Fh
INTERNET_STATUS_REQUEST_SENT            equ 31
LOCALE_SSHORTDATE                    equ 1Fh
NS_STDA                          equ (31)
...
JOB_OBJECT_UILIMIT_GLOBALATOMS   equ 00000020h
JOB_STATUS_OFFLINE                   equ 20h
LC_STYLED                            equ 32
LLKHF_ALTDOWN           equ 20h

Sorted first by value of the equate, then alphabetically.

Besides, I'm not sure whether I would allow my IDE to sort my code ;-)

TimoVJL

Your sorting is a special case, where 'equ' is in line in variable positions.
May the source be with you

jj2007

Quote from: TimoVJL on December 01, 2023, 08:57:06 PMYour sorting is a special case, where 'equ' is in line in variable positions.

Yes indeed, that's why I had to write 30 lines of code :biggrin:

I found a bug:
.if Instr_(esi, "equ", 4)  ; full word
should be:
.if Instr_(esi, "equ", 1+4)  ; case insensitive, full word

Corrected above, it finds now 12,975 equates in Windows.inc.

ES_SYSTEM_REQUIRED equ (00000001h)
EVENTLOG_SEQUENTIAL_READ equ 0001h
PWR_SUSPENDREQUEST                  equ 1
PropertyTagCellWidth            EQU 108h
PropertyTagThumbnailImageDescription    EQU 5025h

NoCforMe

Quote from: jj2007 on December 01, 2023, 08:16:32 PM
Quote from: NoCforMe on December 01, 2023, 01:24:50 PMjust fired up my favorite editor of all time, MultiEdit, selected all the text and told it to sort it

I am sure MultiEdit did it correctly, exactly like the snippet above :thumbsup:

Welllll, I guess I'm on the receiving end of some sarcasm here (early in the am so hard to tell). No matter: MultiEdit just did a plain, I guess you'd call it a "lexicographical" sort, which is all I wanted. I don't care if the EQUates are sorted in numerical order: all I wanted was a sorted list of names, which is exactly what I got. (The purpose of the sorted file is to find what's in there and what's not, and what the exact spelling of the EQUate or structure is.)

I'm pretty sure MultiEdit was capable of sorting exactly the way you did, on primary and secondary values. If not, it would have been easy to whip up a macro that would've done the trick.
Assembly language programming should be fun. That's why I do it.