I want to call SHFileOperation
using code injection. My code works fine while calling simple
functions like MessageBox
from user32.dll
, but won't while calling ShFileOperation
from shell32.dll
.
I'll post the part of the code that I think has the problem. I know the problem is in the struct implementation.
Here is the image of RemoteInfo value:
http://www.freeimagehosting.net/uploads/219d79fc30.jpg
//Structure type LPSHFILEOPSTRUCT = ^SHFILEOPSTRUCT; SHFILEOPSTRUCT = packed record Wnd: HWND; wFunc: UINT; pFrom: PAnsiChar; pTo: PAnsiChar; fFlags: FILEOP_FLAGS; fAnyOperationsAborted: BOOL; hNameMappings: Pointer; lpszProgressTitle: PAnsiChar; end; //Remote Info type TRemoteInfo = record LoadLibrary: function(lpLibFileName: PChar): HMODULE; stdcall; GetProcAddress: function(hModule: HMODULE; lpProcName: LPCSTR): FARPROC; stdcall; shf: SHFILEOPSTRUCT; ; Kernel32: array[0..20] of Char; shell32: array[0..20] of Char; SHFileOperationA: array[0..20] of Char; Fromlpbuff: array[0..20] of char; //Source path Tolpbuff: array[0..20] of Char; //Des Path end; //Initialize .... ZeroMemory(@RemoteInfo, SizeOf(RemoteInfo)); RemoteInfo.shf.Wnd := 0; RemoteInfo.shf.wFunc := FO_COPY; RemoteInfo.shf.pFrom := @remoteInfo.Fromlpbuff; RemoteInfo.shf.pto := @remoteInfo.tolpbuff; lstrcpy(RemoteInfo.shf.pFrom, 'e:\1.jpg' + #0#0); lstrcpy(RemoteInfo.shf.pto, 'f:\1.jpg' + #0#0); RemoteInfo.shf.fFlags := FOF_ALLOWUNDO; RemoteInfo.shf.fAnyOperationsAborted := false; ....