Link to home
Start Free TrialLog in
Avatar of phadar
phadar

asked on

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;
}
Avatar of ThievingSix
ThievingSix
Flag of United States of America image

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

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

ziolko.
Avatar of phadar
phadar

ASKER

Well I tried every possible variables, String, PChar and I get AV when calling the function :(
how did you call this function?

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

ziolko.
ASKER CERTIFIED SOLUTION
Avatar of ThievingSix
ThievingSix
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of phadar

ASKER

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
>>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.