您的位置:程序门 -> vb -> 基础类



我想读取一个程序的内存,但是怎么告诉vb,是哪个程序,具体代码怎么写?谢谢


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


我想读取一个程序的内存,但是怎么告诉vb,是哪个程序,具体代码怎么写?谢谢[已结贴,结贴人:hackboymzw]
发表于:2007-03-09 11:00:18 楼主
本人新手,如果答案是要用api的话,请把声明部分也写出来吧,我对api的声明还不太熟练!谢谢大家了!
发表于:2007-03-09 11:10:501楼 得分:50
http://www.google.cn/search?complete=1&hl=zh-cn&q=declare+readprocessmemory&meta=

有很多很多的例子
发表于:2007-03-09 13:32:312楼 得分:50
private   declare   function   globallock   lib   "kernel32 "   (byval   hmem   as   long)   as   long
private   declare   function   globalsize   lib   "kernel32 "   (byval   hmem   as   long)   as   long
private   declare   function   globalunlock   lib   "kernel32 "   (byval   hmem   as   long)   as   long
private   declare   sub   copymemory   lib   "kernel32 "   alias   "rtlmovememory "   (lpvdest   as   any,   lpvsource   as   any,   byval   cbcopy   as   long)
private   declare   function   globalalloc   lib   "kernel32 "   (byval   wflags   as   long,   byval   dwbytes   as   long)   as   long
private   declare   function   globalfree   lib   "kernel32 "   (byval   hmem   as   long)   as   long
        private   mmydata()   as   byte
        private   mmydatasize   as   long
        private   mhmem   as   long
public   enum   englobalmemoryallocationconstants
        gmem_fixed   =   &;amp;h0
        gmem_discardable   =   &;amp;h100
        gmem_moveable   =   &;amp;h2
        gmem_nocompact   =   &;amp;h10
        gmem_nodiscard   =   &;amp;h20
        gmem_zeroinit   =   &;amp;h40
end   enum
public   sub   copyfromhandle(byval   hmemhandle   as   long)
        dim   lret   as   long
        dim   lptr   as   long
        lret   =   globalsize(hmemhandle)
        if   lret   >   0   then
                mmydatasize   =   lret
                lptr   =   globallock(hmemhandle)
                if   lptr   >   0   then
redim   mmydata(0   to   mmydatasize   -   1)   as   byte
copymemory   mmydata(0),   byval   lptr,   mmydatasize
call   globalunlock(hmemhandle)
                end   if
        end   if
end   sub
'\\   --[copytohandle]--------------------
'           ---------
'\\   copies   the   private   data   to   a   memory  
'           handle
'\\   passed   in
'\\   ------------------------------------
'           ---------
public   sub   copytohandle(byval   hmemhandle   as   long)
        dim   lsize   as   long
        dim   lptr   as   long
        '\\   don 't   copy   if   its   empty
        if   not   (mmydatasize   =   0)   then
                lsize   =   globalsize(hmemhandle)
                '\\   don 't   attempt   to   copy   if   zero   size..
                '           .
                if   lsize   >   0   then
if   lptr   >   0   then
        copymemory   byval   lptr,   mmydata(0),   lsize
        call   globalunlock(hmemhandle)
end   if
                end   if
        end   if
end   sub
是上面這個嗎?在planet-source-code.com上有

   
//**************************************
        //          
        //windows   api/global   declarations   for   :p
        //           ossible   sharable   vb   memory
        //**************************************
        //          
        declare   function   readprocessmemory   lib   "kernel32 "   alias   "readprocessmemory "   (byval   hprocess   as   long,   lpbaseaddress   as   any,   lpbuffer   as   any,   byval   nsize   as   long,   lpnumberofbyteswritten   as   long)   as   long
        declare   function   writeprocessmemory   lib   "kernel32 "   alias   "writeprocessmemory "   (byval   hprocess   as   long,   lpbaseaddress   as   any,   lpbuffer   as   any,   byval   nsize   as   long,   lpnumberofbyteswritten   as   long)   as   long
        declare   function   getcurrentprocessid   lib   "kernel32 "   alias   "getcurrentprocessid "   ()   as   long
        declare   function   openprocess   lib   "kernel32 "   (byval   dwdesiredaccess   as   long,   byval   binherithandle   as   long,   byval   dwprocessid   as   long)   as   long
        public   const   specific_rights_all   =&;amp;h0000ffff  
        public   const   standard_rights_required   =   &;amp;h000f0000  
        public   const   standard_rights_all   =   &;amp;h001f0000  
===============================================================
        dim   a   as   long
        a   =   'process   id   to   open
        dim   b   as   long
        b   =   openprocess((specific_rights_all   and   standard_rights_all),   false,   a)
        'opens   a   process   handle   for   memory   access
        ---
        dim   a   as   long
        dim   b   as   long
        dim   c   as   long
        dim   d   as   boolean
        dim   e   as   long
        dim   f   as   long
        d   =   readprocessmemory(a,   byval   b,   byval   varptr(c),   4,   e)   <--   reads   from   a   openprocess   handle 's   memory   address.
        d   =   writeprocessmemory(a,   byval   b,   c,   4,   e)   <--   writes   instead   of   reads.
发表于:2007-03-09 13:44:243楼 得分:0
支持一下
发表于:2007-03-09 18:53:014楼 得分:0
感谢yourlin(我只是民工),但是代码好复杂,哪位大哥能解释一下吗?
发表于:2007-03-09 19:11:295楼 得分:0
该回复于2007-12-28 17:56:28被管理员或版主删除
发表于:2007-03-11 23:16:376楼 得分:0
public   enum   englobalmemoryallocationconstants
        gmem_fixed   =   &;amp;h0
        gmem_discardable   =   &;amp;h100
        gmem_moveable   =   &;amp;h2
        gmem_nocompact   =   &;amp;h10
        gmem_nodiscard   =   &;amp;h20
        gmem_zeroinit   =   &;amp;h40
end   enum

这里为什么老是红字啊?提示 "缺少表达式 "


快速检索

最新资讯
热门点击