Skip to content

Instantly share code, notes, and snippets.

@john-peterson
Last active August 21, 2023 14:46
Show Gist options
  • Save john-peterson/13d64f0122b4e64b616438d0daee7412 to your computer and use it in GitHub Desktop.
Save john-peterson/13d64f0122b4e64b616438d0daee7412 to your computer and use it in GitHub Desktop.
#include <windows.h>
#include <iostream>
using namespace std;
typedef unsigned int(__stdcall *f_cb)(const char*,int,int,const char*);
typedef unsigned int(__stdcall *f_wcb)(f_cb,int,char**);
typedef int(__cdecl *f_unarc)(f_cb,const char*,const char*,const char*,const char*,const char*,const char*,const char*,const char*,const char*,const char*);
unsigned int __stdcall cb(const char* a,int b, int c, const char* d) {
cout << (char*)a << " " << b << " " << c << (char*)d << endl;
return 0;
}
unsigned int __stdcall wcb(f_cb cb,int argc, char** argv) {
cout << "cb " << hex << cb << " param count " << argc << endl;
for(int i=0;i<argc;i++){
cout << (char*)argv[i] << endl;
}
const char *n="";
cb(n,0,0,n);
return 0;
}
int main(int argc, char** argv) {
HINSTANCE h = LoadLibrary("unarc.dll");
if (!h) {
cout << "unarc.dll not found" << endl;
return 0;
}
f_unarc unarc = (f_unarc)GetProcAddress(h, "FreeArcExtract");
if (!unarc) {
cout << "FreeArcExtract not found" << endl;
return 0;
}
if( argc <7) {
cout << "usage a.exe a b c d e f" << endl;
return 0;
}
char const *a1=argv[1];
char const *a2=argv[2];
char const *a3=argv[3];
char const *a4=argv[4];
char const *a5=argv[5];
char const *a6=argv[6];
const char *n="";
unarc(&cb,a1,a2,a3,a4,a5,a6,n,n,n,n);
return 0;
}
@john-peterson
Copy link
Author

john-peterson commented Aug 19, 2023

https://web.archive.org/web/20150211054442/http://freearc.org/download/testing/FreeArc-console-0.67-alpha-win32.exe

https://web.archive.org/web/20160121022318/http://freearc.org/download/InnoSetup/ISFreeArcExtract%20v.4.0.rar

touch a b c
wine arc.exe create test.arc a b c
wine unarc.exe l test.arc

sudo dpkg --add-architecture i386
sudo apt update
sudo apt install wine32 gdb-mingw-w64 gdb-mingw-w64-target g++-mingw-w64-i686 

wine /usr/share/win32/gdbserver.exe localhost:12345 a.exe x abc.arc&i686-w64-mingw32-gdb -q -ex "target remote localhost:12345"

GOOD LUCK

@john-peterson
Copy link
Author

john-peterson commented Aug 21, 2023

HA!

i686-w64-mingw32-g++ unarc.cpp 

wine a.exe x -o+ -dp. -w. -- abc.arc|head
filename 0 0a
filename 0 0b
filename 0 0c
quit 0 0

ls a b c
a  b  c

wine a.exe l -- abc.arc "" "" ""|head
total_files 3 0
origsize 0 0
compsize 0 0
quit 0 0

Confused about the wrapper

I think this worked by accident

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment