Results 1 to 3 of 3

Thread: help...I wanna read a file and then make changes and save it

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2000
    Posts
    10
    Hi there!

    I'm trying to read a file in...it actually is a prefs file for another program. When i open it in a txt reader it looks like garbage. when I open it with this file viewer called hackmaster it tells me that the file is ascii. How do I open the file and make sense of it?

    Thanx!

    -Deano
    -Deano

  2. #2
    Member
    Join Date
    Nov 1999
    Location
    panama
    Posts
    57
    what is the extension *.txt, *.cmd, *.???

    use open namefile for binary as #1
    or open namefile for input as #1

    depending the extension but is binary your read the line
    and the line convert to ascii
    carlosapv
    [email protected]
    THE TRUTH IS OUT THERE
    Visual Basic 6.0 SP5

  3. #3

    Thread Starter
    New Member
    Join Date
    Apr 2000
    Posts
    10
    there is no extension on the file....it is just called UserData I am really ignorant on the whole issue. Here is what it looks like in a when i open it with wordpad:

     ÿãÏÿü

    like I said it looks like a bunch of garbage.

    when I open it in the other viewer...i get this info about the file:

    TYPE: ASCII
    OFFSET: 00000000

    i know i'm probably not making any sense cause i don't really know what i'm talking about. If you could bear with me i'd really appreciate it...i've pretty much hit a wall with this.

    btw...you can message me on AIM @ remote4177 thanks again!

    ALSO...i found a piece of c code that does the read part of what i am trying to do. Here it is:

    #include <stdio.h>
    #include <stdlib.h>

    #define USERDATA_NAME_OFFSET 0x211
    #define USERDATA_LOGIN_OFFSET 0x299
    #define USERDATA_PASSWORD_OFFSET 0x2BD
    #define USERDATA_PRIVS_OFFSET 0x004

    /***************************************/
    #define CAN_DOWNLOAD_FILES 0x00000020
    #define CAN_UPLOAD_FILES 0x00000040
    #define CAN_UPLOAD_ANYWHERE 0x40000000
    #define CAN_DELETE_FILES 0x00000080
    #define CAN_RENAME_FILES 0x00000010
    #define CAN_MOVE_FILES 0x00000008
    #define CAN_COMMENT_FILES 0x08000000
    #define CAN_CREATE_FOLDERS 0x00000004
    #define CAN_DELETE_FOLDERS 0x00000002
    #define CAN_RENAME_FOLDERS 0x00000001
    #define CAN_MOVE_FOLDERS 0x00008000
    #define CAN_COMMENT_FOLDERS 0x04000000
    #define CAN_VIEW_DROP_BOXES 0x02000000
    #define CAN_MAKE_ALIASES 0x01000000
    /***************************************/
    #define CAN_CREATE_USERS 0x00000200
    #define CAN_DELETE_USERS 0x00000100
    #define CAN_READ_USERS 0x00800000
    #define CAN_MODIFY_USERS 0x00400000
    #define CAN_GET_USER_INFO 0x80000000
    #define CAN_DISCONNECT_USERS 0x00020000
    #define CANNOT_BE_DISCONNECT 0x00010000
    /***************************************/
    #define CAN_READ_NEWS 0x00080000
    #define CAN_POST_NEWS 0x00040000
    /***************************************/
    #define CAN_READ_CHAT 0x00004000
    #define CAN_SEND_CHAT 0x00002000
    /***************************************/
    #define CAN_USE_ANY_NAME 0x20000000
    #define DONT_SHOW_AGREEMENT 0x10000000


    /**************prototypes***************/
    FILE *open_userdata_file(char *filename_p);
    void close_userdata_file(FILE *userdata_file_p);
    void get_account_name(char *name,FILE *userdata_file_p);
    void get_account_login(char *login,FILE *userdata_file_p);
    void get_account_password(char *password,FILE *userdata_file_p);
    void get_account_privs(int *privsdata,FILE *userdata_file_p);

    void main(int argc,char *argv[])
    {
    FILE *userdata_file;
    char name[256];
    char login[256];
    char password[256];
    int privsdata;

    if (argc<2)
    printf("Usage:\n<path to userdata file>\n");
    else
    {
    userdata_file = open_userdata_file(argv[1]);
    get_account_name(name,userdata_file);
    get_account_login(login,userdata_file);
    get_account_password(password,userdata_file);
    printf("Decoding: %s\n",argv[1]);
    printf("*-------------------------------*\n");
    printf("| Hotline UserData Decoder 0.4 |\n")
    printf("*-------------------------------*\n");
    printf("| Name: %-23s |\n",name);
    printf("| Login: %-22s |\n",login);
    printf("| Password: %-19s |\n",password);
    printf("*-------------------------------*\n");
    printf("| Account Access: |\n");
    printf("*-------------------------------*\n");
    get_account_privs(&privsdata,userdata_file);
    printf("*-------------------------------*\n");
    close_userdata_file(userdata_file);
    }
    return;
    }

    FILE *open_userdata_file(char *filename_p)
    {
    FILE *userdata_file_p;
    //possibly check for correct file type?
    if ((userdata_file_p = fopen(filename_p,"rb"))==NULL)
    {
    printf("ERROR: File %s could not be opened.\n",*filename_p);
    exit;
    }
    return userdata_file_p;
    }

    void get_account_name(char *name,FILE *userdata_file_p)
    {
    unsigned long length;

    length=0;
    fseek(userdata_file_p,USERDATA_NAME_OFFSET,0);
    length = fgetc(userdata_file_p);
    fread(name,1,length,userdata_file_p);
    name[length]=0;
    return;
    }

    void get_account_login(char *login,FILE *userdata_file_p)
    {
    unsigned long length;

    length=0;
    fseek(userdata_file_p,USERDATA_LOGIN_OFFSET,0);
    length = fgetc(userdata_file_p);
    fread(login,1,length,userdata_file_p);
    login[length]=0;
    return;
    }

    void get_account_password(char *password,FILE *userdata_file_p)
    {
    unsigned long length;
    unsigned long counter;

    length=0;
    fseek(userdata_file_p,USERDATA_PASSWORD_OFFSET,0);
    length = fgetc(userdata_file_p);
    fread(password,1,length,userdata_file_p);
    for(counter=0;counter<length;counter++)
    {
    //printf("Decoding: %d to %d\n",password[counter],255-password[counter]);
    password[counter]=255-password[counter];
    }
    password[length]=0;
    return;
    }

    void get_account_privs(int *privsdata,FILE *userdata_file_p)
    {
    fseek(userdata_file_p,USERDATA_PRIVS_OFFSET,0);
    fread(privsdata,1,4,userdata_file_p);
    //printf("Debug: %d\n",*privsdata);
    if (*privsdata&CAN_DOWNLOAD_FILES)
    printf("| Can Download Files |\n");
    if (*privsdata&CAN_UPLOAD_FILES)
    printf("| Can Upload Files |\n");
    if (*privsdata&CAN_UPLOAD_ANYWHERE)
    printf("| Can Upload Anywhere |\n");
    if (*privsdata&CAN_DELETE_FILES)
    printf("| Can Delete Files |\n");
    if (*privsdata&CAN_RENAME_FILES)
    printf("| Can Rename Files |\n");
    if (*privsdata&CAN_MOVE_FILES)
    printf("| Can Move Files |\n");
    if (*privsdata&CAN_COMMENT_FILES)
    printf("| Can Comment Files |\n");
    if (*privsdata&CAN_CREATE_FOLDERS)
    printf("| Can Create Folders |\n");
    if (*privsdata&CAN_DELETE_FOLDERS)
    printf("| Can Delete Folders |\n");
    if (*privsdata&CAN_RENAME_FOLDERS)
    printf("| Can Rename Folders |\n");
    if (*privsdata&CAN_MOVE_FOLDERS)
    printf("| Can Move Folders |\n");
    if (*privsdata&CAN_COMMENT_FOLDERS)
    printf("| Can Comment Folders |\n");
    if (*privsdata&CAN_VIEW_DROP_BOXES)
    printf("| Can View Drop Boxes |\n");
    if (*privsdata&CAN_MAKE_ALIASES)
    printf("| Can Make Aliases |\n");
    /*************************************/
    if (*privsdata&CAN_CREATE_USERS)
    printf("| Can Create Users |\n");
    if (*privsdata&CAN_DELETE_USERS)
    printf("| Can Delete Users |\n");
    if (*privsdata&CAN_READ_USERS)
    printf("| Can Read Users |\n");
    if (*privsdata&CAN_MODIFY_USERS)
    printf("| Can Modify Users |\n");
    if (*privsdata&CAN_GET_USER_INFO)
    printf("| Can Get User Info |\n");
    if (*privsdata&CAN_DISCONNECT_USERS)
    printf("| Can Disconnect Users |\n");
    if (*privsdata&CANNOT_BE_DISCONNECT)
    printf("| Cannot Be Disconnected |\n");
    /*************************************/
    if (*privsdata&CAN_READ_NEWS)
    printf("| Can Read News |\n");
    if (*privsdata&CAN_POST_NEWS)
    printf("| Can Post News |\n");
    /*************************************/
    if (*privsdata&CAN_READ_CHAT)
    printf("| Can Read Chat |\n");
    if (*privsdata&CAN_SEND_CHAT)
    printf("| Can Send Chat |\n");
    /*************************************/
    if (*privsdata&CAN_USE_ANY_NAME)
    printf("| Can Use Any Name |\n");
    if (*privsdata&DONT_SHOW_AGREEMENT)
    printf("| Don't Show Agreement |\n");
    return;
    }

    void close_userdata_file(FILE *userdata_file_p)
    {
    fclose(userdata_file_p);
    //add error checking
    return;
    }

    [Edited by deano on 04-08-2000 at 11:42 AM]
    -Deano

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width