very simple. To avoid the engine must load a few thousand const-values every time when i run a script - and then my own constants also - its eating up time and i guess of the more than 5000 that are poked to memory if Uses "UI" we might use a few hundreds per script, if at all. And then the names - what const names are available for %MB_ ??? - yes, a lot.
Can you tell what is the difference between this
Begin Const
$SE_CREATE_TOKEN_NAME = "SeCreateTokenPrivilege"
$SE_ASSIGNPRIMARYTOKEN_NAME = "SeAssignPrimaryTokenPrivilege"
$SE_LOCK_MEMORY_NAME = "SeLockMemoryPrivilege"
$SE_INCREASE_QUOTA_NAME = "SeIncreaseQuotaPrivilege"
$SE_UNSOLICITED_INPUT_NAME = "SeUnsolicitedInputPrivilege"
$SE_MACHINE_ACCOUNT_NAME = "SeMachineAccountPrivilege"
$SE_TCB_NAME = "SeTcbPrivilege"
$SE_SECURITY_NAME = "SeSecurityPrivilege"
$SE_TAKE_OWNERSHIP_NAME = "SeTakeOwnershipPrivilege"
$SE_LOAD_DRIVER_NAME = "SeLoadDriverPrivilege"
$SE_SYSTEM_PROFILE_NAME = "SeSystemProfilePrivilege"
$SE_SYSTEMTIME_NAME = "SeSystemtimePrivilege"
$SE_PROF_SINGLE_PROCESS_NAME = "SeProfileSingleProcessPrivilege"
$SE_INC_BASE_PRIORITY_NAME = "SeIncreaseBasePriorityPrivilege"
$SE_CREATE_PAGEFILE_NAME = "SeCreatePagefilePrivilege"
$SE_CREATE_PERMANENT_NAME = "SeCreatePermanentPrivilege"
$SE_BACKUP_NAME = "SeBackupPrivilege"
$SE_RESTORE_NAME = "SeRestorePrivilege"
$SE_SHUTDOWN_NAME = "SeShutdownPrivilege"
$SE_DEBUG_NAME = "SeDebugPrivilege"
$SE_AUDIT_NAME = "SeAuditPrivilege"
$SE_SYSTEM_ENVIRONMENT_NAME = "SeSystemEnvironmentPrivilege"
$SE_CHANGE_NOTIFY_NAME = "SeChangeNotifyPrivilege"
$SE_REMOTE_SHUTDOWN_NAME = "SeRemoteShutdownPrivilege"
End Const
and this :
Alias Function As Equate
Alias Type As Enum_Const
Enum_Const String_SE
Equate CREATE_TOKEN_NAME() As String : Equate = "SeCreateTokenPrivilege" : End Equate
Equate ASSIGNPRIMARYTOKEN_NAME() As String : Equate ="SeAssignPrimaryTokenPrivilege" : End Equate
Equate LOCK_MEMORY_NAME() As String : Equate ="SeLockMemoryPrivilege" : End Equate
Equate INCREASE_QUOTA_NAME() As String : Equate ="SeIncreaseQuotaPrivilege" : End Equate
Equate UNSOLICITED_INPUT_NAME() As String : Equate ="SeUnsolicitedInputPrivilege" : End Equate
Equate MACHINE_ACCOUNT_NAME() As String : Equate ="SeMachineAccountPrivilege" : End Equate
Equate TCB_NAME() As String : Equate ="SeTcbPrivilege" : End Equate
Equate SECURITY_NAME() As String : Equate ="SeSecurityPrivilege" : End Equate
Equate TAKE_OWNERSHIP_NAME() As String : Equate ="SeTakeOwnershipPrivilege" : End Equate
Equate LOAD_DRIVER_NAME() As String : Equate ="SeLoadDriverPrivilege" : End Equate
Equate SYSTEM_PROFILE_NAME() As String : Equate ="SeSystemProfilePrivilege" : End Equate
Equate SYSTEMTIME_NAME() As String : Equate ="SeSystemtimePrivilege" : End Equate
Equate PROF_SINGLE_PROCESS_NAME () As String : Equate ="SeProfileSingleProcessPrivilege" : End Equate
Equate INC_BASE_PRIORITY_NAME () As String : Equate ="SeIncreaseBasePriorityPrivilege" : End Equate
Equate CREATE_PAGEFILE_NAME () As String : Equate ="SeCreatePagefilePrivilege" : End Equate
Equate CREATE_PERMANENT_NAME () As String : Equate ="SeCreatePermanentPrivilege" : End Equate
Equate BACKUP_NAME() As String : Equate ="SeBackupPrivilege" : End Equate
Equate RESTORE_NAME() As String : Equate ="SeRestorePrivilege" : End Equate
Equate SHUTDOWN_NAME() As String : Equate ="SeShutdownPrivilege" : End Equate
Equate DEBUG_NAME() As String : Equate ="SeDebugPrivilege" : End Equate
Equate AUDIT_NAME() As String : Equate ="SeAuditPrivilege" : End Equate
Equate SYSTEM_ENVIRONMENT_NAME() As String : Equate ="SeSystemEnvironmentPrivilege" : End Equate
Equate CHANGE_NOTIFY_NAME() As String : Equate ="SeChangeNotifyPrivilege" : End Equate
Equate REMOTE_SHUTDOWN_NAME() As String : Equate ="SeRemoteShutdownPrivilege" : End Equate
end Enum_Const
Global SE# as String_SE
Dim a$ as String = SE#.BACKUP_NAME
msgbox a$
Right. It is only available after Global SE#. Not poked to memory nor variables table
it could be better if the top line were
to make it unnecessary to repeat "() As String : Equate = "..." : End Equate
String - on top - all equates in an enumeration are of the same type.
There can only be one of this udt if the last line (actually End Type) would finally dimension it and it were no more possible
to dim anything else as String_SE because String_SE is only the name for this example - actually SE# ends with that numbering symbol # - it works to have subelements but it could be restricted in Local/Global/Dim/Redim.
No Variables name neither a type to dim As must end with # in a Dim-statement
If Keyword "Type" for this "Enumerated Constant" is replaced by another keyword or combination of keywords "Enum" & "Const" it should be not a problem to make the "End Enum Const" finally dimension the Global UDT with the Name given in the beginning.
It could be Enum Equate as well but I used it to replace keyword Function. so i had to use it 3 times per line
(BUG: thinAir will not realize "Function fName() :Return something : End Function " on one line as valid function.
But using Alias Function As Equate works fine.
Final syntax of camouflaged Type-functions to Enumerate Equates can be simpler- no parenthesis nor anything else - just the result to return has to be assigned.
Begin Equate SE# As String
LOAD_DRIVER_NAME = "SeLoadDriverPrivilege"
' function will always return this value
' - so its not possible to change it once the script runs
'....
End Equate
These constants are from WinApi "NT Defined Privileges" - just taken for the example
for the purpose of reading something in the msgbox
Bookmarks