hasherezade / masm_shc

A helper utility for creating shellcodes. Cleans MASM file generated by MSVC, gives refactoring hints.
MIT License
156 stars 30 forks source link

masm_shc string inline error #1

Closed b1tg closed 3 years ago

b1tg commented 3 years ago

masm_shc string inline error

reproduce

source file test.cpp:

#include <stdio.h>
void main() {
    char* temp[] = {"123", "xxx", "bbb"};
    return;
}

use test.bat to build:

cl /c /FA /GS- test.cpp
masm_shc.exe test.asm test_a.asm
ml test_a.asm /link /entry:main

cl.exe output test.asm:


; Line 7
    mov DWORD PTR _temp$[ebp], OFFSET $SG5652
    mov DWORD PTR _temp$[ebp+4], OFFSET $SG5653
    mov DWORD PTR _temp$[ebp+8], OFFSET $SG5654
; Line 8

masm_shc.exe output test_a.asm:

; Line 7
    CALL after_$SG5652
$SG5652 DB  '123', 00H
after_$SG5652:
    POP  DWORD

;   mov DWORD PTR _temp$[ebp], OFFSET $SG5652
    CALL after_$SG5653
$SG5653 DB  'xxx', 00H
after_$SG5653:
    POP  DWORD

expect:

POP DWORD PTR _temp$[ebp]

actual:

POP DWORD
hasherezade commented 3 years ago

Thank you for your contribution, it works very well now!