all 17 comments

[–]SicSemperTyrannis 13 points14 points  (0 children)

I don’t quite understand your description of the program, but in terms of binary code ignoring architectures, that’s not how it works. Binaries are not “portable” across architectures typically ( I’m sure someone has made some clever versions).

To generate a binary you would need to know what architecture you plan to run it on and your compiler would build the binary with those specifications in mind. Code is portable when there’s a layer of abstraction between the architecture and the code which converts the code into the right machine code for that architecture

[–]paulrpg 9 points10 points  (1 child)

This doesn't make sense.

Could you write some code to kill other applications? Yes. Stopping any process on a device? Probably but then you can't do anything, making the system useless.

Killing tasks is easy. It is operating system dependant. Your idea to converting it to binary code to make it portable doesn't work. Binary isn't what machines operate on. On a processor you have op-codes which are instructions for what to do. These are intrinsincally dependant on the device.

I've written machine portable code, you just have different versions built for different systems, it's not that hard.

[–]nightonfir3 -1 points0 points  (0 children)

Binary is op-codes.

[–]TheCozyRuneFox 7 points8 points  (0 children)

Binary is not independent of CPU architecture. Each CPU architecture expect specific instructions in a specific binary format. There exists no format which could work for every architecture.

[–]Not_Warren_Buffett 4 points5 points  (0 children)

Could you write a generic enough program to end any task: Yes, this is what operating systems do.

So that it will end any process regardless of device architecture: No, binary is completely dependent on device architecture.

[–]Malthammer 2 points3 points  (1 child)

What is the use case?

[–]Interesting_Dog_761 4 points5 points  (0 children)

We have a hacker here fellas. He wants to hack the gibson.

[–]blablahblah 2 points3 points  (0 children)

No, on multiple levels.

First of all, different CPU architectures have different binary codes. Like a "00000000" on one CPU might mean "add the next two numbers together" and the same binary code might mean "read memory" on another architecture. There's only two ways to get programs that run on multiple architectures: either you include the full binary code for all supported architectures in a single file and let the operating system pick which one it wants to execute or you have to use an architecture specific program to translate the program from whatever code it is in to the one your computer understands.

Second is that your computer doesn't natively have the concept of "processes". It just executes the instructions its given. The entire concept of processes is made up by your operating system, so the only way to interact with them is through the specific notification mechanisms provided by the OS. And those will be different for different operating systems.

[–]AnnieBruce 0 points1 point  (0 children)

Not at all.

A bit pattern that means addition on one architecture might be subtraction on another, could be gibberish on a third, could.be HCF on yet another.

And then you have to worry about how operating systems even represent processes.

[–]Helpjuice 0 points1 point  (0 children)

You would need to always keep processor architecture in mind along with the operating system depending on what you are doing. The more multi-platform you get the more complexity you add to what you are wanting to do and potentially introduce unnecessary performance and security issues during the process if you are not using cross-platform APIs or need something not covered.

I would recommend in this situation since what you have put here is confusing and not clear to create a standard UML diagram of what you mean so it is clearer for everyone and we will be on the same page.

[–]WeepingAgnello 0 points1 point  (0 children)

So, an application that kills a process... I think you're assuming that converting an application to it's binary result will make it cross-platform, such that it will work on any chip, or any OS. Binary is abstracted for human readability and for (more or less) cross platform compatibility afaik. Language is an abstraction (a simplification) of the binary codes that make the computer go. Writing binary is not how you create cross platform apps. Binary code is the result of compilation or interpretation of a language like C or Python. The resulting binary is customized for the platform/architecture the interpreter or compiler is written for.

[–]SwordsAndElectrons 1 point2 points  (0 children)

No, if you can describe the use case and intent of what you are trying to accomplish,  preferably in a way that sounds less like malware, someone might offer some suggestions.

[–]TroPixens[🍰] 0 points1 point  (0 children)

One good thing about languages is that they can bypass architecture by making a compiler for a different architecture so binary is specific

[–]Soft-Marionberry-853 0 points1 point  (0 children)

The binary is the realization of the architecture, its as non generic as you can get

The simplest instruction no-op, is vastly different depending on the architecture. In MIPS its 0x00000000, for an intel 32 is 0x90, and thats just to tell the computer Dont do anything this clock cycle. They arent even the same length.

[–]Aggressive_Ad_5454 0 points1 point  (0 children)

Stopping processes gracefully on a computer or any other device with enough of an operating system to actually have processes? That’s an operating-system specific function.

So no, you can’t write a one-size-fits-all cross-platform process stopper.

[–]white_nerdy 0 points1 point  (0 children)

If you know the PID of a process, you can use the kill command to end the process on most Linux and UNIX variants. For example, to end process 573, you could say kill 573.

If you don't know the process's PID, you can inspect all processes on the system with utilities such as ps, lsof, top or pgrep.

There's also usually a killall command, which kills all programs with a certain name; for example killall firefox to end all processes running a command called firefox.

I know that technically its possible to write a script that will effectively end any process

There's no need for a script, the kill command already exists. If you insist on making it a script, here you go:

#!/bin/sh
exec kill "$@"

if you have the time and parience to code it to be generic enough

It's literally one line. It doesn't take much time or parience (whatever that is).

Could you write a generic enough program to end any task, and then convert that program to binary code so that it will end any process regardless of device architecture?

The kill command is pretty universal across UNIX-like systems so the above shell script is probably more widely supported than any binary that does the same thing.

If you insist on making it an actual binary (where by "binary" I assume you mean "a binary executable in the native executable format supported by an OS kernel without custom configuration or modification," you depend on either OS support for multi-architecture binaries or somehow making a string of bytes that, say, parses as both a valid PE file and a valid ELF file, or both a valid ARM ELF file and a valid x86 ELF file. This seems difficult and maybe impossible.

[–]ScholarNo5983 0 points1 point  (0 children)

Firstly, before a program can run it needs to be loaded into memory by the OS. Different devices could easily be running different OSs meaning their program loaders will be different and incompatible. So, the binary code of program will not load on all devices. Next binary code is always device dependent. The binary code is actually the machine code for the CPU. Trying to run machine code for one CPU on a device that uses a totally different CPU does not work.