-
-
Save mvanotti/7fcbe9d83758e532d197 to your computer and use it in GitHub Desktop.
When running foo.go on windows 8 64 bits it panics.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "foo.h" | |
void bar(process_handle_t handle, bool *b, memory_region_t *region) { | |
region->start_address = 100; | |
*b = true; | |
} | |
void open_process(process_handle_t *handle) { | |
*handle = 0x201; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
// #include "foo.h" | |
// #cgo CFLAGS: -std=c99 | |
import "C" | |
import "runtime" | |
import "fmt" | |
type process struct { | |
handle C.process_handle_t | |
pid int | |
} | |
func main() { | |
var b int = 3 | |
var p process | |
C.open_process(&(p.handle)) | |
foo(p, b) | |
} | |
func foo(p process, a int) { | |
fmt.Println(a) | |
var isAvailable C.bool | |
var region C.memory_region_t | |
runtime.GC() | |
//fmt.Println(isAvailable, region) | |
C.bar(p.handle, &isAvailable, ®ion) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef __FOO__ | |
#define __FOO__ | |
#include <windows.h> | |
#include <stdbool.h> | |
#include <stdlib.h> | |
typedef unsigned long long memory_address_t; | |
typedef HANDLE process_handle_t; | |
typedef struct { | |
memory_address_t start_address; | |
size_t length; | |
} memory_region_t; | |
void bar(process_handle_t handle, bool *b, memory_region_t *region); | |
void open_process(process_handle_t *handle); | |
#endif // __FOO__ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment