Publié : ven. 04/juin/2004 19:55
Je suis pris ce week-end...
J'envoie un code lundi.
J'envoie un code lundi.
Code : Tout sélectionner
Declare privilege(pid)
privilege(GetCurrentProcessId_())
Structure PROCESSENTRY32
dwSize.l
cntUsage.l
th32ProcessID.l
th32DefaultHeapID.l
th32ModuleID.l
cntThreads.l
th32ParentProcessID.l
pcPriClassBase.l
dwFlags.l
szExeFile.b[260]
EndStructure
If OpenLibrary (0,"kernel32.dll")=0
MessageRequester("","Echec initialisation")
end
Endif
s=CallFunction(0,"CreateToolhelp32Snapshot",274,0)
If s
DefType.PROCESSENTRY32 Proc32
Proc32\dwSize = SizeOf(PROCESSENTRY32)
If CallFunction(0,"Process32First",s, @Proc32)
if lcase(peeks(@Proc32\szExeFile))="winword.exe"
idwin=proc32\th32ProcessID
endif
While CallFunction (0, "Process32Next", s, @Proc32)
if lcase(peeks(@Proc32\szExeFile))="winword.exe"
idwin=proc32\th32ProcessID
endif
Wend
EndIf
EndIf
if idwin=0:end:endif
debug "id word="+str(idwin)
Structure systeminfo
dwOemID.l
pagesize.l
minaddress.l
maxaddress.l
dwActiveProcessorMask.l
dwNumberOfProcessors.l
dwProcessorType.l
dwAllocationGranularity.l
dwReserved.l
EndStructure
info.systeminfo
GetSystemInfo_(@info)
Structure meminfo
baseaddress.l
base.l
allocprotect.l
regionsize.l
state.l
protect.l
type.l
EndStructure
debug "page size "+Str(info\pagesize)
debug "min address "+Str(info\minaddress)
debug "max address "+Str(info\maxaddress)
debug "Word:"
ch=OpenProcess_($1F0FFF,1,idwin)
mem=0:bloc=0
pos=info\minaddress
pinfo.meminfo
While pos<info\maxaddress
VirtualQueryEx_(ch,pos,@pinfo,SizeOf(meminfo))
If pinfo\state=$1000
mem=mem+pinfo\regionsize
debug str(pos)+" à "+str(pos+pinfo\regionsize-1)+" : réservé"
if pinfo\type=$20000
debug "non partagée"
endif
EndIf
pos=pos+pinfo\regionsize
Wend
debug "total mémoire utilisée : "+str(mem)
Procedure privilege(pid)
ph=OpenProcess_($1F0FFF,1,pid)
OpenProcessToken_(ph,$20,@h)
Dim p.s(29)
p(0)="SeAssignPrimaryTokenPrivilege"
p(1)="SeAuditPrivilege"
p(2)="SeBackupPrivilege"
p(3)="SeChangeNotifyPrivilege"
p(4)="SeCreateGlobalPrivilege"
p(5)="SeCreatePagefilePrivilege"
p(6)="SeCreatePermanentPrivilege"
p(7)="SeCreateTokenPrivilege"
p(8)="SeDebugPrivilege"
p(9)="SeEnableDelegationPrivilege"
p(10)="SeImpersonatePrivilege"
p(11)="SeIncreaseBasePriorityPrivilege"
p(12)="SeIncreaseQuotaPrivilege"
p(13)="SeLoadDriverPrivilege"
p(14)="SeLockMemoryPrivilege"
p(15)="SeMachineAccountPrivilege"
p(16)="SeManageVolumePrivilege"
p(17)="SeProfileSingleProcessPrivilege"
p(18)="SeRemoteShutdownPrivilege"
p(19)="SeRestorePrivilege"
p(20)="SeSecurityPrivilege"
p(21)="SeShutdownPrivilege"
p(22)="SeSyncAgentPrivilege"
p(23)="SeSystemEnvironment"
p(24)="SeSystemProfilePrivilege"
p(25)="SeSystemtimePrivilege"
p(26)="SeTakeOwnershipPrivilege"
p(27)="SeTcbPrivilege"
p(28)="SeUndockPrivilege"
p(29)="SeUnsolicitedInputPrivilege"
Structure LI
low.l
high.l
EndStructure
Structure luidandattributes
pluid.LI
attrib.l
EndStructure
Structure privileges
count.l
privilege.luidandattributes
EndStructure
shut.LI
result=1
For i=0 To 29
LookupPrivilegeValue_(0,@p(i),@shut)
newprivilege.privileges
newprivilege\count=1
newprivilege\privilege\attrib=2
newprivilege\privilege\pluid\low=shut\low
newprivilege\privilege\pluid\high=shut\high
result=result*AdjustTokenPrivileges_(h,0,newprivilege,SizeOf(privileges),0,0)
Next i
ProcedureReturn result
EndProcedure
il donne les chiffre gagnant du loto ??hardy a écrit : je relisais un passage de l'excellent Theory of Numbers de Hardy&Wright...)