Jump to content

Calling WinAPI from AutoIt


Recommended Posts

Hi guys :)

Recently I've been trying to get used to the external Dll calling convention of Autoit. I'm okay with basic calls, but as soon as it gets a little bit more complicated (structs, pointers, etc) - I'm dead. For fun I'm just trying to "translate" some of my older C++ projects, so I've got enough idea :P

 

So, let's see my crap :)

First the c++ code: (snippet)


  ‹P…‹Eř‹H@‰JjHhĚ   ‹UřRčî˙˙ƒÄ‹Eřéă  ˇL…ŁP…ë‹
P…‹Q‰P…ƒ=P… t6ƒ=P… t+ˇP…ƒx t ‹
P…‹Q;UôrˇP…‹H;Mđwé[˙˙˙벋Uâ˙˙  ‹E+‰EÇEü    ƒ}ü u"}   @v‹Mé   @Q‹UôRč
ü˙˙ƒÄ‰Eüƒ}ü u"}   @s‹EđP‹MÁ   @Qčĺü˙˙ƒÄ‰Eüƒ}ü u!}   @v‹UR‹E-   @Pčľü˙˙ƒÄ‰Eüƒ}ü u"}   @s‹MÁ   @Q‹URč–ű˙˙ƒÄ‰Eüƒ}ü u‹EP‹MôQč}ű˙˙ƒÄ‰Eüƒ}ü u‹UđR‹EPčdü˙˙ƒÄ‰Eüƒ}ü „”   ‹Mü‰
P…‹P…ÇdtrRˇP…Ç@    ‹
P…‹L…‰QˇP…ŁL…ÇEč    ‹

I replaced every enum/macros, so you (nor me) doesn't have to reverse them.

 

Now I want to write the equivalent Autoit code, but actually... I'm totally lost. Well, let's see what I tried to code :)

‹E��8 u!ÇEř�   ‹Mř‰
`…��‹U�Ä�‰…�ý˙˙‹Ť,ý˙˙‹Q�‹B@P‹Ť�ý˙˙Qč‡Ú˙˙�Ä�‰…�ý˙˙‹•,ý˙˙‹B�‹Ť,ý˙˙‹Q�‰�é6˙˙˙ˇh…��‰…$ý˙˙ë�‹Ť$ý˙˙‹�‰•$ý˙˙�˝$ý˙˙ �„S�  Ç…0ý˙˙� � Ť…0ý˙˙P‹Ť$ý˙˙‹Q�R˙� ���…Ŕ�„%�  ˇl…��‰…(ý˙˙ë�‹Ť(ý˙˙‹�‰•(ý˙˙�˝(ý˙˙ �„ý   ‹…(ý˙˙�x� tr‹Ť(ý˙˙‹•čý˙˙;Q�r_‹…(ý˙˙‹H��Á�9Ťčý˙˙sK‹•(ý˙˙‹…čý˙˙+B�P‹Ť(ý˙˙‹Q�Rč±ĺ˙˙�Ä��¶Ŕ‹Ť(ý˙˙�A�‰…čý˙˙Ť•0ý˙˙R‹…$ý˙˙‹H�Q˙�ś���ëz‹•(ý˙˙‹…čý˙˙;B�ri‹Ť(ý˙˙‹Q��¶B6‹Ť(ý˙˙�A�9…čý˙˙sK‹•(ý˙˙‹…čý˙˙+B��¶ČQ‹•(ý˙˙‹B�PčŇä˙˙�Ä�‹Ť(ý˙˙�A�‰…čý˙˙Ť•0ý˙˙R‹…$ý˙˙‹H�Q˙�ś���éčţ˙˙é’ţ˙˙˙�°���‰…�ý˙˙‹�l…��‰•,ý˙˙�˝,ý˙˙ �„Ď   Ť…�ý˙˙P‹Ť,ý˙˙‹Q�R‹…,ý˙˙‹H��¶Q6R‹…,ý˙˙‹H�Q˙�Ś���‹•,ý˙˙‹B��¶H6Q‹•,ý˙˙‹B�P‹Ť�ý˙˙Q˙�����‹•,ý˙˙�z� t5‹…,ý˙˙�x� t)‹Ť,ý˙˙‹Q�RčŻě˙˙�Ä�‹…,ý˙˙Ç@�    Ç… ý˙˙�   ‹Ť,ý˙˙‹�‰•�ý˙˙‹…,ý˙˙‰…�ý˙˙‹Ť�ý˙˙Qč;Ô˙˙�Ä�‹•�ý˙˙‰•,ý˙˙é$˙˙˙Ç�l…��    �˝ ý˙˙ t��=X…�� u�čŠě˙˙č�đ˙˙ˇh…��‰…$ý˙˙�˝$ý˙˙ tG‹Ť$ý˙˙‹Q�R˙�¤���‹…$ý˙˙‹�‰Ť�ý˙˙‹•$ý˙˙‰•�ý˙˙‹…�ý˙˙Pč·Ó˙˙�Ä�‹Ť�ý˙˙‰Ť$ý˙˙ë°Ç�h…��    Ç�\…��    �}� t
‹U�ˇd…��‰�ˇ`…��‹Mü3ÍčÍŘ˙˙‹ĺ]Â� ĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚU‹ě�ě��=`…�� t
ˇ`…��é    ˙�@���9E�u�3ŔéŽ   j�č3×˙˙�Ä�‰Eô‹Eô‰Eü�}ü u=ÇEř�   �}ü t�‹Mü‰Mđ‹UđRčěŃ˙˙�Ä�ÇEü    ‹EřŁ`…��Ç�d…��    ‹Eřë8‹M�Q˙�¨����ř˙u�˙�¸���‰Eřë°‹Uü‹E�‰B�‹Mü‹�h…��‰�‹EüŁh…��3Ŕ‹ĺ]Â� ĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚU‹ě�ě$‰Mô‹E�‹�Áé��á��á�t/‹Uô�z� t�‹E�‹�Áé��á�‰Měë�‹U�‹�Áč��ŕ�‰Eě‹Mě‰Mäë,‹Uô�: t�‹E�‹�Áé��á�‰Mčë�‹U�‹�Áč��ŕ�‰Eč‹Mč‰Mä‹Uä‰UÜ‹E܉Eř‹M�‹�Áâ�Áú�‰Uđ‹Eř+Eđ‰Eŕ‹M�‹�Áę��â��†¬   ‹E�‹�Áé��á�‹U�Š�
�E˙�¶M˙Š‘°Q���Uţ�¶Eţ�ŕ��Eř‰Eř�¶Mţ�á�tu‹U�‹�Áč��ŕ�‹M�ŠT���Uý�¶Eý�ŕ��ř�uK�¶M˙�áŔ   u�‹Uř�Â�‰Uřë4�¶E˙%Ŕ   �ř@u�‹Mř�Á�‰Mřë��¶U˙�âŔ   �ú€   u    ‹Eř�Ŕ�‰Eř‹Mř+Mđ‰Mŕ‹EřP‹M�Q‹U�RčsŃ˙˙�Ä��}đ t$‹EŕP‹MđQ‹UÜR‹E�P‹M�Q‹Môč[Ó˙˙‹Uô‹J�‰�‹U�‹�Áč��ŕ��ŕ�t�‹Mô‹Q�‹�÷Ř‹Mô‹Q�‰�‹E�‹�Áé��á��á�t�‹Uô‹B�Ç ˙˙˙˙‹E��Eř‹ĺ]Â� ĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚU‹ěQ‰Mü‹E�P‹M�Q‹U�R‹MüčvŐ˙˙¸�   Áŕ ‹M��¶��Ť�Ő A��‰E�‹M��Á�Q‹U��Â�R‹E�P‹U�‹Mü‹B�˙Đ‹ĺ]Â� ĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚU‹ě�ě�‰Mđ¸�   Áŕ �E�‰EěÇEü    ‹Mě�ľ�‰UôÇEř    ‹Eô‹M�ŤT��‹Eđ‹H�‰�ş�   kŇ ‹E��¶���ůë   uJş�   kŇ ‹E�Ć��éą�   Áá �M�‰Mü‹U�+U��Â�‹Eô+‰Eř‹Mü‹Uř‰�‹Eđ‹H�Ç��   ‹E��Ŕ�ëlş�   kŇ ‹E�Ć���ą�   kÉ ‹U��¶�
�ŕ�
€   ą�   Áá ‹U���
¸�   Ńŕ�E�‰Eü‹M�+M��Á�‹Uô+щUř‹Eü‹Mř‰�‹Uđ‹B�Ç �   ‹E��Ŕ�‹ĺ]Â� ĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚU‹ěQ‰Mü‹E��Ŕ�‹ĺ]Â� ĚĚĚĚĚĚĚĚĚĚĚĚĚU‹ěQ‰Mü‹E�P‹M�Q‹U�R‹Müč†Ó˙˙¸�   Áŕ ‹M��¶��Ť�Ő¨I��‰E�‹M��Á�Q‹U��Â�R‹E�P‹U�‹Mü‹B�˙Đ‹ĺ]Â� ĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚU‹ěQ‰Mü‹EüÇ �   ‹M�Q‹U�R‹E�P‹MüčńË˙˙‹ĺ]Â� ĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚU‹ěQ‰Mü‹EüÇ@��   ‹M�Q‹U�R‹E�P‹Müč°Ë˙˙‹ĺ]Â� ĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚU‹ě�ě�‰Mü¸�   Áŕ ‹M��¶���â8u"ÇEôö3��ÇEř!���‹E�P‹M�QŤUôR‹Mü˙Uřë ÇEěö"� ÇEđ!���‹E�P‹M�QŤUěR‹Mü˙Uđ‹ĺ]Â� ĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚU‹ě�ě�‰Mü¸�   Áŕ ‹M��¶���â8u"ÇEô÷F��ÇEř!���‹E�P‹M�QŤUôR‹Mü˙Uřë ÇEě÷"� ÇEđ!���‹E�P‹M�QŤUěR‹Mü˙Uđ‹ĺ]Â� ĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚĚU‹ě�ě�‰Mü¸�   Áŕ ‹M��¶���ú�t�¸�   Áŕ ‹M��¶���ú%u�¸�   Ńŕ‹M�‹��‰Uř‹Eü‹H�‹Uř‹�‰�ëhą�   Áá ‹U��¶�
�ŕ8�ř�tEą�   Áá ‹U��¶�
�ŕ8�ř�t.ą�   Áá ‹U��¶�
�ŕ8�ř t�ą�   Áá ‹U��¶�
�ŕ8�ř(u�‹Mü‹Q�Ç�˙˙˙˙ÇEđ˙"� ÇEô!���‹E�P‹M�QŤUđR‹Mü˙U

Could anyone check what am I doing wrong? I made a quick DLL which hooked SetEntriesInAclA, so I can manually check the parameters, but I'm doing something really wrong, since what my autoit script calls is TOTALLY wrong. I've got no idea where to start debugging and what to correct.

 

I hope you can see my flaw :)

Thanks for every try! :)

Edited by Unc3nZureD
Link to comment
Share on other sites

Ah, facepalm... That fixed 90% of the problems. After this I realised a mistake with strings :) Parameter required a pointer to a string, but I could only pass an array of chars... Well, I solved it by creating a stuct(char[255]) and grabbed it's pointer :) Thanks. Now it seems to work.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...