C translation

Hi Experts,
Need C Translation

#include <string.h>
#include <windows.h>
int PASCAL WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow )
{
H_Intr99; HINSTANCE
H_Intr99=NULL;
typedef long (__stdcall * INTR99)(char *,char*,char *[]);
INTR99 intr99;
H_Intr99=LoadLibrary("INTR32.DLL");
if (H_Intr99==NULL)
{
// MessageBox
}
intr99=(INTR99)GetProcAddress(H_Intr99,"intr99");
if (intr99 == NULL)
{
// MessageBox
}
char int_ot[160];
memset(int_ot,'0',150);
intr99("B10000003C1200D011150T0101",int_ot,0);
FreeLibrary(H_Intr99);
return 1;
}
LVL 2
phadarAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dagan HooverDeveloperCommented:
Hmm, best I could do I'm not all too familiar in C.
type
  TINTR99 = function(cChar,cChar2 : String; sChar: Pointer): LongInt; stdcall;
 
 
procedure TForm1.FormCreate(Sender: TObject);
var
  h_Intr99 : LongWord;
  INTR99 : TINTR99;
  int_ot : String;
begin
  SetLength(int_ot,160);
  h_Intr99 := LoadLibrary('INTR32.DLL');
  If h_Intr99 = 0 Then
    begin
    // ShowMessage
  end;
  INTR99 := GetProcAddress(H_Intr99,'intr99');
  If @INTR99 = nil Then
    begin
    // ShowMessage
  end;
  FillChar(int_ot,150,0);
  INTR99('B10000003C1200D011150T0101',int_ot,nil);
  FreeLibrary(h_Intr99);
end;

Open in new window

0
ziolkoCommented:
I'm afraid C doesn't know string type, so I would use PChar

ziolko.
0
phadarAuthor Commented:
Well I tried every possible variables, String, PChar and I get AV when calling the function :(
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

ziolkoCommented:
how did you call this function?

btw. isn't this dLL some kind of trojan?

ziolko.
0
Dagan HooverDeveloperCommented:
Try this, also when calling GetProcAddress it's case sensitive. Make sure that 'intr99' are all lowercase.
type
  TINTR99 = function(cChar,cChar2 : PChar; sChar: Pointer): LongInt; stdcall;
 
 
procedure TForm1.FormCreate(Sender: TObject);
var
  h_Intr99 : LongWord;
  INTR99 : TINTR99;
  int_ot : String;
begin
  SetLength(int_ot,160);
  h_Intr99 := LoadLibrary('INTR32.DLL');
  If h_Intr99 = 0 Then
    begin
    // ShowMessage
  end;
  INTR99 := GetProcAddress(H_Intr99,'intr99');
  If @INTR99 = nil Then
    begin
    // ShowMessage
  end;
  FillChar(int_ot,150,0);
  INTR99('B10000003C1200D011150T0101',PChar(int_ot)^,nil);
  FreeLibrary(h_Intr99);
end;

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
phadarAuthor Commented:
Well no ziolko, this dll is not a trojan. I've heard of a trojan with the same name but that dll is legimate.
GetProcAddress is lowercase and I don't get error at this stage.
The AV raise when calling the function.
But finally I managed to call the function without any AV.
The problem seems to be Fiiling Char ( FillChar(int_ot,150,0) ), I removed that one and it works fine now.
INTR99('B10000003C1200D011150T0101',PChar(int_ot),nil);

Anyway, Thanks ziolko for your time and comments.
Philip
0
ziolkoCommented:
>>I've heard of a trojan with the same name but that dll is legimate.
ok then I would suggest renaming this DLL as it can be recognized as possible threat to system by most anti-virus software.

ziolko.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.