473,320 Members | 1,979 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

WriteProcessMemory not working (VB2005)

Hi all,

In my previous topic about a week ago on this forum I attempted to use ReadProcessMemory. After several hours of trying different things, It worked. Next up I tried figuring out WriteProcessMemory. I was hoping that after hours of trying things, it would work. Unfortunately, I can't seem to get this one to work, and also my search on the internet resulted nothing useful.

I got this code, which in my eyes should work without any errors, but VB proves me wrong.

What it should do is pretty simple; press T, encode a message from a listbox from ASCII to Bytes, and write it, Then press Enter.

Expand|Select|Wrap|Line Numbers
  1. Private Sub timerC_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles timerC.Tick
  2.         Const WM_KEYDOWN = &H100
  3.         Const WM_KEYUP = &H101
  4.         Const VK_T = &H54
  5.         Const VK_RETURN = &HD
  6.         Dim hwnd, hprocess, idprocess As Integer
  7.         Dim Automsg As String
  8.         Static msg As Integer
  9.  
  10.         If msg = listC.Items.Count - 1 Then msg = -1
  11.         msg = msg + 1
  12.  
  13.         hwnd = FindWindow(vbNullString, windowname.Text)
  14.         If hwnd < 0 Or hwnd > 0 Then
  15.  
  16.             SendMessage(hwnd, WM_KEYDOWN, VK_T, 0&)
  17.             SendMessage(hwnd, WM_KEYUP, VK_T, 0&)
  18.  
  19.             Wait(120)
  20.  
  21.             GetWindowThreadProcessId(hwnd, idprocess)
  22.             hprocess = OpenProcess(PROCESS_ALL_ACCESS, False, idprocess)
  23.             Automsg = msg
  24.  
  25.             System.Text.Encoding.ASCII.GetBytes(Automsg)
  26.             WriteProcessMemory(hprocess, &H875F34, Automsg, 59, 0&)
  27.             CloseHandle(hprocess)
  28.  
  29.             Wait(120)
  30.  
  31.             SendMessage(hwnd, WM_KEYDOWN, VK_RETURN, 0&)
  32.             SendMessage(hwnd, WM_KEYUP, VK_RETURN, 0&)
  33.  
  34.         ElseIf hwnd = 0 Then
  35.             MsgBox("Cannot find " & windowname.Text), MsgBoxStyle.Critical, "Error!")
  36.             timerC.Enabled = False
  37.             Exit Sub
  38.         End If
  39.  
  40.     End Sub
  41.  
I just can't seem to figure out where the problem is, since it doesn't give any errors.
Though, it doesn't write to memory nor press Enter. It does press T but that's all there is.
Could anyone help fixing my code ?

Any help is appreciated.

Thanks in advance,
Evolution445
Sep 25 '07 #1
2 2099
Anyone has any idea on solving this ?
Thanks
Sep 29 '07 #2
I re-attempted the code again, this time thinking it only writes one character per WriteProcessMemory action.

Expand|Select|Wrap|Line Numbers
  1.         Dim AutomsgByte As Byte
  2.             Automsg = msg
  3.             For i As Integer = 0 To Automsg.Length
  4.                 System.Text.Encoding.ASCII.GetBytes(Automsg)
  5.                 Automsg = AutomsgByte
  6.                 WriteProcessMemory(hprocess, &H471E58, AutomsgByte, 59, 0&)
  7.             Next i
  8.  
Still no result.
If anyone knows how to fix my problem, please let me know.
Thanks!
Sep 30 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Charles Law | last post by:
I have defined LVITEM as follows: <StructLayout(LayoutKind.Sequential)> Private Structure LVITEM Dim mask As Int16 Dim iItem As Int16 Dim iSubItem As Int16 Dim state As Int16 Dim stateMask As...
2
by: STiAT | last post by:
Hello. I tried to find a similar Function to WriteMemory, and couldnt find any memory manipulating functions in dotNET at all. I now wanted to know if there are any similar functions to the...
2
by: Jerry Spence1 | last post by:
1. Is there a more suitable, dedicated newsfeed for VB2005 yet? 2. I'm confused as to which version to get. I work for a small company and we will just need VB2005 on my PC. Therefore that tends...
0
by: Rich | last post by:
Hello, I just upgraded a vb2003 app to vb2005. The vb2003 app had/has a statusbar object - which contains panels and I can see the properties of the statusbar in the properties window in...
1
by: r1100r98 | last post by:
I am having a problem moving the data from a datatable to the SQL2005 table (using VB2005). See code below. The SQL2005 table is empty, the datatable is being filled from a text file, not from...
1
by: erickwan88 | last post by:
I am doing a final year project for my school and is going to provide for an organization, so I am asking for some help on here. Indeed, I have no idea on how to get the input from my pen driver...
15
by: Aalaan | last post by:
I am presently a user of classic vb6 and hang out on those newsgroups. Some of you may be aware that there is a very anti MS and vb2005 feeling there. I have tried to get them to tell me which...
1
by: Jeffrey Christiansen | last post by:
I wanted to add a toggle button to a VB2005 form to be used for a simple Windows Application (i.e. compiled to a "*.exe"), so I added the ActiveX Microsoft Forms Object toggle button, however I...
1
by: Vae07 | last post by:
Ok so here is a brief summary of my problem. I need a pop up form that submits input text box information to a pocket excel workbook upon a command botton click. Text box inputs are checked for...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.