qiling icon indicating copy to clipboard operation
qiling copied to clipboard

c++ emulation issue with std::cout << "Hello World!\n";

Open decustom opened this issue 4 years ago • 3 comments

I get an error while emulating following MSVC++ code on Linux: std::cout << d << " Hello World!\n"; However, if I change to use printf("%d Hello World!\n", d); it is able to emulate!

[+] Initiate stack address at 0x7ffffffde000 [+] Loading rootfs/x8664_windows/bin/ConsoleApplication12.exe to 0x140000000 [+] PE entry point at 0x140001524 [+] TEB addr is 0x6030 [+] PEB addr is 0x60b8 [+] Loading rootfs/x8664_windows/Windows/System32/ntdll.dll to 0x7ffff0000000 [+] Done with loading rootfs/x8664_windows/Windows/System32/ntdll.dll [+] Loading rootfs/x8664_windows/Windows/System32/msvcp140.dll to 0x7ffff01f4000 [+] Done with loading rootfs/x8664_windows/Windows/System32/msvcp140.dll [+] Loading rootfs/x8664_windows/Windows/System32/vcruntime140_1.dll to 0x7ffff0285000 [+] Done with loading rootfs/x8664_windows/Windows/System32/vcruntime140_1.dll [+] Loading rootfs/x8664_windows/Windows/System32/vcruntime140.dll to 0x7ffff0291000 [+] Done with loading rootfs/x8664_windows/Windows/System32/vcruntime140.dll [+] Loading rootfs/x8664_windows/Windows/System32/api-ms-win-crt-runtime-l1-1-0.dll to 0x7ffff02aa000 [+] Done with loading rootfs/x8664_windows/Windows/System32/api-ms-win-crt-runtime-l1-1-0.dll [+] Loading rootfs/x8664_windows/Windows/System32/api-ms-win-crt-math-l1-1-0.dll to 0x7ffff02ae000 [+] Done with loading rootfs/x8664_windows/Windows/System32/api-ms-win-crt-math-l1-1-0.dll [+] Loading rootfs/x8664_windows/Windows/System32/api-ms-win-crt-stdio-l1-1-0.dll to 0x7ffff02b3000 [+] Done with loading rootfs/x8664_windows/Windows/System32/api-ms-win-crt-stdio-l1-1-0.dll [+] Loading rootfs/x8664_windows/Windows/System32/api-ms-win-crt-locale-l1-1-0.dll to 0x7ffff02b7000 [+] Done with loading rootfs/x8664_windows/Windows/System32/api-ms-win-crt-locale-l1-1-0.dll [+] Loading rootfs/x8664_windows/Windows/System32/api-ms-win-crt-heap-l1-1-0.dll to 0x7ffff02ba000 [+] Done with loading rootfs/x8664_windows/Windows/System32/api-ms-win-crt-heap-l1-1-0.dll [+] Loading rootfs/x8664_windows/Windows/System32/kernel32.dll to 0x7ffff02bd000 [+] Done with loading rootfs/x8664_windows/Windows/System32/kernel32.dll GetSystemTimeAsFileTime(lpSystemTimeAsFileTime = 0x80000001cfe0) GetCurrentThreadId() = 0x0 GetCurrentProcessId() = 0x7cc QueryPerformanceCounter(lpPerformanceCount = 0x80000001cfe8) = 0x0 _initterm_e(pfbegin = 0x140002228, pfend = 0x140002240) = 0x0 _initterm(pfbegin = 0x140002210, pfend = 0x140002220) _get_initial_narrow_environment() = 0x0 __p___argv() = 0x50009fcd8 __p___argc() = 0x50009fd20 [!] ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@_J@Z is not implemented [!] Emulation Error

decustom avatar Jul 14 '20 11:07 decustom

Need to debug more too see the actual issue.

Well, Windows always a myth and windows + MSVC. i guess we are lost.

xwings avatar Jul 14 '20 13:07 xwings

update issue #333 , we should support C++

xwings avatar Jan 27 '21 02:01 xwings

This is going to be a huge set of functions to support. BTW this specific function translates to: public: class std::basic_ostream<char,struct std::char_traits<char> > & __ptr64 __cdecl std::basic_ostream<char,struct std::char_traits<char> >::operator<<(__int64) __ptr64

learn-more avatar Feb 09 '21 13:02 learn-more

Close for now.

We updated the codebase for Qiling and Unicorn since this issue being posted.

Feel free to try the latest version.

xwings avatar Oct 06 '22 03:10 xwings