Memory or String opcodes [w/o SF]

Strcat
PHP:
:strcat

// 0@ - destination, 1@ - source
// Example: 0AB1: @strcat 2 destination 0@ source 1@

0AB1: @strlen 1 string 0@ _return: 2@
0AB1: @strlen 1 string 1@ _return: 3@
005A: 0@ += 2@  // (int)
0AB1: @memcpy 3 destination 0@ source 1@ size 3@
005A: 0@ += 3@  // (int)
0AB1: @memset 3 destination 0@ value 0 size 1
0AB2: ret 0

:strlen
{
    Example: 0AB1: @strlen 1 string 1@  _return: 3@
    In: 0@ - text;
    Out: 1@ - size;
}
for 1@ = 0 to 1024
    0A8D: 2@ = read_memory 0@ size 1 virtual_protect 0
    if not 2@ == 0
    jf break
    0@ += 1
end
0AB2: ret 1 1@

Strncpy
PHP:
:strncpy
var
0@ : integer
1@ : integer
2@ : integer
30@ : integer
31@ : integer
end

// 0@ - destination, 1@ - source, 2@ - size
// Example: 0AB1: @strncpy 3 destination 0@ source 1@ size 2@

while 803B:   30@ == 2@  // (int)
    0A8D: 31@ = read_memory 1@ size 1 virtual_protect 0
    0A8C: write_memory 0@ size 1 value 31@ virtual_protect 0
    30@++ // count
    0@++ // dst
    1@++ // src
end
0A8C: write_memory 0@ size 1 value 0 virtual_protect 0 // null terminate
0AB2: ret 0

Strcpy
PHP:
:strcpy
// 0@ - destination, 1@ - source
// Example: 0AB1: @strcpy 2 destination 0@ source 1@

31@ = 1
while 31@ <> 0
    0A8D: 31@ = read_memory 1@ size 1 virtual_protect 0
    0A8C: write_memory 0@ size 1 value 31@ virtual_protect 0
    0@++ // dst
    1@++ // src
end
0AB2: ret 0

Memcpy
PHP:
:memcpy

var
0@ : integer
1@ : integer
2@ : integer
3@ : integer
end

// 0@ - destination, 1@ - source, 2@ - size
// Example: 0AB1: @memcpy 3 destination 0@ source 1@ size 2@

dec(2@)
for 3@ = 0 to 2@
    0A8D: 4@ = read_memory 1@ size 1 virtual_protect 0
    0A8C: write_memory 0@ size 1 value 4@ virtual_protect 0
    1@ += 1
    0@ += 1
end

0AB2: ret 0

Memset
PHP:
:memset

var
0@ : integer
1@ : integer
2@ : integer
3@ : integer
end

// 0@ - destination, 1@ - value, 2@ - size
// Example: 0AB1: @memset 3 destination 0@ value 32 size 1
2@ -= 1
for 3@ = 0 to 2@
0A8C: write_memory 0@ size 1 value 1@ virtual_protect 0
0@ += 1
end

0AB2: ret 0

PHP:
:StrlenA
// 0AB1: @StrlenA 1 String 0@ _Returned: Length 1@
0A8D: 26@ = readmem 0x8580DC sz 4 vp 0 // 0x8580DC - KERNEL32.lstrlenA
0AA7: strlen_addr 26@ num_params 1 pop 0 string 0@ _returned_length 25@
0AB2: ret 1 25@

Credits:
@monday
@springfield
Me
 
Last edited:
Top