File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5318,16 +5318,20 @@ struct VM {
53185318 /* *
53195319 * @brief Check for sldt instruction method
53205320 * @category Windows, x86
5321+ * @note code documentation paper in https://www.aldeid.com/wiki/X86-assembly/Instructions/sldt
53215322 */
53225323 [[nodiscard]] static bool sldt () try {
53235324#if (x86_32 && MSVC)
5324- unsigned short ldtr[5 ] = { 0xEF , 0xBE , 0xAD , 0xDE } ;
5325- unsigned int ldt = 0 ;
5325+ unsigned char ldtr[5 ] = " \xef\xbe\xad\xde " ;
5326+ unsigned long ldt = 0 ;
53265327
5327- _asm sldt ldtr;
5328- ldt = *((u32 *)&ldtr[0 ]);
5328+ __asm {
5329+ sldt word ptr ldtr // 'word ptr' to indicate that we're working with a 16-bit value and avoid compiler warnings
5330+ }
5331+
5332+ ldt = *((unsigned long *)&ldtr[0 ]);
53295333
5330- return (ldt != 0xDEAD0000 );
5334+ return (ldt != 0xdead0000 );
53315335#else
53325336 return false ;
53335337#endif
@@ -5745,20 +5749,18 @@ struct VM {
57455749 * @note paper describing this technique is located at /papers/www.s21sec.com_vmware-eng.pdf (2006)
57465750 * @category Windows
57475751 */
5748- [[nodiscard]] static bool vmware_str () try {
5749- #if (!MSVC || !x86)
5750- return false ;
5751- #elif (x86_32)
5752- unsigned short mem[4 ] = { 0 , 0 , 0 , 0 };
5753-
5754- __asm str mem;
5755-
5756- if ((mem[0 ] == 0x00 ) && (mem[1 ] == 0x40 )) {
5752+ [[nodiscard]] static bool vmware_str () try {
5753+ #if (MSVC && x86_32)
5754+ unsigned short tr = 0 ;
5755+ __asm {
5756+ str ax
5757+ mov tr, ax
5758+ }
5759+ if ((tr & 0xFF ) == 0x00 && ((tr >> 8 ) & 0xFF ) == 0x40 ) {
57575760 return core::add (VMWARE);
57585761 }
5759- #else
5760- return false ;
57615762#endif
5763+ return false ;
57625764 }
57635765 catch (...) {
57645766 debug (" VMWARE_STR: caught error, returned false" );
You can’t perform that action at this time.
0 commit comments