Jump to content

Help to Convert


0000
 Share

Recommended Posts

This is C++ function, which I need to convert to AutoIt...

void TakeRes()
{
  HRSRC hRes;
  HGLOBAL hRLoad;
  HANDLE hFile;
  char *cRes;
  DWORD BWritten,SzRsc;
  hRes = FindResource(NULL, MAKEINTRESOURCE(101), TEXT("S")); 
  if(hRes == NULL)
    MessageBox(NULL,"Error","Error",MB_OK);
  hRLoad = LoadResource(NULL,hRes);
  cRes = (char*)LockResource(hRLoad);
  SzRsc = SizeofResource(NULL,hRes); 

  hFile = CreateFile("Loader.exe",GENERIC_WRITE,0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
  WriteFile(hFile,cRes,SzRsc,&BWritten,NULL);
  CloseHandle(hFile);
}

I tried convert it, using this topic:

http://www.autoitscript.com/forum/index.php?showtopic=66538

But it didint help me so much, there is another information which maybe will need:

http://msdn.microsoft.com/en-us/library/ms648042.asp

Because most errors I get with: hRes = FindResource(NULL, MAKEINTRESOURCE(101), TEXT("S"));

Thanks, 0000.

Link to comment
Share on other sites

Ok, I will check it.

Im training to make .exe dropper, which would be Unique from checkbox'es, like user selects his favorite answers, and my .exe generates .exe with his answers, and he can show that .exe to his friends or smthere :)

But I cant get Main.exe inside generator, because I still cant fix Resource Reader ;(

Edited by Guest
Link to comment
Share on other sites

Func SetFilePointer($hFile,$nOffset, $nMethod = 0)

$Callresult = DllCall("kernel32.dll", "int", "SetFilePointer", "ptr", $hFile, "long", $nOffset,"ptr", 0, "dword", $nMethod) ; FILE_BEGIN

Return $Callresult[0]

EndFunc

Func WriteFile($hFile,$lpBuffer,$nNumberOfBytesToWrite)

Local $pRead = DllStructCreate("dword")

$Callresult = DllCall("kernel32.dll", "int", "WriteFile", "int", $hFile,"long",$lpBuffer,"int", $nNumberOfBytesToWrite,"ptr",DllStructGetPtr($pRead),"int", 0)

Return $Callresult[0]

EndFunc

Could somebody say, if I made correct functions, with DllCall, because basiclly, its not working for me, and I don't know what here can be bad :).

Also try to fix it :o

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...