diff options
| author | Juanma Barranquero | 2010-09-28 02:55:08 +0200 |
|---|---|---|
| committer | Juanma Barranquero | 2010-09-28 02:55:08 +0200 |
| commit | 0597ab06f6681758096685a0cd3ed3f24ab6e971 (patch) | |
| tree | 462befdef914fd872fd42949d804a9b0b90cfbef | |
| parent | 95b6d681b1121e1be8955aa3f79dd39098edf4cf (diff) | |
| download | emacs-0597ab06f6681758096685a0cd3ed3f24ab6e971.tar.gz emacs-0597ab06f6681758096685a0cd3ed3f24ab6e971.zip | |
nt/*.c: Use const char*; remove unused code.
* addpm.c (entry, add_registry, main):
* addsection.c (file_data, open_input_file, open_output_file)
(find_section, PTR_TO_OFFSET, copy_executable_and_add_section)
(COPY_CHUNK):
* cmdproxy.c (vfprintf, fprintf, printf, fail, warn, skip_space)
(skip_nonspace, get_next_token, search_dir, make_absolute)
(spawn, main):
* preprep.c (file_data, open_input_file, open_output_file)
(open_inout_file, find_section, PTR_TO_OFFSET, COPY_CHUNK, main):
Use const char*.
* cmdproxy.c (stdin): Don't define, not used.
(main): Don't assign remlen after last use.
| -rw-r--r-- | nt/ChangeLog | 16 | ||||
| -rw-r--r-- | nt/addpm.c | 12 | ||||
| -rw-r--r-- | nt/addsection.c | 28 | ||||
| -rw-r--r-- | nt/cmdproxy.c | 51 | ||||
| -rw-r--r-- | nt/preprep.c | 32 |
5 files changed, 75 insertions, 64 deletions
diff --git a/nt/ChangeLog b/nt/ChangeLog index 275b9bd6279..bacb207c836 100644 --- a/nt/ChangeLog +++ b/nt/ChangeLog | |||
| @@ -1,3 +1,19 @@ | |||
| 1 | 2010-09-28 Juanma Barranquero <lekktu@gmail.com> | ||
| 2 | |||
| 3 | * addpm.c (entry, add_registry, main): | ||
| 4 | * addsection.c (file_data, open_input_file, open_output_file) | ||
| 5 | (find_section, PTR_TO_OFFSET, copy_executable_and_add_section) | ||
| 6 | (COPY_CHUNK): | ||
| 7 | * cmdproxy.c (vfprintf, fprintf, printf, fail, warn, skip_space) | ||
| 8 | (skip_nonspace, get_next_token, search_dir, make_absolute) | ||
| 9 | (spawn, main): | ||
| 10 | * preprep.c (file_data, open_input_file, open_output_file) | ||
| 11 | (open_inout_file, find_section, PTR_TO_OFFSET, COPY_CHUNK, main): | ||
| 12 | Use const char*. | ||
| 13 | |||
| 14 | * cmdproxy.c (stdin): Don't define, not used. | ||
| 15 | (main): Don't assign remlen after last use. | ||
| 16 | |||
| 1 | 2010-09-22 Juanma Barranquero <lekktu@gmail.com> | 17 | 2010-09-22 Juanma Barranquero <lekktu@gmail.com> |
| 2 | 18 | ||
| 3 | * configure.bat: Err out when the argument of --cflags contains | 19 | * configure.bat: Err out when the argument of --cflags contains |
diff --git a/nt/addpm.c b/nt/addpm.c index de09fd5382c..719573de373 100644 --- a/nt/addpm.c +++ b/nt/addpm.c | |||
| @@ -67,8 +67,8 @@ DdeCallback (UINT uType, UINT uFmt, HCONV hconv, | |||
| 67 | 67 | ||
| 68 | static struct entry | 68 | static struct entry |
| 69 | { | 69 | { |
| 70 | char *name; | 70 | const char *name; |
| 71 | char *value; | 71 | const char *value; |
| 72 | } | 72 | } |
| 73 | env_vars[] = | 73 | env_vars[] = |
| 74 | { | 74 | { |
| @@ -85,7 +85,7 @@ env_vars[] = | |||
| 85 | }; | 85 | }; |
| 86 | 86 | ||
| 87 | BOOL | 87 | BOOL |
| 88 | add_registry (char *path) | 88 | add_registry (const char *path) |
| 89 | { | 89 | { |
| 90 | HKEY hrootkey = NULL; | 90 | HKEY hrootkey = NULL; |
| 91 | int i; | 91 | int i; |
| @@ -178,7 +178,7 @@ add_registry (char *path) | |||
| 178 | 178 | ||
| 179 | for (i = 0; i < (sizeof (env_vars) / sizeof (env_vars[0])); i++) | 179 | for (i = 0; i < (sizeof (env_vars) / sizeof (env_vars[0])); i++) |
| 180 | { | 180 | { |
| 181 | char * value = env_vars[i].value ? env_vars[i].value : path; | 181 | const char * value = env_vars[i].value ? env_vars[i].value : path; |
| 182 | 182 | ||
| 183 | if (RegSetValueEx (hrootkey, env_vars[i].name, | 183 | if (RegSetValueEx (hrootkey, env_vars[i].name, |
| 184 | 0, REG_EXPAND_SZ, | 184 | 0, REG_EXPAND_SZ, |
| @@ -198,8 +198,8 @@ main (int argc, char *argv[]) | |||
| 198 | int shortcuts_created = 0; | 198 | int shortcuts_created = 0; |
| 199 | int com_available = 1; | 199 | int com_available = 1; |
| 200 | char modname[MAX_PATH]; | 200 | char modname[MAX_PATH]; |
| 201 | char *prog_name; | 201 | const char *prog_name; |
| 202 | char *emacs_path; | 202 | const char *emacs_path; |
| 203 | char *p; | 203 | char *p; |
| 204 | int quiet = 0; | 204 | int quiet = 0; |
| 205 | HRESULT result; | 205 | HRESULT result; |
diff --git a/nt/addsection.c b/nt/addsection.c index 78457ec0ee8..94087044bc2 100644 --- a/nt/addsection.c +++ b/nt/addsection.c | |||
| @@ -37,9 +37,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. | |||
| 37 | 37 | ||
| 38 | PIMAGE_NT_HEADERS | 38 | PIMAGE_NT_HEADERS |
| 39 | (__stdcall * pfnCheckSumMappedFile) (LPVOID BaseAddress, | 39 | (__stdcall * pfnCheckSumMappedFile) (LPVOID BaseAddress, |
| 40 | DWORD FileLength, | 40 | DWORD FileLength, |
| 41 | LPDWORD HeaderSum, | 41 | LPDWORD HeaderSum, |
| 42 | LPDWORD CheckSum); | 42 | LPDWORD CheckSum); |
| 43 | 43 | ||
| 44 | #undef min | 44 | #undef min |
| 45 | #undef max | 45 | #undef max |
| @@ -50,15 +50,15 @@ PIMAGE_NT_HEADERS | |||
| 50 | /* File handling. */ | 50 | /* File handling. */ |
| 51 | 51 | ||
| 52 | typedef struct file_data { | 52 | typedef struct file_data { |
| 53 | char *name; | 53 | const char *name; |
| 54 | unsigned long size; | 54 | unsigned long size; |
| 55 | HANDLE file; | 55 | HANDLE file; |
| 56 | HANDLE file_mapping; | 56 | HANDLE file_mapping; |
| 57 | unsigned char *file_base; | 57 | unsigned char *file_base; |
| 58 | } file_data; | 58 | } file_data; |
| 59 | 59 | ||
| 60 | int | 60 | int |
| 61 | open_input_file (file_data *p_file, char *filename) | 61 | open_input_file (file_data *p_file, const char *filename) |
| 62 | { | 62 | { |
| 63 | HANDLE file; | 63 | HANDLE file; |
| 64 | HANDLE file_mapping; | 64 | HANDLE file_mapping; |
| @@ -90,7 +90,7 @@ open_input_file (file_data *p_file, char *filename) | |||
| 90 | } | 90 | } |
| 91 | 91 | ||
| 92 | int | 92 | int |
| 93 | open_output_file (file_data *p_file, char *filename, unsigned long size) | 93 | open_output_file (file_data *p_file, const char *filename, unsigned long size) |
| 94 | { | 94 | { |
| 95 | HANDLE file; | 95 | HANDLE file; |
| 96 | HANDLE file_mapping; | 96 | HANDLE file_mapping; |
| @@ -146,7 +146,7 @@ get_unrounded_section_size (PIMAGE_SECTION_HEADER p_section) | |||
| 146 | 146 | ||
| 147 | /* Return pointer to section header for named section. */ | 147 | /* Return pointer to section header for named section. */ |
| 148 | IMAGE_SECTION_HEADER * | 148 | IMAGE_SECTION_HEADER * |
| 149 | find_section (char * name, IMAGE_NT_HEADERS * nt_header) | 149 | find_section (const char *name, IMAGE_NT_HEADERS *nt_header) |
| 150 | { | 150 | { |
| 151 | PIMAGE_SECTION_HEADER section; | 151 | PIMAGE_SECTION_HEADER section; |
| 152 | int i; | 152 | int i; |
| @@ -260,7 +260,7 @@ relocate_offset (DWORD offset, | |||
| 260 | #define PTR_TO_RVA(ptr) ((DWORD)(ptr) - (DWORD) GetModuleHandle (NULL)) | 260 | #define PTR_TO_RVA(ptr) ((DWORD)(ptr) - (DWORD) GetModuleHandle (NULL)) |
| 261 | 261 | ||
| 262 | #define PTR_TO_OFFSET(ptr, pfile_data) \ | 262 | #define PTR_TO_OFFSET(ptr, pfile_data) \ |
| 263 | ((unsigned char *)(ptr) - (pfile_data)->file_base) | 263 | ((unsigned const char *)(ptr) - (pfile_data)->file_base) |
| 264 | 264 | ||
| 265 | #define OFFSET_TO_PTR(offset, pfile_data) \ | 265 | #define OFFSET_TO_PTR(offset, pfile_data) \ |
| 266 | ((pfile_data)->file_base + (DWORD)(offset)) | 266 | ((pfile_data)->file_base + (DWORD)(offset)) |
| @@ -272,7 +272,7 @@ relocate_offset (DWORD offset, | |||
| 272 | static void | 272 | static void |
| 273 | copy_executable_and_add_section (file_data *p_infile, | 273 | copy_executable_and_add_section (file_data *p_infile, |
| 274 | file_data *p_outfile, | 274 | file_data *p_outfile, |
| 275 | char *new_section_name, | 275 | const char *new_section_name, |
| 276 | DWORD new_section_size) | 276 | DWORD new_section_size) |
| 277 | { | 277 | { |
| 278 | unsigned char *dst; | 278 | unsigned char *dst; |
| @@ -287,7 +287,7 @@ copy_executable_and_add_section (file_data *p_infile, | |||
| 287 | 287 | ||
| 288 | #define COPY_CHUNK(message, src, size, verbose) \ | 288 | #define COPY_CHUNK(message, src, size, verbose) \ |
| 289 | do { \ | 289 | do { \ |
| 290 | unsigned char *s = (void *)(src); \ | 290 | unsigned const char *s = (void *)(src); \ |
| 291 | unsigned long count = (size); \ | 291 | unsigned long count = (size); \ |
| 292 | if (verbose) \ | 292 | if (verbose) \ |
| 293 | { \ | 293 | { \ |
diff --git a/nt/cmdproxy.c b/nt/cmdproxy.c index 0f9bd65112d..7c68f868658 100644 --- a/nt/cmdproxy.c +++ b/nt/cmdproxy.c | |||
| @@ -43,12 +43,11 @@ extern int _snprintf (char *buffer, size_t count, const char *format, ...); | |||
| 43 | 43 | ||
| 44 | /* These routines are used primarily to minimize the executable size. */ | 44 | /* These routines are used primarily to minimize the executable size. */ |
| 45 | 45 | ||
| 46 | #define stdin GetStdHandle (STD_INPUT_HANDLE) | ||
| 47 | #define stdout GetStdHandle (STD_OUTPUT_HANDLE) | 46 | #define stdout GetStdHandle (STD_OUTPUT_HANDLE) |
| 48 | #define stderr GetStdHandle (STD_ERROR_HANDLE) | 47 | #define stderr GetStdHandle (STD_ERROR_HANDLE) |
| 49 | 48 | ||
| 50 | int | 49 | int |
| 51 | vfprintf(HANDLE hnd, char * msg, va_list args) | 50 | vfprintf (HANDLE hnd, const char * msg, va_list args) |
| 52 | { | 51 | { |
| 53 | DWORD bytes_written; | 52 | DWORD bytes_written; |
| 54 | char buf[1024]; | 53 | char buf[1024]; |
| @@ -58,7 +57,7 @@ vfprintf(HANDLE hnd, char * msg, va_list args) | |||
| 58 | } | 57 | } |
| 59 | 58 | ||
| 60 | int | 59 | int |
| 61 | fprintf(HANDLE hnd, char * msg, ...) | 60 | fprintf (HANDLE hnd, const char * msg, ...) |
| 62 | { | 61 | { |
| 63 | va_list args; | 62 | va_list args; |
| 64 | int rc; | 63 | int rc; |
| @@ -71,7 +70,7 @@ fprintf(HANDLE hnd, char * msg, ...) | |||
| 71 | } | 70 | } |
| 72 | 71 | ||
| 73 | int | 72 | int |
| 74 | printf(char * msg, ...) | 73 | printf (const char * msg, ...) |
| 75 | { | 74 | { |
| 76 | va_list args; | 75 | va_list args; |
| 77 | int rc; | 76 | int rc; |
| @@ -84,7 +83,7 @@ printf(char * msg, ...) | |||
| 84 | } | 83 | } |
| 85 | 84 | ||
| 86 | void | 85 | void |
| 87 | fail (char * msg, ...) | 86 | fail (const char * msg, ...) |
| 88 | { | 87 | { |
| 89 | va_list args; | 88 | va_list args; |
| 90 | 89 | ||
| @@ -96,7 +95,7 @@ fail (char * msg, ...) | |||
| 96 | } | 95 | } |
| 97 | 96 | ||
| 98 | void | 97 | void |
| 99 | warn (char * msg, ...) | 98 | warn (const char * msg, ...) |
| 100 | { | 99 | { |
| 101 | va_list args; | 100 | va_list args; |
| 102 | 101 | ||
| @@ -122,15 +121,15 @@ canon_filename (char *fname) | |||
| 122 | return fname; | 121 | return fname; |
| 123 | } | 122 | } |
| 124 | 123 | ||
| 125 | char * | 124 | const char * |
| 126 | skip_space (char *str) | 125 | skip_space (const char *str) |
| 127 | { | 126 | { |
| 128 | while (isspace (*str)) str++; | 127 | while (isspace (*str)) str++; |
| 129 | return str; | 128 | return str; |
| 130 | } | 129 | } |
| 131 | 130 | ||
| 132 | char * | 131 | const char * |
| 133 | skip_nonspace (char *str) | 132 | skip_nonspace (const char *str) |
| 134 | { | 133 | { |
| 135 | while (*str && !isspace (*str)) str++; | 134 | while (*str && !isspace (*str)) str++; |
| 136 | return str; | 135 | return str; |
| @@ -140,9 +139,9 @@ int escape_char = '\\'; | |||
| 140 | 139 | ||
| 141 | /* Get next token from input, advancing pointer. */ | 140 | /* Get next token from input, advancing pointer. */ |
| 142 | int | 141 | int |
| 143 | get_next_token (char * buf, char ** pSrc) | 142 | get_next_token (char * buf, const char ** pSrc) |
| 144 | { | 143 | { |
| 145 | char * p = *pSrc; | 144 | const char * p = *pSrc; |
| 146 | char * o = buf; | 145 | char * o = buf; |
| 147 | 146 | ||
| 148 | p = skip_space (p); | 147 | p = skip_space (p); |
| @@ -209,7 +208,7 @@ get_next_token (char * buf, char ** pSrc) | |||
| 209 | else | 208 | else |
| 210 | { | 209 | { |
| 211 | /* Next token is delimited by whitespace. */ | 210 | /* Next token is delimited by whitespace. */ |
| 212 | char * p1 = skip_nonspace (p); | 211 | const char * p1 = skip_nonspace (p); |
| 213 | memcpy (o, p, p1 - p); | 212 | memcpy (o, p, p1 - p); |
| 214 | o += (p1 - p); | 213 | o += (p1 - p); |
| 215 | *o = '\0'; | 214 | *o = '\0'; |
| @@ -224,9 +223,9 @@ get_next_token (char * buf, char ** pSrc) | |||
| 224 | /* Search for EXEC file in DIR. If EXEC does not have an extension, | 223 | /* Search for EXEC file in DIR. If EXEC does not have an extension, |
| 225 | DIR is searched for EXEC with the standard extensions appended. */ | 224 | DIR is searched for EXEC with the standard extensions appended. */ |
| 226 | int | 225 | int |
| 227 | search_dir (char *dir, char *exec, int bufsize, char *buffer) | 226 | search_dir (const char *dir, const char *exec, int bufsize, char *buffer) |
| 228 | { | 227 | { |
| 229 | char *exts[] = {".bat", ".cmd", ".exe", ".com"}; | 228 | const char *exts[] = {".bat", ".cmd", ".exe", ".com"}; |
| 230 | int n_exts = sizeof (exts) / sizeof (char *); | 229 | int n_exts = sizeof (exts) / sizeof (char *); |
| 231 | char *dummy; | 230 | char *dummy; |
| 232 | int i, rc; | 231 | int i, rc; |
| @@ -246,13 +245,13 @@ search_dir (char *dir, char *exec, int bufsize, char *buffer) | |||
| 246 | any file extensions. If an absolute name for PROG cannot be found, | 245 | any file extensions. If an absolute name for PROG cannot be found, |
| 247 | return NULL. */ | 246 | return NULL. */ |
| 248 | char * | 247 | char * |
| 249 | make_absolute (char *prog) | 248 | make_absolute (const char *prog) |
| 250 | { | 249 | { |
| 251 | char absname[MAX_PATH]; | 250 | char absname[MAX_PATH]; |
| 252 | char dir[MAX_PATH]; | 251 | char dir[MAX_PATH]; |
| 253 | char curdir[MAX_PATH]; | 252 | char curdir[MAX_PATH]; |
| 254 | char *p, *fname; | 253 | char *p, *path; |
| 255 | char *path; | 254 | const char *fname; |
| 256 | int i; | 255 | int i; |
| 257 | 256 | ||
| 258 | /* At least partial absolute path specified; search there. */ | 257 | /* At least partial absolute path specified; search there. */ |
| @@ -372,7 +371,7 @@ console_event_handler (DWORD event) | |||
| 372 | /* Change from normal usage; return value indicates whether spawn | 371 | /* Change from normal usage; return value indicates whether spawn |
| 373 | succeeded or failed - program return code is returned separately. */ | 372 | succeeded or failed - program return code is returned separately. */ |
| 374 | int | 373 | int |
| 375 | spawn (char * progname, char * cmdline, char * dir, int * retcode) | 374 | spawn (const char *progname, char *cmdline, const char *dir, int *retcode) |
| 376 | { | 375 | { |
| 377 | BOOL success = FALSE; | 376 | BOOL success = FALSE; |
| 378 | SECURITY_ATTRIBUTES sec_attrs; | 377 | SECURITY_ATTRIBUTES sec_attrs; |
| @@ -470,8 +469,8 @@ main (int argc, char ** argv) | |||
| 470 | /* Due to problems with interaction between API functions that use "OEM" | 469 | /* Due to problems with interaction between API functions that use "OEM" |
| 471 | codepage vs API functions that use the "ANSI" codepage, we need to | 470 | codepage vs API functions that use the "ANSI" codepage, we need to |
| 472 | make things consistent by choosing one and sticking with it. */ | 471 | make things consistent by choosing one and sticking with it. */ |
| 473 | SetConsoleCP (GetACP()); | 472 | SetConsoleCP (GetACP ()); |
| 474 | SetConsoleOutputCP (GetACP()); | 473 | SetConsoleOutputCP (GetACP ()); |
| 475 | 474 | ||
| 476 | /* Although Emacs always sets argv[0] to an absolute pathname, we | 475 | /* Although Emacs always sets argv[0] to an absolute pathname, we |
| 477 | might get run in other ways as well, so convert argv[0] to an | 476 | might get run in other ways as well, so convert argv[0] to an |
| @@ -509,7 +508,7 @@ main (int argc, char ** argv) | |||
| 509 | /* Ask command.com to create an environment block with a reasonable | 508 | /* Ask command.com to create an environment block with a reasonable |
| 510 | amount of free space. */ | 509 | amount of free space. */ |
| 511 | envsize = get_env_size () + 300; | 510 | envsize = get_env_size () + 300; |
| 512 | pass_through_args = (char **) alloca (argc * sizeof(char *)); | 511 | pass_through_args = (char **) alloca (argc * sizeof (char *)); |
| 513 | num_pass_through_args = 0; | 512 | num_pass_through_args = 0; |
| 514 | 513 | ||
| 515 | while (--argc > 0) | 514 | while (--argc > 0) |
| @@ -583,7 +582,7 @@ main (int argc, char ** argv) | |||
| 583 | 582 | ||
| 584 | if (strpbrk (cmdline, copout_chars) == NULL) | 583 | if (strpbrk (cmdline, copout_chars) == NULL) |
| 585 | { | 584 | { |
| 586 | char *args; | 585 | const char *args; |
| 587 | 586 | ||
| 588 | /* The program name is the first token of cmdline. Since | 587 | /* The program name is the first token of cmdline. Since |
| 589 | filenames cannot legally contain embedded quotes, the value | 588 | filenames cannot legally contain embedded quotes, the value |
| @@ -659,7 +658,6 @@ main (int argc, char ** argv) | |||
| 659 | _snprintf (p, remlen, " /e:%d /c %s", envsize, cmdline); | 658 | _snprintf (p, remlen, " /e:%d /c %s", envsize, cmdline); |
| 660 | else | 659 | else |
| 661 | _snprintf (p, remlen, " /c %s", cmdline); | 660 | _snprintf (p, remlen, " /c %s", cmdline); |
| 662 | remlen = maxlen - (p - buf); | ||
| 663 | cmdline = buf; | 661 | cmdline = buf; |
| 664 | } | 662 | } |
| 665 | else | 663 | else |
| @@ -696,10 +694,7 @@ main (int argc, char ** argv) | |||
| 696 | } | 694 | } |
| 697 | 695 | ||
| 698 | if (run_command_dot_com) | 696 | if (run_command_dot_com) |
| 699 | { | 697 | _snprintf (p, remlen, " /e:%d", envsize); |
| 700 | _snprintf (p, remlen, " /e:%d", envsize); | ||
| 701 | remlen = maxlen - (p - cmdline); | ||
| 702 | } | ||
| 703 | } | 698 | } |
| 704 | } | 699 | } |
| 705 | 700 | ||
diff --git a/nt/preprep.c b/nt/preprep.c index dbcc8a85682..220b0e40ce6 100644 --- a/nt/preprep.c +++ b/nt/preprep.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* Pro-process emacs.exe for profiling by MSVC. | 1 | /* Pre-process emacs.exe for profiling by MSVC. |
| 2 | Copyright (C) 1999, 2001, 2002, 2003, 2004, 2005, 2006, 2007, | 2 | Copyright (C) 1999, 2001, 2002, 2003, 2004, 2005, 2006, 2007, |
| 3 | 2008, 2009, 2010 Free Software Foundation, Inc. | 3 | 2008, 2009, 2010 Free Software Foundation, Inc. |
| 4 | 4 | ||
| @@ -37,9 +37,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. | |||
| 37 | 37 | ||
| 38 | PIMAGE_NT_HEADERS | 38 | PIMAGE_NT_HEADERS |
| 39 | (__stdcall * pfnCheckSumMappedFile) (LPVOID BaseAddress, | 39 | (__stdcall * pfnCheckSumMappedFile) (LPVOID BaseAddress, |
| 40 | DWORD FileLength, | 40 | DWORD FileLength, |
| 41 | LPDWORD HeaderSum, | 41 | LPDWORD HeaderSum, |
| 42 | LPDWORD CheckSum); | 42 | LPDWORD CheckSum); |
| 43 | 43 | ||
| 44 | #undef min | 44 | #undef min |
| 45 | #undef max | 45 | #undef max |
| @@ -50,15 +50,15 @@ PIMAGE_NT_HEADERS | |||
| 50 | /* File handling. */ | 50 | /* File handling. */ |
| 51 | 51 | ||
| 52 | typedef struct file_data { | 52 | typedef struct file_data { |
| 53 | char *name; | 53 | const char *name; |
| 54 | unsigned long size; | 54 | unsigned long size; |
| 55 | HANDLE file; | 55 | HANDLE file; |
| 56 | HANDLE file_mapping; | 56 | HANDLE file_mapping; |
| 57 | unsigned char *file_base; | 57 | unsigned char *file_base; |
| 58 | } file_data; | 58 | } file_data; |
| 59 | 59 | ||
| 60 | int | 60 | int |
| 61 | open_input_file (file_data *p_file, char *filename) | 61 | open_input_file (file_data *p_file, const char *filename) |
| 62 | { | 62 | { |
| 63 | HANDLE file; | 63 | HANDLE file; |
| 64 | HANDLE file_mapping; | 64 | HANDLE file_mapping; |
| @@ -90,7 +90,7 @@ open_input_file (file_data *p_file, char *filename) | |||
| 90 | } | 90 | } |
| 91 | 91 | ||
| 92 | int | 92 | int |
| 93 | open_output_file (file_data *p_file, char *filename, unsigned long size) | 93 | open_output_file (file_data *p_file, const char *filename, unsigned long size) |
| 94 | { | 94 | { |
| 95 | HANDLE file; | 95 | HANDLE file; |
| 96 | HANDLE file_mapping; | 96 | HANDLE file_mapping; |
| @@ -120,7 +120,7 @@ open_output_file (file_data *p_file, char *filename, unsigned long size) | |||
| 120 | } | 120 | } |
| 121 | 121 | ||
| 122 | int | 122 | int |
| 123 | open_inout_file (file_data *p_file, char *filename) | 123 | open_inout_file (file_data *p_file, const char *filename) |
| 124 | { | 124 | { |
| 125 | HANDLE file; | 125 | HANDLE file; |
| 126 | HANDLE file_mapping; | 126 | HANDLE file_mapping; |
| @@ -178,7 +178,7 @@ get_unrounded_section_size (PIMAGE_SECTION_HEADER p_section) | |||
| 178 | 178 | ||
| 179 | /* Return pointer to section header for named section. */ | 179 | /* Return pointer to section header for named section. */ |
| 180 | IMAGE_SECTION_HEADER * | 180 | IMAGE_SECTION_HEADER * |
| 181 | find_section (char * name, IMAGE_NT_HEADERS * nt_header) | 181 | find_section (const char *name, IMAGE_NT_HEADERS *nt_header) |
| 182 | { | 182 | { |
| 183 | PIMAGE_SECTION_HEADER section; | 183 | PIMAGE_SECTION_HEADER section; |
| 184 | int i; | 184 | int i; |
| @@ -295,7 +295,7 @@ relocate_offset (DWORD offset, | |||
| 295 | #define PTR_TO_RVA(ptr) ((DWORD)(ptr) - (DWORD) GetModuleHandle (NULL)) | 295 | #define PTR_TO_RVA(ptr) ((DWORD)(ptr) - (DWORD) GetModuleHandle (NULL)) |
| 296 | 296 | ||
| 297 | #define PTR_TO_OFFSET(ptr, pfile_data) \ | 297 | #define PTR_TO_OFFSET(ptr, pfile_data) \ |
| 298 | ((unsigned char *)(ptr) - (pfile_data)->file_base) | 298 | ((unsigned const char *)(ptr) - (pfile_data)->file_base) |
| 299 | 299 | ||
| 300 | #define OFFSET_TO_PTR(offset, pfile_data) \ | 300 | #define OFFSET_TO_PTR(offset, pfile_data) \ |
| 301 | ((pfile_data)->file_base + (DWORD)(offset)) | 301 | ((pfile_data)->file_base + (DWORD)(offset)) |
| @@ -361,7 +361,7 @@ copy_executable_and_move_sections (file_data *p_infile, | |||
| 361 | 361 | ||
| 362 | #define COPY_CHUNK(message, src, size) \ | 362 | #define COPY_CHUNK(message, src, size) \ |
| 363 | do { \ | 363 | do { \ |
| 364 | unsigned char *s = (void *)(src); \ | 364 | unsigned const char *s = (void *)(src); \ |
| 365 | unsigned long count = (size); \ | 365 | unsigned long count = (size); \ |
| 366 | printf ("%s\n", (message)); \ | 366 | printf ("%s\n", (message)); \ |
| 367 | printf ("\t0x%08x Offset in input file.\n", s - p_infile->file_base); \ | 367 | printf ("\t0x%08x Offset in input file.\n", s - p_infile->file_base); \ |
| @@ -766,7 +766,7 @@ main (int argc, char **argv) | |||
| 766 | PIMAGE_NT_HEADERS nt_header; | 766 | PIMAGE_NT_HEADERS nt_header; |
| 767 | file_data in_file, out_file; | 767 | file_data in_file, out_file; |
| 768 | char out_filename[MAX_PATH], in_filename[MAX_PATH]; | 768 | char out_filename[MAX_PATH], in_filename[MAX_PATH]; |
| 769 | char *ptr; | 769 | const char *ptr; |
| 770 | 770 | ||
| 771 | strcpy (in_filename, argv[1]); | 771 | strcpy (in_filename, argv[1]); |
| 772 | strcpy (out_filename, argv[2]); | 772 | strcpy (out_filename, argv[2]); |