Solved

Converting vb codes to C

Posted on 2002-07-16
3
220 Views
Last Modified: 2010-04-15
 Open App.Path & "\test" For Binary Access Read As #1
    lngSize = LOF(1)
    If lngSize <> 204855 Then
      MsgBox "The exe has been tempered. Active failed !", vbInformation, "Error"
      Exit Function
    End If
    Get #1, , arryByte
  Close #1
 
  arryByte(1001) = arryByte(1001) + 100

  Open App.Path & "\test" For Binary Access Write As #2
    Put #2, , arryByte
  Close #2


Above is my VB codes. Can experts help me out to convert
it into C program ?

Thanks !
0
Comment
Question by:tryforum
  • 2
3 Comments
 
LVL 23

Accepted Solution

by:
Roshan Davis earned 130 total points
ID: 7164419
This is a rough work, may be have simple errors,
 Try it


#include <stdio.h>
#include <malloc.h>

void main( void )
{
   FILE *stream;
   int fhandle;
   int filesize;
   char *pchArrayByte;

   if( (stream = fopen( "test", "r" ))  )
   {
          // get handle to the file and determine file size
          fhandle = fileno(stream);
          filesize = filelength(fhandle);

          if ( 204855 != filesize )
          {
               printf("The exe has been tempered. Active failed !");
               return;
          }

          pchArrayByte = (char*)malloc(204855);

          numread = fread( pchArrayByte, sizeof( char ), 204855, stream );

          fclose(stream);

          pchArrayByte[1001] += 100;

          if( (stream = fopen( "test", "w" ))  )
          {
               fwrite( pchArrayByte, sizeof( char ), 204855, stream );

               fclose(stream);
          }
     }
}
0
 

Author Comment

by:tryforum
ID: 7170488
Let me test it out and will let you know ! Thanks
0
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 7184352
Sure
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now