Hackhers Posted October 5, 2015 Posted October 5, 2015 (edited) Hey there, Since DllCall is using stdcall as I see in forums I'm trying to change cdecl to stdcall but It still not working. Any ideas ?Auto IT code:$serverLib = DllOpen(@ScriptDir & "/TestServer.dll") $result = DllCall($serverLib, "str", "ultraDil", "str", "TR") DllClose($serverLib) C++ Code:expandcollapse popup#include <stdio.h> #include <windows.h> #include <iostream> #include <string.h> #define EOF (-1) #define debug true std::wstring s2ws(const std::string& s) { int len; int slength = (int)s.length() + 1; len = MultiByteToWideChar(CP_ACP, 0, s.c_str(), slength, 0, 0); wchar_t* buf = new wchar_t[len]; MultiByteToWideChar(CP_ACP, 0, s.c_str(), slength, buf, len); std::wstring r(buf); delete[] buf; return r; } char diller[6][3] = { "TR", "NE", "DE", "FR", "IT", "ES" }; char TRyazi[10][32] = { { "Bele" }, { "sla" }, { "rdu" }, { "Buyu" }, { "klan" }, { "" }, { "" }, { "" }, { "" }, { "" } }; TCHAR fileName[MAX_PATH + 1]; #ifdef __cplusplus // If used by C++ code, extern "C" { // we need to export the C interface #endif __declspec(dllexport) char* __stdcall ultraDil(char* a) { std::string dil(a); std::string dondur(""); std::string ekle("|"); int i = 0; for (i = 0; i < 10; i++) { if (dil.compare("TR") == 0) { dondur += TRyazi[i]; } dondur += ekle; } char * cstr = new char[dondur.length() + 1]; std::strcpy(cstr, dondur.c_str()); return cstr; } #ifdef __cplusplus } #endif Edited October 5, 2015 by Hackhers
Danyfirex Posted October 5, 2015 Posted October 5, 2015 witch compiler do you use? Saludos Danysys.com AutoIt... Reveal hidden contents UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut
Hackhers Posted October 5, 2015 Author Posted October 5, 2015 On 10/5/2015 at 12:19 AM, Danyfirex said: witch compiler do you use? SaludosI use Visual Studio 2015 but Platform toolset is Visual Studio 2010
Danyfirex Posted October 5, 2015 Posted October 5, 2015 This work for me.$serverLib = DllOpen(@ScriptDir & "/testserver.dll") $result = DllCall($serverLib, "str", "_ultraDil@4", "str", "TR") MsgBox(0,"",$result[0]) DllClose($serverLib)Saludos Danysys.com AutoIt... Reveal hidden contents UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut
Danyfirex Posted October 5, 2015 Posted October 5, 2015 Did you mean this: __declspec(dllexport) char* __cdecl ultraDil(char* a)the call look like this:$serverLib = DllOpen(@ScriptDir & "/prueba.dll") $result = DllCall($serverLib, "str:cdecl", "ultraDil", "str", "TR") MsgBox(0,"",$result[0]) DllClose($serverLib)Saludos Danysys.com AutoIt... Reveal hidden contents UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut
Hackhers Posted October 5, 2015 Author Posted October 5, 2015 (edited) On 10/5/2015 at 12:34 AM, Danyfirex said: This work for me.$serverLib = DllOpen(@ScriptDir & "/testserver.dll") $result = DllCall($serverLib, "str", "_ultraDil@4", "str", "TR") MsgBox(0,"",$result[0]) DllClose($serverLib)SaludosYep thanks, Part that I don't know is why we use @4 at "_ultraDil@4" part,And Is there any way to use it like that by changing the c++ code:$serverLib = DllOpen(@ScriptDir & "/testserver.dll") $result = DllCall($serverLib, "str", "ultraDil", "str", "TR") MsgBox(0,"",$result[0]) DllClose($serverLib) Edited October 5, 2015 by Hackhers
Danyfirex Posted October 5, 2015 Posted October 5, 2015 Search for C++ DLL Export: Decorated/Mangled names I really never care about funtion name. Saludos Danysys.com AutoIt... Reveal hidden contents UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut
trancexx Posted October 5, 2015 Posted October 5, 2015 (edited) The most usual way is to add definition file (again usually called "Exports.def"). Google a bit, it's been beaten to death many times before. Super simple. Edited October 6, 2015 by trancexx eng. ♡♡♡ . eMyvnE
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now