0

I'm looking for a way to execute bytes sequence like a function. For example, I've got a sequence:

[Byte[]]$bytes = 0xb8, 0x15, 0x03, 0x00, 0x00, 0xbb, 0x42, 0x00, 0x00, 0x00, 0x03, 0xc3

which is:

mov eax, 315h
mov ebx, 42h
add eax, ebx
ret

I know about execution this via VirtualAlloc but I'm looking for a way based on the reflection and\or generic delegates.

  • 1
    You're looking to execute assembly-language statements? How does PowerShell come into play? – mklement0 Jan 13 '19 at 12:55
  • I'm looking for [something like this](https://stackoverflow.com/a/39625987). There is unsafe code in that post and it seems there is no feature as unsafe code in PowerShell (without Add-Type, of course). _Assembly.Load_ requires entire assembly. I need to convert bytes to function which will be executed after. Maybe it can be solved with DynamicMethod and OpCodes? – Oganesyan Jan 13 '19 at 14:33
  • 1
    I believe you're swatting flies with a sledgehammer. It would be good if you'd give us some background about your issue. – montonero Jan 14 '19 at 08:29

0 Answers0