{"id":1373,"date":"2014-07-20T23:05:03","date_gmt":"2014-07-20T21:05:03","guid":{"rendered":"http:\/\/labalec.fr\/erwan\/?p=1373"},"modified":"2018-12-16T14:44:54","modified_gmt":"2018-12-16T13:44:54","slug":"ewf-proxy-for-imdisk","status":"publish","type":"post","link":"https:\/\/labalec.fr\/erwan\/?p=1373","title":{"rendered":"EWF Proxy for ImDisk"},"content":{"rendered":"<p>In a previous <a href=\"https:\/\/labalec.fr\/erwan\/?p=1235\" target=\"_blank\" rel=\"noopener\">article<\/a>, I have shared a delphi unit for <a href=\"https:\/\/code.google.com\/p\/libewf\/\" target=\"_blank\" rel=\"noopener\">libewf<\/a>.<\/p>\n<p>Now lets code a proxy for <a href=\"http:\/\/www.ltr-data.se\/opencode.html\/#ImDisk\" target=\"_blank\" rel=\"noopener\">ImDisk <\/a>using that external libyal library to mount an EWF file.<\/p>\n<p>I initially used <a href=\"http:\/\/reboot.pro\/topic\/18958-custom-imdisk-proxy-example\/\" target=\"_blank\" rel=\"noopener\">this template<\/a> from reboot.pro and came with the below basic delphi unit.<\/p>\n<p>Once I had done that, it was pretty easy to fill in the missing parts to mount and EWF reusing my previous libewf delphi unit.<br \/>\nSee code attached.<a href=\"https:\/\/labalec.fr\/erwan\/wp-content\/uploads\/2014\/07\/proxy_EWF.zip\">proxy_EWF<\/a><\/p>\n<pre>library proxy;\r\n\r\nuses\r\n  SysUtils,\r\n  Classes,windows;\r\n\r\n{$R *.res}\r\n\r\ntype\r\n  dllread_proc = function (handle:thandle; buf:pointer; size:cardinal; offset:int64): integer; cdecl;\r\n  dllwrite_proc = function (handle:thandle; buf:pointer; size:cardinal; offset:int64): integer; cdecl;\r\n  dllclose_proc = function (handle:thandle): integer; cdecl;\r\n\r\nvar\r\nfile_handle:thandle;\r\n\r\nfunction SetFilePointerEx (hFile: THandle; lDistanceToMove: int64; lpNewFilePointer: Pointer; dwMoveMethod: DWORD): BOOL; stdcall; external 'kernel32.dll';\r\nfunction GetFileSizeEx(hFile: THandle; var lpFileSize: Int64): BOOL; stdcall; external 'kernel32.dll' name 'GetFileSizeEx';\r\n\r\nfunction my_read_proc(handle:thandle; buf:pointer; size:cardinal; offset:int64): integer; cdecl;\r\nvar\r\nbytes_read:cardinal;\r\nbegin\r\n\twriteln('Read request - size:'+inttostr(size)+' offset:'+inttostr(offset));\r\n\tSetFilePointerEx(handle, offset, nil, FILE_BEGIN);\r\n\tReadFile(handle, buf^, size, bytes_read, nil);\r\n\tresult:=bytes_read;\r\nend;\r\n\r\nfunction my_write_proc(handle:thandle; buf:pointer; size:cardinal; offset:int64): integer; cdecl;\r\nvar\r\nbytes_written:cardinal;\r\nbegin\r\n\twriteln('Write request - size:'+inttostr(size)+' offset:'+inttostr(offset));\r\n\tSetFilePointerEx(handle, offset, nil, FILE_BEGIN);\r\n\tWriteFile(handle, buf^, size, bytes_written, nil);\r\n\tresult:=bytes_written;\r\nend;\r\n\r\nfunction my_close_proc(handle:thandle): integer; cdecl;\r\nbegin\r\n\twriteln('Close request');\r\n\tCloseHandle(handle);\r\n\tresult:=0;\r\nend;\r\n\r\nfunction dllopen(filename:pchar; read_only:integer; var dllread:dllread_proc; var dllwrite:dllwrite_proc; var dllclose:dllclose_proc; var size:int64):thandle;cdecl;\r\nbegin\r\n\twriteln('File to open: '+filename);\r\n\r\n\tdllread := my_read_proc;\r\n\tdllwrite := my_write_proc;\r\n\tdllclose := my_close_proc;\r\n\r\n\tfile_handle := CreateFile(filename, GENERIC_READ or GENERIC_WRITE, FILE_SHARE_READ, nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);\r\n\tGetFileSizeEx(file_handle, size);\r\n\r\n\tresult:=file_handle;\r\nend;\r\n\r\nexports\r\n  dllopen index 1;\r\n\r\nbegin\r\nend.\r\n<\/pre>\n<p>The command lines for the proxy and ImDisk are below :<\/p>\n<p><code>devio --dll=proxy.dll;dllopen shm:test_proxy c:\\test.vmdk<\/code><br \/>\n<code>imdisk -a -t proxy -o shm -o ro -f test_proxy -m Z:<\/code><\/p>\n<p>Devio in action :<br \/>\n<a href=\"https:\/\/labalec.fr\/erwan\/wp-content\/uploads\/2014\/07\/imdisk_ewf.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-1391\" src=\"https:\/\/labalec.fr\/erwan\/wp-content\/uploads\/2014\/07\/imdisk_ewf-1024x322.png\" alt=\"imdisk_ewf\" width=\"695\" height=\"218\" srcset=\"https:\/\/labalec.fr\/erwan\/wp-content\/uploads\/2014\/07\/imdisk_ewf-1024x322.png 1024w, https:\/\/labalec.fr\/erwan\/wp-content\/uploads\/2014\/07\/imdisk_ewf-300x94.png 300w, https:\/\/labalec.fr\/erwan\/wp-content\/uploads\/2014\/07\/imdisk_ewf.png 1561w\" sizes=\"auto, (max-width: 695px) 100vw, 695px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In a previous article, I have shared a delphi unit for libewf. Now lets code a proxy for ImDisk using that external libyal library to mount an EWF file. I initially used this template from reboot.pro and came with the below basic delphi unit. Once I had done that, it was pretty easy to fill <a href='https:\/\/labalec.fr\/erwan\/?p=1373' class='excerpt-more'>[&#8230;]<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[37],"tags":[56,100],"class_list":["post-1373","post","type-post","status-publish","format-standard","hentry","category-delphi","tag-libewf-ewf-delphi","tag-libyal","category-37-id","post-seq-1","post-parity-odd","meta-position-corners","fix"],"_links":{"self":[{"href":"https:\/\/labalec.fr\/erwan\/index.php?rest_route=\/wp\/v2\/posts\/1373","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/labalec.fr\/erwan\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/labalec.fr\/erwan\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/labalec.fr\/erwan\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/labalec.fr\/erwan\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1373"}],"version-history":[{"count":5,"href":"https:\/\/labalec.fr\/erwan\/index.php?rest_route=\/wp\/v2\/posts\/1373\/revisions"}],"predecessor-version":[{"id":1947,"href":"https:\/\/labalec.fr\/erwan\/index.php?rest_route=\/wp\/v2\/posts\/1373\/revisions\/1947"}],"wp:attachment":[{"href":"https:\/\/labalec.fr\/erwan\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1373"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/labalec.fr\/erwan\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1373"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/labalec.fr\/erwan\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1373"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}