Skip to content
MPGHThe Dark Arts
/
RegisterLog in
Forum
Community
What's NewLatest posts across the boardTrendingHottest threads right nowSubscribedThreads you follow
Discussion
GeneralIntroductionsEntertainmentDebate FortFlaming & Rage
Board
News & AnnouncementsMPGH TimesSuggestions & HelpGiveaways
More Sections
Art & Graphic DesignProgrammingHackingCryptocurrency
Hacks & Cheats
Games
ValorantCS2 / CS:GOCall of Duty / WarzoneFortniteApex LegendsEscape From Tarkov
+14 moreLeague of LegendsGTA VMinecraftRustROTMGBattlefieldTroveBattleOnCombat ArmsCrossFireBlackshotRuneScapeDayZDead by Daylight
Resources
Game Hacking TutorialsReverse EngineeringGeneral Game HackingAnti-CheatConsole Game Hacking
Tools
Game Hacking ToolsTrainers & CheatsHack/Release NewsNew
Submit a release →Share your cheat, tool, or config with the community.
AINEW
AI Tools
General & DiscussionPrompt EngineeringLLM JailbreaksHotAI Agents & AutomationLocal / Open Models
AI × Gaming
AI Aimbots & VisionML Anti-CheatGame Bots & Automation
Create
AI Coding / Vibe CodingAI Art & MediaAI Voice & TTS
The AI frontier →Where game hacking meets modern machine learning. Jump in.
Marketplace
Buy & Sell
SellingBuyingTradingUser Services
Trust & Safety
Middleman LoungeMarketplace TalkVouch Copy Profiles
Money
Cryptocurrency TalkCurrency ExchangeWork & Job Offers
Start selling →List accounts, services, and goods. Use the middleman to trade safe.
MPGH The Dark Arts

A community for offensive security research, reverse engineering, and AI.

Community

ForumMarketplaceSearch

Account

RegisterLog in

Legal

Privacy PolicyForum RulesHelp & FAQ
© 2026 MPGH · All rights reserved.Built by the community, for the community. For educational purposes onlyContent is shared for security research and education — we don't condone illegal use. You're responsible for complying with applicable laws. Use at your own risk.
Home › Forum › Programming › Visual Basic Programming › [Help]WriteProcessMemory - Write byte array?

[Help]WriteProcessMemory - Write byte array?

Posts 1–15 of 30 · Page 1 of 2
master131
[MPGH]master131
[Help]WriteProcessMemory - Write byte array?
Is it possible to inject an array of bytes? (lol, fail title)
I tried this, didn't work:

[highlight=vb.net] Public Declare Function VirtualAllocEx Lib "kernel32" ( _
ByVal hProcess As Integer, _
ByVal lpAddress As Integer, _
ByVal dwSize As Integer, _
ByVal flAllocationType As Integer, _
ByVal flProtect As Integer) As Integer

Public Declare Function WriteProcessMemory Lib "kernel32" ( _
ByVal hProcess As Integer, _
ByVal lpBaseAddress As Integer, _
ByVal lpBuffer As Byte(), _
ByVal nSize As Integer, _
ByRef lpNumberOfBytesWritten As Integer) As Integer

Private Declare Function CloseHandle Lib "kernel32" Alias "CloseHandle" ( _
ByVal hObject As Integer) As Integer

Public Declare Function CreateRemoteThread Lib "kernel32" ( _
ByVal hProcess As Integer, _
ByVal lpThreadAttributes As Integer, _
ByVal dwStackSize As Integer, _
ByVal lpStartAddress As Integer, _
ByVal lpParameter As Integer, _
ByVal dwCreationFlags As Integer, _
ByRef lpThreadId As Integer) As Integer

Public Declare Function OpenProcess Lib "kernel32" ( _
ByVal dwDesiredAccess As Integer, _
ByVal bInheritHandle As Integer, _
ByVal dwProcessId As Integer) As Integer

Public Declare Function GetProcAddress Lib "kernel32" ( _
ByVal hModule As Integer, ByVal lpProcName As String) As Integer

Private Declare Function GetModuleHandle Lib "Kernel32" Alias "GetModuleHandleA" ( _
ByVal lpModuleName As String) As Integer

Private TargetProcessHandle As Integer
Private pfnStartAddr As Integer
Public Const MEM_COMMIT = 4096
Public Const PAGE_READWRITE = 4
Public Const PROCESS_CREATE_THREAD = (&H2)
Public Const PROCESS_VM_OPERATION = (&H8)
Public Const PROCESS_VM_WRITE = (&H20)

Private Sub doCrap()
Dim TargetProcess As Process() = Process.GetProcessesByName("test")
TargetProcessHandle = OpenProcess(PROCESS_CREATE_THREAD Or PROCESS_VM_OPERATION Or PROCESS_VM_WRITE, False, TargetProcess(0).Id)
pfnStartAddr = GetProcAddress(GetModuleHandle("Kernel32"), "LoadLibraryA")
Dim LoadLibParamAdr As Integer
Dim fileBytes() As Byte = IO.File.ReadAllBytes("C:\test.dll")
Dim LoadLibParamAdr As Integer = VirtualAllocEx(TargetProcessHandle, 0, UBound(fileBytes), MEM_COMMIT, PAGE_READWRITE)
WriteProcessMemory(TargetProcessHandle, LoadLibParamAdr, fileBytes, UBound(fileBytes), 0)
CreateRemoteThread(TargetProcessHandle, 0, 0, pfnStartAddr, LoadLibParamAdr, 0, 0)
CloseHandle(TargetProcessHandle)
End Sub[/highlight]

I'm pretty sure it's something to do with LoadLibParamAdr or WriteProcessMemory. Btw, I'm just testing various injection methods.
#1 · edited 15y ago · 15y ago
freedompeace
freedompeace
Yes it is.. That's the point of writing to memory - you writes bytes.

Would help but can't see code now (mobile mode) :L
#2 · 15y ago
master131
[MPGH]master131
Quote Originally Posted by freedompeace View Post
Yes it is.. That's the point of writing to memory - you writes bytes.

Would help but can't see code now (mobile mode) :L
No but the standard way of injecting something just involves in passing the string of the DLL location. I'm trying to pass an array of bytes which contains the bytes of a DLL.
#3 · 15y ago
freedompeace
freedompeace
Quote Originally Posted by master131 View Post
No but the standard way of injecting something just involves in passing the string of the DLL location. I'm trying to pass an array of bytes which contains the bytes of a DLL.
Hmm... to save both you and I some trouble, I'm going to go ahead and say you can't do that , not how you're doing it ..

Injecting a DLL = reference to DLL location.
#4 · 15y ago
master131
[MPGH]master131
Quote Originally Posted by freedompeace View Post


Hmm... to save both you and I some trouble, I'm going to go ahead and say you can't do that , not how you're doing it ..

Injecting a DLL = reference to DLL location.
Daum. Oh well then.
/solved now
#5 · 15y ago
Jason
Jason
I remember talking to david about this a few days back coincidentally, he seems to think it IS in fact possible, though as freedom said, not with your current method. I'm 'Memory Retarded' (not my memory, but my comprehension of program memory ) so David got rather exasperated at me, perhaps you should ask him, you may have more luck than I did understanding.,
#6 · 15y ago
Void
Void
The problem with this is that modules are loaded into memory once, and they aren't loaded in a single programs allocated memory.

I'll do a bit of research on this for you, see what I can come up with.

Edit: Wow I'm dumb, I'm pretty sure this technique is called manual mapping.
#7 · edited 15y ago · 15y ago
IA
Iamazn1
If you knew what the code did (instead of random copy/paste), you'd know why the parameter is a string. DLL injection is not using WriteProcessMemory to write the path to the DLL, there is much more than that.
#8 · edited 15y ago · 15y ago
Void
Void
Quote Originally Posted by Iamazn1 View Post
If you knew what the code did (instead of random copy/paste), you'd know why the parameter is a string. DLL injection is not using WriteProcessMemory to write the path to the DLL, there is much more than that.
You mad bro? Don't be a hater.

Anyway, the LoadLibrary function does the writing of the memory for you, so you don't have to do it yourself. In short, you give it a path, it looks for the path and checks if the DLL exists, if it does, it loads the DLL into some allocated memory and calls the module's entry point.

I'm guessing you can do this yourself with VirtualAlloc and WriteProcessMemory then call the main function ( export the main function so you can explicitly find the function's address ) you'd just be rewriting another version of LoadLibrary. Except, LoadLibrary probably fills some hidden data structures somewhere in the kernel, like which modules are loaded, how many modules, base address, dll path, threads, etc etc.
#9 · 15y ago
master131
[MPGH]master131
Quote Originally Posted by Iamazn1 View Post
If you knew what the code did (instead of random copy/paste), you'd know why the parameter is a string. DLL injection is not using WriteProcessMemory to write the path to the DLL, there is much more than that.
I did say that it was a fail title
#10 · 15y ago
IA
Iamazn1
Quote Originally Posted by master131 View Post
I did say that it was a fail title
I wasn't referring to your title.
#11 · 15y ago
topblast
topblast
If this work.... maybe i can get injection method for my Blue file... i dont like outputing to temporary location... which takes time to create the file
#12 · 15y ago
IA
Iamazn1
Quote Originally Posted by topblast View Post
If this work.... maybe i can get injection method for my Blue file... i dont like outputing to temporary location... which takes time to create the file
If you knew what the Injection code actually did, you'd know that writing the Byte Array to the Process's Memory instead of the DLL Path won't work.
#13 · 15y ago
WH
whit
Quote Originally Posted by Iamazn1 View Post
If you knew what the Injection code actually did, you'd know that writing the Byte Array to the Process's Memory instead of the DLL Path won't work.
Dude STFU..
No one wants you here Trolling your wannabe pro ness
#14 · 15y ago
Void
Void
Quote Originally Posted by Iamazn1 View Post
If you knew what the Injection code actually did, you'd know that writing the Byte Array to the Process's Memory instead of the DLL Path won't work.
I hope you know LoadLibrary does exactly this.

Edit: Agreed with whit.
#15 · 15y ago
Posts 1–15 of 30 · Page 1 of 2

Post a Reply

Tags for this Thread

None