The MASM Forum

General => The Workshop => Topic started by: TouEnMasm on May 22, 2013, 11:43:39 PM

Title: a test to know if a handle is a resource handle or a file handle
Post by: TouEnMasm on May 22, 2013, 11:43:39 PM

The test:
Quote
invoke SizeofResource, hInstance,hFile ; hfile = createfile
return 0 on XP but i am not sure it work on any system.
Thanks for testing it,if it don't work , return "BAD TEST..".
Title: Re: a test to know if a handle is a resource handle or a file handle
Post by: TouEnMasm on May 23, 2013, 02:07:13 AM

Seems there is many class.
To use them there is  need to create a c++ library (PROC C)who call those functions.
Title: Re: a test to know if a handle is a resource handle or a file handle
Post by: Gunther on May 23, 2013, 05:06:28 AM
Hi Yves,

here is my output (Windows 7, 64 bit).


GOOD TEST handle isn't a resource


Gunther
Title: Re: a test to know if a handle is a resource handle or a file handle
Post by: Magnum on May 23, 2013, 10:50:00 AM
It didn't work on my XP Sp3.

<?xml version="1.0" encoding="UTF-16"?>
<DATABASE>
<EXE NAME="console.exe" FILTER="GRABMI_FILTER_PRIVACY">
    <MATCHING_FILE NAME="console.exe" SIZE="5120" CHECKSUM="0x46B5A140" MODULE_TYPE="WIN32" PE_CHECKSUM="0x0" LINKER_VERSION="0x0" LINK_DATE="05/22/2013 13:31:30" UPTO_LINK_DATE="05/22/2013 13:31:30" />
</EXE>
<EXE NAME="kernel32.dll" FILTER="GRABMI_FILTER_THISFILEONLY">
    <MATCHING_FILE NAME="kernel32.dll" SIZE="990208" CHECKSUM="0xCC2C4544" BIN_FILE_VERSION="5.1.2600.6293" BIN_PRODUCT_VERSION="5.1.2600.6293" PRODUCT_VERSION="5.1.2600.6293" FILE_DESCRIPTION="Windows NT BASE API Client DLL" COMPANY_NAME="Microsoft Corporation" PRODUCT_NAME="Microsoft® Windows® Operating System" FILE_VERSION="5.1.2600.6293 (xpsp_sp3_gdr.121001-1622)" ORIGINAL_FILENAME="kernel32" INTERNAL_NAME="kernel32" LEGAL_COPYRIGHT="© Microsoft Corporation. All rights reserved." VERFILEDATEHI="0x0" VERFILEDATELO="0x0" VERFILEOS="0x40004" VERFILETYPE="0x2" MODULE_TYPE="WIN32" PE_CHECKSUM="0xFBCBC" LINKER_VERSION="0x50001" UPTO_BIN_FILE_VERSION="5.1.2600.6293" UPTO_BIN_PRODUCT_VERSION="5.1.2600.6293" LINK_DATE="10/03/2012 04:58:13" UPTO_LINK_DATE="10/03/2012 04:58:13" VER_LANGUAGE="English (United States) [0x409]" />
</EXE>
</DATABASE>
Title: Re: a test to know if a handle is a resource handle or a file handle
Post by: TouEnMasm on May 23, 2013, 04:12:55 PM

If it failed on some machine , i change it.

The value of an Handle of resource seem to be greater than the module handle (hinstance).It's not the case for Hfile handle.
The test is:

mov hFile,eax
.if eax < hInstance
invoke printf,TXT("GOOD TEST hFile isn't a resource Handle",10,0)
.else
invoke printf,TXT("BAD TEST hFile isn't a resource Handle",10,0)
.endif
invoke loadrcdatafile,2000,addr fileini
mov eax,fileini.Hmem
.if eax > hInstance
invoke printf,TXT("GOOD TEST Hres is a resource Handle",10,0)
.else
invoke printf,TXT("BAD TEST Hres is a resource Handle",10,0)
.endif
Title: Re: a test to know if a handle is a resource handle or a file handle
Post by: dedndave on May 23, 2013, 06:19:26 PM
xp mce2005, sp3
GOOD TEST hFile isn't a resource Handle
GOOD TEST Hres is a resource Handle
Title: Re: a test to know if a handle is a resource handle or a file handle
Post by: FORTRANS on May 23, 2013, 09:56:52 PM
Hi,

   Windows 2000. "Test_handle is not a valid WIN32 application"

Steve
Title: Re: a test to know if a handle is a resource handle or a file handle
Post by: Siekmanski on May 23, 2013, 11:14:10 PM
OS        : Windows v5.1.2600 Service Pack 3
Processor : Intel(R) Core(TM)2 Quad CPU Q6600  @ 2.40GHz

GOOD TEST hFile isn't a resource Handle
GOOD TEST Hres is a resource Handle
Title: Re: a test to know if a handle is a resource handle or a file handle
Post by: TouEnMasm on May 25, 2013, 06:59:33 AM

The second soluce seems to work.Thanks at all for answers.