01-29-2025, 06:05 PM
This program will detect if it is being run in a WINE emulator.
Note that hackers will place your programs to run in WINE so that they can
pirate or hack your programs.
This is to detect whether the user is using a WINE emulator and to do the
necessary counter action.
Please let me know if you encounter issue with this program.
Note that hackers will place your programs to run in WINE so that they can
pirate or hack your programs.
This is to detect whether the user is using a WINE emulator and to do the
necessary counter action.
Please let me know if you encounter issue with this program.
Code:
' Detect Wine.bas
#COMPILE EXE
#DIM ALL
#INCLUDE "Win32Api.inc"
' Constants for registry access
%KEY_QUERY_VALUE = &H0001
%KEY_WOW64_64KEY = &H0100
'===================
FUNCTION PBMAIN() AS LONG
IF IsRunningInWine() THEN
? "Running in Wine."
ELSE
? "Not running in Wine."
END IF
END FUNCTION
'=========================
FUNCTION IsRunningInWine() AS LONG
' Check for Wine-specific environment variables
LOCAL szBuffer AS ASCIIZ * 256
LOCAL lResult AS LONG
' Check for the "WINEDLLPATH" environment variable
lResult = GetEnvironmentVariable( stWineP, szBuffer, SIZEOF(szBuffer))
IF lResult > 0 THEN
' Wine environment variable found
FUNCTION = 1
EXIT FUNCTION
END IF
' Check for the "WINE" environment variable
lResult = GetEnvironmentVariable(stWine, szBuffer, SIZEOF(szBuffer))
IF lResult > 0 THEN
' Wine environment variable found
FUNCTION = 1
EXIT FUNCTION
END IF
' Check for Wine-specific registry keys
LOCAL hwnKey AS LONG
LOCAL dwType AS LONG
LOCAL dwSize AS LONG
' Check for Wine version in the registry
' Software\Wine
lResult = RegOpenKeyEx(%HKEY_LOCAL_MACHINE, swWine , _
0, %KEY_QUERY_VALUE OR %KEY_WOW64_64KEY, hwnKey)
IF lResult = 0 THEN
' Wine registry key found
FUNCTION = 1
RegCloseKey(hwnKey)
EXIT FUNCTION
END IF
' Check for Wine-specific files
' C:\windows\system32\winecfg.exe
IF GetFileAttributes(stWcfg) <> %INVALID_FILE_ATTRIBUTES THEN
' Wine-specific file found
FUNCTION = 1
EXIT FUNCTION
END IF
' If none of the above checks pass, assume not running in Wine
FUNCTION = 0
END FUNCTION
' ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
' WINEDLLPATH
FUNCTION stWineP() AS STRING
#REGISTER NONE
LOCAL pstr AS DWORD
LOCAL a$
a$ = NUL$(11)
pstr = STRPTR(a$)
! mov esi, pstr
! mov BYTE PTR [esi+6], 76
! mov BYTE PTR [esi+2], 78
! mov BYTE PTR [esi+0], 87
! mov BYTE PTR [esi+4], 68
! mov BYTE PTR [esi+3], 69
! mov BYTE PTR [esi+5], 76
! mov BYTE PTR [esi+10], 72
! mov BYTE PTR [esi+7], 80
! mov BYTE PTR [esi+1], 73
! mov BYTE PTR [esi+8], 65
! mov BYTE PTR [esi+9], 84
FUNCTION = a$
END FUNCTION
' ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
' ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
' WINE
FUNCTION stWine() AS STRING
#REGISTER NONE
LOCAL pstr AS DWORD
LOCAL a$
a$ = NUL$(4)
pstr = STRPTR(a$)
! mov esi, pstr
! mov BYTE PTR [esi+1], 73
! mov BYTE PTR [esi+3], 69
! mov BYTE PTR [esi+2], 78
! mov BYTE PTR [esi+0], 87
FUNCTION = a$
END FUNCTION
' ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
' ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
' Software\Wine
FUNCTION swWine() AS STRING
#REGISTER NONE
LOCAL pstr AS DWORD
LOCAL a$
a$ = NUL$(13)
pstr = STRPTR(a$)
! mov esi, pstr
! mov BYTE PTR [esi+7], 101
! mov BYTE PTR [esi+9], 87
! mov BYTE PTR [esi+0], 83
! mov BYTE PTR [esi+6], 114
! mov BYTE PTR [esi+3], 116
! mov BYTE PTR [esi+4], 119
! mov BYTE PTR [esi+1], 111
! mov BYTE PTR [esi+10], 105
! mov BYTE PTR [esi+2], 102
! mov BYTE PTR [esi+11], 110
! mov BYTE PTR [esi+12], 101
! mov BYTE PTR [esi+5], 97
! mov BYTE PTR [esi+8], 92
FUNCTION = a$
END FUNCTION
' ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
' ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
' C:\windows\system32\winecfg.exe
FUNCTION stWcfg() AS STRING
#REGISTER NONE
LOCAL pstr AS DWORD
LOCAL a$
a$ = NUL$(31)
pstr = STRPTR(a$)
! mov esi, pstr
! mov BYTE PTR [esi+24], 99
! mov BYTE PTR [esi+25], 102
! mov BYTE PTR [esi+17], 51
! mov BYTE PTR [esi+22], 110
! mov BYTE PTR [esi+14], 116
! mov BYTE PTR [esi+15], 101
! mov BYTE PTR [esi+27], 46
! mov BYTE PTR [esi+9], 115
! mov BYTE PTR [esi+12], 121
! mov BYTE PTR [esi+7], 111
! mov BYTE PTR [esi+2], 92
! mov BYTE PTR [esi+23], 101
! mov BYTE PTR [esi+29], 120
! mov BYTE PTR [esi+26], 103
! mov BYTE PTR [esi+28], 101
! mov BYTE PTR [esi+8], 119
! mov BYTE PTR [esi+18], 50
! mov BYTE PTR [esi+30], 101
! mov BYTE PTR [esi+4], 105
! mov BYTE PTR [esi+19], 92
! mov BYTE PTR [esi+6], 100
! mov BYTE PTR [esi+11], 115
! mov BYTE PTR [esi+0], 67
! mov BYTE PTR [esi+1], 58
! mov BYTE PTR [esi+5], 110
! mov BYTE PTR [esi+3], 119
! mov BYTE PTR [esi+10], 92
! mov BYTE PTR [esi+20], 119
! mov BYTE PTR [esi+21], 105
! mov BYTE PTR [esi+16], 109
! mov BYTE PTR [esi+13], 115
FUNCTION = a$
END FUNCTION
' ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤