[solved] PB a4, debugger quits unexpectedly

Just starting out? Need help? Post your questions and find answers here.
User avatar
DoubleDutch
Addict
Addict
Posts: 3219
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

[solved] PB a4, debugger quits unexpectedly

Post by DoubleDutch »

The debugger quit unexpectedly (both C and asm compilers).

The code that crashed the debugger was the verifyfile procedure in this, it works on previous versions:
(previously I'd tried it on the 32 bit version of PB - so maybe it's a 32/64 bit thing?)

Code: Select all

; wintrust.pbi

;!Author: Gustavo J. Fiorenza (aim: gushhfx)
;!Date: 15/07/2008 - Rev: 1
;!Comments: header of wintrust.pb4
;!License: Bananas.
 
#WTD_UI_NONE 					= 2
#WTD_CHOICE_FILE 				= 1
#WTD_REVOKE_NONE 				= 0
#WTD_STATEACTION_IGNORE 			= 0
#WTD_HASH_ONLY_FLAG 				= $00000200
#WTD_REVOCATION_CHECK_NONE			= $00000010
 
 
;#ERROR_SUCCESS
 
#TRUST_E_PROVIDER_UNKNOWN 			= $800B0001
#TRUST_E_ACTION_UNKNOWN				= $800B0002
#TRUST_E_SUBJECT_FORM_UNKNOWN			= $800B0003
#TRUST_E_SUBJECT_NOT_TRUSTED			= $800B0004
#TRUST_E_NOSIGNATURE				= $800B0100
 
 
;### Thanks Trond!
Macro GUID(name, l1, w1, w2, b1b2, brest)
  DataSection
  name:
    Data.l $l1
    Data.w $w1, $w2
    Data.b $b1b2 >> 8, $b1b2 & $FF
    Data.b $brest >> 40 & $FF
    Data.b $brest >> 32 & $FF
    Data.b $brest >> 24 & $FF
    Data.b $brest >> 16 & $FF
    Data.b $brest >> 8 & $FF
    Data.b $brest & $FF
  EndDataSection
EndMacro
 
GUID(WINTRUST_ACTION_GENERIC_VERIFY_V2, 00AAC56B, CD44, 11D0, 8CC2, 00C04FC295EE)
;###
 
Structure WINTRUST_DATA
 
	cbStruct.l
	pPolicyCallbackData.l
	pSIPClientData.l
	dwUIChoice.l
	fdwRevocationChecks.l
	dwUnionChoice.l
 
	StructureUnion
		*pFile.WINTRUST_FILE_INFO
		*pCatalog.WINTRUST_CATALOG_INFO
		*pBlob.WINTRUST_BLOB_INFO
		*pSgnr.WINTRUST_SGNR_INFO
		*pCert.WINTRUST_CERT_INFO
	EndStructureUnion
 
	dwStateAction.l
	hWVTStateData.l
	*pwszURLReference
	dwProvFlags.l
	dwUIContext.l
 
EndStructure
 
Structure WINTRUST_FILE_INFO
  cbStruct.l
  *pcwszFilePath
  hFile.l
  pgKnownSubject.l
EndStructure

Procedure.l VerifyFile( Filename.s )
 
	Define.l WindowsMajorVersion 	= (GetVersion_()&$ffff)&$ff
 
	If(WindowsMajorVersion < 5)
		ProcedureReturn 2;
	EndIf
 
	Define.WINTRUST_DATA 		WinTD
	Define.WINTRUST_FILE_INFO 	wf
 
	Define.l gAction 			= ?WINTRUST_ACTION_GENERIC_VERIFY_V2
	Define.s wszPath 			= Space(#MAX_PATH*2)
 
	PokeS( @wszPath, FileName, Len(FileName)+1, #PB_Unicode )
 
	With wf
		\cbStruct 			= SizeOf(WINTRUST_FILE_INFO)
		\hFile 				= #Null
		\pcwszFilePath 			= @wszPath
	EndWith
 
	With WinTD
		\cbStruct 			= SizeOf(WINTRUST_DATA)
		\dwUIChoice 			= #WTD_UI_NONE
		\dwUnionChoice 			= #WTD_CHOICE_FILE
		\fdwRevocationChecks 		= #WTD_REVOKE_NONE
		\pFile 				= wf
		\dwStateAction 			= #WTD_STATEACTION_IGNORE
		\dwProvFlags 			= #WTD_HASH_ONLY_FLAG | #WTD_REVOCATION_CHECK_NONE
	EndWith
 
	ProcedureReturn WinVerifyTrust_( 0, gAction, WinTD )
 
EndProcedure

Procedure.s TrustStatus( ReturnCode.l )
	Select ReturnCode
		Case #ERROR_SUCCESS
			ProcedureReturn "Trusted"
		Case #TRUST_E_PROVIDER_UNKNOWN
			ProcedureReturn "Provider Unknown"
		Case #TRUST_E_SUBJECT_FORM_UNKNOWN
			ProcedureReturn "Form Unknown"
		Case #TRUST_E_SUBJECT_NOT_TRUSTED
			ProcedureReturn "Not Trusted"
		Case #TRUST_E_NOSIGNATURE
			ProcedureReturn "Not signed"
		Default
			ProcedureReturn "Unknown code: "+Str(ReturnCode)
	EndSelect
EndProcedure
 
Last edited by DoubleDutch on Tue Sep 07, 2021 12:16 pm, edited 1 time in total.
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
infratec
Always Here
Always Here
Posts: 6817
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: PB a4, debugger quits unexpectedly

Post by infratec »

.l vartiables can not store an address with x64

You have to use .i, because .l is only 32bit.

Example:

Code: Select all

Define.l gAction 			= ?WINTRUST_ACTION_GENERIC_VERIFY_V2
Should be

Code: Select all

Define.i gAction 			= ?WINTRUST_ACTION_GENERIC_VERIFY_V2
User avatar
DoubleDutch
Addict
Addict
Posts: 3219
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Re: PB a4, debugger quits unexpectedly

Post by DoubleDutch »

Well spotted, that works now - so not a bug (32/64 bit thing).
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
infratec
Always Here
Always Here
Posts: 6817
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: [solved] PB a4, debugger quits unexpectedly

Post by infratec »

In general you should always use .i

Only if an API requires a dword or a long, then you should use .l
Post Reply