Wow, Nice work on this mate!

Thanks everyone
I have a problem with the plugin now, simba just crashes for some reason when it tries to load my plugin. It is a weird problem because if i set GetFunctionCount() to return 1, it works fine but if it is set to anything higher it will somehow mess up. And i have 3 functions that i am trying to export, the addresses and pascal-type declaration are checked and they are fine.
If someone who has more experience in plugins could take a look at the source i would appreciate it.
Some things are from silentwolf's plugin so credits to him.
And yea i can change any of the other two exports to be the first and they work well when GFC returns 1 so there is no problem with any specific export. I compile it with Visual Studio C++ 2008 Express.
Code:#include <windows.h> #include <stdio.h> #define Export __declspec(dllexport) #define DelphiExport extern "C" Export #define DX_PIPE "\\\\.\\pipe\\DxInterceptPipe" DelphiExport int GetPluginABIVersion(); DelphiExport int GetFunctionCount(); DelphiExport int GetFunctionInfo(int x, void** address, char** def); DelphiExport bool DXI_Connect(); DelphiExport void DXI_Disconnect(); DelphiExport int DXI_MakeCompass(int angle); HINSTANCE inst = NULL; HANDLE hPipe = INVALID_HANDLE_VALUE; BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD reason, LPVOID reserved) { switch(reason) { case DLL_PROCESS_ATTACH: { inst = hInstance; return true; } break; case DLL_PROCESS_DETACH: { FreeLibrary(inst); } break; } return false; } DelphiExport bool DXI_Connect() { if(hPipe != INVALID_HANDLE_VALUE) return true; hPipe = CreateFile(DX_PIPE, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL); return (hPipe != INVALID_HANDLE_VALUE); } DelphiExport void DXI_Disconnect() { if(hPipe != INVALID_HANDLE_VALUE) CloseHandle(hPipe); hPipe = INVALID_HANDLE_VALUE; } DelphiExport int DXI_MakeCompass(int angle) { if(hPipe == INVALID_HANDLE_VALUE) return -1; float request = (float)angle; DWORD written = 0; BOOL success = WriteFile(hPipe, &request, 4, &written, NULL); if(!success || written != 4) { return -1; } float receive; DWORD read = 0; success = ReadFile(hPipe, &receive, 4, &read, NULL); if(success && read == 4) { return (int)receive; } return -1; } DelphiExport int GetPluginABIVersion() { return 2; } DelphiExport int GetFunctionCount() { return 1; //with 1 works well, 2 or 3 makes it crash } #pragma warning(disable : 4996) //strcpy not safe DelphiExport int GetFunctionInfo(int x, void** address, char** def) { switch(x) { case 0: { *address = GetProcAddress(inst, "DXI_MakeCompass"); strcpy(*def, "function DXI_MakeCompass(angle: integer): integer;"); } break; case 1: { *address = GetProcAddress(inst, "DXI_Connect"); strcpy(*def, "function DXI_Connect: boolean;"); } break; case 2: { *address = GetProcAddress(inst, "DXI_Disconnect"); strcpy(*def, "procedure DXI_Disconnect();"); } break; default: { char buff[128]; memset(buff, 0, 128); sprintf_s(buff, 128, "Wrong function index: %i", x); MessageBox(NULL, buff, "info", MB_OK); x = -1; } } return x; } #pragma warning(default : 4996)
Last edited by Mato; 07-09-2012 at 12:50 PM.
Use *& to assign to a pointer. Don't assign to the pointer like that. Use a reinterpret_cast if you're strict on this being C++ rather than a c-style cast. Static won't work here. That's all I changed I think?
Sorry I removed your pragma warnings because I used sprintf instead of sprintf_s.
C++ Code:#include <windows.h>
#include <stdio.h>
#define Export __declspec(dllexport)
#define DelphiExport extern "C" Export
#define DX_PIPE "\\\\.\\pipe\\DxInterceptPipe"
DelphiExport int GetPluginABIVersion();
DelphiExport int GetFunctionCount();
DelphiExport int GetFunctionInfo(int x, void*& address, char*& def);
DelphiExport bool DXI_Connect();
DelphiExport void DXI_Disconnect();
DelphiExport int DXI_MakeCompass(int angle);
HINSTANCE inst = NULL;
HANDLE hPipe = INVALID_HANDLE_VALUE;
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD reason, LPVOID reserved)
{
switch(reason)
{
case DLL_PROCESS_ATTACH:
{
inst = hInstance;
return true;
} break;
case DLL_PROCESS_DETACH:
{
FreeLibrary(inst);
} break;
}
return false;
}
DelphiExport bool DXI_Connect()
{
if(hPipe != INVALID_HANDLE_VALUE)
return true;
hPipe = CreateFile(DX_PIPE, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
return (hPipe != INVALID_HANDLE_VALUE);
}
DelphiExport void DXI_Disconnect()
{
if(hPipe != INVALID_HANDLE_VALUE)
CloseHandle(hPipe);
hPipe = INVALID_HANDLE_VALUE;
}
DelphiExport int DXI_MakeCompass(int angle)
{
if(hPipe == INVALID_HANDLE_VALUE)
return -1;
float request = (float)angle;
DWORD written = 0;
BOOL success = WriteFile(hPipe, &request, 4, &written, NULL);
if(!success || written != 4)
{
return -1;
}
float receive;
DWORD read = 0;
success = ReadFile(hPipe, &receive, 4, &read, NULL);
if(success && read == 4)
{
return (int)receive;
}
return -1;
}
DelphiExport int GetPluginABIVersion()
{
return 2;
}
DelphiExport int GetFunctionCount()
{
return 3; //with 1 works well, 2 or 3 makes it crash
}
DelphiExport int GetFunctionInfo(int x, void*& address, char*& def)
{
switch(x)
{
case 0:
{
address = reinterpret_cast<void*>(GetProcAddress(inst, "DXI_MakeCompass"));
strcpy(def, "function DXI_MakeCompass(angle: integer): integer;");
} break;
case 1:
{
address = reinterpret_cast<void*>(GetProcAddress(inst, "DXI_Connect"));
strcpy(def, "function DXI_Connect: boolean;");
} break;
case 2:
{
address = reinterpret_cast<void*>(GetProcAddress(inst, "DXI_Disconnect"));
strcpy(def, "procedure DXI_Disconnect();");
} break;
default:
{
char buff[128];
memset(buff, 0, 128);
sprintf(buff, "Wrong function index: %i", 128);
MessageBox(NULL, buff, "info", MB_OK);
x = -1;
}
}
return x;
}
![]()
Last edited by Brandon; 07-09-2012 at 01:53 PM.
I am Ggzz..
Hackintosher
Thanks for the help but it still crashes with the exact same code you have there. I think its something to do with the simba version, i see you use 990 and i use 984. Ill download the newest one too and check if it works with it.
EDIT: Yep, that was it. Works beutifully nowAgain thanks for the help.
Last edited by Mato; 07-09-2012 at 02:10 PM.
You're right.. I just downgraded Simba to 0.984, it crashes.. I got a stacktrace though but it isn't helpful in any way.
I also tried it with the new libsmart (Not remote) and it also crashes. Made my own plugin and that crashes too. Dunno why either.
With that said, use the 0.99 I guess since it works there.. The below shows 0.984 trying to load your plugin twice. Time to re-upgrade then.
For any on lookers, You can try running simba through CMD and see what I mean.. It'll look like:
Code:Microsoft Windows [Version 6.2.8400] (c) 2012 Microsoft Corporation. All rights reserved. C:\Users\Brandon>C:/Simba/Simba.exe Setting LastConfig/MainForm/RecentFiles/File10 to You cannot hide the window, since its not created by Simba No valid command line args are passed Init procedure successfully called Init procedure successfully called Init procedure successfully called Setting Extensions/ExtensionCount to 10 Adding Plugin Path: C:\Simba\Plugins\ Adding Plugin Path: C:\Simba\Plugins\ Current Simba version: 984 Latest Simba Version: 984 Loading plugin ExportPascal at C:\Simba\Plugins\ funcinfo 0 funcinfo 1 funcinfo 2 Loading plugin ExportPascal at C:\Simba\Plugins\ funcinfo 0 funcinfo 1 funcinfo 2 TApplication.HandleException Access violation Stack trace: $0040C2C8 $0053B8AE $759C7704 $759C842B $759C81ED $759C82DA $0053E505 $00421E39 $0042227F $00460513 $0042223A $0042223A C:\Users\Brandon>
I am Ggzz..
Hackintosher
Mato how does your direct x walking work? Can work out a way to get tiles or what :P Just wondering.
He uses the Geometry of runescape surface I think pretty clever and accurate
Thats right. The paths are just arrays of points relative to the path starting point. The starting point is found by searching the surface geometry for that point so it only has to find the one point once and then it can walk along the path correctly regardless of compass angle.
Same as John
It'll be amazing if you had a vague ETA
Mat
^^
I've been eager for this myself we just have to be patient as this is a one man show atm.
I'm currently looking into the basics of C++ myself so I could possible help in the near future but I have to admit the language is ugly as hell.
This might be a stupid question but what do you mean by ETA? I tried to search for it in google but didnt find anything that would fit this topic.
haha you need to watch more action films estimated time arrival
Oh yea haha :P I was linking it to some copyright related stuffBut yea i cant give a accurate ETA cause i just do this in my freetime when i feel like it
![]()
This looks familiar... Oh right!
Silentwolf left long before you were around here, John.
On another note, Silentwolf worked with OpenGL and the project was continued by Aftermath and MissSilabsoft over at MITB. Infact, an OGL plugin for Simba is still fully functional to this day; Aftermath wrote many anti-randoms through the plugin alone. So Silentwolf's leaving was not "the end of it".
Current projects:
[ AeroGuardians (GotR minigame), Motherlode Miner, Blast furnace ]
"I won't fall in your gravity. Open your eyes,
you're the Earth and I'm the sky..."
Alrite bud been tryng to play with the pluggin having trouble injecting the dll now which i wasnt befoe this version has anything changed to effect the injection process ?
Mato, how long did it take to get it this far, like, when did you start working on it?
I started with this about 1 and a half months ago. And no, nothing in that side has changed so the injection should go just like before. Can you give me a more detailed report of the problem and the log file if it ran long enough to print it so i could see where the problem is? And also did you switch to directx first, reload the game and then inject or did you just try to switch to directx after injection? If you did like last way, do it the way i said first.
ive tried it both ways
here is the log file
also i have no problems using the other DLL injects perfect with that one allows me Show id ect while this one doesnt also tried running the Compas procedure from pluggin it correcty calls the function Mouse moves ect but due to it not injecting doesnt correctly change angle.Code:HandlePipe(): Pipe succesfully created addrCallCreateDevice: 0x634A257A hWnd: 0x000402CE Hooks initialized
If the mouse moves even a bit it means that it should be running properly. Did you remember to press numpad 4 ingame so the text pops out? Im on my phone atm so i cant check but you might need to press that key for it to start updating the minimap position and angle so try that. If no luck with that, i cant do more from my phone.
Nice work on the first post but you forgot the links to download your project :P
Nice project! Subscribed and +REP. I hope this will still work after optimus though![]()
Former Name: MasterCrimeZ.
ToDo: 1. Finish my private bot 2. Make some cool bots for this community 3. Become a member
If you have any questions about scripting, feel free to PM me
There are currently 2 users browsing this thread. (0 members and 2 guests)