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?
 
ThievingSixConnect With a Mentor Commented:
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
 
ThievingSixCommented:
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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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

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

ziolko.
0
 
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
All Courses

From novice to tech pro — start learning today.