PB program delivery string variable

xiaoxiao2021-03-06  71

PB program delivery string variable

We know that you can use the send (Handle, Message #, LOWWORD, LONG) function to complete messaging between different program windows, where the last two parameters are long, so that two parameters can be utilized to deliver digital variables. What if you want to pass? Since each process has its own independent memory address and memory space, it is not possible to obtain variables directly through the method of accessing the variable address.

The method of PB is given below:

Source program:

External function:

Function ulong getcurrentprocessid () library "kernel32.dll"

Function Integer Sndmsg (Long Hwnd, Long Umsg, Long Url, & Ref Blob Info) Library "User32.dll" Alias ​​for "SendMessagea

Constant Long PBM_CUSTOM01 = 1024

program:

If IL_HTARGET <= 0 THEN FINDTARGET () / / Find a window of acceptance variables, mainly using FindWindow to implement if il_htarget> 0 Then String Ls_len // Composition a string URL = " info " string (srctype) to send (SRCTYPE) " String (offlinetype) // Calculate the length of the character to send characters, and convert to a string of length 10 LS_LEN = String (Len (URL)) if LEN (LS_LEN) <10 THEN LS_LEN = Space (10 - LEN (LS_LEN)) LS_LEN END IF / / Translate into BLOB and Sends BLOB LB_SND LB_SND = BLOB (LS_LEN URL) SNDMSG (IL_HTARGET, PBM_CUSTOM01 9, GetCurrentProcessid (), LB_SND) End IF

Target program:

External function:

Function ulong OpenProcess (ulong dwDesiredAccess, ulong bInheritHandle, ulong dwProcessId) LIBRARY "kernel32.dll" Function ulong ReadProcessMemoryStr (ulong hProcess, long lpBaseAddress, ref string lpBuffer, ulong nSize, ref long lpNumberOfBytesWritten) LIBRARY "kernel32.dll" Alias ​​for "ReadProcessMemory "Function ulong ReadProcessMemoryBlob (ulong hProcess, long lpBaseAddress, ref blob lpBuffer, ulong nSize, ref long lpNumberOfBytesWritten) LIBRARY" kernel32.dll "Alias ​​for" ReadProcessMemory "FUNCTION ulong CloseHandle (ulong hObject) LIBRARY" kernel32.dll "

Event PBM_CUSTOM10:

IF (wparam = 0) or (lparam = 0) THEN RETURN

Long ll_nullsetnull (ll_null) long processhndConstant long process_vm_read = 16

processhnd = openprocess (PROCESS_VM_READ, 0, wparam); // read memory data sending process String ls_sizeLong ll_sizels_size = Space (10) // data size ReadProcessMemoryStr (processhnd, lparam, ls_size, 10, ll_null) ll_size = Long (Trim (ls_size)))))

BLOB LB_DATALB_DATA = blob (String (Space (ll_size)))

ReadProcessMemoryBlob (Processh, LPARAM 10, LB_DATA, LL_SIZE, LL_NULL)

String ls_data

Ls_data = string (lb_data) // is good, receive a gift

CloseHandle (Processhnd)

转载请注明原文地址:https://www.9cbs.com/read-87626.html

New Post(0)