在RMVA使用Fiddle代替win32api
#===============================================================# Vx aceFiddle##===============================================================module Fiddle TYPE_VOID = DL::TYPE_VOIDTYPE_INT = DL::TYPE_INTTYPE_LONG = DL::TYPE_LONGTYPE_VOIDP= DL::TYPE_VOIDPTYPE_FLOAT= DL::TYPE_FLOATTYPE_DOUBLE = DL::TYPE_DOUBLETYPE_CHAR = DL::TYPE_CHARTYPE_SHORT= DL::TYPE_SHORTTYPE_UCHAR= -TYPE_CHARTYPE_USHORT = -TYPE_SHORTTYPE_UINT = -TYPE_INTTYPE_ULONG= -TYPE_LONG#调用约定DEFAULT = :stdcall#========== 函数封装 ==========class Function def initialize(ptr, args, ret, abi = DEFAULT) @ptr= ptr @args = args @ret= ret @calltype = case abi when :stdcall, :STDCALL, 1 then :stdcall when :cdecl, :CDECL, 0 then :cdecl else :stdcall end @cfunc = DL::CFunc.new(ptr, ret, 'fiddle_func', @calltype) end def call(*args) temp_ptrs = [] converted = args.zip(@args).map do |val, type| if type == TYPE_VOIDP if val.nil? 0 elsif val.is_a?(String) #转为 UTF-16LE(Unicode) utf16 = val.encode("UTF-16LE") + "\0\0".encode("UTF-16LE") bin = utf16.force_encoding("ASCII-8BIT") ptr = DL::CPtr temp_ptrs
页:
[1]