After Ctl+Alt+Delete is pressed, continous Alt key is sent

Windows specific questions.
coderJeff
Site Admin
Posts: 3023
Joined: Nov 04, 2005 14:23
Location: Ontario, Canada
Contact:

Re: After Ctl+Alt+Delete is pressed, continous Alt key is sent

Postby coderJeff » Aug 23, 2018 4:12

jj2007, thanks. So easy to find now I know what it is called. :)

Getting the proc address means the function exists. Still have to call it, no?

Code: Select all

sub hi()
   print "hi"
end sub

var p = procptr(hi)
print p  '' address
p()      '' call function through pointer 

I'm going to play with it and report the results. It's just a bit of work for me to get WinXP up and running.

I am thinking of fixing a number of gfxlib2 bugs next, and want to do this one too. If this works, there's a few options for us, for example, allowing fbc-32 DirectX to run on Wow64, but using GetKeyboardState() instead of IDirectInput, and so on.
jj2007
Posts: 1216
Joined: Oct 23, 2016 15:28
Location: Roma, Italia
Contact:

Re: After Ctl+Alt+Delete is pressed, continous Alt key is sent

Postby jj2007 » Aug 23, 2018 4:26

coderJeff wrote:Getting the proc address means the function exists. Still have to call it, no?
Yep, that's the problem: It does exist on XP-32. And calling is a bit more complicated, since you need a process ID, access rights, ...

Btw one of the top google hits is How can a 32-bit program detect that it is launched in a 64-bit Windows?:
Keep in mind that the IsWow64Process function is included only in 64-bit Windows versions.
WRONG.
coderJeff
Site Admin
Posts: 3023
Joined: Nov 04, 2005 14:23
Location: Ontario, Canada
Contact:

Re: After Ctl+Alt+Delete is pressed, continous Alt key is sent

Postby coderJeff » Aug 23, 2018 6:11

Win98, WinXP (limited user), Win7 (standard user) works as expected with this:

Code: Select all

#include "windows.bi"

function IsWow64() as boolean
   function = false
   type LPFN_ISWOWPROCESS as function(byval hProcess as HANDLE, byval Wow64Process as PBOOL) as WINBOOL
   dim h as HMODULE = LoadLibrary("kernel32")
   if( h ) then
      dim f as LPFN_ISWOWPROCESS = cast( LPFN_ISWOWPROCESS ptr, GetProcAddress( h, "IsWow64Process" ) )
      if( f ) then
         dim b as WINBOOL = 0
         if( f(GetCurrentProcess(), @b ) ) then
            function = cbool(b)
         end if
      end if
      FreeLibrary( h )
   end if    
end function

#ifdef __FB_64BIT__
   print "64 bit exe running on win64"
#else
   if( IsWow64() ) then
      print "32 bit exe running on WoW64"
   else
      print "32 bit exe running on win32"
   end if
#endif

I'm cheating a little here, basically the 32/64 bit is known because fbc knows it. When compiling the gfxlib2 need to use something else like __X86_64__ or similar.

Side note, the dim f as LPFN_ISWOWPROCESS = cast( LPFN_ISWOWPROCESS, GetProcAddress( h, "IsWow64Process" ) ) is OK in fbc 1.05 but will cause a warning in the latest fbc 1.06 master repo. That's because I recently added more thorough function pointer type checking, but maybe a little too much. At least it only a warning, but will have to look at that, again.
marpon
Posts: 340
Joined: Dec 28, 2012 13:31
Location: Paris - France

Re: After Ctl+Alt+Delete is pressed, continous Alt key is sent

Postby marpon » Aug 23, 2018 7:20

my proposal to check if os is 32 or 64bits

Code: Select all

#include "windows.bi"

Function OsBits() as Long
    #IfDef __FB_64BIT__
        Return 64                                'if compiled under 64, its normal to be 64
    #Else
        Dim handle          as HANDLE
        Dim ret1              as Long       
        ' Assume initially that this is not a Wow64 process     
        ' and check  if IsWow64Process function exists
        handle = GetProcAddress(GetModuleHandle( "kernel32") , "IsWow64Process")       
        If handle > 0 Then                       ' IsWow64Process function exists
            ' Now use the function to determine if we are running under Wow64
            IsWow64Process(GetCurrentProcess() , @ret1)
        End If
        If ret1 Then Return 64
        Return 32
    #EndIf
End Function
jj2007
Posts: 1216
Joined: Oct 23, 2016 15:28
Location: Roma, Italia
Contact:

Re: After Ctl+Alt+Delete is pressed, continous Alt key is sent

Postby jj2007 » Aug 23, 2018 8:36

You are both cheating quite a lot: GetCurrentProcess() is your own current process, and while building that one, you got the info you need from the compiler. IIRC it is __FB64__ or so.

Asking from a 32-bit process whether the OS is 64-bit is a bit more difficult (though not impossible).
Asking from a 64-bit process whether the OS is 64-bit is trivial: the answer is YES.
marpon
Posts: 340
Joined: Dec 28, 2012 13:31
Location: Paris - France

Re: After Ctl+Alt+Delete is pressed, continous Alt key is sent

Postby marpon » Aug 23, 2018 9:25

@jj2007
Asking from a 32-bit process whether the OS is 64-bit is a bit more difficult (though not impossible).


it is the purpose of my Function OsBits() as Long

if you get 64
you are running a 64 bits app on 64 os or you have a 32 bits app under 64 bits os (via Wow64)

if you get 32
you are running a 32 bits app under 32 bits os
jj2007
Posts: 1216
Joined: Oct 23, 2016 15:28
Location: Roma, Italia
Contact:

Re: After Ctl+Alt+Delete is pressed, continous Alt key is sent

Postby jj2007 » Aug 23, 2018 10:34

marpon,

Congrats, you are right! I had misunderstood the documentation: IsWow64Process means "it's a 32-bit process running under Wow64" - and the latter doesn't exist in Win32. Problem solved, thanks a lot for teaching me new things ;-)

P.S.: I've credited you in my updated post at the Masm32 forum. Thanks again.
MrSwiss
Posts: 3222
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: After Ctl+Alt+Delete is pressed, continous Alt key is sent

Postby MrSwiss » Aug 23, 2018 13:09

marpon
Posts: 340
Joined: Dec 28, 2012 13:31
Location: Paris - France

Re: After Ctl+Alt+Delete is pressed, continous Alt key is sent

Postby marpon » Aug 23, 2018 15:37

@jj2007

P.S.: I've credited you in my updated post at the Masm32 forum. Thanks again.

thanks for credit, my name is marpon not marpov , but was just a converted c code, available freely in internet...
Pierre Bellisle
Posts: 36
Joined: Dec 11, 2016 17:22

Re: After Ctl+Alt+Delete is pressed, continous Alt key is sent

Postby Pierre Bellisle » Aug 23, 2018 17:12

Also, there is GetNativeSystemInfo() available since Windows XP.

Code: Select all

#include "Windows.bi"
Dim SysInfo AS SYSTEM_INFO
GetNativeSystemInfo(@SysInfo) 'Available since Windows XP.
MessageBox(HWND_DESKTOP, "Windows is " & _
           IIf(SysInfo.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_AMD64, "64", "32") & _
           " bit", "System info", MB_OK OR MB_TOPMOST)
jj2007
Posts: 1216
Joined: Oct 23, 2016 15:28
Location: Roma, Italia
Contact:

Re: After Ctl+Alt+Delete is pressed, continous Alt key is sent

Postby jj2007 » Aug 23, 2018 17:50

marpon wrote:thanks for credit, my name is marpon not marpov
Corrected.

@Pierre: Thanks, another good option!

Return to “Windows”

Who is online

Users browsing this forum: No registered users and 1 guest