{
rxcallback_t userfunc;
unsigned long offset, len;
+ struct aim_tlvlist_t *tlvlist;
+ struct aim_tlv_t *tlv;
+ char *modname;
offset = aimutil_get32(data);
len = aimutil_get32(data+4);
- faimdprintf(sess, 1, "data at 0x%08lx (%d bytes) requested\n", offset, len);
+ if(rx->commandlen > 0x12) { /* XXX right len? */
+ tlvlist = aim_readtlvchain(data+8, datalen-8);
+
+ if((tlv = aim_gettlv(tlvlist, 0x0001, 1))) {
+ modname = malloc(tlv->length + 5);
+ memset(modname, 0, tlv->length + 5);
+ memcpy(modname, tlv->value, tlv->length);
+ strncat(modname, ".ocm", tlv->length + 5 - strlen(modname));
+ } else {
+ modname = "aim.exe";
+ }
+ } else
+ modname = "aim.exe";
+
+ faimdprintf(sess, 1, "data at 0x%08lx (%d bytes) of %s requested\n", offset, len, modname);
if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
- return userfunc(sess, rx, offset, len);
+ return userfunc(sess, rx, offset, len, modname);
return 0;
}
return 1;
}
-static int getaimdata(unsigned char *buf, int buflen, unsigned long offset)
+static int getaimdata(unsigned char *buf, int buflen, unsigned long offset, char *modname)
{
FILE *f;
- if (!(f = fopen(aimbinarypath, "r"))) {
+ char *filename;
+ int len;
+
+ len = strlen(aimbinarypath)+1+strlen(modname)+1;
+
+ if(!(filename = malloc(len))) {
+ dperror("memrequest: malloc");
+ return -1;
+ }
+
+ memset(filename,0, len);
+ memcpy(filename, aimbinarypath, strlen(aimbinarypath));
+ filename[strlen(filename)] = '/';
+ strncat(filename, modname, len - strlen(filename));
+
+ if (!(f = fopen(filename, "r"))) {
dperror("memrequest: fopen");
return -1;
}
va_list ap;
unsigned long offset, len;
unsigned char *buf;
+ char *modname;
va_start(ap, command);
offset = va_arg(ap, unsigned long);
len = va_arg(ap, unsigned long);
+ modname = va_arg(ap, char *);
va_end(ap);
if (!(buf = malloc(len))) {
return 0;
}
- if (aimbinarypath && (getaimdata(buf, len, offset) == len)) {
+ if (aimbinarypath && (getaimdata(buf, len, offset, modname) == len)) {
- dvprintf("memrequest: sending %ld bytes from 0x%08lx in %s...\n", len, offset, aimbinarypath);
+ dvprintf("memrequest: sending %ld bytes from 0x%08lx in \"%s/%s\"...\n", len, offset, aimbinarypath, modname);
aim_sendmemblock(sess, command->conn, offset, len, buf);
} else {
- dprintf("memrequest: unable to use AIM binary, sending defaults...\n");
+ dvprintf("memrequest: unable to use AIM binary (\"%s/%s\"), sending defaults...\n", aimbinarypath, modname);
aim_sendmemblock(sess, command->conn, offset, len, NULL);