Guidance
指路人
g.yi.org
Software / Reginald / Examples / usb.rex

Register 
新用户注册
Search 搜索
首页 
Home Home
Software
Upload

  
OPTIONS "C_CALL LABELCHECK WINFUNC NOSOURCE"

DO
	FUNCDEF("CreateFileA", "void, str, 32u, 32u, 32u, 32u, 32u, 32u", "kernel32")
	FUNCDEF("CloseHandle", "32u, void", "kernel32")
	storage_device_descriptor = "32u, 32u, 8u, 8u, 8u, 8u, 32u, 32u, 32u, 32u, 32u, 32u, 32u"
	storage_property_query = "32u, 32u, 32u"
	FUNCDEF("DeviceIoControl", "32u, void, 32u, struct STORAGE_PROPERTY_QUERY, 32u, struct STORAGE_DEVICE_DESCRIPTOR stor, 32u, 32u stor, 32u", "kernel32")
	CATCH FAILURE
		CONDITION("M")
		RETURN
END

IF isdriveusb("D") == "YES" THEN SAY ARG(1) || ": is a USB drive."
RETURN

isdriveusb: PROCEDURE
usbtype = 7
filename = "\\?\" || ARG(1) || ":"
device = createfilea(filename, 2147483648, 3, 0, 3, 0, 0)
IF device \= -1 THEN DO
	query.1 = 0; query.2 = 0; query.3 = 0
	IF deviceiocontrol(device, 2954240, query, 12, desc, 40, outbytes, 0) = 1 THEN DO
		IF desc.11 = usbtype THEN DO
			closehandle(device)
			RETURN "YES"
		END
	END
	closehandle(device)
END
ELSE SAY STREAM(filename, "D")
RETURN "NO"
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Sat 2018-5-26  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2010-07-16 20:45:54