VB6-star clearance

Source: Internet
Author: User

A long time ago, at that time, I was not very familiar with the (and not very good yet) Game of mine clearance, and my classmates always showed off in front of me how clever I was. "Advanced, 99 thunder, only three minutes ...", So. Maybe I really need talent. I have to check it for a while and then click the left button, and then go to boom!

One day, I saw an article about "plug-ins for mine clearance" on the web page. I remember that this person was prepared by sink. If I remember correctly, it should be masm32. The article probably means that the layout of Ray is marked, and the target value in the ray area is 0x8f. To locate the coordinates of all mines, the premise is to first find the border of the minefield, that is, the starting point, width, and length. I am afraid it is difficult to find out if I do not disassemble the Code (at least I can understand the binary code. Fortunately, the master is like this: he provides the base of the minefield. I had to pick up people and make changes. I used VB6 to implement a "mine clearing Star ".

Note: The minefield distribution should be established only after you click the first one. Therefore, when you are playing the game, open the Mine Clearance and click the "Mine Clearance Star ".

The principle is very simple, so I won't go into details, just go to the Code:

'_ Killboom. basprivate declare function findwindow lib "USER32" alias "find0000wa" (byval lpclassname as string, _ byval lpwindowname as string) as longprivate declare function getwindowdc lib "USER32" (byval hwnd as long) as longprivate declare function bitblt lib "GDI32" (byval hdestdc as long, _ byval X as long, _ byval y as long, _ byval nwidth as long, _ byval nheight as long, _ byval hsrcdc S long, _ byval xsrc as long, _ byval ysrc as long, _ byval dwrop as long) as longprivate declare function getwindowthreadprocessid lib "USER32" (byval hwnd as long, _ lpdwprocessid as long) as includeclare function OpenProcess lib "Kernel32" (byval dwdesiredaccess as long, _ byval binherithandle as long, _ byval dwprocessid as long) as includeclare function readprocessmemory lib "Ke Rnel32 "(byval hprocess as long, _ lpbaseaddress as any, _ lpbuffer as any, _ byval nsize as long, _ lpnumberofbyteswritten as long) as longprivate declare function closehandle lib "Kernel32" (byval hobject as long) as longprivate declare function releasedc lib "USER32" (byval hwnd as long, _ byval HDC as long) as longprivate declare function setforegroundwindow lib "USER32" (byval hwnd as long) S longprivate declare function postmessage lib "USER32" alias "postmessagea" (byval hwnd as long, _ byval wmsg as long, _ byval wparam as long, _ byval lparam as long) as longprivate const process_all_access = & your const region = & h201private const region = & h202private const region = & h204private const region = & h205' is the base address of the minefield private const total_addr = 56a4private const partition = & h10056a8private const width_addr = & h10056acprivate const area_addr = & h1005361public function killboom () as Boolean '. This is the thunder drive function !! Dim hwnd as long hwnd = findwindow ("", vbnullstring) if hwnd = 0 then killboom = false exit function end if Dim HDC as long dim PID as long dim HP as long HDC = getwindowdc (hwnd) Call getwindowthreadprocessid (hwnd, pid) HP = OpenProcess (process_all_access, 0 &, pid) dim total as long dim height as long dim width as long call readprocessmemory (HP, byval total_addr, byval varptr (total), 4 &, 0 &) Call readprocessmemory (HP, byval height_addr, byval varptr (height), 4 &, 0 &) Call readprocessmemory (HP, byval width_addr, byval varptr (width), 4 &, 0 &) dim size as long dim MEM () as byte size = 32 * height + 16 redim MEM (size) as byte call readprocessmemory (HP, byval area_addr, byval varptr (MEM (0), size, 0 &) dim I as long dim X as long dim y as long for I = 0 to size-1 '. Why, I also forgot, because it was too long to write this code. 'It should have been calculated a little bit.' For example, 16 is the distance from the left side of the Form. '97 is the distance from the top of the Form. x = I mod 32 y = I \ 32 x = 16 + x * 16 Y = 97 + y * 16- 32 If mem (I) = & h8f then' If yes, insert a small red flag call postmessage (hwnd, wm_rbuttondown, 0 &, makeparam (x, y) Call postmessage (hwnd, wm_rbuttonup, 0 &, makeparam (x, y) else 'is not a ray. Open it and call postmessage (hwnd, wm_lbuttondown, 0 &, makeparam (x, y) Call postmessage (hwnd, wm_lbuttonup, 0 &, makeparam (x, y) end if next erase mem call closehandle (HP) Call releasedc (hwnd, HDC) Call setforegroundwindow (hwnd) killboom = trueend functionprivate function makeparam (byval loword as long, byval hiword as long) As long makeparam = (hiword * & h10000) or (loword and & hffff &) end Function

 

To be more elegant, add the hotkey. In this way, enter the shortcut key (Alt + Shift + k) to kill in seconds. Haha (slightly evil ):

'_ Hotkey. bas 'This module is found on the Internet, the link is as follows' @ http://www.cnblogs.com/rosesmall/archive/2012/09/19/2693707.htmlPublic declare function setwindowlong lib "USER32" alias "setwindowlonga" (byval hwnd as long, _ byval nindex as long, _ byval dwnewlong as long) as longpublic declare function getwindowlong lib "USER32" alias "getwindowlonga" (byval hwnd as long, _ byval nindex as long) as longpublic declare function callwindowproc lib "USER32" alias "callwindowproca" (byval lpprevwndfunc as long, _ byval hwnd as long, _ byval MSG as long, _ byval wparam as long, _ byval lparam as long) as longpublic declare function registerhotkey lib "USER32" (byval hwnd as long, _ byval ID as long, _ byval fskey_modifiers as long, _ byval VK as long) as longpublic declare function unregisterhotkey lib "USER32" (byval hwnd as long, byval ID as long) as longpublic const wm_hotkey = & h312public const mod_alt = & h1public const mod_control = & h2public const mod_shift = & h4public const gwl_wndproc = (-4) private type talong ll as longend typeprivate type t2int lword as integer hword as integerend typepublic prewinproc as longpublic modifiers as long, u1_key as long, idhotkey as longpublic function compute (byval hwnd as long, _ byval MSG as long, _ byval wparam as long, _ byval lparam as long) As long if MSG = wm_hotkey then if wparam = idhotkey then dim LP as talong, I2 as t2int LP. LL = lparam lset I2 = LP if (i2.lword = modifiers) and i2.hword = u1_key then call killboom end if else = callwindowproc (prewinproc, hwnd, MSG, wparam, lparam) end Function

 

The last part is the form part. register the hotkey and hide yourself:

Private Sub Form_Load()‘this code refered from following link‘@http://www.cnblogs.com/rosesmall/archive/2012/09/19/2693707.html    preWinProc = GetWindowLong(Me.hwnd, GWL_WNDPROC)    Call SetWindowLong(Me.hwnd, GWL_WNDPROC, AddressOf CallbackWndproc)    idHotKey = 1 ‘in the range &h0000 through &hBFFF    Modifiers = MOD_ALT + MOD_SHIFT    uVirtKey = vbKeyK    Call RegisterHotKey(Me.hwnd, idHotKey, Modifiers, uVirtKey)    Call Me.HideEnd SubPrivate Sub Form_Unload(Cancel As Integer)    Call SetWindowLong(Me.hwnd, GWL_WNDPROC, preWinProc)    Call UnregisterHotKey(Me.hwnd, uVirtKey)End Sub

 

Work done! In addition, forgive me for the compilation, because I can't remember the website of your article, so I cannot post it here.

Show off with a picture:

I can finally beat my classmates, but unfortunately I have graduated...

PS: I almost forgot about it. It is best to register another hotkey (such as ALT + Shift + q) to close myself. Otherwise, you may forget its existence if the form is hidden. Orz is not required because it is in debugging mode.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.