Home Man
Search
Today's Posts
Register

Post questions about C, C++, Java, SQL, and other programming languages here.

Embed text in C code

Tags
c code, code, embed, shell scripts, text

👤 Login to reply

 
Thread Tools Search this Thread
# 1  
Old 1 Week Ago
Embed text in C code

I hope c coding is ok here.

I am fairly new at c coding.

I simply want to embed some text in the executable.

I tried this but can't find the text using Ghex.

Code:
#include <stdio.h>
const char * S = "andrew";

int main()
{
printf("Hello World!\n");
return 0;
}

# 2  
Old 1 Week Ago
Code:
#include <stdio.h>

const char *str = "andrew";

int main()
{
  printf("Hello World! %s\n", str);
  return 0;
}

The Following User Says Thank You to milhan For This Useful Post:
drew77 (1 Week Ago)
# 3  
Old 1 Week Ago
Quote:
Originally Posted by drew77
I simply want to embed some text in the executable.

I tried this but can't find the text using Ghex.

Code:
#include <stdio.h>
const char * S = "andrew";

int main()
{
printf("Hello World!\n");
return 0;
}

Text strings won't be embedded in the code, they will reside in the data segment.
# 4  
Old 1 Week Ago
Ok.

Can I get it embedded in the code segment where it will be near the top when viewed with a hex editor?
# 5  
Old 6 Days Ago
Tricky. Most large-scale architectures separate data and code.

What you might be able to find is the value of the pointer.

Code:
#include <stdio.h>

int main(void)
{
        printf("%p\n", "fixed text");
}

Compile and run that and you'll be given a hexadecimal value. Search for that value in the code segment and you won't find the text itself, but you'll find something which uses it.
👤 Login to reply

« Previous Thread | Next Thread »
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Embed tcl in ksh93 script gio001 UNIX for Advanced & Expert Users 3 02-19-2013 12:37 PM
How to embed commands in awk search delphys Shell Programming and Scripting 2 12-16-2011 12:57 PM
embed a separator after each word in a text file venu Shell Programming and Scripting 9 11-18-2011 11:41 AM
Embed function in if statement msarro Shell Programming and Scripting 1 07-21-2011 05:05 PM
Why can't embed commands like fg or bg in a shell script ? qiulang Shell Programming and Scripting 4 04-20-2009 10:28 AM
php youtube style embed code mainegate Web Programming 0 11-18-2008 10:44 PM
does any one know free web server to embed in my app umen Programming 4 03-18-2008 10:47 AM
How To Embed Image In output file minut UNIX for Dummies Questions & Answers 0 09-03-2007 04:50 AM
How to embed shell script in a awk code rajbal Shell Programming and Scripting 8 09-28-2006 04:19 PM


All times are GMT -4. The time now is 01:43 AM.

Unix & Linux Forums Content Copyrightę1993-2018. All Rights Reserved.
UNIX.COM Login
Username:
Password:  
Show Password