Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1101425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:02:02+00:00 2026-05-17T01:02:02+00:00

#include <Windows.h> void memfrob(void * s, size_t n) { char *p = (char *)

  • 0
#include <Windows.h>

void memfrob(void * s, size_t n)
{
 char *p = (char *) s;

 while (n-- > 0)
  *p++ ^= 42;
}

int main()
{
 memfrob("C:\\Program Files\\***\***\\***\***\\***", 30344);
}

There’s my code. If you can’t tell, I’m not sure what I’m doing. I’ve Googled for about an hour and I haven’t seen an example of how to use memfrob(), which is probably why I’m so lost. I’m trying to pass it the name of the file and then the size of the file in bytes, but my program just crashes.

Alright, this is what I have right now:

#include <Windows.h>
#include <stdio.h>

int count = 0;
FILE* pFile = 0;
long Size = 0;

void *memfrob(void * s, size_t n)
{
    char *p = (char *) s;

    while (n-- > 0)
        *p++ ^= 42;
    return s;
}

int main()
{
    fopen_s(&pFile, "C:\\Program Files\\CCP\\EVE\\lib\\corelib\\nasty.pyj", "r+");
    fseek(pFile, 0, SEEK_END);
    Size = ftell(pFile);
    char *buffer = (char*)malloc(Size);
    memset(buffer, 0, Size);
    fread(buffer, Size, 1, pFile);
    fclose(pFile);
    memfrob(buffer, Size);
    fopen_s(&pFile, "C:\\Program Files\\CCP\\EVE\\lib\\corelib\\nasty.pyj", "w+");
    fwrite(buffer, Size, 1, pFile);
    fclose(pFile);
}

In my debugger, it seems that fread is not writing anything to buffer, and my ending file is just 2A over and over, which is 00 xor’d with 42. So can I get another hint?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T01:02:03+00:00Added an answer on May 17, 2026 at 1:02 am

    You need to pass memfrob a piece of memory containing the contents of the file, rather than the name of the file. It’s crashing because you’re passing in a buffer of read-only memory, and then trying to modify it.

    Investigate the open and read I/O functions, or alternatively fopen and fread. Your mainline should look something like:

    int main() {
        // open file 
        // find size of file
        // allocate buffer of that size
        // read contents of file into the buffer
        // close the file
        // call memfrob on the buffer
        // do what you want with the file
        // free the buffer
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There is a self deleting program #include <windows.h> #include <stdio.h> void main(int argc, char*
The following C program: #include <stdio.h> int main(void) { printf("%u %u %u\n",sizeof "",sizeof(""+0),sizeof(char *));
#include <Windows.h> #include <iostream> using namespace std; int main(void) { unsigned char* pFoo =
below is the code Code : #include <stdio.h> int main(void) { int ch; while((ch
windows.h is included, code: #include <windows.h> int main() { HANDLE hToken; DWORD dwSize; TOKEN_ELEVATION_TYPE
#include <Windows.h> #include <cstdio> const int KEY=111; void encryptStrA(char* sometext) { int length; length=strlen(sometext);
#ifndef UNICODE #define UNICODE #endif #include <stdio.h> #include <Windows.h> int main(void) { TCHAR greeting[50]
I was under the impression that this code #include <windows.h> #include <stdio.h> int WINAPI
include "stdafx.h" #include <windows.h> #include <tchar.h> #include <stdio.h> void _tmain(int argc, TCHAR *argv[]) {
I saw a piece of code like this: #include <windows.h> static VOID (WINAPI *

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.