• 0

VB6 Hack?


Question

i've came across this block of code that executes machine code real time like i could type this in a text box and it would execute it

578B7C240C33C00FA2891F895704894F085F33C0C3

Which is just a simple routine to execute CPUID

now the code im using i downloaded and im not to sure on how it works so i was wondering if someone could explain it to me so i can do more with it thanks :D

Option Explicit

Private Type TPROC
hMem As Long
vtPtr As Long
End Type
Private aProc() As TPROC

Private Declare Function GlobalAlloc Lib "kernel32" (ByVal wFlags As Long, ByVal dwBytes As Long) As Long
Private Declare Function GlobalLock Lib "kernel32" (ByVal hMem As Long) As Long
Private Declare Function GlobalFree Lib "kernel32" (ByVal hMem As Long) As Long
Private Declare Function GlobalUnlock Lib "kernel32" (ByVal hMem As Long) As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)

Function CpuID(ByVal strBuf As Long) As Long
RASM "578B7C240C33C00FA2891F895704894F085F33C0C3"
End Function

Private Sub Class_Initialize()
Dim b As Long
Dim a(1 To 12) As Byte
CpuID VarPtr(a(1))
End Sub

Private Sub RASM(s As String)
s = Replace$(s, " ", "")
Dim i As Long, aSize As Long, aB() As Byte
aSize = Len(s) \ 2

ReDim Preserve aB(1 To aSize)
For i = 1 To aSize
aB(i) = Val("&H" & Mid$(s, i * 2 - 1, 2))
Next

Static cp As Long
ReDim Preserve aProc(cp)
Dim hMem As Long, lPtr As Long
hMem = GlobalAlloc(0, aSize)
lPtr = GlobalLock(hMem)
CopyMemory ByVal lPtr, aB(1), aSize
GlobalUnlock hMem

aProc(cp).hMem = hMem
aProc(cp).vtPtr = VTable(cp)
VTable(cp) = lPtr
cp = cp + 1
End Sub

Private Sub Class_Terminate()
On Error GoTo E
Dim i As Long
For i = 0 To UBound(aProc)
VTable(i) = aProc(i).vtPtr
GlobalFree aProc(i).hMem
Next
E:
End Sub

Private Property Get VTable(ByVal Index As Long) As Long
Dim p As Long
Index = &H1C + Index * 4
CopyMemory p, ByVal ObjPtr(Me), 4
CopyMemory VTable, ByVal p + Index, 4
End Property

Private Property Let VTable(ByVal Index As Long, ByVal ProcPtr As Long)
Dim p As Long
Index = &H1C + Index * 4
CopyMemory p, ByVal ObjPtr(Me), 4
CopyMemory ByVal p + Index, ProcPtr, 4
End Property



so yeah thats pretty much it in a class module if anyone knows the exact (or even close to) details on how this work please let me know ^_^

the above code is fully operational if others wish to use it

Credit to Damian for this code he left this comment inthe class module

'

' Asmippets by Damian (Assembler Snippets)

' the way of calling procedures in machine codes from VB

'

' well, it's so hard to comment this stuff... if you're really eager to,

' you'd carefully step thru each single line of it and read tons

' of MSDN articles. if not, heh, it wasn't worth to comment it.

'

' general idea - replace VTable entries of class factory interface

' by links to pre-allocated memory blocks with our code.

' not a fastest way but works in both IDE and EXE, p-code and native.

'

' fastest way is replacing proc bodies in global modules - eliminates

' overhead of class methods calling and COM parameters passing. but

' no way to make it work in IDE except of using stuff like

' CallWindowProc - but this gets us back to call overhead and screws

' parameters passing.

'

not sure what the whole vtable entry class factory thingy is

and wonder if anyone knows how to implement the faster way which is the proc bodies (3rd paragraph) minus callwindowproc

Link to comment
https://www.neowin.net/forum/topic/533650-vb6-hack/
Share on other sites

5 answers to this question

Recommended Posts

  • 0
awesome thank you very much

hehe this your code? very ingenious :p

Damian's code is his code... my code is my code... but searching the net recently when published the article, i found this thread and thought you might want to read my detailed explaination about how these things work and what can be accomplished with.

PS: the embedding native code technique I've learned >10 yrs ago, when still using VB6 for daily work.

Best regards,

Link to comment
https://www.neowin.net/forum/topic/533650-vb6-hack/#findComment-588668183
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • I am not a fan of haptic feedback touchpads. I've owned a Surface Laptop 7 (Snapdragon) with one and a Lenovo Slim (Intel), and I hated both to the point where I purchased different laptops. It's not that they don't work most of the time; it's that they don't work 100% of the time, and there is no advantage from a user's perspective over a good mechanical trackpad like what's on a ThinkPad X1 or a Yoga 9i. I do not believe that I'll buy another haptic feedback touchpad laptop again in the near future.
    • Works fine here too. About this build, I don't like to download any kind of Windows, from any site except Microsoft. The mod might work, but I don't know what it's inside. Can contain malware, backdoors... Long time ago I've used something like this but reversed - it was 98se with the look and some functionality  of XP. Or, later XP with Vista look. But I made it myself. Not downloaded from obscure sites.
    • Rockstar gives last-gen GTA V players free upgrades tomorrow by Pulasthi Ariyasinghe Rockstar is preparing to launch Grand Theft Auto VI later this year, but ahead of that, the company has revealed a new offer for some Grand Theft Auto V owners. It today announced that Xbox One and PlayStation 4 version owners of the 2013-released title will soon be receiving a free upgrade to the current generation version. The studio released the Xbox Series X|S and PlayStation 5 version of Grand Theft Auto V back in 2022, bringing significant upgrades to the original console editions. This included 60 FPS gameplay at up to 4K resolution, as well as major upgrades to textures, draw distance, and audio. Faster load times, ray tracing elements, and HDR support were also added with it. While this new and enhanced version needed a new purchase of the game to jump in, now Rockstar has decided to make it a free upgrade, dropping the $40 price tag entirely on consoles. "Beginning tomorrow, those who own any PS4 version or the digital Xbox One version of Grand Theft Auto V will be able to upgrade to the PS5 or Xbox Series X|S versions at no additional cost, and experience the best versions of GTA V and GTA Online," said the company in an official blog post. The free upgrade offer will be released tomorrow, June 18, for all Xbox One and PlayStation 4 owners of Grand Theft Auto V. Players who will be jumping in on the offer will want to check how to migrate their GTA Online profile from last-generation to current-generation consoles by heading over here. The offer lands ahead of The Kortz Center Heist hitting Grand Theft Auto Online, where players and crews will be tasked with stealing priceless international art from a prestigious gallery in Pacific Bluffs. It doesn't look like Rockstar plans to stop updating its previous game even with Grand Theft Auto VI being on the horizon. The latest title is slated to launch on November 19, 2026, across Xbox Series X|S and PlayStation 5.
    • Now comes with a money back guarantee instead of a replacement! Hah
  • Recent Achievements

    • One Month Later
      Vincian earned a badge
      One Month Later
    • First Post
      Jocimo earned a badge
      First Post
    • Week One Done
      suprememobiles48 earned a badge
      Week One Done
    • One Month Later
      Windows Guy earned a badge
      One Month Later
    • One Month Later
      Prasann earned a badge
      One Month Later
  • Popular Contributors

    1. 1
      +primortal
      510
    2. 2
      +Edouard
      172
    3. 3
      PsYcHoKiLLa
      89
    4. 4
      Steven P.
      76
    5. 5
      neufuse
      69
  • Tell a friend

    Love Neowin? Tell a friend!