topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Thursday October 31, 2024, 6:50 pm
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: Invalid Address specified to RtlFreeHeap( 00820000, 001596D8 )  (Read 18415 times)

drgreen

  • Participant
  • Joined in 2005
  • *
  • default avatar
  • Posts: 6
    • View Profile
    • Donate to Member
Found a problem, when I call EncryptString or DecryptString using my own char array, it looks as if your dll is trying to free it or something.

In the debug window I see:
HEAP[m220.exe]: Invalid Address specified to RtlFreeHeap( 00820000, 001596D8 )
HEAP[m220.exe]: Invalid Address specified to RtlFreeHeap( 00820000, 00159728 )

m220 is the name of my program,  here is some example code which will reproduce the same error:


#include <stdio.h>
#include <windows.h>

char * (__stdcall *DecryptString)(char *, char *,char *, int);
char * (__stdcall *EncryptString)(char *, char *,char *, int);
void  (__stdcall *FreeResultString)(char *);


int main(int argc, char **argv)
{
  char *v;
  char result[1024];
  HINSTANCE hDll;

  if ( argc == 1 )
  {
    fprintf(stdout,"usage: %s [key] [text]\n",argv[0]);
    exit(1);
  }


  hDll = LoadLibrary("mircryption.dll");
  if ( hDll == NULL)
  {
    fprintf(stdout,"Error loading dll %u\n",GetLastError());
    exit(1);
  }
  DecryptString = (void *)GetProcAddress(hDll,"DecryptString");
  EncryptString = (void *)GetProcAddress(hDll,"EncryptString");
  FreeResultString = (void *)GetProcAddress(hDll,"FreeResultString");

  if ( DecryptString == NULL || EncryptString == NULL || FreeResultString == NULL )
  {
    fprintf(stdout,"Error finding exported functions from the dll!\n");
    exit(1);
  }

  v = EncryptString(argv[1],argv[2],result,sizeof(result));
  fprintf(stdout,"%s\n",v);
  getchar();
}

debug this program, and youll end up at an int 3 breakpoint inside ntdll.dll
It also looks as if your dll is leaking memory?

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,913
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Invalid Address specified to RtlFreeHeap( 00820000, 001596D8 )
« Reply #1 on: June 13, 2005, 09:52 PM »
thx.. seems this was a bug, drgreen and i found the problem, it was in simpleexports.cpp,
the code was calling free(XXX) when it should have been calling delete [] XXX.

(free what you alloc, delete what you new)!

drgreen

  • Participant
  • Joined in 2005
  • *
  • default avatar
  • Posts: 6
    • View Profile
    • Donate to Member
Re: Invalid Address specified to RtlFreeHeap( 00820000, 001596D8 )
« Reply #2 on: June 13, 2005, 10:16 PM »
 :up:  That solves the problem,  I think its time you uploaded a fresh beta! :)