voilla un code pour les programmeur "avancé" ahhm.. comment "hacker loll" un gadget qui est crée par un autre processus!!!!
le code :
Code : Tout sélectionner
;//Celtic88 ::::only for educational purposes
Import "kernel32.lib"
IsWow64Process.l(hProcess.i, *Wow64Process)
EndImport
Procedure.i Window_MemInit(hWnd)
Protected iPid.l
If GetWindowThreadProcessId_(hWnd,@iPid)
If iPid = GetCurrentProcessId_()
ProcedureReturn 1
EndIf
#PROCESS_QUERY_LIMITED_INFORMATION = $1000
ProcedureReturn OpenProcess_(#PROCESS_VM_OPERATION| #PROCESS_VM_READ| #PROCESS_VM_WRITE|#PROCESS_QUERY_LIMITED_INFORMATION,0,iPid)
EndIf
EndProcedure
Procedure.l Window_Is64Bit(hWinInit)
If Not hWinInit:ProcedureReturn 0:EndIf
If hWinInit = 1
ProcedureReturn Bool(#PB_Compiler_Processor = #PB_Processor_x64)
EndIf
Protected IsWow64.l
IsWow64Process(hWinInit, @IsWow64)
ProcedureReturn Bool(IsWow64 = 0)
EndProcedure
Procedure.l Window_IsUnicode(hWnd)
ProcedureReturn IsWindowUnicode_(hWnd)
EndProcedure
Procedure.l Window_MemWrite(hWinInit,pAllocMemory ,*pSrce,pSrceSize.l)
If Not hWinInit Or Not pAllocMemory :ProcedureReturn 0:EndIf
If hWinInit = 1
ProcedureReturn pSrceSize
EndIf
Protected nByt.l
WriteProcessMemory_(hWinInit,pAllocMemory,*pSrce,pSrceSize,@nByt)
ProcedureReturn nByt
EndProcedure
Procedure.i Window_MemAllocate(hWinInit,*pmem, iSize.l ,IfWrite.b = 0)
If Not hWinInit:ProcedureReturn 0:EndIf
If hWinInit = 1
ProcedureReturn *pmem
EndIf
Protected pAllocMemory = VirtualAllocEx_(hWinInit, 0, iSize, #MEM_RESERVE|#MEM_COMMIT, #PAGE_READWRITE)
If pAllocMemory And IfWrite
Window_MemWrite(hWinInit,pAllocMemory ,*pmem,iSize)
EndIf
ProcedureReturn pAllocMemory
EndProcedure
Procedure.l Window_MemRead(hWinInit,pAllocMemory,*pDes,pDesSize.l)
If Not hWinInit Or Not pAllocMemory :ProcedureReturn 0:EndIf
If hWinInit = 1
ProcedureReturn pDesSize
EndIf
Protected nByt.l
ReadProcessMemory_(hWinInit,pAllocMemory,*pDes,pDesSize,@nByt)
ProcedureReturn nByt
EndProcedure
Procedure.l Window_FreeMemAllocate(hWinInit,pAllocMemory,iSize.l)
If Not hWinInit Or Not pAllocMemory :ProcedureReturn 0:EndIf
If hWinInit = 1
ProcedureReturn 1
EndIf
ProcedureReturn VirtualFreeEx_(hWinInit,pAllocMemory,iSize, #MEM_RELEASE)
EndProcedure
Procedure.l Window_FreeMemInit(hWinInit)
If Not hWinInit:ProcedureReturn 0:EndIf
If hWinInit = 1
ProcedureReturn 1
EndIf
ProcedureReturn CloseHandle_(hWinInit)
EndProcedure
important ce code il faut le lancer en premier
Code : Tout sélectionner
If OpenWindow(0, 100, 100, 300, 400, "ListIconGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ListIconGadget(0, 5, 5, 290, 390, "Nom", 100, #PB_ListIcon_FullRowSelect | #PB_ListIcon_AlwaysShowSelection)
AddGadgetColumn(0, 1, "Adresse", 250)
AddGadgetItem(0, -1, "Harry Rannit"+Chr(10)+"12 Parliament Way, Battle Street, By the Bay")
AddGadgetItem(0, -1, "Ginger Brokeit"+Chr(10)+"130 PureBasic Road, BigTown, CodeCity")
Repeat
Evenement = WaitWindowEvent()
Until Evenement = #PB_Event_CloseWindow
EndIf
Code : Tout sélectionner
IncludeFile "window_mem.pb"
Structure LVITEM_x64 Align #PB_Structure_AlignC
Mask.l
Item.l
SubItem.l
State.l
StateMask.l
Text.q
TextMax.l
Image.l
Param.q
Indent.l
GroupID.l
Columns.l
pColumns.q
piColFmt.q
iGroup.l
EndStructure
Structure LVITEM_x84 Align #PB_Structure_AlignC
Mask.l
Item.l
SubItem.l
State.l
StateMask.l
Text.l
TextMax.l
Image.l
Param.l
Indent.l
GroupID.l
Columns.l
pColumns.l
piColFmt.l
iGroup.l
EndStructure
Procedure.l ListView_InsertItem(hWnd, sText.s, iIndex.l = -1, iParam.l = 0)
If iIndex = -1
iIndex = SendMessage_(hWnd, #LVM_GETITEMCOUNT, 0, 0)
EndIf
Protected hRWinInit=Window_MemInit(hWnd)
If Not hRWinInit
Debug "error Window_MemInit()"
ProcedureReturn -1
EndIf
Protected isUnicode.l = Window_IsUnicode(hWnd)
Protected iTextTyp.l
If isUnicode
iTextTyp = #PB_Unicode
Else
iTextTyp = #PB_UTF8
EndIf
Protected ptext = AllocateMemory( StringByteLength(sText,iTextTyp)+1)
If Not ptext
Debug "error local AllocateMemory()"
ProcedureReturn -1
EndIf
PokeS(ptext,sText,-1,iTextTyp)
Protected pRString=Window_MemAllocate(hRWinInit,ptext,MemorySize(ptext))
If Not pRString
Debug "error remote Window_MemAllocate()"
ProcedureReturn -1
EndIf
Window_MemWrite(hRWinInit,pRString,ptext,MemorySize(ptext))
Protected Is64Bit.l= Window_Is64Bit(hRWinInit)
Protected tItemx64.LVITEM_x64
Protected tItemx84.LVITEM_x84
Protected itemsize.l ,tItem.i
If Is64Bit
itemsize = SizeOf(tItemx64)
tItem = tItemx64
tItemx64\TextMax=Len(sText)
tItemx64\Mask=#LVIF_TEXT|#LVIF_PARAM
tItemx64\Item=iIndex
tItemx64\Param=iParam
tItemx64\Text=pRString
Else
itemsize = SizeOf(tItemx84)
tItem = tItemx84
tItemx84\TextMax=Len(sText)
tItemx84\Mask=#LVIF_TEXT|#LVIF_PARAM
tItemx84\Item=iIndex
tItemx84\Param=iParam
tItemx84\Text=pRString
EndIf
Protected pRStructur=Window_MemAllocate(hRWinInit,tItem,itemsize)
If Not pRStructur
Debug "error remote Window_MemAllocate()"
ProcedureReturn -1
EndIf
Window_MemWrite(hRWinInit,pRStructur,tItem,itemsize)
Protected iReturn.l
If isUnicode
iReturn = SendMessage_(hWnd, #LVM_INSERTITEMW, 0, pRStructur)
Else
iReturn = SendMessage_(hWnd, #LVM_INSERTITEMA, 0, pRStructur)
EndIf
Window_FreeMemAllocate(hRWinInit,pRStructur,itemsize)
Window_FreeMemAllocate(hRWinInit,pRString,MemorySize(ptext))
Window_FreeMemInit(hRWinInit)
FreeMemory(ptext)
ProcedureReturn iReturn
EndProcedure
Procedure.l ListView_GetItemParam(hWnd, iIndex.l)
Protected hRWinInit=Window_MemInit(hWnd)
If Not hRWinInit
Debug "error Window_MemInit()"
ProcedureReturn -1
EndIf
Protected isUnicode.l = Window_IsUnicode(hWnd)
Protected Is64Bit.l= Window_Is64Bit(hRWinInit)
Protected tItemx64.LVITEM_x64
Protected tItemx84.LVITEM_x84
Protected itemsize.l ,tItem.i
If Is64Bit
itemsize = SizeOf(tItemx64)
tItem = tItemx64
tItemx64\Mask=#LVIF_PARAM
tItemx64\Item=iIndex
Else
itemsize = SizeOf(tItemx84)
tItem = tItemx84
tItemx84\Mask=#LVIF_PARAM
tItemx84\Item=iIndex
EndIf
Protected pRStructur=Window_MemAllocate(hRWinInit,tItem,itemsize)
If Not pRStructur
Debug "error remote Window_MemAllocate()"
ProcedureReturn -1
EndIf
Window_MemWrite(hRWinInit,pRStructur,tItem,itemsize)
Protected iReturn.l
If isUnicode
iReturn = SendMessage_(hWnd, #LVM_GETITEMW, 0, pRStructur)
Else
iReturn = SendMessage_(hWnd, #LVM_GETITEMA, 0, pRStructur)
EndIf
Window_MemRead(hRWinInit,pRStructur,tItem,itemsize)
Protected iParm.l
If Is64Bit
iParm = tItemx64\Param
Else
iParm = tItemx84\Param
EndIf
Window_FreeMemAllocate(hRWinInit,pRStructur,itemsize)
Window_FreeMemInit(hRWinInit)
ProcedureReturn iParm
EndProcedure
Procedure.s ListView_GetItemText(hWnd, iIndex.l, iSubItem.l = 0, TxtLenMax.l=999)
Protected hRWinInit=Window_MemInit(hWnd)
If Not hRWinInit
Debug "error Window_MemInit()"
ProcedureReturn
EndIf
Protected isUnicode.l = Window_IsUnicode(hWnd)
Protected iTextTyp.l
If isUnicode
iTextTyp = #PB_Unicode
Else
iTextTyp = #PB_UTF8
EndIf
Protected sText.s=Space(TxtLenMax)
Protected ptext = AllocateMemory( StringByteLength(sText,iTextTyp)+1)
If Not ptext
Debug "error local AllocateMemory()"
ProcedureReturn
EndIf
Protected pRString=Window_MemAllocate(hRWinInit,ptext,MemorySize(ptext))
If Not pRString
Debug "error remote Window_MemAllocate()"
ProcedureReturn
EndIf
Protected Is64Bit.l= Window_Is64Bit(hRWinInit)
Protected tItemx64.LVITEM_x64
Protected tItemx84.LVITEM_x84
Protected itemsize.l ,tItem.i
If Is64Bit
itemsize = SizeOf(tItemx64)
tItem = tItemx64
tItemx64\TextMax=Len(sText)
tItemx64\Mask=#LVIF_TEXT
tItemx64\SubItem=iSubItem
tItemx64\Text=pRString
Else
itemsize = SizeOf(tItemx84)
tItem = tItemx84
tItemx84\TextMax=Len(sText)
tItemx84\Mask=#LVIF_TEXT
tItemx84\SubItem=iSubItem
tItemx84\Text=pRString
EndIf
Protected pRStructur=Window_MemAllocate(hRWinInit,tItem,itemsize)
If Not pRStructur
Debug "error remote Window_MemAllocate()"
ProcedureReturn
EndIf
Window_MemWrite(hRWinInit,pRStructur,tItem,itemsize)
Protected iReturn.l
If isUnicode
iReturn = SendMessage_(hWnd, #LVM_GETITEMTEXTW, iIndex, pRStructur)
Else
iReturn = SendMessage_(hWnd, #LVM_GETITEMTEXTA, iIndex, pRStructur)
EndIf
Window_MemRead(hRWinInit,pRString,ptext,MemorySize(ptext))
sText = PeekS(ptext,-1,iTextTyp)
Window_FreeMemAllocate(hRWinInit,pRStructur,itemsize)
Window_FreeMemAllocate(hRWinInit,pRString,MemorySize(ptext))
Window_FreeMemInit(hRWinInit)
FreeMemory(ptext)
ProcedureReturn sText
EndProcedure
Procedure.l WNDENUMPROC(hwnd.i, lparam.i)
Protected clasname.s ,GadgetiD.l
clasname = Space(99)
GetClassName_(hwnd,@clasname,99)
GadgetiD = GetDlgCtrlID_(hWnd)
If clasname = #WC_LISTVIEW
PokeI(lparam,hwnd)
ProcedureReturn 0
EndIf
ProcedureReturn 1
EndProcedure
Procedure FindLISTVIEWGadgetIDbyWindowTitle(WindowTitle.s)
Protected hWnd = FindWindow_(0, @WindowTitle)
Protected hWndListIconGadget.i = 0
If hWnd And EnumChildWindows_(hWnd,@WNDENUMPROC(),@hWndListIconGadget) = 0
ProcedureReturn hWndListIconGadget
EndIf
EndProcedure
Define hWndListIconGadget = FindLISTVIEWGadgetIDbyWindowTitle("ListIconGadget")
If Not hWndListIconGadget
MessageBox_(0,"Window does not exist","",16)
End
EndIf
Define itemindex.l = ListView_InsertItem(hWndListIconGadget, "just un test.",-1, 0)
Debug itemindex
Debug ListView_GetItemParam(hWndListIconGadget, itemindex)
MessageBox_(0,ListView_GetItemText(hWndListIconGadget, 1, 1),"",0)
amusez vous bien