Richard Robertson Posted July 19, 2008 Share Posted July 19, 2008 Have you looked at his code? He's getting the value of AutoIt plugin function parameters and each one is a string that is a character long. He needs to take these and put them into a string. On second thought, forget a conversion. Why don't you just accept all four characters as a string parameter? That makes a lot more sense. Link to comment Share on other sites More sharing options...
cppman Posted July 19, 2008 Share Posted July 19, 2008 (edited) Have you looked at his code? He's getting the value of AutoIt plugin function parameters and each one is a string that is a character long. He needs to take these and put them into a string. On second thought, forget a conversion. Why don't you just accept all four characters as a string parameter? That makes a lot more sense.I'm still kind of confused on what he is trying to do. He is trying to convert an array of 1 character + 1 null character strings, into 1 string? char *IV[4] = {"a", "b", "c", "d"}; char *result = new char[5]; memset(result, 0, sizeof(char) * 5); for (int i = 0; i < 4; i++) result[i] = *IV[i]; // and when you're done.. delete[] result; result is now the string. expandcollapse popupchar encrypted_buffer[10000]; //big chunk of space :D some packets hit more than 9k you know. char *IV[4]; AU3_PLUGIN_DEFINE(enc) { AU3_PLUGIN_VAR *s2au3; char *packet; int packetlen; IV[0] = AU3_GetString(&p_AU3_Params[0]); IV[1] = AU3_GetString(&p_AU3_Params[1]); IV[2] = AU3_GetString(&p_AU3_Params[2]); IV[3] = AU3_GetString(&p_AU3_Params[3]); packet = AU3_GetString(&p_AU3_Params[4]); packetlen = AU3_GetInt32(&p_AU3_Params[5]); InitEncryption(51); char buf2send[10240]; //10k ok buf space becuase packets can get bigger than 9k char result[10240] = {0}; //result of encryption // allocate our return string... char *au3ready = new char[packetlen + 1]; memset(au3ready, 0, sizeof(char) * (packetlen + 1)); strcpy(buf2send,packet); mc_encrypt(IV, buf2send, result, packetlen); strcpy(au3ready, result); /* for (int i=0;i<packetlen;i++){ au3ready[i] = result[i]; } */ s2au3 = AU3_AllocVar (); AU3_SetString(s2au3,au3ready); *p_AU3_Result = s2au3; *n_AU3_ErrorCode = 0; *n_AU3_ExtCode = 0; } ? Edited July 19, 2008 by cppman Miva OS Project Link to comment Share on other sites More sharing options...
mmavipc Posted July 20, 2008 Author Share Posted July 20, 2008 I'm still kind of confused on what he is trying to do. He is trying to convert an array of 1 character + 1 null character strings, into 1 string? char *IV[4] = {"a", "b", "c", "d"}; char *result = new char[5]; memset(result, 0, sizeof(char) * 5); for (int i = 0; i < 4; i++) result[i] = *IV[i]; // and when you're done.. delete[] result; result is now the string. expandcollapse popupchar encrypted_buffer[10000]; //big chunk of space :D some packets hit more than 9k you know. char *IV[4]; AU3_PLUGIN_DEFINE(enc) { AU3_PLUGIN_VAR *s2au3; char *packet; int packetlen; IV[0] = AU3_GetString(&p_AU3_Params[0]); IV[1] = AU3_GetString(&p_AU3_Params[1]); IV[2] = AU3_GetString(&p_AU3_Params[2]); IV[3] = AU3_GetString(&p_AU3_Params[3]); packet = AU3_GetString(&p_AU3_Params[4]); packetlen = AU3_GetInt32(&p_AU3_Params[5]); InitEncryption(51); char buf2send[10240]; //10k ok buf space becuase packets can get bigger than 9k char result[10240] = {0}; //result of encryption // allocate our return string... char *au3ready = new char[packetlen + 1]; memset(au3ready, 0, sizeof(char) * (packetlen + 1)); strcpy(buf2send,packet); mc_encrypt(IV, buf2send, result, packetlen); strcpy(au3ready, result); /* for (int i=0;i<packetlen;i++){ au3ready[i] = result[i]; } */ s2au3 = AU3_AllocVar (); AU3_SetString(s2au3,au3ready); *p_AU3_Result = s2au3; *n_AU3_ErrorCode = 0; *n_AU3_ExtCode = 0; } ?au3ready cant be an array [size="10"]Pure Au3 crypt funcs(I'm currently also working on making a dll from this)[/size][Y] Be more active in the community[Y] Get 200 posts[N] Get 300 posts[N] Make a Topic in the example scripts forum with at least 50 replies.People who currently hate me:ValikSmOke_N Link to comment Share on other sites More sharing options...
mmavipc Posted July 20, 2008 Author Share Posted July 20, 2008 au3ready cant be an arrayI;m trying to turn result into 1 string [size="10"]Pure Au3 crypt funcs(I'm currently also working on making a dll from this)[/size][Y] Be more active in the community[Y] Get 200 posts[N] Get 300 posts[N] Make a Topic in the example scripts forum with at least 50 replies.People who currently hate me:ValikSmOke_N Link to comment Share on other sites More sharing options...
cppman Posted July 20, 2008 Share Posted July 20, 2008 (edited) I;m trying to turn result into 1 stringStrings are arrays. A string is simply an array of characters ending with a '\0' (NULL character).So au3ready is a single string. Edited July 20, 2008 by cppman Miva OS Project Link to comment Share on other sites More sharing options...
Richard Robertson Posted July 20, 2008 Share Posted July 20, 2008 Are you saying you don't know enough about C++ to know a character array? You shouldn't be writing plugins. ^^; I suggested this though. IV[0] = AU3_GetString(&p_AU3_Params[0]); IV[1] = AU3_GetString(&p_AU3_Params[1]); IV[2] = AU3_GetString(&p_AU3_Params[2]); IV[3] = AU3_GetString(&p_AU3_Params[3]); Instead of that, just send one parameter that is a string, four characters long. Then you can read one parameter into IV. Link to comment Share on other sites More sharing options...
mmavipc Posted July 20, 2008 Author Share Posted July 20, 2008 (edited) current code: AU3_PLUGIN_DEFINE(enc) { AU3_PLUGIN_VAR *pMyResult; char *packet; int packetlen; IV[0] = AU3_GetString(&p_AU3_Params[0]); IV[1] = AU3_GetString(&p_AU3_Params[1]); IV[2] = AU3_GetString(&p_AU3_Params[2]); IV[3] = AU3_GetString(&p_AU3_Params[3]); packet = AU3_GetString(&p_AU3_Params[4]); packetlen = AU3_GetInt32(&p_AU3_Params[5]); InitEncryption(51); char buf2send[10240]; //10k ok buf space becuase packets can get bigger than 9k char result[10240]; //result of encryption char *au3ready; strcpy(buf2send,packet); mc_encrypt(IV, buf2send, result, packetlen); for (int i=0;i<packetlen;i++){ au3ready[i] = result[i]; } pMyResult = AU3_AllocVar (); AU3_SetString(pMyResult,au3ready); *p_AU3_Result = s2au3; *n_AU3_ErrorCode = 0; *n_AU3_ExtCode = 0; } compile log: Compiler: Default compiler Building Makefile: "D:\Documents and Settings\Maverick\Desktop\thumb\AutoitMSEmu\dllpaser\Makefile.win" Executing make... make.exe -f "D:\Documents and Settings\Maverick\Desktop\thumb\AutoitMSEmu\dllpaser\Makefile.win" all g++.exe -c main.cpp -o main.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include" main.cpp: In function `int enc(int, const AU3_PLUGIN_VAR*, AU3_PLUGIN_VAR**, int*, int*)': main.cpp:78: error: cannot convert `char**' to `char*' in argument passing make.exe: *** [main.o] Error 1 Execution terminated line 78: mc_encrypt(IV, buf2send, result, packetlen); Edit: tried changing au3ready to a pointer and it worked. Edited July 20, 2008 by mmavipc [size="10"]Pure Au3 crypt funcs(I'm currently also working on making a dll from this)[/size][Y] Be more active in the community[Y] Get 200 posts[N] Get 300 posts[N] Make a Topic in the example scripts forum with at least 50 replies.People who currently hate me:ValikSmOke_N Link to comment Share on other sites More sharing options...
mmavipc Posted July 20, 2008 Author Share Posted July 20, 2008 Is there anyway to turn a *(pointer) into a non-*(non-pointer)? [size="10"]Pure Au3 crypt funcs(I'm currently also working on making a dll from this)[/size][Y] Be more active in the community[Y] Get 200 posts[N] Get 300 posts[N] Make a Topic in the example scripts forum with at least 50 replies.People who currently hate me:ValikSmOke_N Link to comment Share on other sites More sharing options...
Valik Posted July 20, 2008 Share Posted July 20, 2008 Yes. By reading a text-book (preferably on C\C++). Link to comment Share on other sites More sharing options...
mmavipc Posted July 21, 2008 Author Share Posted July 21, 2008 Yes. By reading a text-book (preferably on C\C++).muttley [size="10"]Pure Au3 crypt funcs(I'm currently also working on making a dll from this)[/size][Y] Be more active in the community[Y] Get 200 posts[N] Get 300 posts[N] Make a Topic in the example scripts forum with at least 50 replies.People who currently hate me:ValikSmOke_N Link to comment Share on other sites More sharing options...
cppman Posted July 21, 2008 Share Posted July 21, 2008 You dereference a pointer like this:int *ptr ...; int val = *ptr; Miva OS Project Link to comment Share on other sites More sharing options...
Richard Robertson Posted July 21, 2008 Share Posted July 21, 2008 Technically you could also use ptr[0] to get the value. I'm sure the subscript operator would just add confusion to normal code though. Link to comment Share on other sites More sharing options...
Valik Posted July 21, 2008 Share Posted July 21, 2008 You dereference a pointer like this: int *ptr ...; int val = *ptr;Why do you continue to help somebody who has virtually no knowledge and based on their reaction doesn't seem very willing put forth the effort necessary to get some knowledge on their own? Sometimes, despite the fact that we can help, we just have to say, "No, you need to learn that on your own." Helping people every time and never forcing them to help themselves, that's not really a good thing. Link to comment Share on other sites More sharing options...
cppman Posted July 22, 2008 Share Posted July 22, 2008 Why do you continue to help somebody who has virtually no knowledge and based on their reaction doesn't seem very willing put forth the effort necessary to get some knowledge on their own? Sometimes, despite the fact that we can help, we just have to say, "No, you need to learn that on your own." Helping people every time and never forcing them to help themselves, that's not really a good thing.It isn't exactly easy to figure out what to search for when you are just starting out. It really helps to work off of examples. Thus, I gave him a "dead" example, and a term, in italics, to search for. Miva OS Project Link to comment Share on other sites More sharing options...
Valik Posted July 22, 2008 Share Posted July 22, 2008 It isn't exactly easy to figure out what to search for when you are just starting out. It really helps to work off of examples. Thus, I gave him a "dead" example, and a term, in italics, to search for.It's pretty easy to know what to search for when starting out. They're called books. There's a sticky in this forum to them. The OP isn't at the point where they need to search for anything, they are at the point where they need basic knowledge covered by any text book. Link to comment Share on other sites More sharing options...
mmavipc Posted July 22, 2008 Author Share Posted July 22, 2008 (edited) new code: AU3_PLUGIN_DEFINE(enc) { AU3_PLUGIN_VAR *s2au3; char *packet; int packetlen; IV[0] = AU3_GetString(&p_AU3_Params[0]); IV[1] = AU3_GetString(&p_AU3_Params[1]); IV[2] = AU3_GetString(&p_AU3_Params[2]); IV[3] = AU3_GetString(&p_AU3_Params[3]); packet = AU3_GetString(&p_AU3_Params[4]); packetlen = AU3_GetInt32(&p_AU3_Params[5]); InitEncryption(51); char buf2send[10240]; //10k ok buf space becuase packets can get bigger than 9k char result[10240]; //result of encryption char *au3ready; strcpy(buf2send,packet); mc_encrypt(*IV, buf2send, result, packetlen); for (int i=0;i<packetlen;i++){ au3ready[i] = result[i]; } s2au3 = AU3_AllocVar (); AU3_SetString(s2au3,au3ready); *p_AU3_Result = s2au3; *n_AU3_ErrorCode = 0; *n_AU3_ExtCode = 0; return AU3_PLUGIN_OK; } Can anyone tell me why this crashes autoit? edit: dummies 4TW except that it crashes autoit...... Edit: just noticed soo many replies happened while I was getting a book and reading muttley Edited July 22, 2008 by mmavipc [size="10"]Pure Au3 crypt funcs(I'm currently also working on making a dll from this)[/size][Y] Be more active in the community[Y] Get 200 posts[N] Get 300 posts[N] Make a Topic in the example scripts forum with at least 50 replies.People who currently hate me:ValikSmOke_N Link to comment Share on other sites More sharing options...
Richard Robertson Posted July 22, 2008 Share Posted July 22, 2008 What was the error returned? Something Valik suggested to me when I was writing a plugin before was to run the code in it's own program for testing. That way you can use all the debugging tools. Link to comment Share on other sites More sharing options...
mmavipc Posted July 22, 2008 Author Share Posted July 22, 2008 What was the error returned? Something Valik suggested to me when I was writing a plugin before was to run the code in it's own program for testing. That way you can use all the debugging tools.it does that windows crash thingy and autoit.exe exits with this errorcode !>12:17:40 AutoIT3.exe ended.rc:-1073741819 the testing proggy i used was: $hplugin = PluginOpen("dll.dll") ConsoleWrite("lolz" & @lf) ConsoleWrite(enc(0x00,0x00,0x00,0x00,"lolz",4) & @lf) PluginClose($hplugin) How would I run the plugin in it's own program? [size="10"]Pure Au3 crypt funcs(I'm currently also working on making a dll from this)[/size][Y] Be more active in the community[Y] Get 200 posts[N] Get 300 posts[N] Make a Topic in the example scripts forum with at least 50 replies.People who currently hate me:ValikSmOke_N Link to comment Share on other sites More sharing options...
Richard Robertson Posted July 22, 2008 Share Posted July 22, 2008 You copy the code from one file, to another. Write a small user interface so you can test it. Set it to debug mode for whatever IDE you use. Link to comment Share on other sites More sharing options...
Valik Posted July 22, 2008 Share Posted July 22, 2008 The OP knows less than the basics here. Writing re-usable code is well outside the capabilities demonstrated thus far... Link to comment Share on other sites More sharing options...
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